domImage.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
  5. * file except in compliance with the License. You may obtain a copy of the License at:
  6. * http://research.scea.com/scea_shared_source_license.html
  7. *
  8. * Unless required by applicable law or agreed to in writing, software distributed under the License
  9. * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied. See the License for the specific language governing permissions and limitations under the
  11. * License.
  12. */
  13. #ifndef __domImage_h__
  14. #define __domImage_h__
  15. #include <dae/daeDocument.h>
  16. #include <dom/domTypes.h>
  17. #include <dom/domElements.h>
  18. #include <dom/domAsset.h>
  19. #include <dom/domExtra.h>
  20. class DAE;
  21. /**
  22. * The image element declares the storage for the graphical representation
  23. * of an object. The image element best describes raster image data, but
  24. * can conceivably handle other forms of imagery. The image elements allows
  25. * for specifying an external image file with the init_from element or embed
  26. * image data with the data element.
  27. */
  28. class domImage : public daeElement
  29. {
  30. public:
  31. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::IMAGE; }
  32. static daeInt ID() { return 635; }
  33. virtual daeInt typeID() const { return ID(); }
  34. public:
  35. class domData;
  36. typedef daeSmartRef<domData> domDataRef;
  37. typedef daeTArray<domDataRef> domData_Array;
  38. /**
  39. * The data child element contains a sequence of hexadecimal encoded binary
  40. * octets representing the embedded image data.
  41. */
  42. class domData : public daeElement
  43. {
  44. public:
  45. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::DATA; }
  46. static daeInt ID() { return 636; }
  47. virtual daeInt typeID() const { return ID(); }
  48. protected: // Value
  49. /**
  50. * The domListOfHexBinary value of the text data of this element.
  51. */
  52. domListOfHexBinary _value;
  53. public: //Accessors and Mutators
  54. /**
  55. * Gets the _value array.
  56. * @return Returns a domListOfHexBinary reference of the _value array.
  57. */
  58. domListOfHexBinary &getValue() { return _value; }
  59. /**
  60. * Gets the _value array.
  61. * @return Returns a constant domListOfHexBinary reference of the _value array.
  62. */
  63. const domListOfHexBinary &getValue() const { return _value; }
  64. /**
  65. * Sets the _value array.
  66. * @param val The new value for the _value array.
  67. */
  68. void setValue( const domListOfHexBinary &val ) { _value = val; }
  69. protected:
  70. /**
  71. * Constructor
  72. */
  73. domData(DAE& dae) : daeElement(dae), _value() {}
  74. /**
  75. * Destructor
  76. */
  77. virtual ~domData() {}
  78. /**
  79. * Overloaded assignment operator
  80. */
  81. virtual domData &operator=( const domData &cpy ) { (void)cpy; return *this; }
  82. public: // STATIC METHODS
  83. /**
  84. * Creates an instance of this class and returns a daeElementRef referencing it.
  85. * @return a daeElementRef referencing an instance of this object.
  86. */
  87. static DLLSPEC daeElementRef create(DAE& dae);
  88. /**
  89. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  90. * If a daeMetaElement already exists it will return that instead of creating a new one.
  91. * @return A daeMetaElement describing this COLLADA element.
  92. */
  93. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  94. };
  95. class domInit_from;
  96. typedef daeSmartRef<domInit_from> domInit_fromRef;
  97. typedef daeTArray<domInit_fromRef> domInit_from_Array;
  98. /**
  99. * The init_from element allows you to specify an external image file to use
  100. * for the image element.
  101. */
  102. class domInit_from : public daeElement
  103. {
  104. public:
  105. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::INIT_FROM; }
  106. static daeInt ID() { return 637; }
  107. virtual daeInt typeID() const { return ID(); }
  108. protected: // Value
  109. /**
  110. * The xsAnyURI value of the text data of this element.
  111. */
  112. xsAnyURI _value;
  113. public: //Accessors and Mutators
  114. /**
  115. * Gets the value of this element.
  116. * @return Returns a xsAnyURI of the value.
  117. */
  118. xsAnyURI &getValue() { return _value; }
  119. /**
  120. * Gets the value of this element.
  121. * @return Returns a constant xsAnyURI of the value.
  122. */
  123. const xsAnyURI &getValue() const { return _value; }
  124. /**
  125. * Sets the _value of this element.
  126. * @param val The new value for this element.
  127. */
  128. void setValue( const xsAnyURI &val ) { _value = val; }
  129. /**
  130. * Sets the _value of this element.
  131. * @param val The new value for this element.
  132. */
  133. void setValue( xsString val ) { _value = val; }
  134. protected:
  135. /**
  136. * Constructor
  137. */
  138. domInit_from(DAE& dae) : daeElement(dae), _value(dae, *this) {}
  139. /**
  140. * Destructor
  141. */
  142. virtual ~domInit_from() {}
  143. /**
  144. * Overloaded assignment operator
  145. */
  146. virtual domInit_from &operator=( const domInit_from &cpy ) { (void)cpy; return *this; }
  147. public: // STATIC METHODS
  148. /**
  149. * Creates an instance of this class and returns a daeElementRef referencing it.
  150. * @return a daeElementRef referencing an instance of this object.
  151. */
  152. static DLLSPEC daeElementRef create(DAE& dae);
  153. /**
  154. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  155. * If a daeMetaElement already exists it will return that instead of creating a new one.
  156. * @return A daeMetaElement describing this COLLADA element.
  157. */
  158. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  159. };
  160. protected: // Attributes
  161. /**
  162. * The id attribute is a text string containing the unique identifier of
  163. * this element. This value must be unique within the instance document.
  164. * Optional attribute.
  165. */
  166. xsID attrId;
  167. /**
  168. * The name attribute is the text string name of this element. Optional attribute.
  169. */
  170. xsNCName attrName;
  171. /**
  172. * The format attribute is a text string value that indicates the image format.
  173. * Optional attribute.
  174. */
  175. xsToken attrFormat;
  176. /**
  177. * The height attribute is an integer value that indicates the height of
  178. * the image in pixel units. Optional attribute.
  179. */
  180. domUint attrHeight;
  181. /**
  182. * The width attribute is an integer value that indicates the width of the
  183. * image in pixel units. Optional attribute.
  184. */
  185. domUint attrWidth;
  186. /**
  187. * The depth attribute is an integer value that indicates the depth of the
  188. * image in pixel units. A 2-D image has a depth of 1, which is also the
  189. * default value. Optional attribute.
  190. */
  191. domUint attrDepth;
  192. protected: // Elements
  193. /**
  194. * The image element may contain an asset element. @see domAsset
  195. */
  196. domAssetRef elemAsset;
  197. /**
  198. * The data child element contains a sequence of hexadecimal encoded binary
  199. * octets representing the embedded image data. @see domData
  200. */
  201. domDataRef elemData;
  202. /**
  203. * The init_from element allows you to specify an external image file to use
  204. * for the image element. @see domInit_from
  205. */
  206. domInit_fromRef elemInit_from;
  207. /**
  208. * The extra element may appear any number of times. @see domExtra
  209. */
  210. domExtra_Array elemExtra_array;
  211. /**
  212. * Used to preserve order in elements that do not specify strict sequencing of sub-elements.
  213. */
  214. daeElementRefArray _contents;
  215. /**
  216. * Used to preserve order in elements that have a complex content model.
  217. */
  218. daeUIntArray _contentsOrder;
  219. /**
  220. * Used to store information needed for some content model objects.
  221. */
  222. daeTArray< daeCharArray * > _CMData;
  223. public: //Accessors and Mutators
  224. /**
  225. * Gets the id attribute.
  226. * @return Returns a xsID of the id attribute.
  227. */
  228. xsID getId() const { return attrId; }
  229. /**
  230. * Sets the id attribute.
  231. * @param atId The new value for the id attribute.
  232. */
  233. void setId( xsID atId ) { *(daeStringRef*)&attrId = atId; _validAttributeArray[0] = true;
  234. if( _document != NULL ) _document->changeElementID( this, attrId );
  235. }
  236. /**
  237. * Gets the name attribute.
  238. * @return Returns a xsNCName of the name attribute.
  239. */
  240. xsNCName getName() const { return attrName; }
  241. /**
  242. * Sets the name attribute.
  243. * @param atName The new value for the name attribute.
  244. */
  245. void setName( xsNCName atName ) { *(daeStringRef*)&attrName = atName; _validAttributeArray[1] = true; }
  246. /**
  247. * Gets the format attribute.
  248. * @return Returns a xsToken of the format attribute.
  249. */
  250. xsToken getFormat() const { return attrFormat; }
  251. /**
  252. * Sets the format attribute.
  253. * @param atFormat The new value for the format attribute.
  254. */
  255. void setFormat( xsToken atFormat ) { *(daeStringRef*)&attrFormat = atFormat; _validAttributeArray[2] = true; }
  256. /**
  257. * Gets the height attribute.
  258. * @return Returns a domUint of the height attribute.
  259. */
  260. domUint getHeight() const { return attrHeight; }
  261. /**
  262. * Sets the height attribute.
  263. * @param atHeight The new value for the height attribute.
  264. */
  265. void setHeight( domUint atHeight ) { attrHeight = atHeight; _validAttributeArray[3] = true; }
  266. /**
  267. * Gets the width attribute.
  268. * @return Returns a domUint of the width attribute.
  269. */
  270. domUint getWidth() const { return attrWidth; }
  271. /**
  272. * Sets the width attribute.
  273. * @param atWidth The new value for the width attribute.
  274. */
  275. void setWidth( domUint atWidth ) { attrWidth = atWidth; _validAttributeArray[4] = true; }
  276. /**
  277. * Gets the depth attribute.
  278. * @return Returns a domUint of the depth attribute.
  279. */
  280. domUint getDepth() const { return attrDepth; }
  281. /**
  282. * Sets the depth attribute.
  283. * @param atDepth The new value for the depth attribute.
  284. */
  285. void setDepth( domUint atDepth ) { attrDepth = atDepth; _validAttributeArray[5] = true; }
  286. /**
  287. * Gets the asset element.
  288. * @return a daeSmartRef to the asset element.
  289. */
  290. const domAssetRef getAsset() const { return elemAsset; }
  291. /**
  292. * Gets the data element.
  293. * @return a daeSmartRef to the data element.
  294. */
  295. const domDataRef getData() const { return elemData; }
  296. /**
  297. * Gets the init_from element.
  298. * @return a daeSmartRef to the init_from element.
  299. */
  300. const domInit_fromRef getInit_from() const { return elemInit_from; }
  301. /**
  302. * Gets the extra element array.
  303. * @return Returns a reference to the array of extra elements.
  304. */
  305. domExtra_Array &getExtra_array() { return elemExtra_array; }
  306. /**
  307. * Gets the extra element array.
  308. * @return Returns a constant reference to the array of extra elements.
  309. */
  310. const domExtra_Array &getExtra_array() const { return elemExtra_array; }
  311. /**
  312. * Gets the _contents array.
  313. * @return Returns a reference to the _contents element array.
  314. */
  315. daeElementRefArray &getContents() { return _contents; }
  316. /**
  317. * Gets the _contents array.
  318. * @return Returns a constant reference to the _contents element array.
  319. */
  320. const daeElementRefArray &getContents() const { return _contents; }
  321. protected:
  322. /**
  323. * Constructor
  324. */
  325. domImage(DAE& dae) : daeElement(dae), attrId(), attrName(), attrFormat(), attrHeight(), attrWidth(), attrDepth(), elemAsset(), elemData(), elemInit_from(), elemExtra_array() {}
  326. /**
  327. * Destructor
  328. */
  329. virtual ~domImage() { daeElement::deleteCMDataArray(_CMData); }
  330. /**
  331. * Overloaded assignment operator
  332. */
  333. virtual domImage &operator=( const domImage &cpy ) { (void)cpy; return *this; }
  334. public: // STATIC METHODS
  335. /**
  336. * Creates an instance of this class and returns a daeElementRef referencing it.
  337. * @return a daeElementRef referencing an instance of this object.
  338. */
  339. static DLLSPEC daeElementRef create(DAE& dae);
  340. /**
  341. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  342. * If a daeMetaElement already exists it will return that instead of creating a new one.
  343. * @return A daeMetaElement describing this COLLADA element.
  344. */
  345. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  346. };
  347. #endif