CFx SDK Documentation  2022 SP0
GsBaseVectorizer.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 __OD_GS_BASE_VECTORIZER_H_
25 #define __OD_GS_BASE_VECTORIZER_H_
26 
27 #include "TD_PackPush.h"
28 
29 #include "Gs/GsExport.h"
31 #include "Gs/GsExtAccum.h"
32 #include "Gs/GsModel.h"
33 #include "GsMarkerArray.h"
34 #include "Gs/GsHighlightData.h"
35 
36 class OdGsBaseModel;
37 class OdGsLayerNode;
38 class OdGsUpdateContext;
39 class OdGiSelectProc;
40 class OdGsEntityNode;
43 struct OdGsGeomPortion;
44 class OdGsMaterialNode;
45 class OdGsBaseVectorizer;
46 
47 class OdGsMtContext;
48 class OdGsUpdateState;
49 class OdGiSharedRefDesc;
50 class OdGiHistory;
52 
53 class OdPerfTimerBase;
54 
62 {
63 public:
65 
70  {
71  return *m_pExtAccum.get();
72  }
73  OdGsBaseModel* gsModel() const { return m_pGsModel; }
74 
75  bool isRecordingMetafile() { return m_pGeomPortion != 0; }
76  OdGsGeomPortion *currentGeomPortion() const { return m_pGeomPortion; }
77 
78  void beginMetafileRecording(OdGsGeomPortion* pGeomPortion) { m_pGeomPortion = pGeomPortion; }
80  void onNestedDrawable(OdDbStub* layerId);
82 
83  bool isLayerFrozen(OdGsLayerNode *pLayerNode) const;
84 private:
85  friend class OdGsBaseVectorizer;
86  void set(OdGsBaseVectorizer* v) { m_vectorizer = v; }
87  void onLayerModified(OdDbStub* layerId);
88  void onLayerModified(OdDbStub* layerId, bool bFrozen);
89  void onFrozenLayerModified(OdDbStub* layerId) const;
90 
91 public:
93 
94 protected:
98 };
99 
104 
112 {
113 public:
115 
116 protected:
118 
119 public:
120 #ifdef SWIG
121  virtual void draw(const OdGiDrawable* pDrawable) {draw(pDrawable);};
122 #endif
125  OdGsWriter& gsWriter() { return m_gsWriter; }
126  const OdGsWriter& gsWriter() const { return m_gsWriter; }
127  OdGsExtAccum& gsExtentsAccum() { return gsWriter().extentsAccum(); }
128 
153  virtual void beginMetafile(OdRxObject* pMetafile);
165  virtual void endMetafile(OdRxObject* pMetafile);
166 
177  virtual void playMetafile(const OdRxObject* pMetafile);
178 
184  virtual bool saveMetafile(const OdRxObject* pMetafile, OdGsFiler *pFiler);
190 
195  bool isMetafileEmpty() const { return m_nMetafileSize == 0; }
196 
202  {
203  if( m_nMetafileSize != OdUInt64( -1 ) ) return m_nMetafileSize;
204  return 0;
205  }
206 
210  virtual void loadViewport();
211 
212  virtual bool forceMetafilesDependence() const;
213 
214  virtual bool isViewRegenerated() const;
215 
219  virtual void drawViewportFrame();
220  virtual void updateViewport();
221 
222  // Materials support
223  virtual void processMaterialNode(OdDbStub *materialId, OdGsMaterialNode *pNode);
224  virtual bool saveMaterialCache(const OdGsMaterialNode *pNode, OdGsFiler *pFiler);
225  virtual bool loadMaterialCache(OdGsMaterialNode *pNode, OdGsFiler *pFiler);
226 
227  virtual void addPointLight(const OdGiPointLightTraitsData&) {}
228  virtual void addSpotLight(const OdGiSpotLightTraitsData&) {}
230  virtual void addWebLight(const OdGiWebLightTraitsData&);
231  // default implementation call's addPointLight
232 
234 
238  void pushModelTransform(const OdGeVector3d& normal);
240 
244 
248  virtual void setEntityTraitsDataChanged(int bit, bool value = true);
249 
251 
254  bool disableInfiniteGeomExtents() const { return GETBIT(m_flags, kDisableInfiniteGeomExtents); }
255  bool sectionableGeomExtentsOnly() const { return GETBIT(m_flags, kSectionableGeomExtentsOnly); }
256  void setSectionableGeomExtentsOnly(bool bOn) { SETBIT(m_flags, kSectionableGeomExtentsOnly, bOn); }
257 
263  void playMetafileMode(const OdRxObject* pMetafile, EMetafilePlayMode eMode);
267  EMetafilePlayMode metafilePlayMode() const { return m_eMfPlayMode; }
268 
270  {
271  kSharedRefTransform = (1 << 0),
272  kSharedRefUpdate = (1 << 1),
273  kSharedRefSelect = (1 << 2)
274  };
275  virtual void pushMetafileTransform(const OdGeMatrix3d&, OdUInt32 = 0){}
276  virtual void popMetafileTransform(OdUInt32 = 0){}
277 
278  virtual bool useSharedBlockReferences() const { return true; }
279  virtual bool useMetafileAsGeometry() const { return false; }
283  virtual void reportUpdateError(OdDbStub* /*entityId*/, const OdError& error)
284  {
285 #ifdef ODA_DIAGNOSTICS
286  throw error;
287 #else
288  ODA_ASSERT(error); // prevent arg unused warning
289 #endif
290  }
291 
292  OdGsLayerNode* gsLayerNode(OdDbStub* layerId, OdGsBaseModel* pModel);
293 
297  inline bool isFaded() const;
298  inline OdUInt32 fadingIntensity() const;
299 
300  inline bool isHighlighted() const;
301 
302  inline bool isSelecting() const;
303 
304  bool isDragging() const;
305 
306  virtual OdGiConveyorOutput& gsExtentsOutput() { return secondaryOutput(); }
307 
316  virtual void setAnalyticLinetypingCircles(bool analytic);
317 
325  virtual bool isAnalyticLinetypingCircles() const;
326 
335  virtual void setAnalyticLinetypingComplexCurves(bool analytic);
336 
344  virtual bool isAnalyticLinetypingComplexCurves() const;
345 
346 //#ifdef GS_INEXACT_SELECTION
348 //#endif
349 
351  OdUInt32 incFlags = OdGsProperties::kAll);
352 
357 
358  // OdGiBaseVectorizerImpl methods
359  virtual void setUp(OdGsViewImpl& view);
360 
361  // OdGiBaseVectorizer methods
362  virtual void beginViewVectorization();
363  virtual void endViewVectorization();
364  virtual void onTraitsModified();
365  virtual bool regenAbort() const;
366  virtual bool doDraw(OdUInt32 drawableFlags, const OdGiDrawable* pDrawable);
367  virtual void setSelectionMarker(OdGsMarker selectionMarker);
369 
375  virtual void setVisualStyle(const OdGiVisualStyle& visualStyle);
376 
377  const OdGsMarkerArray* highlightedSubentities() const;
379  OdUInt32 threadIndex() const;
380 
381  void highlight(bool bHighlight);
385  const OdGsHlBranch* currentHighlightBranch() const;
386 
387  OdGsLayerNode *activeLayerNode(bool bSync = false) const;
388 
389  OdGsModel::RenderType activeRenderType() const;
390  OdGsOverlayId activeOverlay() const;
391 protected:
392  void doSelect(const OdGePoint2d* aPtDc, int numPoints,
407  virtual void display(bool bUpdate);
413  virtual void updateExtents(bool bBuildCache);
414 
415  // OdGiBaseVectorizer methods
417  virtual OdDbStub* switchLayer(OdDbStub* layerId) const;
418 
419  void selectionMarkerOnChange(OdGsMarker nSelectionMarker);
420 
421  void checkRenderType(const OdGsModel *pModel);
422  virtual void renderTypeOnChange(OdGsModel::RenderType renderType);
423  virtual void switchOverlay(OdGsOverlayId overlayId);
424 
426 
427 public:
428  void updateExtentsInThreadInit(OdGsMtContext& mtContext);
429 
430 private:
431  void setInitGsState(bool bOn);
432  bool isRecordingHistory();
433  void deleteHistory();
434  void setThreadIndex(OdUInt32 idx) { m_threadIndex = idx; }
435  bool drawSectionable(const OdGiDrawable& drawable, bool& bRes);
436  bool drawSectionGeometry(OdGiSectionGeometry& geom, bool bVpModelTfAwareBefore);
437  void setCurrentState(OdGsUpdateState& newState);
438  OdGsUpdateState* currentState() { return m_curState; }
439  const OdGsUpdateState* currentState() const { return m_curState; }
440  void applyState(const OdGsUpdateState& s, const OdGsUpdateState& prev);
441 
442 public:
444 protected:
451  OdGsUpdateState* m_curState;
455  // Fading support
457  {
458  kFfLockedLayer = (1 << 0),
459  kFfXref = (1 << 1),
460  kFfRefEdit = (1 << 2),
461  kFfFlagsMask = kFfLockedLayer | kFfXref | kFfRefEdit,
462  kEFfLockedLayer = (1 << 4),
463  kEFfXref = (1 << 5),
464  kEFfRefEdit = (1 << 6),
465  kEFfFlagsMask = kEFfLockedLayer | kEFfXref | kEFfRefEdit,
466  kEFfFlagsOffset = 4,
467  kFvLockedLayerOffset = 8,
468  kFvLockedLayerMask = (0xFF << kFvLockedLayerOffset),
469  kFvXrefOffset = 16,
470  kFvXrefMask = (0xFF << kFvXrefOffset),
471  kFvRefEditOffset = 24,
472  kFvRefEditMask = (0xFF << kFvRefEditOffset)
473  };
475  template <OdGiContext::FadingType fadingType> friend class OdGsLockFadingFlag;
476 
477 public:
482  void setRenderAbort( bool bSet );
486  virtual bool renderAbort();
487 protected:
489  {
491  kViewInteractive = OdGiBaseVectorizerImpl::kLastImplFlag << 2,
492  kLastBaseVectorizerFlag = kViewInteractive
493  };
496 
497 
498 private:
499  mutable const OdGiLayerTraitsData* m_pCachedLayer;
500  OdGsLayerNode* m_effectiveLayer;
501  OdGsExtAccumPtr m_pOutputExtents;
502  OdGiHistory* m_giHistory;
503  OdUInt32 m_threadIndex;
504  bool m_bTraitsDataChanged;
505  bool m_bByBlockTraitsChanged;
506  friend class OdGsUpdateContext;
507  friend class OdGsDisplayContext;
508  friend class OdGsBaseVectorizeView;
509  friend class OdGsApplyModelOverrides;
510 };
511 
512 template <OdGiContext::FadingType fadingType>
514 {
515  protected:
518  public:
520  : m_lockedFlags(vectorizer.m_fadingFlags)
521  , m_bSavedBit(GETBIT(vectorizer.m_fadingFlags, 1 << fadingType))
522  {}
523  void set(bool bNewVal) { SETBIT(m_lockedFlags, 1 << fadingType, bNewVal); }
524  OdGsLockFadingFlag(OdGsBaseVectorizer &vectorizer, bool bNewVal)
525  : m_lockedFlags(vectorizer.m_fadingFlags)
526  , m_bSavedBit(GETBIT(vectorizer.m_fadingFlags, 1 << fadingType))
527  { set(bNewVal); }
529 };
530 
531 inline bool OdGsBaseVectorizer::isFaded() const
532 { // Returns true in case if any type of fading is 'true' and fading value is positive
534 }
535 
537 { // Returns percentage in [0-100] range
538  OdUInt32 nIntensityMix = 100;
540  nIntensityMix = nIntensityMix * (100 - ((m_fadingFlags & kFvLockedLayerMask) >> kFvLockedLayerOffset)) / 100;
542  nIntensityMix = nIntensityMix * (100 - ((m_fadingFlags & kFvXrefMask) >> kFvXrefOffset)) / 100;
544  nIntensityMix = nIntensityMix * (100 - ((m_fadingFlags & kFvRefEditMask) >> kFvRefEditOffset)) / 100;
545  return 100 - nIntensityMix;
546 }
547 
549 {
550  return m_pCurHltBr.get() && m_pCurHltBr->markers().size() ? &m_pCurHltBr->markers() : NULL;
551 }
552 
554 {
555  return m_threadIndex;
556 }
557 
559 {
560  return m_pCurHltBr;
561 }
562 
564 {
565  if (bSync)
567  return m_effectiveLayer;
568 }
569 
571 {
572  return m_curRenderType;
573 }
574 
576 {
577  return m_curOverlay;
578 }
579 
581 {
582  return m_pSelectProc != 0;
583 }
584 
586 {
587  return GETBIT(m_flags, kHighlighted);
588 }
589 
590 #include "TD_PackPop.h"
591 
592 #endif // __OD_GS_BASE_VECTORIZER_H_
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
EMetafilePlayMode
Definition: GsDefs.h:328
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdGsOverlayId
Definition: GsOverlayDefs.h:40
#define NULL
Definition: GsProperties.h:177
ptrdiff_t OdGsMarker
unsigned int OdUInt32
ptrdiff_t OdIntPtr
#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
static GE_STATIC_EXPORT const OdGeMatrix3d kIdentity
Definition: GeMatrix3d.h:79
void updateLayerTraits(OdGiSubEntityTraitsData &subEntityTraits) const
OdGiSubEntityTraitsData m_effectiveEntityTraitsData
OdUInt64 lastMetafileSize() const
virtual void addDistantLight(const OdGiDistantLightTraitsData &)
virtual void setAnalyticLinetypingComplexCurves(bool analytic)
OdIntPtr m_drawableFilterFunction
OdGiSelectProc * m_pSelectProc
OdGsHlBranch * findHighlightedSubnodeBranch()
OdGsLayerNode * activeLayerNode(bool bSync=false) const
virtual bool displayViewportProperties(OdGsPropertiesDirectRenderOutput *pdro=NULL, OdUInt32 incFlags=OdGsProperties::kAll)
virtual bool saveMaterialCache(const OdGsMaterialNode *pNode, OdGsFiler *pFiler)
virtual void beginMetafile(OdRxObject *pMetafile)
virtual void updateExtents(bool bBuildCache)
virtual OdGiConveyorOutput & gsExtentsOutput()
virtual OdRxObjectPtr loadMetafile(OdGsFiler *pFiler)
void displayWithoutNesting(OdGsEntityNode *pNode)
OdUInt32 threadIndex() const
virtual void renderTypeOnChange(OdGsModel::RenderType renderType)
virtual OdGiConveyorOutput & outputForMetafileGeometry()
virtual void loadViewport()
virtual void popMetafileTransform(OdUInt32=0)
virtual void setVisualStyle(const OdGiVisualStyle &visualStyle)
OdUInt32 fadingIntensity() const
OdPerfTimerBase * m_viewTimingProcessor
virtual void updateViewport()
virtual OdGeMatrix3d getTransformForMetafileGeometry() const
bool disableInfiniteGeomExtents() const
OdGsModel::RenderType activeRenderType() const
bool isHighlighted() const
OdGiConveyorOutput & secondaryOutput()
virtual bool renderAbort()
virtual void addWebLight(const OdGiWebLightTraitsData &)
virtual OdRxObjectPtr newGsMetafile()
virtual void endMetafile(OdRxObject *pMetafile)
void pushClipBoundary(OdGiClipBoundary *pBoundary, OdGiAbstractClipBoundary *pClipInfo)
void playMetafileMode(const OdRxObject *pMetafile, EMetafilePlayMode eMode)
OdGiConveyorGeometry * m_pDetachedOutput
virtual void endViewVectorization()
virtual bool regenAbort() const
OdGsUpdateState * m_curState
virtual void setTransformForMetafileGeometry(const OdGeMatrix3d &)
virtual void setEntityTraitsDataChanged(int bit, bool value=true)
bool isDragging() const
virtual void addSpotLight(const OdGiSpotLightTraitsData &)
bool isSelecting() const
virtual void onTraitsModified()
virtual void display(bool bUpdate)
virtual void drawViewportFrame()
virtual void beginViewVectorization()
EMetafilePlayMode metafilePlayMode() const
virtual void pushMetafileTransform(const OdGeMatrix3d &, OdUInt32=0)
virtual bool useMetafileAsGeometry() const
void doSelect(const OdGePoint2d *aPtDc, int numPoints, OdGsSelectionReactor *pReactor, OdGsView::SelectionMode mode)
virtual bool useSharedBlockReferences() const
virtual OdGeMatrix3d objectToDeviceMatrix() const
OdGsHlBranchPtr m_pCurHltBr
ODRX_USING_HEAP_OPERATORS(OdGiBaseVectorizer)
void setRenderAbort(bool bSet)
virtual const OdGiLayerTraitsData & effectiveLayerTraits() const
EMetafilePlayMode m_eMfPlayMode
virtual void setUp(OdGsViewImpl &view)
OdGsLayerNode * gsLayerNode(OdDbStub *layerId, OdGsBaseModel *pModel)
void updateExtentsInThreadInit(OdGsMtContext &mtContext)
OdGsExtAccum & gsExtentsAccum()
void pushModelTransform(const OdGeMatrix3d &xfm)
virtual void addPointLight(const OdGiPointLightTraitsData &)
virtual void switchOverlay(OdGsOverlayId overlayId)
virtual void setEntityTraitsDataChanged()
virtual void setAnalyticLinetypingCircles(bool analytic)
virtual void playMetafile(const OdRxObject *pMetafile)
const OdGsHlBranch * currentHighlightBranch() const
void selectionMarkerOnChange(OdGsMarker nSelectionMarker)
virtual void setSelectionMarker(OdGsMarker selectionMarker)
OdGsModel::RenderType m_curRenderType
const OdGsWriter & gsWriter() const
OdGsOverlayId activeOverlay() const
virtual bool isAnalyticLinetypingComplexCurves() const
virtual bool doDraw(OdUInt32 drawableFlags, const OdGiDrawable *pDrawable)
virtual OdDbStub * switchLayer(OdDbStub *layerId) const
virtual void reportUpdateError(OdDbStub *, const OdError &error)
const OdGsMarkerArray * highlightedSubentities() const
void setSectionableGeomExtentsOnly(bool bOn)
OdGsOverlayId m_curOverlay
bool sectionableGeomExtentsOnly() const
virtual bool isViewRegenerated() const
virtual bool forceMetafilesDependence() const
virtual bool isAnalyticLinetypingCircles() const
void highlight(bool bHighlight)
bool doViewExtents(OdGeBoundBlock3d &extents)
OdGiConveyorGeometry * m_pDetachedSecondaryOutput
bool isMetafileEmpty() const
virtual bool loadMaterialCache(OdGsMaterialNode *pNode, OdGsFiler *pFiler)
virtual OdGiConveyorOutput & output()
virtual void processMaterialNode(OdDbStub *materialId, OdGsMaterialNode *pNode)
void checkRenderType(const OdGsModel *pModel)
void pushModelTransform(const OdGeVector3d &normal)
void pushClipBoundary(OdGiClipBoundary *pBoundary)
virtual bool saveMetafile(const OdRxObject *pMetafile, OdGsFiler *pFiler)
OdGsWriter & gsWriter()
const OdGsMarkerArray & markers() const
OdGsLockFadingFlag(OdGsBaseVectorizer &vectorizer, bool bNewVal)
void set(bool bNewVal)
OdGsLockFadingFlag(OdGsBaseVectorizer &vectorizer)
SelectionMode
Definition: Gs.h:157
void separateMetafile()
OdGsExtAccumPtr m_pExtAccum
void endMetafileRecording()
void beginMetafileRecording(OdGsGeomPortion *pGeomPortion)
OdGsGeomPortion * currentGeomPortion() const
bool isLayerFrozen(OdGsLayerNode *pLayerNode) const
OdGsBaseModel * m_pGsModel
void onNestedDrawable(OdDbStub *layerId)
bool isRecordingMetafile()
OdGsBaseVectorizer * m_vectorizer
OdGsExtAccum & extentsAccum()
OdGsBaseModel * gsModel() const
OdGsGeomPortion * m_pGeomPortion
const TObj * get() const
Definition: TPtr.h:111
const GLfloat * v
Definition: gles2_ext.h:315
GLsizei const GLfloat * value
Definition: gles2_ext.h:302