CFx SDK Documentation  2020SP3
GsHighlightData.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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 Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 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 #include "GsMarkerArray.h"
28 #include "Gi/GiDrawable.h"
29 #include "Gs.h"
30 #include "TPtr.h"
31 
32 #include "TD_PackPush.h"
33 
34 class OdGsHlBranch;
37 
39 
44 
53 {
54  protected:
56 
57  OdRefCounter m_nRefCounter; // shared ownership
58  const void* m_pDrawableId; // persistent id or transient drawable pointer (depends from flag)
59  bool m_bPersistentId; // true if m_pDrawableId stores OdDbStub pointer
60  OdGsHlBranchReactorPtr m_pReactor; // OdGsHlBranch reactor
61  OdGsMarkerArray m_aMarkers; // sorted array of markers
62  OdGsHlBranchPtrArray m_aChild; // sorted array of nested entities
63  // the sorting rule: first are transient entities with id 0, sorted by drw() value,
64  // next are persistent entities with id != 0, sorted by id()
65  public:
66  OdGsHlBranch(const OdDbStub* pDrawableId)
67  : m_nRefCounter(1)
68  , m_pDrawableId(pDrawableId)
69  , m_bPersistentId(true)
70  , m_aMarkers(0, 1)
71  , m_aChild(0, 1)
72  {
73  }
74  OdGsHlBranch(const OdGiDrawable* pTransDrawable)
75  : m_nRefCounter(1)
76  , m_pDrawableId(pTransDrawable)
77  , m_bPersistentId(false)
78  , m_aMarkers(0, 1)
79  , m_aChild(0, 1)
80  {
81  }
82 
83  static OdGsHlBranchPtr create(OdDbStub* pDrawableId, OdGsMarker marker);
84  static OdGsHlBranchPtr create(OdGiDrawable* pTransDrawable, OdGsMarker marker);
85 
86  void addRef()
87  {
88  ++m_nRefCounter;
89  }
90  void release()
91  {
92  ODA_ASSERT((m_nRefCounter > 0));
93  if (!(--m_nRefCounter))
94  delete this;
95  }
96 
97  // access to nested entities
98  const OdGsHlBranchPtrArray& aChild() const { return m_aChild; }
99  // access to subentities
100  const OdGsMarkerArray& markers() const { return m_aMarkers; }
101 
102  // add/remove/find nested entities info
103  OdGsHlBranch* addChild(OdDbStub* pDrawableId);
104  OdGsHlBranch* addChild(const OdGiDrawable* pTransDrawable);
105  void removeChild(const OdGsHlBranch* pChild);
106  OdGsHlBranch* findChild(const OdDbStub* pDrawableId); // search in a sorted array, fast
107  OdGsHlBranch* findChild(const OdGiDrawable* pTransDrawable); // search in a sorted array, fast
108 
109  // add/remove/find subentities info
110  bool addMarker(OdGsMarker marker);
111  bool removeMarker(OdGsMarker marker);
112  bool hasMarker(OdGsMarker marker) const; // search in a sorted array, fast
113 
114  // access to the OdGsEntityNode data
115  const OdDbStub* id() const
116  {
117  return (m_bPersistentId) ? reinterpret_cast<const OdDbStub*>(m_pDrawableId) : NULL;
118  }
119  const OdGiDrawable* drw() const
120  {
121  return (!m_bPersistentId) ? reinterpret_cast<const OdGiDrawable*>(m_pDrawableId) : NULL;
122  }
123  bool isEmpty() const
124  {
125  return markers().isEmpty() && aChild().isEmpty();
126  }
127 
128  // access flags
129  bool isPersistentId() const { return m_bPersistentId; }
130 
131  // reactor
132  void setReactor(OdGsHlBranchReactor *pReactor);
133  OdGsHlBranchReactor *reactor();
134 
135  static inline bool isValidMarker(OdGsMarker marker)
136  {
137  return (marker != kNullSubentIndex);
138  }
139 };
140 
149 {
150  public:
151  virtual void onChildAdded(OdGsHlBranch *pHlBranch, OdGsHlBranch *pHlBranchAdded) = 0;
152  virtual void onChildRemoved(OdGsHlBranch *pHlBranch, OdGsHlBranch *pHlBranchRemoved) = 0;
153  virtual void onMarkerAdded(OdGsHlBranch *pHlBranch, OdGsMarker gsMarker) = 0;
154  virtual void onMarkerRemoved(OdGsHlBranch *pHlBranch, OdGsMarker gsMarker) = 0;
155 };
156 
157 // gcc3x template instantiation must be done after class declaration
158 inline void OdGsHlBranch::setReactor(OdGsHlBranchReactor *pReactor) { m_pReactor = pReactor; }
160 
169 {
170  public:
171  static void attach(OdGsHlBranch *pHlBranch, const void *pModule, OdGsHlBranchReactor *pReactor);
172  static void detach(OdGsHlBranch *pHlBranch, const void *pModule);
173  static OdGsHlBranchReactor *getReactor(OdGsHlBranch *pHlBranch, const void *pModule);
174  static void setReactor(OdGsHlBranch *pHlBranch, const void *pModule, OdGsHlBranchReactor *pReactor);
175 };
176 
177 #include "TD_PackPop.h"
178 
179 #endif // __ODGSHIGHLIGHTDATA_H__
OdGsHlBranchPtrArray
OdArray< OdGsHlBranchPtr > OdGsHlBranchPtrArray
Definition: GsHighlightData.h:36
OdGsHlBranch::drw
const OdGiDrawable * drw() const
Definition: GsHighlightData.h:119
OdGsHlBranch::removeMarker
bool removeMarker(OdGsMarker marker)
NULL
#define NULL
Definition: GsProperties.h:177
OdGsHlBranchReactorPtr
OdSmartPtr< OdGsHlBranchReactor > OdGsHlBranchReactorPtr
Definition: GsHighlightData.h:38
OdGsHlBranch::m_bPersistentId
bool m_bPersistentId
Definition: GsHighlightData.h:59
OdGsHlBranchReactor::onChildRemoved
virtual void onChildRemoved(OdGsHlBranch *pHlBranch, OdGsHlBranch *pHlBranchRemoved)=0
OdGsHlBranch::reactor
OdGsHlBranchReactor * reactor()
Definition: GsHighlightData.h:159
OdGsHlBranch::removeChild
void removeChild(const OdGsHlBranch *pChild)
false
false
Definition: DimVarDefs.h:165
OdRxObject
Definition: RxObject.h:564
OdRefCounter
int OdRefCounter
Definition: OdMutex.h:436
OdGsHlBranch::m_nRefCounter
OdRefCounter m_nRefCounter
Definition: GsHighlightData.h:57
OdGsHlBranchReactor
Definition: GsHighlightData.h:149
OdArray< OdGsHlBranchPtr >
TD_PackPop.h
OdGsMarker
ptrdiff_t OdGsMarker
Definition: OdPlatformSettings.h:889
OdGsHlBranch::id
const OdDbStub * id() const
Definition: GsHighlightData.h:115
OdGsHlBranch::hasMarker
bool hasMarker(OdGsMarker marker) const
OdGsHlBranch
Definition: GsHighlightData.h:53
OdGsHlBranch::m_aChild
OdGsHlBranchPtrArray m_aChild
Definition: GsHighlightData.h:62
OdGsHlBranchMultimoduleReactor
Definition: GsHighlightData.h:169
OdGsHlBranch::isEmpty
bool isEmpty() const
Definition: GsHighlightData.h:123
OdGsHlBranch::m_pDrawableId
const void * m_pDrawableId
Definition: GsHighlightData.h:58
OdGsHlBranchReactor::onChildAdded
virtual void onChildAdded(OdGsHlBranch *pHlBranch, OdGsHlBranch *pHlBranchAdded)=0
OdGsHlBranch::OdGsHlBranch
OdGsHlBranch(const OdDbStub *pDrawableId)
Definition: GsHighlightData.h:66
OdSmartPtr< OdGsHlBranchReactor >
OdGsHlBranchMultimoduleReactor::setReactor
static void setReactor(OdGsHlBranch *pHlBranch, const void *pModule, OdGsHlBranchReactor *pReactor)
true
true
Definition: DimVarDefs.h:2046
OdGsHlBranch::release
void release()
Definition: GsHighlightData.h:90
Gs.h
OdGiDrawable
Definition: GiDrawable.h:49
OdGsHlBranch::addChild
OdGsHlBranch * addChild(const OdGiDrawable *pTransDrawable)
OdGsHlBranch::OdGsHlBranch
OdGsHlBranch(const OdGiDrawable *pTransDrawable)
Definition: GsHighlightData.h:74
OdSmartPtr::get
const T * get() const
Definition: SmartPtr.h:326
OdGsHlBranch::isValidMarker
static bool isValidMarker(OdGsMarker marker)
Definition: GsHighlightData.h:135
OdGsHlBranch::ODRX_HEAP_OPERATORS
ODRX_HEAP_OPERATORS()
OdGsHlBranch::addRef
void addRef()
Definition: GsHighlightData.h:86
OdGsHlBranch::addChild
OdGsHlBranch * addChild(OdDbStub *pDrawableId)
OdGsHlBranch::isPersistentId
bool isPersistentId() const
Definition: GsHighlightData.h:129
TD_PackPush.h
OdGsHlBranch::findChild
OdGsHlBranch * findChild(const OdGiDrawable *pTransDrawable)
OdGsHlBranchMultimoduleReactor::getReactor
static OdGsHlBranchReactor * getReactor(OdGsHlBranch *pHlBranch, const void *pModule)
kNullSubentIndex
const OdGsMarker kNullSubentIndex
Definition: Gs.h:1426
OdGsHlBranch::aChild
const OdGsHlBranchPtrArray & aChild() const
Definition: GsHighlightData.h:98
GsMarkerArray.h
OdGsHlBranch::create
static OdGsHlBranchPtr create(OdDbStub *pDrawableId, OdGsMarker marker)
TPtr< OdGsHlBranch >
ODA_ASSERT
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
OdGsHlBranch::create
static OdGsHlBranchPtr create(OdGiDrawable *pTransDrawable, OdGsMarker marker)
OdGsHlBranch::addMarker
bool addMarker(OdGsMarker marker)
GS_TOOLKIT_EXPORT
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
GiDrawable.h
OdGsHlBranch::m_aMarkers
OdGsMarkerArray m_aMarkers
Definition: GsHighlightData.h:61
OdGsHlBranchReactor::onMarkerRemoved
virtual void onMarkerRemoved(OdGsHlBranch *pHlBranch, OdGsMarker gsMarker)=0
OdGsHlBranch::setReactor
void setReactor(OdGsHlBranchReactor *pReactor)
Definition: GsHighlightData.h:158
TPtr.h
OdGsHlBranch::m_pReactor
OdGsHlBranchReactorPtr m_pReactor
Definition: GsHighlightData.h:60
OdGsHlBranch::markers
const OdGsMarkerArray & markers() const
Definition: GsHighlightData.h:100
OdGsHlBranchReactor::onMarkerAdded
virtual void onMarkerAdded(OdGsHlBranch *pHlBranch, OdGsMarker gsMarker)=0
OdGsHlBranchPtr
TPtr< OdGsHlBranch > OdGsHlBranchPtr
Definition: GsHighlightData.h:34
OdGsHlBranch::findChild
OdGsHlBranch * findChild(const OdDbStub *pDrawableId)
OdGsHlBranchMultimoduleReactor::attach
static void attach(OdGsHlBranch *pHlBranch, const void *pModule, OdGsHlBranchReactor *pReactor)
OdGsHlBranchMultimoduleReactor::detach
static void detach(OdGsHlBranch *pHlBranch, const void *pModule)