AcDbAssocActionParam.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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: Jiri Kripac March 2009
  12. //
  13. //////////////////////////////////////////////////////////////////////////////
  14. #pragma once
  15. #include "AcDbAssocGlobal.h"
  16. #include "AcDbCompoundObjectId.h"
  17. #pragma pack (push, 8)
  18. /// <summary><para>
  19. /// Abstract base class for all derived AcDbAssocXxxActionParam classes. Action
  20. /// parameters are owned by AcDbAssocAction, either directly or via an
  21. /// AcDbAssocCompoundActionParam hierarchy.
  22. /// </para><para>
  23. /// Action parameters provide a uniform and high-level way for custom action bodies
  24. /// to keep and access their data. Instead of each custom action body implementing
  25. /// its own code to keep its data and devise its own representation of the data,
  26. /// the data is kept in the form of action parameters and owned by the parent action.
  27. /// The action body then does not need to take care of the data serialization and
  28. /// cloning, because it is performed by the parent action. External code can inspect
  29. /// the action body data without knowing anything about the action body itself,
  30. /// because the data in the form of action parameters can be traversed and inspected
  31. /// in a general way.
  32. /// </para><para>
  33. /// The concrete derived action parameter classes provide a general and high-level
  34. /// mechanism for keeping and accessing the application data, transparent to the
  35. /// client code. For example, when an action body needs to keep a reference to an
  36. /// edge subentity of an entity (such as to a line entity, segment of a polyline,
  37. /// edge of a solid or surface, or generally to anything that provides AcGeCurve3d
  38. /// geometry), it just creates an object of AcDbAssocEdgeActionParam class that
  39. /// takes care of keeping the data. Anytime the client code needs the current
  40. /// geometry of the edge subentity, it asks the AcDbAssocEdgeActionParam and it
  41. /// provides the geometry to the client code. The AcDbAssocEdgeActionParam takes
  42. /// care of keeping the data in various ways, such as by referencing an AcDbEntity
  43. /// in the database, by referencing an edge subentity of an AcDbEntity, or by directly
  44. /// keeping a constant AcGeCurve. The client code does not need to worry about
  45. /// how the data is kept. It just asks the AcDbAssocEdgeActionParam and obtains
  46. /// the current AcGeCurve3d* from it.
  47. /// </para></summary>
  48. ///
  49. class ACDB_PORT AcDbAssocActionParam : public AcDbObject
  50. {
  51. public:
  52. ACRX_DECLARE_MEMBERS(AcDbAssocActionParam);
  53. /// <summary> Default constructor. </summary>
  54. /// <param name="createImpObject"> See AcDbAssocCreateImpObject. </param>
  55. ///
  56. AcDbAssocActionParam(AcDbAssocCreateImpObject createImpObject = kAcDbAssocCreateImpObject);
  57. /// <summary>
  58. /// Returns the action parameter name. It may be any string, possibly empty.
  59. /// The parameter name is case sensitive. Multiple action parameters owned
  60. /// by the same action may have the same name.
  61. /// </summary>
  62. /// <returns> The name of the action parameter. </returns>
  63. ///
  64. const AcString& name() const;
  65. /// <summary>
  66. /// Sets the parameter name. It may be any string, possibly empty.
  67. /// The parameter name is case sensitive. Multiple action parameters owned
  68. /// by the same action may have the same name.
  69. /// </summary>
  70. /// <param name="newName"> New name of this action parameter. </param>
  71. /// <returns> Acad::ErrorStatus. </returns>
  72. ///
  73. virtual Acad::ErrorStatus setName(const AcString& newName);
  74. /// <summary>
  75. /// Resets the contents of the parameter to "empty" state, optionally
  76. /// erasing all objects that the parameter physically or logically owns,
  77. /// such as sub-parameters or dependencies (dependencies are "physically" owned
  78. /// by the action but may be "logically" owned by the action parameter). If
  79. /// alsoEraseOwnedObjects is true, the default implementation just calls
  80. /// detachDependenices(), otherwise it does nothing.
  81. /// </summary>
  82. /// <param name="alsoEraseOwnedObjects">
  83. /// If true is passed, the objects owned by this action parameter are erased.
  84. /// Otherwise they are just detached.
  85. /// </param>
  86. /// <returns> Acad::ErrorStatus. </returns>
  87. ///
  88. virtual Acad::ErrorStatus makeParamEmpty(bool alsoEraseOwnedObjects);
  89. /// <summary>
  90. /// If the parameter has some dependencies, it detaches and erases them,
  91. /// making the parameter not depend on any other object.
  92. /// </summary>
  93. /// <returns> Acad::ErrorStatus. </returns>
  94. ///
  95. virtual Acad::ErrorStatus detachDependencies();
  96. /// <summary>
  97. /// Similar to detachDependencies() but before detaching the dependencies,
  98. /// it may also make a backup copy of the current contents of the dependent-on
  99. /// entities and keep this backup copy as constant data. The default
  100. /// implementation just calls detachDependencies().
  101. /// </summary>
  102. /// <returns> Acad::ErrorStatus. </returns>
  103. ///
  104. virtual Acad::ErrorStatus makeParamConstant();
  105. /// <summary>
  106. /// Transforms any constant geometry kept in the action parameter, such as
  107. /// AcGeCurve3d* or AcGePoint3d.
  108. /// </summary>
  109. /// <param name="transform"> The transform to be applied to the constant geometry. </param>
  110. /// <returns> Acad::ErrorStatus. </returns>
  111. ///
  112. virtual Acad::ErrorStatus transformConstantGeometry(const AcGeMatrix3d& transform);
  113. /// <summary>
  114. /// Climbs up the action parameter ownership hierarchy (action parameters may
  115. /// be owned by other parameters, such as by AcDbAssocCompoundActionParam),
  116. /// up to the AcDbAssocAction.
  117. /// </summary>
  118. /// <returns>
  119. /// The AcDbAssocAction that owns (directly or indirectly) this action parameter.
  120. ///</returns>
  121. ///
  122. AcDbObjectId parentAction() const;
  123. /// <summary>
  124. /// Returns all dependencies that the action parameter references. These
  125. /// dependencies are "physically" owned by the action, but may be "logically"
  126. /// owned by action parameters that use them. For example, AcDbAssocEdgeActionParam
  127. /// may logically own an AcDbAssocGeomDependency or AcDbAssocDependency on
  128. /// the entity that provides the edge geometry.
  129. /// </summary>
  130. /// <param name="readDependenciesWanted"> Read-type dependencies wanted. </param>
  131. /// <param name="writeDependenciesWanted"> Write-type dependencies wanted. </param>
  132. /// <param name="dependencyIds"> Returned AcDbObjectIds of AcDbAssocDependencies. </param>
  133. /// <returns> Acad::ErrorStatus. </returns>
  134. ///
  135. virtual Acad::ErrorStatus getDependencies(bool readDependenciesWanted,
  136. bool writeDependenciesWanted,
  137. AcDbObjectIdArray& dependencyIds) const;
  138. /// <summary>
  139. /// Utility method that just calls getDependencies() on the action parameter and
  140. /// returns AcDbCompoundObjectIds these dependencies depend on. Notice that the
  141. /// returned array may contain the same AcDbCompoundObjectId multiply times,
  142. /// if several dependencies depend on it, and it may also contain null or invalid
  143. /// AcDbCompoundObjectIds.
  144. /// </summary>
  145. /// <param name="readDependenciesWanted"> Read-type dependencies wanted. </param>
  146. /// <param name="writeDependenciesWanted"> Write-type dependencies wanted. </param>
  147. /// <param name="dependencyIds"> Returned AcDbCompoundObjectIds the dependencies depend on. </param>
  148. /// <returns> Acad::ErrorStatus. </returns>
  149. ///
  150. Acad::ErrorStatus getCompoundObjectIds(bool readDependenciesWanted,
  151. bool writeDependenciesWanted,
  152. AcArray<AcDbCompoundObjectId>& compoundObjectIds) const;
  153. /// <summary>
  154. /// Returns the internal AcDbAssocStatus member data of the action parameter.
  155. /// If alsoCheckDependencies, it also considers the status of all the dependencies
  156. /// referred to by this action parameter and returns the most 'severe' status of
  157. /// all the statuses. Generally evaluation requests statuses are the most severe and
  158. /// kIsUpToDateAssoc it the least severe.
  159. /// </summary>
  160. ///
  161. AcDbAssocStatus status(bool alsoCheckDependencies) const;
  162. /// <summary><para>
  163. /// Sets the internal AcDbAssocStatus member data of the action parameter, including
  164. /// setting the same newStatus in action parameters owning this action parameter.
  165. /// At the end of an action evaluation, the AcDbAssocStatus of all action parameters
  166. /// owned by that action is reset to kIsUpToDateAssocStatus.
  167. /// </para><para>
  168. /// For the logic of setting various AcDbAssocStatus values, see the documentation
  169. /// of AcDbAssocDependency::setStatus() because this method exercises analogous logic.
  170. /// </para></summary>
  171. /// <param name="newStatus"> The new AcDbAssocStatus of the action parameter. </param>
  172. /// <param name="notifyParentAction">
  173. /// If true, isEvaluationRequest(newStatus), the status of the AcDbAssocAction owning
  174. /// this action parameter is set to the same status (unless the action evaluation status
  175. /// is already more severe than the new one). The action then notifies its owning network.
  176. /// </param>
  177. /// <param name="setInOwnedParams">
  178. /// Allows to set the same newStatus in all action parameters owned by this action parameter.
  179. /// </param>
  180. /// <returns> Acad::ErrorStatus. </returns>
  181. ///
  182. Acad::ErrorStatus setStatus(AcDbAssocStatus newStatus,
  183. bool notifyParentAction = true,
  184. bool setInOwnedParams = false);
  185. /// <summary><para>
  186. /// Called from AcDbAssocManager::auditAssociativeData() after file open and possibly
  187. /// after some other scenarios when the associative data may need to be audited and fixed-up.
  188. /// At this time custom code may also initialize internal chaches that were not saved to dwg/dxf
  189. /// file, or do some other work.
  190. /// </para><para>
  191. /// The action paramter may request the parent action to be erased by setting kErasedAssocStatus
  192. /// to parentActionHandling output argument. Setting kChangedDirectlyAssocStatus to
  193. /// parentActionHandling will make the parent action evaluate after the audit of all
  194. /// actions has been completed.
  195. /// </para><para>
  196. /// An example of possible and inevitable inconsistencies is when the drawing was modified
  197. /// in an AutoCAD release that didn't have code for the action, the action body was a proxy
  198. /// and therefore didn't react to notifications and didn't evaluate.
  199. /// </para><para>
  200. /// Another example of possible and inevitable ininconsistencies are references to objects
  201. /// that are not in the database any more because their owning objects were erased, the
  202. /// drawing was then saved, and these objects with erased owners were not saved to
  203. /// database. No notifications happen about the erase of these objects because they were
  204. /// not actually erased, so the actions cannot know that these objects are not in the database
  205. /// any more and may still hold AcDbObjectIds of these "lazily-erased" objects.
  206. /// </para><para>
  207. /// Before auditAssociativeData() is called on the action parameter, the system performs
  208. /// overall checks and fixes for cases like a dependency depending on a non-existent object,
  209. /// checks proper links between network, action, action body, action parameters, and
  210. /// dependencies, etc., so that these general checks do not need to be performed by
  211. /// the custom code.
  212. /// </para></summary>
  213. ///
  214. virtual void auditAssociativeData(AcDbAssocStatus& parentActionHandling);
  215. /// <summary>
  216. /// Using this method the action parameter reveals its AcDbStepIds and AcDbPersSubentIds
  217. /// to the AcDbAssocPersSubentManager.
  218. /// </summary>
  219. /// <param name="stepIds"> The array of returned AcDbPersStepIds. </param>
  220. /// <param name="persSubentIds"> The array of returned AcDbPersSubentIds. </param>
  221. /// <remarks> This method is currently for internal use only. </remarks>
  222. ///
  223. virtual void collectPersSubentNamingDataOverride(AcDbPersStepIdArray& stepIds,
  224. AcDbPersSubentIdArray& persSubentIds) const;
  225. /// <summary>
  226. /// Using this method the action parameter asks the AcDbAssocPersSubentManager
  227. /// to remap its AcDbPersStepIds and PersSubentIds after the action parameter
  228. /// has been cloned.
  229. /// </summary>
  230. /// <param name="pCloner">
  231. /// AcDbAssocPersSubentManagerCloner that the action parameter uses to remap
  232. /// its AcDbPersStepIds and PersSubentIds.
  233. /// </param>
  234. /// <remarks> This method is currently for internal use only. </remarks>
  235. ///
  236. virtual void clonePersSubentNamingDataOverride(AcDbAssocPersSubentManagerCloner* pCloner);
  237. };
  238. #pragma pack (pop)