FBX SDK Reference Guide: kfbxiosettings.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_IO_SETTINGS_H_
00005 #define _FBXSDK_IO_SETTINGS_H_
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2001 - 2008 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 
00042 #include <kaydaradef.h>
00043 #ifndef KFBX_DLL 
00044     #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046 
00047 // libxml is not included on CFM.
00048 #ifndef KARCH_ENV_MACOSX_CFM
00049 
00050 
00051 #include <klib/karrayul.h>
00052 #include <klib/kstring.h>
00053 
00054 #ifndef MB_FBXSDK
00055 #include <kbaselib_nsuse.h>
00056 #endif
00057 
00058 
00059 #include <kfbxplugins/kfbxobject.h>
00060 
00061 #include <libxml.h>
00062 #include <libxml/parser.h>
00063 #include <libxml/tree.h>
00064 #include <libxml/globals.h>
00065 
00066 
00067 #include <kfbxplugins/kfbxtypes.h>
00068 
00069 #include <kbaselib_forward.h>
00070 #include <fbxfilesdk_nsbegin.h>
00071 
00072 #include "kfbxiosettingspath.h"
00073 
00074 #define IOSREF  KFbxIOSettings::IOSettingsRef()
00075 
00076 #define IOSVisible    true
00077 #define IOSHidden     false
00078 
00079 #define IOSSavable    true
00080 #define IOSNotSavable false
00081 
00082 #define IOSEnabled    true
00083 #define IOSDisabled   false
00084 
00085 
00086 #define IOSBinary     0
00087 #define IOSASCII      1
00088 
00089 // class to handle old StreamOptions information
00090 class KsoInfo
00091 {
00092 
00093 public: enum EIMPEXP
00094 {
00095     eIMPORT = 0,
00096     eEXPORT
00097 };
00098 
00099 public: 
00100     KsoInfo();
00101 
00103     void Reset(EIMPEXP pImpExp);
00104     
00106     void SetTimeMode(KTime::ETimeMode pTimeMode, double pCustomFrameRate = 0.0);
00107 
00109     KTime::ETimeMode GetTimeMode(){ return mTimeMode; }
00110 
00112     KTime GetFramePeriod();
00113     
00114     void SetASFScene(KFbxObject* pASFScene, bool pASFSceneOwned = false);
00115     KFbxObject* GetASFScene(){ return mASFScene; }
00116 
00117     //-----------------
00118     // data
00119 
00120 private: 
00121         KTime::ETimeMode mTimeMode;
00122         KFbxObject * mASFScene;
00123 
00124         EIMPEXP mImpExp;
00125 };
00126 
00127 class KFbxSdkManager;
00128 
00129 
00130 // http://www.microsoft.com/globaldev/reference/winxp/langtla.mspx
00131 
00132 //  LOCALE                            TLA  LCID
00133 
00134 //  English - United States           ENU  0409
00135 //  German - Germany                  DEU  0407
00136 //  French - France                   FRA  040c
00137 //  Japanese - Japan                  JPN  0411
00138 //  Korean(Extended Wansung) - Korea  KOR  0412
00139 //  Chinese - PRC                     CHS  0804
00140 
00141 enum FBXUILANGUAGE
00142 {
00143     eENU = 0,                   // MAX 409 English - United States
00144     eDEU,                       // MAX 407 German - Germany
00145     eFRA,                       // MAX 40c French - France
00146     eJPN,                       // MAX 411 Japanese - Japan
00147     eKOR,                       // MAX 412 Korean(Extended Wansung) - Korea 
00148     eCHS,                       // MAX 804 Chinese - PRC
00149     eFBXUILANGUAGE_COUNT
00150 };
00151 
00152 static const char* XML_LAGUAGE_LABELS[] = 
00153 {
00154     "lbENU",       // = eENU English - United States
00155     "lbDEU",       // = eDEU German - Germany                  
00156     "lbFRA",       // = eFRA French - France
00157     "lbJPN",       // = eJPN Japanese - Japan
00158     "lbKOR",       // = eKOR Korean(Extended Wansung) - Korea
00159     "lbCHS"        // = eCHS Chinese - PRC
00160 };
00161 
00162 static const char* LAGUAGE_SYMBOLS[] = 
00163 {
00164     "ENU",       // = eENU English - United States
00165     "DEU",       // = eDEU German - Germany                  
00166     "FRA",       // = eFRA French - France
00167     "JPN",       // = eJPN Japanese - Japan
00168     "KOR",       // = eKOR Korean(Extended Wansung) - Korea
00169     "CHS"        // = eCHS Chinese - PRC
00170 };
00171 
00172 // this class is located in the UserDataPtr of each KFbxIOSettings properties
00173 class PropInfo
00174 {
00175 public:
00176     PropInfo();
00177     ~PropInfo();
00178 
00179     void            * UIWidget;            // UI widget for showing the property
00180     void            * cbValueChanged;      // call back when value changed
00181     void            * cbDirty;             // call back when value changed
00182     KStringList       labels;              // list of labels in many languages
00183 };
00184 
00185 
00186 
00193 class KFBX_DLL KFbxIOSettings : public KFbxObject
00194 {
00195 
00196 KFBXOBJECT_DECLARE(KFbxIOSettings,KFbxObject);
00197 
00199 public: virtual ~KFbxIOSettings();
00200 
00202 public: static void AllocateIOSettings(KFbxSdkManager& pManager);
00203 
00204 public: static bool IsIOSettingsAllocated();
00205 
00207 public: void FreeIOSettings();
00208 
00210 public: static KFbxIOSettings& IOSettingsRef();
00211 
00213 public: virtual void Clear();
00214 
00216 public: KFbxProperty AddPropertyGroup(char const* pName, KFbxDataType const &pDataType=KFbxDataType(), char const* pLabel="");
00217 
00219 public: KFbxProperty AddPropertyGroup(  KFbxProperty const &pParentProperty, 
00220                                         char const*         pName, 
00221                                         KFbxDataType const &pDataType      = KFbxDataType(), 
00222                                         char const*         pLabel         = "",
00223                                         bool                pVisible       = true,
00224                                         bool                pSavable       = true,
00225                                         bool                pEnabled       = true
00226                                      );
00227 
00229 public: KFbxProperty AddProperty(    KFbxProperty const     &pParentProperty, 
00230                                      char const*            pName, 
00231                                      KFbxDataType const     &pDataType      = KFbxDataType(), 
00232                                      char const*            pLabel          = "",
00233                                      void const*            pValue          = NULL,
00234                                      EFbxType               pValueType      = eUNIDENTIFIED,
00235                                      bool                   pVisible        = true,
00236                                      bool                   pSavable        = true,
00237                                      bool                   pEnabled        = true
00238                                    );
00239 
00241 public: KFbxProperty AddPropertyMinMax(    KFbxProperty const     &pParentProperty, 
00242                                      char const*            pName, 
00243                                      KFbxDataType const     &pDataType      = KFbxDataType(), 
00244                                      char const*            pLabel          = "",
00245                                      void const*            pValue          = NULL,
00246                                      double const*          pMinValue       = NULL,
00247                                      double const*          pMaxValue       = NULL,
00248                                      EFbxType               pValueType      = eUNIDENTIFIED,                                     
00249                                      bool                   pVisible        = true,
00250                                      bool                   pSavable        = true,
00251                                      bool                   pEnabled        = true
00252                                    );
00253 
00254 
00256 public: KFbxProperty GetProperty(char const* pName);
00257 
00259 public: KFbxProperty GetProperty(KFbxProperty const &pParentProperty, char const* pName);
00260 
00262 public: bool GetBoolProp(char const* pName, bool pDefValue);
00263 public: void SetBoolProp(char const* pName, bool pValue);
00264 
00266 public: double GetDoubleProp(char const* pName, double pDefValue);
00267 public: void   SetDoubleProp(char const* pName, double pValue);
00268 
00270 public: int    GetIntProp(char const* pName, int pDefValue);
00271 public: void   SetIntProp(char const* pName, int pValue);
00272 
00274 public: KTime  GetKTimeProp(char const* pName, KTime pDefValue);
00275 public: void   SetKTimeProp(char const* pName, KTime pValue);
00276 
00278 public: KString GetEnumProp(char const* pName, KString pDefValue);
00279 public: int     GetEnumProp(char const* pName, int pDefValue);
00280 public: int     GetEnumIndex(char const* pName, KString pValue);
00281 
00282 public: void    SetEnumProp(char const* pName, KString pValue);
00283 public: void    SetEnumProp(char const* pName, int pValue);
00284 
00285 public: void    RemoveEnumPropValue(char const* pName, KString pValue);
00286 public: void    EmptyEnumProp(char const* pName);
00287 
00288         // set a specific flag value on a specific property
00289 public: bool    SetFlag(char const* pName, FbxPropertyFlags::eFbxPropertyFlags propFlag, bool pValue);
00290 
00292 public: KString GetStringProp(char const* pName, KString pDefValue);
00293 public: void    SetStringProp(char const* pName, KString pValue);
00294 
00295 
00297 public: virtual bool ReadXMLFile(KString& path);
00298 
00300 public: virtual bool WriteXMLFile(KString& path);
00301 
00302 public: bool WriteXmlPropToFile(KString& pFullPath, KString& propPath);
00303 
00305 public: bool WriteXmlPropToRegistry(KString& regKeyName, KString& regValueName, KString& propPath, KString& regPath );
00306         
00308 public: bool ReadXmlPropFromRegistry(KString& regKeyName, KString& regValueName, KString& regPath);
00309 
00311 public: bool ReadXmlPropFromMyDocument(KString& subDir, KString& filename);
00312 
00314 public: bool WriteXmlPropToMyDocument(KString& subDir, KString& filename, KString& propPath);
00315 
00316 public: static KString GetUserMyDocumentDir();
00317 
00318         
00319 
00320 public: enum ELoadMode         { eMERGE, eEXCLUSIVE_MERGE, eCREATE };
00321 public: enum EQuaternionMode   { eAS_QUATERNION, eAS_EULER, eRESAMPLE };
00322 public: enum EObjectDerivation { eBY_LAYER, eBY_ENTITY, eBY_BLOCK }; 
00323 
00324 public: enum ESysUnits
00325     {
00326         kUNITS_USER,
00327         kUNITS_INCHES, 
00328         kUNITS_FEET,
00329         kUNITS_YARDS,
00330         kUNITS_MILES,
00331         kUNITS_MILLIMETERS,
00332         kUNITS_CENTIMETERS,
00333         kUNITS_METERS,
00334         kUNITS_KILOMETERS
00335     };
00336 
00337 public: enum ESysFrameRate  
00338     {
00339         kFRAMERATE_USER,
00340         kFRAMERATE_HOURS,
00341         kFRAMERATE_MINUTES,
00342         kFRAMERATE_SECONDS,
00343         kFRAMERATE_MILLISECONDS,
00344         kFRAMERATE_GAMES_15,
00345         kFRAMERATE_FILM_24,
00346         kFRAMERATE_PAL_25,
00347         kFRAMERATE_NTSC_30,
00348         kFRAMERATE_SHOWSCAN_48,
00349         kFRAMERATE_PALFIELD_50,
00350         kFRAMERATE_NTSCFIELD_60
00351     };
00352     
00353 // Max
00354 public: enum EEnveloppeSystem
00355     {
00356         eSKIN_MODIFIER,
00357         ePHYSIQUE,
00358         eBONESPRO,
00359         eENVELOPPE_SYSTEM_COUNT
00360     };
00361 
00362 // Max
00363 public: enum EGeometryType
00364     {
00365         eTRIANGLE,
00366         eSIMPLIFIED_POLY,
00367         ePOLY,
00368         eNURB,
00369         ePATCH,
00370         eGEOMETRY_TYPE_COUNT
00371     };
00372 
00373 
00374 //------------------------------------------------------------------------
00375             // Constructor
00376             // Use AllocateIOSettings() to construct a KFbxIOSettings
00377 protected:  KFbxIOSettings(KFbxSdkManager& pManager,char const* pName);
00378 
00379             // add recurively a xml node equivalent for a KFbxProperty and all child KFbxProperties
00380 private:    void AddXMLProp(KFbxProperty& pProp, xmlNodePtr pParent, xmlDocPtr pXmlDoc);
00381 
00382             // create a new xmlNode with all KFbxProperty info
00383 private:    xmlNodePtr GetXMLNode(KFbxProperty& pProp);
00384 
00385 public:     KsoInfo impInfo;
00386 public:     KsoInfo expInfo;
00387 
00388 public:     FBXUILANGUAGE UILanguage;
00389 
00390 private:    void AddNewPropInfo(KFbxProperty &pProp);
00391 private:    void DeletePropInfo(KFbxProperty &pProp);
00392 private:    void DeleteAllPropInfo(KFbxProperty &pProp);
00393 
00394 public:     PropInfo * GetPropInfo(KFbxProperty &pProp);
00395 public:     KString GetLanguageLabel(KFbxProperty &pProp);
00396 public:     void SetLanguageLabel(KFbxProperty &pProp, KString &pLabel);
00397 public:     FBXUILANGUAGE Get_Max_Runtime_Language(KString regLocation);
00398 
00399 private: xmlNode* GetChildXmlNode(xmlNode* parent, KString* nodeName);
00400 private: xmlNode* AddChildXmlNode(xmlNode* parent, KString* nodeName, KString* nodeValue = NULL);
00401 private: xmlAttr* AddAttributeToXmlNode(xmlNode* node, KString* attName, KString* attValue = NULL);
00402 
00403 // the caller must delete the KString returned
00404 private: KString* GetAttributeFromXmlNode(xmlNode* node, KString* attName);
00405 
00406 // the caller must delete the KString returned
00407 private: KString* GetInnerTextXmlNode(xmlNode* node);
00408 
00409 
00410 public: bool IsEnumExist(KFbxProperty& pProp, KString& enumString);
00411 public: int  GetEnumIndex(KFbxProperty& pProp, KString& enumString, bool pNoCase = false);
00412 
00413 private: bool WriteXmlDocToRegistry(KString* regPath, KString* regKeyName, KString* regValueName, xmlDocPtr XmlDoc);
00414 
00415 // the caller must delete the xmlDocPtr returned
00416 private: xmlDocPtr ReadXmlDocFromRegistry(KString* regPath, KString* regKeyName, KString* regValueName );
00417 
00418 private: void CreatePropRecursive(xmlNode* pNode, KFbxProperty& pPropParent);
00419 
00420 public: virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pType) const;
00421 
00422 };
00423 
00424 #include <fbxfilesdk_nsend.h>
00425 
00426 #endif // KARCH_ENV_MACOSX_CFM
00427 
00428 #endif // #define _FBXSDK_IO_SETTINGS_H_
00429