#ifndef _MItDependencyGraph #define _MItDependencyGraph // //- // ========================================================================== // Copyright (C) 1995 - 2006 Autodesk, Inc., and/or its licensors. All // rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files contain unpublished // information proprietary to Autodesk, Inc. ("Autodesk") and/or its // licensors, which is protected by U.S. and Canadian federal copyright law // and by international treaties. // // The Data may not be disclosed or distributed to third parties or be // copied or duplicated, in whole or in part, without the prior written // consent of Autodesk. // // The copyright notices in the Software and this entire statement, // including the above license grant, this restriction and the following // disclaimer, must be included in all copies of the Software, in whole // or in part, and all derivative works of the Software, unless such copies // or derivative works are solely in the form of machine-executable object // code generated by a source language processor. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. // AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED // WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF // NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, // OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO // EVENT WILL AUTODESK AND/OR ITS LICENSORS BE LIABLE FOR ANY LOST // REVENUES, DATA, OR PROFITS, OR SPECIAL, DIRECT, INDIRECT, OR // CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS LICENSORS HAS // BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES. // ========================================================================== //+ // // CLASS: MItDependencyGraph // // ***************************************************************************** // // CLASS DESCRIPTION (MItDependencyGraph) // // In Maya, all geometry, animation and rendering information is implemented // in Nodes in the Dependency Graph (DG). The DG includes the Directed Acyclic // Graph (DAG). Therefore, all DAG Nodes are also DG Nodes. The data on Nodes // is associated with Attributes. Attributes on Nodes are connected to // Attributes on other Nodes via Plugs on the Attributes. Plugs are, in effect // the external intefaces of Attributes. // // The DG Iterator Class (MItDependencyGraph) provides methods for iterating // over either Nodes or Plugs, as well as methods for setting and querying the // characteristics and behaviour of the iterator. // // This iterator will traverse all attributes upstream or downstream from the // root node of the traversal. For non root nodes, only attributes that are // affected by the incoming attribute to that node will be traversed. // Hence, only nodes to which data from the root node is flowing will be // traversed. // // The DG Iterator is used in conjunction with the Maya Object (MObject), Plug // (MPlug), Maya Object Array (MObjectArray) and Plug Array (MPlugArray) // classes. // // It is also useful to use Function Sets specific to the Nodes returned by // the iterator to query and modify the Nodes in the DG. // // The DG itself can be modified using a DG Modifer (MDGModifier). // // Additionally, Nodes can be added to and retrieved from selection lists using // the Selection List (MSelectionList) class and Selection List Iterator // (MItSelectionList). This can be useful for obtaining the root Node for an // iteration. // // Attributes on the Nodes can be manipulated using the Attribute Function Set // (MFnAttribute) and its derivations. // // ***************************************************************************** #if defined __cplusplus // ***************************************************************************** // INCLUDED HEADER FILES #include #include #include #include #include #include #include // ***************************************************************************** // DECLARATIONS // ***************************************************************************** // CLASS DECLARATION (MItDependencyGraph) class MIteratorType; /// Dependency Graph Iterator. (OpenMaya) (OpenMaya.py) /** Iterate over Dependency Graph (DG) Nodes or Plugs starting at a specified root Node or Plug. Set and query the root of the iteration. Set and query the direction (downstream or upstream), traversal priority (depth first or breadth first) and level of detail (Node level or Plug level) of the iteration. Set and disable a filter to iterate over only speicifc types (MFn::Type) of Nodes. Reset the root, filter, direction, traversal priority and level of detail of the iteration. Prune branches of the graph from iteration. */ #ifdef _WIN32 #pragma warning(disable: 4522) #endif // _WIN32 class OPENMAYA_EXPORT MItDependencyGraph { public: /// Direction within the DG relative to root Node or Plug enum Direction { /// From source to destination kDownstream, /// From destination to source kUpstream }; /// Perform a depth first or breadth first traversal enum Traversal { /// Away from root first kDepthFirst, /// Equidistant from root first kBreadthFirst }; /// Level of detail of the iteration enum Level { /// Visit each Node at most once kNodeLevel, /// Visit each Plug at most once kPlugLevel }; /// MItDependencyGraph ( MObject& rootNode, MFn::Type filter = MFn::kInvalid, Direction direction = kDownstream, Traversal traversal = kDepthFirst, Level level = kNodeLevel, MStatus* ReturnStatus = NULL ); /// MItDependencyGraph ( MPlug& rootPlug, MFn::Type filter = MFn::kInvalid, Direction direction = kDownstream, Traversal traversal = kDepthFirst, Level level = kPlugLevel, MStatus* ReturnStatus = NULL ); /// MItDependencyGraph( MObject& rootNode, MPlug& rootPlug, MIteratorType& infoObject, Direction direction = kDownstream, Traversal traversal = kDepthFirst, Level level = kNodeLevel, MStatus* ReturnStatus = NULL ); /// ~MItDependencyGraph (); /// MStatus reset(); /// MStatus resetTo( MObject& rootNode, MFn::Type filter = MFn::kInvalid, Direction direction = kDownstream, Traversal traversal = kDepthFirst, Level level = kNodeLevel ); /// MStatus resetTo( MPlug& rootPlug, MFn::Type filter = MFn::kInvalid, Direction direction = kDownstream, Traversal traversal = kDepthFirst, Level level = kPlugLevel ); /// MStatus resetTo( MObject* rootNode, MPlug* rootPlug, MIteratorType& infoObject, Direction direction = kDownstream, Traversal traversal = kDepthFirst, Level level = kPlugLevel ); /// MObject rootNode( MStatus* ReturnStatus = NULL ); /// MPlug rootPlug( MStatus* ReturnStatus = NULL ); /// MFn::Type currentFilter( MStatus* ReturnStatus = NULL ); /// MStatus setCurrentFilter( MFn::Type filter = MFn::kInvalid ); /// MStatus resetFilter(); /// bool isPruningOnFilter( MStatus* ReturnStatus = NULL ); /// MStatus enablePruningOnFilter(); /// MStatus disablePruningOnFilter(); /// bool isDirectionDownStream( MStatus* ReturnStatus = NULL ); /// Direction currentDirection( MStatus* ReturnStatus = NULL ); /// MStatus toggleDirection( ); /// bool isTraversalDepthFirst( MStatus* ReturnStatus = NULL ); /// Traversal currentTraversal( MStatus* ReturnStatus = NULL ); /// MStatus toggleTraversal( ); /// bool atNodeLevel( MStatus* ReturnStatus = NULL ); /// Level currentLevel( MStatus* ReturnStatus = NULL ); /// MStatus toggleLevel( ); /// MStatus next( ); /// bool isDone( MStatus* ReturnStatus = NULL ); /// MStatus prune( ); /// OBSOLETE MObject thisNode( MStatus* ReturnStatus = NULL ); /// MObject currentItem( MStatus* ReturnStatus = NULL ); /// bool thisNodeHasUnknownType( MStatus* ReturnStatus = NULL ); /// MPlug thisPlug( MStatus* ReturnStatus = NULL ); /// MPlug previousPlug( MStatus* ReturnStatus = NULL ); /// MStatus getNodesVisited( MObjectArray& nodesVisted ) const; /// MStatus getPlugsVisited( MPlugArray& plugsVisted ) const; /// MStatus getNodePath( MObjectArray& path ) const; /// MStatus getPlugPath( MPlugArray& path ) const; protected: // No protected members private: static const char* className(); void * currentIterator; bool objectsHasFnOnFilterOrList(const MObject& nodeObj, const MObject& attrObj); void getCurrentIteratorFromMObjectOrMPlug(MObject& rootNode, MPlug& rootPlug, Direction direction, Traversal traversal, Level level, MStatus* ReturnStatus); void resetCurrentIteratorFromMObjectOrMPlug(MObject& rootNode, MPlug& rootPlug, Direction direction, Traversal traversal, Level level, MStatus* ReturnStatus); MFn::Type currentTypeFilter; bool pruneOnNoMatch; MIntArray filterList; bool useFilterList; }; #ifdef _WIN32 #pragma warning(default: 4522) #endif // _WIN32 // ***************************************************************************** #endif /* __cplusplus */ #endif /* _MItDependencyGraph */