modstack.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: modstack.h
00004 
00005     DESCRIPTION:
00006 
00007     CREATED BY: Rolf Berteig
00008 
00009     HISTORY: created January 20, 1996
00010 
00011  *> Copyright (c) 1994, All Rights Reserved.
00012  **********************************************************************/
00013 #pragma once
00014 
00015 #include "coreexp.h"
00016 #include "maxtypes.h"
00017 #include "object.h"
00018 
00019 // These are the class IDs for object space derived objects and
00020 // world space derived objects
00021 extern CoreExport Class_ID derivObjClassID;
00022 extern CoreExport Class_ID WSMDerivObjClassID;
00023 
00024 
00039 class IDerivedObject : public Object
00040 {
00041     public:
00042         // Adds a modifier to the derived object.
00043         // before = 0               :Place modifier at the end of the pipeline (top of stack)
00044         // before = NumModifiers()  :Place modifier at the start of the pipeline (bottom of stack)
00056         virtual void AddModifier(Modifier *mod, ModContext *mc=NULL, int before=0)=0;               
00061         virtual void DeleteModifier(int index=0)=0;
00064         virtual int NumModifiers()=0;       
00065 
00066         // Searches down the pipeline for the base object (an object that is not a
00067         // derived object). May step into other derived objects. 
00068         // This function has been moved up to Object, with a default implementation
00069         // that just returns "this".  It is still implemented by derived objects and
00070         // WSM's to search down the pipeline.  This allows you to just call it on
00071         // a Nodes ObjectRef without checking for type.
00072 //      virtual Object *FindBaseObject()=0;
00073         
00074         // Get and set the object that this derived object reference.
00075         // This is the next object down in the stack and may be the base object.
00079         virtual Object *GetObjRef()=0;
00088         virtual RefResult ReferenceObject(Object *pob)=0;
00089 
00090         // Access the ith modifier.
00095         virtual Modifier *GetModifier(int index)=0;
00096 
00097         // Replaces the ith modifier in the stack
00105         virtual void SetModifier(int index, Modifier *mod)=0;
00106 
00107         // Access the mod context for the ith modifier
00112         virtual ModContext* GetModContext(int index)=0;
00113         
00126         virtual ObjectState Eval(TimeValue t, int modIndex = 0)=0;
00127 
00128         // pass any notifies onto my ObjRef, such as node attaches/deletes - jbw 9.9.00
00129         void NotifyTarget(int msg, RefMakerHandle rm) { if (GetObjRef()) GetObjRef()->NotifyTarget(msg, rm); }  
00130 
00131         using Object::GetInterface;
00132         CoreExport virtual void* GetInterface(ULONG id);
00133     };
00134 
00135 // Create a world space or object space derived object.
00136 // If the given object pointer is non-NULL then the derived
00137 // object will be set up to reference that object.
00143 CoreExport IDerivedObject *CreateWSDerivedObject(Object *pob=NULL);
00149 CoreExport IDerivedObject *CreateDerivedObject(Object *pob=NULL);
00150 
00151 enum PipeEnumResult {
00152     PIPE_ENUM_CONTINUE,
00153     PIPE_ENUM_STOP
00154 };
00155 
00156 // This is the callback procedure for pipeline enumeration. The ReferenceTarget 
00157 // passed to the proc can be a Node, Modifier or Object. In case it is a Modifier
00158 // derObj contains the DerivedObject and the index is the index of this modifier 
00159 // in the DerivedObject. In all other cases derObj is NULL and index is 0;
00160 // In case the flag includeEmptyDOs is declared as true, the proc will be called
00161 // even for DerivedObjects, that don't contain any modifiers. In that case the
00162 // object pointer will be NULL, the derObj pointer will contain the DerivedObject
00163 // and the index will be -1.
00164 
00177 class GeomPipelineEnumProc : public InterfaceServer
00178 {
00179 public: 
00200     virtual PipeEnumResult proc(ReferenceTarget *object, IDerivedObject *derObj, int index)=0;
00201 };
00202 
00203 //---------------------------------------------------------------------------
00204 // Pipeline Enumeration
00205 
00206 // These methods start a pipeline enumeration down the pipeline towards the baseobject
00207 // and over the baseobjects' branches in case it is a compound object.
00208 // A pipleine enumeration can be started from a Node, an Object or from a Modifier. 
00209 // In case it is started from a Modifier, the client has to provide the IDerviedObject the 
00210 // Modifier is applied to and the index of the Modifier in the IDerivedObject. One can use 
00211 // the method Modifier::GetIDerivedObject(); in order to get the IDerviedObject 
00212 // and the index, given a modifier and a ModContext.
00213 
00229 CoreExport int EnumGeomPipeline(GeomPipelineEnumProc *gpep, INode *start, bool includeEmptyDOs = false);
00245 CoreExport int EnumGeomPipeline(GeomPipelineEnumProc *gpep, Object *start, bool includeEmptyDOs = false);
00267 CoreExport int EnumGeomPipeline(GeomPipelineEnumProc *gpep, IDerivedObject *start, int modIndex = 0, bool includeEmptyDOs = false);
00268 
00269 //---------------------------------------------------------------------------
00270 // Collapse Notification 
00271 
00272 // Whenever the modifier stack is collapsed the code has to notify all objects in the 
00273 // stack with a Pre and a Post notification. In order to do this, the 
00274 // NotifyCollapseEnumProc can be used in conjunction with the method 
00275 // EnumGeomPipleine(). In the constructor one can specify, if it is a pre-, 
00276 // or post-collapse notification. In case it is a postcollapse the object that 
00277 // represents the result of the collapse has to be provided as well. The
00278 // INode pointer to the beginning of the pipeline that was collapsed has to be 
00279 // provided in both cases.
00280 
00292 class NotifyCollapseEnumProc : public GeomPipelineEnumProc
00293 {
00294 bool bPreCollapse;
00295 INode *node;
00296 Object *collapsedObject;
00297 public: 
00314     NotifyCollapseEnumProc(bool preCollapse, INode *n, Object *collapsedObj = NULL) : bPreCollapse(preCollapse), node(n), collapsedObject(collapsedObj) {}
00318     virtual PipeEnumResult proc(ReferenceTarget *object,IDerivedObject *derObj, int index) {
00319         if(object->ClassID() == Class_ID(BASENODE_CLASS_ID,0))
00320             return PIPE_ENUM_CONTINUE;
00321 
00322         if(bPreCollapse)
00323             ((BaseObject *) object)->NotifyPreCollapse(node, derObj, index);
00324         else
00325             ((BaseObject *) object)->NotifyPostCollapse(node, collapsedObject, derObj, index);
00326 
00327         return PIPE_ENUM_CONTINUE;
00328     }
00329 
00330 };
00331 
00333 
00339 class NotifyCollapseMaintainCustAttribEnumProc : public GeomPipelineEnumProc
00340 {
00341     bool bPreCollapse;
00342     INode *node;
00343     Object *collapsedObject;
00344     bool bCopied;
00345 public: 
00346     
00348 
00352     CoreExport NotifyCollapseMaintainCustAttribEnumProc(bool preCollapse, INode *n, Object *collapsedObj = NULL);
00354 
00359     CoreExport virtual PipeEnumResult proc(ReferenceTarget *object,IDerivedObject *derObj, int index); 
00360 
00361 };
00362 
00364 
00381 class NotifyCollapseMaintainCustAttribEnumProc2 : public GeomPipelineEnumProc
00382 {
00383     INode *node;
00384     Object *collapsedObject;
00385     Object *nodeBaseObject;
00386     bool bPreCollapse;
00387     bool bCopied;
00388     bool bIgnoreBaseObjectCAs;
00389 public: 
00390 
00392 
00397     CoreExport NotifyCollapseMaintainCustAttribEnumProc2(bool preCollapse, INode *node, bool ignoreBaseObjectCAs = false, Object *collapsedObj = NULL);
00399 
00406     CoreExport virtual PipeEnumResult proc(ReferenceTarget *object,IDerivedObject *derObj, int index); 
00407 
00408 };
00409