dbdimassoc.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //
  12. // FILE: dimassoc.h
  13. //
  14. // DESCRIPTION: Declaration for Dimension Associativity API
  15. // and AcDbDimAssoc class.
  16. #ifndef AD_DBDIMASSOC_H
  17. #define AD_DBDIMASSOC_H
  18. #include "dbmain.h"
  19. class AcDb2LineAngularDimension;
  20. class AcDb3PointAngularDimension;
  21. class AcDbAlignedDimension;
  22. class AcDbArcDimension;
  23. class AcDbDiametricDimension;
  24. class AcDbLeader;
  25. class AcDbMLeader;
  26. class AcDbOrdinateDimension;
  27. class AcDbPointRef;
  28. class AcDbRadialDimension;
  29. class AcDbRadialDimensionLarge;
  30. class AcDbRotatedDimension;
  31. // Exported AcDbDimAssoc class and some global APIs for external use.
  32. // Class declaration for AcDbDimAssoc
  33. //
  34. class AcDbDimAssoc : public AcDbObject
  35. {
  36. public:
  37. ACDB_DECLARE_MEMBERS(AcDbDimAssoc);
  38. //ACRX_DECLARE_MEMBERS(AcDbDimAssoc);
  39. enum { kMaxPointRefs = 4 };
  40. enum PointType {
  41. kXline1Point = 0,
  42. kXline2Point = 1,
  43. kOriginPoint = 0,
  44. kDefiningPoint = 1,
  45. kXline1Start = 0,
  46. kXline1End = 1,
  47. kXline2Start = 2,
  48. kXline2End = 3,
  49. kVertexPoint = 2,
  50. kChordPoint = 0,
  51. kCenterPoint = 1,
  52. kFarChordPoint = 1,
  53. kOverrideCenterPoint = 2,
  54. kAngLineStart = 2,
  55. kJogPoint = 3,
  56. kAngLineEnd = 3,
  57. kLeaderPoint = 0
  58. };
  59. enum AssocFlags {
  60. kFirstPointRef = 1,
  61. kSecondPointRef = 2,
  62. kThirdPointRef = 4,
  63. kFourthPointRef = 8
  64. };
  65. enum RotatedDimType {
  66. kUnknown = 0,
  67. kParallel = 1,
  68. kPerpendicular = 2
  69. };
  70. AcDbDimAssoc();
  71. virtual ~AcDbDimAssoc();
  72. AcDbObjectId dimObjId() const;
  73. Acad::ErrorStatus setDimObjId(const AcDbObjectId& dimId);
  74. Acad::ErrorStatus setAssocFlag(int ptType, bool value);
  75. void setAssocFlag(int assocFlg);
  76. bool assocFlag(int ptType) const;
  77. int assocFlag(void);
  78. Acad::ErrorStatus setPointRef(int ptType, AcDbPointRef* ptRef);
  79. const AcDbPointRef *pointRef(int ptType) const;
  80. Acad::ErrorStatus setRotatedDimType(RotatedDimType dimType);
  81. RotatedDimType rotatedDimType() const;
  82. Acad::ErrorStatus addToPointRefReactor();
  83. Acad::ErrorStatus addToDimensionReactor(bool isAdd = true);
  84. Acad::ErrorStatus removePointRef(int ptType);
  85. Acad::ErrorStatus updateDimension(bool update = true, bool skipReactors = false);
  86. Acad::ErrorStatus removeAssociativity(bool force = true);
  87. bool isTransSpatial() const;
  88. Acad::ErrorStatus setTransSpatial(bool value);
  89. Acad::ErrorStatus startCmdWatcher();
  90. Acad::ErrorStatus startOopsWatcher(bool bAddAll = true);
  91. void removeOopsWatcher(void);
  92. Acad::ErrorStatus restoreAssocFromOopsWatcher(void);
  93. bool hasOopsWatcher(void) const;
  94. Acad::ErrorStatus post(AcDbObjectId dimId,
  95. AcDbObjectId& dimAssocId,
  96. bool isActive = true);
  97. Acad::ErrorStatus getDimAssocGeomIds(AcDbObjectIdArray& geomIds) const;
  98. bool isAllGeomErased() const;
  99. virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler*);
  100. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const;
  101. virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler*);
  102. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const;
  103. virtual void modifiedGraphics(const AcDbEntity* pObj);
  104. virtual Acad::ErrorStatus swapReferences (const AcDbIdMapping& idMap);
  105. Acad::ErrorStatus updateFillet(const AcDbObjectIdArray& ids);
  106. Acad::ErrorStatus updateAssociativity(const AcDbObjectIdArray& ids);
  107. Acad::ErrorStatus updateXrefSubentPath();
  108. Acad::ErrorStatus updateSubentPath(AcDbIdMapping& idMap);
  109. void updateDueToMirror(bool wasInMirror);
  110. protected:
  111. Acad::ErrorStatus setPointRefReactor (int ptType,
  112. bool isAdd = true);
  113. Acad::ErrorStatus removeDimExtDict (void);
  114. bool isPointBetweenRays (const AcGePoint3d& vertex,
  115. const AcGePoint3d& firstPt,
  116. const AcGePoint3d& secondPt,
  117. const AcGePoint3d& angPt,
  118. const AcGeVector3d& normal);
  119. Acad::ErrorStatus updateDimension (AcDbRotatedDimension* pRotDim,
  120. AcGePoint3d* pNewPts,
  121. bool bUpdate = true);
  122. Acad::ErrorStatus updateDimension (AcDbAlignedDimension* pAlnDim,
  123. AcGePoint3d* pNewPts,
  124. bool bUpdate = true);
  125. Acad::ErrorStatus updateDimension (AcDbRadialDimension* pRadDim,
  126. AcGePoint3d* pNewPts,
  127. bool bUpdate = true);
  128. Acad::ErrorStatus updateDimension (AcDbRadialDimensionLarge* pRadDimLarge,
  129. AcGePoint3d* pNewPts,
  130. bool bUpdate = true);
  131. Acad::ErrorStatus updateDimension (AcDbDiametricDimension* pDiaDim,
  132. AcGePoint3d* pNewPts,
  133. bool bUpdate = true);
  134. Acad::ErrorStatus updateDimension (AcDb2LineAngularDimension* pA2Dim,
  135. AcGePoint3d* pNewPts,
  136. bool bUpdate = true);
  137. Acad::ErrorStatus updateDimension (AcDb3PointAngularDimension* pA3Dim,
  138. AcGePoint3d* pNewPts,
  139. bool bUpdate = true);
  140. Acad::ErrorStatus updateDimension (AcDbOrdinateDimension* pOrdDim,
  141. AcGePoint3d* pNewPts,
  142. bool bUpdate = true);
  143. Acad::ErrorStatus updateDimension (AcDbArcDimension* pArcDim,
  144. AcGePoint3d* pNewPts,
  145. bool bUpdate = true);
  146. Acad::ErrorStatus updateDimension (AcDbLeader* pLeader,
  147. AcGePoint3d* pNewPts,
  148. bool bUpdate = true);
  149. Acad::ErrorStatus updateDimension (AcDbMLeader* pMLeader,
  150. AcGePoint3d* pNewPts,
  151. bool bUpdate = true);
  152. Acad::ErrorStatus updateDimLineAndTextLocation(AcDbRotatedDimension* pAlnDim,
  153. const AcGePoint3d* kpOldPts,
  154. const AcGePoint3d* kpNewPts);
  155. Acad::ErrorStatus updateDimLineAndTextLocation(AcDbAlignedDimension* pAlnDim,
  156. const AcGePoint3d* pOldPts,
  157. const AcGePoint3d* pNewPts);
  158. Acad::ErrorStatus updateDimLineAndTextLocation(AcDb2LineAngularDimension* pA2Dim,
  159. const AcGePoint3d* pOldPts,
  160. const AcGePoint3d* pNewPts);
  161. Acad::ErrorStatus updateDimLineAndTextLocation(AcDb3PointAngularDimension* pA3Dim,
  162. const AcGePoint3d* pOldPts,
  163. const AcGePoint3d* pNewPts);
  164. Acad::ErrorStatus updateDimLineAndTextLocation(AcDbArcDimension* pArcDim,
  165. const AcGePoint3d* kpOldPts,
  166. const AcGePoint3d* kpNewPts);
  167. Acad::ErrorStatus calculate3PointAngDimArcLocation(const AcGePoint3d* kpOldPts,
  168. const AcGePoint3d& kOldArcPt,
  169. const AcGePoint3d& kOldTextPt,
  170. const AcGePoint3d* kpNewPts,
  171. const AcGeVector3d& normal,
  172. AcGePoint3d& newArcPt,
  173. AcGePoint3d& newTextPt);
  174. Acad::ErrorStatus calculate2LineAngDimArcLocation(const AcGePoint3d* kpOldPts,
  175. const AcGePoint3d& kOldArcPt,
  176. const AcGePoint3d& kOldTextPt,
  177. const AcGePoint3d* kpNewPts,
  178. const AcGeVector3d& kNormal,
  179. AcGePoint3d& newArcPt,
  180. AcGePoint3d& newTextPt);
  181. };
  182. // Post pDimAssoc object to database in the extension
  183. // dictionary of the given dimension.
  184. //
  185. Acad::ErrorStatus
  186. acdbPostDimAssoc(AcDbObjectId dimId, AcDbDimAssoc* pDimAssoc,
  187. AcDbObjectId& dimAssocId, bool isActive = true);
  188. // Perform forced update for the given associative dimension.
  189. //
  190. Acad::ErrorStatus
  191. acdbUpdateDimension(AcDbObjectId dimId);
  192. // Perform forced update for the all dimensions in the database (DIMREGEN)
  193. //
  194. Acad::ErrorStatus
  195. acdbUpdateAllDimensions(AcDbDatabase* pDb);
  196. // Get the AcDbDimAssoc objectId from the given dimension.
  197. //
  198. Acad::ErrorStatus
  199. acdbGetDimAssocId(AcDbObjectId dimId, AcDbObjectId& dimAssocId);
  200. // Get the AcDbDimAssoc objectId from the geometry in
  201. // AcDbPointRef object.
  202. //
  203. Acad::ErrorStatus
  204. acdbGetDimAssocIds(AcDbObjectId entId, AcDbObjectIdArray& dimAssocIds);
  205. // Verify whether the given idPath is a trans-spatial path
  206. //
  207. bool
  208. acdbIsTransSpatial(const AcDbFullSubentPath& idPath);
  209. /// Get the object id of the annotation action body associated to
  210. /// idDim. Annotations include dimension, leader, and mleader. If
  211. /// such associativity does not exist, returns Acad::eNotApplicable.
  212. ///
  213. ACDB_PORT Acad::ErrorStatus
  214. acdbGetAssocAnnotationActionBody(const AcDbObjectId& idDim,
  215. AcDbObjectId& idActionBody
  216. );
  217. // Get all non-associative annotations in model space or paper space.
  218. // The annotations may include dimension, leader, mleader, and any custom
  219. // objects which have AcDbAnnoMonitorPE implemented.
  220. //
  221. ACDB_PORT Acad::ErrorStatus
  222. acdbGetNonAssocAnnotations(AcDbDatabase* pDb, bool isPaperSpace, AcDbObjectId& blockId,
  223. AcDbObjectIdArray& annoIds, bool ignoreOffOrFrozenLayers = false);
  224. // Check if the specified pEnt resides in a block or external reference.
  225. //
  226. ACDB_PORT bool
  227. acdbIsEntityInBlockOrXref(const AcDbEntity* pEnt);
  228. // Check if ANNOMONITOR sysvar is ON or OFF
  229. //
  230. ACDB_PORT bool
  231. acdbIsAnnoMonitorOn();
  232. // Check if associativity alert icon is disabled for the specified pEnt.
  233. // pEnt can be AbDbDimension, AcDbMLeader or AcDbLeader
  234. //
  235. ACDB_PORT bool
  236. acdbIsAssociativityAlertIconDisabled(AcDbEntity *pEnt);
  237. // Disable or enable the associativity alert icon for the specified pEnt.
  238. // pEnt can be AbDbDimension, AcDbMLeader or AcDbLeader
  239. //
  240. ACDB_PORT bool
  241. acdbDisableAssociativityAlertIcon(AcDbEntity *pEnt, bool disable);
  242. // Check if the specified pObj is associative or not. pObj can be
  243. // AcDbDimension, AcDbMLeader or AcDbLeader
  244. //
  245. ACDB_PORT bool
  246. acdbIsAssociativeAnnotation(AcDbObject* pObj, bool* pIsPartialAssoc = NULL);
  247. class AcDbAnnoAlertDisabler
  248. {
  249. public:
  250. ACDB_PORT AcDbAnnoAlertDisabler(const AcDbObjectId& objId);
  251. ACDB_PORT ~AcDbAnnoAlertDisabler();
  252. private:
  253. AcDbObjectId m_objId;
  254. };
  255. // Get the associativity override nValue for the specified pObj.
  256. // nValue = 0: non-associative
  257. // nValue = 1: associative
  258. //
  259. ACDB_PORT bool
  260. acdbGetAssociativityOverride(AcDbEntity *pEnt, int& nValue);
  261. // Set the associativity override for the specified pObj.
  262. // nValue = 0: non-associative
  263. // nValue = 1: associative
  264. // nValue = -1: clean up override xData and use default associativity
  265. //
  266. ACDB_PORT bool
  267. acdbSetAssociativityOverride(AcDbEntity *pEnt, int nValue);
  268. #endif // AD_DBDIMASSOC_H