00001 /********************************************************************** 00002 00003 FILE: IADTObjMgr.h 00004 00005 DESCRIPTION: Public interface for working with (file)linked ADT Objects 00006 00007 CREATED BY: Attila Szabo, Discreet 00008 00009 HISTORY: - created Sep.25.02 00010 00011 *> Copyright (c) 1998-2002, All Rights Reserved. 00012 **********************************************************************/ 00013 00014 #pragma once 00015 #include "ref.h" 00016 #include "iFnPub.h" 00017 #include "maxtypes.h" 00018 #include "GetCOREInterface.h" 00019 00020 // --- Forward declaration 00021 class IADTCategory; 00022 class IADTStyle; 00023 class INode; 00024 class RemapDir; 00025 00026 // --- Interface IDs 00027 #define ADT_OBJ_MGR_INTERFACE Interface_ID(0x3d8514f1, 0x7c9252af) 00028 00029 // class IADTObjMgr 00030 // 00031 // This interface allows different parts of the system (max) and plugins 00032 // to create, destroy and work with ADT Objects. 00033 // 00034 // ADT objects have categories and styles associated with them. 00035 // Examples of categories are wall, window, etc. Each category has a number 00036 // of styles. Styles have components. Each style component defines the dimensions 00037 // of some part of the ADT object, display and rendering properties. 00038 // 00039 // Although in ADT objects don't have components, only styles have, when transferred 00040 // into max (or derived products), the ADT objects will have components the user 00041 // can select and work with. These components will correspond to the components of 00042 // the style that is associated with the ADT object and we sometimes reffer to them 00043 // as style instances 00044 // 00045 // This is how client code can create style instances (that is, associate category, 00046 // style and style component information with nodes): 00047 // (i) Make sure that desired category and style exist. Call: 00048 // IADTStyle* IADTObjMgr::GetStyle(const MCHAR* pCategName, const MCHAR* pStyleName) 00049 // (ii) Create an instance of the desired style. 00050 // IADTStyle::Iterator IADTStyle::SetInstance(INode& styleInst, bool hasCompVisOverrides); 00051 // (iii) Add style component instances to the style instance created above. 00052 // bool IADTStyle::SetComponent(IADTStyle::Iterator i, INode& styleCompInst, 00053 // const MCHAR* pCompName, bool mtlOverride, 00054 // bool keepRelativeTransform); 00055 // 00056 // Style instances are destroyed when the nodes associated with a style and style 00057 // component are deleted, rather than by deleting a style or a category. 00058 // For more deatils see iADTObjMgr.h, iADTStyle.h, iADTCategory.h 00059 class IADTObjMgr : public ReferenceTarget, public FPStaticInterface 00060 { 00061 public: 00062 00063 // Makes sure the given category and the given style within that category 00064 // exist. If the category and\or the style exist, simply returns a pointer 00065 // to the style - it doesn't create a new one. The resulting style can be 00066 // used by client code to create instances of that style (ADT objects that 00067 // are associated with that style). The category and style names cannot 00068 // be NULL and are case in-sensitive. 00069 // - const MCHAR* pCategName - The name of ADT object category (wall, window, etc) 00070 // - const MCHAR* pStyleName - The name of ADT Style. This cannot be NULL. 00071 // - Returns NULL if it doesn't succeed, otherwise the style within the given category 00072 virtual IADTStyle* GetStyle(const MCHAR* pCategName, const MCHAR* pStyleName) = 0; 00073 00074 // Checks whether a node is associated with an ADT Style. If yes, it means 00075 // it's a style instance and the method returns a pointer to the instanced 00076 // style or style component. 00077 // - INode& n - the node we want to know if it's a style instance 00078 virtual IADTStyle* IsInstance(INode& n) const = 0; 00079 00080 // Returns the node that represents the top of an ADT object. In other words, 00081 // if parameter n is a component of an ADT object, this method returns the node 00082 // that is an instance of the style whose component n is. 00083 // If n is not a style instance, return NULL. 00084 virtual INode* GetInstanceTop(INode& n) const = 0; 00085 00086 // Returns the number of all nodes in the scene that represent style instances 00087 // (this number doesn't include style component instances) 00088 virtual unsigned long NumInstances() const = 0; 00089 00090 // Fills out the provided array with all the nodes in the scene that represent 00091 // style instances. Returns their count 00092 virtual unsigned long GetInstances(Tab<INode*>& instances) const = 0; 00093 00094 // Returns true if the node is a style instance and if that style has 00095 // more then one instance 00096 virtual bool CanMakeUnique(INode& node) const = 0; 00097 00098 // Makes unique the given style instance. This means, that after this operation 00099 // the style instance (node) will be associate with a unique style, but it will 00100 // maintain its material override and visibility override flags. 00101 // When called with a node that is a style composite instance, the components of that 00102 // style instance are also made unique (the child nodes that are style instances) 00103 // To find out if a style instance can be made unique, call IADTObjMgr::CanMakeUnique 00104 // NOTE: this method does not make unique the objects referenced by the node; 00105 // it only makes unique the style makes the new style reference the given node. 00106 // A node should be always referenced by only one style - a node can be the instance of 00107 // one style only. 00108 // - INode& - the Node that represents the style instance. 00109 // - RemapDir* - allows for making style instances unique with respect to 00110 // each other or not 00111 // - Returns a pointer to the style of the unique style instance or NULL if the 00112 // operation failed 00113 virtual IADTStyle* MakeUnique(INode& node, RemapDir* pRemapDir) const = 0; 00114 00115 // Creates a name that is unique among the names of all categories and it's 00116 // based on the given name. The unique name is seeded by passing in a seed-name 00117 // through the MSTR& 00118 // - MSTR& - Input\Output parameter. As input parameter, it represents a seed 00119 // for the the unique name. As output parameter, it holds the unique name that 00120 // was generated 00121 virtual void MakeUniqueCategoryName(MSTR& name) const = 0; 00122 00123 // TOOD: Category iteration 00124 virtual unsigned long NumCategories() const = 0; 00125 00126 // Retrieves all Categories within the current drawing 00127 virtual unsigned long GetCategories(Tab<IADTCategory*>& categories) const = 0; 00128 00129 // Retrieves a category given a category name 00130 virtual IADTCategory* FindCategory(const MCHAR* pCategName) const = 0; 00131 00132 // For each node in the given array that represents a style instance, extends 00133 // the current selection set with the nodes that represent instances of components 00134 // of that style 00135 virtual void ExpandSelection(INodeTab& nodes) const = 0; 00136 00137 // This is how client code can get to the ADT Object Manager 00138 static IADTObjMgr* GetADTObjMgr() 00139 { 00140 return static_cast<IADTObjMgr*>(GetCOREInterface(ADT_OBJ_MGR_INTERFACE)); 00141 } 00142 }; 00143 00144 00145 00146