AcDbAssocArrayPathParameters.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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: Mei Jiayin March 2010
  12. //
  13. // DESCRIPTION:
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. #pragma once
  17. #include "AcDbAssocArrayCommonParameters.h"
  18. class AcDbImpAssocArrayPathParameters;
  19. /// <summary>
  20. /// AcDbAssocArrayPathParameters class provides interface to manipulate
  21. /// path array parameters.
  22. /// </summary>
  23. ///
  24. class ACDB_PORT AcDbAssocArrayPathParameters : public AcDbAssocArrayCommonParameters
  25. {
  26. public:
  27. ACRX_DECLARE_MEMBERS(AcDbAssocArrayPathParameters);
  28. /// <summary>
  29. /// Following list of enums can be used as input to method
  30. /// getGripPointAt(unsigned int, AcDbArrayGripAppData* &) to get specific
  31. /// type of grip. System internally uses these enums for grip operations on
  32. /// path array.
  33. /// </summary>
  34. ///
  35. enum GripModes
  36. {
  37. /// <summary>
  38. /// Moves the array object.
  39. /// </summary>
  40. ///
  41. kStretchGrip = 1 << 0,
  42. /// <summary>
  43. /// Changes number of rows.
  44. /// </summary>
  45. ///
  46. kRowCountGrip = 1 << 1,
  47. /// <summary>
  48. /// Changes distance between rows.
  49. /// </summary>
  50. ///
  51. kRowSpacingGrip = 1 << 2,
  52. /// <summary>
  53. /// Changes distance between rows by distributing the move uniformly
  54. /// across all the rows.
  55. /// </summary>
  56. ///
  57. kUniformRowSpacingGrip = 1 << 3,
  58. /// <summary>
  59. /// Changes number of levels.
  60. /// </summary>
  61. ///
  62. kLevelCountGrip = 1 << 4,
  63. /// <summary>
  64. /// Changes distance between levels.
  65. /// </summary>
  66. ///
  67. kLevelSpacingGrip = 1 << 5,
  68. /// <summary>
  69. /// Changes distance between levels by distributing the move uniformly
  70. /// across all the levels.
  71. /// </summary>
  72. ///
  73. kUniformLevelSpacingGrip = 1 << 6,
  74. /// <summary>
  75. /// Changes number of items.
  76. /// </summary>
  77. ///
  78. kItemCountGrip = 1 << 7,
  79. /// <summary>
  80. /// Used in measure method only.
  81. /// Changes distance between items.
  82. /// </summary>
  83. ///
  84. kItemSpacingGrip = 1 << 8,
  85. /// <summary>
  86. /// Used in measure method only.
  87. /// Changes distance between items by distributing the move uniformly
  88. /// across all the items.
  89. /// </summary>
  90. ///
  91. kUniformItemSpacingGrip = 1 << 9,
  92. };
  93. /// <summary> Constructor.</summary>
  94. /// <param name="itemSpacing"> The input spacing between adjacent items. </param>
  95. /// <param name="rowSpacing"> The input spacing between adjacent rows. </param>
  96. /// <param name="levelSpacing"> The input spacing between adjacent levels. </param>
  97. /// <param name="itemCount"> The input number of items. </param>
  98. /// <param name="rowCount"> The input number of rows. </param>
  99. /// <param name="levelCount"> The input number of levels. </param>
  100. /// <param name="rowElevation"> The input elevation between adjacent rows. </param>
  101. ///
  102. AcDbAssocArrayPathParameters(double itemSpacing = 1, double rowSpacing = 1,
  103. double levelSpacing = 1, int itemCount = 1, int rowCount = 1,
  104. int levelCount = 1, double rowElevation = 1);
  105. /// <summary> Default destructor.</summary>
  106. ///
  107. virtual ~AcDbAssocArrayPathParameters(void);
  108. /// <summary>
  109. /// The method of arraying items along the path.
  110. /// </summary>
  111. ///
  112. enum Method
  113. {
  114. /// <summary>
  115. /// Divide method arranges given number of items on entire path equidistantly.
  116. /// </summary>
  117. ///
  118. kDivide,
  119. /// <summary>
  120. /// Mesure method arranges given number of items at specified item spacing along the path.
  121. /// </summary>
  122. ///
  123. kMeasure,
  124. };
  125. /// <summary>
  126. /// Gets the item count of the path array.
  127. /// If there is no expression for a particular param,
  128. /// expression string and the evaluatorId are empty strings.
  129. /// </summary>
  130. /// <param name="expression"> The returned expression. </param>
  131. /// <param name="evaluatorId"> The returned evaluatorId. </param>
  132. /// <returns> Returns item count. </returns>
  133. ///
  134. int itemCount(AcString& expression, AcString& evaluatorId) const;
  135. inline int itemCount() const
  136. {
  137. AcString expression, evaluatorId;
  138. return itemCount(expression, evaluatorId);
  139. }
  140. inline int itemCount(AcString & expression) const
  141. {
  142. AcString evaluatorId;
  143. return itemCount(expression, evaluatorId);
  144. }
  145. /// <summary>
  146. /// Gets the item spacing of the path array.
  147. /// If there is no expression for a particular param,
  148. /// expression string and the evaluatorId are empty strings.
  149. /// </summary>
  150. /// <param name="expression"> The returned expression. </param>
  151. /// <param name="evaluatorId"> The returned evaluatorId. </param>
  152. /// <returns> Returns item spacing. </returns>
  153. ///
  154. double itemSpacing(AcString& expression, AcString& evaluatorId) const;
  155. inline double itemSpacing() const
  156. {
  157. AcString expression, evaluatorId;
  158. return itemSpacing(expression, evaluatorId);
  159. }
  160. inline double itemSpacing(AcString& expression) const
  161. {
  162. AcString evaluatorId;
  163. return itemSpacing(expression, evaluatorId);
  164. }
  165. /// <summary>
  166. /// Gets the AcDbEdgeRef that identifies the path of the path array.
  167. /// </summary>
  168. /// <returns> Returns the AcDbEdgeRef that identifies the path. </returns>
  169. ///
  170. AcDbEdgeRef path() const;
  171. /// <summary>
  172. /// Gets the method of arraying items along the path.
  173. /// </summary>
  174. /// <returns> Returns the method of arraying items along the path. Default method is kMeasure</returns>
  175. ///
  176. Method method() const;
  177. /// <summary>
  178. /// Gets the align items option.
  179. /// </summary>
  180. /// <returns> Returns whether to align items. Default value is true</returns>
  181. ///
  182. bool alignItems() const;
  183. /// <summary>
  184. /// Gets the start offset of the path array.
  185. /// If there is no expression for a particular param,
  186. /// expression string and the evaluatorId are empty strings.
  187. /// </summary>
  188. /// <param name="expression"> The returned expression. </param>
  189. /// <param name="evaluatorId"> The returned evaluatorId. </param>
  190. /// <returns> Returns start offset. </returns>
  191. ///
  192. double startOffset(AcString& expression, AcString& evaluatorId) const;
  193. inline double startOffset() const
  194. {
  195. AcString expression, evaluatorId;
  196. return startOffset(expression, evaluatorId);
  197. }
  198. /// <summary>
  199. /// Gets the end offset of the path array.
  200. /// End offset is only avaliable for Divide method.
  201. /// If there is no expression for a particular param,
  202. /// expression string and the evaluatorId are empty strings.
  203. /// </summary>
  204. /// <param name="expression"> The returned expression. </param>
  205. /// <param name="evaluatorId"> The returned evaluatorId. </param>
  206. /// <returns> Returns end offset. </returns>
  207. ///
  208. double endOffset(AcString& expression, AcString& evaluatorId) const;
  209. inline double endOffset() const
  210. {
  211. AcString expression, evaluatorId;
  212. return endOffset(expression, evaluatorId);
  213. }
  214. /// <summary>
  215. /// Sets the item count of the path array.
  216. /// If there is no expression for the parameter, the expression string and
  217. /// the evaluatorId must be empty strings.
  218. /// </summary>
  219. /// <param name="nItems"> The item count to set. </param>
  220. /// <param name="expression"> The expression to set. </param>
  221. /// <param name="evaluatorId"> The evaluatorId to set. </param>
  222. /// <param name="errorMessage"> The returned error message for the individual expression. </param>
  223. /// <returns> Acad::ErrorStatus. </returns>
  224. ///
  225. Acad::ErrorStatus setItemCount(int nItems, const AcString& expression = AcString(),
  226. const AcString& evaluatorId = AcString(), AcString& errorMessage = dummyString());
  227. /// <summary>
  228. /// Sets the item spacing of the path array.
  229. /// If there is no expression for the parameter, the expression string and
  230. /// the evaluatorId must be empty strings. This has no effect if method is set to kDivide.
  231. /// </summary>
  232. /// <param name="offset"> The item spacing to set. </param>
  233. /// <param name="expression"> The expression to set. </param>
  234. /// <param name="evaluatorId"> The evaluatorId to set. </param>
  235. /// <param name="errorMessage"> The returned error message for the individual expression. </param>
  236. /// <returns> Acad::ErrorStatus. </returns>
  237. ///
  238. Acad::ErrorStatus setItemSpacing(double offset, const AcString& expression = AcString(),
  239. const AcString& evaluatorId = AcString(), AcString& errorMessage = dummyString());
  240. /// <summary>
  241. /// Sets the path of the path array.
  242. /// </summary>
  243. /// <param name="edgeRef"> The AcDbEdgeRef to set. </param>
  244. /// <returns> Acad::ErrorStatus. </returns>
  245. ///
  246. Acad::ErrorStatus setPath(const AcDbEdgeRef& edgeRef);
  247. /// <summary>
  248. /// Sets the method of arraying items along the path.
  249. /// </summary>
  250. /// <param name="method"> The input method of arraying items along the path. </param>
  251. /// <returns> Acad::ErrorStatus. </returns>
  252. ///
  253. Acad::ErrorStatus setMethod(Method method);
  254. /// <summary>
  255. /// Sets whether to align items or not.
  256. /// </summary>
  257. /// <param name="bAlignItems"> The boolean value to set. </param>
  258. /// <returns> Acad::ErrorStatus. </returns>
  259. ///
  260. Acad::ErrorStatus setAlignItems(bool bAlignItems);
  261. /// <summary>
  262. /// Sets the start offset of the path array.
  263. /// If there is no expression for the parameter, the expression string and
  264. /// the evaluatorId must be empty strings.
  265. /// </summary>
  266. /// <param name="startOffset"> The start offset to set. This must be non-negative value. </param>
  267. /// <param name="expression"> The expression to set. </param>
  268. /// <param name="evaluatorId"> The evaluatorId to set. </param>
  269. /// <param name="errorMessage"> The returned error message for the individual expression. </param>
  270. /// <returns> Acad::ErrorStatus. </returns>
  271. ///
  272. Acad::ErrorStatus setStartOffset(double startOffset, const AcString& expression = AcString(),
  273. const AcString& evaluatorId = AcString(), AcString& errorMessage = dummyString());
  274. /// <summary>
  275. /// Sets the end offset of the path array.
  276. /// End offset is only avaliable for Divide method.
  277. /// If there is no expression for the parameter, the expression string and
  278. /// the evaluatorId must be empty strings.
  279. /// </summary>
  280. /// <param name="endOffset"> The end offset to set. This must be non-negative value.</param>
  281. /// <param name="expression"> The expression to set. </param>
  282. /// <param name="evaluatorId"> The evaluatorId to set. </param>
  283. /// <param name="errorMessage"> The returned error message for the individual expression. </param>
  284. /// <returns> Acad::ErrorStatus. </returns>
  285. ///
  286. Acad::ErrorStatus setEndOffset(double endOffset, const AcString& expression = AcString(),
  287. const AcString& evaluatorId = AcString(), AcString& errorMessage = dummyString());
  288. /// <summary>
  289. /// Sets the direction of path curve.
  290. /// if bAlongParams is false, then the parameter of this path curve is reversed
  291. /// and is created from end point to start point.
  292. /// </summary>
  293. /// <param name="bAlongParams"> The boolean value to set. </param>
  294. /// <returns> Acad::ErrorStatus. </returns>
  295. ///
  296. Acad::ErrorStatus setPathDirection(bool bAlongParams);
  297. /// <summary> <para>
  298. /// Obtains list of items patterned by the set of owned parameters. Each
  299. /// parameters class uses its own logic based on owned value as well as
  300. /// geometry parameters to define a set of items to be patterned as array.
  301. /// </para><para>
  302. /// The owning AcDbAssocArrayActionBody calls this method while evaluating
  303. /// the array to update transforms of each item in the array. The caller
  304. /// may pass its current list of items for update. The input list can be
  305. /// modified by this implementation to cater change in value parameters
  306. /// controlling number of items in various directions.
  307. /// </para></summary>
  308. /// <param name="items"> The updated list of items. </param>
  309. /// <returns> Acad::ErrorStatus. </returns>
  310. ///
  311. virtual Acad::ErrorStatus getItems(AcArray<AcDbAssocArrayItem*>& items) const;
  312. /// <summary>
  313. /// Obtains position as well as orientation of an item at given spatial
  314. /// index specified by the locator.
  315. /// </summary>
  316. /// <param name="locator"> The input item locator or spatial index. </param>
  317. /// <param name="position"> The returned positon of the item whose location is
  318. /// indicated by the input locator. </param>
  319. /// <param name="xform"> The returned orientation transform of the item.
  320. /// </param>
  321. /// <returns> Acad::ErrorStatus. </returns>
  322. ///
  323. virtual Acad::ErrorStatus getItemPosition(const AcDbItemLocator& locator,
  324. AcGePoint3d& position, AcGeMatrix3d& xform) const;
  325. inline Acad::ErrorStatus getItemPosition(const AcDbItemLocator& locator,
  326. AcGePoint3d& position) const
  327. {
  328. AcGeMatrix3d xform;
  329. return getItemPosition(locator, position,xform);
  330. }
  331. protected:
  332. friend class AcDbImpAssocArrayPathParameters;
  333. explicit AcDbAssocArrayPathParameters(AcDbImpAssocArrayPathParameters* pSelf);
  334. };