CFx SDK Documentation  2022 SP0
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__
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
true
Definition: DimVarDefs.h:2046
false
Definition: DimVarDefs.h:165
const OdGsMarker kNullSubentIndex
Definition: Gs.h:1426
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdSmartPtr< OdGsHlBranchReactor > OdGsHlBranchReactorPtr
TPtr< OdGsHlBranch > OdGsHlBranchPtr
OdArray< OdGsHlBranchPtr > OdGsHlBranchPtrArray
#define NULL
Definition: GsProperties.h:177
int OdRefCounter
Definition: OdMutex.h:436
ptrdiff_t OdGsMarker
bool isEmpty() const
static OdGsHlBranchPtr create(OdGiDrawable *pTransDrawable, OdGsMarker marker)
OdRefCounter m_nRefCounter
const OdDbStub * id() const
OdGsHlBranchReactor * reactor()
OdGsHlBranch * findChild(const OdGiDrawable *pTransDrawable)
OdGsHlBranch * findChild(const OdDbStub *pDrawableId)
OdGsHlBranchReactorPtr m_pReactor
static bool isValidMarker(OdGsMarker marker)
OdGsHlBranch(const OdDbStub *pDrawableId)
void setReactor(OdGsHlBranchReactor *pReactor)
static OdGsHlBranchPtr create(OdDbStub *pDrawableId, OdGsMarker marker)
const OdGiDrawable * drw() const
bool isPersistentId() const
const OdGsHlBranchPtrArray & aChild() const
OdGsHlBranchPtrArray m_aChild
OdGsMarkerArray m_aMarkers
const OdGsMarkerArray & markers() const
OdGsHlBranch * addChild(OdDbStub *pDrawableId)
OdGsHlBranch * addChild(const OdGiDrawable *pTransDrawable)
bool addMarker(OdGsMarker marker)
bool hasMarker(OdGsMarker marker) const
bool removeMarker(OdGsMarker marker)
OdGsHlBranch(const OdGiDrawable *pTransDrawable)
const void * m_pDrawableId
void removeChild(const OdGsHlBranch *pChild)
static void setReactor(OdGsHlBranch *pHlBranch, const void *pModule, OdGsHlBranchReactor *pReactor)
static void detach(OdGsHlBranch *pHlBranch, const void *pModule)
static void attach(OdGsHlBranch *pHlBranch, const void *pModule, OdGsHlBranchReactor *pReactor)
static OdGsHlBranchReactor * getReactor(OdGsHlBranch *pHlBranch, const void *pModule)
virtual void onMarkerRemoved(OdGsHlBranch *pHlBranch, OdGsMarker gsMarker)=0
virtual void onChildAdded(OdGsHlBranch *pHlBranch, OdGsHlBranch *pHlBranchAdded)=0
virtual void onChildRemoved(OdGsHlBranch *pHlBranch, OdGsHlBranch *pHlBranchRemoved)=0
virtual void onMarkerAdded(OdGsHlBranch *pHlBranch, OdGsMarker gsMarker)=0
const T * get() const
Definition: SmartPtr.h:326