dbvisualstyle.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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. #pragma once
  13. #include "dbmain.h"
  14. #include "acgi.h"
  15. #pragma pack (push, 8)
  16. // Legacy (shademode) styles
  17. const ACHAR kszVSFlat[] = /*MSG0*/ACRX_T("Flat");
  18. const ACHAR kszVSFlatWithEdges[] = /*MSG0*/ACRX_T("FlatWithEdges");
  19. const ACHAR kszVSGouraud[] = /*MSG0*/ACRX_T("Gouraud");
  20. const ACHAR kszVSGouraudWithEdges[] = /*MSG0*/ACRX_T("GouraudWithEdges");
  21. // Visual Styles
  22. const ACHAR kszVS2DWireframe[] = /*MSG0*/ACRX_T("2dWireframe");
  23. const ACHAR kszVS3DWireframe[] = /*MSG0*/ACRX_T("Wireframe");
  24. const ACHAR kszVSBasic[] = /*MSG0*/ACRX_T("Basic");
  25. const ACHAR kszVSHidden[] = /*MSG0*/ACRX_T("Hidden");
  26. const ACHAR kszVSRealistic[] = /*MSG0*/ACRX_T("Realistic");
  27. const ACHAR kszVSConceptual[] = /*MSG0*/ACRX_T("Conceptual");
  28. const ACHAR kszVSCustom[] = /*MSG0*/ACRX_T("Custom");
  29. const ACHAR kszVSShadesOfGray[] = /*MSG0*/ACRX_T("Shades of Gray");
  30. const ACHAR kszVSSketchy[] = /*MSG0*/ACRX_T("Sketchy");
  31. const ACHAR kszVSXRay[] = /*MSG0*/ACRX_T("X-Ray");
  32. //AirMax Visual Style
  33. const ACHAR kszVSShadedWithEdges[] = /*MSG0*/ACRX_T("Shaded with edges");
  34. const ACHAR kszVSShaded[] = /*MSG0*/ACRX_T("Shaded");
  35. // Highlight Visual Styles (internal use only)
  36. const ACHAR kszVSDim[] = /*MSG0*/ACRX_T("Dim");
  37. const ACHAR kszVSBrighten[] = /*MSG0*/ACRX_T("Brighten");
  38. const ACHAR kszVSThicken[] = /*MSG0*/ACRX_T("Thicken");
  39. const ACHAR kszVSTransparent[] = /*MSG0*/ACRX_T("Transparent");
  40. const ACHAR kszVSLinePattern[] = /*MSG0*/ACRX_T("Linepattern");
  41. const ACHAR kszVSFacePattern[] = /*MSG0*/ACRX_T("Facepattern");
  42. const ACHAR kszVSColorChange[] = /*MSG0*/ACRX_T("ColorChange");
  43. // Edge Style Override Visual Styles (internal use only)
  44. const ACHAR kszVSJitterOff[] = /*MSG0*/ACRX_T("JitterOff");
  45. const ACHAR kszVSOverhangOff[] = /*MSG0*/ACRX_T("OverhangOff");
  46. const ACHAR kszVSEdgeColorOff[] = /*MSG0*/ACRX_T("EdgeColorOff");
  47. ////////////////////////////////////////////////////////////////////////
  48. // class AcDbVisualStyle
  49. ////////////////////////////////////////////////////////////////////////
  50. /// <summary>
  51. /// This class describes the visual style database object, which contains
  52. /// a collection of properties that can be applied to faces, edges and the
  53. /// display.
  54. /// </summary>
  55. class AcDbVisualStyle : public AcDbObject
  56. {
  57. public:
  58. ACDB_DECLARE_MEMBERS(AcDbVisualStyle);
  59. /// <summary>
  60. /// Default constructor. Initializes members to reasonable default values.
  61. /// </summary>
  62. AcDbVisualStyle();
  63. /// <summary>
  64. /// Destructor. Performs any necessary cleanup of the visual style.
  65. /// </summary>
  66. virtual ~AcDbVisualStyle();
  67. /// <summary>
  68. /// Sets the visual style description
  69. /// </summary>
  70. /// <param name="pDescription">
  71. /// Input ACHAR* const pointer to the description of the visual style.
  72. /// </param>
  73. /// <returns>
  74. /// Returns Acad::ErrorStatus eOk.
  75. /// </returns>
  76. Acad::ErrorStatus setDescription (const ACHAR* pDescription);
  77. /// <summary>
  78. /// Reports the description of this visual style.
  79. /// </summary>
  80. /// <returns>
  81. /// Returns ACHAR* const pointer to the description of the visual style.
  82. /// </returns>
  83. const ACHAR* description (void) const;
  84. /// <summary>
  85. /// Sets the visual style type from the given AcGiVisualStyle::Type
  86. /// enumerator.
  87. /// </summary>
  88. /// <param name="type">
  89. /// Input ACHAR* const pointer to the type of the visual style.
  90. /// </param>
  91. /// <returns>
  92. /// Returns Acad::ErrorStatus eOk.
  93. /// </returns>
  94. Acad::ErrorStatus setType(AcGiVisualStyle::Type type);
  95. /// <summary>
  96. /// Reports the visual style type via the AcGiVisualStyle::Type
  97. /// enumerator.
  98. /// </summary>
  99. /// <returns>
  100. /// Returns AcGiVisualStyle::Type, the type of this visual style
  101. /// as a value from the AcGiVisualStyle::Type enumeration.
  102. /// </returns>
  103. AcGiVisualStyle::Type type() const;
  104. /// <summary>
  105. /// Sets a property of the visual style.
  106. /// </summary>
  107. /// <param name="prop">
  108. /// Input AcGiVisualStyleProperties::Property to set into the visual style.
  109. /// </param>
  110. /// <param name="pVal">
  111. /// Input AcGiVariant property value to set into the visual style.
  112. /// </param>
  113. /// <param name="op">
  114. /// Input AcGiVisualStyleOperations::Operation to use when setting the property into the visual style.
  115. /// </param>
  116. /// <returns>
  117. /// Returns Acad::eOk if successful; otherwise, returns Acad::eInvalidInput.
  118. /// </returns>
  119. /// <example>
  120. /// <example>
  121. ///
  122. /// // Set brightness to 1.0
  123. /// AcGiVariant displayBrightness.set(1.0);
  124. /// acdbVisualStyle.setTrait (AcGiVisualStyleProperties::kDisplayBrightness, displayBrightness);
  125. ///
  126. /// </example>
  127. Acad::ErrorStatus setTrait(AcGiVisualStyleProperties::Property prop,
  128. const AcGiVariant *pVal,
  129. AcGiVisualStyleOperations::Operation op
  130. = AcGiVisualStyleOperations::kSet);
  131. /// <summary>
  132. /// Sets an integer property of the visual style.
  133. /// </summary>
  134. /// <param name="prop">
  135. /// Input AcGiVisualStyleProperties::Property to set into the visual style. Valid
  136. /// Property values for this method are:
  137. //// kFaceLightingModel
  138. //// kFaceLightingQuality
  139. //// kFaceColorMode
  140. //// kFaceModifier
  141. //// kEdgeModel
  142. //// kEdgeStyle
  143. //// kEdgeObscuredLinePattern
  144. //// kEdgeIntersectionLinePattern
  145. //// kEdgeModifier
  146. //// kEdgeWidth
  147. //// kEdgeOverhang
  148. //// kEdgeJitter
  149. //// kEdgeSilhouetteWidth
  150. //// kEdgeHaloGap
  151. //// kEdgeIsolines
  152. //// kDisplayStyle
  153. //// kDisplayShadowType
  154. /// </param>
  155. /// <param name="nVal">
  156. /// Input integer property value to set into the visual style.
  157. /// </param>
  158. /// <param name="op">
  159. /// Input AcGiVisualStyleOperations::Operation to use when setting the property into the visual style.
  160. /// </param>
  161. /// <returns>
  162. /// Returns Acad::eOk if successful; otherwise, returns Acad::eInvalidInput.
  163. /// </returns>
  164. /// <example>
  165. ///
  166. /// // Set lighting model to kGooch
  167. /// using namespace AcGiVisualStyleProperties;
  168. /// acgiVisualStyle.setTrait (kFaceLightingModel, kGooch);
  169. ///
  170. /// // Set halogap to 20
  171. /// acdbVisualStyle.setTrait (AcGiVisualStyleProperties::kEdgeHaloGap, 20);
  172. ///
  173. /// </example>
  174. Acad::ErrorStatus setTrait(AcGiVisualStyleProperties::Property prop,
  175. int nVal,
  176. AcGiVisualStyleOperations::Operation op
  177. = AcGiVisualStyleOperations::kSet);
  178. /// <summary>
  179. /// Sets a boolean property of the visual style.
  180. /// </summary>
  181. /// <param name="prop">
  182. /// Input AcGiVisualStyleProperties::Property to set into the visual style. Valid
  183. /// Property values for this method are:
  184. //// kEdgeHidePrecision
  185. /// </param>
  186. /// <param name="bVal">
  187. /// Input boolean property value to set into the visual style.
  188. /// </param>
  189. /// <param name="op">
  190. /// Input AcGiVisualStyleOperations::Operation to use when setting the property into the visual style.
  191. /// </param>
  192. /// <returns>
  193. /// Returns Acad::eOk if successful; otherwise, returns Acad::eInvalidInput.
  194. /// </returns>
  195. /// <example>
  196. ///
  197. /// // Set hide precision to false
  198. /// acdbVisualStyle.setTrait (AcGiVisualStyleProperties::kEdgeHidePrecision, false);
  199. ///
  200. /// </example>
  201. Acad::ErrorStatus setTrait(AcGiVisualStyleProperties::Property prop,
  202. bool bVal,
  203. AcGiVisualStyleOperations::Operation op
  204. = AcGiVisualStyleOperations::kSet);
  205. /// <summary>
  206. /// Sets a double property of the visual style.
  207. /// </summary>
  208. /// <param name="prop">
  209. /// Input AcGiVisualStyleProperties::Property to set into the visual style. Valid
  210. /// Property values for this method are:
  211. //// kFaceOpacity
  212. //// kFaceSpecular
  213. //// kEdgeCreaseAngle
  214. //// kEdgeOpacity
  215. //// kDisplayBrightness
  216. /// </param>
  217. /// <param name="dVal">
  218. /// Input double property value to set into the visual style.
  219. /// </param>
  220. /// <param name="op">
  221. /// Input AcGiVisualStyleOperations::Operation to use when setting the property into the visual style.
  222. /// </param>
  223. /// <returns>
  224. /// Returns Acad::eOk if successful; otherwise, returns Acad::eInvalidInput.
  225. /// </returns>
  226. /// <example>
  227. ///
  228. /// // Set brightness to 1.0
  229. /// acdbVisualStyle.setTrait (AcGiVisualStyleProperties::kDisplayBrightness, 1.0);
  230. ///
  231. /// </example>
  232. Acad::ErrorStatus setTrait(AcGiVisualStyleProperties::Property prop,
  233. double dVal,
  234. AcGiVisualStyleOperations::Operation op
  235. = AcGiVisualStyleOperations::kSet);
  236. /// <summary>
  237. /// Sets a color property of the visual style.
  238. /// </summary>
  239. /// <param name="prop">
  240. /// Input AcGiVisualStyleProperties::Property to set into the visual style. Valid
  241. /// Property values for this method are:
  242. //// kFaceMonoColor
  243. //// kEdgeIntersectionColor
  244. //// kEdgeObscuredColor
  245. //// kEdgeColor
  246. //// kEdgeSilhouetteColor
  247. /// </param>
  248. /// <param name="red">
  249. /// Input red color value to set into the visual style. Valid value is from 0.0 to 1.0.
  250. /// </param>
  251. /// <param name="green">
  252. /// Input green color value to set into the visual style. Valid value is from 0.0 to 1.0.
  253. /// </param>
  254. /// <param name="blue">
  255. /// Input blue color value to set into the visual style. Valid value is from 0.0 to 1.0.
  256. /// </param>
  257. /// <param name="op">
  258. /// Input AcGiVisualStyleOperations::Operation to use when setting the property into the visual style.
  259. /// </param>
  260. /// <returns>
  261. /// Returns Acad::eOk if successful; otherwise, returns Acad::eInvalidInput.
  262. /// </returns>
  263. /// <example>
  264. ///
  265. /// // Set edge intersection color to 110% red
  266. /// acdbVisualStyle.setTrait (AcGiVisualStyleProperties::kEdgeIntersectionColor, 1.1, 1.0, 1.0);
  267. ///
  268. /// </example>
  269. Acad::ErrorStatus setTrait(AcGiVisualStyleProperties::Property prop,
  270. double red,
  271. double green,
  272. double blue,
  273. AcGiVisualStyleOperations::Operation op
  274. = AcGiVisualStyleOperations::kSet);
  275. /// <summary>
  276. /// Sets a color property of the visual style.
  277. /// </summary>
  278. /// <param name="prop">
  279. /// Input AcGiVisualStyleProperties::Property to set into the visual style. Valid
  280. /// Property values for this method are:
  281. //// kFaceMonoColor
  282. //// kEdgeIntersectionColor
  283. //// kEdgeObscuredColor
  284. //// kEdgeColor
  285. //// kEdgeSilhouetteColor
  286. /// </param>
  287. /// <param name="pColor">
  288. /// Input AcCmColor property value to set into the visual style.
  289. /// </param>
  290. /// <param name="op">
  291. /// Input AcGiVisualStyleOperations::Operation to use when setting the property into the visual style.
  292. /// </param>
  293. /// <returns>
  294. /// Returns Acad::eOk if successful; otherwise, returns Acad::eInvalidInput.
  295. /// </returns>
  296. /// <example>
  297. ///
  298. /// // Set monoColor to white
  299. /// AcCmColor monoColor;
  300. /// monoColor.setRGB(255,255,255);
  301. /// acdbVisualStyle.setTrait (AcGiVisualStyleProperties::kFaceMonoColor, &monoColor);
  302. ///
  303. /// </example>
  304. Acad::ErrorStatus setTrait(AcGiVisualStyleProperties::Property prop,
  305. const AcCmColor *pColor,
  306. AcGiVisualStyleOperations::Operation op
  307. = AcGiVisualStyleOperations::kSet);
  308. /// <summary>
  309. /// Gets a property of the visual style.
  310. /// </summary>
  311. /// <param name="prop">
  312. /// Input AcGiVisualStyleProperties::Property to get from the visual style.
  313. /// </param>
  314. /// <param name="pOp">
  315. /// Output AcGiVisualStyleOperations::Operation to get the operation currently in effect for this property. If NULL, nothing is returned.
  316. /// </param>
  317. /// <returns>
  318. /// Returns the AcGiVariant value of the property if successful; otherwise,
  319. /// returns an AcGiVariant of type AcGiVariant::kUndefined.
  320. /// </returns>
  321. /// <example>
  322. ///
  323. /// AcGiVariant displayBrightness =
  324. /// acgiVisualStyle.trait (AcGiVisualStyleProperties::kDisplayBrightness);
  325. ///
  326. /// </example>
  327. const AcGiVariant& trait(AcGiVisualStyleProperties::Property prop,
  328. AcGiVisualStyleOperations::Operation *pOp = NULL) const;
  329. /// <summary>
  330. /// Sets a property flag into the visual style, for properties which are bitfield enums.
  331. /// </summary>
  332. /// <param name="flagProp">
  333. /// Input bitfield enum AcGiVisualStyleProperties::Property to set into the visual style.
  334. /// </param>
  335. /// <param name="flagVal">
  336. /// Input bit flag enum unsigned long property to set into the visual style.
  337. /// </param>
  338. /// <param name="bEnable">
  339. /// Input bool set to true to enable the flag, false to disable.
  340. /// </param>
  341. /// <returns>
  342. /// Returns Acad::eOk if successful; otherwise, returns Acad::eInvalidInput.
  343. /// </returns>
  344. /// <example>
  345. ///
  346. /// acgiVisualStyle.setTraitFlag (AcGiVisualStyleProperties::kEdgeModifier,
  347. /// AcGiVisualStyle::kJitter,
  348. /// true);
  349. ///
  350. /// </example>
  351. Acad::ErrorStatus setTraitFlag(AcGiVisualStyleProperties::Property flagProp,
  352. Adesk::UInt32 flagVal,
  353. bool bEnable = true);
  354. /// <summary>
  355. /// Gets a property flag from the visual style, for properties which are bitfield enums.
  356. /// </summary>
  357. /// <param name="flagProp">
  358. /// Input bitfield enum AcGiVisualStyleProperties::Property to get from the visual style.
  359. /// </param>
  360. /// <param name="flagVal">
  361. /// Input bit flag enum unsigned long property to get from the visual style.
  362. /// </param>
  363. /// <returns>
  364. /// Returns true if flag is enabled, false otherwise.
  365. /// </returns>
  366. /// <example>
  367. ///
  368. /// bool bJitterEnabled =
  369. /// acgiVisualStyle.traitFlag(AcGiVisualStyleProperties::kEdgeModifier,
  370. /// AcGiVisualStyle::kJitter);
  371. ///
  372. /// </example>
  373. bool traitFlag(AcGiVisualStyleProperties::Property flagProp,
  374. Adesk::UInt32 flagVal) const;
  375. // AcDbObject protocol
  376. //
  377. /// <summary>
  378. /// Files in the visual style properties from a .dwg format file.
  379. /// </summary>
  380. /// <param name="pFiler">
  381. /// Input AcDbDwgFiler* pointer to the .dwg file filer.
  382. /// </param>
  383. /// <returns>
  384. /// Returns Acad::ErrorStatus value of Acad::eOk if successful,
  385. /// otherwise an error status return indicating type of failure.
  386. /// </returns>
  387. virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler* pFiler);
  388. /// <summary>
  389. /// Files out the visual style properties to a .dwg format file.
  390. /// </summary>
  391. /// <param name="pFiler">
  392. /// Input AcDbDwgFiler* pointer to the .dwg file filer.
  393. /// </param>
  394. /// <returns>
  395. /// Returns Acad::ErrorStatus value of Acad::eOk if successful,
  396. /// otherwise an error status return indicating type of failure.
  397. /// </returns>
  398. virtual Acad::ErrorStatus dwgOutFields (AcDbDwgFiler* pFiler) const;
  399. /// <summary>
  400. /// Files in the visual style properties from a .dxf format file.
  401. /// </summary>
  402. /// <param name="pFiler">
  403. /// Input AcDbDxfFiler* pointer to the .dxf file filer.
  404. /// </param>
  405. /// <returns>
  406. /// Returns Acad::ErrorStatus value of Acad::eOk if successful,
  407. /// otherwise an error status return indicating type of failure.
  408. /// </returns>
  409. virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler* pFiler);
  410. /// <summary>
  411. /// Files out the visual style properties to a .dxf format file.
  412. /// </summary>
  413. /// <param name="pFiler">
  414. /// Input AcDbDxfFiler* pointer to the .dxf file filer.
  415. /// </param>
  416. /// <returns>
  417. /// Returns Acad::ErrorStatus value of Acad::eOk if successful,
  418. /// otherwise an error status return indicating type of failure.
  419. /// </returns>
  420. virtual Acad::ErrorStatus dxfOutFields (AcDbDxfFiler* pFiler) const;
  421. // AcGiDrawable protocol
  422. //
  423. /// <summary>
  424. /// Returns a pointer to this visual style object.
  425. /// </summary>
  426. /// <returns>
  427. /// Returns AcGiDrawable* pointer to this object.
  428. /// </returns>
  429. virtual AcGiDrawable* drawable (void);
  430. /// <summary>
  431. /// Reports whether this visual style is for internal use only
  432. /// </summary>
  433. /// <returns>
  434. /// Returns boolean indicating whether this visual style is for
  435. /// internal use only and will not be exposed in any UI.
  436. /// </returns>
  437. virtual bool isInternalUseOnly() const;
  438. /// <summary>
  439. /// Sets a flag indicating that this visual style is for internal use
  440. /// only and will not be exposed in any UI.
  441. /// </summary>
  442. /// <param name="bInternalUseOnly">
  443. /// Input boolean indicating this visual style is for internal use only.
  444. /// </param>
  445. virtual void setInternalUseOnly(bool bInternalUseOnly);
  446. // Utility functions to map between AcDbVisualStyle and AcGiVisualStyle
  447. /// <summary>
  448. /// Copies this visual style to the given destination visual style.
  449. /// </summary>
  450. /// <param name="pDest">
  451. /// Input AcGiVisualStyle* pointer to the desination visual style.
  452. /// </param>
  453. /// <returns>
  454. /// Returns Acad::ErrorStatus Acad::eOk for success, otherwise an error
  455. /// return value Acad::eInvalidInput if the parameter passed is null.
  456. /// </returns>
  457. virtual Acad::ErrorStatus copyTo(AcGiVisualStyle * pDest) const;
  458. /// <summary>
  459. /// Copies the given visual style to this visual style.
  460. /// </summary>
  461. /// <param name="pSrc">
  462. /// Input AcGiVisualStyle* pointer to the visual style to copy from.
  463. /// </param>
  464. /// <returns>
  465. /// Returns Acad::ErrorStatus Acad::eOk for success, otherwise an error
  466. /// return value Acad::eInvalidInput if the parameter passed is null.
  467. /// </returns>
  468. virtual Acad::ErrorStatus copyFrom(const AcGiVisualStyle * pSrc);
  469. /// <summary>
  470. /// Prepares the visual style for saving to previous AutoCAD versions.
  471. /// </summary>
  472. /// <param name="ver">
  473. /// Drawing version to which the visual style is being saved.
  474. /// </param>
  475. /// <param name="replaceObj">
  476. ///
  477. /// </param>
  478. /// <param name="replaceId">
  479. ///
  480. /// </param>
  481. /// <param name="exchangeXData">
  482. ///
  483. /// </param>
  484. /// <returns>
  485. /// Returns Acad::ErrorStatus Acad::eOk for success, otherwise an error
  486. /// return value.
  487. /// </returns>
  488. virtual Acad::ErrorStatus decomposeForSave(
  489. AcDb::AcDbDwgVersion ver,
  490. AcDbObject*& replaceObj,
  491. AcDbObjectId& replaceId,
  492. Adesk::Boolean& exchangeXData);
  493. ACDB_PORT Acad::ErrorStatus name(AcString &value) const;
  494. protected:
  495. };
  496. #pragma pack (pop)