//- // ========================================================================== // Copyright (C) 1995 - 2005 Alias Systems Corp. and/or its licensors. All // rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files are provided by Alias // Systems Corp. ("Alias") and/or its licensors for the exclusive use of the // Customer (as defined in the Alias Software License Agreement that // accompanies this Alias software). Such Customer has the right to use, // modify, and incorporate the Data into other products and to distribute such // products for use by end-users. // // THE DATA IS PROVIDED "AS IS". ALIAS HEREBY DISCLAIMS ALL WARRANTIES // RELATING TO THE DATA, INCLUDING, WITHOUT LIMITATION, ANY AND ALL EXPRESS OR // IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. IN NO EVENT SHALL ALIAS BE LIABLE FOR ANY DAMAGES // WHATSOEVER, WHETHER DIRECT, INDIRECT, SPECIAL, OR PUNITIVE, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, OR IN EQUITY, // ARISING OUT OF ACCESS TO, USE OF, OR RELIANCE UPON THE DATA. // ========================================================================== //+ // // ShapeMonitor // // Author: Christian Laforte // // Data: March 2001 // #ifndef _ShapeMonitor_ #define _ShapeMonitor_ #include #include "AWarray.h" class MSelectionList; // Structure used to track monitored Maya nodes. class MonitoredObject { public: MString mayaNodeName; MonitoredObject() { renamedCallbackId = 0; dirtyCallbackId = 0; } virtual ~MonitoredObject() {} MCallbackId renamedCallbackId; MCallbackId dirtyCallbackId; }; class ShapeMonitor { public: // Return a pointer to the singleton node. // It is created automatically if it doesn't already exist. static ShapeMonitor* instance(); // Initialize the ShapeMonitor singleton. // This frees internal data structures and detach any callbacks left, // and returns a fresh and clean ShapeMonitor instance. static ShapeMonitor* initialize(); // Destroy the internal content of the ShapeMonitor singleton. // This also detaches any callbacks left. static void destroy(); // Watch the given node. This function will add an element in the monitored objects array, // and set callbacks on the node in order to get notified when the node changes. void watch(MString mayaNodeName, MonitoredObject* pMon); // Stop watching all nodes that correspond to the given unique texture name. // This function can also be used to stop watching all elements, by setting that argument to true. void stopWatching(MString mayaNodeName); // Stop watching all nodes. void stopWatchingAll(); void stopWatchingUnselectedDagObjects(MSelectionList& selectedObjects); private: // The constructor and destructor are private, to guarantee that client-side code cannot instance // more than one at a time. ShapeMonitor(); ~ShapeMonitor(); // Pointer to the singleton private instance. static ShapeMonitor* privateInstance; // The list of currently monitored objects. AWarray< MonitoredObject* > monitoredObjectsPtrArray; // Find a monitored object according to its node name. // This is used to ensure that we don't store duplicates in the list. MonitoredObject* retrieveMonitorObject(MString nodeName); // Callback functions. Those are called, respectively, when a node is dirty (has changed substantially), // or when a node is renamed. static void watchedObjectDirtyCallback( void* clientData ); static void watchedObjectRenamedCallback( MObject & node, void* clientData ); void removeCallbacks(MonitoredObject *mon); }; #endif // _ShapeMonitor_