AcDbAssocArrayItem.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // CREATED BY: Sharad Jaiswal March 2010
  12. //
  13. // DESCRIPTION:
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. #pragma once
  17. /// <summary>
  18. /// AcDbItemLocator, represents spatial index of an item in a 3D array
  19. /// i.e an item index{i,j,k} for rectangular array.
  20. /// </summary>
  21. ///
  22. class ACDB_PORT AcDbItemLocator
  23. {
  24. public:
  25. /// <summary>
  26. /// Enum to define index type for a 3D item index.
  27. /// </summary>
  28. ///
  29. enum IndexType
  30. {
  31. /// <summary>
  32. /// Index type indicating item position relative to the first item.
  33. /// </summary>
  34. ///
  35. kItemIndex,
  36. /// <summary>
  37. /// Index type indicating item position relative to the first row.
  38. /// </summary>
  39. ///
  40. kRowIndex,
  41. /// <summary>
  42. /// Index type indicating item position relative to the first level.
  43. /// </summary>
  44. ///
  45. kLevelIndex,
  46. };
  47. /// <summary>
  48. /// Default constructor. Object constructed using this constructor remains
  49. /// uninitialized.
  50. /// </summary>
  51. ///
  52. AcDbItemLocator();
  53. /// <summary>
  54. /// Parameterized constructor, this initializes all indices of the object.
  55. /// The cannonical form of AcDbItemLocator always uses +ve value for
  56. /// indices, but clients may use -ve values for indices subjected to their
  57. /// own interpretation of -ve vlaues.
  58. /// </summary>
  59. /// <param name="itemIndex"> The input Index relative to the first item.
  60. /// </param>
  61. /// <param name="rowIndex"> The input Index relative to the first row.
  62. /// </param>
  63. /// <param name="levelIndex"> The input Index relative to the first level.
  64. /// </param>
  65. ///
  66. AcDbItemLocator(int itemIndex, int rowIndex, int levelIndex);
  67. /// <summary>
  68. /// Copy constructor, this copies all indices of the other object to this
  69. /// object.
  70. /// </summary>
  71. /// <param name="other"> The other AcDbItemLocator object intended to copy from. </param>
  72. ///
  73. AcDbItemLocator(const AcDbItemLocator& other);
  74. /// <summary>
  75. /// Index operator, this returns index of a particular index type.
  76. /// </summary>
  77. /// <param name="i"> The input Index type. </param>
  78. /// <returns> The index of given Index type. </returns>
  79. ///
  80. int operator [] (IndexType i) const { return mIndices[i]; }
  81. /// <summary>
  82. /// Assignment operator, this copies all indices of the other object to
  83. /// this object.
  84. /// </summary>
  85. ///
  86. AcDbItemLocator& operator = (const AcDbItemLocator& other);
  87. /// <summary>
  88. /// Subtraction operator, this returns difference from other object.
  89. /// </summary>
  90. ///
  91. AcDbItemLocator operator - (const AcDbItemLocator& other) const;
  92. /// <summary>
  93. /// Addition operator, this combines indices of other object and
  94. /// this object to return a new object.
  95. /// </summary>
  96. ///
  97. AcDbItemLocator operator + (const AcDbItemLocator& other) const;
  98. /// <summary>
  99. /// Equal to operator, checks if the other object is same as this object.
  100. /// </summary>
  101. ///
  102. bool operator == (const AcDbItemLocator& other) const;
  103. /// <summary>
  104. /// Not equal to operator, checks if the other object is different than
  105. /// this object.
  106. /// </summary>
  107. ///
  108. bool operator != (const AcDbItemLocator& other) const;
  109. /// <summary>
  110. /// Less operator, checks if this object is less than the other object.
  111. /// </summary>
  112. ///
  113. bool operator < (const AcDbItemLocator& other) const;
  114. /// <summary>
  115. /// Greator operator, checks if this object is less than the other object.
  116. /// </summary>
  117. ///
  118. bool operator > (const AcDbItemLocator& other) const { return compareWith(other) > 0; }
  119. /// <summary>
  120. /// Compares this with other object, returns 0 if the two objects are same
  121. /// -ve value if this is smaller than the other, +ve value if this is
  122. /// greater than other object.
  123. /// </summary>
  124. ///
  125. int compareWith(const AcDbItemLocator& other) const;
  126. private:
  127. int mIndices[3];
  128. };
  129. class AcDbImpAssocArrayItem;
  130. /// <summary>
  131. /// AcDbAssocArrayItem class represents transformation and other meta data of
  132. /// an item in an array. This class provides interface to obtain item transform,
  133. /// it's locator (spatial index), relative transform etc.
  134. /// </summary>
  135. /// <remarks> This class is currently for internal use only. </remarks>
  136. ///
  137. class ACDB_PORT AcDbAssocArrayItem : public AcRxObject
  138. {
  139. public:
  140. ACRX_DECLARE_MEMBERS(AcDbAssocArrayItem);
  141. /// <summary>
  142. /// Default constructor.
  143. /// </summary>
  144. ///
  145. AcDbAssocArrayItem();
  146. /// <summary>
  147. /// Parameterized constructor, initializes locator and default transform.
  148. /// </summary>
  149. /// <param name="locator"> The input AcDbItemLocator. </param>
  150. /// <param name="transform"> The input transformation matrix. </param>
  151. ///
  152. AcDbAssocArrayItem(AcDbItemLocator& locator, const AcGeMatrix3d& transform);
  153. /// <summary>
  154. /// Default destructor.
  155. /// </summary>
  156. ///
  157. virtual ~AcDbAssocArrayItem();
  158. /// transformation specific query methods.
  159. /// <summary>
  160. /// Obtains default or compounded transform of this item. Default transform
  161. /// defines original transform for the item in the array. Compounded
  162. /// transform includes relative transformation (if any) applied to the item.
  163. /// </summary>
  164. /// <param name="transform"> Returned transformation matrix. </param>
  165. /// <param name="bCompounded"> A flag to indicate whether compounded or
  166. /// default transform to be obtained. </param>
  167. /// <returns> Acad::ErrorStatus </returns>
  168. ///
  169. Acad::ErrorStatus getTransform(AcGeMatrix3d& transform, bool bCompounded = true) const;
  170. /// <summary>
  171. /// Checks if this items has a relative transform.
  172. /// </summary>
  173. /// <returns> true, if item has a relative transform. </returns>
  174. ///
  175. bool hasRelativeTransform() const;
  176. /// <summary>
  177. /// Applies relative transform to this item.
  178. /// </summary>
  179. /// <param name="transform"> Input transformation matrix. </param>
  180. /// <returns> Acad::ErrorStatus </returns>
  181. ///
  182. Acad::ErrorStatus transformBy(const AcGeMatrix3d& transform);
  183. /// <summary>
  184. /// Sets default transform of this item.
  185. /// </summary>
  186. /// <param name="transform"> Input transformation matrix. </param>
  187. /// <returns> Acad::ErrorStatus </returns>
  188. ///
  189. Acad::ErrorStatus setDefaultTransform(const AcGeMatrix3d& transform);
  190. /// Query methods for other properties.
  191. /// <summary>
  192. /// Marks the item erased.
  193. /// </summary>
  194. /// <param name="bErased"> Input flag to mark erased. </param>
  195. /// <returns> Acad::ErrorStatus </returns>
  196. ///
  197. Acad::ErrorStatus setErased(bool bErased);
  198. /// <summary>
  199. /// Checks if the item is erased.
  200. /// </summary>
  201. /// <returns> true, if this item is erased. </returns>
  202. ///
  203. bool isErased() const;
  204. /// <summary>
  205. /// Obtains item's spatial index/locator.
  206. /// </summary>
  207. /// <returns> AcDbItemLocator, spatial index of the item. </returns>
  208. ///
  209. const AcDbItemLocator& locator() const;
  210. /// <summary>
  211. /// Obtains entity provider for this item.
  212. /// </summary>
  213. /// <returns> Object id of entity provider. </returns>
  214. ///
  215. const AcDbObjectId& entityProvider() const;
  216. /// <summary>
  217. /// Sets entity provider for this item.
  218. /// </summary>
  219. /// <param name="provider"> Input Object id of entity provider. </param>
  220. ///
  221. void setEntityProvider(AcDbObjectId provider);
  222. /// <summary>
  223. /// Copies item's content from other object.
  224. /// </summary>
  225. /// <param name="other"> Pointer to other item. </param>
  226. /// <returns> Acad::ErrorStatus </returns>
  227. ///
  228. virtual Acad::ErrorStatus copyFrom(const AcRxObject* other);
  229. /// <summary> This function is called by dwgIn().
  230. /// Its purpose is to allow the object to read in its data.
  231. /// </summary>
  232. /// <param name="pFiler"> Input pointer to filer to use to read in
  233. /// the object's data. </param>
  234. /// <returns> Acad::ErrorStatus </returns>
  235. ///
  236. virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
  237. /// <summary> This function is called by dwgOut().
  238. /// Its purpose is to allow the object to write out its data.
  239. /// </summary>
  240. /// <param name="pFiler"> Input pointer to filer to use to write out
  241. /// the object's data. </param>
  242. /// <returns> Acad::ErrorStatus </returns>
  243. ///
  244. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
  245. /// <summary> This function is called by dxfIn().
  246. /// Its purpose is to allow the object to read in its data.
  247. /// </summary>
  248. /// <param name="pFiler"> Input pointer to filer to use to read in
  249. /// the object's data. </param>
  250. /// <returns> Acad::ErrorStatus </returns>
  251. ///
  252. virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler* pFiler);
  253. /// <summary> This function is called by dxfOut().
  254. /// Its purpose is to allow the object to write out its data.
  255. /// </summary>
  256. /// <param name="pFiler"> Input pointer to filer to use to write out
  257. /// the object's data. </param>
  258. /// <returns> Acad::ErrorStatus </returns>
  259. ///
  260. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler) const;
  261. private:
  262. AcDbAssocArrayItem(const AcDbAssocArrayItem& other); //Copy constructor.
  263. friend class AcDbImpAssocArrayItem;
  264. AcDbImpAssocArrayItem* mpSelf;
  265. };