Class IGraphObjectManager

3DS Max Plug-In SDK

Class IGraphObjectManager

See Also: Class IGraphNode, Class IGraphRef, Class Animatable.

class IGraphObjectManager

Description:

This class is available in release 3.0 and later only.

This class essentially represents an instance of a schematic view window and provides methods for adding nodes and node pointers, refreshing the schematic view, accessing filter bits and updating and controlling the various editors within 3ds max in ways that are not surfaced in the general interface.

Methods:

public:

Prototype:

virtual SvGraphNodeReference AddAnimatable(Animatable *anim, Animatable *owner, int id, DWORD flags = 0)=0;

Remarks:

Adds an Animatable to the schematic view. Note that “owner” and “id” are actually arbitrary – they are used to provide context for this Animatable. This means that the plug-in developer can set them to any value. They are not used internally by the schematic view except in the "Sv*" methods (which the developer can override). So, when you add an Animatable to the schematic view, you would typically add the owner (parent) Animatable as well as the sub-anim id. This allows you to, for example, easily return the name of the object when queried by the SvGetName(...) call (whose default implementation is shown below):

TSTR Animatable::SvGetName(IGraphObjectManager *gom, IGraphNode *gNode, bool isBeingEdited)

 {

 Animatable *owner;

 int subNum;

 TSTR name; 

 

 owner = gNode->GetOwner();

 subNum = gNode->GetID();

 name = owner->SubAnimName(subNum);

 

 return name;

 }

Parameters:

Animatable *anim

Points to the animatable to add.

Animatable *owner

Points to the owner of anim above (typically).

int id

When nodes are added to the schematic view via this method this integer is provided. This value is not used internally by the schematic view. Rather, it is available to implementers of the Animatable::Sv*() methods to aid in identifying the node.

DWORD flags = 0

This flag is some combination of the following bit flags. See List of Schematic View AddAnimatable Flags.

Return Value:

A SvGraphNodeReference object.

Prototype:

virtual void PushLevel(Animatable *anim, int id = SV_NO_ID)=0;

Remarks:

During traversal of the Animatable graph via SvTraverseAnimGraph(...), this method (and PopLevel() below) should be called appropriately to maintain an ownership stack. This is required by the schematic view when nodes are added to the graph with the SV_DUPLICATE_INSTANCES flag set. Note: In 3ds max 3.0, SV_DUPLICATE_INSTANCES is always on (i.e., the flag is ignored). Because of this, PushLevel() and PopLevel() should always be called in SvTraverseAnimGraph(...).

See the sample code in Animatable::SvStdTraverseAnimGraph() for an example of this.

Parameters:

Animatable *anim

This is the Animatable that you are, in all likelihood, about to add to the graph via the AddAnimatable() call.

int id = SV_NO_ID

This is also the same "id" you'd pass into AddAnimatable(). The "id" is only required in cases where it's impossible for the schematic view to distinguish between two (or more) children in the tree that have the same Animatable but represent different sub-anims. For example, a box has both its width and height set to the same controller (instanced). In the schematic view, this is still shown in tree form so we need the ID to distinguish between the "width" and "height" children.

Prototype:

virtual void PopLevel()=0;

Remarks:

Pops a level off the animatable ownership stack. See PushLevel() above for details.

Prototype:

virtual IGraphRef *AddReference(IGraphNode *maker, IGraphNode *target, SvReferenceType type)=0;

Remarks:

This method adds a reference from the specified "maker" node to the specified "target" node.

Parameters:

IGraphNode *maker

Points to the 'maker' node in schematic view.

IGraphNode *target

Points to the 'target' node in schematic view.

SvReferenceType type

One of the following enum values:

 REFTYPE_CHILD

 REFTYPE_SUBANIM

 REFTYPE_PLUGIN

Return Value:

A pointer to an IGraphRef object.

Sample Code:

SvGraphNodeReference Control::SvTraverseAnimGraph(IGraphObjectManager *gom, Animatable *owner, int id, DWORD flags)

 {

 int i;

 SvGraphNodeReference nodeRef;

 SvGraphNodeReference childNodeRef;

 

//

// Test filter to see if "Controllers" are active.

// Bail out if they're off (being filtered out)...

//

 if (!gom->TestFilter(SV_FILTER_CONTROLLERS))

  return SvGraphNodeReference();

 

//

// Push this level in the tree. Note that the sub-anim id is passed

// in here because it's possible that the same instance of this control

// may exist in multiple tracks of "owner".

//

 gom->PushLevel(this, id);

 

//

// Some flags are set here pertaining to the control being added.

// Note that the flags are also propagated down the tree

// by passing them on to SubAnim(i)->SvTraverseAnimGraph(gom, this, i, flags);

// SV_DUPLICATE_INSTANCES tells the schematic view not to

// represent multiple instances with a single node. Instead they

// are represented by multiple nodes in the schematic view

// with the "triangle thingy" attached to the side to indicate

// shared instances. This flag is ignored in R3 because

// this mode of operation is globally enabled

// SV_INITIALLY_HIDDEN tells the schematic view that this

// control's node is to be initially displayed in the closed state.

// Note that this has no effect if the node already exists

// in the graph -- it only applies to newly added nodes.

//

 

 flags |= SV_DUPLICATE_INSTANCES | SV_INITIALLY_HIDDEN;

 

//

// The control is added to the schematic view...

//

 nodeRef = gom->AddAnimatable(this, owner, id, flags);

 if (nodeRef.stat == SVT_PROCEED)

  {

//

// This control's sub-anims are iterated over...

//

  for (i = 0; i < NumSubs(); i++)

   {

   if (SubAnim(i))

    {

//

// SvTraverseAnimGraph(...) is recursively called to add this sub-anim (and all its descendents) to the graph...

//

    childNodeRef = SubAnim(i)->SvTraverseAnimGraph(gom, this, i, flags);

 

//

// Now a link (node pointer) is created in the schematic between the control (nodeRef.gNode) and its child sub-anim (childNodeRef.gNode)....

//

    if (childNodeRef.stat != SVT_DO_NOT_PROCEED)

     gom->AddReference(nodeRef.gNode, childNodeRef.gNode, REFTYPE_SUBANIM);

    }

   }

  }

 

//

// The tree level is popped. Note: a PopLevel() call must always be paired with a PushLevel() call!

//

 gom->PopLevel();

 

 return nodeRef;

 }

Prototype:

virtual void SvEditSelectedNodeProperties()=0;

Remarks:

Pops up the property editor dialog on the selected nodes in the schematic view.

Prototype:

virtual void SvSelectInMaterialEditor(IGraphNode *gNode)=0;

Remarks:

Selects the given node in the material editor. Does nothing if "gNode" does not represent a material or map.

Parameters:

IGraphNode *gNode

Points to the node in schematic view.

Prototype:

virtual void SvSetCurEditObject(IGraphNode *gNode)=0;

Remarks:

Selects the given node in the modifier panel. Does nothing if "gNode" does not represent an object.

Parameters:

IGraphNode *gNode

Points to the node in schematic view.

Prototype:

virtual void SvInvalidateView()=0;

Remarks:

Invalidates the schematic view window.

Prototype:

virtual void SvInvalidateNode(IGraphNode *gNode)=0;

Remarks:

Invalidates a node in the schematic view window.

Parameters:

IGraphNode *gNode

Points to the node in schematic view.

Prototype:

virtual void SvUpdateMaterialEditor()=0;

Remarks:

Forces the material editor to update.

Prototype:

virtual void SvUpdateModifierPanel()=0;

Remarks:

Forces the modifier panel to update.

Prototype:

virtual void SetFilter(DWORD mask)=0;

Remarks:

Sets the specified filter bits.

Parameters:

DWORD mask

See List of IGraphObjectManager Filter Bits.

Prototype:

virtual void ClearFilter(DWORD mask)=0;

Remarks:

Clears the specified filter bits.

Parameters:

DWORD mask

See List of IGraphObjectManager Filter Bits.

Prototype:

virtual bool TestFilter(DWORD mask)=0;

Remarks:

Tets the specified filter bits. Returns true if set; otherwise false.

Parameters:

DWORD mask

See List of IGraphObjectManager Filter Bits.