CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GsLayerNode.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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"
32#include "ThreadsCounter.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 };
50protected:
58 void update(OdGsUpdateContext& ctx, OdGsContainerNode* pParent,
59 OdSiSpatialIndex* pParentIndex);
60
65 virtual void display(OdGsDisplayContext& ctx);
66
72 bool extents(OdGeExtents3d& ) const;
73
83
92
95
96 friend class OdGsBaseModel;
98public:
100
108 OdGsLayerNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable, bool bSetGsNode = true);
109
114
118 void destroy() {}
119
125 OdGiLayerTraitsData& layerTraits(OdUInt32 nVpId);
126
132 const OdGiLayerTraitsData& layerTraits(OdUInt32 nVpId) const;
133
135
136 bool isDirty() const;
137 void setDirty(bool bDirty);
138
146 bool isUpToDate(OdUInt32 nVpId) const;
147
155 bool isValidCache(OdUInt32 nVpId) const;
156
163
170 bool isInvalidated() const;
171
178 bool isVpDep() const;
179
183 virtual ENodeType nodeType() const { return kLayerNode; }
184
191 inline bool isVpFrozen() const;
192
199 inline bool isFrozen() const;
200
209
215 virtual void update(OdGsBaseVectorizer& view);
216
232 bool isTraitsCompatible(OdUInt32 nVpId1, OdUInt32 nVpId2) const;
233
242 bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL) const;
243
252 bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL);
253private:
255 OdGsEmptyMetafileCache m_emfCache;
256 OdMutexPtr m_mt;
257};
258
259inline bool
261{
262 return GETBIT(m_flags, kDirty);
263}
264
265inline void
267{
268 SETBIT(m_flags, kDirty, bDirty);
269}
270
271inline bool OdGsLayerNode::isUpToDate(OdUInt32 nVpId) const
272{
273 if(isInvalidated())
274 return false;
275 if(isVpDep())
276 {
277 if(nVpId > 0 && m_vpLayerTraits.size() < nVpId)
278 return false;
279 return !GETBIT(layerTraits(nVpId).flags(), 0x80000000);
280 }
281 return !GETBIT(layerTraits(0).flags(), 0x80000000);
282}
283
285{
286 return (m_layerTraits.m_flags == 0xFFFFFFFF) && !m_vpLayerTraits.size();
287}
288
289inline bool OdGsLayerNode::isVpDep() const
290{
291 return GETBIT(m_flags, kVpDep);
292}
293
295{
296 return const_cast<OdGiLayerTraitsData&>(static_cast<const OdGsLayerNode*>(this)->layerTraits(nVpId));
297}
298
300{
301 if(isVpDep() && nVpId > 0)
302 {
303 ODA_ASSERT(m_vpLayerTraits.size() >= nVpId);
304 return m_vpLayerTraits[--nVpId];
305 }
306 return m_layerTraits;
307}
308
309inline bool OdGsLayerNode::isVpFrozen() const
310{
311 return GETBIT(m_flags, kVpFrozen);
312}
313
314inline bool OdGsLayerNode::isFrozen() const
315{
316 return m_layerTraits.isFrozen();
317}
318
326{
328 public:
336 : m_view(view) { if (pInheritTaker) reset(*pInheritTaker); }
337
338
348 OdGiViewport& viewport() const { return *const_cast<OdGiLayerTraitsTakerView*>(this); }
349
354 OdUInt32 sequenceNumber() const { return 0; }
355
364 bool isValidId(const OdUInt32 acgiId) const { return m_view.isValidViewportId(acgiId); }
365
372 OdDbStub* viewportObjectId() const { return m_view.getViewportObjectId(); }
373
374
385
393
401
409
415 virtual bool isPerspective() const { return m_view.isPerspective(); }
416
427 virtual bool doPerspective(OdGePoint3d& pt) const { return m_view.doPerspectivePt(pt); }
428
439 virtual bool doInversePerspective(OdGePoint3d& pt) const { return m_view.doInversePerspectivePt(pt); }
440
452 virtual void getNumPixelsInUnitSquare(const OdGePoint3d& pt, OdGePoint2d& pixelDensity, bool bUsePerspective = true) const
453 { m_view.getNumPixelsInUnitSquare(pt, pixelDensity, bUsePerspective); }
454
458 virtual OdGePoint3d getCameraLocation() const { return m_view.position(); }
459
463 virtual OdGePoint3d getCameraTarget() const { return m_view.target(); }
464
468 virtual OdGeVector3d getCameraUpVector() const { return m_view.upVector(); }
469
473 virtual OdGeVector3d viewDir() const { return m_view.eyeVector(); }
474
481 virtual OdUInt32 viewportId() const { return m_view.viewportId(); }
482
489 virtual OdInt16 acadWindowId() const
492 return OdInt16(vi.acadWindowId);
493 }
494
505 virtual void getViewportDcCorners(OdGePoint2d& lowerLeft, OdGePoint2d& upperRight) const
506 { m_view.viewportDcCorners(lowerLeft, upperRight); }
507
523 virtual bool getFrontAndBackClipValues(bool& clipFront, bool& clipBack, double& front, double& back) const
524 { clipFront = m_view.isFrontClipped();
525 clipBack = m_view.isBackClipped();
526 front = m_view.frontClip();
527 back = m_view.backClip();
528 return (clipFront || clipBack);
529 }
530
534 virtual double linetypeScaleMultiplier() const { return m_view.getLinetypeScaleMultiplier(); }
535
544
552 virtual bool layerVisible(OdDbStub* layerId) const { return m_view.isLayerVisible(layerId); }
553
554
561 virtual void addRef() {}
562
566 virtual void release() {}
567
568
595 virtual double deviation(const OdGiDeviationType type, const OdGePoint3d& pt) const
596 { return m_view.getDeviation(type, pt, true); }
597
607
625 virtual OdGiRegenType regenType() const { return m_view.getRegenType(); }
626
633 virtual bool regenAbort() const { return m_view.userGiContext()->regenAbort(); }
634
638 virtual OdGiContext* context() const { return m_view.userGiContext(); }
639 protected:
641};
642
643// Include inline OdGsEmptyMetafileCache methods
644#ifndef __OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__
645#define __OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__
646#include "GsEmptyMetafileCache.h"
647#endif
648//
649
650#include "TD_PackPop.h"
651
652#endif // __OD_GS_LAYER_NODE__
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
OdGiRegenType
Definition: GiCommonDraw.h:51
OdGiDeviationType
Definition: GiCommonDraw.h:65
ENodeType
Definition: GsBaseModel.h:69
@ kLayerNode
Definition: GsBaseModel.h:75
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdVector< OdGiLayerTraitsData, OdMemoryAllocator< OdGiLayerTraitsData > > OdGiLayerTraitsDataArray
Definition: GsLayerNode.h:36
#define ODRX_USING_HEAP_OPERATORS(T)
Definition: OdHeap.h:140
unsigned int OdUInt32
short OdInt16
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:516
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
virtual OdUInt32 numberOfIsolines() const
virtual bool regenAbort() const
void reset(const OdGiLayerTraitsData &ltData=OdGiLayerTraitsData())
virtual void getNumPixelsInUnitSquare(const OdGePoint3d &pt, OdGePoint2d &pixelDensity, bool bUsePerspective=true) const
Definition: GsLayerNode.h:452
OdGiLayerTraitsTakerView(OdGsViewImpl &view, const OdGiLayerTraitsTaker *pInheritTaker=NULL)
Definition: GsLayerNode.h:335
virtual OdGeVector3d viewDir() const
Definition: GsLayerNode.h:473
virtual OdGePoint3d getCameraLocation() const
Definition: GsLayerNode.h:458
virtual OdUInt32 numberOfIsolines() const
Definition: GsLayerNode.h:606
virtual bool layerVisible(OdDbStub *layerId) const
Definition: GsLayerNode.h:552
virtual bool regenAbort() const
Definition: GsLayerNode.h:633
virtual OdGeMatrix3d getEyeToWorldTransform() const
Definition: GsLayerNode.h:408
virtual OdInt16 acadWindowId() const
Definition: GsLayerNode.h:489
virtual bool doInversePerspective(OdGePoint3d &pt) const
Definition: GsLayerNode.h:439
bool isValidId(const OdUInt32 acgiId) const
Definition: GsLayerNode.h:364
virtual double deviation(const OdGiDeviationType type, const OdGePoint3d &pt) const
Definition: GsLayerNode.h:595
OdGiViewport & viewport() const
Definition: GsLayerNode.h:348
OdGsViewImpl & m_view
Definition: GsLayerNode.h:640
OdUInt32 sequenceNumber() const
Definition: GsLayerNode.h:354
virtual OdGeVector3d getCameraUpVector() const
Definition: GsLayerNode.h:468
virtual double linetypeGenerationCriteria() const
Definition: GsLayerNode.h:543
OdDbStub * viewportObjectId() const
Definition: GsLayerNode.h:372
virtual OdUInt32 viewportId() const
Definition: GsLayerNode.h:481
virtual OdGiContext * context() const
Definition: GsLayerNode.h:638
virtual bool getFrontAndBackClipValues(bool &clipFront, bool &clipBack, double &front, double &back) const
Definition: GsLayerNode.h:523
virtual double linetypeScaleMultiplier() const
Definition: GsLayerNode.h:534
virtual OdGeMatrix3d getWorldToEyeTransform() const
Definition: GsLayerNode.h:400
virtual bool doPerspective(OdGePoint3d &pt) const
Definition: GsLayerNode.h:427
virtual OdGeMatrix3d getModelToEyeTransform() const
Definition: GsLayerNode.h:384
virtual OdGeMatrix3d getEyeToModelTransform() const
Definition: GsLayerNode.h:392
virtual OdGiRegenType regenType() const
Definition: GsLayerNode.h:625
virtual void release()
Definition: GsLayerNode.h:566
virtual bool isPerspective() const
Definition: GsLayerNode.h:415
virtual void getViewportDcCorners(OdGePoint2d &lowerLeft, OdGePoint2d &upperRight) const
Definition: GsLayerNode.h:505
virtual OdGePoint3d getCameraTarget() const
Definition: GsLayerNode.h:463
virtual void addRef()
Definition: GsLayerNode.h:561
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
OdGiLayerTraitsData & layerTraits(OdUInt32 nVpId)
Definition: GsLayerNode.h:294
bool isVpFrozen() const
Definition: GsLayerNode.h:309
void reserveLayerTraits(OdUInt32 nVpId)
OdGiLayerTraitsData m_layerTraits
Definition: GsLayerNode.h:93
void destroy()
Definition: GsLayerNode.h:118
OdGiLayerTraitsDataArray m_vpLayerTraits
Definition: GsLayerNode.h:94
virtual void update(OdGsBaseVectorizer &view)
void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *pParentIndex)
bool isDirty() const
Definition: GsLayerNode.h:260
virtual void display(OdGsDisplayContext &ctx)
bool isInvalidated() const
Definition: GsLayerNode.h:284
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
void setDirty(bool bDirty)
Definition: GsLayerNode.h:266
void propagateLayerChanges(OdGsViewImpl &view)
OdGsLayerNode * m_pNextChanged
Definition: GsLayerNode.h:97
virtual ENodeType nodeType() const
Definition: GsLayerNode.h:183
bool isFrozen() const
Definition: GsLayerNode.h:314
bool isValidCache(OdUInt32 nVpId) const
bool extents(OdGeExtents3d &) const
bool isVpDep() const
Definition: GsLayerNode.h:289
void updateVpFrozen(OdGsViewImpl *pView)
bool isTraitsCompatible(OdUInt32 nVpId1, OdUInt32 nVpId2) const
void setCacheUpToDate(OdUInt32 nVpId)
ODRX_DECLARE_MEMBERS(OdGsLayerNode)
bool isUpToDate(OdUInt32 nVpId) const
Definition: GsLayerNode.h:271
OdGsLayerNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
OdUInt32 m_flags
Definition: GsNode.h:91
@ kLastFlag
Definition: GsNode.h:88
virtual OdGiContext * userGiContext() const =0
OdUInt32 viewportId() const
Definition: GsViewImpl.h:1119
virtual OdGiRegenType getRegenType() const
Definition: GsViewImpl.h:1439
const OdGeMatrix3d & eyeToWorldMatrix() const
Definition: GsViewImpl.h:2328
virtual double getDeviation(const OdGiDeviationType deviationType, const OdGePoint3d &pointOnCurve, bool bRecalculate=false) const
virtual OdGePoint3d position() const
virtual OdGePoint3d target() const
OdDbStub * getViewportObjectId() const
Definition: GsViewImpl.h:1134
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:2338
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
virtual double backClip() const
void viewportDcCorners(OdGePoint2d &lower_left, OdGePoint2d &upper_right) const
virtual void clientViewInfo(OdGsClientViewInfo &viewInfo) const
const OdGeVector3d & eyeVector() const
Definition: GsViewImpl.h:1449
size_type size() const
Definition: OdVector.h:1204
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:1211