AcDbAssocArrayParameters.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. // CREATED BY: Sharad Jaiswal March 2010
  11. //
  12. // DESCRIPTION:
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #pragma once
  16. #include "rxobject.h"
  17. #include "AcDbAssocArrayItem.h"
  18. class AcDbArrayGripAppData;
  19. class AcDbImpAssocArrayParameters;
  20. /// <summary><para>
  21. /// AcDbAssocArrayParameters class provides interface to manipulate array
  22. /// parameters. Its derived classes implement logic for providing array item
  23. /// transforms as well as grip manipulation. AcDbAssocArrayActionBody owns
  24. /// the object of this class and uses its methods to evaluate the entire array.
  25. /// This class can also be used by UI module to access parameters or provide
  26. /// jigging effect.
  27. /// </para><para>
  28. /// This class provides two kinds of parameters, value params and geometry
  29. /// params.
  30. /// </para></summary>
  31. /// <remarks> Deriving from this class is not supported. </remarks>
  32. ///
  33. class ACDB_PORT AcDbAssocArrayParameters : public AcRxObject
  34. {
  35. public:
  36. ACRX_DECLARE_MEMBERS(AcDbAssocArrayParameters);
  37. /// <summary> Default destructor. </summary>
  38. ///
  39. virtual ~AcDbAssocArrayParameters(void);
  40. /// <summary><para>
  41. /// Sets value, expression and evaluatorId for a given value action parameter
  42. /// If there is no expression for the parameter, the expression string and
  43. /// the evaluatorId must be empty strings.
  44. /// </para><para>
  45. /// If the user enters the expression in the form of "name=expression", the
  46. /// automatically created AcDbAssocVariable is assigned the given "name",
  47. /// apperars in the parameters manager and can be referenced by other
  48. /// expressions as any other variable. If the expression is in the form
  49. /// "expression", an anonymous variable is created that cannot be referenced
  50. /// and is not visible in the parameters manager.
  51. /// </para><para>
  52. /// If a value parameter of the given name does not exist, it is created.
  53. /// Otherwise the existing value parameter is used.
  54. /// </para><para>
  55. /// This method does not do any validation on given value or expression
  56. /// so should not be directly used to modify array parameters.
  57. /// This method is for derived parameter classes to set their validated value.
  58. /// </para></summary>
  59. /// <param name="paramName"> The name of the value action parameter. </param>
  60. /// <param name="value"> The value to set. </param>
  61. /// <param name="expression"> The expression to set. </param>
  62. /// <param name="evaluatorId"> The evaluatorId to set. </param>
  63. /// <param name="errorMessage"> The returned error message for the individual expression. </param>
  64. /// <param name="pUnitType"> The unit type to set. If it is NULL, the default value is AcValue::kUnitless</param>
  65. /// <returns> Acad::ErrorStatus. </returns>
  66. ///
  67. Acad::ErrorStatus setValueParam(const AcString& paramName,
  68. const AcDbEvalVariant& value,
  69. const AcString& expression,
  70. const AcString& evaluatorId,
  71. AcString& errorMessage,
  72. AcValue::UnitType* pUnitType = NULL);
  73. /// <summary>
  74. /// Obtains value, expression and evaluatorId for a given value action param
  75. /// owned by this parameter. If there is no expression for a particular param,
  76. /// expression string and the evaluatorId are empty strings.
  77. /// </summary>
  78. /// <param name="paramName"> The name of the value action parameter. </param>
  79. /// <param name="value"> The returned value. </param>
  80. /// <param name="expression"> The returned expression. </param>
  81. /// <param name="evaluatorId"> The returned evaluatorId. </param>
  82. /// <param name="unitType"> The returned unit type. </param>
  83. /// <returns>
  84. /// If a value action parameter with the given name is not found, returns Acad::eNotInGroup.
  85. /// </returns>
  86. ///
  87. Acad::ErrorStatus getValueParam(const AcString& paramName,
  88. AcDbEvalVariant& value,
  89. AcString& expression,
  90. AcString& evaluatorId,
  91. AcValue::UnitType& unitType) const;
  92. /// <summary><para>
  93. /// Sets a pointer to AcDbGeomRef for a given geometry action parameter
  94. /// such as AcDbAssocVertexActionParam, AcDbAssocPathActionParam or
  95. /// AcDbAssocFaceActionParam etc.
  96. /// </para><para>
  97. /// If a geometry parameter of the given name does not exist, it is created.
  98. /// Otherwise the existing geometry parameter is used.
  99. /// </para></summary>
  100. /// <param name="paramName"> The name of the geometry action parameter.
  101. /// </param>
  102. /// <param name="pGeomRef"> The geometry reference to set. </param>
  103. /// <param name="paramId"> The returned object id of geometry action
  104. /// parameter. </param>
  105. /// <returns> Acad::ErrorStatus. </returns>
  106. ///
  107. Acad::ErrorStatus setGeomParam(const AcString& paramName,
  108. const AcDbGeomRef* pGeomRef,
  109. AcDbObjectId& paramId);
  110. /// <summary>
  111. /// Obtains pointer to AcDbGeomRef for a given geometry action parameter
  112. /// owned by this parameter.
  113. /// The returned AcDbGeomRef* should be deleted by caller after use.
  114. /// </summary>
  115. /// <param name="paramName"> The name of the geometry action parameter.
  116. /// </param>
  117. /// <param name="pGeomRef"> The returned geometry reference. </param>
  118. /// <param name="paramId"> The returned object id of geometry action
  119. /// parameter. </param>
  120. /// <returns>
  121. /// If a geometry action parameter with the given name is not found, returns Acad::eNotInGroup.
  122. /// </returns>
  123. ///
  124. Acad::ErrorStatus getGeomParam(const AcString& paramName,
  125. AcDbGeomRef*& pGeomRef,
  126. AcDbObjectId& paramId) const;
  127. /// <summary>
  128. /// Returns names of all owned value action parameters. The names of the value
  129. /// action parameters are arbitrary case-sensitive strings but must be unique.
  130. /// </summary>
  131. /// <param name="paramNames"> Names of all owned value action parameters. </param>
  132. ///
  133. void ownedValueParamNames(AcArray<AcString>& paramNames) const;
  134. /// <summary>
  135. /// Returns names of all owned geometry action parameters. The names of the geometry
  136. /// action parameters are arbitrary case-sensitive strings but must be unique.
  137. /// </summary>
  138. /// <param name="paramNames"> Names of all owned geometry action parameters. </param>
  139. ///
  140. void ownedGeomParamNames(AcArray<AcString>& paramNames) const;
  141. /// <summary>
  142. /// Sets input AcDbAssocArrayActionBody as owner. When owner is not set the
  143. /// parameters are locally cached with this object. Once it is set all the
  144. /// value action params and geometry action params are transferred to owning
  145. /// action. Once owner is set, it can't be changed any more.
  146. /// </summary>
  147. /// <param name="pOwner"> The assoc array action to be set as owner. </param>
  148. /// <returns> Acad::ErrorStatus. </returns>
  149. ///
  150. Acad::ErrorStatus setOwner(class AcDbAssocArrayActionBody* pOwner);
  151. /// <summary>
  152. /// Gets the owner AcDbAssocArrayActionBody pointer for read.
  153. /// </summary>
  154. /// <returns> Pointer to AcDbAssocArrayActionBody. </returns>
  155. ///
  156. const AcDbAssocArrayActionBody* owner() const;
  157. /// <summary>
  158. /// Gets the owner AcDbAssocArrayActionBody pointer for write.
  159. /// </summary>
  160. /// <returns> Pointer to AcDbAssocArrayActionBody. </returns>
  161. ///
  162. AcDbAssocArrayActionBody* owner();
  163. /// <summary>
  164. /// Copies the parameters from other object. The input object must be of the
  165. /// class.
  166. /// </summary>
  167. /// <param name="other"> The other input parameter to be copied from. </param>
  168. /// <returns> Acad::ErrorStatus. </returns>
  169. ///
  170. virtual Acad::ErrorStatus copyFrom(const AcRxObject* other);
  171. /// <summary> <para>
  172. /// Obtains list of items patterned by the set of owned parameters. Each
  173. /// parameters class uses its own logic based on owned value as well as
  174. /// geometry parameters to define a set of items to be patterned as array.
  175. /// </para><para>
  176. /// The owning AcDbAssocArrayActionBody calls this method while evaluating
  177. /// the array to update transforms of each item in the array. The caller
  178. /// may pass its current list of items for update. The input list can be
  179. /// modified by this implementation to cater change in value parameters
  180. /// controlling number of items in various directions.
  181. /// </para></summary>
  182. /// <param name="items"> The updated list of items. </param>
  183. /// <returns> Acad::ErrorStatus. </returns>
  184. ///
  185. virtual Acad::ErrorStatus getItems(AcArray<AcDbAssocArrayItem*>& items) const = 0;
  186. /// <summary>
  187. /// Obtains position as well as orientation of an item at given spatial
  188. /// index specified by the locator.
  189. /// </summary>
  190. /// <param name="locator"> The input item locator or spatial index. </param>
  191. /// <param name="position"> The returned positon of the item whose location is
  192. /// indicated by the input locator. </param>
  193. /// <param name="xform"> The returned orientation transform of the item.
  194. /// </param>
  195. /// <returns> Acad::ErrorStatus. </returns>
  196. ///
  197. virtual Acad::ErrorStatus getItemPosition(const AcDbItemLocator& locator,
  198. AcGePoint3d& position, AcGeMatrix3d& xform) const = 0;
  199. /// <summary>
  200. /// Obtains canonical form of given item locator. The given locator may be
  201. /// counted wrt start or end, but the returned canonical form is always
  202. /// counted from start of the array pattern.
  203. /// </summary>
  204. /// <param name="locator"> The input item locator or spatial index. </param>
  205. /// <returns> Canonical form of input locator. </returns>
  206. ///
  207. virtual AcDbItemLocator getCanonicalForm(const AcDbItemLocator& locator) const = 0;
  208. /// <summary>
  209. /// Obtains grip data based on the grip mode. The default implementation
  210. /// returns Acad::eNotImplementedYet error code. The UI code calls this
  211. /// method to get grip data for specific grip mode. Caller needs to delete
  212. /// allocated memory for pGrip.
  213. /// </summary>
  214. /// <param name="mode"> The input grip mode. </param>
  215. /// <param name="pGrip"> The returned grip data for input grip mode. </param>
  216. /// <returns> Acad::ErrorStatus. </returns>
  217. ///
  218. virtual Acad::ErrorStatus getGripPointAt(unsigned int mode, AcDbArrayGripAppData* &pGrip) const;
  219. /// <summary>
  220. /// Obtains all grips supported by this parameters class. This method will be
  221. /// called when system wants to show grips of the array controlled by its
  222. /// owner array action. The default implementation doesn't return any grip.
  223. /// The caller needs to delete allocated memory for grips.
  224. /// </summary>
  225. /// <param name="grips"> The returned list of grips provided by this
  226. /// parameters class. </param>
  227. /// <returns> Acad::ErrorStatus. </returns>
  228. ///
  229. virtual Acad::ErrorStatus getGripPoints(AcArray<AcDbArrayGripAppData*>& grips) const;
  230. /// <summary>
  231. /// This method is responsible for updating value action params based on
  232. /// a particular grip movement. Default implementation doesn't do anything.
  233. /// </summary>
  234. /// <param name="pGrip"> The input grip data that is being moved with given
  235. /// offset. </param>
  236. /// <param name="offset"> The input offset vector with which grip is moved.
  237. /// </param>
  238. /// <param name="modificationBit"> The returned flag to indicate any
  239. /// parameter modification. If given offset doesn't modify this object the
  240. /// returned value will be zero. </param>
  241. /// <returns> Acad::eOwnerToBeTransformed if this call needs to be handled
  242. /// by owner, Acad::ErrorStatus otherwise. </returns>
  243. ///
  244. virtual Acad::ErrorStatus moveGripPointAt(const AcDbArrayGripAppData* pGrip,
  245. const AcGeVector3d &offset,
  246. int& modificationBit);
  247. protected:
  248. friend class AcDbImpAssocArrayParameters;
  249. explicit AcDbAssocArrayParameters(AcDbImpAssocArrayParameters* pSelf = NULL);
  250. AcDbImpAssocArrayParameters* mpSelf;
  251. };