iADTStyle.h

Go to the documentation of this file.
00001      /**********************************************************************
00002  
00003     FILE: IADTStyle.h
00004 
00005     DESCRIPTION:  Public intefaces that defines the concept of ADT Styles
00006 
00007     CREATED BY: Attila Szabo, Discreet
00008 
00009     HISTORY: - created Sep 29, 2002
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 
00019 // Forward declarations
00020 class IADTCategory;
00021 class BitArray;
00022 
00023 // class IADTStyle
00024 //
00025 // This interface models an ADT Style that can have components
00026 // A number of ADT objects can be associated with the same style. These
00027 // objects are reffered to as style instances. The components of these
00028 // objects are associated with style components and are also reffered to as
00029 // style instance.
00030 //
00031 // Once a style is created through the ADT Object Manager, instances of that 
00032 // style can be created and components can be added to it
00033 // See iADTObjMgr for more details.
00034 class IADTStyle : public ReferenceTarget, public FPMixinInterface 
00035 {
00036     public:
00037     using ReferenceTarget::GetInterface;
00038     typedef int InstIterator;
00039     
00040     // Access to the name of the style. The name is not case sensitive.
00041         virtual const MCHAR* GetName() const = 0;
00042         virtual void SetName(const MCHAR* pName) = 0;
00043         
00044         // Creates an instance of the desired style, by associating it with a node. 
00045         // If the node represents an instance of another style,
00046         // that association will be destroyed first, and then a new one created.
00047         // - INode& styleInst - The node that will represent an instance of this style
00048         // - const bool hasCompVisOverride - A value of 'true' means that this particular
00049         // style instance has the visibility of some of its components overriden, i.e.
00050         // set to a different value than the visibility defined by the style for those
00051         // components.
00052         // - Returns an iterator that can be used later to get to this particular instance
00053         // of this style. A negative value means failure, while a positive value means success
00054         virtual InstIterator SetInstance(INode& styleInst, const bool hasCompVisOverride) = 0;
00055 
00056         // Destroys the association between the given node and this style, and between 
00057         // the instances of the components of this style and their style components. 
00058         // To find out if a node is a style instance, call 
00059         // IADTStyle* IADTObjMgr::IsStyleInstance(INode& n) const;
00060         // - INode& n - Node representing a style instance
00061         // - Returns false if the node is not a style instance.
00062         virtual bool RemoveInstance(INode& n) = 0;
00063     
00064     // Adds a component to this style, and in the same time, creates an instance
00065     // of the style component. This instance becomes a component of the style instance 
00066     // represented by the iterator. If the style already has a component with the given 
00067     // name, a new one won't be created. If the given node is already an instance
00068     // of another style or style component, this operation changes that and makes
00069     // it an instance of this style component.
00070     // The style component names are case in-sensitive, thus if a component with 
00071     // this name exists aleady, an new one won't be created.
00072     // - const Iterator& i - This iterator represents the style instance whose 
00073         // component we are creating
00074     // - INode& styleCompInst - The node that will represent an instance of the 
00075     // style component
00076     // - const MCHAR* pCompName - The name of the style component. Cannot be NULL.
00077     // It's not case sensitive
00078     // - const bool mtlOverride - A value of 'true' means that the material of this
00079     // style component instance is different than that defined by the style component
00080     // - const bool keepRelTransf - A value of 'true' means that the transform 
00081     // of the style component instance relative to the style instance should not be
00082     // changed by this operation
00083     // - Returns a pointer to the style component
00084     virtual IADTStyle* SetComponent(const InstIterator& instIt, 
00085                               INode& styleCompInst, 
00086                               const MCHAR* pCompName, 
00087                               const bool hasMtlOverride, 
00088                               const bool keepRelTransf) = 0;
00089 
00090         // A style component can be removed from a style if that style component
00091         // has zero instances associated with it.
00092     // - const MCHAR* pCompName - The name of the style component. Cannot be NULL.
00093     // It's not case sensitive
00094     // - Returns false if the component cannot be found or it still has instances
00095         virtual bool RemoveComponent(const MCHAR* pCompName) = 0;
00096         
00097     // Returns NULL if the style component does not exist
00098         virtual IADTStyle* FindComponent(const MCHAR* pCompName) const = 0;
00099         
00100     // TODO: style component iteration
00101         virtual unsigned long NumComponents() const = 0;
00102         virtual unsigned long GetComponents(Tab<IADTStyle*>& components) const = 0;
00103 
00104         // Returns NULL if the Style doesn't belong to a category. 
00105         // This indicates an inconsistency in the scene
00106         virtual IADTCategory* GetCategory() const = 0;
00107     
00108     // If this style is a component of another style, it returns that style
00109     // owtherwise itself
00110         virtual IADTStyle* GetCompositeStyle() = 0;
00111         
00112     // Returns the number of all nodes in the scene that represent instances of
00113     // this style. 
00114         virtual unsigned long NumInstances() const = 0;
00115     
00116         // Fills out the provided arrays with all the nodes in the scene that represent 
00117     // instances of this style and their material override flags. Returns their count
00118         virtual unsigned long GetInstances(Tab<INode*>& instances, BitArray* pMtlOverrides = NULL) const = 0;
00119         
00120         // Searches the instances of this style for a match with the provided style 
00121         // instance. If it finds it, returns the iterator withis this style to it,
00122         // material and visibility override information for the style instance.
00123         // - INode& styleInst - The alleged style instance to search for
00124         // - bool* pMtlOverride - The material override flag for the instance
00125         // - Returns an iterator to the found style instance. If the provided style
00126         // instance is not an instance of this style, the iterator value will be
00127         // negative.
00128         virtual InstIterator  FindInstance(INode& styleInst, bool* pMtlOverride = NULL) const = 0;
00129 
00130         // Returns true if the given style instance needs a selection box displayed
00131         // around it when selected
00132         virtual bool IsSelectionBoxNeeded(INode& styleInst) const = 0;
00133         
00134         // Creates a name that is unique among the names of all style components and it's 
00135         // based on the given name. The unique name is seeded by passing in a seed-name
00136         // through the MSTR&
00137         // - MSTR& - Input\Output parameter. As input parameter, it represents a seed
00138         // for the the unique name. As output parameter, it holds the unique name that 
00139         // was generated
00140         virtual void MakeUniqueComponentName(MSTR& name) const = 0;
00141 
00142 }; 
00143 
00144 
00145 
00146 #define ADT_STYLE_INTERFACE Interface_ID(0x4cd242c8, 0x554201b3)
00147 inline IADTStyle* GetADTStyleInterface(BaseInterface* baseIfc)  
00148 { 
00149     DbgAssert( baseIfc != NULL); 
00150     return static_cast<IADTStyle*>(baseIfc->GetInterface(ADT_STYLE_INTERFACE)); 
00151 }
00152