dbDimData.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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. #ifndef AD_DBDIMDATA_H
  13. #define AD_DBDIMDATA_H
  14. #include "acdb.h"
  15. #include "acarray.h"
  16. #include "dbdim.h"
  17. class AcDbDimData;
  18. typedef AcArray<AcDbDimData*> AcDbDimDataPtrArray;
  19. typedef AcGeVector3d (*DimDataSetValueFuncPtr) (AcDbDimData* pThis,
  20. AcDbEntity* pEnt,
  21. double newValue,
  22. const AcGeVector3d& offset);
  23. // DimDataSetCustomStringFuncPtr is the callback function signature for AcDbDimData::setCustomStringFunc
  24. typedef AcGeVector3d (*DimDataSetCustomStringFuncPtr) (AcDbDimData* pThis,
  25. AcDbEntity* pEnt,
  26. const ACHAR* pCustomString,
  27. const AcGeVector3d& offset);
  28. class AcDbDimData
  29. {
  30. public:
  31. enum DimDataFlags {
  32. kDimEditable = 0x1,
  33. kDimInvisible = 0x2,
  34. kDimFocal = 0x4,
  35. kDimHideIfValueIsZero = 0x8,
  36. kDimEmptyData = 0x10, //For constraint-unlock support
  37. kDimResultantLength = 0x20,
  38. kDimDeltaLength = 0x40,
  39. kDimResultantAngle = 0x80,
  40. kDimDeltaAngle = 0x100,
  41. kDimRadius = 0x200,
  42. kDimCustomValue = 0x400,
  43. kDimConstrained = 0x800,
  44. kDimCustomString = 0x1000
  45. };
  46. AcDbDimData();
  47. AcDbDimData(AcDbDimension* pDim,
  48. DimDataSetValueFuncPtr setDimFunc = NULL,
  49. unsigned int bitFlags = 0,
  50. void* appData = NULL,
  51. DimDataSetCustomStringFuncPtr setCustomStringFunc = NULL);
  52. ~AcDbDimData();
  53. AcDbDimData(const AcDbDimData&);
  54. AcDbDimData& operator = (const AcDbDimData&);
  55. AcDbDimension* dimension() const;
  56. Acad::ErrorStatus setDimension(AcDbDimension* pDim);
  57. AcDbObjectId ownerId() const;
  58. Acad::ErrorStatus setOwnerId(const AcDbObjectId& objId);
  59. unsigned int bitFlags() const;
  60. Acad::ErrorStatus setBitFlags(unsigned int flags);
  61. bool isDimFocal() const;
  62. Acad::ErrorStatus setDimFocal(bool focal);
  63. bool isDimEditable() const;
  64. Acad::ErrorStatus setDimEditable(bool editable);
  65. bool isDimInvisible() const;
  66. Acad::ErrorStatus setDimInvisible(bool invisible);
  67. bool isDimHideIfValueIsZero() const;
  68. Acad::ErrorStatus setDimHideIfValueIsZero(bool hide);
  69. void *appData() const;
  70. Acad::ErrorStatus setAppData(void* appData);
  71. DimDataSetValueFuncPtr dimValueFunc() const;
  72. Acad::ErrorStatus setDimValueFunc(DimDataSetValueFuncPtr funcPtr);
  73. DimDataSetCustomStringFuncPtr customStringFunc() const;
  74. Acad::ErrorStatus setCustomStringFunc(DimDataSetCustomStringFuncPtr funcPtr);
  75. bool isDimResultantLength() const;
  76. Acad::ErrorStatus setDimResultantLength(bool bValue);
  77. bool isDimDeltaLength() const;
  78. Acad::ErrorStatus setDimDeltaLength(bool bValue);
  79. bool isDimResultantAngle() const;
  80. Acad::ErrorStatus setDimResultantAngle(bool bValue);
  81. bool isDimDeltaAngle() const;
  82. Acad::ErrorStatus setDimDeltaAngle(bool bValue);
  83. bool isDimRadius() const;
  84. Acad::ErrorStatus setDimRadius(bool bValue);
  85. bool isCustomDimValue() const;
  86. Acad::ErrorStatus setCustomDimValue(bool custom);
  87. bool isConstrained() const;
  88. Acad::ErrorStatus setConstrain(bool bValue);
  89. bool isCustomString() const;
  90. Acad::ErrorStatus setCustomString(bool bValue);
  91. private:
  92. AcDbDimension* mpDim;
  93. AcDbObjectId mOwnerId;
  94. unsigned int mBitFlags;
  95. DimDataSetValueFuncPtr mpSetDimValueFunc;
  96. void* mpAppData;
  97. DimDataSetCustomStringFuncPtr mpSetCustomStringFunc;
  98. };
  99. typedef AcArray<AcDbDimData> AcDbDimDataArray;
  100. inline AcDbDimData::AcDbDimData() :
  101. mpDim(NULL),
  102. mBitFlags(0),
  103. mpSetDimValueFunc(NULL),
  104. mpAppData (NULL),
  105. mpSetCustomStringFunc(NULL)
  106. {
  107. }
  108. inline AcDbDimData::AcDbDimData(AcDbDimension* pDim,
  109. DimDataSetValueFuncPtr setValueFunc,
  110. unsigned int bitFlags,
  111. void* appData,
  112. DimDataSetCustomStringFuncPtr setCustomStringFunc) :
  113. mpDim(pDim),
  114. mBitFlags(bitFlags),
  115. mpSetDimValueFunc(setValueFunc),
  116. mpAppData(appData),
  117. mpSetCustomStringFunc(setCustomStringFunc)
  118. {
  119. }
  120. inline AcDbDimData::AcDbDimData(const AcDbDimData& src)
  121. {
  122. *this = src;
  123. }
  124. inline AcDbDimData::~AcDbDimData()
  125. {
  126. if (mpDim)
  127. delete mpDim;
  128. }
  129. inline AcDbDimData& AcDbDimData::operator = (const AcDbDimData& src)
  130. {
  131. if (this == &src)
  132. return *this;
  133. mpDim = (AcDbDimension*)src.dimension()->clone();
  134. mOwnerId = src.ownerId();
  135. mpSetDimValueFunc = src.dimValueFunc();
  136. mpSetCustomStringFunc = src.customStringFunc();
  137. mBitFlags = src.bitFlags();
  138. mpAppData = src.appData();
  139. return *this;
  140. }
  141. inline AcDbDimension*
  142. AcDbDimData::dimension() const
  143. {
  144. return mpDim;
  145. }
  146. inline Acad::ErrorStatus
  147. AcDbDimData::setDimension(AcDbDimension* pDim)
  148. {
  149. mpDim = pDim;
  150. return Acad::eOk;
  151. }
  152. inline AcDbObjectId
  153. AcDbDimData::ownerId() const
  154. {
  155. return mOwnerId;
  156. }
  157. inline Acad::ErrorStatus
  158. AcDbDimData::setOwnerId(const AcDbObjectId& objId)
  159. {
  160. mOwnerId = objId;
  161. return Acad::eOk;
  162. }
  163. inline unsigned int
  164. AcDbDimData::bitFlags() const
  165. {
  166. return mBitFlags;
  167. }
  168. inline Acad::ErrorStatus
  169. AcDbDimData::setBitFlags(unsigned int flags)
  170. {
  171. mBitFlags = flags;
  172. return Acad::eOk;
  173. }
  174. inline bool
  175. AcDbDimData::isDimFocal() const
  176. {
  177. return !!(mBitFlags & kDimFocal);
  178. }
  179. inline Acad::ErrorStatus
  180. AcDbDimData::setDimFocal(bool focal)
  181. {
  182. if (focal)
  183. mBitFlags |= kDimFocal;
  184. else
  185. mBitFlags &= ~kDimFocal;
  186. return Acad::eOk;
  187. }
  188. inline bool
  189. AcDbDimData::isDimEditable() const
  190. {
  191. return !!(mBitFlags & kDimEditable);
  192. }
  193. inline Acad::ErrorStatus
  194. AcDbDimData::setDimEditable(bool editable)
  195. {
  196. if (editable)
  197. mBitFlags |= kDimEditable;
  198. else
  199. mBitFlags &= ~kDimEditable;
  200. return Acad::eOk;
  201. }
  202. inline bool
  203. AcDbDimData::isDimInvisible() const
  204. {
  205. return !!(mBitFlags & kDimInvisible);
  206. }
  207. inline Acad::ErrorStatus
  208. AcDbDimData::setDimInvisible(bool invisible)
  209. {
  210. if (invisible)
  211. mBitFlags |= kDimInvisible;
  212. else
  213. mBitFlags &= ~kDimInvisible;
  214. return Acad::eOk;
  215. }
  216. inline bool
  217. AcDbDimData::isDimHideIfValueIsZero() const
  218. {
  219. return !!(mBitFlags & kDimHideIfValueIsZero);
  220. }
  221. inline Acad::ErrorStatus
  222. AcDbDimData::setDimHideIfValueIsZero(bool hide)
  223. {
  224. if (hide)
  225. mBitFlags |= kDimHideIfValueIsZero;
  226. else
  227. mBitFlags &= ~kDimHideIfValueIsZero;
  228. return Acad::eOk;
  229. }
  230. inline bool
  231. AcDbDimData::isDimResultantLength() const
  232. {
  233. return !!(mBitFlags & kDimResultantLength);
  234. }
  235. inline Acad::ErrorStatus
  236. AcDbDimData::setDimResultantLength(bool bValue)
  237. {
  238. if (bValue)
  239. mBitFlags |= kDimResultantLength;
  240. else
  241. mBitFlags &= ~kDimResultantLength;
  242. return Acad::eOk;
  243. }
  244. inline bool
  245. AcDbDimData::isDimDeltaLength() const
  246. {
  247. return !!(mBitFlags & kDimDeltaLength);
  248. }
  249. inline Acad::ErrorStatus
  250. AcDbDimData::setDimDeltaLength(bool bValue)
  251. {
  252. if (bValue)
  253. mBitFlags |= kDimDeltaLength;
  254. else
  255. mBitFlags &= ~kDimDeltaLength;
  256. return Acad::eOk;
  257. }
  258. inline bool
  259. AcDbDimData::isDimResultantAngle() const
  260. {
  261. return !!(mBitFlags & kDimResultantAngle);
  262. }
  263. inline Acad::ErrorStatus
  264. AcDbDimData::setDimResultantAngle(bool bValue)
  265. {
  266. if (bValue)
  267. mBitFlags |= kDimResultantAngle;
  268. else
  269. mBitFlags &= ~kDimResultantAngle;
  270. return Acad::eOk;
  271. }
  272. inline bool
  273. AcDbDimData::isDimDeltaAngle() const
  274. {
  275. return !!(mBitFlags & kDimDeltaAngle);
  276. }
  277. inline Acad::ErrorStatus
  278. AcDbDimData::setDimDeltaAngle(bool bValue)
  279. {
  280. if (bValue)
  281. mBitFlags |= kDimDeltaAngle;
  282. else
  283. mBitFlags &= ~kDimDeltaAngle;
  284. return Acad::eOk;
  285. }
  286. inline bool
  287. AcDbDimData::isDimRadius() const
  288. {
  289. return !!(mBitFlags & kDimRadius);
  290. }
  291. inline Acad::ErrorStatus
  292. AcDbDimData::setDimRadius(bool bValue)
  293. {
  294. if (bValue)
  295. mBitFlags |= kDimRadius;
  296. else
  297. mBitFlags &= ~kDimRadius;
  298. return Acad::eOk;
  299. }
  300. inline bool
  301. AcDbDimData::isCustomDimValue() const
  302. {
  303. return !!(mBitFlags & kDimCustomValue);
  304. }
  305. inline Acad::ErrorStatus
  306. AcDbDimData::setCustomDimValue(bool custom)
  307. {
  308. if (custom)
  309. mBitFlags |= kDimCustomValue;
  310. else
  311. mBitFlags &= ~kDimCustomValue;
  312. return Acad::eOk;
  313. }
  314. inline bool
  315. AcDbDimData::isConstrained() const
  316. {
  317. return !!(mBitFlags & kDimConstrained);
  318. }
  319. inline Acad::ErrorStatus
  320. AcDbDimData::setConstrain(bool bValue)
  321. {
  322. if (bValue)
  323. mBitFlags |= kDimConstrained;
  324. else
  325. mBitFlags &= ~kDimConstrained;
  326. return Acad::eOk;
  327. }
  328. inline bool
  329. AcDbDimData::isCustomString() const
  330. {
  331. return !!(mBitFlags & kDimCustomString);
  332. }
  333. inline Acad::ErrorStatus
  334. AcDbDimData::setCustomString(bool bValue)
  335. {
  336. if (bValue)
  337. mBitFlags |= kDimCustomString;
  338. else
  339. mBitFlags &= ~kDimCustomString;
  340. return Acad::eOk;
  341. }
  342. inline void*
  343. AcDbDimData::appData() const
  344. {
  345. return mpAppData;
  346. }
  347. inline Acad::ErrorStatus
  348. AcDbDimData::setAppData(void* appData)
  349. {
  350. mpAppData = appData;
  351. return Acad::eOk;
  352. }
  353. inline DimDataSetValueFuncPtr
  354. AcDbDimData::dimValueFunc() const
  355. {
  356. return mpSetDimValueFunc;
  357. }
  358. inline Acad::ErrorStatus
  359. AcDbDimData::setDimValueFunc(DimDataSetValueFuncPtr funcPtr)
  360. {
  361. mpSetDimValueFunc = funcPtr;
  362. return Acad::eOk;
  363. }
  364. inline DimDataSetCustomStringFuncPtr
  365. AcDbDimData::customStringFunc() const
  366. {
  367. return mpSetCustomStringFunc;
  368. }
  369. inline Acad::ErrorStatus
  370. AcDbDimData::setCustomStringFunc(DimDataSetCustomStringFuncPtr funcPtr)
  371. {
  372. mpSetCustomStringFunc = funcPtr;
  373. return Acad::eOk;
  374. }
  375. #endif // AD_DBDIMDATA_H