1 /*
2     Copyright (c) 2008-2009 NetAllied Systems GmbH
3 
4     This file is part of COLLADAFramework.
5 
6     Licensed under the MIT Open Source License,
7     for details please see LICENSE file or the website
8     http://www.opensource.org/licenses/mit-license.php
9 */
10 
11 #ifndef __COLLADAFW_ASSET_H__
12 #define __COLLADAFW_ASSET_H__
13 
14 #include "COLLADAFWPrerequisites.h"
15 #include "COLLADAFWPointerArray.h"
16 
17 #include "COLLADABUURI.h"
18 
19 
20 namespace COLLADAFW
21 {
22 
23     /**
24     Computers store vast amounts of information. An asset is a set of information that is organized into a
25     distinct collection and managed as a unit. A wide range of attributes describes assets so that the
26     information can be maintained and understood both by software tools and by humans. Asset information is
27     often hierarchical, where the parts of a large asset are divided into smaller pieces that are managed as
28     distinct assets themselves.
29     */
30     class FileInfo
31     {
32     public:
33 
34         typedef std::pair<String, String> ValuePair;
35         typedef PointerArray<ValuePair> ValuePairPointerArray;
36 
37     public:
38 
39         /** Descriptive information about unit of measure. Its optional attributes are:*/
40         class Unit
41         {
42         public:
43             static const double LINEAR_UNIT_KILOMETER;
44             static const double LINEAR_UNIT_METER;
45             static const double LINEAR_UNIT_DECIMETER;
46             static const double LINEAR_UNIT_CENTIMETER;
47             static const double LINEAR_UNIT_MILLIMETER;
48             static const double LINEAR_UNIT_FOOT;
49             static const double LINEAR_UNIT_INCH;
50             static const double LINEAR_UNIT_YARD;
51 
52             static const String LINEAR_UNIT_KILOMETER_NAME;
53             static const String LINEAR_UNIT_METER_NAME;
54             static const String LINEAR_UNIT_DECIMETER_NAME;
55             static const String LINEAR_UNIT_CENTIMETER_NAME;
56             static const String LINEAR_UNIT_MILLIMETER_NAME;
57             static const String LINEAR_UNIT_FOOT_NAME;
58             static const String LINEAR_UNIT_INCH_NAME;
59             static const String LINEAR_UNIT_YARD_NAME;
60 
61             static const String ANGULAR_UNIT_DEGREES_NAME;
62             static const String ANGULAR_UNIT_RADIANS_NAME;
63 
64             static const String TIME_UNIT_FILM_NAME;
65 
66 
67             enum LinearUnit
68             {
69                 KILOMETER,
70                 METER,
71                 DECIMETER,
72                 CENTIMETER,
73                 MILLIMETER,
74                 FOOT,
75                 INCH,
76                 YARD,
77                 UNKNOWN_LINEAR_UNIT
78             };
79 
80             enum AngularUnit
81             {
82                 DEGREES,
83                 RADIANS,
84                 UNKNOWN_ANGULAR_UNIT
85             };
86 
87             enum TimeUnit
88             {
89                 FILM,
90                 UNKNOWN_TIME_UNIT
91             };
92 
93         private:
94 
95             /**
96              * The enum value for the linear unit.
97              */
98             LinearUnit mLinearUnitUnit;
99 
100             /**
101             * The name of the distance unit to use in the scene. For example,
102             * "meter", "centimeter", "inches", or "parsec". This can be the
103             * real name of a measurement, or an imaginary name.
104             */
105             String mLinearUnitName;
106 
107             /**
108             * How many real-world meters in one distance unit as a floating-point number.
109             * For example, 1.0 for the name "meter"; 1000 for the name "kilometer";
110             * 0.3048 for the name "foot".
111              */
112             double mLinearUnitMeter;
113 
114             /**
115              * The angular unit;
116              */
117             String mAngularUnitName;
118             AngularUnit mAngularUnitUnit;
119 
120             /**
121              * The time unit.
122              */
123             String mTimeUnitName;
124             TimeUnit mTimeUnitUnit;
125 
126         public:
127 
Unit()128             Unit ()
129                 : mLinearUnitUnit ( METER )
130                 , mLinearUnitName ( LINEAR_UNIT_METER_NAME )
131                 , mLinearUnitMeter ( LINEAR_UNIT_METER )
132                 , mAngularUnitName ( ANGULAR_UNIT_DEGREES_NAME )
133                 , mAngularUnitUnit ( DEGREES )
134                 , mTimeUnitName ( TIME_UNIT_FILM_NAME )
135                 , mTimeUnitUnit ( FILM )
136             {}
137 
138             Unit ( String linearUnitName, double linearUnitMeter,
139                 String angularUnitName, String timeUnitName = TIME_UNIT_FILM_NAME )
mLinearUnitName(linearUnitName)140                 : mLinearUnitName ( linearUnitName )
141                 , mLinearUnitMeter ( linearUnitMeter )
142                 , mAngularUnitName ( angularUnitName )
143                 , mTimeUnitName ( timeUnitName )
144             {
145                 initializeLinearUnitUnit ( linearUnitMeter );
146                 initializeAngularUnitUnitByName ( mAngularUnitName );
147                 initializeTimeUnitUnitByName ( mTimeUnitName );
148             }
149 
~Unit()150             virtual ~Unit () {}
151 
152             /**
153             * The enum value for the linear unit.
154             */
getLinearUnitUnit()155             const LinearUnit& getLinearUnitUnit () const { return mLinearUnitUnit; }
setLinearUnitUnit(const LinearUnit & val)156             void setLinearUnitUnit ( const LinearUnit& val ) { mLinearUnitUnit = val; }
157 
158             /**
159             * The name of the distance unit to use in the scene. For example,
160             * "meter", "centimeter", "inches", or "parsec". This can be the
161             * real name of a measurement, or an imaginary name.
162             */
getLinearUnitName()163             const String& getLinearUnitName () const { return mLinearUnitName; }
164             void setLinearUnitName ( const String& val );
165 
166             /**
167              * Initializes the linear unit unit with the specified enum value
168              * in depend of the given name.
169              */
170             void initializeLinearUnitUnit ( const double val );
171 
172             /**
173             * How many real-world meters in one distance unit as a floating-point number.
174             * For example, 1.0 for the name "meter"; 1000 for the name "kilometer";
175             * 0.3048 for the name "foot".
176             */
getLinearUnitMeter()177             const double getLinearUnitMeter () const { return mLinearUnitMeter; }
178             void setLinearUnitMeter ( const double val );
179 
180 			/**
181 			* The angular unit;
182 			*/
getAngularUnit()183 			AngularUnit getAngularUnit () const { return mAngularUnitUnit; }
setAngularUnit(AngularUnit angularUnitUnit)184 			void setAngularUnit ( AngularUnit angularUnitUnit ) { mAngularUnitUnit = angularUnitUnit;}
185 
186 			/**
187 			* The angular unit;
188 			*/
getAngularUnitName()189 			const String& getAngularUnitName () const { return mAngularUnitName; }
190 			void setAngularUnitName ( const String& val );
191 
192             /**
193             * Initializes the angular unit unit with the specified enum value
194             * in depend of the given name.
195             */
196             void initializeAngularUnitUnitByName ( const String& angularUnitName );
197 
198             /**
199             * The time unit.
200             */
getTimeUnitName()201             const String& getTimeUnitName () const { return mTimeUnitName; }
202             void setTimeUnitName ( const String& val );
203 
204             /**
205             * Initializes the time unit unit with the specified enum value
206             * in depend of the given name.
207             */
208             void initializeTimeUnitUnitByName ( const String& timeUnitName );
209 
210         };
211 
212 
213         /*Descriptive information about the coordinate system
214         of the geometric data. All coordinates are right handed
215         by definition. Valid values are X_UP, Y_UP,
216         or Z_UP. This element specifies which axis is
217         considered upward, which is considered to the
218         right, and which is considered inward.*/
219         enum UpAxisType
220         {
221             NONE,
222             X_UP,
223             Y_UP,
224             Z_UP
225         };
226 
227         static const String X_UP_STRING;
228         static const String Y_UP_STRING;
229         static const String Z_UP_STRING;
230 
231     private:
232 
233         /** Descriptive information about unit of measure. Its optional attributes are:*/
234         Unit mUnit;
235 
236         /* Descriptive information about the coordinate system of the geometric data.
237         All coordinates are right handed by definition. Valid values are X_UP, Y_UP,
238         or Z_UP. This element specifies which axis is considered upward, which is considered
239         to the right, and which is considered inward. */
240         UpAxisType mUpAxisType;
241 
242         /** A pair where you can hold file informations. */
243         ValuePairPointerArray mValuePairArray;
244 
245 		/** The absolute file uri.*/
246 		COLLADABU::URI mAbsoluteFileUri;
247 
248 	public:
249 
250         /** Constructor. */
251         FileInfo();
252 
253         /** Destructor. */
254         virtual ~FileInfo();
255 
256         /** A pair where you can hold file informations. */
257         void appendValuePair ( ValuePair* valuePair );
258 
259         /** A pair where you can hold file informations. */
260         void appendValuePair ( const String& value1, const String& value2 );
261 
262         /** A pair where you can hold file informations. */
getValuePairArray()263         const ValuePairPointerArray& getValuePairArray () const { return mValuePairArray; }
264 
265 
266         /** Sets the unit used by the document.
267         @param unit The unit to use.
268         */
setUnit(const Unit & unit)269         void setUnit ( const Unit& unit )
270         {
271             mUnit = unit;
272         }
273 
274         /**
275         * Sets the linear unit.
276         */
setLinearUnit(const String & linearUnit)277         void setLinearUnit ( const String& linearUnit )
278         {
279             mUnit.setLinearUnitName ( linearUnit );
280         }
281 
282         /**
283         * Sets the linear unit meter.
284         */
setLinearUnitMeter(double linearUnitMeter)285         void setLinearUnitMeter ( double linearUnitMeter )
286         {
287             mUnit.setLinearUnitMeter ( linearUnitMeter );
288         }
289 
290         /** Returns the unit. */
getUnit()291         Unit& getUnit()
292         {
293             return mUnit;
294         }
295 
296         /** Returns the unit. */
getUnit()297         const Unit& getUnit() const
298         {
299             return mUnit;
300         }
301 
302         /** Sets the up axis of the document. */
setUpAxisType(UpAxisType upAxisType)303         void setUpAxisType ( UpAxisType upAxisType )
304         {
305             mUpAxisType = upAxisType;
306         }
307 
308         /** Sets the up axis of the document. */
309         void setUpAxisType ( const String& upAxis );
310 
311         /** Returns the up axis. */
getUpAxisType()312         UpAxisType getUpAxisType() const
313         {
314             return mUpAxisType;
315         }
316 
317 		/** Returns the absolute uri of the file.*/
getAbsoluteFileUri()318 		const COLLADABU::URI& getAbsoluteFileUri() const { return mAbsoluteFileUri; }
319 
320 		/** Sets the absolute uri of the file.*/
setAbsoluteFileUri(const COLLADABU::URI & absoluteFileUri)321 		void setAbsoluteFileUri( const COLLADABU::URI& absoluteFileUri) { mAbsoluteFileUri = absoluteFileUri; }
322 
323 	private:
324 
325         /** Disable default copy ctor. */
326 		FileInfo( const FileInfo& pre );
327 
328         /** Disable default assignment operator. */
329 		const FileInfo& operator= ( const FileInfo& pre );
330 
331 	};
332 
333 } // namespace COLLADAFW
334 
335 #endif // __COLLADAFW_ASSET_H__
336