CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GsBlockNode.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_BLOCK_NODE__
25#define __OD_GS_BLOCK_NODE__
26
27#include "TD_PackPush.h"
28
30#include "GsBlockRefNodeDesc.h"
31#define STL_USING_SET
32#define STL_USING_MAP
33#include "OdaSTL.h"
34#include "ThreadsCounter.h"
35
36class OdGsSharedRefDefinition;
37class OdGsReferenceImpl;
38
45{
46protected:
47 enum
48 {
51 };
52public:
53 enum
54 {
56 //NS: use this mask in invalidate() to invalidate extents of corresponding
57 //references when block is modified
58 };
59
61
62 OdGsBlockNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable,
63 bool bSetGsNode): OdGsNode(pModel, pUnderlyingDrawable), m_bModelTfDependent(0)
64 {
65 if(bSetGsNode)
66 setToDrawable(pUnderlyingDrawable);
67 }
69 {
70 if (isUnloaded())
71 {
72 // this block-node corresponds to block in xreffed db;
73 // here db can be unloaded, so prevent access to the associated block table record.
75 }
77 }
78
79 void setUnloaded(bool isUnloaded);
80 bool isUnloaded() const;
81 void setModelTfDependent(bool bOn);
82 bool isModelTfDependent() const;
83
84 virtual ENodeType nodeType() const { return kBlockNode; }
85
87
89 {
91 {
93 m_inserts.insert(pEntity);
94 }
95 else
96 {
97 m_inserts.insert(pEntity);
98 }
99 }
100
102 {
104 m_inserts.erase(pEntity);
105 if(!isUnloaded() || !m_inserts.empty())
106 return;
107 // this block-node corresponds to block in xreffed db;
108 // here db can be unloaded, so prevent access to the associated block table record.
110 baseModel()->detach(this);
111 }
112
118 void update(OdGsUpdateContext&, OdGsContainerNode*, OdSiSpatialIndex*)
119 {
120 ODA_ASSERT(false);
121 }
122
128 {
129 ODA_ASSERT(false);
130 }
131
141 {
142 ODA_ASSERT(false);
143 return false;
144 }
145
153 virtual void propagateLayerChanges(OdGsViewImpl& /*view*/);
154
155 void destroy();
156
158 {
159 m_sharedImp.destroy();
160 }
161
162 OdGsSharedRefDefinition* createDef(const OdGsBlockRefNodeDesc& d);
163 OdGsSharedRefDefinition* findCreateDef(const OdGsBlockRefNodeDesc& d);
164
165 void invalidateSharedSubents(OdUInt32 vpID, OdUInt32 nViewChanges);
166
167 void invalidateSharedRegenDraw(OdUInt32 vpID, const OdDbStub* layoutId);
169 void invalidateSharedAwareFlags(OdGsViewImpl* pView, OdUInt32 nViewChanges, const OdDbStub* layoutId);
170
171 void removeDef(OdGsSharedRefDefinition* pDef)
172 {
173 if(odThreadsCounter())
174 {
176 m_sharedImp.removeDef(pDef);
177 }
178 else
179 {
180 m_sharedImp.removeDef(pDef);
181 }
182 }
183 bool findDef(const OdGsSharedRefDefinition* pDef, OdGsBlockRefNodeDesc& d)
184 {
185 if(odThreadsCounter())
186 {
188 return m_sharedImp.findDef(pDef, d);
189 }
190 return m_sharedImp.findDef(pDef, d);
191 }
192
193 bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL) const;
194 bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL);
196
197protected:
199
200protected:
202 {
203 public:
204 ~ImpMap() { clear(); }
205 void clear();
206 void destroy();
207 OdGsSharedRefDefinition* findAt(const OdGsBlockRefNodeDesc& d)
208 {
209 _map::iterator it = m_map.find(d);
210 return (it == m_map.end() ? NULL : it->second);
211 }
212 OdGsSharedRefDefinition* insertAt(const OdGsBlockRefNodeDesc& d,
213 OdGsReferenceImpl* pImp);
215 void invalidateSubents(OdUInt32 vpID, OdUInt32 nViewChanges);
216 void invalidateRegenDraw(OdUInt32 vpID, const OdDbStub* layoutId);
217 void removeDef(OdGsSharedRefDefinition* pDef);
218 bool findDef(const OdGsSharedRefDefinition* pDef, OdGsBlockRefNodeDesc& d);
220 void invalidateAwareFlags(OdGsViewImpl* pView, OdUInt32 nViewChanges, const OdDbStub* layoutId, OdGsBaseModel* pModel);
222
223 public:
224 typedef std::map<OdGsBlockRefNodeDesc, OdGsSharedRefDefinition*,
225 std::less<OdGsBlockRefNodeDesc> > _map;
227 };
228
229protected:
230 typedef std::set<OdGsBlockReferenceNode*> Inserts;
231 typedef Inserts::iterator InsertIterator;
237};
238
243
244inline bool OdGsBlockNode::isUnloaded() const
245{
246 return GETBIT(m_flags, kUnloaded);
247}
248
250{
251 if(isModelTfDependent() == bOn)
252 return;
253#ifndef TD_SINGLE_THREAD
254 OdInterlockedExchangeAdd(&m_bModelTfDependent, bOn ? 1 : -1);
255#else
257#endif
258 if(bOn)
259 {
260 //don't keep content of m_sharedImp anymore. These definitions remain
261 //on inserts, if any, and will be released in the course of their update()
262 if(odThreadsCounter())
263 {
265 m_sharedImp.clear();
266 }
267 else
268 {
269 m_sharedImp.clear();
270 }
271 }
272}
273
275{
276 //atomic function is required, called in MT mode (update)
277#ifndef TD_SINGLE_THREAD
278 return OdInterlockedExchangeAdd(&const_cast<OdGsBlockNode*>(this)->m_bModelTfDependent, 0) != 0;
279#else
280 return m_bModelTfDependent;
281#endif
282}
283
284#include "TD_PackPop.h"
285
286#endif // __OD_GS_BLOCK_NODE__
#define ODA_ASSERT(exp)
Definition DebugStuff.h:57
ENodeType
Definition GsBaseModel.h:69
@ kBlockNode
Definition GsBaseModel.h:73
#define GS_TOOLKIT_EXPORT
Definition GsExport.h:37
@ kVpLastPropBit
bool isModelTfDependent(OdUInt32 flags)
unsigned int OdUInt32
#define SETBIT(flags, bit, value)
Definition OdaDefs.h:516
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
#define TD_AUTOLOCK_P_DEF(Mutex)
#define TD_AUTOLOCK_P(Mutex)
FIRSTDLL_EXPORT ThreadsCounter & odThreadsCounter()
virtual void detach(OdGsNode *pNode)
bool layersChanged(OdGsViewImpl &view, OdGsBaseModel *pModel)
void removeDef(OdGsSharedRefDefinition *pDef)
bool findDef(const OdGsSharedRefDefinition *pDef, OdGsBlockRefNodeDesc &d)
void invalidateRegenDraw(OdUInt32 vpID, const OdDbStub *layoutId)
void propagateLayerChangesStock()
void invalidateAwareFlags(OdGsViewImpl *pView, OdUInt32 nViewChanges, const OdDbStub *layoutId, OdGsBaseModel *pModel)
OdGsSharedRefDefinition * findAt(const OdGsBlockRefNodeDesc &d)
std::map< OdGsBlockRefNodeDesc, OdGsSharedRefDefinition *, std::less< OdGsBlockRefNodeDesc > > _map
OdGsSharedRefDefinition * insertAt(const OdGsBlockRefNodeDesc &d, OdGsReferenceImpl *pImp)
void invalidateSubents(OdUInt32 vpID, OdUInt32 nViewChanges)
Inserts::iterator InsertIterator
bool extents(OdGeExtents3d &) const
virtual void propagateLayerChanges(OdGsViewImpl &)
ODRX_DECLARE_MEMBERS(OdGsBlockNode)
void update(OdGsUpdateContext &, OdGsContainerNode *, OdSiSpatialIndex *)
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
OdGsSharedRefDefinition * createDef(const OdGsBlockRefNodeDesc &d)
void removeDef(OdGsSharedRefDefinition *pDef)
void clearInserts()
void invalidateSharedAwareFlags(OdGsViewImpl *pView, OdUInt32 nViewChanges, const OdDbStub *layoutId)
void invalidateSharedRegenDraw(OdUInt32 vpID, const OdDbStub *layoutId)
Inserts m_inserts
void setModelTfDependent(bool bOn)
bool isUnloaded() const
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *view, OdUInt32 mask)
OdMutexPtr m_insertsMt
OdGsSharedRefDefinition * findCreateDef(const OdGsBlockRefNodeDesc &d)
std::set< OdGsBlockReferenceNode * > Inserts
OdMutexPtr m_sharedMt
@ kInvalidateRefExtentsMask
Definition GsBlockNode.h:55
OdGsBlockNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode)
Definition GsBlockNode.h:62
void invalidateSharedSectionable()
void display(OdGsDisplayContext &)
void invalidateShared()
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
void release(OdGsBlockReferenceNode *pEntity)
volatile int m_bModelTfDependent
void setUnloaded(bool isUnloaded)
void addRef(OdGsBlockReferenceNode *pEntity)
Definition GsBlockNode.h:88
ImpMap m_sharedImp
virtual ENodeType nodeType() const
Definition GsBlockNode.h:84
void invalidateSharedSubents(OdUInt32 vpID, OdUInt32 nViewChanges)
bool findDef(const OdGsSharedRefDefinition *pDef, OdGsBlockRefNodeDesc &d)
bool isModelTfDependent() const
bool postprocessNodeLoading(OdGsFiler *pFiler)
friend class OdGsViewImpl
Definition GsNode.h:62
OdUInt32 m_flags
Definition GsNode.h:93
@ kSyncDrawable
Definition GsNode.h:85
@ kLastFlag
Definition GsNode.h:90
friend class OdGsBaseModel
Definition GsNode.h:61
void setToDrawable(const OdGiDrawable *pUnderlyingDrawable)
OdGsBaseModel * baseModel() const
Definition GsNode.h:449
OdGsNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable)
GLenum GLint GLuint mask
Definition gles2_ext.h:262