drawable.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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 __DRAWABLE_H
  13. #define __DRAWABLE_H
  14. #include "rxobject.h"
  15. #include "rxoverrule.h"
  16. #include "dbid.h"
  17. #pragma pack (push, 8)
  18. class AcGiDrawableTraits;
  19. class AcGiWorldDraw;
  20. class AcGiViewportDraw;
  21. class AcGsNode;
  22. class AcDbSubentId;
  23. class AcDbExtents;
  24. class AcGiDrawStream;
  25. class ADESK_NO_VTABLE AcGiDrawable : public AcRxObject
  26. {
  27. public:
  28. ACRX_DECLARE_MEMBERS(AcGiDrawable);
  29. // Combine these flags in the return value
  30. // of setAttributes for efficiency of implementation
  31. // it is vital that if you use certain aspects of the
  32. // API that the correct flags be used. Otherwise the
  33. // display system may be incorrectly configured for
  34. // subsequent graphics. kIsCompoundObject gives
  35. // full access to the AcGi API, enabling the use
  36. // of draw() and the AcGi primitives together. Enabling
  37. // this makes the elaboration of an object marginally
  38. // slower. So you should use the lowest value appropriate.
  39. //
  40. //
  41. enum SetAttributesFlags
  42. {
  43. // Default drawable, just uses acgi primitives and does not use
  44. // nested calls to draw()
  45. kDrawableNone = 0,
  46. // AcDbEntity derived classes (may require some special processing)
  47. kDrawableIsAnEntity = 1,
  48. // (block table record) Uses nesting but does not send down additional
  49. // primitives. It uses draw() exclusively and makes no calls to the
  50. // other AcGi primitives such as circle or shell
  51. kDrawableUsesNesting = 2,
  52. // You MUST specify this value if you nest entities as a block does.
  53. kDrawableIsCompoundObject = 4,
  54. // Drawable specifies when viewportDraw will be called. Employ
  55. // per-Viewport caching of viewportDraw geometry. As well, this
  56. // drawable does not use worldDraw.
  57. kDrawableViewIndependentViewportDraw = 8,
  58. // If this entity is not visible (AcDbEntity::visibility())
  59. kDrawableIsInvisible = 16,
  60. // If a compound object has attributes it must specify this value
  61. kDrawableHasAttributes = 32,
  62. // If the geometry you elaborate is dependent on the regentype; for
  63. // instance, if your drawable draws itself as a set of polygons in a
  64. // "shaded" regen-mode but as a set of wires in "standard display",
  65. // specify this flag
  66. kDrawableRegenTypeDependentGeometry = 64,
  67. // Dimensions receive special handling, behaving similarly to blocks
  68. kDrawableIsDimension = (kDrawableIsAnEntity + kDrawableIsCompoundObject + 128),
  69. // Always regenerate drawable
  70. kDrawableRegenDraw = 256,
  71. // Drawable has single level of detail for regen type
  72. // kAcGiStandardDisplay
  73. kDrawableStandardDisplaySingleLOD = 512,
  74. // Drawable has single level of detail for regen type
  75. // kAcGiShadedDisplay
  76. kDrawableShadedDisplaySingleLOD = 1024,
  77. // Drawable requires viewportDraw be called on every view change.
  78. kDrawableViewDependentViewportDraw = 2048,
  79. // Drawable requires unique viewportDraw elaboration for each block path.
  80. kDrawableBlockDependentViewportDraw = 4096,
  81. // Drawable is an external reference
  82. kDrawableIsExternalReference = 8192,
  83. // Drawable will not be plotted
  84. kDrawableNotPlottable = 16384,
  85. // Drawable will never be drawn under the LCS mechanism
  86. kDrawableNotAllowLCS = 32768,
  87. // this is used for wipeout plotting to pdf.
  88. kDrawableMergeControlOff = 65536
  89. };
  90. // These are the Drawable types
  91. //
  92. enum DrawableType
  93. {
  94. kGeometry = 0,
  95. kDistantLight,
  96. kPointLight,
  97. kSpotLight,
  98. kAmbientLight,
  99. kSolidBackground,
  100. kGradientBackground,
  101. kImageBackground,
  102. kGroundPlaneBackground,
  103. kViewport,
  104. kWebLight,
  105. kSkyBackground,
  106. kImageBasedLightingBackground
  107. };
  108. #pragma warning(push)
  109. #pragma warning(disable: 4481)
  110. #pragma warning(disable: 4100) // unreferenced formal params in RolloverHit()
  111. ACDB_PORT AcGiDrawable();
  112. ACDB_PORT ~AcGiDrawable();
  113. // For default attributes
  114. ACDB_PORT ADESK_SEALED_VIRTUAL Adesk::UInt32 setAttributes (AcGiDrawableTraits * traits) ADESK_SEALED;
  115. // For geometry shared between multiple viewports
  116. ACDB_PORT ADESK_SEALED_VIRTUAL Adesk::Boolean worldDraw (AcGiWorldDraw * wd) ADESK_SEALED;
  117. // For viewport-specific geometry
  118. ACDB_PORT ADESK_SEALED_VIRTUAL void viewportDraw (AcGiViewportDraw * vd) ADESK_SEALED;
  119. // For ViewIndependentViewportDraw caching
  120. // return bitwise combination of SetAttributesFlags
  121. // for now, 3D GS only investigates kDrawableRegenTypeDependentGeometry
  122. ACDB_PORT ADESK_SEALED_VIRTUAL Adesk::UInt32 viewportDrawLogicalFlags (AcGiViewportDraw * vd) ADESK_SEALED;
  123. // Persistent/transient
  124. virtual Adesk::Boolean isPersistent (void) const = 0;
  125. virtual AcDbObjectId id (void) const = 0;
  126. // Drawable type.
  127. virtual DrawableType drawableType (void) const { return kGeometry; }
  128. // Graphics cache - deprecated
  129. ACDB_PORT ADESK_DEPRECATED virtual void setGsNode (AcGsNode * gsnode) ADESK_SEALED;
  130. ACDB_PORT ADESK_DEPRECATED virtual AcGsNode* gsNode (void) const ADESK_SEALED;
  131. // nMouseFlags are identical to the WM_MOUSEMOVE wParam windows message. See MSDN for those flags, they are provided as is.
  132. // reset is true if rollover is resetting or leaving your object.
  133. // return true if you want rollover to track your object, false to ignore it.
  134. virtual Adesk::Boolean RolloverHit (Adesk::ULongPtr /*nSubentId*/,
  135. Adesk::ULongPtr /*nMouseFlags*/,
  136. Adesk::Boolean /*bReset*/) { return Adesk::kFalse; }
  137. // Set the bounds of the drawable. Return false if the drawable has no
  138. // bounds, the bounds cannot be set, or the method is unimplemented.
  139. virtual bool bounds (AcDbExtents& /*bounds*/) const { return false; }
  140. // Draw stream
  141. ACDB_PORT virtual void setDrawStream (AcGiDrawStream * pStream);
  142. ACDB_PORT virtual AcGiDrawStream* drawStream (void) const;
  143. #pragma warning(pop)
  144. protected:
  145. friend class AcGiDrawableOverrule;
  146. virtual Adesk::UInt32 subSetAttributes (AcGiDrawableTraits * traits) = 0;
  147. virtual Adesk::Boolean subWorldDraw (AcGiWorldDraw * wd) = 0;
  148. virtual void subViewportDraw (AcGiViewportDraw * vd) = 0;
  149. virtual Adesk::UInt32 subViewportDrawLogicalFlags (AcGiViewportDraw * /*vd*/) { return 0; }
  150. private:
  151. friend class AcGiDrawableAccessory;
  152. class AcGiDrawableAccessory* m_pAccessory;
  153. };
  154. /// <property name="versionspecific" value="=18.0.0.0" />
  155. ///
  156. /// <description>
  157. /// AcGiDrawableOverrule overrules a subset of draw related
  158. /// operations that AcGiDrawable class specifies. It is intended
  159. /// as a base class for clients who want to alter some or all
  160. /// behavior of a given AcGiDrawable-derived class. At the base
  161. /// level, each default implementation simply calls the
  162. /// corresponding method in the target class.
  163. /// </description>
  164. class AcGiDrawableOverrule : public AcRxOverrule
  165. {
  166. public:
  167. ACRX_DECLARE_MEMBERS(AcGiDrawableOverrule);
  168. ACDB_PORT AcGiDrawableOverrule();
  169. /// <property name="versionspecific" value="=18.0.0.0" />
  170. ///
  171. /// <description>
  172. /// Overrules AcGiDrawable::setAttributes method.
  173. /// </description>
  174. /// <remarks>
  175. /// The default implementation of
  176. /// AcGiDrawableOverrule::setAttributes calls
  177. /// AcGiDrawable::subSetAttributes.
  178. /// </remarks>
  179. /// <param name="pSubject">Pointer to an AcRxObject that this
  180. /// overrule is applied against.</param>
  181. /// <param name="traits">Pointer to the graphics traits.</param>
  182. ACDB_PORT virtual Adesk::UInt32 setAttributes (AcGiDrawable* pSubject, AcGiDrawableTraits * traits);
  183. /// <property name="versionspecific" value="=18.0.0.0" />
  184. ///
  185. /// <description>
  186. /// Overrules AcGiDrawable::worldDraw.
  187. /// </description>
  188. /// <param name="pSubject">Pointer to an AcRxObject that this
  189. /// overrule is applied against.</param>
  190. /// <param name="wd">Pointer to the graphics traits.</param>
  191. /// <remarks>
  192. /// The default implementation of AcGiDrawableOverrule::worldDraw
  193. /// calls the protected virtual AcGiDrawable::subWorldDraw
  194. /// method.
  195. /// </remarks>
  196. ACDB_PORT virtual Adesk::Boolean worldDraw (AcGiDrawable* pSubject, AcGiWorldDraw * wd);
  197. /// <property name="versionspecific" value="=18.0.0.0" />
  198. ///
  199. /// <description>
  200. /// Overrules AcGiDrawable::viewportDraw method.
  201. /// </description>
  202. /// <remarks>
  203. /// Default implementation of AcGiDrawableOverrule::viewportDraw
  204. /// calls protected virtual AcGiDrawable::subViewportDraw method.
  205. ///
  206. /// </remarks>
  207. ACDB_PORT virtual void viewportDraw (AcGiDrawable* pSubject, AcGiViewportDraw * vd);
  208. /// <property name="versionspecific" value="=18.0.0.0" />
  209. ///
  210. /// <description>
  211. /// Overrules AcGiDrawable::viewportDrawLogicalFlags method.
  212. /// </description>
  213. /// <remarks>
  214. /// The default implementation of AcGiDrawableOverrule::
  215. /// viewportDrawLogicalFlags calls the protected virtual
  216. /// AcGiDrawable:: subViewportDrawLogicalFlags method.
  217. /// </remarks>
  218. ACDB_PORT virtual Adesk::UInt32 viewportDrawLogicalFlags (AcGiDrawable* pSubject, AcGiViewportDraw * vd);
  219. };
  220. /// <description>
  221. /// AcGiDrawableReactor provides notifications of key AcGiDrawable-
  222. /// related events including begin/end regen, modification, and
  223. /// erasure. Clients who derive from this class will receive these
  224. /// events after registering their reactor with AcGiDrawableEvent.
  225. /// </description>
  226. class ACDB_PORT AcGiDrawableReactor : public AcRxObject
  227. {
  228. public:
  229. ACRX_DECLARE_MEMBERS(AcGiDrawableReactor);
  230. enum RegenFlags
  231. {
  232. k2DRegen,
  233. k3DRegen
  234. };
  235. virtual void beginRegen (AcGiDrawable* /*pDrawable*/, RegenFlags /*flags*/) {}
  236. virtual void endRegen (AcGiDrawable* /*pDrawable*/, RegenFlags /*flags*/) {}
  237. virtual void modified (AcGiDrawable* /*pDrawable*/) {}
  238. virtual void erased (AcGiDrawable* /*pDrawable*/) {}
  239. virtual void handOverTo (AcGiDrawable* /*pFromDrawable*/, AcGiDrawable* /*pToDrawable*/) {}
  240. };
  241. /// <description>
  242. /// AcGiDrawableEvent manages a set of AcGiDrawableReactors and sends
  243. /// notifications to them when certain events occur. Access is through
  244. /// a singleton instance of this class, acgiDrawableEvent. Clients of
  245. /// AcGiDrawableEvent fall into three categories:
  246. ///
  247. /// 1. Any client interested in making use of AcGiDrawableReactor must
  248. /// add and remove their reactor through addReactor/removeReactor.
  249. ///
  250. /// 2. AcGiDrawable-derived clients may use this class to notify graphics
  251. /// systems of modifications and erasures of their graphics.
  252. ///
  253. /// 3. Graphics systems may use this class to notify interested listeners
  254. /// (e.g. AcGiDrawStream) of regen begin/end events.
  255. ///
  256. /// </description>
  257. #define acgiDrawableEvent (&AcGiDrawableEvent::instance())
  258. class AcGiDrawableEvent : public AcRxObject
  259. {
  260. public:
  261. ACRX_DECLARE_MEMBERS(AcGiDrawableEvent);
  262. ACDB_PORT static AcGiDrawableEvent& instance();
  263. virtual void addReactor (AcGiDrawableReactor* pReactor);
  264. virtual void removeReactor (AcGiDrawableReactor* pReactor);
  265. virtual void sendBeginRegen (AcGiDrawable* pDrawable, AcGiDrawableReactor::RegenFlags flags);
  266. virtual void sendEndRegen (AcGiDrawable* pDrawable, AcGiDrawableReactor::RegenFlags flags);
  267. virtual void sendModified (AcGiDrawable* pDrawable);
  268. virtual void sendErased (AcGiDrawable* pDrawable);
  269. virtual void sendHandOverTo (AcGiDrawable* pDrawableFrom, AcGiDrawable* pDrawableTo);
  270. private:
  271. AcGiDrawableEvent ();
  272. AcGiDrawableEvent (const AcGiDrawableEvent&);
  273. void operator= (const AcGiDrawableEvent&);
  274. ~AcGiDrawableEvent ();
  275. class AcGiImpDrawableEvent* m_pImp;
  276. };
  277. #pragma pack (pop)
  278. #endif // __DRAWABLE_H