kfbxproperty.h

Go to the documentation of this file.
00001 
00003 #ifndef _KFbxProperty_h
00004 #define _KFbxProperty_h
00005 
00006 /**************************************************************************************
00007 
00008  Copyright © 2004 - 2007 Autodesk, Inc. and/or its licensors.
00009  All Rights Reserved.
00010 
00011  The coded instructions, statements, computer programs, and/or related material
00012  (collectively the "Data") in these files contain unpublished information
00013  proprietary to Autodesk, Inc. and/or its licensors, which is protected by
00014  Canada and United States of America federal copyright law and by international
00015  treaties.
00016 
00017  The Data may not be disclosed or distributed to third parties, in whole or in
00018  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00019 
00020  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00021  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00022  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00023  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE,
00024  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE.
00025  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00026  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE.
00027 
00028  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00029  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00030  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00031  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00032  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00033  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00034  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00035  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00036  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00037  OR DAMAGE.
00038 
00039 **************************************************************************************/
00040 
00041 #include <kaydaradef.h>
00042 #ifndef KFBX_DLL 
00043     #define KFBX_DLL K_DLLIMPORT
00044 #endif
00045 
00046 #ifndef MB_FBXSDK
00047 #include <kbaselib_nsuse.h>
00048 #endif
00049 #include <kbaselib_forward.h>
00050 
00051 #include <klib/kstring.h>
00052 #include <kfbxplugins/kfbxplug.h>
00053 #include <kfbxplugins/kfbxtypes.h>
00054 #include <kfcurve/kfcurvenode.h>
00055 #include <fbxfilesdk_nsbegin.h>
00056 
00057     class KFbxObject;
00058 
00059     class KFbxColor;
00060     class KFbxObject;
00061     class KFbxObject_internal;
00062     class KFbxProperty_internal;
00063     class KFbxSdkManager;
00064 
00068     class KFBX_DLL KFbxProperty : public KFbxPlug
00069     {
00070         KFBXPLUG_DECLARE(KFbxProperty);
00071 
00076         public:
00083             static KFbxProperty Create(KFbxObject* pObject, char const* pName, KFbxDataType const &pDataType=KFbxDataType(), char const* pLabel="");
00084 
00089             static KFbxProperty Create(KFbxObject* pObject, KFbxProperty& pFromProperty);
00090 
00097             static KFbxProperty Create(KFbxProperty const &pCompoundProperty, char const* pName, KFbxDataType const &pDataType=KFbxDataType(), char const* pLabel="");
00098 
00106             KFbxProperty const & StaticInit(KFbxObject* pObject, char const* pName, KFbxDataType const &pDataType, char const* pLabel);
00107 
00110             void Destroy(bool pRecursive = true, bool pDependents = false);
00111 
00114             KFbxProperty();
00115 
00118             KFbxProperty(KFbxProperty const &pProperty);
00119 
00122             ~KFbxProperty();
00123 
00124         public:
00126 
00130         public:
00134             KFbxDataType        GetPropertyDataType() const;
00135 
00139             KString             GetName() const;
00140 
00150             KString             GetLabel(bool pReturnNameIfEmpty=true);
00151 
00152 
00156             void                SetLabel(KString pLabel);
00157 
00161             KFbxObject*         GetFbxObject();
00162 
00163             void                SetUserTag(int pTag);
00164             int                 GetUserTag();
00166 
00171 
00178             typedef enum
00179             {
00180                 eNO_FLAG    = 0,
00181                 eANIMATABLE = 1, 
00182                 eUSER       = 1<<1,
00183                 eTEMPORARY  = 1<<2,  // System property
00184                 ePUBLISHED  = 1<<3, 
00185                 eSTATIC     = 1<<4, 
00186             } EFlags;
00187 
00192             void                ModifyFlag(EFlags pFlag, bool pValue);
00193 
00198             bool                GetFlag(EFlags pFlag);
00200 
00202         KFbxProperty &      operator=  (KFbxProperty const &pKProperty);
00203         bool                operator==(KProperty const* pKProperty) const;
00204         bool                operator== (KFbxProperty const &pKProperty) const;
00205         bool                operator!= (KFbxProperty const &pKProperty) const;
00206         bool CompareValue(KFbxProperty const& pProp) const;
00207 
00212         bool CopyValue(KFbxProperty const& pProp);
00213 
00214 
00219             bool            IsValid() const; 
00220 
00224             bool Set(void const *pValue,EFbxType pValueType);
00225 
00229             bool Get(void *pValue,EFbxType pValueType) const;
00230 
00231             // usefull set and get functions
00232             template <class T> inline bool  Set( T const &pValue )  { return Set( &pValue,FbxTypeOf(pValue) ); }
00233             template <class T> inline T     Get( T const *pFBX_TYPE) const { T lValue; Get( &lValue,FbxTypeOf(lValue) ); return lValue; }
00234 //          template <class T> inline T     Get( T *pValue) const           { T lValue; Get( &lValue,FbxTypeOf(lValue) ); if (pValue) { *pValue= lValue; } return lValue; }
00236 
00248             void                SetMinLimit(double pMin);
00249 
00253             double              GetMinLimit();
00254 
00258             void                SetMaxLimit(double pMax);
00262             double              GetMaxLimit();
00263 
00268             void                SetLimits(double pMin, double pMax);
00270 
00281             int                 AddEnumValue(char const *pStringValue);
00282 
00290             void                InsertEnumValue(int pIndex, char const *pStringValue);
00291 
00296             int                 GetEnumCount();
00297 
00306             void                SetEnumValue(int pIndex, char const *pStringValue);
00307 
00311             void                RemoveEnumValue(int pIndex);
00312 
00318             char *              GetEnumValue(int pIndex);
00320 
00325             int             GetPropertyCount();
00326             KFbxProperty    GetProperty(int pIndex);
00328 
00333             bool            SetArraySize( int pSize, bool pVariableArray );
00334             int             GetArraySize();
00335             KFbxProperty    GetArrayItem(int pIndex);
00336             inline KFbxProperty operator[](int pIndex) { return GetArrayItem(pIndex); }
00338 
00346             KFCurveNode* CreateKFCurveNode(const char* pTakeName=NULL);
00347 
00353             KFCurveNode* GetKFCurveNode(bool pCreateAsNeeded=false, const char* pTakeName=NULL);
00354             
00355 
00357 
00362             // Properties
00363             inline int          GetSrcPropertyCount     ()                                      { return GetFbxSrcCount(KFbxProperty::ClassId); }
00364             inline KFbxProperty GetSrcProperty          (int pIndex=0)                          { return *((KFbxProperty *)GetFbxSrc(pIndex,KFbxProperty::ClassId)); }
00365             inline KFbxProperty FindSrcProperty         (const char *pName,int pStartIndex=0)   { return *((KFbxProperty *)FindFbxSrc(pName,KFbxProperty::ClassId,pStartIndex)); }
00366             inline bool         ConnectSrcProperty      (KFbxProperty const & pProperty)        { return ConnectFbxSrc((KFbxPlug *)&pProperty);     }
00367             inline bool         IsConnectedSrcProperty      (KFbxProperty const & pProperty)    { return IsConnectedFbxSrc((KFbxPlug *)&pProperty); }
00368             inline bool         DisconnectSrcProperty   (KFbxProperty const & pProperty)        { return DisconnectFbxSrc((KFbxPlug *)&pProperty);  }
00369 
00370             inline int          GetDstPropertyCount     ()                                      { return GetFbxDstCount(KFbxProperty::ClassId); }
00371             inline KFbxProperty GetDstProperty          (int pIndex=0)                          { return *((KFbxProperty *)GetFbxDst(pIndex,KFbxProperty::ClassId)); }
00372             inline KFbxProperty FindDstProperty         (const char *pName,int pStartIndex=0)   { return *((KFbxProperty *)FindFbxDst(pName,KFbxProperty::ClassId,pStartIndex)); }
00373             inline bool         ConnectDstProperty      (KFbxProperty const & pProperty)        { return ConnectFbxDst((KFbxPlug *)&pProperty);     }
00374             inline bool         IsConnectedDstProperty  (KFbxProperty const & pProperty)        { return IsConnectedFbxDst((KFbxPlug *)&pProperty); }
00375             inline bool         DisconnectDstProperty   (KFbxProperty const & pProperty)        { return DisconnectFbxDst((KFbxPlug *)&pProperty);  }
00377 
00378         virtual void  SetUserDataPtr(void* pUserData);
00379         virtual void* GetUserDataPtr();
00380 
00381 
00382         // Deprecated function calls
00383         typedef enum {   eUNIDENTIFIED,eBOOL,eREAL,eCOLOR,eINTEGER,eVECTOR,eLIST, eMATRIX} EUserPropertyType;
00384 
00385 //      K_DEPRECATED static             KFbxProperty Create(KFbxSdkManager& pManager, char const* pName, KFbxDataType const &pDataType=KFbxDataType(), char const* pLabel="");
00386         K_DEPRECATED static char*       GetPropertyTypeName(EUserPropertyType pType);
00387         K_DEPRECATED char *             GetPropertyTypeName();
00388         K_DEPRECATED EUserPropertyType  GetPropertyType();
00389 
00390         K_DEPRECATED void               SetDefaultValue(bool pValue);
00391         K_DEPRECATED void               SetDefaultValue(double pValue);
00392         K_DEPRECATED void               SetDefaultValue(KFbxColor& pValue);
00393         K_DEPRECATED void               SetDefaultValue(int pValue);
00394         K_DEPRECATED void               SetDefaultValue(double pValue1, double pValue2, double pValue3);
00395         K_DEPRECATED void               GetDefaultValue(bool& pValue);
00396         K_DEPRECATED void               GetDefaultValue(double& pValue);
00397         K_DEPRECATED void               GetDefaultValue(KFbxColor& pValue);
00398         K_DEPRECATED void               GetDefaultValue(int& pValue);
00399         K_DEPRECATED void               GetDefaultValue(double& pValue1, double& pValue2, double& pValue3);
00400 
00402         //
00403         //  WARNING!
00404         //
00405         //  Anything beyond these lines may not be documented accurately and is 
00406         //  subject to change without notice.
00407         //
00409         #ifndef DOXYGEN_SHOULD_SKIP_THIS
00410         protected:
00411              /* The pLabel parameter is defined for backward compatibility. Older FBX files
00412                 saved it along with the other attributes. Now, the label attribute exists only while
00413                 the property object is in memory and is lost when saving to the FBX file.
00414               */
00415 
00417             static KFbxProperty* Create(KFbxSdkManager& pManager, KProperty* pProperty);
00418             KFbxProperty(KFbxSdkManager& pManager, KProperty* pProperty);
00419             KFbxProperty(KFbxSdkManager& pManager, char const* pName, KFbxDataType const &pDataType=KFbxDataType(), char const* pLabel="");
00420             KFbxProperty(KFbxObject* pObject, char const* pName, KFbxDataType const &pDataType=KFbxDataType(), char const* pLabel="");
00421             KFbxProperty(KFbxProperty_internal *pPropertyInfo);
00422 
00423             void Init(KFbxSdkManager& pManager, char const* pName, KFbxDataType const &pDataType=KFbxDataType(), char const* pLabel="");
00424 
00425             // Virtual plug overides
00426             virtual KFbxSdkManager*     GetFbxSdkManager();
00427             virtual KPlug*              GetInternalPlug(bool pCreateOnDemand=false);
00428             virtual KPlug const*        GetInternalPlug(bool pCreateOnDemand=false) const;
00429             bool                        CreateKProperty();
00430             bool                        DestroyKProperty();
00431             KProperty*                  GetKProperty();
00432             bool                        FbxPlugNotify(KFbxPlugEvent const &pEvent);
00433 
00434             void                        SetFbxObject(KFbxObject* pKFbxObject);
00435 
00436 //          void                        SetKFbxObject_internal(KFbxObject_internal* pKFbxObject_internal);
00437 
00438             private:
00440                 KFbxProperty_internal* mData;
00441 
00442             // Needed internal 
00443             friend class KFbxObject;
00444             friend class KFbxTakeNodeContainer;
00445             friend class KFbxObject_internal;
00446             friend class KFbxReaderFbx;
00447 
00448         #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00449     };
00450 
00451     typedef KFbxProperty* HKFbxProperty;
00452 
00453     template <class T> inline bool  KFbxSet( KFbxProperty &pProperty,T const &pValue )  { return pProperty.Set( &pValue,FbxTypeOf(pValue) ); }
00454     template <class T> inline bool  KFbxGet( KFbxProperty const& pProperty,T &pValue )      { return pProperty.Get( &pValue,FbxTypeOf(pValue) ); }
00455     template <class T> inline T     KFbxGet( KFbxProperty const& pProperty)                 { T pValue; pProperty.Get( &pValue,FbxTypeOf(pValue) ); return pValue; }
00456 
00457     template <class T> class KFbxTypedProperty : public KFbxProperty {
00458         public:
00459             inline KFbxTypedProperty() : KFbxProperty()                                         {}
00460             inline KFbxTypedProperty(KFbxProperty const &pProperty) : KFbxProperty(pProperty)   {}
00461             inline ~KFbxTypedProperty()                                                         {}
00462 
00463             inline KFbxProperty const & StaticInit(KFbxObject* pObject, char const* pName,EFlags pFlags=eNO_FLAG) 
00464             {
00465                 KFbxProperty::StaticInit(pObject, pName, GetFbxDataType(FbxTypeOf(*((T *)0))), "");
00466                 ModifyFlag(pFlags, true);
00467                 return *this;
00468             }
00469             inline KFbxProperty const & StaticInit(KFbxObject* pObject, char const* pName,T const &pValue,EFlags pFlags=eNO_FLAG) 
00470             {
00471                 KFbxProperty::StaticInit(pObject, pName, GetFbxDataType(FbxTypeOf(*((T *)0))), "");
00472                 Set(pValue);
00473                 ModifyFlag(pFlags, true);
00474                 return *this;
00475             }
00476 
00477             inline KFbxProperty const & StaticInit(KFbxObject* pObject, char const* pName, KFbxDataType const &pDataType,EFlags pFlags=eNO_FLAG) 
00478             {
00479                 KFbxProperty::StaticInit(pObject, pName, pDataType, "");
00480                 ModifyFlag(pFlags, true);
00481                 return *this;
00482             }
00483             inline KFbxProperty const & StaticInit(KFbxObject* pObject, char const* pName, KFbxDataType const &pDataType,T const &pValue,EFlags pFlags=eNO_FLAG)
00484             {
00485                 KFbxProperty::StaticInit(pObject, pName, pDataType, "");
00486                 Set(pValue);
00487                 ModifyFlag(pFlags, true);
00488                 return *this;
00489             }
00490         public:
00491             KFbxTypedProperty &operator =(T const &pValue)      { KFbxSet(*this,pValue); return *this; }
00492             bool     Set(T const &pValue)   { return KFbxSet(*this,pValue); }
00493             T        Get() const            { T lValue; KFbxGet(*this,lValue); return lValue; }
00494 
00495         friend class KFbxObject;
00496     };
00497 
00498     // For use with deprecated type functions 
00499     KFbxDataType                        EUserPropertyTypeToDataType(KFbxProperty::EUserPropertyType);
00500     KFbxProperty::EUserPropertyType     DataTypeToEUserPropertyType(const KFbxDataType &pDataType);
00501 
00502 
00503     typedef KFbxTypedProperty<fbxBool1>         KFbxPropertyBool1;
00504     typedef KFbxTypedProperty<fbxInteger1>      KFbxPropertyInteger1;
00505     typedef KFbxTypedProperty<fbxDouble1>       KFbxPropertyDouble1;
00506     typedef KFbxTypedProperty<fbxDouble3>       KFbxPropertyDouble3;
00507     typedef KFbxTypedProperty<fbxDouble4>       KFbxPropertyDouble4;
00508     typedef KFbxTypedProperty<fbxString>        KFbxPropertyString;
00509  
00510 
00511 #include <fbxfilesdk_nsend.h>
00512 
00513 #endif // _KFbxProperty_h
00514 
00515