CFx SDK Documentation  2020SP3
GsViewProps.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 __OD_GS_VIEW_PROPS__
25 #define __OD_GS_VIEW_PROPS__
26 
27 #include "GsViewPropsDef.h"
28 #include "Ge/GeMatrix3d.h"
29 #include "DbStubPtrArray.h"
30 #include "GsViewLocalId.h"
31 
32 #include "TD_PackPush.h"
33 
34 class OdGsViewImpl;
35 
43 {
44 public:
47  OdDbStub* m_vpObjectId;
57  double m_deviation[5];
58  double m_frontClip;
59  double m_backClip;
62  const void* m_renderModule;
63  OdDbStub* m_annoScale;
65  OdDbStub* m_visualStyle;
67 
68  void set(const OdGsViewImpl& view);
69  OdUInt32 difference(const ViewProps& props) const;
70  bool isCompatibleWith(const ViewProps& props, OdUInt32 nFlags,
71  bool bCompareFrozenLayers = true) const;
72  bool isInvalid() const { return GETBIT(m_nViewChanges, 0x80000000); }
73  void setInvalid(bool bValue) { SETBIT(m_nViewChanges, 0x80000000, bValue); }
74 };
76 
84 {
85 public:
86  ViewRefs() : m_nViews(0), m_nMaxVpId(-1) {}
87  OdUInt32 numViews() const { return m_nViews; }
88  void add(OdUInt32 viewportId)
89  {
90  if(viewportId < m_data.size())
91  {
92  if(!m_data[viewportId])
93  ++m_nViews;
94  }
95  else
96  {
97  m_data.insert(m_data.end(), viewportId + 1 - m_data.size(), 0);
98  ++m_nViews;
99  }
100  ++m_data[viewportId];
101  m_nMaxVpId = -1;
102  }
103  void remove(OdUInt32 viewportId)
104  {
105  ODA_ASSERT(m_nViews);
106  ODA_ASSERT(m_data.size() > viewportId);
107  ODA_ASSERT(m_data[viewportId] > 0);
108  if((--m_data[viewportId]) == 0)
109  {
110  --m_nViews;
111  if(!m_nViews)
112  m_data.clear();
113  }
114  m_nMaxVpId = -1;
115  }
116  int maxViewportId() const
117  {
118  if (m_nMaxVpId < 0)
119  {
120  for(unsigned i = m_data.size(); i; )
121  if(m_data[--i])
122  return m_nMaxVpId = (int)i;
123  }
124  return m_nMaxVpId;
125  }
126  unsigned numDifferentViewports() const
127  {
128  unsigned count = 0;
129  for(unsigned i = 0; i < m_data.size(); ++i)
130  if(m_data[i])
131  ++count;
132  return count;
133  }
134  void clear() { m_data.clear(); m_nViews = 0; m_nMaxVpId = -1; }
135 #ifndef ODGS_LOCAL_IDS
136  void set(OdGsDevice& device, OdUInt32 nViews);
137 #else
138  void set(const OdGsBaseModel *pModel);
139 #endif
140  bool contains(OdUInt32 viewportId) const
141  {
142  return (viewportId < m_data.size()) && (m_data[viewportId] != 0);
143  }
144 
146  {
147  public:
148  const_iterator(const ViewRefs& refs): m_refs(refs), m_pos(-1){}
149  const_iterator(const const_iterator& c): m_refs(c.m_refs), m_pos(c.m_pos){}
150  void start() { m_pos = -1; findNext(); }
151  bool done() const { return m_pos < 0 || m_pos >= (int)(m_refs.m_data.size()); }
152  OdUInt32 viewportId() const { ODA_ASSERT(!done()); return m_pos; }
153  void step() { findNext(); }
154 
155  protected:
156  void findNext()
157  {
158  ODA_ASSERT(m_pos > -2);
159  for(++m_pos; (m_pos < (int)m_refs.m_data.size()) && !m_refs.m_data[m_pos]; ++m_pos);
160  }
161  protected:
162  const ViewRefs& m_refs;
163  int m_pos;
164  };
165 
166  friend class const_iterator;
167 protected:
171  mutable int m_nMaxVpId; // cache maxViewportId
172 };
173 
181 {
182 public:
186 
187  const ViewProps& viewProps(unsigned i) const { return m_viewProps.getAt(i); }
188  unsigned numViewProps() const { return m_viewProps.size(); }
189  const ViewRefs& viewRefs() const { return m_viewRefs; }
190  const OdRxClass* deviceClass() const { return m_deviceClass; }
191 
192  bool set(const ViewRefs& refs, const ViewPropsArray& props,
193  const OdRxClass* deviceClass)
194  {
195  if(!deviceClass)
196  return false;//no device to identity cached data
197  unsigned i = 0;
198  for(; (i < props.size()) && props.getAt(i).isInvalid(); ++i);
199  if(i == props.size())
200  return false; //all props are invalid, won't be used anyway
201  m_viewRefs = refs;
202  m_viewProps = props;
204  return true;
205  }
207 
208 protected:
212 };
213 
214 inline bool sameSortedArrays(const OdDbStubPtrArray& ar1, const OdDbStubPtrArray& ar2)
215 {
216  if (ar1.size() == ar2.size())
217  {
218  if (ar1.getPtr() != ar2.getPtr())
219  return ::memcmp(ar1.getPtr(), ar2.getPtr(), sizeof(OdDbStub*) * ar2.size()) == 0;
220  else
221  return true;
222  }
223  return false;
224 }
225 
227  const ViewProps& props, OdUInt32 nMask
228  ,bool bCompareFrozenLayers
229  ) const
230 {
231  //NS: optimization
232  if((!nMask) && !bCompareFrozenLayers)
233  return true;
234  if(GETBIT(nMask, kVpID))
235  {
236  if((m_vpId!=props.m_vpId) || (m_vpObjectId!=props.m_vpObjectId))
237  return false;
238  }
239  if(GETBIT(nMask, kVpRegenType))
240  {
241  if(m_regenType!=props.m_regenType)
242  return false;
243  }
244  if(GETBIT(nMask, kVpRenderMode))
245  {
246  if(m_renderMode!=props.m_renderMode)
247  return false;
248  }
249  if(bCompareFrozenLayers && (GETBIT(nMask, kVpFrozenLayers) ||
251  {
252  return false;
253  }
254  if(GETBIT(nMask, kVpFrontBack))
255  {
256  if(m_frontClip!=props.m_frontClip || m_backClip!=props.m_backClip)
257  return false;
258  }
259  if(GETBIT(nMask, kVpCamLocation))
260  {
262  return false;
263  }
264  if(GETBIT(nMask, kVpCamTarget))
265  {
266  if(m_cameraTarget!=props.m_cameraTarget)
267  return false;
268  }
269  if(GETBIT(nMask, kVpMaxDevForCircle))
270  {
272  return false;
273  }
274  if(GETBIT(nMask, kVpCamUpVector))
275  {
277  return false;
278  }
279  if(GETBIT(nMask, kVpCamViewDir))
280  {
281  if(m_viewDir!=props.m_viewDir)
282  return false;
283  }
284  if(GETBIT(nMask, kVpViewport))
285  {
287  return false;
288  }
289  if(GETBIT(nMask, kVpWorldToEye))
290  {
291  if(m_worldToEye!=props.m_worldToEye)
292  return false;
293  }
294  if(GETBIT(nMask, kVpLtypeScaleMult))
295  {
297  return false;
298  }
299  if(GETBIT(nMask, kVpRenderModule))
300  {
301  if(m_renderModule!=props.m_renderModule)
302  return false;
303  }
304  if(GETBIT(nMask, kVpAnnoScale))
305  {
306  if(m_annoScale!=props.m_annoScale)
307  return false;
308  }
309  if(GETBIT(nMask, kVpFilterFunction))
310  {
312  return false;
313  }
314  if(GETBIT(nMask, kVpVisualStyle))
315  {
316  if(m_visualStyle!=props.m_visualStyle)
317  return false;
318  }
319  return true;
320 }
321 
322 #include "TD_PackPop.h"
323 
324 #endif // __OD_GS_VIEW_PROPS__
GETBIT
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
ViewRefs::m_data
_marray m_data
Definition: GsViewProps.h:169
StockProps::m_viewRefs
ViewRefs m_viewRefs
Definition: GsViewProps.h:209
ViewProps::m_nViewChanges
OdUInt32 m_nViewChanges
Definition: GsViewProps.h:66
ViewRefs::contains
bool contains(OdUInt32 viewportId) const
Definition: GsViewProps.h:140
StockProps::m_deviceClass
const OdRxClass * m_deviceClass
Definition: GsViewProps.h:211
OdEqual
bool OdEqual(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:523
ViewProps::isCompatibleWith
bool isCompatibleWith(const ViewProps &props, OdUInt32 nFlags, bool bCompareFrozenLayers=true) const
Definition: GsViewProps.h:226
OdGeVector3d
Definition: GeVector3d.h:54
OdGsView::RenderMode
RenderMode
Definition: Gs.h:138
kVpCamLocation
@ kVpCamLocation
Definition: GsViewPropsDef.h:39
kVpRenderModule
@ kVpRenderModule
Definition: GsViewPropsDef.h:52
kVpFrontBack
@ kVpFrontBack
Definition: GsViewPropsDef.h:44
StockProps::viewProps
const ViewProps & viewProps(unsigned i) const
Definition: GsViewProps.h:187
OdArray::getAt
const T & getAt(size_type arrayIndex) const
Definition: OdArray.h:1176
StockProps::StockProps
StockProps(const StockProps &c)
Definition: GsViewProps.h:184
count
GLsizei GLsizei * count
Definition: gles2_ext.h:276
ViewProps::m_deviation
double m_deviation[5]
Definition: GsViewProps.h:57
ViewRefs::const_iterator::done
bool done() const
Definition: GsViewProps.h:151
StockProps::m_viewProps
ViewPropsArray m_viewProps
Definition: GsViewProps.h:210
kVpVisualStyle
@ kVpVisualStyle
Definition: GsViewPropsDef.h:55
ViewProps::m_renderModule
const void * m_renderModule
Definition: GsViewProps.h:62
ViewRefs::clear
void clear()
Definition: GsViewProps.h:134
ViewProps::m_linetypeScaleMultiplier
double m_linetypeScaleMultiplier
Definition: GsViewProps.h:61
ViewRefs::maxViewportId
int maxViewportId() const
Definition: GsViewProps.h:116
SETBIT
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:497
OdGsDevice
Definition: Gs.h:1061
ViewRefs::add
void add(OdUInt32 viewportId)
Definition: GsViewProps.h:88
StockProps::clear
void clear()
Definition: GsViewProps.h:206
OdArray< OdDbStub *, OdMemoryAllocator< OdDbStub * > >
ViewRefs::m_nMaxVpId
int m_nMaxVpId
Definition: GsViewProps.h:171
kVpRenderMode
@ kVpRenderMode
Definition: GsViewPropsDef.h:30
ViewProps::m_viewDir
OdGeVector3d m_viewDir
Definition: GsViewProps.h:54
TD_PackPop.h
ViewProps::m_annoScale
OdDbStub * m_annoScale
Definition: GsViewProps.h:63
ViewRefs::const_iterator::const_iterator
const_iterator(const const_iterator &c)
Definition: GsViewProps.h:149
GsViewPropsDef.h
ViewProps::ViewProps
ViewProps()
ViewRefs::_marray
OdIntArray _marray
Definition: GsViewProps.h:168
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdGeMatrix3d
Definition: GeMatrix3d.h:73
ViewProps::m_backClip
double m_backClip
Definition: GsViewProps.h:59
ViewRefs::const_iterator::start
void start()
Definition: GsViewProps.h:150
ViewProps::m_filterFunction
OdIntPtr m_filterFunction
Definition: GsViewProps.h:64
OdArray::getPtr
const T * getPtr() const
Definition: OdArray.h:1102
OdArray::clear
void clear()
Definition: OdArray.h:979
kVpLtypeScaleMult
@ kVpLtypeScaleMult
Definition: GsViewPropsDef.h:46
OdRxClass
Definition: RxObject.h:865
ViewRefs::ViewRefs
ViewRefs()
Definition: GsViewProps.h:86
ViewRefs::m_nViews
OdUInt32 m_nViews
Definition: GsViewProps.h:170
ViewProps::m_worldToEye
OdGeMatrix3d m_worldToEye
Definition: GsViewProps.h:50
ViewProps::m_cameraTarget
OdGePoint3d m_cameraTarget
Definition: GsViewProps.h:52
OdGePoint3d
Definition: GePoint3d.h:55
ViewProps::m_frozenLayers
OdDbStubPtrArray m_frozenLayers
Definition: GsViewProps.h:60
ViewPropsArray
OdArray< ViewProps > ViewPropsArray
Definition: GsViewProps.h:75
ViewRefs::const_iterator::m_pos
int m_pos
Definition: GsViewProps.h:163
OdArray::size
size_type size() const
Definition: OdArray.h:893
ViewRefs::numViews
OdUInt32 numViews() const
Definition: GsViewProps.h:87
OdGsViewImpl
Definition: GsViewImpl.h:58
ViewProps::m_visualStyle
OdDbStub * m_visualStyle
Definition: GsViewProps.h:65
sameSortedArrays
bool sameSortedArrays(const OdDbStubPtrArray &ar1, const OdDbStubPtrArray &ar2)
Definition: GsViewProps.h:214
ViewProps::m_vpObjectId
OdDbStub * m_vpObjectId
Definition: GsViewProps.h:47
ViewProps::m_cameraLocation
OdGePoint3d m_cameraLocation
Definition: GsViewProps.h:51
OdNegative
bool OdNegative(double x, double tol=1.e-10)
Definition: OdaDefs.h:508
kVpCamTarget
@ kVpCamTarget
Definition: GsViewPropsDef.h:40
StockProps::deviceClass
const OdRxClass * deviceClass() const
Definition: GsViewProps.h:190
ViewProps::isInvalid
bool isInvalid() const
Definition: GsViewProps.h:72
TD_PackPush.h
kVpFrozenLayers
@ kVpFrozenLayers
Definition: GsViewPropsDef.h:45
ViewProps::m_regenType
OdGiRegenType m_regenType
Definition: GsViewProps.h:48
StockProps::numViewProps
unsigned numViewProps() const
Definition: GsViewProps.h:188
ViewRefs::set
void set(const OdGsBaseModel *pModel)
kVpID
@ kVpID
Definition: GsViewPropsDef.h:28
ViewRefs::numDifferentViewports
unsigned numDifferentViewports() const
Definition: GsViewProps.h:126
ViewRefs::const_iterator::findNext
void findNext()
Definition: GsViewProps.h:156
ViewProps::m_vpId
OdUInt32 m_vpId
Definition: GsViewProps.h:46
kVpFilterFunction
@ kVpFilterFunction
Definition: GsViewPropsDef.h:54
OdIntPtr
ptrdiff_t OdIntPtr
Definition: OdPlatformSettings.h:884
StockProps::viewRefs
const ViewRefs & viewRefs() const
Definition: GsViewProps.h:189
OdGsBaseModel
Definition: GsBaseModel.h:118
ViewProps::m_cameraUpVector
OdGeVector3d m_cameraUpVector
Definition: GsViewProps.h:53
ODA_ASSERT
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
ViewProps::m_renderMode
OdGsView::RenderMode m_renderMode
Definition: GsViewProps.h:49
ViewProps::setInvalid
void setInvalid(bool bValue)
Definition: GsViewProps.h:73
GS_TOOLKIT_EXPORT
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
ViewProps::set
void set(const OdGsViewImpl &view)
StockProps
Definition: GsViewProps.h:181
StockProps::StockProps
StockProps()
Definition: GsViewProps.h:183
ViewProps::m_vpUpperRight
OdGePoint2d m_vpUpperRight
Definition: GsViewProps.h:56
kVpViewport
@ kVpViewport
Definition: GsViewPropsDef.h:43
ViewProps::difference
OdUInt32 difference(const ViewProps &props) const
kVpCamUpVector
@ kVpCamUpVector
Definition: GsViewPropsDef.h:41
GsViewLocalId.h
ViewProps::m_vpLowerLeft
OdGePoint2d m_vpLowerLeft
Definition: GsViewProps.h:55
DbStubPtrArray.h
ViewRefs
Definition: GsViewProps.h:84
GeMatrix3d.h
OdGiRegenType
OdGiRegenType
Definition: GiCommonDraw.h:50
ViewRefs::const_iterator::viewportId
OdUInt32 viewportId() const
Definition: GsViewProps.h:152
ViewRefs::remove
void remove(OdUInt32 viewportId)
Definition: GsViewProps.h:103
ViewProps
Definition: GsViewProps.h:43
kVpRegenType
@ kVpRegenType
Definition: GsViewPropsDef.h:29
ViewRefs::const_iterator::step
void step()
Definition: GsViewProps.h:153
ViewProps::m_frontClip
double m_frontClip
Definition: GsViewProps.h:58
ViewRefs::const_iterator::const_iterator
const_iterator(const ViewRefs &refs)
Definition: GsViewProps.h:148
kOdGiMaxDevForCircle
@ kOdGiMaxDevForCircle
Definition: GiCommonDraw.h:65
kVpWorldToEye
@ kVpWorldToEye
Definition: GsViewPropsDef.h:31
kVpCamViewDir
@ kVpCamViewDir
Definition: GsViewPropsDef.h:42
StockProps::set
bool set(const ViewRefs &refs, const ViewPropsArray &props, const OdRxClass *deviceClass)
Definition: GsViewProps.h:192
ViewRefs::const_iterator
Definition: GsViewProps.h:146
ViewRefs::const_iterator::m_refs
const ViewRefs & m_refs
Definition: GsViewProps.h:162
kVpMaxDevForCircle
@ kVpMaxDevForCircle
Definition: GsViewPropsDef.h:34
OdGePoint2d
Definition: GePoint2d.h:60
kVpAnnoScale
@ kVpAnnoScale
Definition: GsViewPropsDef.h:53