CFx SDK Documentation  2020SP3
GsLayerNode.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_LAYER_NODE__
25 #define __OD_GS_LAYER_NODE__
26 
27 #include "TD_PackPush.h"
28 
29 #include "Gs/GsNode.h"
30 #include "Gs/GsViewImpl.h"
31 #include "Gi/GiLayerTraitsData.h"
32 #include "ThreadsCounter.h"
33 #include "GsEmptyMetafileCache.h"
34 #include "OdVector.h"
35 
37 
41 {
42  enum
43  {
44  kDirty = OdGsNode::kLastFlag << 1,
45  kVpDep = OdGsNode::kLastFlag << 2,
46  kVpFrozen = OdGsNode::kLastFlag << 3,
47 
48  kLastFlag = kVpFrozen
49  };
50 protected:
54  void update(OdGsUpdateContext& ctx, OdGsContainerNode* pParent,
55  OdSiSpatialIndex* pParentIndex);
56 
60  virtual void display(OdGsDisplayContext& ctx);
61 
65  bool extents(OdGeExtents3d& ) const;
66 
68 
71 
72  friend class OdGsBaseModel;
74 public:
76 
80  OdGsLayerNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable, bool bSetGsNode = true);
82 
83  void destroy() {}
84 
85  OdGiLayerTraitsData& layerTraits(OdUInt32 nVpId);
86 
87  const OdGiLayerTraitsData& layerTraits(OdUInt32 nVpId) const;
88 
90 
91  bool isDirty() const;
92  void setDirty(bool bDirty);
93  bool isUpToDate(OdUInt32 nVpId) const;
94  bool isValidCache(OdUInt32 nVpId) const;
96  bool isInvalidated() const;
97  bool isVpDep() const;
98  virtual ENodeType nodeType() const { return kLayerNode; }
99  inline bool isVpFrozen() const;
100  inline bool isFrozen() const;
101 
106 
109  virtual void update(OdGsBaseVectorizer& view);
110 
111  bool isTraitsCompatible(OdUInt32 nVpId1, OdUInt32 nVpId2) const;
112 
113  bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL) const;
114  bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL);
115 private:
117  OdGsEmptyMetafileCache m_emfCache;
118  OdMutexPtr m_mt;
119 };
120 
121 inline bool
123 {
124  return GETBIT(m_flags, kDirty);
125 }
126 
127 inline void
129 {
130  SETBIT(m_flags, kDirty, bDirty);
131 }
132 
133 inline bool OdGsLayerNode::isUpToDate(OdUInt32 nVpId) const
134 {
135  if(isInvalidated())
136  return false;
137  if(isVpDep())
138  {
139  if(nVpId > 0 && m_vpLayerTraits.size() < nVpId)
140  return false;
141  return !GETBIT(layerTraits(nVpId).flags(), 0x80000000);
142  }
143  return !GETBIT(layerTraits(0).flags(), 0x80000000);
144 }
145 
146 inline bool OdGsLayerNode::isInvalidated() const
147 {
148  return (m_layerTraits.m_flags == 0xFFFFFFFF) && !m_vpLayerTraits.size();
149 }
150 
151 inline bool OdGsLayerNode::isVpDep() const
152 {
153  return GETBIT(m_flags, kVpDep);
154 }
155 
157 {
158  return const_cast<OdGiLayerTraitsData&>(static_cast<const OdGsLayerNode*>(this)->layerTraits(nVpId));
159 }
160 
162 {
163  if(isVpDep() && nVpId > 0)
164  {
165  ODA_ASSERT(m_vpLayerTraits.size() >= nVpId);
166  return m_vpLayerTraits[--nVpId];
167  }
168  return m_layerTraits;
169 }
170 
171 inline bool OdGsLayerNode::isVpFrozen() const
172 {
173  return GETBIT(m_flags, kVpFrozen);
174 }
175 
176 inline bool OdGsLayerNode::isFrozen() const
177 {
178  return m_layerTraits.isFrozen();
179 }
180 
189 {
190  ODRX_USING_HEAP_OPERATORS(OdGiLayerTraitsTaker);
191  public:
193 
195  OdGiViewport& viewport() const { return *const_cast<OdGiLayerTraitsTakerView*>(this); }
196  OdUInt32 sequenceNumber() const { return 0; }
197  bool isValidId(const OdUInt32 acgiId) const { return m_view.isValidViewportId(acgiId); }
198  OdDbStub* viewportObjectId() const { return m_view.getViewportObjectId(); }
199 
205  virtual bool isPerspective() const { return m_view.isPerspective(); }
206  virtual bool doPerspective(OdGePoint3d& pt) const { return m_view.doPerspectivePt(pt); }
207  virtual bool doInversePerspective(OdGePoint3d& pt) const { return m_view.doInversePerspectivePt(pt); }
208  virtual void getNumPixelsInUnitSquare(const OdGePoint3d& pt, OdGePoint2d& pixelDensity, bool bUsePerspective = true) const
209  { m_view.getNumPixelsInUnitSquare(pt, pixelDensity, bUsePerspective); }
210  virtual OdGePoint3d getCameraLocation() const { return m_view.position(); }
211  virtual OdGePoint3d getCameraTarget() const { return m_view.target(); }
212  virtual OdGeVector3d getCameraUpVector() const { return m_view.upVector(); }
213  virtual OdGeVector3d viewDir() const { return m_view.eyeVector(); }
214  virtual OdUInt32 viewportId() const { return m_view.viewportId(); }
215  virtual OdInt16 acadWindowId() const
216  { OdGsClientViewInfo vi;
218  return OdInt16(vi.acadWindowId);
219  }
220  virtual void getViewportDcCorners(OdGePoint2d& lowerLeft, OdGePoint2d& upperRight) const
221  { m_view.viewportDcCorners(lowerLeft, upperRight); }
222  virtual bool getFrontAndBackClipValues(bool& clipFront, bool& clipBack, double& front, double& back) const
223  { clipFront = m_view.isFrontClipped();
224  clipBack = m_view.isBackClipped();
225  front = m_view.frontClip();
226  back = m_view.backClip();
227  return (clipFront || clipBack);
228  }
229  virtual double linetypeScaleMultiplier() const { return m_view.getLinetypeScaleMultiplier(); }
231  virtual bool layerVisible(OdDbStub* layerId) const { return m_view.isLayerVisible(layerId); }
232 
234  virtual void addRef() {}
235  virtual void release() {}
236 
238  virtual double deviation(const OdGiDeviationType type, const OdGePoint3d& pt) const
239  { return m_view.getDeviation(type, pt, true); }
241  virtual OdGiRegenType regenType() const { return m_view.getRegenType(); }
242  virtual bool regenAbort() const { return m_view.userGiContext()->regenAbort(); }
243  virtual OdGiContext* context() const { return m_view.userGiContext(); }
244  protected:
246 };
247 
248 // Include inline OdGsEmptyMetafileCache methods
249 #ifndef __OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__
250 #define __OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__
251 #include "GsEmptyMetafileCache.h"
252 #endif
253 //
254 
255 #include "TD_PackPop.h"
256 
257 #endif // __OD_GS_LAYER_NODE__
OdGsViewImpl::position
virtual OdGePoint3d position() const
GETBIT
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
OdGiContext
Definition: GiCommonDraw.h:108
OdSiSpatialIndex
Definition: SiSpatialIndex.h:118
OdGsLayerNode::isFrozen
bool isFrozen() const
Definition: GsLayerNode.h:176
OdGeVector3d
Definition: GeVector3d.h:54
OdGiLayerTraitsTakerView
Definition: GsLayerNode.h:189
OdGiLayerTraitsTakerView::context
virtual OdGiContext * context() const
Definition: GsLayerNode.h:243
OdGsViewImpl::isLayerVisible
bool isLayerVisible(OdDbStub *layerId) const
NULL
#define NULL
Definition: GsProperties.h:177
OdGsLayerNode::setDirty
void setDirty(bool bDirty)
Definition: GsLayerNode.h:128
OdGsLayerNode::isVpDep
bool isVpDep() const
Definition: GsLayerNode.h:151
OdGsLayerNode::destroy
void destroy()
Definition: GsLayerNode.h:83
OdGiLayerTraitsTakerView::isPerspective
virtual bool isPerspective() const
Definition: GsLayerNode.h:205
OdGsLayerNode::OdGsLayerNode
OdGsLayerNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
OdGiLayerTraitsTakerView::viewport
OdGiViewport & viewport() const
Definition: GsLayerNode.h:195
OdGsContainerNode
Definition: GsContainerNode.h:47
OdGiLayerTraitsTakerView::deviation
virtual double deviation(const OdGiDeviationType type, const OdGePoint3d &pt) const
Definition: GsLayerNode.h:238
OdGiLayerTraitsData
Definition: GiLayerTraitsData.h:72
OdGsBaseVectorizer
Definition: GsBaseVectorizer.h:112
OdGsViewImpl::getLinetypeGenerationCriteria
double getLinetypeGenerationCriteria() const
OdGiLayerTraitsTakerView::viewDir
virtual OdGeVector3d viewDir() const
Definition: GsLayerNode.h:213
OdVector.h
OdGsViewImpl::isPerspective
virtual bool isPerspective() const
OdGsEmptyMetafileCache
Definition: GsEmptyMetafileCache.h:38
GsEmptyMetafileCache.h
OdGsLayerNode::propagateLayerChanges
void propagateLayerChanges(OdGsViewImpl &view)
OdGsLayerNode::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdGsLayerNode)
type
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
OdGiLayerTraitsTakerView::OdGiLayerTraitsTakerView
OdGiLayerTraitsTakerView(OdGsViewImpl &view)
Definition: GsLayerNode.h:192
OdGiViewport
Definition: GiViewport.h:51
SETBIT
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:497
OdGsViewImpl::clientViewInfo
virtual void clientViewInfo(OdGsClientViewInfo &viewInfo) const
OdGiLayerTraitsTakerView::getModelToEyeTransform
virtual OdGeMatrix3d getModelToEyeTransform() const
Definition: GsLayerNode.h:201
OdGiLayerTraitsTaker
Definition: GiLayerTraitsData.h:158
OdGsNode
Definition: GsNode.h:60
OdGsLayerNode
Definition: GsLayerNode.h:41
OdGsLayerNode::m_pNextChanged
OdGsLayerNode * m_pNextChanged
Definition: GsLayerNode.h:73
OdGsLayerNode::~OdGsLayerNode
~OdGsLayerNode()
OdGsLayerNode::reserveLayerTraits
void reserveLayerTraits(OdUInt32 nVpId)
OdGiLayerTraitsTakerView::numberOfIsolines
virtual OdUInt32 numberOfIsolines() const
Definition: GsLayerNode.h:240
OdGsViewImpl::getRegenType
OdGiRegenType getRegenType() const
Definition: GsViewImpl.h:388
OdGiLayerTraitsTakerView::getNumPixelsInUnitSquare
virtual void getNumPixelsInUnitSquare(const OdGePoint3d &pt, OdGePoint2d &pixelDensity, bool bUsePerspective=true) const
Definition: GsLayerNode.h:208
OdGiContext::regenAbort
virtual bool regenAbort() const
OdGiLayerTraitsTakerView::getFrontAndBackClipValues
virtual bool getFrontAndBackClipValues(bool &clipFront, bool &clipBack, double &front, double &back) const
Definition: GsLayerNode.h:222
OdGiLayerTraitsTakerView::acadWindowId
virtual OdInt16 acadWindowId() const
Definition: GsLayerNode.h:215
OdGiLayerTraitsTakerView::layerVisible
virtual bool layerVisible(OdDbStub *layerId) const
Definition: GsLayerNode.h:231
OdGsViewImpl::eyeToWorldMatrix
const OdGeMatrix3d & eyeToWorldMatrix() const
Definition: GsViewImpl.h:913
OdGsLayerNode::setCacheUpToDate
void setCacheUpToDate(OdUInt32 nVpId)
TD_PackPop.h
kLayerNode
@ kLayerNode
Definition: GsBaseModel.h:71
OdGiLayerTraitsTakerView::isValidId
bool isValidId(const OdUInt32 acgiId) const
Definition: GsLayerNode.h:197
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdGiLayerTraitsTakerView::regenAbort
virtual bool regenAbort() const
Definition: GsLayerNode.h:242
OdGeMatrix3d
Definition: GeMatrix3d.h:73
OdInt16
short OdInt16
Definition: OdPlatformSettings.h:756
OdGsLayerNode::m_vpLayerTraits
OdGiLayerTraitsDataArray m_vpLayerTraits
Definition: GsLayerNode.h:70
mask
GLenum GLint GLuint mask
Definition: gles2_ext.h:262
OdGsViewImpl::getDeviation
virtual double getDeviation(const OdGiDeviationType deviationType, const OdGePoint3d &pointOnCurve, bool bRecalculate=false) const
OdGiLayerTraitsTakerView::getWorldToEyeTransform
virtual OdGeMatrix3d getWorldToEyeTransform() const
Definition: GsLayerNode.h:203
OdGiLayerTraitsData::isFrozen
bool isFrozen() const
Definition: GiLayerTraitsData.h:119
OdGsLayerNode::update
void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *pParentIndex)
OdGsLayerNode::isTraitsCompatible
bool isTraitsCompatible(OdUInt32 nVpId1, OdUInt32 nVpId2) const
OdGsLayerNode::nodeType
virtual ENodeType nodeType() const
Definition: GsLayerNode.h:98
OdGiLayerTraitsTakerView::linetypeGenerationCriteria
virtual double linetypeGenerationCriteria() const
Definition: GsLayerNode.h:230
ENodeType
ENodeType
Definition: GsBaseModel.h:65
OdGsViewImpl::isValidViewportId
bool isValidViewportId(const OdUInt32 vpId) const
OdGiLayerTraitsTakerView::m_view
OdGsViewImpl & m_view
Definition: GsLayerNode.h:245
GsNode.h
ThreadsCounter.h
OdGiLayerTraitsTakerView::linetypeScaleMultiplier
virtual double linetypeScaleMultiplier() const
Definition: GsLayerNode.h:229
OdGsViewImpl::eyeVector
const OdGeVector3d & eyeVector() const
Definition: GsViewImpl.h:395
OdGePoint3d
Definition: GePoint3d.h:55
OdGsViewImpl::worldToEyeMatrix
const OdGeMatrix3d & worldToEyeMatrix() const
Definition: GsViewImpl.h:923
OdGsLayerNode::isDirty
bool isDirty() const
Definition: GsLayerNode.h:122
OdGsNode::kLastFlag
@ kLastFlag
Definition: GsNode.h:84
OdGsLayerNode::isInvalidated
bool isInvalidated() const
Definition: GsLayerNode.h:146
OdGiLayerTraitsTakerView::addRef
virtual void addRef()
Definition: GsLayerNode.h:234
OdGsLayerNode::update
virtual void update(OdGsBaseVectorizer &view)
GsViewImpl.h
OdGiLayerTraitsTakerView::release
virtual void release()
Definition: GsLayerNode.h:235
OdGiLayerTraitsTakerView::getCameraTarget
virtual OdGePoint3d getCameraTarget() const
Definition: GsLayerNode.h:211
OdGiDrawable
Definition: GiDrawable.h:49
OdGiLayerTraitsTakerView::viewportId
virtual OdUInt32 viewportId() const
Definition: GsLayerNode.h:214
OdGsViewImpl::getLinetypeScaleMultiplier
double getLinetypeScaleMultiplier() const
OdGsViewImpl
Definition: GsViewImpl.h:58
OdGiLayerTraitsTakerView::sequenceNumber
OdUInt32 sequenceNumber() const
Definition: GsLayerNode.h:196
OdGsLayerNode::extents
bool extents(OdGeExtents3d &) const
OdGsViewImpl::doInversePerspectivePt
bool doInversePerspectivePt(OdGePoint3d &point) const
OdGiLayerTraitsTakerView::doInversePerspective
virtual bool doInversePerspective(OdGePoint3d &pt) const
Definition: GsLayerNode.h:207
OdGiLayerTraitsTakerView::doPerspective
virtual bool doPerspective(OdGePoint3d &pt) const
Definition: GsLayerNode.h:206
OdGsLayerNode::loadNodeState
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
OdVector
Definition: OdVector.h:54
OdGsViewImpl::getViewportObjectId
OdDbStub * getViewportObjectId() const
Definition: GsViewImpl.h:244
OdGiContext::numberOfIsolines
virtual OdUInt32 numberOfIsolines() const
OdGsLayerNode::display
virtual void display(OdGsDisplayContext &ctx)
OdGiLayerTraitsDataArray
OdVector< OdGiLayerTraitsData, OdMemoryAllocator< OdGiLayerTraitsData > > OdGiLayerTraitsDataArray
Definition: GsLayerNode.h:36
OdGsViewImpl::viewportDcCorners
void viewportDcCorners(OdGePoint2d &lower_left, OdGePoint2d &upper_right) const
TD_PackPush.h
OdGsViewImpl::doPerspectivePt
bool doPerspectivePt(OdGePoint3d &point) const
OdGiLayerTraitsTakerView::getCameraUpVector
virtual OdGeVector3d getCameraUpVector() const
Definition: GsLayerNode.h:212
OdGsLayerNode::m_layerTraits
OdGiLayerTraitsData m_layerTraits
Definition: GsLayerNode.h:69
OdGiDeviationType
OdGiDeviationType
Definition: GiCommonDraw.h:64
OdGsLayerNode::invalidate
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
GiLayerTraitsData.h
OdGsLayerNode::isVpFrozen
bool isVpFrozen() const
Definition: GsLayerNode.h:171
OdGsViewImpl::viewportId
OdUInt32 viewportId() const
Definition: GsViewImpl.h:240
OdGsLayerNode::isUpToDate
bool isUpToDate(OdUInt32 nVpId) const
Definition: GsLayerNode.h:133
OdGsBaseModel
Definition: GsBaseModel.h:118
ODA_ASSERT
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
OdGsClientViewInfo
Definition: Gs.h:1021
OdGsClientViewInfo::acadWindowId
long acadWindowId
Definition: Gs.h:1031
OdGeExtents3d
Definition: GeExtents3d.h:45
GS_TOOLKIT_EXPORT
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdGsViewImpl::target
virtual OdGePoint3d target() const
OdGsNode::m_flags
OdUInt32 m_flags
Definition: GsNode.h:87
OdGsView::userGiContext
virtual OdGiContext * userGiContext() const =0
OdGsLayerNode::layerTraits
OdGiLayerTraitsData & layerTraits(OdUInt32 nVpId)
Definition: GsLayerNode.h:156
OdGiLayerTraitsTakerView::getEyeToModelTransform
virtual OdGeMatrix3d getEyeToModelTransform() const
Definition: GsLayerNode.h:202
OdVector::size
size_type size() const
Definition: OdVector.h:866
OdGiLayerTraitsTakerView::getViewportDcCorners
virtual void getViewportDcCorners(OdGePoint2d &lowerLeft, OdGePoint2d &upperRight) const
Definition: GsLayerNode.h:220
OdGiLayerTraitsTakerView::getEyeToWorldTransform
virtual OdGeMatrix3d getEyeToWorldTransform() const
Definition: GsLayerNode.h:204
OdGiLayerTraitsTakerView::getCameraLocation
virtual OdGePoint3d getCameraLocation() const
Definition: GsLayerNode.h:210
OdMutexPtr
Definition: ThreadsCounter.h:38
OdGsLayerNode::saveNodeState
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
OdGsLayerNode::isValidCache
bool isValidCache(OdUInt32 nVpId) const
OdGiRegenType
OdGiRegenType
Definition: GiCommonDraw.h:50
OdGsViewImpl::isBackClipped
virtual bool isBackClipped() const
OdGsViewImpl::upVector
virtual OdGeVector3d upVector() const
OdGsFiler
Definition: GsFiler.h:63
OdGsViewImpl::frontClip
virtual double frontClip() const
OdGsViewImpl::isFrontClipped
virtual bool isFrontClipped() const
OdGiLayerTraitsTakerView::regenType
virtual OdGiRegenType regenType() const
Definition: GsLayerNode.h:241
OdGiLayerTraitsTakerView::viewportObjectId
OdDbStub * viewportObjectId() const
Definition: GsLayerNode.h:198
OdGsViewImpl::getNumPixelsInUnitSquare
virtual void getNumPixelsInUnitSquare(const OdGePoint3d &givenWorldpt, OdGePoint2d &pixelArea, bool includePerspective=true) const
OdGiLayerTraitsData::m_flags
OdUInt32 m_flags
Definition: GiLayerTraitsData.h:122
OdGsViewImpl::backClip
virtual double backClip() const
OdGePoint2d
Definition: GePoint2d.h:60