dbModelDocViewStyle.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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 __ACDBMODELDOCVIEWSTYLE_H__
  13. #define __ACDBMODELDOCVIEWSTYLE_H__
  14. #pragma once
  15. #include "acdbport.h"
  16. #include "dbmain.h"
  17. #include "dbmtext.h"
  18. #include "AcString.h"
  19. class AcDbImpModelDocViewStyle;
  20. class ACDB_PORT AcDbModelDocViewStyle : public AcDbObject
  21. {
  22. protected:
  23. /// <summary>
  24. /// Default constructor.
  25. /// </summary>
  26. ///
  27. /// <remarks>
  28. /// Default constructor is protected since AcDbModelDocViewStyle
  29. /// is abstract class. This constructor can be invoked only
  30. /// from constructor of derived class.
  31. /// </remarks>
  32. ///
  33. AcDbModelDocViewStyle();
  34. public:
  35. ACDB_DECLARE_MEMBERS(AcDbModelDocViewStyle);
  36. /// <summary>
  37. /// Enumeration defining attachment point for label
  38. /// </summary>
  39. enum AttachmentPoint {
  40. kAboveView = 0,
  41. kBelowView = 1,
  42. };
  43. /// <summary>
  44. /// Enumeration defining label text alignment
  45. /// </summary>
  46. enum TextAlignment {
  47. kTextAlignmentLeft = 0,
  48. kTextAlignmentCenter = 1,
  49. kTextAlignmentRight = 2,
  50. };
  51. /// <summary>
  52. /// Default destructor.
  53. /// </summary>
  54. ///
  55. /// <remarks>
  56. /// Default destructor.
  57. /// </remarks>
  58. ///
  59. virtual ~AcDbModelDocViewStyle() = 0;
  60. /// <summary>
  61. /// Get the name of AcDbModelDocViewStyle
  62. /// </summary>
  63. ///
  64. /// <param name="pszName">
  65. /// Output the name of AcDbModelDocViewStyle
  66. /// </param>
  67. ///
  68. /// <returns>
  69. /// Return Acae::eOk if Successful
  70. /// </returns>
  71. virtual Acad::ErrorStatus getName(ACHAR*& pszName) const;
  72. /// <summary>
  73. /// Get the name of AcDbModelDocViewStyle
  74. /// </summary>
  75. ///
  76. /// <param name="strName">
  77. /// Output the name of AcDbModelDocViewStyle
  78. /// </param>
  79. ///
  80. /// <returns>
  81. /// Return Acae::eOk if Successful
  82. /// </returns>
  83. virtual Acad::ErrorStatus getName(AcString& strName) const;
  84. /// <summary>
  85. /// Set the name of AcDbModelDocViewStyle
  86. /// </summary>
  87. ///
  88. /// <param name="pszName">
  89. /// Input the name of AcDbModelDocViewStyle
  90. /// </param>
  91. ///
  92. /// <returns>
  93. /// Return Acae::eOk if Successful
  94. /// </returns>
  95. virtual Acad::ErrorStatus setName(const ACHAR * pszName);
  96. /// <summary>
  97. /// Return the pointer to a string containing the description of this view style.
  98. /// </summary>
  99. ///
  100. /// <returns>
  101. /// Return the pointer to a string containing the description of this view style.
  102. /// </returns>
  103. virtual const ACHAR* description(void) const;
  104. /// <summary>
  105. /// Get the description of AcDbModelDocViewStyle
  106. /// </summary>
  107. ///
  108. /// <param name="strDescription">
  109. /// Output the description of AcDbModelDocViewStyle
  110. /// </param>
  111. virtual void getDescription(AcString& strDescription) const;
  112. /// <summary>
  113. /// Set the pointer to a string containing the description of this view style.
  114. /// </summary>
  115. ///
  116. /// <param name="pszDescription">
  117. /// Input the pointer to a string containing the description of this view style.
  118. /// </param>
  119. ///
  120. /// <returns>
  121. /// Return Acad::eOk if successful.
  122. /// </returns>
  123. virtual Acad::ErrorStatus setDescription(const ACHAR * pszDescription);
  124. /// <summary>
  125. /// This function sets the object properties to the default values
  126. /// of the database indicated by pDb. If pDb == NULL, then the
  127. /// current database in the AutoCAD editor is used.
  128. /// </summary>
  129. ///
  130. /// <param name="pDb">
  131. /// Input database whose defaults will be used to set the values
  132. /// of the entity
  133. /// </param>
  134. ///
  135. /// <returns>
  136. /// Return Acad::eOk if successful.
  137. /// </returns>
  138. void setDatabaseDefaults(AcDbDatabase* pDb);
  139. /// <summary>
  140. /// Add this object into database.
  141. /// </summary>
  142. ///
  143. /// <param name="pDb">
  144. /// Pointer of the database which will hold the style
  145. /// </param>
  146. /// <param name="styleName">
  147. /// Name of the view style
  148. /// </param>
  149. /// <param name="viewStyleId">
  150. /// Output the AcDbObjectId of this object posted into database
  151. /// </param>
  152. ///
  153. /// <returns>
  154. /// Return Acad::eOk if successful.
  155. /// </returns>
  156. Acad::ErrorStatus postViewStyleToDb (AcDbDatabase* pDb, const ACHAR* styleName, AcDbObjectId &viewStyleId);
  157. /// <summary>
  158. /// Indicate whether properties were changed.
  159. /// </summary>
  160. ///
  161. /// <returns>
  162. /// Return true if properties were changed; otherwise, returns false.
  163. /// </returns>
  164. bool isModifiedForRecompute() const;
  165. /// <summary>
  166. /// Returns default view name based on index for 1 it returns A, for 2 B, ...AA, AB, ....
  167. /// </summary>
  168. ///
  169. /// <param name="names">
  170. /// Returned available view names.
  171. /// </param>
  172. /// <param name="idx">
  173. /// Requested index of default name.
  174. /// </param>
  175. ///
  176. /// <returns>
  177. /// Return view name
  178. /// </returns>
  179. AcString defaultViewName(int index) const;
  180. /// <summary>
  181. /// Checks whether label name is valid.
  182. /// </summary>
  183. ///
  184. /// <param name="pName">
  185. /// Label name to check.
  186. /// </param>
  187. ///
  188. /// <returns>
  189. /// Return true if name is valid label string
  190. /// </returns>
  191. bool isViewNameValid(const ACHAR* pName) const;
  192. /// <summary>
  193. /// Calculate position of view label. This function receives bounding box
  194. /// of the view, attachment and offset and then calculate position of the text.
  195. /// </summary>
  196. ///
  197. /// <param name="offsetVector">Calculated offset vector.
  198. /// </param>
  199. /// <param name="textAlignment">text alignment to be set to view label.
  200. /// </param>
  201. /// <param name="attachment">Used attachment together with offset parameter
  202. /// defines position with respect to bounding box.
  203. /// </param>
  204. /// <param name="offset">Offset for view lable together with attachment parameter
  205. /// defines position with respect to bounding box.
  206. /// </param>
  207. /// <param name="minPt">Left lower corner of view's bounding box.
  208. /// </param>
  209. /// <param name="maxPt">Right upper corner of view's bounding box.
  210. /// </param>
  211. /// <returns>
  212. /// Offset position of view label defines relative position to alignment point
  213. /// on bounding box.
  214. /// </returns>
  215. static AcGePoint3d calculateViewLabelPosition (AcGeVector2d &offsetVector,
  216. AcDbMText::AttachmentPoint &textAlignment,
  217. AcDbModelDocViewStyle::AttachmentPoint attachment,
  218. double offset,
  219. const AcGePoint3d &minPt,
  220. const AcGePoint3d &maxPt);
  221. /// <summary>
  222. /// Set view label to initial position. This function receives bounding box
  223. /// of the view, attachment and offset and then calculate position of the text
  224. /// and sets the text to this position.
  225. /// </summary>
  226. ///
  227. /// <param name="pMText">Pointer to MText object to be positioned.
  228. /// </param>
  229. /// <param name="attachment">Used attachment together with offset parameter
  230. /// defines position with respect to bounding box.
  231. /// </param>
  232. /// <param name="offset">Offset for view lable together with attachment parameter
  233. /// defines position with respect to bounding box.
  234. /// </param>
  235. /// <param name="minPt">Left lower corner of view's bounding box.
  236. /// </param>
  237. /// <param name="maxPt">Right upper corner of view's bounding box.
  238. /// </param>
  239. /// <returns>
  240. /// Offset position of view label defines relative position to alignment point
  241. /// on bounding box.
  242. /// </returns>
  243. static AcGeVector2d setViewLabelPosition (AcDbMText *pMText,
  244. AcDbModelDocViewStyle::AttachmentPoint attachment,
  245. double offset,
  246. const AcGePoint3d &minPt,
  247. const AcGePoint3d &maxPt);
  248. /// <summary>
  249. /// Updates view label's position. This function receives bounding box
  250. /// of the view, attachment and offset and then calculate position of the text
  251. /// and sets the text to this position.
  252. /// </summary>
  253. ///
  254. /// <param name="pMText">Pointer to MText object to be positioned.
  255. /// </param>
  256. /// <param name="attachment">Used attachment together with offset parameter
  257. /// defines position with respect to bounding box.
  258. /// </param>
  259. /// <param name="offset">Offset for view lable together with attachment parameter
  260. /// defines position with respect to bounding box.
  261. /// </param>
  262. /// <param name="minPt">Left lower corner of view's bounding box.
  263. /// </param>
  264. /// <param name="maxPt">Right upper corner of view's bounding box.
  265. /// </param>
  266. /// <returns>
  267. /// Offset position of view label defines relative position to alignment point
  268. /// on bounding box.
  269. /// </returns>
  270. static AcGeVector2d updateViewLabelPosition(AcDbMText *pMText,
  271. AcDbModelDocViewStyle::AttachmentPoint &attachment,
  272. const AcGePoint3d &minPt,
  273. const AcGePoint3d &maxPt);
  274. protected:
  275. // For internal use only
  276. //
  277. virtual Acad::ErrorStatus subDeepClone(AcDbObject* pOwner, AcDbObject*& pClonedObject,
  278. AcDbIdMapping& idMap, Adesk::Boolean isPrimary = true) const;
  279. virtual Acad::ErrorStatus subWblockClone(AcRxObject* pOwner, AcDbObject*& pClonedObject,
  280. AcDbIdMapping& idMap, Adesk::Boolean isPrimary = true) const;
  281. private:
  282. friend class AcDbImpModelDocViewStyle;
  283. };
  284. #endif // __ACDBMODELDOCVIEWSTYLE_H__