Drag and drop behavior of GvNode
-
On 21/11/2016 at 16:07, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 18
Platform: Mac ;
Language(s) : C++ ;---------
Hi,Two questions:
-
I noticed in the Arnold shader graph and XPRESSO, if you drag a connection onto a node it presents the input or output port menu, depending on which corner you drag it to. That doesn't seem to work with our nodes. Is there a message we need to look for, or a method we need to override?
-
It looks like you can also drag attributes from the attributes manager onto the nodes as well. How is that accomplish?
Thanks,
Ian -
-
On 22/11/2016 at 02:17, xxxxxxxx wrote:
Hello,
when a connection is draggend onto a node's input or output area the list of ports appears by default. This should not need any further programming, only some defined ports.
To handle drag and drop on the node and the input and output areas you have to implement IsSetDataAllowed() and SetData():
Bool IsSetDataAllowed(GvNode* bn, GvDataType type, void* data, GvOpSetDataMode mode) { if (!data) return false; switch (type) { case GV_DESCID: { return true; } } return false; } Bool SetData(GvNode* bn, GvDataType type, void* data, GvOpSetDataMode mode) { BaseList2D* object = nullptr; switch (type) { case GV_DESCID: { DescPropertyDragData* dpdd = (DescPropertyDragData* )data; if (dpdd) { AtomArray* objects = dpdd->arr; if (objects && objects->GetCount() > 0) { BaseList2D* element = static_cast<BaseList2D*>(objects->GetIndex(0)); if (element) GePrint("Object: " + element->GetName()); } DescID transid = dpdd->did; GePrint("Dragged Parameter ID: " + String::IntToString(transid[-1].id)); } break; } } return true; }
best wishes,
Sebastian -
On 22/11/2016 at 09:06, xxxxxxxx wrote:
Ah, thanks. Yup, I got the drag and drop behavior working with your example, so thanks for that!
when a connection is draggend onto a node's input or output area the list of ports appears by default. This should not need any further programming, only some defined ports.
Hmm...that doesn't seem to be the case for us. When we drag the connection onto the input area, the line turns grey, not green or orange. Could this be because we're overriding the FillPortsMenu and iGetPortDescription methods?
I'll send you a direct e-mail with a link to a private video that shows the behavior we're seeing.
Thanks,
Ian -
On 23/11/2016 at 00:38, xxxxxxxx wrote:
Hello,
the connection only appears green when there is something to connect to: when the dragged port can be connected to one or some of the target node input ports. Are you sure this is the case with your nodes?
Could you also post your implementation of iGetPortDescription() and FillPortsMenu()?
best wishes,
Sebastian -
On 23/11/2016 at 08:59, xxxxxxxx wrote:
I've e-mailed you the source code for the two methods.
Thanks,
Ian -
On 24/11/2016 at 02:07, xxxxxxxx wrote:
Hello,
can you explain what exactly your intention for using FillPortsMenu() is?
You can add (potential) ports to the port list with iGetPortList() and define the added port in iGetPortDescription(). Adding ports this ways seems to work fine with the described dragging of connections:
void iGetPortList(GvNode* bn, GvPortIO port, GvPortList& portlist) { SUPER::iGetPortList(bn, port, portlist); if (port == GV_PORT_INPUT) { portlist.Append(NewObjClear(GvPortListEntry, 123456)); } } Bool iGetPortDescription(GvNode* bn, GvPortIO port, Int32 id, GvPortDescription* pd) { if (id == 123456) { pd->data_id = ID_GV_DATA_TYPE_INTEGER; pd->name = "My Integer Port"; pd->flags = GV_PORTDESCRIPTION_NONE; pd->parent_id = GV_PORT_INVALID_ID; return true; } return SUPER::iGetPortDescription(bn, port, id, pd); }
best wishes,
Sebastian -
On 25/11/2016 at 09:17, xxxxxxxx wrote:
Thanks, Sebastian. Looks like adding an iGetPortList() worked and we now see the port menu when we drag the connection. We were using the FillPortsMenu based on Andreas' example, in my other thread: https://developers.maxon.net/forum/topic/9673/13012_item-selection-in-gvoperatordatafillportsmenu&PID=51477#51477
I tried just using the iGetPortList() but it seems to put all the items in the menu in alphabetical order, so I guess we want to keep our FillPortsMenu().
Cheers!
Ian