CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GsLayerNode.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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
40
44{
45 //DOM-IGNORE-BEGIN
46 enum
47 {
48 kDirty = OdGsNode::kLastFlag << 1,
49 kVpDep = OdGsNode::kLastFlag << 2,
50 kVpFrozen = OdGsNode::kLastFlag << 3,
51
52 kLastFlag = kVpFrozen
53 };
54 //DOM-IGNORE-END
55protected:
63 void update(OdGsUpdateContext& ctx, OdGsContainerNode* pParent,
64 OdSiSpatialIndex* pParentIndex);
65
70 virtual void display(OdGsDisplayContext& ctx);
71
77 bool extents(OdGeExtents3d& ) const;
78
88
97
101
102 friend class OdGsBaseModel;
104public:
106
114 OdGsLayerNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable, bool bSetGsNode = true);
115
120
124 void destroy() {}
125
132 OdGiLayerTraitsData& layerTraits(OdUInt32 nVpId, bool bVpFrozen = true);
133
140 const OdGiLayerTraitsData& layerTraits(OdUInt32 nVpId, bool bVpFrozen = true) const;
141
143
144 bool isDirty() const;
145 void setDirty(bool bDirty);
146
154 bool isUpToDate(OdUInt32 nVpId) const;
155
163 bool isValidCache(OdUInt32 nVpId) const;
164
171
178 bool isInvalidated() const;
179
186 bool isVpDep() const;
187
191 virtual ENodeType nodeType() const { return kLayerNode; }
192
199 inline bool isVpFrozen() const;
200
207 inline bool isFrozen() const;
208
217
223 virtual void update(OdGsBaseVectorizer& view);
224
240 bool isTraitsCompatible(OdUInt32 nVpId1, OdUInt32 nVpId2) const;
241
250 bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL) const;
251
260 bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL);
261private:
263 OdGsEmptyMetafileCache m_emfCache;
264 OdMutexPtr m_mt;
265};
266
267inline bool
269{
270 return GETBIT(m_flags, kDirty);
271}
272
273inline void
275{
276 SETBIT(m_flags, kDirty, bDirty);
277}
278
279inline bool OdGsLayerNode::isUpToDate(OdUInt32 nVpId) const
280{
281 if(isInvalidated())
282 return false;
283 if(isVpDep())
284 {
285 if(nVpId > 0 && m_vpLayerTraits.size() < nVpId)
286 return false;
287 return !GETBIT(layerTraits(nVpId, false).flags(), 0x80000000);
288 }
289 return !GETBIT(layerTraits(0, false).flags(), 0x80000000);
290}
291
293{
294 return (m_layerTraits.m_flags == 0xFFFFFFFF) && !m_vpLayerTraits.size();
295}
296
297inline bool OdGsLayerNode::isVpDep() const
298{
299 return GETBIT(m_flags, kVpDep);
300}
301
303{
304 return const_cast<OdGiLayerTraitsData&>(static_cast<const OdGsLayerNode*>(this)->layerTraits(nVpId, bVpFrozen));
305}
306
307inline const OdGiLayerTraitsData& OdGsLayerNode::layerTraits(OdUInt32 nVpId, bool bVpFrozen) const
308{
309 if (isVpFrozen() && bVpFrozen && m_vpFrozenTraits.size() > nVpId && m_vpFrozenTraits[nVpId].m_flags != 0xFFFFFFFF)
310 return m_vpFrozenTraits[nVpId];
311 if(isVpDep() && nVpId > 0)
312 {
313 ODA_ASSERT(m_vpLayerTraits.size() >= nVpId);
314 return m_vpLayerTraits[--nVpId];
315 }
316 return m_layerTraits;
317}
318
319inline bool OdGsLayerNode::isVpFrozen() const
320{
321 return GETBIT(m_flags, kVpFrozen);
322}
323
324inline bool OdGsLayerNode::isFrozen() const
325{
326 return m_layerTraits.isFrozen();
327}
328
336{
338 public:
346 : m_view(view) { if (pInheritTaker) reset(*pInheritTaker); }
347
348
350
351
358 OdGiViewport& viewport() const { return *const_cast<OdGiLayerTraitsTakerView*>(this); }
359
364 OdUInt32 sequenceNumber() const { return 0; }
365
374 bool isValidId(const OdUInt32 acgiId) const { return m_view.isValidViewportId(acgiId); }
375
382 OdDbStub* viewportObjectId() const { return m_view.getViewportObjectId(); }
383
384
386
387
395
403
410 virtual OdGeMatrix3d getWorldToEyeTransform() const { return m_view.worldToEyeMatrix(); }
411
418 virtual OdGeMatrix3d getEyeToWorldTransform() const { return m_view.eyeToWorldMatrix(); }
419
425 virtual bool isPerspective() const { return m_view.isPerspective(); }
426
437 virtual bool doPerspective(OdGePoint3d& pt) const { return m_view.doPerspectivePt(pt); }
438
449 virtual bool doInversePerspective(OdGePoint3d& pt) const { return m_view.doInversePerspectivePt(pt); }
450
462 virtual void getNumPixelsInUnitSquare(const OdGePoint3d& pt, OdGePoint2d& pixelDensity, bool bUsePerspective = true) const
463 { m_view.getNumPixelsInUnitSquare(pt, pixelDensity, bUsePerspective); }
464
468 virtual OdGePoint3d getCameraLocation() const { return m_view.position(); }
469
473 virtual OdGePoint3d getCameraTarget() const { return m_view.target(); }
474
478 virtual OdGeVector3d getCameraUpVector() const { return m_view.upVector(); }
479
483 virtual OdGeVector3d viewDir() const { return m_view.eyeVector(); }
484
491 virtual OdUInt32 viewportId() const { return m_view.viewportId(); }
492
499 virtual OdInt16 acadWindowId() const
501 m_view.clientViewInfo(vi);
502 return OdInt16(vi.acadWindowId);
503 }
504
515 virtual void getViewportDcCorners(OdGePoint2d& lowerLeft, OdGePoint2d& upperRight) const
516 { m_view.viewportDcCorners(lowerLeft, upperRight); }
517
533 virtual bool getFrontAndBackClipValues(bool& clipFront, bool& clipBack, double& front, double& back) const
534 { clipFront = m_view.isFrontClipped();
535 clipBack = m_view.isBackClipped();
536 front = m_view.frontClip();
537 back = m_view.backClip();
538 return (clipFront || clipBack);
539 }
540
544 virtual double linetypeScaleMultiplier() const { return m_view.getLinetypeScaleMultiplier(); }
545
553 virtual double linetypeGenerationCriteria() const { return m_view.getLinetypeGenerationCriteria(); }
554
562 virtual bool layerVisible(OdDbStub* layerId) const { return m_view.isLayerVisible(layerId); }
563
564
566
567
571 virtual void addRef() override {}
572
576 virtual void release() ODRX_NOEXCEPT override {}
577
578
580
581
605 virtual double deviation(const OdGiDeviationType type, const OdGePoint3d& pt) const
606 { return m_view.getDeviation(type, pt, true); }
607
616 virtual OdUInt32 numberOfIsolines() const { return m_view.userGiContext()->numberOfIsolines(); }
617
635 virtual OdGiRegenType regenType() const { return m_view.getRegenType(); }
636
643 virtual bool regenAbort() const { return m_view.userGiContext()->regenAbort(); }
644
648 virtual OdGiContext* context() const { return m_view.userGiContext(); }
649 protected:
651};
652
653// Include inline OdGsEmptyMetafileCache methods
654#ifndef __OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__
655#define __OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__
656#include "GsEmptyMetafileCache.h"
657#endif
658//
659
660#include "TD_PackPop.h"
661
662#endif // __OD_GS_LAYER_NODE__
#define ODA_ASSERT(exp)
Definition DebugStuff.h:57
OdGiRegenType
OdGiDeviationType
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:39
#define ODRX_USING_HEAP_OPERATORS(T)
Definition OdHeap.h:124
unsigned int OdUInt32
short OdInt16
#define ODRX_NOEXCEPT
#define SETBIT(flags, bit, value)
Definition OdaDefs.h:516
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
void reset(const OdGiLayerTraitsData &ltData=OdGiLayerTraitsData())
virtual void getNumPixelsInUnitSquare(const OdGePoint3d &pt, OdGePoint2d &pixelDensity, bool bUsePerspective=true) const
OdGiLayerTraitsTakerView(OdGsViewImpl &view, const OdGiLayerTraitsTaker *pInheritTaker=NULL)
virtual OdGeVector3d viewDir() const
virtual OdGePoint3d getCameraLocation() const
virtual OdUInt32 numberOfIsolines() const
virtual void addRef() override
virtual bool layerVisible(OdDbStub *layerId) const
virtual bool regenAbort() const
virtual OdGeMatrix3d getEyeToWorldTransform() const
virtual OdInt16 acadWindowId() const
virtual bool doInversePerspective(OdGePoint3d &pt) const
bool isValidId(const OdUInt32 acgiId) const
virtual double deviation(const OdGiDeviationType type, const OdGePoint3d &pt) const
OdGiViewport & viewport() const
OdUInt32 sequenceNumber() const
virtual OdGeVector3d getCameraUpVector() const
virtual double linetypeGenerationCriteria() const
OdDbStub * viewportObjectId() const
virtual OdUInt32 viewportId() const
virtual OdGiContext * context() const
virtual bool getFrontAndBackClipValues(bool &clipFront, bool &clipBack, double &front, double &back) const
virtual double linetypeScaleMultiplier() const
virtual void release() ODRX_NOEXCEPT override
virtual OdGeMatrix3d getWorldToEyeTransform() const
virtual bool doPerspective(OdGePoint3d &pt) const
virtual OdGeMatrix3d getModelToEyeTransform() const
virtual OdGeMatrix3d getEyeToModelTransform() const
virtual OdGiRegenType regenType() const
virtual bool isPerspective() const
virtual void getViewportDcCorners(OdGePoint2d &lowerLeft, OdGePoint2d &upperRight) const
virtual OdGePoint3d getCameraTarget() const
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
bool isVpFrozen() const
friend class OdGsEmptyMetafileCache
OdGiLayerTraitsDataArray m_vpFrozenTraits
void reserveLayerTraits(OdUInt32 nVpId)
OdGiLayerTraitsData m_layerTraits
Definition GsLayerNode.h:98
OdGiLayerTraitsDataArray m_vpLayerTraits
Definition GsLayerNode.h:99
virtual void update(OdGsBaseVectorizer &view)
friend class OdGsBaseModel
void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *pParentIndex)
bool isDirty() const
virtual void display(OdGsDisplayContext &ctx)
OdGiLayerTraitsData & layerTraits(OdUInt32 nVpId, bool bVpFrozen=true)
bool isInvalidated() const
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
void setDirty(bool bDirty)
void propagateLayerChanges(OdGsViewImpl &view)
OdGsLayerNode * m_pNextChanged
virtual ENodeType nodeType() const
bool isFrozen() const
bool isValidCache(OdUInt32 nVpId) const
bool extents(OdGeExtents3d &) const
bool isVpDep() const
void updateVpFrozen(OdGsViewImpl *pView)
bool isTraitsCompatible(OdUInt32 nVpId1, OdUInt32 nVpId2) const
void setCacheUpToDate(OdUInt32 nVpId)
ODRX_DECLARE_MEMBERS(OdGsLayerNode)
bool isUpToDate(OdUInt32 nVpId) const
OdGsLayerNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
friend class OdGsViewImpl
Definition GsNode.h:62
OdUInt32 m_flags
Definition GsNode.h:93
@ kLastFlag
Definition GsNode.h:90
OdGsNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable)
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:1237