CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GsHighlightData.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 __ODGSHIGHLIGHTDATA_H__
25#define __ODGSHIGHLIGHTDATA_H__
26
27#define STL_USING_MAP
28#include "OdaSTL.h"
29
30#include "Gi/GiDrawable.h"
31#include "Gs.h"
32#include "GsSimpleParams.h"
33#include "TPtr.h"
34
35#include "TD_PackPush.h"
36
37class OdGsStateBranch;
40
41typedef std::map<OdGsMarker, OdGsSimpleParamPtr> OdGsMarkerSet;
42
44
49
58{
59 public:
64 {
65 kHighlightingBranch, // Highlighting state branch.
66 kVisibilityBranch, // Visibility state branch.
67 kTransformationBranch, // Transformation state branch.
68
69 kNumBranchTypes // Number of state branch types.
70 };
71 protected:
73 ~OdGsStateBranch() { if (m_pSetMarkers) { delete m_pSetMarkers; } } // Prevent direct delete of state branches
74 OdGsStateBranchPtrArray::iterator findChildImp(const OdDbStub *pDrawableId) const;
78
79 enum Flags
80 {
81 kPersistentId = (1 << 0) // true if m_pDrawableId stores OdDbStub pointer
82 };
83
84 OdRefCounter m_nRefCounter; // Shared ownership
85 OdUInt16 m_flags; // Bit flags
86 OdUInt16 m_type; // Branch type
87 const void *m_pDrawableId; // Persistent id or transient drawable pointer (depends from flag)
88 // @@@TODO: Add ability to set style index per selection marker.
89 OdGsSimpleParamPtr m_pData; // Additional data attached to specific branch type
90 OdGsStateBranchReactorPtr m_pReactor; // OdGsStateBranch reactor
91 OdGsStateBranchPtr m_pNext; // Next type of per-entity branch
92 mutable OdGsMarkerSet *m_pSetMarkers; // Set of selection markers
93 mutable OdGsStateBranchPtrArray m_aChild; // Sorted array of nested entities
94 // the sorting rule: first are transient entities with id 0, sorted by drw() value,
95 // next are persistent entities with id != 0, sorted by id()
96 public:
97 OdGsStateBranch(const OdDbStub* pDrawableId, BranchType branchType)
98 : m_nRefCounter(1)
100 , m_type((OdUInt16)branchType)
101 , m_pDrawableId(pDrawableId)
102 , m_pSetMarkers(NULL)
103 , m_aChild(0, 1)
104 {
105 }
106 OdGsStateBranch(const OdGiDrawable* pTransDrawable, BranchType branchType)
107 : m_nRefCounter(1)
108 , m_flags(0)
109 , m_type((OdUInt16)branchType)
110 , m_pDrawableId(pTransDrawable)
111 , m_pSetMarkers(NULL)
112 , m_aChild(0, 1)
113 {
114 }
115
116 static OdGsStateBranchPtr create(OdDbStub* pDrawableId, BranchType branchType,
117 OdGsMarker marker = kNullSubentIndex, const OdGsSimpleParam *pData = NULL);
118 static OdGsStateBranchPtr create(OdGiDrawable* pTransDrawable, BranchType branchType,
119 OdGsMarker marker = kNullSubentIndex, const OdGsSimpleParam *pData = NULL);
120 static void destroy(OdGsStateBranch *pStateBranch);
121
122 void addRef()
123 {
125 }
126 bool release()
127 {
129 if (!(--m_nRefCounter))
130 {
131 destroy(this);
132 return true;
133 }
134 return false;
135 }
136
137 // access to nested entities
138 const OdGsStateBranchPtrArray& aChild() const { return m_aChild; }
139 // access to subentities
140 const OdGsMarkerSet& markers() const { return initCheckMarkers(); }
141 OdUInt32 markersSize() const { return m_pSetMarkers ? (OdUInt32)m_pSetMarkers->size() : 0; }
142 bool markersEmpty() const { return m_pSetMarkers ? m_pSetMarkers->empty() : true; }
143
144 // add/remove/find nested entities info
145 OdGsStateBranch* addChild(OdDbStub* pDrawableId);
146 OdGsStateBranch* addChild(const OdGiDrawable* pTransDrawable);
147 void removeChild(const OdGsStateBranch* pChild);
148 OdGsStateBranch* findChild(const OdDbStub* pDrawableId) const; // search in a sorted array, fast
149 OdGsStateBranch* findChild(const OdGiDrawable* pTransDrawable) const; // search in a sorted array, fast
150
151 // add/remove/find subentities info
152 bool addMarker(OdGsMarker marker, const OdGsSimpleParam *pData = NULL, bool bDiffParamSet = false);
154 bool hasMarker(OdGsMarker marker) const; // search in a sorted array, fast
155 bool hasMarker(OdGsMarker marker, OdGsMarkerSet::const_iterator &itRev) const;
156
157 // access to the OdGsEntityNode data
158 const OdDbStub* id() const
159 {
160 return (GETBIT(m_flags, kPersistentId)) ? reinterpret_cast<const OdDbStub*>(m_pDrawableId) : NULL;
161 }
162 const OdGiDrawable* drw() const
163 {
164 return (!GETBIT(m_flags, kPersistentId)) ? reinterpret_cast<const OdGiDrawable*>(m_pDrawableId) : NULL;
165 }
166 bool isEmpty() const
167 {
168 return (!m_pSetMarkers || m_pSetMarkers->empty()) && aChild().isEmpty();
169 }
170
171 // access flags
172 bool isPersistentId() const { return GETBIT(m_flags, kPersistentId); }
173
174 BranchType type() const { return (BranchType)m_type; }
175
176 // chain
179 const OdGsStateBranch *nextTypeOfBranch() const { return m_pNext.get(); }
180
181 // reactor
182 void setReactor(OdGsStateBranchReactor *pReactor);
183 OdGsStateBranchReactor *reactor();
184
185 // style/transform
186 bool setData(const OdGsSimpleParam *pData);
187 void resetData() { setData(NULL); }
188 const OdGsSimpleParam *data() const { return m_pData.get(); }
189 bool hasData() const { return !m_pData.isNull(); }
190
191 const OdGsSimpleParam *markerData(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev = nullptr) const;
192 bool hasMarkerData(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev = nullptr) const;
193
194 OdUInt32 dataAsInt() const;
195 OdUInt32 markerDataAsInt(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev = nullptr) const;
196 const OdGeMatrix3d &dataAsMatrix() const;
197 const OdGeMatrix3d &markerDataAsMatrix(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev = nullptr) const;
198
199 static inline bool isValidMarker(OdGsMarker marker)
200 {
201 return (marker != kNullSubentIndex);
202 }
203};
204
213{
214 public:
215 virtual void onChildAdded(OdGsStateBranch *pStateBranch, OdGsStateBranch *pStateBranchAdded) = 0;
216 virtual void onChildRemoved(OdGsStateBranch *pStateBranch, OdGsStateBranch *pStateBranchRemoved) = 0;
217 virtual void onMarkerAdded(OdGsStateBranch *pStateBranch, OdGsMarker gsMarker, const OdGsSimpleParam *pData) = 0;
218 virtual void onMarkerRemoved(OdGsStateBranch *pStateBranch, OdGsMarker gsMarker) = 0;
219 virtual void onMarkerDataModified(OdGsStateBranch *pStateBranch, OdGsMarker gsMarker,
220 const OdGsSimpleParam *pPrevData, const OdGsSimpleParam *pData) = 0;
221 virtual void onDataModified(OdGsStateBranch *pStateBranch, const OdGsSimpleParam *pPrevData, const OdGsSimpleParam *pData) = 0;
222 virtual void onExtentsChanged(const OdGsCache *pGsNode, OdGsStateBranch *pStateBranch,
223 const OdGeExtents3d &extBefore, const OdGeExtents3d &extAfter) = 0;
224 virtual void onBranchDetach(const OdGsCache *pGsNode, OdGsStateBranch *pStateBranch) = 0;
225};
226
227// gcc3x template instantiation must be done after class declaration
230
232{
233 if (m_pData.get() != pData)
234 { OdGsSimpleParamPtr pPrevData = m_pData;
235 m_pData = pData;
236 if (!m_pReactor.isNull())
237 m_pReactor->onDataModified(this, pPrevData, pData);
238 return true;
239 }
240 return false;
241}
242
244{
245 if (type() == kHighlightingBranch && hasData())
246 return static_cast<const OdGsIntParam*>(data())->value();
247 return 0;
248}
249
250inline OdUInt32 OdGsStateBranch::markerDataAsInt(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev) const
251{ const OdGsSimpleParam *pParam = NULL;
252 if (type() == kHighlightingBranch && (pParam = markerData(marker, itRev)))
253 return static_cast<const OdGsIntParam*>(pParam)->value();
254 return 0;
255}
256
258{
259 if (type() == kTransformationBranch && hasData())
260 return static_cast<const OdGsMatrixParam*>(data())->value();
262}
263
264inline const OdGeMatrix3d &OdGsStateBranch::markerDataAsMatrix(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev) const
265{ const OdGsSimpleParam *pParam = NULL;
266 if (type() == kTransformationBranch && (pParam = markerData(marker, itRev)))
267 return static_cast<const OdGsMatrixParam*>(pParam)->value();
269}
270
272{
273 if (!m_pSetMarkers)
275 return *m_pSetMarkers;
276}
277
279{
280 if (m_pSetMarkers && m_pSetMarkers->empty())
281 { delete m_pSetMarkers; m_pSetMarkers = NULL; }
282}
283
292{
293 public:
294 static void attach(OdGsStateBranch *pStateBranch, const void *pModule, OdGsStateBranchReactor *pReactor);
295 static void detach(OdGsStateBranch *pStateBranch, const void *pModule);
296 static OdGsStateBranchReactor *getReactor(OdGsStateBranch *pStateBranch, const void *pModule);
297 static void setReactor(OdGsStateBranch *pStateBranch, const void *pModule, OdGsStateBranchReactor *pReactor);
298};
299
300#include "TD_PackPop.h"
301
302#endif // __ODGSHIGHLIGHTDATA_H__
#define ODA_ASSERT(exp)
Definition DebugStuff.h:57
const OdGsMarker kNullSubentIndex
Definition Gs.h:1655
#define GS_TOOLKIT_EXPORT
Definition GsExport.h:37
TPtr< OdGsStateBranch > OdGsStateBranchPtr
std::map< OdGsMarker, OdGsSimpleParamPtr > OdGsMarkerSet
OdSmartPtr< OdGsStateBranchReactor > OdGsStateBranchReactorPtr
OdArray< OdGsStateBranchPtr > OdGsStateBranchPtrArray
OdSmartPtr< OdGsSimpleParam > OdGsSimpleParamPtr
int OdRefCounter
Definition OdMutex.h:478
ptrdiff_t OdGsMarker
unsigned int OdUInt32
unsigned short OdUInt16
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
OdGsStateBranchPtr * iterator
Definition OdArray.h:838
static GE_STATIC_EXPORT const OdGeMatrix3d kIdentity
Definition GeMatrix3d.h:97
OdGsStateBranch(const OdGiDrawable *pTransDrawable, BranchType branchType)
OdGsStateBranch * nextTypeOfBranch()
OdGsStateBranch(const OdDbStub *pDrawableId, BranchType branchType)
void setNextTypeOfBranch(OdGsStateBranch *pNext)
OdGsStateBranch * addChild(OdDbStub *pDrawableId)
bool removeMarker(OdGsMarker marker)
OdGsSimpleParamPtr m_pData
OdGsStateBranchPtrArray::iterator findChildImp(const OdDbStub *pDrawableId) const
OdGsStateBranchPtr m_pNext
void removeChild(const OdGsStateBranch *pChild)
OdGsStateBranchPtrArray::iterator findChildImp(const OdGiDrawable *pTransDrawable) const
const OdGiDrawable * drw() const
bool markersEmpty() const
const OdGsSimpleParam * data() const
bool hasMarker(OdGsMarker marker, OdGsMarkerSet::const_iterator &itRev) const
OdGsStateBranchReactorPtr m_pReactor
bool hasData() const
bool isPersistentId() const
const OdGsSimpleParam * markerData(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev=nullptr) const
const OdGeMatrix3d & markerDataAsMatrix(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev=nullptr) const
BranchType type() const
OdRefCounter m_nRefCounter
OdGsStateBranchPtrArray m_aChild
const OdGeMatrix3d & dataAsMatrix() const
static OdGsStateBranchPtr create(OdDbStub *pDrawableId, BranchType branchType, OdGsMarker marker=kNullSubentIndex, const OdGsSimpleParam *pData=NULL)
bool hasMarkerData(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev=nullptr) const
const void * m_pDrawableId
OdUInt32 dataAsInt() const
static bool isValidMarker(OdGsMarker marker)
OdGsStateBranch * findChild(const OdDbStub *pDrawableId) const
OdGsStateBranch * addChild(const OdGiDrawable *pTransDrawable)
const OdDbStub * id() const
bool hasMarker(OdGsMarker marker) const
bool setData(const OdGsSimpleParam *pData)
static OdGsStateBranchPtr create(OdGiDrawable *pTransDrawable, BranchType branchType, OdGsMarker marker=kNullSubentIndex, const OdGsSimpleParam *pData=NULL)
OdGsMarkerSet * m_pSetMarkers
bool addMarker(OdGsMarker marker, const OdGsSimpleParam *pData=NULL, bool bDiffParamSet=false)
bool isEmpty() const
const OdGsStateBranch * nextTypeOfBranch() const
OdGsMarkerSet & initCheckMarkers() const
OdUInt32 markersSize() const
static void destroy(OdGsStateBranch *pStateBranch)
const OdGsMarkerSet & markers() const
void setReactor(OdGsStateBranchReactor *pReactor)
OdUInt32 markerDataAsInt(OdGsMarker marker, OdGsMarkerSet::const_iterator *itRev=nullptr) const
OdGsStateBranchReactor * reactor()
OdGsStateBranch * findChild(const OdGiDrawable *pTransDrawable) const
const OdGsStateBranchPtrArray & aChild() const
static void attach(OdGsStateBranch *pStateBranch, const void *pModule, OdGsStateBranchReactor *pReactor)
static void detach(OdGsStateBranch *pStateBranch, const void *pModule)
static OdGsStateBranchReactor * getReactor(OdGsStateBranch *pStateBranch, const void *pModule)
static void setReactor(OdGsStateBranch *pStateBranch, const void *pModule, OdGsStateBranchReactor *pReactor)
virtual void onDataModified(OdGsStateBranch *pStateBranch, const OdGsSimpleParam *pPrevData, const OdGsSimpleParam *pData)=0
virtual void onChildRemoved(OdGsStateBranch *pStateBranch, OdGsStateBranch *pStateBranchRemoved)=0
virtual void onMarkerRemoved(OdGsStateBranch *pStateBranch, OdGsMarker gsMarker)=0
virtual void onMarkerAdded(OdGsStateBranch *pStateBranch, OdGsMarker gsMarker, const OdGsSimpleParam *pData)=0
virtual void onChildAdded(OdGsStateBranch *pStateBranch, OdGsStateBranch *pStateBranchAdded)=0
virtual void onMarkerDataModified(OdGsStateBranch *pStateBranch, OdGsMarker gsMarker, const OdGsSimpleParam *pPrevData, const OdGsSimpleParam *pData)=0
virtual void onBranchDetach(const OdGsCache *pGsNode, OdGsStateBranch *pStateBranch)=0
virtual void onExtentsChanged(const OdGsCache *pGsNode, OdGsStateBranch *pStateBranch, const OdGeExtents3d &extBefore, const OdGeExtents3d &extAfter)=0
Definition TPtr.h:76
GLsizei const GLfloat * value
Definition gles2_ext.h:302