Instance.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2005-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 //  $Header: //DWF/Development/Components/Internal/DWF Toolkit/v7.6/develop/global/src/dwf/package/Instance.h#2 $
00019 //  $DateTime: 2008/06/18 18:08:14 $
00020 //  $Author: gaoje $
00021 //  $Change: 101166 $
00022 //  $Revision: #2 $
00023 //
00024 
00025 #ifndef _DWFTK_INSTANCE_H
00026 #define _DWFTK_INSTANCE_H
00027 
00032 
00033 #include "dwfcore/STL.h"
00034 #include "dwfcore/Vector.h"
00035 #include "dwfcore/SkipList.h"
00036 
00037 #include "dwf/Toolkit.h"
00038 #include "dwf/package/XML.h"
00039 
00040 namespace DWFToolkit
00041 {
00042 
00043 //
00044 // fwd declarations
00045 //
00046 class DWFRenderable;
00047 
00048 
00061 class DWFInstance : public DWFXMLBuildable
00062 #ifndef DWFTK_READ_ONLY
00063                   , public DWFXMLSerializable
00064 #endif
00065                   _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00066 {
00067 
00068 public:
00069 
00073     typedef DWFOrderedVector<DWFInstance*>          tList;
00077     typedef DWFStringKeySkipList<DWFInstance*>      tMap;
00082     typedef DWFCachingIterator<DWFInstance*>        tCachingIterator;
00086     typedef DWFIterator<DWFInstance*>               tIterator;
00087 
00091     //
00092     // These are bit flags
00093     //
00094     typedef enum teAttributes {
00095 
00099         eVisible        = 0x01,
00100 
00104         eTransparent    = 0x02
00105 
00106     } teAttributes;
00107 
00108 public:
00109 
00123     _DWFTK_API
00124     DWFInstance( const DWFString&   zInstanceID,
00125                  DWFRenderable*     pRenderedElement,
00126                  int                iNodeID,
00127                  unsigned int       nAttributes = DWFInstance::eVisible,
00128                  int                nGeometricVariationIndex = -1 )
00129         throw( DWFException );
00130 
00139     _DWFTK_API
00140     DWFInstance()
00141         throw();
00142 
00148     _DWFTK_API
00149     virtual ~DWFInstance()
00150         throw();
00151 
00158     _DWFTK_API
00159     const DWFString& id() const
00160         throw()
00161     {
00162         return _zID;
00163     }
00164 
00171     _DWFTK_API
00172     DWFRenderable* getRenderedElement() const
00173         throw()
00174     {
00175         return _pRenderedElement;
00176     }
00177 
00184     _DWFTK_API
00185     int getNodeID() const
00186         throw()
00187     {
00188         return _nNodeID;
00189     }
00190 
00197     _DWFTK_API
00198     bool getVisibility() const
00199         throw()
00200     {
00201         return ((_nAttributeFlags & eVisible) ? true : false);
00202     }
00203 
00209     _DWFTK_API
00210     void setVisibility( bool bVisible )
00211         throw()
00212     {
00213         if (bVisible)
00214         {
00215             _nAttributeFlags |= eVisible;
00216         }
00217         else
00218         {
00219             _nAttributeFlags &= ~eVisible;
00220         }
00221     }
00222 
00229     _DWFTK_API
00230     bool getTransparency() const
00231         throw()
00232     {
00233         return ((_nAttributeFlags & eTransparent) ? true : false);
00234     }
00235 
00241     _DWFTK_API
00242     void setTransparency( bool bTransparent )
00243         throw()
00244     {
00245         if (bTransparent)
00246         {
00247             _nAttributeFlags |= eTransparent;
00248         }
00249         else
00250         {
00251             _nAttributeFlags &= ~eTransparent;
00252         }
00253     }
00254 
00262     _DWFTK_API
00263     unsigned int getGraphicsAttributes() const
00264         throw()
00265     {
00266         return _nAttributeFlags;
00267     }
00268 
00276     _DWFTK_API
00277     void setGraphicsAttributes( unsigned int nAttributes)
00278         throw( DWFException )
00279     {
00280         if (nAttributes > (eVisible | eTransparent))
00281         {
00282             _DWFCORE_THROW( DWFInvalidArgumentException, /*NOXLATE*/L"Trying to set unknown attribute flags on the instance" );
00283         }
00284 
00285         _nAttributeFlags = nAttributes;
00286     }
00287 
00295     _DWFTK_API
00296     int getGeometricVariationIndex() const
00297         throw()
00298     {
00299         return _nGeometricVariationIndex;
00300     }
00301 
00307     _DWFTK_API
00308     void setGeometricVariationIndex( int nIndex )
00309         throw()
00310     {
00311         _nGeometricVariationIndex = nIndex;
00312     }
00313 
00317     _DWFTK_API
00318     virtual void parseAttributeList( const char** ppAttributeList )
00319         throw( DWFException );
00320 
00321 #ifndef DWFTK_READ_ONLY
00322 
00326     _DWFTK_API
00327     void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00328         throw( DWFException );
00329 
00330 #endif
00331 
00339     _DWFTK_API
00340     void setRenderable( DWFRenderable* pRenderable )
00341     {
00342         _pRenderedElement = pRenderable;
00343     }
00344 
00345 private:
00346 
00347     _DWFTK_API
00348     void _identify( const DWFString& zID )
00349         throw()
00350     {
00351         _zID = zID;
00352     }
00353 
00354 private:
00355 
00356     //
00357     // The UUID of the instance.
00358     //
00359     DWFString           _zID;
00360 
00361     //
00362     // The object or feature that the instance renders.
00363     //
00364     DWFRenderable*      _pRenderedElement;
00365 
00366     //
00367     // The resource-specific ID of the graphics node - 2D or 3D, that
00368     // corresponds to the graphical rendition of the above object.
00369     //
00370     int                 _nNodeID;
00371 
00372     //
00373     // The graphics attributes of the instance
00374     //
00375     unsigned int        _nAttributeFlags;
00376 
00377     //
00378     // This just gives the published index of the geomtric variation to
00379     // activate. The publisher needs to ensure that the index is valid.
00380     // A -1 indicates that there are no geometric variations.
00381     //
00382     int                 _nGeometricVariationIndex;
00383 
00384 private:
00385 
00386     //
00387     // Not Implemented
00388     //
00389     DWFInstance( const DWFInstance& );
00390     DWFInstance& operator=( const DWFInstance& );
00391 
00392 };
00393 
00394 }
00395 
00396 #endif
00397 

Generated on Tue Jan 6 22:40:03 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5