CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GsBlockNode.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_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 {
49 kUnloaded = OdGsNode::kLastFlag << 1,
50 kLastFlag = kUnloaded
51 };
52public:
53 enum
54 {
55 kInvalidateRefExtentsMask = (kVpLastPropBit << 1)
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.
74 SETBIT(m_flags, kSyncDrawable, false);
75 }
76 clearInserts();
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 {
92 TD_AUTOLOCK_P(m_insertsMt.get());
93 m_inserts.insert(pEntity);
94 }
95 else
96 {
97 m_inserts.insert(pEntity);
98 }
99 }
100
102 {
103 TD_AUTOLOCK_P_DEF(m_insertsMt);
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.
109 SETBIT(m_flags, kSyncDrawable, false);
110 baseModel()->detach(this);
111 }
112
118 void update(OdGsUpdateContext&, OdGsContainerNode*, OdSiSpatialIndex*)
119 {
120 ODA_ASSERT(false);
121 }
122
127 void display(OdGsDisplayContext&)
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 {
175 TD_AUTOLOCK_P(m_sharedMt.get());
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 {
187 TD_AUTOLOCK_P(m_sharedMt.get());
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
239inline void OdGsBlockNode::setUnloaded(bool isUnloaded)
240{
242}
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 {
266 }
267 else
268 {
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)
Definition: GsBlockNode.h:207
std::map< OdGsBlockRefNodeDesc, OdGsSharedRefDefinition *, std::less< OdGsBlockRefNodeDesc > > _map
Definition: GsBlockNode.h:225
OdGsSharedRefDefinition * insertAt(const OdGsBlockRefNodeDesc &d, OdGsReferenceImpl *pImp)
void invalidateSubents(OdUInt32 vpID, OdUInt32 nViewChanges)
Inserts::iterator InsertIterator
Definition: GsBlockNode.h:231
bool extents(OdGeExtents3d &) const
Definition: GsBlockNode.h:140
virtual void propagateLayerChanges(OdGsViewImpl &)
ODRX_DECLARE_MEMBERS(OdGsBlockNode)
void update(OdGsUpdateContext &, OdGsContainerNode *, OdSiSpatialIndex *)
Definition: GsBlockNode.h:118
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
OdGsSharedRefDefinition * createDef(const OdGsBlockRefNodeDesc &d)
void removeDef(OdGsSharedRefDefinition *pDef)
Definition: GsBlockNode.h:171
void clearInserts()
void invalidateSharedAwareFlags(OdGsViewImpl *pView, OdUInt32 nViewChanges, const OdDbStub *layoutId)
void invalidateSharedRegenDraw(OdUInt32 vpID, const OdDbStub *layoutId)
Inserts m_inserts
Definition: GsBlockNode.h:232
void setModelTfDependent(bool bOn)
Definition: GsBlockNode.h:249
bool isUnloaded() const
Definition: GsBlockNode.h:244
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *view, OdUInt32 mask)
OdMutexPtr m_insertsMt
Definition: GsBlockNode.h:235
OdGsSharedRefDefinition * findCreateDef(const OdGsBlockRefNodeDesc &d)
std::set< OdGsBlockReferenceNode * > Inserts
Definition: GsBlockNode.h:230
OdMutexPtr m_sharedMt
Definition: GsBlockNode.h:234
OdGsBlockNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode)
Definition: GsBlockNode.h:62
void invalidateSharedSectionable()
void display(OdGsDisplayContext &)
Definition: GsBlockNode.h:127
void invalidateShared()
Definition: GsBlockNode.h:157
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
void release(OdGsBlockReferenceNode *pEntity)
Definition: GsBlockNode.h:101
volatile int m_bModelTfDependent
Definition: GsBlockNode.h:236
void setUnloaded(bool isUnloaded)
Definition: GsBlockNode.h:239
void addRef(OdGsBlockReferenceNode *pEntity)
Definition: GsBlockNode.h:88
ImpMap m_sharedImp
Definition: GsBlockNode.h:233
virtual ENodeType nodeType() const
Definition: GsBlockNode.h:84
void invalidateSharedSubents(OdUInt32 vpID, OdUInt32 nViewChanges)
bool findDef(const OdGsSharedRefDefinition *pDef, OdGsBlockRefNodeDesc &d)
Definition: GsBlockNode.h:183
bool isModelTfDependent() const
Definition: GsBlockNode.h:274
bool postprocessNodeLoading(OdGsFiler *pFiler)
OdUInt32 m_flags
Definition: GsNode.h:91
@ kLastFlag
Definition: GsNode.h:88
void setToDrawable(const OdGiDrawable *pUnderlyingDrawable)
OdGsBaseModel * baseModel() const
Definition: GsNode.h:413
OdMutex * get()
GLenum GLint GLuint mask
Definition: gles2_ext.h:262