AcGeomConstraint.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. #pragma once
  11. #include "AcConstraintGroupNode.h"
  12. #pragma pack (push, 8)
  13. // Forward class declarations.
  14. //
  15. class AcConstrainedGeometry;
  16. class AcHelpParameter;
  17. class AcEqualHelpParameterConstraint;
  18. class AcCompositeConstraint;
  19. /// <summary>
  20. /// This class represents a constraint node in the owning AcDbAssoc2dConstraintGroup.
  21. /// It is the base class for all the kind of constraints, including geometrical and
  22. /// dimensional constraints.
  23. /// </summary>
  24. ///
  25. class ACDB_PORT AcGeomConstraint : public AcConstraintGroupNode
  26. {
  27. public:
  28. ACRX_DECLARE_MEMBERS(AcGeomConstraint);
  29. /// <summary>
  30. /// The type of a geometrical constraint. It is mainly used to indicate the
  31. /// new constraint type to be added between geometries.
  32. /// </summary>
  33. ///
  34. enum GeomConstraintType
  35. {
  36. /// <summary>
  37. /// Horizontal constraint. Can be applied to a line or two points.
  38. /// </summary>
  39. ///
  40. kHorizontal = 0,
  41. /// <summary>
  42. /// Vertical constraint. Can be applied to a line or two points.
  43. /// </summary>
  44. ///
  45. kVertical ,
  46. /// <summary>
  47. /// Parallel constraint. Can be applied between two lines.
  48. /// </summary>
  49. ///
  50. kParallel ,
  51. /// <summary>
  52. /// Perpendicular constraint. Can be applied between two lines.
  53. /// </summary>
  54. ///
  55. kPerpendicular ,
  56. /// <summary>
  57. /// Normal constraint. Currently can only be applied between a line and circle(or arc).
  58. /// </summary>
  59. ///
  60. kNormal ,
  61. /// <summary>
  62. /// Colinear constraint. Can be applied between two lines.
  63. /// </summary>
  64. ///
  65. kColinear ,
  66. /// <summary>
  67. /// Coincident constraint. Can be applied between two points, a point and a curve.
  68. /// </summary>
  69. ///
  70. kCoincident ,
  71. /// <summary>
  72. /// Concentric constraint. Can be applied between any two of circles, ellipses, arcs or bounded ellipses.
  73. /// </summary>
  74. ///
  75. kConcentric ,
  76. /// <summary>
  77. /// Tangent constraint. Can be applied between two of curves (except two lines).
  78. /// This constraint is not applicable for closed splines; for bounded splines,
  79. /// the tangent point can only be the start or end point which is coincident with
  80. /// start or end point of the other bounded curve.
  81. /// </summary>
  82. ///
  83. kTangent ,
  84. /// <summary>
  85. /// EqualRadius constraint. Can be applied between any two of circles or arcs.
  86. /// </summary>
  87. ///
  88. kEqualRadius ,
  89. /// <summary>
  90. /// EqualLength constraint. Can be applied between two bounded lines (not rays).
  91. /// </summary>
  92. ///
  93. kEqualLength ,
  94. /// <summary>
  95. /// Symmetric constraint. Can be applied between two same type geometries.
  96. /// circle and arc are considered to be the same type of geometry.
  97. /// The symmetry axis is a line.
  98. /// </summary>
  99. ///
  100. kSymmetric ,
  101. /// <summary>
  102. /// G2Smooth constraint. Can be applied between a bounded spline and a bounded curve (including spline).
  103. /// </summary>
  104. ///
  105. kG2Smooth ,
  106. /// <summary>
  107. /// Fix constraint. Can be applied on any supported geometry.
  108. /// </summary>
  109. ///
  110. kFix
  111. };
  112. /// <summary>
  113. /// Returns the array of pointer to AcConstrainedGeometry objects which this constraint is connected to.
  114. /// </summary>
  115. /// <param name="apConsGeoms">
  116. /// The returned array of pointer to AcConstrainedGeometry.
  117. /// </param>
  118. /// <returns> Returns Acad::eOk if successful. </returns>
  119. ///
  120. virtual Acad::ErrorStatus getConnectedGeometries(AcArray<AcConstrainedGeometry*>& apConsGeoms) const;
  121. /// <summary><para>
  122. /// Returns the array of pointer to AcHelpParameter objects which this constraint is connected to.
  123. /// The number of the AcHelpParameter object is the same as the number of geometries involved
  124. /// in this constraint.
  125. /// </para><para>
  126. /// Only a few kind of constraints may have help parameters which are only applicable for
  127. /// splines and ellipses. For example, in case of Tangent constraint, a help parameter may be
  128. /// used to indicate the tangent point on a spline or ellipse.
  129. /// </para></summary>
  130. /// <param name="apHelpParameters">
  131. /// The returned array of pointer to AcHelpParameter objects.
  132. /// </param>
  133. /// <returns> Returns Acad::eOk if successful. </returns>
  134. ///
  135. virtual Acad::ErrorStatus getConnectedHelpParameters(AcArray<AcHelpParameter*>& apHelpParameters) const;
  136. /// <summary><para>
  137. /// Returns pointer to AcHelpParameter which this constraint and
  138. /// the specified constrained geometry both are connected to.
  139. /// </para><para>
  140. /// A AcHelpParameter object is always connected with a AcGeomConstraint object
  141. /// and a AcConstrainedGeometry object.
  142. /// </para></summary>
  143. /// <param name="pConsGeom">
  144. /// The pointer to AcConstrainedGeometry object.
  145. /// </param>
  146. /// <returns>
  147. /// Returns pointer to the connected AcHelpParameter object if successful,
  148. /// otherwise NULL is returned.
  149. /// </returns>
  150. ///
  151. virtual AcHelpParameter* getConnectedHelpParameterFor(const AcConstrainedGeometry* pConsGeom) const;
  152. /// <summary>
  153. /// Returns the pointer to the owning AcCompositeConstraint object if
  154. /// this constraint is owned by a composite constraint.
  155. /// </summary>
  156. /// <returns> Returns pointer to AcCompositeConstraint object. </returns>
  157. ///
  158. AcCompositeConstraint* getOwningCompositeConstraint() const;
  159. /// <summary> <para>
  160. /// Leaves the AcGeomConstraint node in the AcDbAssoc2dConstraintGroup but
  161. /// removes it from the DCM dimension system.
  162. /// </para><para>
  163. /// Currently only implemented for AcExplicitConstraint because we need to
  164. /// temporarily deactivate them during grip-point editing of dimensional
  165. /// constraint attachment grips.
  166. /// </para></summary>
  167. ///
  168. Acad::ErrorStatus deactivate();
  169. /// <summary><para>
  170. /// Takes an inactive AcGeomConstraint and adds it to the DCM dimension system.
  171. /// </para><para>
  172. /// Currently only implemented for AcExplicitConstraint because we need to
  173. /// temporarily deactivate them during grip-point editing of dimensional
  174. /// constraint attachment grips.
  175. /// </para></summary>
  176. ///
  177. Acad::ErrorStatus reactivate();
  178. /// <summary>
  179. /// Returns true iff the AcGeomConstraint is in DCM dimension system.
  180. /// </summary>
  181. ///
  182. bool isActive() const;
  183. /// <summary>
  184. /// Returns true iff the AcGeomConstraint is implied. This flag "implied"
  185. /// means the constraints are applied by the framework for implied geometric
  186. /// conditions, such as end point constraints for bounded curve. In polyline,
  187. /// if any geometric constrains are applied to the segment(s), there would be
  188. /// a few implied point-point or point-curve constraints added by the
  189. /// framework, these are implied constraints and the constraint UI
  190. /// (constraint bar/icon) should not show these constraints.
  191. /// </summary>
  192. /// <returns> True if it is implied; false if not. </returns>
  193. ///
  194. bool isImplied() const;
  195. /// <summary>
  196. /// Sets the isImplied() flag. This method is not intended for public use.
  197. /// </summary>
  198. /// <param name="yesNo"> True if it is to be made implied; false if not. </param>
  199. ///
  200. void setIsImplied(bool yesNo);
  201. /// <summary>
  202. /// Returns true iff the constraint is implied or is part of a composite constraint.
  203. /// Internal constraints should not be directly dealt with at client-code level.
  204. /// </summary>
  205. /// <returns> True if it is internal; false if not. </returns>
  206. ///
  207. bool isInternal() const;
  208. /// <summary>
  209. /// Returns true iff the constraint is enabled
  210. /// </summary>
  211. /// <returns> True if it is enabled; false if not. </returns>
  212. ///
  213. bool isEnabled() const;
  214. protected:
  215. /// <summary> Protected default constructor. </summary>
  216. ///
  217. AcGeomConstraint();
  218. };
  219. /// <summary><para>
  220. /// This class represents a help parameter node in the owning AcDbAssoc2dConstraintGroup.
  221. /// Help parameters are only applicable for splines and ellipses and are required for some
  222. /// kind of constraints.
  223. /// </para><para>
  224. /// A AcHelpParameter object is always connected with a AcGeomConstraint object and
  225. /// a AcConstrainedGeometry object.
  226. /// </para></summary>
  227. ///
  228. class ACDB_PORT AcHelpParameter : public AcConstraintGroupNode
  229. {
  230. public:
  231. ACRX_DECLARE_MEMBERS(AcHelpParameter);
  232. /// <summary> default constructor. </summary>
  233. ///
  234. AcHelpParameter(bool bCreateImp = true);
  235. /// <summary>
  236. /// Returns the pointer to AcConstrainedGeometry which this help parameter is connected to.
  237. /// </summary>
  238. /// <param name="pGeometry">
  239. /// The returned pointer to AcConstrainedGeometry.
  240. /// </param>
  241. /// <returns> Returns Acad::eOk if successful. </returns>
  242. ///
  243. Acad::ErrorStatus getConnectedGeometry(AcConstrainedGeometry*& pGeometry) const;
  244. /// <summary>
  245. /// Returns the pointer to AcGeomConstraint which this help parameter is connected to.
  246. /// This method does not take in account of equal parameter constraints applied on this help parameter
  247. /// </summary>
  248. /// <param name="pConstraint">
  249. /// The returned pointer to AcGeomConstraint.
  250. /// </param>
  251. /// <returns> Returns Acad::eOk if successful. </returns>
  252. ///
  253. Acad::ErrorStatus getConnectedConstraint(AcGeomConstraint*& pConstraint) const;
  254. /// <summary>
  255. /// Returns the array of pointer to AcEqualHelpParameterConstraint object which this constraint
  256. /// is connected to.
  257. /// </summary>
  258. /// <param name="apEqualParamConstrs">
  259. /// The returned array of pointer to AcEqualHelpParameterConstraint. If this help parameter
  260. /// is not involved in any equal help parameter constraint, the array returned is empty.
  261. /// </param>
  262. /// <returns> Returns Acad::eOk if successful. </returns>
  263. ///
  264. Acad::ErrorStatus getConnectedEqualparamConstraints(AcArray<AcEqualHelpParameterConstraint*>& apEqualParamConstrs) const;
  265. /// <summary>
  266. /// Returns the value of this help parameter, the value is always larger than or equal to 0.0
  267. /// </summary>
  268. /// <returns> Returns double parameter value. </returns>
  269. ///
  270. double getValue() const;
  271. };
  272. /// <summary>
  273. /// This class represents a composite constraint node in the owning AcDbAssoc2dConstraintGroup.
  274. /// It is the base class for all the kind of composite constraints, the owned constraints are
  275. /// all applied on(connected with) the same constrained geometries.
  276. /// </summary>
  277. ///
  278. class ACDB_PORT AcCompositeConstraint : public AcGeomConstraint
  279. {
  280. public:
  281. ACRX_DECLARE_MEMBERS(AcCompositeConstraint);
  282. /// <summary>
  283. /// Returns the array of pointer to AcGeomConstraint objects which are
  284. /// owned by this composite constraint.
  285. /// </summary>
  286. /// <param name="apSubConstraints">
  287. /// The returned array of pointer to AcGeomConstraint objects.
  288. /// </param>
  289. /// <returns> Returns Acad::eOk if successful. </returns>
  290. ///
  291. Acad::ErrorStatus getOwnedConstraints(AcArray<AcGeomConstraint*>& apSubConstraints) const;
  292. protected:
  293. /// <summary> Protected default constructor. </summary>
  294. ///
  295. AcCompositeConstraint(){}
  296. };
  297. #pragma pack (pop)