CFx SDK Documentation  2022 SP0
GsBaseVectorizeDevice.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef ODGSBASEVECTORIZEDEVICE_INC
25 #define ODGSBASEVECTORIZEDEVICE_INC
26 
27 #include "TD_PackPush.h"
28 #include "Gs/GsBaseModule.h"
29 #include "Gs/GsDCRectArray.h"
30 #include "Gs/GsVectPerformance.h"
31 #include "Gs/GsModel.h"
32 #include "GsOverlayDefs.h"
33 #include "SlotManager.h"
34 #include "ThreadsCounter.h"
35 
36 #include "Gs/GsUpdateManager.h"
37 
42 
43 class OdGiPathNode;
46 
48 class OdGsViewImpl;
49 
54 
69 {
70  friend class OdGsViewImpl;
71  friend class OdGsBaseVectorizeView;
72 
73  friend class OdGsBaseModule;
74  OdGsBaseModulePtr m_pModule;
75  OdSlotManager m_slotManager;
76 protected:
86 
88 
90  enum
91  {
92  kFirstFlag = 1,
93 
94  kInvalid = kFirstFlag << 0,
95  kSortRenderTypes = kFirstFlag << 1,
96  kSpatialIndexDisabled = kFirstFlag << 2,
97  kDynamicHighlight = kFirstFlag << 3,
98  kDynamicSubhighlight = kFirstFlag << 4,
99  kSupportBlocks = kFirstFlag << 5,
100  kSupportOverlays = kFirstFlag << 6,
101  kSupportComposition = kFirstFlag << 7,
102  kEnableComposition = kFirstFlag << 8,
103  kMtDisplay = kFirstFlag << 9,
104  kUseSectionGeometryMap = kFirstFlag << 10,
105  kUseVpLtypeScaleMult = kFirstFlag << 11,
106  kUseVpFilterFunction = kFirstFlag << 12,
107  kCullingVolumeEnabled = kFirstFlag << 13,
108  kDisplayOffLayers = kFirstFlag << 14,
109  kSupportInteractiveView= kFirstFlag << 15,
110 
111  kLastFlag = kSupportInteractiveView
112  };
113 
115  {
118  };
120  {
121  public:
123  bool hasInvalidRects(OdUInt32 nOverlays = kGsAllOverlays) const;
124  bool mergeInvalidRects(OdGsDCRect* pRect, OdUInt32 nOverlays = kGsAllOverlays) const;
125  bool containsInvalidRects(const OdGsViewImpl &view, bool bIfHas = false, OdUInt32 nOverlays = kGsAllOverlays) const;
126  };
128 
129  void registerOverlay(OdGsViewImpl *pView, const OdGsModel *pModel);
130  void unregisterOverlay(OdGsViewImpl *pView, const OdGsModel *pModel);
131 
132  virtual void onOverlayActivated(OdGsOverlayId nOverlay);
133  virtual void onOverlayDeactivated(OdGsOverlayId nOverlay);
134 public:
138  bool invalid() const { return GETBIT(m_flags, kInvalid); }
143  void setInvalid(bool bSet) { SETBIT(m_flags, kInvalid, bSet); }
148  void setValid(bool bFlag);
149 
154 public:
155  virtual bool supportPartialUpdate() const;
156 
157  void onViewAdded(OdGsView* pView);
158 public:
160 
162 
164  void setUserGiContext(OdGiContext* pUserGiContext);
165 
168 
172  int height() const;
173 
177  int width() const;
178 
179  void invalidate();
180  void invalidate(const OdGsDCRect &screenRect);
181 
182  virtual void invalidate(OdUInt32 nOverlays);
183  virtual void invalidate(OdUInt32 nOverlays, const OdGsDCRect &screenRect);
184  void invalidate(const OdGsViewImpl *pView, const OdGsDCRect &screenRect);
185  void invalidate(const OdGsModel *pModel, const OdGsDCRect &screenRect);
186 
187  void invalidateRegion(const OdGiPathNode& path);
188 
189  const OdGsDCRectArray& invalidRects() const;
190  const OdGsDCRectArray* invalidRects(OdGsOverlayId overlayId) const;
191 
192  bool isValid() const;
193 
194  virtual void update(OdGsDCRect* pUpdatedRect);
195  virtual void updateGeometry();
196  virtual void updateScreen();
197 
198  void onSize(const OdGsDCRect& outputRect);
199 
200  const OdGsDCRect& outputRect() const;
201  void getSize(OdGsDCRect& outputRect) const;
202 
204 
206 
208  int bitsPerPixel,
209  int xPixels,
210  int yPixels);
211 
213  const OdGsClientViewInfo* pViewInfo = 0,
214  bool enableLayerVisibilityPerView = false);
215 
216  void addView(OdGsView* pView);
217 
218  void insertView(int viewIndex, OdGsView* pView);
219 
220  bool eraseView(OdGsView* pView);
221 
222  int numViews() const;
223 
224  OdGsView* viewAt(int viewIndex);
225  const OdGsView* viewAt(int viewIndex) const;
226  OdGsViewImpl* viewImplAt(int viewIndex);
227  const OdGsViewImpl* viewImplAt(int viewIndex) const;
228 
229  bool eraseView(int viewIndex);
230 
232 
233  bool setBackgroundColor(ODCOLORREF backgroundColor);
234 
236 
237  void setLogicalPalette(const ODCOLORREF* logicalPalette, int numColors);
238 
242  void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect &region);
243 
248  ODCOLORREF getColor(OdUInt16 colorIndex) const;
249 
254 
258  const ODCOLORREF* getPalette() const;
259 
264  const ODCOLORREF* getLogicalPalette(int &numColors) const;
265 
267  bool isModelCompatible(OdGsModel* pModel) const;
268 
269  const OdGsView* rootView() const;
270 
271  // renderTypes support
272  bool sortRenderTypes() const;
273  void setSortRenderTypes(bool flag);
275  OdGsModel::RenderType transientRenderType() const;
276  void setTransientRenderType(OdGsModel::RenderType renderType);
277  // overlays support
278  bool supportOverlays() const;
279  void setSupportOverlays(bool bFlag);
281  OdGsOverlayId gsModelOverlay(const OdGsModel *pModel) const;
282  int isOverlayRequireUpdate(OdGsOverlayId overlayId) const;
283 
284  bool isSpatialIndexDisabled() const;
285  void disableSpatialIndex(bool bSet);
286 
287  bool isCullingVolumeEnabled() const;
288  void enableCullingVolume(bool bSet);
289 
290  bool supportDynamicHighlight() const;
291  bool supportDynamicSubhighlight() const;
292 
293  bool supportBlocks() const;
294 
295  bool supportComposition() const;
296 
297  bool compositionEnabled() const;
298  void enableComposition(bool bSet);
299 
300  bool isDisplayOffLayersEnabled() const;
301  void enableDisplayOffLayers(bool bSet);
302 
303  bool isValidViewportId(const OdUInt32 acgiId) const
304  {
305  return m_slotManager.contains(acgiId);
306  }
307 
308  bool useVpLtypeScaleMult() const { return GETBIT(m_flags, kUseVpLtypeScaleMult); }
309  bool useVpFilterFunction() const { return GETBIT(m_flags, kUseVpFilterFunction); }
310 
314  OdRxObject* mtServices() { return m_mtServices; }
315 
318 
319  virtual bool isSupportDeviceStateSaving() const;
320  bool saveDeviceState(OdGsFiler *pFiler) const;
321  bool loadDeviceState(OdGsFiler *pFiler);
322  virtual bool saveClientDeviceState(OdGsFiler *pFiler) const;
323  virtual bool loadClientDeviceState(OdGsFiler *pFiler);
324  virtual bool saveLinkedDeviceState(OdGsFiler *pFiler) const;
325  virtual bool loadLinkedDeviceState(OdGsFiler *pFiler);
326 
327  bool supportInteractiveViewMode() const { return GETBIT( m_flags, kSupportInteractiveView ); }
328  void setSupportInteractiveViewMode( bool bSet ) { SETBIT( m_flags, kSupportInteractiveView, bSet ); }
329 
330  OdGsUpdateManagerPtr getUpdateManager( bool createIfNotExist = false );
332  OdGsUpdateManager* updateManager() { return m_pUpdateManager.get(); }
333 
334 protected:
336 public:
337  OdRxObjectPtr deviceSelfReference() { return m_pDeviceRef; }
338 
339 protected:
340  friend class DisplayScheduler;
341  virtual bool supportParallelDisplay() const { return false; }
343  void viewUpdateScreen(OdGsBaseVectorizeView* pView, bool bUpdate);
344 
345 public:
347 private:
348  OdRxObjectPtr m_mtServices;
349  OdRefCounter m_vectThreadIndex;
350  OdMutexPtr m_mtInvalidate;
351  OdMutexPtr m_mtSectionGeometryMap;
352 };
353 
355 {
357 }
358 
360 {
362 }
363 
365 {
367 }
368 
370 {
372 }
373 
375 {
377 }
378 
380 {
382 }
383 
385 {
387 }
388 
390 {
392 }
393 
395 {
397 }
398 
400 {
402 }
403 
405 {
406  return GETBIT(m_flags, kSupportBlocks);
407 }
408 
410 {
412 }
413 
415 {
417 }
418 
420 {
422 }
423 
425 {
427 }
428 
430 {
432 }
433 
435 {
436  return m_transientRenderType;
437 }
438 
440 {
441  m_transientRenderType = renderType;
442 }
443 
444 inline const
446 {
447  return m_outputRect;
448 }
449 
450 inline
452 {
453  outputRect = this->outputRect();
454 }
455 
456 inline
458 {
459  return m_logPalette[colorIndex];
460 }
461 
462 inline
464 {
465  return m_logPalette.getPtr();
466 }
467 
468 inline
470 {
471  numColors = (int)m_logPalette.size();
472  return m_logPalette.getPtr();
473 }
474 
475 inline const OdGsDCRectArray&
477 { // Main overlay is always available
479 }
480 
481 inline const OdGsDCRectArray*
483 { const GsDeviceOverlayData *pOverlayData = m_overlayData.getOverlayData(overlayId);
484  return (pOverlayData) ? &(pOverlayData->m_invalidRects) : NULL;
485 }
486 
487 #include "TD_PackPop.h"
488 
489 #endif // ODGSBASEVECTORIZEDEVICE_INC
OdArray< ODCOLORREF, OdMemoryAllocator< ODCOLORREF > > ODGSPALETTE
OdSmartPtr< OdGiTransientManager > OdGiTransientManagerPtr
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdGsOverlayId
Definition: GsOverlayDefs.h:40
@ kGsMainOverlay
Definition: GsOverlayDefs.h:41
@ kGsAllOverlays
Definition: GsOverlayDefs.h:55
#define NULL
Definition: GsProperties.h:177
int OdRefCounter
Definition: OdMutex.h:436
#define ODCOLORREF
Definition: OdPlatform.h:883
unsigned int OdUInt32
unsigned short OdUInt16
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:497
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
size_type size() const
Definition: OdArray.h:893
const T * getPtr() const
Definition: OdArray.h:1102
bool mergeInvalidRects(OdGsDCRect *pRect, OdUInt32 nOverlays=kGsAllOverlays) const
bool containsInvalidRects(const OdGsViewImpl &view, bool bIfHas=false, OdUInt32 nOverlays=kGsAllOverlays) const
void clearInvalidRects(OdUInt32 nOverlays=kGsAllOverlays)
bool hasInvalidRects(OdUInt32 nOverlays=kGsAllOverlays) const
bool eraseView(int viewIndex)
ODCOLORREF getBackgroundColor()
virtual bool isSupportDeviceStateSaving() const
void onDisplayChange(int bitsPerPixel, int xPixels, int yPixels)
OdGiTransientManager * transientManager()
bool isValidViewportId(const OdUInt32 acgiId) const
const OdGsDCRect & outputRect() const
int isOverlayRequireUpdate(OdGsOverlayId overlayId) const
const OdGsView * rootView() const
GsDeviceOverlayDataContainer m_overlayData
virtual void update(OdGsDCRect *pUpdatedRect)
OdGsModel::RenderType transientRenderType() const
void unregisterOverlay(OdGsViewImpl *pView, const OdGsModel *pModel)
OdGsUpdateManager * updateManager()
void setTransientRenderType(OdGsModel::RenderType renderType)
OdGsModel::RenderType m_transientRenderType
void onSize(const OdGsDCRect &outputRect)
virtual bool supportParallelDisplay() const
virtual void updateScreen()
GsVectPerformanceData m_vectPerfData
OdSmartPtr< OdGiContext > m_pUserContext
void setUpdateManager(OdGsUpdateManagerPtr pManager)
const ODCOLORREF * getPalette() const
void enableDisplayOffLayers(bool bSet)
void onViewAdded(OdGsView *pView)
void invalidate(const OdGsViewImpl *pView, const OdGsDCRect &screenRect)
bool saveDeviceState(OdGsFiler *pFiler) const
bool isModelCompatible(OdGsModel *pModel) const
void invalidate(const OdGsDCRect &screenRect)
const OdGsView * viewAt(int viewIndex) const
virtual OdGsOverlayId renderTypeOverlay(OdGsModel::RenderType renderType) const
OdRxObjectPtr getSectionGeometryMap()
void setLogicalPalette(const ODCOLORREF *logicalPalette, int numColors)
bool setBackgroundColor(ODCOLORREF backgroundColor)
void invalidate(const OdGsModel *pModel, const OdGsDCRect &screenRect)
OdGsModelPtr createModel()
virtual void onOverlayActivated(OdGsOverlayId nOverlay)
OdGsUpdateManagerPtr getUpdateManager(bool createIfNotExist=false)
void getSize(OdGsDCRect &outputRect) const
ODCOLORREF getPaletteBackground() const
const ODCOLORREF * getLogicalPalette(int &numColors) const
virtual OdUInt32 renderTypeWeight(OdGsModel::RenderType renderType) const
void setSupportInteractiveViewMode(bool bSet)
const OdGsViewImpl * viewImplAt(int viewIndex) const
void viewUpdateScreen(OdGsBaseVectorizeView *pView, bool bUpdate)
OdGsUpdateManagerPtr m_pUpdateManager
virtual void onOverlayDeactivated(OdGsOverlayId nOverlay)
bool eraseView(OdGsView *pView)
virtual void invalidate(OdUInt32 nOverlays, const OdGsDCRect &screenRect)
virtual bool saveLinkedDeviceState(OdGsFiler *pFiler) const
void registerOverlay(OdGsViewImpl *pView, const OdGsModel *pModel)
void setValid(bool bFlag)
ODCOLORREF getColor(OdUInt16 colorIndex) const
bool loadDeviceState(OdGsFiler *pFiler)
OdGsOverlayId gsModelOverlay(const OdGsModel *pModel) const
virtual bool supportPartialUpdate() const
void addView(OdGsView *pView)
ODRX_DECLARE_MEMBERS(OdGsBaseVectorizeDevice)
virtual bool loadLinkedDeviceState(OdGsFiler *pFiler)
OdGiTransientManagerPtr m_transientManager
void setSupportOverlays(bool bFlag)
virtual void updateGeometry()
OdArray< OdGsViewPtr > m_views
void setUserGiContext(OdGiContext *pUserGiContext)
OdGsViewImpl * viewImplAt(int viewIndex)
OdGiSectionGeometryManager * getSectionGeometryManager()
virtual void invalidate(OdUInt32 nOverlays)
virtual bool loadClientDeviceState(OdGsFiler *pFiler)
void invalidateRegion(const OdGiPathNode &path)
const OdGsDCRectArray & invalidRects() const
virtual bool saveClientDeviceState(OdGsFiler *pFiler) const
OdGsView * viewAt(int viewIndex)
OdGsViewPtr createView(const OdGsClientViewInfo *pViewInfo=0, bool enableLayerVisibilityPerView=false)
void setTransientManager(OdGiTransientManager *pManager)
void insertView(int viewIndex, OdGsView *pView)
OdGiContext * userGiContext() const
OdRxDictionaryPtr properties()
void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect &region)
virtual const ODCOLORREF * getLogicalPalette(int &numColors) const =0
virtual void getSize(OdGsDCRect &outputRect) const =0
OverlayDataType * getOverlayData(OdGsOverlayId id, bool bActivate=false)
Definition: Gs.h:133
bool contains(OdSlotId slotId) const
Definition: SlotManager.h:93
const T * get() const
Definition: SmartPtr.h:326