CFx SDK Documentation  2023 SP0
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__
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
OdGiRegenType
Definition: GiCommonDraw.h:50
@ kOdGiMaxDevForCircle
Definition: GiCommonDraw.h:65
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdArray< ViewProps > ViewPropsArray
Definition: GsViewProps.h:75
bool sameSortedArrays(const OdDbStubPtrArray &ar1, const OdDbStubPtrArray &ar2)
Definition: GsViewProps.h:214
@ kVpLtypeScaleMult
@ kVpMaxDevForCircle
@ kVpFilterFunction
@ kVpCamViewDir
@ kVpRenderModule
@ kVpCamLocation
@ kVpAnnoScale
@ kVpID
@ kVpCamTarget
@ kVpWorldToEye
@ kVpViewport
@ kVpFrontBack
@ kVpRegenType
@ kVpFrozenLayers
@ kVpCamUpVector
@ kVpRenderMode
@ kVpVisualStyle
unsigned int OdUInt32
ptrdiff_t OdIntPtr
bool OdEqual(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:525
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:499
bool OdNegative(double x, double tol=1.e-10)
Definition: OdaDefs.h:510
#define GETBIT(flags, bit)
Definition: OdaDefs.h:500
void clear()
Definition: OdArray.h:979
const T & getAt(size_type arrayIndex) const
Definition: OdArray.h:1176
size_type size() const
Definition: OdArray.h:893
const T * getPtr() const
Definition: OdArray.h:1102
RenderMode
Definition: Gs.h:138
const OdRxClass * deviceClass() const
Definition: GsViewProps.h:190
void clear()
Definition: GsViewProps.h:206
StockProps(const StockProps &c)
Definition: GsViewProps.h:184
unsigned numViewProps() const
Definition: GsViewProps.h:188
const ViewRefs & viewRefs() const
Definition: GsViewProps.h:189
bool set(const ViewRefs &refs, const ViewPropsArray &props, const OdRxClass *deviceClass)
Definition: GsViewProps.h:192
ViewRefs m_viewRefs
Definition: GsViewProps.h:209
const ViewProps & viewProps(unsigned i) const
Definition: GsViewProps.h:187
const OdRxClass * m_deviceClass
Definition: GsViewProps.h:211
ViewPropsArray m_viewProps
Definition: GsViewProps.h:210
const_iterator(const const_iterator &c)
Definition: GsViewProps.h:149
const_iterator(const ViewRefs &refs)
Definition: GsViewProps.h:148
OdUInt32 viewportId() const
Definition: GsViewProps.h:152
const ViewRefs & m_refs
Definition: GsViewProps.h:162
OdIntArray _marray
Definition: GsViewProps.h:168
void clear()
Definition: GsViewProps.h:134
void remove(OdUInt32 viewportId)
Definition: GsViewProps.h:103
int m_nMaxVpId
Definition: GsViewProps.h:171
bool contains(OdUInt32 viewportId) const
Definition: GsViewProps.h:140
int maxViewportId() const
Definition: GsViewProps.h:116
void set(const OdGsBaseModel *pModel)
unsigned numDifferentViewports() const
Definition: GsViewProps.h:126
_marray m_data
Definition: GsViewProps.h:169
OdUInt32 m_nViews
Definition: GsViewProps.h:170
OdUInt32 numViews() const
Definition: GsViewProps.h:87
void add(OdUInt32 viewportId)
Definition: GsViewProps.h:88
GLsizei GLsizei * count
Definition: gles2_ext.h:276
OdGeVector3d m_viewDir
Definition: GsViewProps.h:54
double m_backClip
Definition: GsViewProps.h:59
double m_deviation[5]
Definition: GsViewProps.h:57
OdGeVector3d m_cameraUpVector
Definition: GsViewProps.h:53
double m_frontClip
Definition: GsViewProps.h:58
bool isInvalid() const
Definition: GsViewProps.h:72
OdGePoint3d m_cameraLocation
Definition: GsViewProps.h:51
OdDbStubPtrArray m_frozenLayers
Definition: GsViewProps.h:60
OdGePoint2d m_vpUpperRight
Definition: GsViewProps.h:56
OdDbStub * m_vpObjectId
Definition: GsViewProps.h:47
bool isCompatibleWith(const ViewProps &props, OdUInt32 nFlags, bool bCompareFrozenLayers=true) const
Definition: GsViewProps.h:226
OdGsView::RenderMode m_renderMode
Definition: GsViewProps.h:49
void setInvalid(bool bValue)
Definition: GsViewProps.h:73
OdUInt32 m_vpId
Definition: GsViewProps.h:46
OdUInt32 m_nViewChanges
Definition: GsViewProps.h:66
OdGePoint3d m_cameraTarget
Definition: GsViewProps.h:52
const void * m_renderModule
Definition: GsViewProps.h:62
void set(const OdGsViewImpl &view)
OdGiRegenType m_regenType
Definition: GsViewProps.h:48
OdIntPtr m_filterFunction
Definition: GsViewProps.h:64
OdDbStub * m_visualStyle
Definition: GsViewProps.h:65
double m_linetypeScaleMultiplier
Definition: GsViewProps.h:61
OdGeMatrix3d m_worldToEye
Definition: GsViewProps.h:50
OdGePoint2d m_vpLowerLeft
Definition: GsViewProps.h:55
OdDbStub * m_annoScale
Definition: GsViewProps.h:63
OdUInt32 difference(const ViewProps &props) const