CFx SDK Documentation  2023 SP0
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__
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
OdGiRegenType
Definition: GiCommonDraw.h:50
OdGiDeviationType
Definition: GiCommonDraw.h:64
ENodeType
Definition: GsBaseModel.h:65
@ kLayerNode
Definition: GsBaseModel.h:71
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdVector< OdGiLayerTraitsData, OdMemoryAllocator< OdGiLayerTraitsData > > OdGiLayerTraitsDataArray
Definition: GsLayerNode.h:36
#define NULL
Definition: GsProperties.h:177
unsigned int OdUInt32
short OdInt16
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:499
#define GETBIT(flags, bit)
Definition: OdaDefs.h:500
virtual OdUInt32 numberOfIsolines() const
virtual bool regenAbort() const
virtual void getNumPixelsInUnitSquare(const OdGePoint3d &pt, OdGePoint2d &pixelDensity, bool bUsePerspective=true) const
Definition: GsLayerNode.h:208
virtual OdGeVector3d viewDir() const
Definition: GsLayerNode.h:213
virtual OdGePoint3d getCameraLocation() const
Definition: GsLayerNode.h:210
virtual OdUInt32 numberOfIsolines() const
Definition: GsLayerNode.h:240
virtual bool layerVisible(OdDbStub *layerId) const
Definition: GsLayerNode.h:231
virtual bool regenAbort() const
Definition: GsLayerNode.h:242
virtual OdGeMatrix3d getEyeToWorldTransform() const
Definition: GsLayerNode.h:204
virtual OdInt16 acadWindowId() const
Definition: GsLayerNode.h:215
virtual OdGiContext * context() const
Definition: GsLayerNode.h:243
virtual bool doInversePerspective(OdGePoint3d &pt) const
Definition: GsLayerNode.h:207
bool isValidId(const OdUInt32 acgiId) const
Definition: GsLayerNode.h:197
virtual double deviation(const OdGiDeviationType type, const OdGePoint3d &pt) const
Definition: GsLayerNode.h:238
OdDbStub * viewportObjectId() const
Definition: GsLayerNode.h:198
OdGsViewImpl & m_view
Definition: GsLayerNode.h:245
OdUInt32 sequenceNumber() const
Definition: GsLayerNode.h:196
virtual OdGeVector3d getCameraUpVector() const
Definition: GsLayerNode.h:212
virtual double linetypeGenerationCriteria() const
Definition: GsLayerNode.h:230
virtual OdUInt32 viewportId() const
Definition: GsLayerNode.h:214
virtual bool getFrontAndBackClipValues(bool &clipFront, bool &clipBack, double &front, double &back) const
Definition: GsLayerNode.h:222
virtual double linetypeScaleMultiplier() const
Definition: GsLayerNode.h:229
virtual OdGeMatrix3d getWorldToEyeTransform() const
Definition: GsLayerNode.h:203
OdGiViewport & viewport() const
Definition: GsLayerNode.h:195
virtual bool doPerspective(OdGePoint3d &pt) const
Definition: GsLayerNode.h:206
virtual OdGeMatrix3d getModelToEyeTransform() const
Definition: GsLayerNode.h:201
OdGiLayerTraitsTakerView(OdGsViewImpl &view)
Definition: GsLayerNode.h:192
virtual OdGeMatrix3d getEyeToModelTransform() const
Definition: GsLayerNode.h:202
virtual OdGiRegenType regenType() const
Definition: GsLayerNode.h:241
virtual void release()
Definition: GsLayerNode.h:235
virtual bool isPerspective() const
Definition: GsLayerNode.h:205
virtual void getViewportDcCorners(OdGePoint2d &lowerLeft, OdGePoint2d &upperRight) const
Definition: GsLayerNode.h:220
virtual OdGePoint3d getCameraTarget() const
Definition: GsLayerNode.h:211
virtual void addRef()
Definition: GsLayerNode.h:234
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
OdGiLayerTraitsData & layerTraits(OdUInt32 nVpId)
Definition: GsLayerNode.h:156
bool isVpFrozen() const
Definition: GsLayerNode.h:171
void reserveLayerTraits(OdUInt32 nVpId)
OdGiLayerTraitsData m_layerTraits
Definition: GsLayerNode.h:69
void destroy()
Definition: GsLayerNode.h:83
OdGiLayerTraitsDataArray m_vpLayerTraits
Definition: GsLayerNode.h:70
virtual void update(OdGsBaseVectorizer &view)
void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *pParentIndex)
bool isDirty() const
Definition: GsLayerNode.h:122
virtual void display(OdGsDisplayContext &ctx)
bool isInvalidated() const
Definition: GsLayerNode.h:146
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
void setDirty(bool bDirty)
Definition: GsLayerNode.h:128
void propagateLayerChanges(OdGsViewImpl &view)
OdGsLayerNode * m_pNextChanged
Definition: GsLayerNode.h:73
virtual ENodeType nodeType() const
Definition: GsLayerNode.h:98
bool isFrozen() const
Definition: GsLayerNode.h:176
bool isValidCache(OdUInt32 nVpId) const
bool extents(OdGeExtents3d &) const
bool isVpDep() const
Definition: GsLayerNode.h:151
bool isTraitsCompatible(OdUInt32 nVpId1, OdUInt32 nVpId2) const
void setCacheUpToDate(OdUInt32 nVpId)
ODRX_DECLARE_MEMBERS(OdGsLayerNode)
bool isUpToDate(OdUInt32 nVpId) const
Definition: GsLayerNode.h:133
OdGsLayerNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
OdUInt32 m_flags
Definition: GsNode.h:87
@ kLastFlag
Definition: GsNode.h:84
virtual OdGiContext * userGiContext() const =0
OdUInt32 viewportId() const
Definition: GsViewImpl.h:240
const OdGeMatrix3d & eyeToWorldMatrix() const
Definition: GsViewImpl.h:913
virtual double getDeviation(const OdGiDeviationType deviationType, const OdGePoint3d &pointOnCurve, bool bRecalculate=false) const
virtual OdGePoint3d position() const
virtual OdGePoint3d target() const
bool isLayerVisible(OdDbStub *layerId) const
virtual void getNumPixelsInUnitSquare(const OdGePoint3d &givenWorldpt, OdGePoint2d &pixelArea, bool includePerspective=true) const
virtual OdGeVector3d upVector() const
double getLinetypeGenerationCriteria() const
virtual bool isPerspective() const
const OdGeMatrix3d & worldToEyeMatrix() const
Definition: GsViewImpl.h:923
OdDbStub * getViewportObjectId() const
Definition: GsViewImpl.h:244
const OdGeVector3d & eyeVector() const
Definition: GsViewImpl.h:395
virtual double frontClip() const
double getLinetypeScaleMultiplier() const
bool doPerspectivePt(OdGePoint3d &point) const
virtual bool isBackClipped() const
virtual bool isFrontClipped() const
bool doInversePerspectivePt(OdGePoint3d &point) const
bool isValidViewportId(const OdUInt32 vpId) const
OdGiRegenType getRegenType() const
Definition: GsViewImpl.h:388
virtual double backClip() const
void viewportDcCorners(OdGePoint2d &lower_left, OdGePoint2d &upper_right) const
virtual void clientViewInfo(OdGsClientViewInfo &viewInfo) const
size_type size() const
Definition: OdVector.h:866
GLenum GLint GLuint mask
Definition: gles2_ext.h:262
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
long acadWindowId
Definition: Gs.h:1031