iassemblymgr.h

Go to the documentation of this file.
00001  /**********************************************************************
00002  
00003     FILE: IAssemblyMgr.h
00004 
00005     DESCRIPTION:  Public interface for defining and working with assemblies
00006 
00007     CREATED BY: Attila Szabo, Discreet
00008 
00009     HISTORY: - created April 03, 2001
00010 
00011  *> Copyright (c) 1998-2000, All Rights Reserved.
00012  **********************************************************************/
00013 #pragma once
00014 
00015 #include "iFnPub.h"
00016 #include "iassembly.h"
00017 #include "GetCOREInterface.h"
00018 
00019 // forward declarations
00020 class INode;
00021 class INodeTab;
00022 class HitByNameDlgCallback;
00023 class Box3;
00024 
00025 // class IAssemblyMgr
00026 //
00027 // This interface allows for working with assemblies and its methods are
00028 // implemented by the system (Max). One can get this interface by calling 
00029 // IAssemblyMgr* GetAssemblyMgr();
00030 //
00031 // Assemblies are very similar to groups. The main differences are:
00032 // - As opposed to a group head object, an assembly head can be any object, 
00033 //   not just a dummy object
00034 // - The base object of an assembly head node can be edited in the modify panel
00035 class IAssemblyMgr : public FPStaticInterface 
00036 {
00037     public:
00038         // Creates an assembly from the supplied nodes. 
00039         // If called with the default parameters, the user is asked to provide 
00040         // a name and pick a head object for the assembly. After creation the 
00041         // assembly is selected.
00042         //
00043         // PARAMETERS:
00044         // const INodeTab* const nodes  
00045         //   List of nodes to assemble. Only those nodes which can be assembled are
00046         //   assembled, the others are not taken into account. If no nodes are supplied
00047         //   (NULL) the current selection set is used.
00048         //
00049         // const MCHAR* name            
00050         //   The name of the assembly. If not supplied the user
00051         //   is presented with a unique assembly name that he can change.
00052         //
00053         // const ClassDesc* cd      
00054         //   Describes the head object type. 
00055         //   The head object must be a helper object.
00056         //   If a ClassDesc is not supplied, the user is asked to choose a head object
00057     //   from a list of objects
00058         //
00059         // bool select 
00060         //   Controls whether the assembly is selected or not after creation
00061         //
00062         // RETURNS:
00063         //   Returns a pointer to the assembly node created or NULL if none of the
00064         //   nodes could be assembled or something went wrong.
00065         virtual INode*  Assemble(
00066             const INodeTab* const nodes = NULL, 
00067             const MCHAR* name = NULL, 
00068             const ClassDesc* const cd = NULL,
00069             bool select = true) = 0;
00070 
00071         // Destroys the assemblies found in the given set of nodes. 
00072         // - Deletes the assembly head node and base object
00073         // - The members of the assembly are not destroyed
00074         // - If no list is supplied (NULL) the current selection set is used
00075         //
00076         // RETURNS:
00077         //   True on success   
00078         virtual bool        Disassemble(const INodeTab* const nodes = NULL) = 0;
00079         
00080         // Explodes the assemblies found in the given set of nodes. 
00081         // As opposed to Disassemble, it acts recursively on assemblies
00082         // (destroys nested assemblies). If no nodes are supplied (NULL) the 
00083         // current selection set is used
00084         //
00085         // RETURNS:
00086         //   True on success   
00087         virtual bool        Explode(const INodeTab* const nodes = NULL) = 0;
00088         
00089         // Puts the assemblies found in the given set of nodes
00090         // in a state where the users can access their members 
00091         // - It doesn't act recursively on assemblies.
00092         //
00093         // PARAMETERS:
00094         // const INodeTab* const nodes  
00095         // - Assembly head nodes to open. If no nodes are supplied (NULL) 
00096         // the current selection set is used
00097         //
00098         // bool clearSelection
00099         // - If TRUE, the nodes will be unselected after the operation is completed.
00100         //
00101         // RETURNS:
00102         //   True on success   
00103         virtual bool        Open(const INodeTab* const nodes = NULL, bool clearSelection = true) = 0;
00104         
00105         // Opposite of Open
00106         virtual bool        Close(const INodeTab* const nodes = NULL, bool select = true) = 0;
00107 
00108         // Attaches the supplied nodes to the given assembly 
00109         // - Only nodes that are attach-able are attached
00110         // - If called with the default parameters, the user is asked to provide
00111         // the assembly to which the nodes are to be attached
00112         //
00113         // PARAMETRS:
00114         // const INodeTab* const nodes  
00115         //   List of nodes to attach to an assembly. Only those nodes 
00116         //   which can be attached are attached. If no nodes are supplied (NULL) 
00117         //   the current selection set is used
00118         //
00119         // const INode* const assembly
00120         //   Pointer to a member or head node of the assembly to which the nodes
00121         //   should be attached. If none is supplied the user is asked to pick an
00122         //   assembly to which the nodes will be attached.
00123         //
00124         // RETURNS:
00125         //   Returns false if none of the nodes could be attached or if something went wrong
00126         virtual bool        Attach(const INodeTab* const nodes = NULL, const INode* const assembly = NULL) = 0;
00127 
00128         // Detaches the given nodes from the assembly they belong to.
00129         // If no nodes are supplied (NULL) the current selection set is used.
00130         //
00131         // RETURNS:
00132         //   Returns false if none of the nodes could be detached or if something went wrong
00133         virtual bool        Detach(const INodeTab* const nodes = NULL) = 0;
00134 
00135         //
00136         // --- Helper methods       
00137         //
00138 
00139         // Checks whether the nodes to be assembled comply with these rules:
00140         // - Nodes must have the scene root as their common and direct parent OR
00141         // their parent must be in the list of nodes to be assembled
00142         // - If the common parent node is an assembly head node, and has some children 
00143         // that are members, and others that aren't, then the candidate nodes for 
00144         // assembling must be all members, or all non-members.
00145         // - Closed member nodes are ignored and their parent assembly node 
00146         // is added to the new assembly. 
00147         // - In case of nodes that are already members of an assembly, their new
00148         // assembly node will become a member of that assembly.
00149         // - If no nodes are supplied (NULL) the current selection set is used.
00150         //
00151         // DEFAULTS:
00152         //   Operates on active selection set
00153         //
00154         // RETURNS:
00155         //   Returns true only if all nodes can be assembled, otherwise returns false.
00156         virtual bool    CanAssemble(const INodeTab* const nodes = NULL) = 0;
00157 
00158         // Checks whether the nodes comply with these rules:
00159         // - Only assembly closed heads can be disassembled
00160         // - Assembly heads which are members of another assembly can be
00161         // disassembled only if the enclosing assembly is open.
00162         // - If no nodes are supplied (NULL) the current selection set is used.
00163         //
00164         // DEFAULTS:
00165         //   Operates on active selection set
00166         //
00167         // RETURNS:
00168         //   Returns true if at least one assembly is found that complies with the
00169         //   rules above.
00170         virtual bool    CanDisassemble(const INodeTab* const nodes = NULL) = 0;
00171 
00172         // Checks whether the nodes comply with these rules:
00173         // - There has to be at least one closed assembly head selected
00174         // - If no nodes are supplied (NULL) the current selection set is used.
00175         //
00176         // DEFAULTS:
00177         //   Operates on active selection set
00178         //
00179         // RETURNS:
00180         //   Returns false if none of the given nodes pass the test
00181         virtual bool    CanExplode(const INodeTab* const nodes = NULL) = 0;
00182 
00183         // Checks whether the nodes comply with these rules:
00184         // - There has to be at least one closed assembly head selected
00185         // - If no nodes are supplied (NULL) the current selection set is used.
00186         //
00187         // DEFAULTS:
00188         //   Operates on active selection set
00189         //
00190         // RETURNS:
00191         //   Returns false if none of the given nodes pass the test
00192         virtual bool    CanOpen(const INodeTab* const nodes = NULL) = 0;
00193 
00194         // Checks whether the nodes comply with these rules:
00195         // - There has to be at least one open assembly head or member selected
00196         // - If no nodes are supplied (NULL) the current selection set is used.
00197         //
00198         // DEFAULTS:
00199         //   Operates on active selection set
00200         //
00201         // RETURNS:
00202         //   Returns false if none of the given nodes pass the test
00203         virtual bool    CanClose(const INodeTab* const nodes = NULL) = 0;
00204 
00205         // Checks whether the nodes comply with these rules:
00206         // - Nodes must be good for assembling 
00207         // - Nodes should not contain open assembly members
00208         // - If an assembly is not specified, there has to be an assembly 
00209         // in the current scene that the given nodes are not part of 
00210         //
00211         // PARAMETRS:
00212         // const INodeTab* const nodes  
00213         //   List of nodes to attach to an assembly. If no nodes are supplied (NULL) 
00214         //   the current selection set is used.
00215         //
00216         // const INode* const assembly
00217         //   Pointer to a member or head node of an assembly to attach the nodes to.
00218         //   If none supplied (NULL) the user has to pick one.
00219         //
00220         // DEFAULTS:
00221         //   Operates on active selection set
00222         //
00223         // RETURNS:
00224         //   Returns false if none of the given nodes can be attached
00225         //   or there's no assembly to attach the nodes to
00226         virtual bool    CanAttach(const INodeTab* const nodes = NULL, const INode* const assembly = NULL) = 0;
00227 
00228         // Checks whether the nodes comply with these rules:
00229         // - Nodes must each have a parent that is an open assembly member
00230         // - If no nodes are supplied (NULL) the current selection set is used.
00231         //
00232         // DEFAULTS:
00233         //   Operates on active selection set
00234         //
00235         // RETURNS:
00236         //   Returns false if none of the given nodes pass the test
00237         virtual bool    CanDetach(const INodeTab* const nodes = NULL) = 0;
00238 
00239         // Checks if all nodes in the given array belong to the same level (outer) assembly. 
00240         //
00241         // PARAMETRS:
00242         // const INodeTab* const nodes  
00243         //  List of nodes check. If no nodes are provided (NULL) the method works on the current selection.
00244         //
00245         // RETURNS:
00246         //  Pointer to the assembly head node - If the array of nodes passed in as parameter belong 
00247         //  to the same closed assembly. Nodes that are part of an inner assembly are not 
00248         //  taken into account, are ignored, they are considered as just one node in the outer assembly.
00249         //  NULL - If the array of nodes passed in as parameter contains no assembly, 
00250         //  more than one high level assembly or not all nodes are members of the same 
00251         //  high level\outer assembly.
00252         virtual INode*  IsAssembly(const INodeTab* const nodes = NULL) = 0;
00253 
00254         //  Filters the members of a given assembly based on a given object type.
00255         //  This method does not iterate through the nodes of inner closed assemblies.
00256         //  If the geometry pipeline associated with the assembly member node contains a
00257         //  modifier or base object with the super class ID specified as filtering criteria
00258         //  that node is saved into the filteredNodes output parameter.
00259         //
00260         // PARAMETRS:
00261         //  const INode* const assemblyHead - An assembly head node. Can be open or closed assembly head. 
00262         //  const SClass_ID filterSClassID  - Superclass ID describing the type wanted to be fileterd
00263         //  INodeTab&   filteredNodes                   - The filtered assembly members. This is an output parameter
00264         //
00265         // RETURNS:
00266         //  An array of nodes. The array contains the nodes that are members of the 
00267         //  assembly parameter and which pass   the filter criteria. Nodes of inner 
00268         //  assemblies will not taken into account by this method.
00269         virtual bool    FilterAssembly(
00270             const INode* const assemblyHead, 
00271             const SClass_ID filterSClassID, 
00272             INodeTab& filteredNodes) = 0;
00273 
00274         // Returns a pointer to a hit by name dialog class
00275         virtual const HitByNameDlgCallback* GetHitByNameDlgCB() const = 0;
00276 
00277         // Calculates the world bounding box of the whole assembly and 
00278     // transforms it into the assembly head node's space
00279         virtual void  GetWorldBBox(TimeValue t, INode* assemblyHead, Box3& worldBBox) const = 0;
00280 
00281         // Function IDs for function publishing
00282         enum 
00283         { 
00284             E_ASSEMBLE, 
00285             E_DISASSEMBLE, 
00286             E_OPEN, 
00287             E_CLOSE, 
00288             E_EXPLODE, 
00289             E_ATTACH, 
00290             E_DETACH, 
00291             E_CAN_ASSEMBLE, 
00292             E_CAN_DISASSEMBLE, 
00293             E_CAN_EXPLODE, 
00294             E_CAN_OPEN, 
00295             E_CAN_CLOSE, 
00296             E_CAN_ATTACH, 
00297             E_CAN_DETACH, 
00298             E_IS_ASSEMBLY,
00299             E_FILTER_ASSEMBLY,
00300         }; 
00301 
00302 }; 
00303 
00304 
00305 // Assembly Manager interface ID
00306 #define ASSEMBLY_MGR_INTERFACE Interface_ID(0x576c528f, 0x5cc23607)
00307 inline IAssemblyMgr* GetAssemblyMgr() { return static_cast<IAssemblyMgr*>(GetCOREInterface(ASSEMBLY_MGR_INTERFACE)); }
00308 
00309