CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GsHighlightData.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 __ODGSHIGHLIGHTDATA_H__
25#define __ODGSHIGHLIGHTDATA_H__
26
27#define STL_USING_SET
28#include "OdaSTL.h"
29
30#include "GsMarkerArray.h"
31#include "Gi/GiDrawable.h"
32#include "Gs.h"
33#include "TPtr.h"
34
35#include "TD_PackPush.h"
36
37class OdGsStateBranch;
40
41typedef std::set<OdGsMarker> OdGsMarkerSet;
42
44
49
58{
59 protected:
61
62 OdRefCounter m_nRefCounter; // shared ownership
63 const void* m_pDrawableId; // persistent id or transient drawable pointer (depends from flag)
64 bool m_bPersistentId; // true if m_pDrawableId stores OdDbStub pointer
65 OdUInt32 m_nStyle; // Style index
66 // @@@TODO: Add ability to set style index per selection marker.
67 OdGsStateBranchReactorPtr m_pReactor; // OdGsStateBranch reactor
68 OdGsMarkerSet m_setMarkers; // Set of markers
69 OdGsStateBranchPtrArray m_aChild; // sorted array of nested entities
70 // the sorting rule: first are transient entities with id 0, sorted by drw() value,
71 // next are persistent entities with id != 0, sorted by id()
72 public:
73 OdGsStateBranch(const OdDbStub* pDrawableId)
74 : m_nRefCounter(1)
75 , m_pDrawableId(pDrawableId)
76 , m_bPersistentId(true)
77 , m_nStyle(0)
78 , m_aChild(0, 1)
79 {
80 }
81 OdGsStateBranch(const OdGiDrawable* pTransDrawable)
82 : m_nRefCounter(1)
83 , m_pDrawableId(pTransDrawable)
84 , m_bPersistentId(false)
85 , m_nStyle(0)
86 , m_aChild(0, 1)
87 {
88 }
89
90 static OdGsStateBranchPtr create(OdDbStub* pDrawableId, OdGsMarker marker);
91 static OdGsStateBranchPtr create(OdGiDrawable* pTransDrawable, OdGsMarker marker);
92
93 void addRef()
94 {
95 ++m_nRefCounter;
96 }
97 void release()
98 {
99 ODA_ASSERT((m_nRefCounter > 0));
100 if (!(--m_nRefCounter))
101 delete this;
102 }
103
104 // access to nested entities
105 const OdGsStateBranchPtrArray& aChild() const { return m_aChild; }
106 // access to subentities
107 const OdGsMarkerSet& markers() const { return m_setMarkers; }
108 OdUInt32 markersSize() const { return (OdUInt32)m_setMarkers.size(); }
109 bool markersEmpty() const { return m_setMarkers.empty(); }
110
111 // add/remove/find nested entities info
112 OdGsStateBranch* addChild(OdDbStub* pDrawableId);
113 OdGsStateBranch* addChild(const OdGiDrawable* pTransDrawable);
114 void removeChild(const OdGsStateBranch* pChild);
115 OdGsStateBranch* findChild(const OdDbStub* pDrawableId); // search in a sorted array, fast
116 OdGsStateBranch* findChild(const OdGiDrawable* pTransDrawable); // search in a sorted array, fast
117
118 // add/remove/find subentities info
119 bool addMarker(OdGsMarker marker);
121 bool hasMarker(OdGsMarker marker) const; // search in a sorted array, fast
122
123 // access to the OdGsEntityNode data
124 const OdDbStub* id() const
125 {
126 return (m_bPersistentId) ? reinterpret_cast<const OdDbStub*>(m_pDrawableId) : NULL;
127 }
128 const OdGiDrawable* drw() const
129 {
130 return (!m_bPersistentId) ? reinterpret_cast<const OdGiDrawable*>(m_pDrawableId) : NULL;
131 }
132 bool isEmpty() const
133 {
134 return m_setMarkers.empty() && aChild().isEmpty();
135 }
136
137 // access flags
138 bool isPersistentId() const { return m_bPersistentId; }
139
140 // reactor
141 void setReactor(OdGsStateBranchReactor *pReactor);
142 OdGsStateBranchReactor *reactor();
143
144 // style
145 void setStyle(OdUInt32 nStyle);
146 OdUInt32 style() const { return m_nStyle; }
147 bool hasStyle() const { return m_nStyle != 0; }
148
149 static inline bool isValidMarker(OdGsMarker marker)
150 {
151 return (marker != kNullSubentIndex);
152 }
153};
154
163{
164 public:
165 virtual void onChildAdded(OdGsStateBranch *pHlBranch, OdGsStateBranch *pHlBranchAdded) = 0;
166 virtual void onChildRemoved(OdGsStateBranch *pHlBranch, OdGsStateBranch *pHlBranchRemoved) = 0;
167 virtual void onMarkerAdded(OdGsStateBranch *pHlBranch, OdGsMarker gsMarker) = 0;
168 virtual void onMarkerRemoved(OdGsStateBranch *pHlBranch, OdGsMarker gsMarker) = 0;
169 virtual void onStyleModified(OdGsStateBranch *pHlBranch, OdUInt32 nPrevStyle, OdUInt32 nStyle) = 0;
170};
171
172// gcc3x template instantiation must be done after class declaration
175
177{
178 if (nStyle != m_nStyle)
179 {
180 const OdUInt32 nPrevStyle = m_nStyle;
181 m_nStyle = nStyle;
182 if (!m_pReactor.isNull())
183 m_pReactor->onStyleModified(this, nPrevStyle, nStyle);
184 }
185}
186
195{
196 public:
197 static void attach(OdGsStateBranch *pHlBranch, const void *pModule, OdGsStateBranchReactor *pReactor);
198 static void detach(OdGsStateBranch *pHlBranch, const void *pModule);
199 static OdGsStateBranchReactor *getReactor(OdGsStateBranch *pHlBranch, const void *pModule);
200 static void setReactor(OdGsStateBranch *pHlBranch, const void *pModule, OdGsStateBranchReactor *pReactor);
201};
202
203#include "TD_PackPop.h"
204
205#endif // __ODGSHIGHLIGHTDATA_H__
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
true
Definition: DimVarDefs.h:2046
false
Definition: DimVarDefs.h:165
const OdGsMarker kNullSubentIndex
Definition: Gs.h:1823
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
std::set< OdGsMarker > OdGsMarkerSet
TPtr< OdGsStateBranch > OdGsStateBranchPtr
OdSmartPtr< OdGsStateBranchReactor > OdGsStateBranchReactorPtr
OdArray< OdGsStateBranchPtr > OdGsStateBranchPtrArray
int OdRefCounter
Definition: OdMutex.h:487
ptrdiff_t OdGsMarker
unsigned int OdUInt32
bool isNull() const
Definition: BaseObjectPtr.h:86
bool hasStyle() const
OdGsStateBranch * addChild(OdDbStub *pDrawableId)
bool removeMarker(OdGsMarker marker)
OdUInt32 style() const
void removeChild(const OdGsStateBranch *pChild)
const OdGiDrawable * drw() const
bool markersEmpty() const
OdGsStateBranchReactorPtr m_pReactor
void setStyle(OdUInt32 nStyle)
static OdGsStateBranchPtr create(OdDbStub *pDrawableId, OdGsMarker marker)
OdGsMarkerSet m_setMarkers
bool isPersistentId() const
OdRefCounter m_nRefCounter
OdGsStateBranch * findChild(const OdDbStub *pDrawableId)
OdGsStateBranchPtrArray m_aChild
const void * m_pDrawableId
OdGsStateBranch(const OdDbStub *pDrawableId)
static bool isValidMarker(OdGsMarker marker)
OdGsStateBranch * addChild(const OdGiDrawable *pTransDrawable)
const OdDbStub * id() const
bool hasMarker(OdGsMarker marker) const
OdGsStateBranch(const OdGiDrawable *pTransDrawable)
bool isEmpty() const
OdUInt32 markersSize() const
static OdGsStateBranchPtr create(OdGiDrawable *pTransDrawable, OdGsMarker marker)
const OdGsMarkerSet & markers() const
OdGsStateBranch * findChild(const OdGiDrawable *pTransDrawable)
void setReactor(OdGsStateBranchReactor *pReactor)
bool addMarker(OdGsMarker marker)
OdGsStateBranchReactor * reactor()
const OdGsStateBranchPtrArray & aChild() const
static void attach(OdGsStateBranch *pHlBranch, const void *pModule, OdGsStateBranchReactor *pReactor)
static OdGsStateBranchReactor * getReactor(OdGsStateBranch *pHlBranch, const void *pModule)
static void detach(OdGsStateBranch *pHlBranch, const void *pModule)
static void setReactor(OdGsStateBranch *pHlBranch, const void *pModule, OdGsStateBranchReactor *pReactor)
virtual void onChildAdded(OdGsStateBranch *pHlBranch, OdGsStateBranch *pHlBranchAdded)=0
virtual void onChildRemoved(OdGsStateBranch *pHlBranch, OdGsStateBranch *pHlBranchRemoved)=0
virtual void onMarkerAdded(OdGsStateBranch *pHlBranch, OdGsMarker gsMarker)=0
virtual void onStyleModified(OdGsStateBranch *pHlBranch, OdUInt32 nPrevStyle, OdUInt32 nStyle)=0
virtual void onMarkerRemoved(OdGsStateBranch *pHlBranch, OdGsMarker gsMarker)=0
const T * get() const
Definition: SmartPtr.h:339
Definition: TPtr.h:76