Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Calling every menu of a GVNode

 Post Reply Post Reply
Author
Message
rustEdge View Drop Down
Member
Member
Avatar

Joined: 2010 Oct 06
Location: Vancouver
Online Status: Online
Posts: 52
Post Options Post Options   Quote rustEdge Quote  Post ReplyReply Direct Link To This Post Topic: Calling every menu of a GVNode
    Posted: 2017 Jun 27 at 2:54pm

User Information:

Cinema 4D Version:   18 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

I'm trying to make some usability tools for XPresso, but I'm not finding certain items from the documentation.

What I want to do is open several GvNode popup menus via code, without the user having to do mouse operations in the XPresso Editor window.

So far the only item I've found was the NodeContextMenu() from NodeGUI, which isn't what I'm looking for. Is it possible to invoke/read the FillPortMenu() and FillPortsMenu() method in a GvNode somehow?


Edited by rustEdge - 2017 Jun 27 at 2:55pm
-------------------------
Do what you want to do, not what you think you want to do.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1381
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jun 28 at 5:54am
Hi,

actually I'm not quite sure, I understand the question or intention. Is it about getting access to the data? Presenting a menu to the user? Or executing menu items?

Anyway, it is possible to call FillPortMenu() and FillPortsMenu().
You just need to get the GvOperatorData from the GvNode via GetOperatorData().
Just don't expect too much from FillPortMenu() as a node will only fill menu entries additional to the standard four. None of the built-in nodes does this.

Furthermore GvPortDescription might also be helpful in this context, get it via GetPortDescription() from the node.

Not sure this helps...

Cheers,
Andreas
SDK Support Engineer
Back to Top
rustEdge View Drop Down
Member
Member
Avatar

Joined: 2010 Oct 06
Location: Vancouver
Online Status: Online
Posts: 52
Post Options Post Options   Quote rustEdge Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jun 28 at 7:35am
Both actually. I want to present the "Add In/Out Port" menus and after that, execute them.
GetOperatorData seems to do the trick. Here's a snippet I'm using in my GeUserArea's InputEvent method.


// "node" is a GvNode processed earlier

BaseContainer   names, ids, popupbc;
GeData          gedata;
GvOperatorData* gvopdata = node->GetOperatorData();

// get inports from node
Int32           ct       = gvopdata->FillPortsMenu( node, names, ids, ID_GV_VALUE_TYPE_NONE, GV_PORT_INPUT, GV_MESSAGE_FIRST_DATA_ID );

// iterate from FillPortsMenu, then add popup menu entries.
Int32 i = 0, bcindex;
while ( true )
{
  bcindex = names.GetIndexId( i++ );
  if ( bcindex == NOTOK )
  {
    break;
  } 
  popupbc.SetString( ids.GetInt32( bcindex ), names.GetString( bcindex ) );
}
Int32 screenx = msg.GetInt32( BFM_INPUT_X ),
      screeny = msg.GetInt32( BFM_INPUT_Y );
Local2Screen( &screenx, &screeny );
Int32 menuselect = ShowPopupMenu( nullptr, screenx, screeny, popupbc, POPUP_RIGHT );

// process selected menu entry


One problem right now is my code doesn't iterate through sub-containers yet (e.g. Coordinatess, Object Properties in an Object OperatorNode.) I'll try and figure it out later, then I'll post an update.

Thanks!
-------------------------
Do what you want to do, not what you think you want to do.
Back to Top
rustEdge View Drop Down
Member
Member
Avatar

Joined: 2010 Oct 06
Location: Vancouver
Online Status: Online
Posts: 52
Post Options Post Options   Quote rustEdge Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jun 28 at 2:25pm
Okay, I just overcomplicated my code for no reason. I just needed to directly use the returned names BaseContainer into ShowPopupMenu()


// "node" is a GvNode processed earlier whose menus will be displayed

// get inports from node
BaseContainer   names, ids;
GvOperatorData* gvopdata = node->GetOperatorData();
Int32           ct       = gvopdata->FillPortsMenu( node, names, ids, ID_GV_VALUE_TYPE_NONE, GV_PORT_INPUT, GV_MESSAGE_FIRST_DATA_ID );

// display popup below mouse cursor
Int32 screenx = msg.GetInt32( BFM_INPUT_X ),
      screeny = msg.GetInt32( BFM_INPUT_Y );
Local2Screen( &screenx, &screeny );
Int32 menuselect = ShowPopupMenu( nullptr, screenx, screeny, names, POPUP_RIGHT );

// process node with returned value from "menuselect", use "ids" as id lookup table
if ( node->AddPortIsOK( GV_PORT_INPUT, ids.GetInt32( menuselect ) ) )
{
  node->AddPort( GV_PORT_INPUT, ids.GetInt32( menuselect ) );
}



Edited by rustEdge - 2017 Jun 28 at 2:47pm
-------------------------
Do what you want to do, not what you think you want to do.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.