gs.h 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  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 "AcArray.h"
  14. #include "AdAChar.h"
  15. #include "gept3dar.h"
  16. #include "dbid.h"
  17. #include "AcString.h"
  18. #include "acgi.h"
  19. // ****************************************************************************
  20. // Forward declarations
  21. // ****************************************************************************
  22. class AcGeMatrix3d;
  23. class AcGePoint3d;
  24. class AcGeVector3d;
  25. class AcGePoint2d;
  26. class AcGsModel;
  27. class AcGsDevice;
  28. class AcGsGraphicsKernel;
  29. class AcGiVisualStyle;
  30. class AcGiContextualColors;
  31. class AcGiContextualAttributes;
  32. struct AcGsClientViewInfo;
  33. class AcGsRenderInterrupter;
  34. namespace Atil
  35. {
  36. class Image;
  37. };
  38. // ****************************************************************************
  39. // Helper classes
  40. // ****************************************************************************
  41. namespace GS
  42. {
  43. // Error Codes
  44. enum ErrorStatus {
  45. kSuccess,
  46. kOutOfRange,
  47. kInvalidInput
  48. };
  49. enum DeviceType {
  50. kScreenDevice = 0,
  51. kOffScreenDevice = 1,
  52. kSelectionDevice = 2
  53. };
  54. enum HighlightStyle {
  55. kHighlightDashed = 0,
  56. kHighlightThicken = 1,
  57. kHighlightDashedAndThicken = 2,
  58. kHighlightCustom = 3,
  59. kHighlightDim = 4,
  60. kHighlightThickDim = 5,
  61. kHighlightGlow = 6
  62. };
  63. /// Sync behavior - defining if the request runs synchronously
  64. enum SyncBehavior
  65. {
  66. eSync = 0, /// The request runs synchronously
  67. eAsync = 1, /// The request runs asynchronously
  68. };
  69. /// Image Properties - For screenshots, thumbnails...etc generated through Gs
  70. enum ImageOrientation
  71. {
  72. kTopDown = 0, //ATIL TopDownLeftRight
  73. kBottomUp = 1 //ATIL BottomUpLeftRight
  74. };
  75. enum ImageDataFormat
  76. {
  77. kRGBA = 0,
  78. kBGRA = 1
  79. };
  80. };
  81. // copied (with modification) from limits.h to avoid extra #includes
  82. #define SCALAR_MIN (-2147483647 - 1) // minimum (signed) int value
  83. #define SCALAR_MAX 2147483647 // maximum (signed) int value
  84. #pragma pack (push, 8)
  85. class AcGsDCPoint
  86. {
  87. public:
  88. enum MaxFlag { Maximum };
  89. enum MinFlag { Minimum };
  90. AcGsDCPoint (void) { }
  91. AcGsDCPoint (long xin, long yin) : x (xin), y (yin) { }
  92. AcGsDCPoint (MaxFlag) { x = SCALAR_MAX; y = SCALAR_MAX; }
  93. AcGsDCPoint (MinFlag) { x = SCALAR_MIN; y = SCALAR_MIN; }
  94. void operator= (MaxFlag) { x = SCALAR_MAX; y = SCALAR_MAX; }
  95. void operator= (MinFlag) { x = SCALAR_MIN; y = SCALAR_MIN; }
  96. void operator= (AcGsDCPoint const & r) { x = r.x; y = r.y; }
  97. bool operator== (AcGsDCPoint const & r) const { return x == r.x && y == r.y; }
  98. bool operator!= (AcGsDCPoint const & r) const { return x != r.x || y != r.y; }
  99. long x;
  100. long y;
  101. };
  102. class AcGsDCRect
  103. {
  104. public:
  105. enum NullFlag { Null };
  106. AcGsDCRect (void) { }
  107. AcGsDCRect (AcGsDCPoint const & min, AcGsDCPoint const & max)
  108. : m_min (min)
  109. , m_max (max) { }
  110. AcGsDCRect (long l, long r, long b, long t)
  111. : m_min (l,b)
  112. , m_max (r,t) { }
  113. AcGsDCRect (NullFlag) { set_null(); }
  114. AcGsDCRect & operator= (AcGsDCRect const & other) {
  115. m_min = other.m_min;
  116. m_max = other.m_max;
  117. return *this;
  118. }
  119. void operator|= (AcGsDCRect const & rightside) {
  120. if (m_min.x > rightside.m_min.x)
  121. m_min.x = rightside.m_min.x;
  122. if (m_max.x < rightside.m_max.x)
  123. m_max.x = rightside.m_max.x;
  124. if (m_min.y > rightside.m_min.y)
  125. m_min.y = rightside.m_min.y;
  126. if (m_max.y < rightside.m_max.y)
  127. m_max.y = rightside.m_max.y;
  128. }
  129. void operator&= (AcGsDCRect const & rightside) {
  130. if (m_min.x < rightside.m_min.x)
  131. m_min.x = rightside.m_min.x;
  132. if (m_max.x > rightside.m_max.x)
  133. m_max.x = rightside.m_max.x;
  134. if (m_min.y < rightside.m_min.y)
  135. m_min.y = rightside.m_min.y;
  136. if (m_max.y > rightside.m_max.y)
  137. m_max.y = rightside.m_max.y;
  138. if (m_min.x > m_max.x || m_min.y > m_max.y)
  139. *this = Null;
  140. }
  141. bool operator== (AcGsDCRect const & rightside) const {
  142. return m_min == rightside.m_min &&
  143. m_max == rightside.m_max;
  144. }
  145. bool operator!= (AcGsDCRect const & rightside) const {
  146. return !(*this == rightside);
  147. }
  148. void set_null (void) {
  149. m_min = AcGsDCPoint::Maximum;
  150. m_max = AcGsDCPoint::Minimum;
  151. }
  152. bool is_null (void) const {// should be either valid or properly null
  153. #ifdef ASSERT
  154. ASSERT ((m_min.x <= m_max.x && m_min.y <= m_max.y) ||
  155. (m_min == AcGsDCPoint::Maximum && m_max == AcGsDCPoint::Minimum));
  156. #endif
  157. return m_min.x > m_max.x;
  158. }
  159. bool within (AcGsDCRect const & rightside) const {
  160. #ifdef ASSERT
  161. ASSERT (!is_null()); // (if *this is Null and rightside is not, does not work.
  162. #endif
  163. return m_min.x >= rightside.m_min.x && // if *this is non-Null and right is Null, works.
  164. m_min.y >= rightside.m_min.y && // if both are Null, does not work.)
  165. m_max.x <= rightside.m_max.x &&
  166. m_max.y <= rightside.m_max.y;
  167. }
  168. AcGsDCPoint m_min;
  169. AcGsDCPoint m_max;
  170. };
  171. struct AcGsColor
  172. {
  173. unsigned char m_red; // unicode safe
  174. unsigned char m_green;
  175. unsigned char m_blue;
  176. unsigned char m_filler;
  177. };
  178. typedef void *AcGsWindowingSystemID; // i.e. -- HWND
  179. typedef void *AcGsWindowId; // Alias for AcGsWindowingSystemID
  180. // ****************************************************************************
  181. // AcGsNode
  182. // ****************************************************************************
  183. class AcGsNode
  184. {
  185. public:
  186. virtual ~AcGsNode() { }
  187. virtual AcGiDrawable *drawable (void) const = 0;
  188. };
  189. // ****************************************************************************
  190. // AcGsView
  191. // ****************************************************************************
  192. class AcGsView
  193. {
  194. public:
  195. enum Projection
  196. {
  197. kParallel,
  198. kPerspective
  199. };
  200. enum SelectionMode
  201. {
  202. kWindow,
  203. kCrossing,
  204. kFence,
  205. kWPoly,
  206. kCPoly,
  207. };
  208. enum DefaultLightingType
  209. {
  210. kOneLight,
  211. kTwoLights,
  212. kBackLight
  213. };
  214. enum ModelCloneOption
  215. {
  216. kCloneNoModels,
  217. kCloneMainPersistentModel,
  218. kCloneAllModels
  219. };
  220. virtual ~AcGsView (void) { }
  221. // Who created this AcGsView?
  222. virtual AcGsGraphicsKernel &graphicsKernel(void) = 0;
  223. // Viewport size & position in normalized device coords and screen coords
  224. //
  225. virtual void setViewport (const AcGePoint2d & lowerLeft,
  226. const AcGePoint2d & upperRight) = 0;
  227. virtual void setViewport (const AcGsDCRect & screen_rect) = 0;
  228. virtual void getViewport ( AcGePoint2d & lowerLeft,
  229. AcGePoint2d & upperRight) const = 0;
  230. virtual void getViewport ( AcGsDCRect & screen_rect) const = 0;
  231. // Non-Rectangular Viewports
  232. //
  233. virtual void setViewportClipRegion (int contours,
  234. int const * counts,
  235. AcGsDCPoint const * points) = 0;
  236. virtual void removeViewportClipRegion (void) = 0;
  237. // Viewport Borders
  238. //
  239. virtual void setViewportBorderProperties (AcGsColor const & color,
  240. int weight) = 0;
  241. virtual void getViewportBorderProperties (AcGsColor & color,
  242. int & weight) const = 0;
  243. virtual void setViewportBorderVisibility (bool bVisible) = 0;
  244. virtual bool isViewportBorderVisible (void) const = 0;
  245. // View transformation
  246. //
  247. virtual void setView (const AcGePoint3d & position,
  248. const AcGePoint3d & target,
  249. const AcGeVector3d& upVector,
  250. double fieldWidth,
  251. double fieldHeight,
  252. Projection projection = kParallel) = 0;
  253. virtual AcGePoint3d position (void) const = 0;
  254. virtual AcGePoint3d target (void) const = 0;
  255. virtual AcGeVector3d upVector (void) const = 0;
  256. virtual bool isPerspective (void) const = 0;
  257. virtual double fieldWidth (void) const = 0;
  258. virtual double fieldHeight (void) const = 0;
  259. // Clip Planes
  260. //
  261. virtual void setEnableFrontClip (bool enable) = 0;
  262. virtual bool isFrontClipped (void) const = 0;
  263. virtual void setFrontClip (double distance) = 0;
  264. virtual double frontClip (void) const = 0;
  265. virtual void setEnableBackClip (bool enable) = 0;
  266. virtual bool isBackClipped (void) const = 0;
  267. virtual void setBackClip (double distance) = 0;
  268. virtual double backClip (void) const = 0;
  269. // Matrix
  270. //
  271. virtual AcGeMatrix3d viewingMatrix (void) const = 0;
  272. virtual AcGeMatrix3d projectionMatrix (void) const = 0;
  273. virtual AcGeMatrix3d screenMatrix (void) const = 0;
  274. virtual AcGeMatrix3d worldToDeviceMatrix (void) const = 0;
  275. virtual AcGeMatrix3d objectToDeviceMatrix(void) const = 0;
  276. // Drawables
  277. //
  278. virtual bool add (AcGiDrawable * drawable,
  279. AcGsModel * model) = 0;
  280. virtual bool erase (AcGiDrawable * drawable) = 0;
  281. virtual void eraseAll (void) = 0;
  282. // Validation
  283. //
  284. virtual void invalidate (void) = 0;
  285. virtual void invalidate (const AcGsDCRect &rect)= 0;
  286. virtual bool isValid (void) const = 0;
  287. // Updates
  288. //
  289. virtual void update (void) = 0;
  290. virtual void beginInteractivity (double fFrameRateInHz) = 0;
  291. virtual void endInteractivity (void) = 0;
  292. virtual bool isInteractive (void) const = 0;
  293. virtual void flush (void) = 0;
  294. // Degradation
  295. //
  296. virtual void setMaximumUpgrade (int step) = 0;
  297. virtual int maximumUpgrade (void) = 0;
  298. virtual void setMinimumDegrade (int step) = 0;
  299. virtual int minimumDegrade (void) = 0;
  300. // Visibility
  301. //
  302. virtual void hide (void) = 0;
  303. virtual void show (void) = 0;
  304. virtual bool isVisible (void) = 0;
  305. // Viewport visibility of layers
  306. //
  307. virtual void freezeLayer (LONG_PTR layerID) = 0;
  308. virtual void thawLayer (LONG_PTR layerID) = 0;
  309. virtual void clearFrozenLayers (void) = 0;
  310. // Logical View Control
  311. //
  312. virtual void invalidateCachedViewportGeometry (void) = 0;
  313. // For client-friendly view manipulation
  314. //
  315. virtual void dolly (const AcGeVector3d & vector) = 0;
  316. virtual void dolly (double x, double y, double z) = 0;
  317. virtual void roll (double angle) = 0;
  318. virtual void orbit (double x, double y) = 0;
  319. virtual void zoom (double factor) = 0;
  320. virtual void zoomExtents (const AcGePoint3d& minPoint,
  321. const AcGePoint3d& maxPoint) = 0;
  322. virtual void zoomWindow (const AcGePoint2d& lowerLeft,
  323. const AcGePoint2d& upperRight) = 0;
  324. virtual void pan (double x, double y) = 0;
  325. virtual bool pointInView (const AcGePoint3d& pnt) = 0;
  326. virtual bool extentsInView (const AcGePoint3d& minPoint,
  327. const AcGePoint3d& maxPoint) = 0;
  328. virtual AcGsView * clone (bool bCloneViewParameters = true,
  329. bool bCloneGeometry = false) = 0;
  330. // Viewing limits
  331. //
  332. virtual bool exceededBounds (void) = 0;
  333. // Stereo
  334. //
  335. virtual void enableStereo (bool bEnable) = 0;
  336. virtual bool isStereoEnabled (void) const = 0;
  337. virtual void setStereoParameters (double magnitude,
  338. double parallax) = 0;
  339. virtual void getStereoParameters (double & magnitude,
  340. double & parallax) const = 0;
  341. // Off-screen Rendering
  342. //
  343. virtual void getSnapShot (Atil::Image * pOutput,
  344. AcGsDCPoint const & offset) = 0;
  345. virtual bool renderToImage (Atil::Image* pOutput,
  346. AcGiDrawable* pSettings,
  347. void* pProgressMonitor,
  348. const AcGsDCRect & rectScreen,
  349. bool bReuseScene = false) = 0;
  350. // Device mapping
  351. virtual AcGsDevice * getDevice(void) const = 0;
  352. // Visual Style
  353. virtual void setVisualStyle (const AcDbObjectId visualStyleId) = 0;
  354. virtual AcDbObjectId visualStyle (void) const = 0;
  355. virtual void setVisualStyle (const AcGiVisualStyle &visualStyle) = 0;
  356. virtual bool visualStyle (AcGiVisualStyle &visualStyle) const = 0;
  357. // Background
  358. virtual void setBackground (const AcDbObjectId backgroundId) = 0;
  359. virtual AcDbObjectId background (void) const = 0;
  360. // Default lighting
  361. virtual void enableDefaultLighting (bool bEnable,
  362. DefaultLightingType type = kTwoLights) = 0;
  363. virtual void getNumPixelsInUnitSquare(const AcGePoint3d& givenWorldpt, // Pixel information.
  364. AcGePoint2d& pixelArea,
  365. bool includePerspective = true) const = 0;
  366. // GS Model
  367. virtual AcGsModel* getModel (AcGiDrawable*) const = 0;
  368. virtual void getModelList (AcArray<AcGsModel*>&) const = 0;
  369. virtual const AcGsClientViewInfo& getClientViewInfo() const = 0;
  370. // ************************************************************************
  371. // GSN additions
  372. // ************************************************************************
  373. virtual void update (GS::SyncBehavior sync) = 0;
  374. virtual bool isPointInViewport (const Adesk::Int32 x, const Adesk::Int32 y) = 0;
  375. virtual AcGsView * clone (bool bCloneViewParameters,
  376. ModelCloneOption cloneOption) = 0;
  377. virtual Atil::Image * createSnapshot (const AcGsDCPoint& offset,
  378. const AcGsDCRect& imageDim,
  379. GS::ImageDataFormat format,
  380. GS::ImageOrientation orientation,
  381. bool bOnlyCaptureRenderedImage = false) = 0;
  382. // Deprecated -- use renderToImage() instead.
  383. ADESK_DEPRECATED virtual bool RenderToImage (Atil::Image* pOutput,
  384. AcGiDrawable* pSettings,
  385. void* pProgressMonitor,
  386. const AcGsDCRect & rectScreen,
  387. bool bReuseScene = false) = 0;
  388. enum EnableIRResult
  389. {
  390. kSuccess,
  391. kOutOfMemory
  392. };
  393. virtual EnableIRResult beginInteractiveRender (void* pProgressMonitor) = 0;
  394. virtual void endInteractiveRender (void) = 0;
  395. virtual bool isRendering (void) const = 0;
  396. // Fast inteactivity status:
  397. // trace some inteactivity behavior triggered by middle mouse zoom/pan with high frequency.
  398. virtual void beginFastInteractivity (void) = 0;
  399. virtual bool endFastInteractivity (void) = 0;// return if need update screen
  400. virtual bool isFastInteractivity (void) = 0;
  401. };
  402. // ****************************************************************************
  403. // AcGsView2
  404. // ****************************************************************************
  405. class AcGsView2 : public AcGsView
  406. {
  407. public:
  408. virtual void invalidateCachedViewportGeometry(AcGiDrawable* pDrawable) = 0;
  409. };
  410. // ****************************************************************************
  411. // AcGsModel
  412. // ****************************************************************************
  413. class AcGsModel
  414. {
  415. public:
  416. enum RenderType
  417. {
  418. kMain, // Use main Z-buffer
  419. kSprite, // Use alternate Z-buffer, for sprites
  420. kDirect, // Render into frame buffer without the z-test
  421. kHighlight, // Render directly onto the device (skipping the frame buffer and the z-test)
  422. kHighlightSelection,// Render directly onto the device in selection highlight style (internal only)
  423. kDirectTopmost, // Render above all other render types except contrast, and render without the z-test
  424. kContrast, // Render directly onto the device in contrast style, for transients
  425. kCount // Count of RenderTypes
  426. };
  427. enum InvalidationHint
  428. {
  429. kInvalidateNone,
  430. kInvalidateIsolines,
  431. kInvalidateViewportCache,
  432. kInvalidateAll,
  433. kInvalidateAllStatic,
  434. kInvalidateFacets,
  435. kInvalidateFills,
  436. kInvalidateLinetypes,
  437. kInvalidateMaterials,
  438. kInvalidateLayers,
  439. kInvalidateXrefs,
  440. kInvalidateRasterImages,
  441. kInvalidateAttributes,
  442. kInvalidateUnderlayFrame,
  443. kInvalidateLtScale,
  444. kInvalidateTransform,
  445. kInvalidateTransparencies,
  446. kInvalidateDrawableByView
  447. };
  448. enum OrderActionType
  449. {
  450. kMoveBelow,
  451. kMoveAbove,
  452. kSwapOrder,
  453. };
  454. virtual ~AcGsModel (void) { }
  455. // Who created this AcGsModel?
  456. virtual AcGsGraphicsKernel &graphicsKernel(void) = 0;
  457. // Scene graph roots
  458. //
  459. virtual bool addSceneGraphRoot (AcGiDrawable * pRoot) = 0;
  460. virtual bool eraseSceneGraphRoot (AcGiDrawable * pRoot) = 0;
  461. // Change notification
  462. //
  463. virtual void onAdded (AcGiDrawable * pAdded,
  464. AcGiDrawable * pParent) = 0;
  465. virtual void onAdded (AcGiDrawable * pAdded,
  466. LONG_PTR parentID) = 0;
  467. virtual void onModified (AcGiDrawable * pModified,
  468. AcGiDrawable * pParent) = 0;
  469. virtual void onModified (AcGiDrawable * pModified,
  470. LONG_PTR parentID) = 0;
  471. virtual void onErased (AcGiDrawable * pErased,
  472. AcGiDrawable * pParent) = 0;
  473. virtual void onErased (AcGiDrawable * pErased,
  474. LONG_PTR parentID) = 0;
  475. virtual void onPaletteModified (void) = 0;
  476. // Transformations
  477. //
  478. virtual void setTransform (const AcGeMatrix3d &) = 0;
  479. virtual AcGeMatrix3d transform (void) const = 0;
  480. virtual void setExtents (const AcGePoint3d &,
  481. const AcGePoint3d &) = 0;
  482. // Invalidation notification
  483. //
  484. virtual void invalidate (InvalidationHint hint) = 0;
  485. // View overrides
  486. //
  487. virtual void setViewClippingOverride (bool bOverride) = 0;
  488. // Visual style
  489. //
  490. virtual void setVisualStyle (const AcDbObjectId visualStyleId) = 0;
  491. virtual AcDbObjectId visualStyle (void) const = 0;
  492. virtual void setVisualStyle (const AcGiVisualStyle &visualStyle) = 0;
  493. virtual bool visualStyle (AcGiVisualStyle &visualStyle) const = 0;
  494. // Background
  495. virtual void setBackground (const AcDbObjectId backgroundId) = 0;
  496. virtual AcDbObjectId background (void) const = 0;
  497. // Linetypes
  498. //
  499. virtual void enableLinetypes (bool bEnable) = 0;
  500. virtual bool linetypesEnabled (void) const = 0;
  501. // Sectioning
  502. //
  503. virtual void setEnableSectioning (bool enable) = 0;
  504. virtual bool isSectioningEnabled (void) const = 0;
  505. virtual bool setSectioning (const AcGePoint3dArray & pts,
  506. const AcGeVector3d & upVector) = 0;
  507. virtual bool setSectioning (const AcGePoint3dArray & pts,
  508. const AcGeVector3d & upVector,
  509. double top,
  510. double bottom) = 0;
  511. virtual void setSectioningVisualStyle (const AcDbObjectId visualStyleId) = 0;
  512. // Render Type
  513. //
  514. virtual RenderType renderType (void) = 0;
  515. // Shadowing
  516. //
  517. virtual double shadowPlaneLocation (void) const = 0;
  518. virtual void setShadowPlaneLocation (double planeLocationZ) = 0;
  519. // Selection
  520. //
  521. virtual void setSelectable (bool bEnable) = 0;
  522. virtual bool selectable (void) const = 0;
  523. // ************************************************************************
  524. // GSN additions
  525. // ************************************************************************
  526. // Draw Order
  527. //
  528. virtual void setDrawOrder (AcGiDrawable* pDrawable,
  529. AcGiDrawable* pRelativeDrawable,
  530. AcGiDrawable* pParent,
  531. OrderActionType action) = 0;
  532. // Bounds
  533. //
  534. virtual bool bounds (const AcGiDrawable& drawable,
  535. AcGePoint3d& minPt,
  536. AcGePoint3d& maxPt) = 0;
  537. virtual void onModified (AcGiDrawable * pModified,
  538. AcGiDrawable * pParent,
  539. InvalidationHint hint) = 0;
  540. virtual void onModified (AcGiDrawable * pModified,
  541. LONG_PTR parentID,
  542. InvalidationHint hint) = 0;
  543. };
  544. // ****************************************************************************
  545. // AcGsModel2
  546. // ****************************************************************************
  547. class AcGsModel2 : public AcGsModel
  548. {
  549. public:
  550. /// <description>
  551. /// Sets the unit scaling in meters per unit. This conversion scale is necessary for
  552. /// any physical-based properties such as photometric lighting or real-world materials.
  553. /// </description>
  554. virtual void setUnitScale(double metersPerUnit) = 0;
  555. /// <description>
  556. /// Returns the unit scaling in meters per unit. This conversion scale is necessary for
  557. /// any physical-based properties such as photometric lighting or real-world materials.
  558. /// </description>
  559. virtual double unitScale(void) const = 0;
  560. /// <description>
  561. /// Enables/disables photometric lighting.
  562. /// </description>
  563. virtual void setLightingPhotometric(bool bPhotometric) = 0;
  564. /// <description>
  565. /// Returns true if photometric lighting is enabled.
  566. /// </description>
  567. virtual bool isLightingPhotometric(void) const = 0;
  568. /// <description>
  569. /// Enables/disables lights in blocks.
  570. /// </description>
  571. virtual void setLightsInBlocksEnabled(bool bEnabled) = 0;
  572. /// <description>
  573. /// Returns true if lights in blocks are enabled.
  574. /// </description>
  575. virtual bool lightsInBlocksEnabled(void) const = 0;
  576. };
  577. // ****************************************************************************
  578. // AcGsDevice
  579. // ****************************************************************************
  580. class AcGsDevice
  581. {
  582. public:
  583. enum RendererType
  584. {
  585. kDefault,
  586. kSoftware,
  587. kSoftwareNewViewsOnly,
  588. kFullRender,
  589. kSelectionRender,
  590. kFbxExportRender
  591. };
  592. virtual ~AcGsDevice (void) { }
  593. // Who created this AcGsDevice?
  594. virtual AcGsGraphicsKernel &graphicsKernel(void) = 0;
  595. // Validation
  596. //
  597. virtual void invalidate (void) = 0;
  598. virtual void invalidate (const AcGsDCRect &rect)= 0;
  599. virtual bool isValid (void) const = 0;
  600. // Updates
  601. //
  602. // Pass in a rectangle to know which region on the device was updated by the GS
  603. virtual void update (AcGsDCRect *pUpdatedRect = nullptr) = 0;
  604. // Change notification
  605. //
  606. virtual void onSize (int width, int height) = 0;
  607. virtual void onRealizeForegroundPalette (void) = 0;
  608. virtual void onRealizeBackgroundPalette (void) = 0;
  609. virtual void onDisplayChange (int nBitsPerPixel,
  610. int nXRes,
  611. int nYRes) = 0;
  612. // View connections
  613. //
  614. virtual bool add (AcGsView * view) = 0;
  615. virtual bool erase (AcGsView * view) = 0;
  616. virtual void eraseAll (void) = 0;
  617. virtual bool setBackgroundColor (AcGsColor color) = 0;
  618. virtual AcGsColor getBackgroundColor (void) = 0;
  619. virtual void setLogicalPalette (const AcGsColor * palette,
  620. int nCount) = 0;
  621. virtual void setPhysicalPalette (const AcGsColor * palette,
  622. int nCount) = 0;
  623. // Off-screen Rendering
  624. virtual void getSnapShot (Atil::Image * pOutput,
  625. AcGsDCPoint const & offset) = 0;
  626. // Device Renderer type
  627. virtual void setDeviceRenderer (RendererType type) = 0;
  628. virtual RendererType getDeviceRenderer (void) = 0;
  629. // Interruptible traversal
  630. virtual void setRenderInterrupter(AcGsRenderInterrupter* pInterrupter) = 0;
  631. virtual AcGsRenderInterrupter* getRenderInterrupter(void) const = 0;
  632. virtual void setDisplayUpdateSuppressed(bool bSuppressed) = 0;
  633. // *************************************************************************
  634. // GSN additions
  635. // *************************************************************************
  636. virtual void invalidate (AcGsModel::RenderType pane) = 0;
  637. virtual void invalidate (const AcGsDCRect &rect,
  638. AcGsModel::RenderType pane) = 0;
  639. virtual void update (AcGsDCRect* pUpdatedRect, GS::SyncBehavior sync) = 0;
  640. virtual Atil::Image * createSnapshot (const AcGsDCPoint& offset,
  641. const AcGsDCRect& imageDim,
  642. GS::ImageDataFormat format,
  643. GS::ImageOrientation orientation) = 0;
  644. // Maximum device size
  645. virtual int getMaxDeviceWidth (void) = 0;
  646. virtual int getMaxDeviceHeight (void) = 0;
  647. // ************************************************************************
  648. // Below functions are for RapidRT Rendering.
  649. //
  650. //
  651. // Below four functions are device-related, should only exposed on GsDevice level.
  652. //
  653. virtual void setDesiredFrameRate (float frameRate) = 0;
  654. virtual void pauseInteractiveRender (void) = 0;
  655. virtual void resumeInteractiveRender (void) = 0;
  656. virtual void postRenderProgressCheckingReqeust() = 0;
  657. enum EnableIRResult
  658. {
  659. kSuccess,
  660. kOutOfMemory
  661. };
  662. //
  663. // Below three functions are both device and data relate, so exposed on GsDevice and GsView.
  664. //
  665. virtual EnableIRResult beginInteractiveRender (void* pProgressMonitor) = 0;
  666. virtual void endInteractiveRender (void) = 0;
  667. virtual bool isRendering (void) const = 0;
  668. //
  669. // End of RapidRT
  670. // *************************************************************************
  671. // Text font kerning display setting
  672. virtual void setFontKerningDisplay (bool bDisplay) = 0;
  673. };
  674. // ****************************************************************************
  675. // AcGsConfig
  676. // ****************************************************************************
  677. class AcGsConfigReactor
  678. {
  679. public:
  680. AcGsConfigReactor (void) { }
  681. virtual ~AcGsConfigReactor (void) { }
  682. virtual void hardwareAccelerationWasModified(bool /*newValue*/) { }
  683. virtual void configWasModified (void) { }
  684. virtual void deviceSwitchToBegin (void) { }
  685. virtual void deviceSwitchHasEnded (void) { }
  686. };
  687. #ifndef DRAWBRIDGE_API
  688. #define DRAWBRIDGE_API __declspec(dllimport)
  689. #endif // !DRAWBRIDGE_API
  690. class DRAWBRIDGE_API AcGsConfig
  691. {
  692. public:
  693. enum Handedness
  694. {
  695. kLeft,
  696. kRight
  697. };
  698. enum Quality
  699. {
  700. kLowQuality,
  701. kMediumQuality,
  702. kHighQuality
  703. };
  704. enum DegradationChannel
  705. {
  706. kViewportDraw, // Viewport draw objects On to Off
  707. kLineAntialias, // Line antialias On to Off
  708. kLighting, // User lighting to Default lighting
  709. kTransparencyQuality, // Transparency quality High to Medium then Medium to Low
  710. kShadowsFull, // Full Shadows to Ground Shadows
  711. kTransparency, // Transparency On to Off
  712. kDiscardBackfaces, // Discard Backfaces Off to On
  713. kShadowsGround, // Ground Shadows to Shadows Off
  714. kEdgeStyles, // Any Edge Style On to All Edge Styles Off
  715. kFacetEdges, // Facet Edges to Isolines
  716. kFastSilhouette, // Fast silhouettes On to Off
  717. kTextures, // Textures On to Off
  718. kMaterials, // Materials On to Off
  719. kLightingQuality, // Lighting Quality Per-Vertex to Per-Face
  720. kBackgrounds, // Backgrounds On to Off
  721. kIntersectEdges, // Face Intersect Edges On to Off
  722. kFaceted, // Faceted to Wireframe
  723. kWireframe, // Wireframe to Bounding box
  724. kDegradationChannels
  725. };
  726. virtual ~AcGsConfig (void) { }
  727. // dialog, read & write registry
  728. virtual bool configure (void) = 0;
  729. virtual bool showConfigDialog (const wchar_t *strInput = nullptr) const = 0;
  730. // hardware & software drivers
  731. virtual void driverName (ACHAR *pszPath,
  732. int nStrLen) const = 0;
  733. virtual int driverVersion (void) const = 0;
  734. virtual int driverRevision (void) const = 0;
  735. virtual void driverPath (ACHAR *pszPath,
  736. int nStrLen) const = 0;
  737. virtual void setDriverPath (const ACHAR *pszPath) = 0;
  738. virtual void currentDisplayDriver (ACHAR *pszPath,
  739. int nPathStrLen,
  740. ACHAR *pszDriver,
  741. int nDriverStrLen,
  742. bool &bAccelerated) const = 0;
  743. virtual void hardwareAcceleratedDriver (ACHAR *pszPath,
  744. int nPathStrLen,
  745. ACHAR *pszDriver,
  746. int nDriverStrLen) const = 0;
  747. virtual void setHardwareAcceleratedDriver (const ACHAR *pszPath,
  748. const ACHAR *pszDriver) = 0;
  749. virtual void defaultHardwareAcceleratedDriver(ACHAR *pszPath,
  750. int nPathStrLen,
  751. ACHAR *pszDriver,
  752. int nDriverStrLen) const = 0;
  753. virtual void hardwareAcceleratedDrivers (ACHAR *pszPath,
  754. int nPathStrLen,
  755. ACHAR **pszDrivers,
  756. int nDrivers,
  757. int nDriverStrLen) = 0;
  758. virtual int numHardwareAcceleratedDrivers (void) = 0;
  759. // level of detail & dynamic tessellation
  760. virtual void setDynamicTessellation (bool bDynamicTessellation) = 0;
  761. virtual bool dynamicTessellation (void) const = 0;
  762. virtual GS::ErrorStatus setMaxLODs (int nLevels) = 0;
  763. virtual int maxLODs (void) const = 0;
  764. virtual GS::ErrorStatus setSurfaceTessellationTol (int surfaceTessellationTol) = 0;
  765. virtual int surfaceTessellationTol (void) const = 0;
  766. virtual GS::ErrorStatus setCurveTessellationTol (int curveTessellationTol) = 0;
  767. virtual int curveTessellationTol (void) const = 0;
  768. // adaptive degradation
  769. virtual GS::ErrorStatus setFrameRate (int nFramesPerSecond) = 0;
  770. virtual int frameRate (void) const = 0;
  771. virtual void setAdaptiveDegradation (bool bAdaptiveDegradation) = 0;
  772. virtual bool adaptiveDegradation (void) const = 0;
  773. virtual int degradationChainPosition (DegradationChannel) const = 0;
  774. virtual DegradationChannel degradationChannelAt (int position) const = 0;
  775. virtual void shiftDegradationChainPosition (DegradationChannel,
  776. bool bShiftDown) = 0;
  777. virtual void setCanDegradeChannel (DegradationChannel,
  778. bool bDegrade) = 0;
  779. virtual bool canDegradeChannel (DegradationChannel) const = 0;
  780. // performance
  781. virtual void setRedrawOnWindowExpose (bool bRedrawWindowExpose) = 0; // internal use
  782. virtual bool redrawOnWindowExpose (void) const = 0;
  783. // display options
  784. virtual void setHandedness (Handedness) = 0;
  785. virtual Handedness handedness (void) const = 0;
  786. virtual void setDiscardBackFaces (bool bDiscardBackFaces) = 0;
  787. virtual bool discardBackFaces (void) const = 0;
  788. virtual void setTransparency (Quality quality) = 0;
  789. virtual Quality transparency (void) const = 0;
  790. virtual void addReactor (AcGsConfigReactor *) = 0;
  791. virtual void removeReactor (AcGsConfigReactor *) = 0;
  792. // ************************************************************************
  793. // GSN additions
  794. // ************************************************************************
  795. struct EffectStatus
  796. {
  797. const AcUniqueString* pUniqueString; //Unique identifier for string
  798. AcString effectName; //Name of Effect
  799. bool bEnabled;
  800. bool bRecommended;
  801. bool bAvailable;
  802. int nFeatureLevel; //Minimum feature level required for effect
  803. };
  804. struct CertificationData
  805. {
  806. AcString sCardName; //Video Card Name
  807. AcString sDriverVersion; //Video Card Driver Version
  808. AcString sProductDriverURL; //URL to Autodesk Certification Site
  809. AcString sTuningDate; //Date of last tuning
  810. AcString sDeviceFailed; //List of failed devices
  811. int nHardwareFeatureLevel; //Hardware supported feature level
  812. int nSoftwareFeatureLevel; //Software supported feature level
  813. int nCertificationStatus; //Certification Status
  814. int nHardwareID; //Recommended HardwareID
  815. };
  816. enum EffectListType {
  817. kEL_Current,
  818. kEL_RegistryHardware,
  819. kEL_RegistrySoftware,
  820. kEL_File
  821. };
  822. // hardware features
  823. virtual AcArray<EffectStatus> *
  824. getEffectList (EffectListType type) = 0;
  825. virtual bool isFeatureEnabled (const AcUniqueString*) const = 0;
  826. virtual void setFeatureEnabled (const AcUniqueString*,
  827. bool bEnable = true) = 0;
  828. virtual bool isFeatureAvailable (const AcUniqueString*) const = 0;
  829. virtual bool isFeatureRecommended (const AcUniqueString*) const = 0;
  830. virtual void setHardwareAcceleration (bool bEnable) = 0;
  831. virtual bool isHardwareAccelerationEnabled (void) = 0;
  832. virtual bool isHardwareAccelerationAvailable (void) = 0;
  833. virtual bool isHardwareAccelerationRecommended(void) = 0;
  834. virtual bool isNoHardwareOverrideEnabled (void) = 0;
  835. virtual CertificationData getCertificationData (void) = 0;
  836. virtual AcString getVirtualDeviceName (void) = 0;
  837. virtual void setGenerateVertexNormals (bool bEnable) = 0;
  838. virtual bool generateVertexNormals (void) const = 0;
  839. };
  840. // ****************************************************************************
  841. // Access protocol for persistent drawables
  842. // ****************************************************************************
  843. typedef AcGiDrawable* (* AcGsGetInterfaceFunc) (LONG_PTR objectId,
  844. bool bNeedsValidation); // does id need validation?
  845. typedef void (* AcGsReleaseInterfaceFunc) (AcGiDrawable*);
  846. // ****************************************************************************
  847. // AcGsReactor
  848. // ****************************************************************************
  849. class AcGsReactor
  850. {
  851. public:
  852. AcGsReactor (void) { }
  853. virtual ~AcGsReactor (void) { }
  854. enum ViewUpdateFlags { kCameraChanged = 1 };
  855. virtual void viewWasCreated (AcGsView *) { }
  856. virtual void viewToBeDestroyed (AcGsView *) { }
  857. virtual void viewToBeUpdated (AcGsView *, int /*viewUpdateflags*/) { }
  858. virtual void viewWasUpdated (AcGsView *, int /*viewUpdateflags*/) { }
  859. virtual void gsToBeUnloaded (AcGsGraphicsKernel *) { }
  860. // ************************************************************************
  861. // GSN additions
  862. // ************************************************************************
  863. virtual void viewInteractivityToBeChanged(const AcGsView *, bool /*interactive*/) { }
  864. virtual void viewInteractivityWasChanged (const AcGsView *, bool /*interactive*/) { }
  865. };
  866. // ****************************************************************************
  867. // AcGsModelReactor
  868. // ****************************************************************************
  869. class AcGsModelReactor
  870. {
  871. public:
  872. AcGsModelReactor (void) { }
  873. virtual ~AcGsModelReactor (void) { }
  874. virtual bool onSceneGraphRootAdded (AcGsModel * /*pModel*/,
  875. AcGiDrawable * /*pAdded*/) { return true; }
  876. virtual bool onSceneGraphRootErased (AcGsModel * /*pModel*/,
  877. AcGiDrawable * /*pErased*/) { return true; }
  878. virtual bool onAdded (AcGsModel * /*pModel*/,
  879. AcGiDrawable * /*pAdded*/,
  880. AcGiDrawable * /*pParent*/) { return true; }
  881. virtual bool onAdded (AcGsModel * /*pModel*/,
  882. AcGiDrawable * /*pAdded*/,
  883. LONG_PTR /*parentID*/) { return true; }
  884. virtual bool onErased (AcGsModel * /*pModel*/,
  885. AcGiDrawable * /*pErased*/,
  886. AcGiDrawable * /*pParent*/) { return true; }
  887. virtual bool onErased (AcGsModel * /*pModel*/,
  888. AcGiDrawable * /*pErased*/,
  889. LONG_PTR /*parentID*/) { return true; }
  890. virtual bool onModified (AcGsModel * /*pModel*/,
  891. AcGiDrawable * /*pModified*/,
  892. AcGiDrawable * /*pParent*/) { return true; }
  893. virtual bool onModified (AcGsModel * /*pModel*/,
  894. AcGiDrawable * /*pModified*/,
  895. LONG_PTR /*parentID*/) { return true; }
  896. };
  897. // ****************************************************************************
  898. // AcGsDrawablePath
  899. // ****************************************************************************
  900. struct AcGsDrawableLink
  901. {
  902. LONG_PTR id;
  903. AcGiDrawable *pDrawable;
  904. AcGsNode *pNode;
  905. };
  906. typedef AcArray<AcGsDrawableLink> AcGsDrawablePath;
  907. // ****************************************************************************
  908. // AcGsGraphicsKernel
  909. // ****************************************************************************
  910. struct AcGsClientViewInfo
  911. {
  912. AcGsClientViewInfo()
  913. : viewportId(0)
  914. , acadWindowId(0)
  915. , viewportObjectId(0)
  916. , contextColors(nullptr)
  917. , contextualAttributes(nullptr) { }
  918. LONG_PTR viewportId; // returned via AcGiViewport::viewportId()
  919. LONG_PTR acadWindowId; // returned via AcGiViewport::acadWindowId()
  920. LONG_PTR viewportObjectId; // returned via AcGiViewportDraw::viewportObjectId()
  921. AcGiContextualColors *contextColors; // returned via AcGiViewport::contextualColors()
  922. AcGiContextualAttributes *contextualAttributes; // returned via AcGiViewport::contextualAttributes()
  923. AcDbObjectId viewportObjectAsObjectId() const;
  924. };
  925. //
  926. // AcGsKernelDescriptor is used to describe the capabilities of
  927. // a graphics kernel, or to specify the desired capabilities.
  928. //
  929. // Sample usage:
  930. // AcGsKernelDescriptor descriptor;
  931. // descriptor.addRequirement(AcGsKernelDescriptor::k3DDrawing);
  932. // requestKernel(descriptor);
  933. //
  934. // const AcGsKernelDescriptor &descriptor = kernel.getDescriptor();
  935. // if (descriptor.supports(AcGsKernelDescriptor::k3DDrawing))
  936. // ...
  937. //
  938. #ifndef DRAWBRIDGE_API
  939. #define DRAWBRIDGE_API __declspec(dllimport)
  940. #endif // DRAWBRIDGE_API
  941. class AcGsKernelDescriptor : public AcGiKernelDescriptor
  942. {
  943. public:
  944. // Used by a graphics kernel to define support for a given capability.
  945. void addSupport(const AcUniqueString *capability) { append(capability); }
  946. // Used by a graphics kernel to make sure it supports what a client requires.
  947. bool requires(const AcUniqueString *capability) const { return contains(capability); }
  948. // Predefined capabilities.
  949. static DRAWBRIDGE_API const AcUniqueString *k2DDrawing; // "2D Drawing"
  950. static DRAWBRIDGE_API const AcUniqueString *k3DDrawing; // "3D Drawing"
  951. static DRAWBRIDGE_API const AcUniqueString *k3DSelection; // "3D Selection"
  952. static DRAWBRIDGE_API const AcUniqueString *k3DRapidRTRendering; // "RapidRT Rendering"
  953. };
  954. #ifdef __clang__
  955. #define DRAWBRIDGE_MAC_API DRAWBRIDGE_API
  956. #else
  957. #define DRAWBRIDGE_MAC_API
  958. #endif
  959. class DRAWBRIDGE_MAC_API AcGsGraphicsKernel : public AcGiGraphicsKernel
  960. {
  961. public:
  962. AcGsGraphicsKernel (void) : m_refCount(0) { }
  963. virtual ~AcGsGraphicsKernel (void) { }
  964. // Base class implementations.
  965. DRAWBRIDGE_API void addRef (void);
  966. DRAWBRIDGE_API bool delRef (void); // True if deleted.
  967. virtual bool isCompatibleWith (const AcGsKernelDescriptor &) const = 0;
  968. virtual AcGsModel *createModel (AcGsModel::RenderType, LONG_PTR databaseId,
  969. AcGsGetInterfaceFunc, AcGsReleaseInterfaceFunc) = 0;
  970. virtual void deleteModel (AcGsModel *) = 0;
  971. virtual AcGsView *createView (const AcGsClientViewInfo * = nullptr,
  972. bool bEnableLayerVisibilityPerView = false) = 0;
  973. virtual void deleteView (AcGsView *view) = 0;
  974. virtual AcGsDevice *createDevice (AcGsWindowingSystemID, GS::DeviceType = GS::kScreenDevice) = 0;
  975. virtual AcGsDevice *createOffScreenDevice(void) = 0;
  976. virtual void deleteDevice (AcGsDevice *) = 0;
  977. virtual AcGsConfig *getConfig (void) const = 0;
  978. virtual void addReactor (AcGsReactor *) = 0;
  979. virtual void removeReactor (AcGsReactor *) = 0;
  980. virtual void addModelReactor (AcGsModel *, AcGsModelReactor *) = 0;
  981. virtual void removeModelReactor (AcGsModel *, AcGsModelReactor *) = 0;
  982. protected:
  983. int m_refCount;
  984. };
  985. // ****************************************************************************
  986. // AcGsRenderInterrupter
  987. // ****************************************************************************
  988. class AcGsRenderInterrupter
  989. {
  990. public:
  991. virtual bool interrupt(AcGsView* pView, AcGsModel::RenderType nType) = 0;
  992. };
  993. #pragma pack(pop)