1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxiosettings.h
13#ifndef _FBXSDK_FILEIO_IO_SETTINGS_H_
14#define _FBXSDK_FILEIO_IO_SETTINGS_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/core/fbxobject.h>
19#include <fbxsdk/fileio/fbxiosettingspath.h>
20
21#include <fbxsdk/fbxsdk_nsbegin.h>
22
23//Undefine the macro mkdir, since it conflict with function mkdir in Qt\4.2.3\src\corelib\io\qdir.h
24#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(mkdir)
25 #undef mkdir
26#endif
27
28#define IOSVisible true
29#define IOSHidden false
30
31#define IOSSavable true
32#define IOSNotSavable false
33
34#define IOSEnabled true
35#define IOSDisabled false
36
37#define IOSBinary 0
38#define IOSASCII 1
39
40class FbxManager;
41class FbxIOSettings;
42
43/*****************************************************************************************************************************
44** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
45*****************************************************************************************************************************/
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
47class FbxIOPropInfo
48{
49public:
50 FbxIOPropInfo();
51 ~FbxIOPropInfo();
52
53 void* UIWidget; // UI widget for showing the property
54 void* cbValueChanged; // call back when value changed
55 void* cbDirty; // call back when value changed
56 FbxStringList labels; // list of labels in many languages
57};
58
59class FBXSDK_DLL FbxIOInfo
60{
61public:
62 enum EImpExp {eImport, eExport};
63
64 FbxIOInfo();
65
66 void Reset(EImpExp pImpExp);
67 void SetTimeMode(FbxTime::EMode pTimeMode, double pCustomFrameRate = 0.0);
68 FbxTime::EMode GetTimeMode(){ return mTimeMode; }
69 FbxTime GetFramePeriod();
70 void SetASFScene(FbxObject* pASFScene, bool pASFSceneOwned = false);
71 FbxObject* GetASFScene(){ return mASFScene; }
72 void Set_IOS(FbxIOSettings* pIOS){ios = pIOS;}
73 void SetImportExportMode(EImpExp pImpExp){mImpExp = pImpExp;}
74
75private:
76 FbxTime::EMode mTimeMode;
77 FbxObject* mASFScene;
78 EImpExp mImpExp;
79 FbxIOSettings* ios;
80};
81#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
82
83/** FbxIOSettings is a collection of properties, arranged as a tree, that
84 * can be used by FBX file readers and writers to represent import and export
85 * options.
86 * It is primarily used by FBX importers (FbxImporter) and FBX exporter (FbxExporter)
87 * when reading or writing data from or to a disk.
88 * The FBX plugins of some Autodesk products expose a UI representing the content of those options
89 * to let users see and choose options when an import or export operation is about to be done.
90 * The tree of options is extensible.
91 *
92 * Options can be saved or loaded from an XML file using the functions:
93 * ReadXMLFile(), WriteXMLFile(), WriteXmlPropToFile(). This functionality can be useful
94 * for plugins that use preset files.
95 *
96 * An instance of FbxIOSettings must be created to be used before an import/export operation.
97 * When a new FbxIOSettings instance is created, all options are created with default values.
98 * The new instance of FbxIOSettings can be passed to the FbxManager,
99 * this way that instance will be used by all import/export operations.
100 *
101 * Ex: to set an instance of FbxIOSettings to the FbxManager
102 *
103 * \code
104 * // First create a new instance of FbxIOSettings
105 * FbxIOSettings * ios = FbxIOSettings::Create((FbxManager *) mManager, IOSROOT);
106 * // then set the FbxManager
107 * mManager->SetIOSettings(ios);
108 * \endcode
109 *
110 * It's also possible for a developer to create another instance
111 * of FbxIOSettings, set particular options and use it for import/export operation.
112 *
113 * Ex: to set an instance of FbxIOSettings to a FbxImporter/FbxExporter
114 * \code
115 * mImporter->SetIOSettings(ios); / mExporter->SetIOSettings(ios);
116 * \endcode
117 *
118 * A schematic view of the FbxIOSettings tree :
119 *
120 * \verbatim
121
122 OPTION_GROUP_ROOT (IOSROOT)
123 |
124 |
125 ________________________________________
126 | |
127 -OPTION_GROUP_EXPORT (IOSN_EXPORT) -OPTION_GROUP_IMPORT (IOSN_IMPORT)
128 | |
129 -OPTION_GROUP_A -OPTION_GROUP_A
130 | | | |
131 | -OPTION_A | -OPTION_A
132 | -OPTION_B | -OPTION_B
133 | |
134 -OPTION_GROUP_B -OPTION_GROUP_B
135 | | | |
136 | -OPTION_GROUP_A | -OPTION_GROUP_A
137 | | | | | |
138 | | -OPTION_A | | -OPTION_A
139 | | -OPTION_B | | -OPTION_B
140 | | | |
141 | -OPTION_GROUP_B | -OPTION_GROUP_B
142 | | | |
143 | -OPTION_A | -OPTION_A
144 | -OPTION_B | -OPTION_B
145 | |
146 -OPTION_GROUP_C -OPTION_GROUP_C
147 | |
148 -OPTION_A -OPTION_A
149
150 \endverbatim
151 *
152 * Any group of options can contain sub options, or group of sub options.
153 * To access an option value, we must pass the full path to the Get/Set functions
154 * Ex:
155 * \code
156 * ios->GetBoolProp("Import|IncludeGrp|Animation", true); // the root node name is not required
157 * \endcode
158 *
159 * All options path are defined in the file kfbxiosettingspath.h to ease the access of any options.
160 * Then "Import|IncludeGrp|Animation" == IMP_ANIMATION since IMP_ANIMATION is defined in kfbxiosettingspath.h
161 * All options defined path start with "IMP_" for import branch or "EXP_" for export branch.
162 *
163 * We strongly encourage to use the defined path in kfbxiosettingspath.h, this way if the parent group of an option is changed
164 * the change occur only in kfbxiosettingspath.h not in the code elsewhere.
165 *
166 * Ex: to get the boolean import "Animation" option
167 * \code
168 * bool anim = ios->GetBoolProp(IMP_ANIMATION, true); // will return true if not found, since we pass true as second param
169 * \endcode
170 *
171 * Ex: to set the boolean import "Animation" option to false
172 * \code
173 * ios->SetBoolProp(IMP_ANIMATION, false);
174 * \endcode
175 *
176 * Ex: to create a new option group under the "Import" branch
177 * \code
178 * // get the parent "Import" property
179 * FbxProperty import_Group = ios->GetProperty( IOSN_IMPORT ); // IOSN_IMPORT is defined as "Import" in kfbxiosettingspath.h
180 * if(import_Group.IsValid()) // check if we have found the IOSN_IMPORT parent option
181 * {
182 * // add a new group of options "myOptionGroup"
183 * FbxProperty myOptionGrp = ios->AddPropertyGroup(import_Group, "myOptionGroup", FbxStringDT, "My Option Group UI Label");
184 * }
185 * \endcode
186 *
187 * Ex: to create a new boolean option under the "myOptionGroup"
188 * \code
189 * FbxProperty myOptionGrp = ios->GetProperty( "Import|myOptionGroup" ); // can also use IOSN_IMPORT|"myOptionGroup"
190 * if(myOptionGrp.IsValid()) // check if we have found the "myOptionGroup"
191 * {
192 * bool defaultValue = true;
193 * FbxProperty myOption = ios->AddProperty(myOptionGrp, "myOptionName", FbxBoolDT, "My Option UI label" , &defaultValue, eFbxBool);
194 * }
195 * \endcode
196 *
197 * Ex: to set some flags to myOption
198 * \code
199 * FbxProperty myOption = ios->GetProperty( "Import|myOptionGroup|myOptionName" );
200 * if(myOption.IsValid())
201 * {
202 * myOPtion.ModifyFlag(FbxPropertyFlags::eUIHidden, true); // to make that option not visible to the UI
203 * myOPtion.ModifyFlag(FbxPropertyFlags::eNotSavable, true); // to avoid the read/save of that option in XML file
204 * }
205 * \endcode
206 */
207class FBXSDK_DLL FbxIOSettings : public FbxObject
208{
209 FBXSDK_OBJECT_DECLARE(FbxIOSettings, FbxObject);
210
211public:
212 //! Supported languages enumeration list
213 enum ELanguage
214 {
215 eENU, //!< 409 English - United States
216 eDEU, //!< 407 German - Germany
217 eFRA, //!< 40c French - France
218 eJPN, //!< 411 Japanese - Japan
219 eKOR, //!< 412 Korean(Extended Wansung) - Korea
220 eCHS, //!< 804 Chinese - PRC
221 eLanguageCount //!< Total language count
222 };
223
224 /** Add a property group under the root prop to be a direct child of IOSROOT
225 * \param pName
226 * \param pDataType
227 * \param pLabel
228 * \return a new FbxProperty created
229 */
230 FbxProperty AddPropertyGroup(const char* pName, const FbxDataType& pDataType=FbxDataType(), const char* pLabel="");
231
232 /** Add a property group under another parent property
233 * \param pParentProperty
234 * \param pName
235 * \param pDataType
236 * \param pLabel (optional, used by the UI as widget label)
237 * \param pVisible (used by the UI to show or not that property)
238 * \param pSavable (to enable a read & write to an XML file)
239 * \param pEnabled (used by the widget UI to show enabled or disabled)
240 * \return a new FbxProperty created
241 */
242 FbxProperty AddPropertyGroup(const FbxProperty& pParentProperty, const char* pName, const FbxDataType& pDataType = FbxDataType(),
243 const char* pLabel = "", bool pVisible = true, bool pSavable = true, bool pEnabled = true );
244
245 /** Add a property under another parent property with a value to set
246 * \param pParentProperty
247 * \param pName
248 * \param pDataType
249 * \param pLabel (optional, used by the UI as widget label)
250 * \param pValue
251 * \param pVisible (used by the UI to show or not that property)
252 * \param pSavable (to enable a read & write to an XML file)
253 * \param pEnabled (used by the widget UI to show enabled or disabled)
254 * \return a new FbxProperty created
255 */
256 FbxProperty AddProperty(const FbxProperty& pParentProperty, const char* pName, const FbxDataType& pDataType = FbxDataType(),
257 const char* pLabel = "", const void* pValue = NULL, bool pVisible = true,
258 bool pSavable = true, bool pEnabled = true );
259
260 /** Add a property under another parent property with a value to set and a min max values
261 * \param pParentProperty
262 * \param pName
263 * \param pDataType
264 * \param pLabel (optional, used by the UI as widget label)
265 * \param pValue
266 * \param pMinValue
267 * \param pMaxValue
268 * \param pVisible (used by the UI to show or not that property)
269 * \param pSavable (to enable a read & write to an XML file)
270 * \param pEnabled (used by the widget UI to show enabled or disabled)
271 * \return a new FbxProperty created
272 * \remarks Normally used with numeric properties Ex: integer, float, double, etc.
273 */
274 FbxProperty AddPropertyMinMax(const FbxProperty& pParentProperty, const char* pName, const FbxDataType& pDataType = FbxDataType(),
275 const char* pLabel = "", const void* pValue = NULL, const double* pMinValue = NULL, const double* pMaxValue = NULL,
276 bool pVisible = true, bool pSavable = true, bool pEnabled = true );
277
278
279 /** Get a property using the full path in the tree ex: "Export|IncludeGrp|Animation"
280 * \param pName
281 * \return a FbxProperty found
282 * \remarks We strongly encourage to use the defined path in kfbxiosettingspath.h
283 * ex: EXP_ANIMATION == "Export|IncludeGrp|Animation"
284 */
285 FbxProperty GetProperty(const char* pName) const;
286
287 /** Get a property using a short path found under the parent property.
288 * \param pParentProperty
289 * \param pName
290 * \return a FbxProperty found
291 * \remarks This is a faster way to access a property when the parent is known
292 */
293 FbxProperty GetProperty(const FbxProperty& pParentProperty, const char* pName) const;
294
295 /** Get a bool property value using the full path
296 * \param pName
297 * \param pDefValue Value returned if the property is not found
298 * \return true or false
299 */
300 bool GetBoolProp(const char* pName, bool pDefValue) const;
301
302 /** set a bool property value using the full path
303 * \param pName
304 * \param pValue
305 */
306 void SetBoolProp(const char* pName, bool pValue);
307
308 /** Get a double property value using the full path
309 * \param pName
310 * \param pDefValue Value returned if the property is not found
311 * \return a double
312 */
313 double GetDoubleProp(const char* pName, double pDefValue) const;
314
315 /** Set a double property using the full path
316 * \param pName
317 * \param pValue
318 */
319 void SetDoubleProp(const char* pName, double pValue);
320
321 /** Get a int property value using the full path
322 * \param pName
323 * \param pDefValue Value returned if the property is not found
324 * \return a int
325 */
326 int GetIntProp(const char* pName, int pDefValue) const;
327
328 /** Set a int property value using the full path
329 * \param pName
330 * \param pValue
331 */
332 void SetIntProp(const char* pName, int pValue);
333
334 /** Get a FbxTime property value using the full path
335 * \param pName
336 * \param pDefValue Value returned if the property is not found
337 */
338 FbxTime GetTimeProp(const char* pName, FbxTime pDefValue) const;
339
340 /** Set a FbxTime property value using the full path
341 * \param pName
342 * \param pValue
343 * \return a FbxTime
344 */
345 void SetTimeProp(const char* pName, FbxTime pValue);
346
347 /** \name Enum Properties
348 * An enum property is a list of FbxString and integer pairs.
349 * A current index value is available to get the selected pair
350 * of FbxString+integer
351 *
352 * Ex: Content of an enum property
353 * \code
354 * 0 -> (14, "Bird")
355 * 1 -> (17, "Horse")
356 * 2 -> (93, "Cat")
357 * 3 -> (45, "Dog")
358 * \endcode
359 *
360 * If current index is 2: the current int value is 93,
361 * and the current FbxString value is "Cat"
362 */
363
364 //@{
365
366 /** Get the FbxString at current index of an enum property using the full path.
367 * \param pName
368 * \param pDefValue Value returned if the property is not found
369 * \return a FbxString
370 */
371 FbxString GetEnumProp(const char* pName, FbxString pDefValue) const;
372
373 /** Get the integer at current index of an enum property using the full path.
374 * \param pName
375 * \param pDefValue Value returned if the property is not found
376 * \return a int
377 */
378 int GetEnumProp(const char* pName, int pDefValue) const;
379
380 /** Get the index of a FbxString from the enum property using the full path.
381 * \param pName
382 * \param pValue Return -1 if the FbxString is not found
383 * \return a int
384 */
385 int GetEnumIndex(const char* pName, FbxString pValue) const;
386
387 /** Set the current index using an existing FbxString of an enum property using the full path.
388 * \param pName
389 * \param pValue
390 * \remarks The current index will not change if the FbxString is not found
391 */
392 void SetEnumProp(const char* pName, FbxString pValue);
393
394 /** Set the current index of an enum property using the full path.
395 * \param pName
396 * \param pValue
397 * \remarks The current index will not change if the pValue is out of bound
398 */
399 void SetEnumProp(const char* pName, int pValue);
400
401 /** Remove a pair of FbxString+integer from an enum property.
402 * \param pName
403 * \param pValue The FbxString to find
404 * \remarks The first FbxString found from 0 index will be removed only even
405 * if the same FbxString exist in other index, if the current index was on the FbxString found
406 * the current index will be set to 0
407 */
408 void RemoveEnumPropValue(const char* pName, FbxString pValue);
409
410 /** Empty all the FbxString+integer pair of the enum property
411 * \param pName
412 */
413 void EmptyEnumProp(const char* pName);
414
415 /** Check if a FbxString is present in the enum property.
416 * \param &pProp a ref to an enum prop
417 * \param &enumString ref to a FbxString to find
418 * \return \c true if found, \c false otherwise.
419 */
420 bool IsEnumExist(FbxProperty& pProp, const FbxString& enumString) const;
421
422 /** Get the enum index of a FbxString
423 * \param &pProp a ref to an enum prop
424 * \param &enumString ref to string to find
425 * \param pNoCase To match case sensitive or not
426 * \return the index found or -1 if not found
427 */
428 int GetEnumIndex(FbxProperty& pProp, const FbxString& enumString, bool pNoCase = false) const;
429 //@}
430
431 /** Set a specific flag value on a property using the full path
432 * \param pName
433 * \param propFlag
434 * \param pValue
435 * \return Always true
436 */
437 bool SetFlag(const char* pName, FbxPropertyFlags::EFlags propFlag, bool pValue);
438
439 /** Get a FbxString property value using the full path.
440 * \param pName
441 * \param pDefValue Value returned if the property is not found
442 * \return The FbxString value
443 */
444 FbxString GetStringProp(const char* pName, FbxString pDefValue) const;
445
446 /** Set a FbxString property value using the full path
447 * \param pName
448 * \param pValue
449 */
450 void SetStringProp(const char* pName, FbxString pValue);
451
452 /** \name XML Serialization Functions */
453 //@{
454
455 /** Load the settings values from an XML file.
456 * \param path The path of the XML file.
457 * \return \c True on success, \c false otherwise.
458 */
459 virtual bool ReadXMLFile(const FbxString& path);
460
461 /** Write the settings values to an XML file.
462 * \param path The path of the XML file.
463 * \return \c True on success, \c false otherwise.
464 * \remarks The flag of the property must be FbxPropertyFlags::eNotSavable == false
465 */
466 virtual bool WriteXMLFile(const FbxString& path);
467
468 /** Write the settings values to an XML file.
469 * \param pFullPath The path of the XML file.
470 * \param propPath a prop Path
471 * \return \c True on success, \c false otherwise.
472 * \remarks To save only a branch of the settings ex: Import branch only
473 */
474 bool WriteXmlPropToFile(const FbxString& pFullPath, const FbxString& propPath);
475 //@}
476
477/*****************************************************************************************************************************
478** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
479*****************************************************************************************************************************/
480#ifndef DOXYGEN_SHOULD_SKIP_THIS
481 FbxIOPropInfo* GetPropInfo(FbxProperty &pProp);
482
483 ELanguage UILanguage;
484 FbxString GetLanguageLabel(FbxProperty& pProp);
485 void SetLanguageLabel(FbxProperty& pProp, FbxString& pLabel);
486 ELanguage Get_Max_Runtime_Language(FbxString pRegLocation);
487
488 FbxIOInfo impInfo;
489 FbxIOInfo expInfo;
490
491 static FbxString GetUserMyDocumentDir();
492 void SetPropVisible(FbxProperty& pProp, bool pWithChildren, bool pVisible);
493
494 // Read an XML file from MyDocument dir
495 bool ReadXmlPropFromMyDocument(const FbxString& subDir, const FbxString& filename);
496
497 // Write property branch to an XML file in MyDocument dir
498 bool WriteXmlPropToMyDocument(const FbxString& subDir, const FbxString& filename, const FbxString& propPath);
499
500 static const char* GetFileMergeDescription(int pIndex);
501
502 enum ELoadMode
503 {
504 eCreate, /*!< Add to scene(duplicate the ones with the same name) */
505 eMerge, /*!< Add to scene and update animation */
506 eExclusiveMerge /*!< Update animation */
507 };
508
509
510 enum EQuaternionMode { eAsQuaternion, eAsEuler, eResample };
511 enum EObjectDerivation { eByLayer, eByEntity, eByBlock };
512
513 enum ESysUnits
514 {
515 eUnitsUser,
516 eUnitsInches,
517 eUnitsFeet,
518 eUnitYards,
519 eUnitsMiles,
520 eUnitsMillimeters,
521 eUnitsCentimeters,
522 eUnitsMeters,
523 eUnitsKilometers
524 };
525
526 enum ESysFrameRate
527 {
528 eFrameRateUser,
529 eFrameRateHours,
530 eFrameRateMinutes,
531 eFrameRateSeconds,
532 eFrameRateMilliseconds,
533 eFrameRateGames15,
534 eFrameRateFilm24,
535 eFrameRatePAL25,
536 eFrameRateNTSC30,
537 eFrameRateShowScan48,
538 eFrameRatePALField50,
539 eFrameRateNTSCField60
540 };
541
542// Max
543 enum EEnveloppeSystem
544 {
545 eSkinModifier,
546 ePhysic,
547 eBonePro,
548 eEnveloppeSystemCount
549 };
550
551// Max
552 enum EGeometryType
553 {
554 eTriangle,
555 eSimplifiedPoly,
556 ePolygon,
557 eNurbs,
558 ePatch,
559 eGeometryTypeCount
560 };
561
562// Maya IK type
563 enum EIKType
564 {
565 eNone,
566 eFBIK,
567 eHumanIK
568 };
569
570protected:
571 virtual void Construct(const FbxObject* pFrom);
572 virtual void ConstructProperties(bool pForceSet);
573 virtual void Destruct(bool pRecursive);
574
575private:
576 void AddNewPropInfo(FbxProperty& pProp);
577 void DeletePropInfo(FbxProperty& pProp);
578 void DeleteAllPropInfo(FbxProperty& pProp);
579#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
580};
581
582#include <fbxsdk/fbxsdk_nsend.h>
583
584#endif /* _FBXSDK_FILEIO_IO_SETTINGS_H_ */
585