CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GsViewProps.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 __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
34class OdGsViewImpl;
35
43{
44public:
66
69
71 OdDbStub* m_vpObjectId;
72
75
78
81
84
87
90
93
96
99
101 double m_deviation[5];
102
105
108
111
114
116 const void* m_renderModule;
117
119 OdDbStub* m_annoScale;
120
123
125 OdDbStub* m_visualStyle;
126
129
134 void set(const OdGsViewImpl& view);
135
142 OdUInt32 difference(const ViewProps& props) const;
143
153 bool isCompatibleWith(const ViewProps& props, OdUInt32 nFlags,
154 bool bCompareFrozenLayers = true) const;
155
162 bool isInvalid() const { return GETBIT(m_nViewChanges, 0x80000000); }
163
169 void setInvalid(bool bValue) { SETBIT(m_nViewChanges, 0x80000000, bValue); }
170};
175
176inline bool isInvalid(const ViewPropsArray& props)
177{
178 unsigned i = 0;
179 for(; (i < props.size()) && props.getAt(i).isInvalid(); ++i);
180 return (i == props.size()); //all are invalid
181}
182
190{
191public:
192 ViewRefs() : m_nViews(0), m_nMaxVpId(-1) {}
193 OdUInt32 numViews() const { return m_nViews; }
194 void add(OdUInt32 viewportId)
195 {
196 if(viewportId < m_data.size())
197 {
198 if(!m_data[viewportId])
199 ++m_nViews;
200 }
201 else
202 {
203 m_data.insert(m_data.end(), viewportId + 1 - m_data.size(), 0);
204 ++m_nViews;
205 }
206 ++m_data[viewportId];
207 m_nMaxVpId = -1;
208 }
209 void remove(OdUInt32 viewportId)
210 {
211 ODA_ASSERT(m_nViews);
212 ODA_ASSERT(m_data.size() > viewportId);
213 ODA_ASSERT(m_data[viewportId] > 0);
214 if((--m_data[viewportId]) == 0)
215 {
216 --m_nViews;
217 if(!m_nViews)
218 m_data.clear();
219 }
220 m_nMaxVpId = -1;
221 }
222 int maxViewportId() const
223 {
224 if (m_nMaxVpId < 0)
225 {
226 for(unsigned i = m_data.size(); i; )
227 if(m_data[--i])
228 return m_nMaxVpId = (int)i;
229 }
230 return m_nMaxVpId;
231 }
232 unsigned numDifferentViewports() const
233 {
234 unsigned count = 0;
235 for(unsigned i = 0; i < m_data.size(); ++i)
236 if(m_data[i])
237 ++count;
238 return count;
239 }
240 void clear() { m_data.clear(); m_nViews = 0; m_nMaxVpId = -1; }
241 void set(const OdGsBaseModel *pModel);
242 bool contains(OdUInt32 viewportId) const
243 {
244 return (viewportId < m_data.size()) && (m_data[viewportId] != 0);
245 }
246
248 {
249 public:
250 const_iterator(const ViewRefs& refs): m_refs(refs), m_pos(-1){}
251 const_iterator(const const_iterator& c): m_refs(c.m_refs), m_pos(c.m_pos){}
252 void start() { m_pos = -1; findNext(); }
253 bool done() const { return m_pos < 0 || m_pos >= (int)(m_refs.m_data.size()); }
254 OdUInt32 viewportId() const { ODA_ASSERT(!done()); return m_pos; }
255 void step() { findNext(); }
256
257 protected:
258 void findNext()
259 {
260 ODA_ASSERT(m_pos > -2);
261 for(++m_pos; (m_pos < (int)m_refs.m_data.size()) && !m_refs.m_data[m_pos]; ++m_pos);
262 }
263 protected:
265 int m_pos;
266 };
267
268 friend class const_iterator;
269protected:
273 mutable int m_nMaxVpId; // cache maxViewportId
274};
275
283{
284public:
288
289 const ViewProps& viewProps(unsigned i) const { return m_viewProps.getAt(i); }
290 unsigned numViewProps() const { return m_viewProps.size(); }
291 const ViewRefs& viewRefs() const { return m_viewRefs; }
292 const OdRxClass* deviceClass() const { return m_deviceClass; }
293
294 bool set(const ViewRefs& refs, const ViewPropsArray& props,
295 const OdRxClass* deviceClass)
296 {
297 if(!deviceClass)
298 return false;//no device to identity cached data
299 ODA_ASSERT(!isInvalid(props));
300 m_viewRefs = refs;
301 m_viewProps = props;
303 return true;
304 }
306
307protected:
311};
312
313inline bool sameSortedArrays(const OdDbStubPtrArray& ar1, const OdDbStubPtrArray& ar2)
314{
315 if (ar1.size() == ar2.size())
316 {
317 if (ar1.getPtr() != ar2.getPtr())
318 return ::memcmp(ar1.getPtr(), ar2.getPtr(), sizeof(OdDbStub*) * ar2.size()) == 0;
319 else
320 return true;
321 }
322 return false;
323}
324
326 const ViewProps& props, OdUInt32 nMask
327 ,bool bCompareFrozenLayers
328 ) const
329{
330 //NS: optimization
331 if (!(nMask & ~kVpForceEraseMf) && !bCompareFrozenLayers)
332 return true;
333 if(GETBIT(nMask, kVpID))
334 {
335 if((m_vpId!=props.m_vpId) || (m_vpObjectId!=props.m_vpObjectId))
336 return false;
337 }
338 if(GETBIT(nMask, kVpRegenType))
339 {
340 if(m_regenType!=props.m_regenType)
341 return false;
342 }
343 if(GETBIT(nMask, kVpRenderMode))
344 {
345 if(m_renderMode!=props.m_renderMode)
346 return false;
347 }
348 if(bCompareFrozenLayers && (GETBIT(nMask, kVpFrozenLayers) ||
350 {
351 return false;
352 }
353 if(GETBIT(nMask, kVpFrontBack))
354 {
355 if(m_frontClip!=props.m_frontClip || m_backClip!=props.m_backClip)
356 return false;
357 }
358 if(GETBIT(nMask, kVpCamLocation))
359 {
361 return false;
362 }
363 if(GETBIT(nMask, kVpCamTarget))
364 {
366 return false;
367 }
368 for (OdUInt32 nDeviation = kOdGiMaxDevForCircle; nDeviation <= kOdGiMaxDevForCurve; nDeviation++)
369 {
370 if(GETBIT(nMask, kVpMaxDevForCircle << nDeviation))
371 {
372 if(OdNegative(m_deviation[nDeviation] - props.m_deviation[nDeviation]))
373 return false;
374 }
375 }
376 //skip kOdGiMaxDevForBoundary and kOdGiMaxDevForIsoline
377 if(GETBIT(nMask, kVpMaxDevForFacet))
378 {
380 return false;
381 }
382 if(GETBIT(nMask, kVpCamUpVector))
383 {
385 return false;
386 }
387 if(GETBIT(nMask, kVpCamViewDir))
388 {
389 if(m_viewDir!=props.m_viewDir)
390 return false;
391 }
392 if(GETBIT(nMask, kVpViewport))
393 {
395 return false;
396 }
397 if(GETBIT(nMask, kVpWorldToEye))
398 {
399 if(m_worldToEye!=props.m_worldToEye)
400 return false;
401 }
402 if(GETBIT(nMask, kVpLtypeScaleMult))
403 {
405 return false;
406 }
407 if(GETBIT(nMask, kVpRenderModule))
408 {
410 return false;
411 }
412 if(GETBIT(nMask, kVpAnnoScale))
413 {
414 if(m_annoScale!=props.m_annoScale)
415 return false;
416 }
417 if(GETBIT(nMask, kVpFilterFunction))
418 {
420 return false;
421 }
422 if(GETBIT(nMask, kVpVisualStyle))
423 {
425 return false;
426 }
427 return true;
428}
429
430#include "TD_PackPop.h"
431
432#endif // __OD_GS_VIEW_PROPS__
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
OdGiRegenType
Definition: GiCommonDraw.h:51
@ kOdGiMaxDevForCircle
Definition: GiCommonDraw.h:66
@ kOdGiMaxDevForCurve
Definition: GiCommonDraw.h:67
@ kOdGiMaxDevForFacet
Definition: GiCommonDraw.h:70
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
bool isInvalid(const ViewPropsArray &props)
Definition: GsViewProps.h:176
OdArray< ViewProps > ViewPropsArray
Definition: GsViewProps.h:174
bool sameSortedArrays(const OdDbStubPtrArray &ar1, const OdDbStubPtrArray &ar2)
Definition: GsViewProps.h:313
@ kVpLtypeScaleMult
@ kVpMaxDevForCircle
@ kVpFilterFunction
@ kVpCamViewDir
@ kVpRenderModule
@ kVpForceEraseMf
@ kVpCamLocation
@ kVpAnnoScale
@ kVpID
@ kVpCamTarget
@ kVpWorldToEye
@ kVpViewport
@ kVpFrontBack
@ kVpRegenType
@ kVpFrozenLayers
@ kVpCamUpVector
@ kVpRenderMode
@ kVpMaxDevForFacet
@ kVpVisualStyle
unsigned int OdUInt32
ptrdiff_t OdIntPtr
bool OdEqual(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:542
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:516
bool OdNegative(double x, double tol=1.e-10)
Definition: OdaDefs.h:527
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
void clear()
Definition: OdArray.h:1400
const T & getAt(size_type arrayIndex) const
Definition: OdArray.h:1684
size_type size() const
Definition: OdArray.h:1247
const T * getPtr() const
Definition: OdArray.h:1600
RenderMode
Definition: Gs.h:148
const ViewRefs & viewRefs() const
Definition: GsViewProps.h:291
void clear()
Definition: GsViewProps.h:305
StockProps(const StockProps &c)
Definition: GsViewProps.h:286
unsigned numViewProps() const
Definition: GsViewProps.h:290
const ViewProps & viewProps(unsigned i) const
Definition: GsViewProps.h:289
const OdRxClass * deviceClass() const
Definition: GsViewProps.h:292
bool set(const ViewRefs &refs, const ViewPropsArray &props, const OdRxClass *deviceClass)
Definition: GsViewProps.h:294
ViewRefs m_viewRefs
Definition: GsViewProps.h:308
const OdRxClass * m_deviceClass
Definition: GsViewProps.h:310
ViewPropsArray m_viewProps
Definition: GsViewProps.h:309
const_iterator(const const_iterator &c)
Definition: GsViewProps.h:251
const_iterator(const ViewRefs &refs)
Definition: GsViewProps.h:250
OdUInt32 viewportId() const
Definition: GsViewProps.h:254
const ViewRefs & m_refs
Definition: GsViewProps.h:264
OdIntArray _marray
Definition: GsViewProps.h:270
void clear()
Definition: GsViewProps.h:240
void remove(OdUInt32 viewportId)
Definition: GsViewProps.h:209
int m_nMaxVpId
Definition: GsViewProps.h:273
bool contains(OdUInt32 viewportId) const
Definition: GsViewProps.h:242
int maxViewportId() const
Definition: GsViewProps.h:222
void set(const OdGsBaseModel *pModel)
unsigned numDifferentViewports() const
Definition: GsViewProps.h:232
_marray m_data
Definition: GsViewProps.h:271
OdUInt32 m_nViews
Definition: GsViewProps.h:272
OdUInt32 numViews() const
Definition: GsViewProps.h:193
void add(OdUInt32 viewportId)
Definition: GsViewProps.h:194
GLsizei GLsizei * count
Definition: gles2_ext.h:276
OdGeVector3d m_viewDir
Definition: GsViewProps.h:92
double m_backClip
Definition: GsViewProps.h:107
double m_deviation[5]
Definition: GsViewProps.h:101
OdGeVector3d m_cameraUpVector
Definition: GsViewProps.h:89
double m_frontClip
Definition: GsViewProps.h:104
bool isInvalid() const
Definition: GsViewProps.h:162
OdGePoint3d m_cameraLocation
Definition: GsViewProps.h:83
OdDbStubPtrArray m_frozenLayers
Definition: GsViewProps.h:110
OdGePoint2d m_vpUpperRight
Definition: GsViewProps.h:98
OdDbStub * m_vpObjectId
Definition: GsViewProps.h:71
bool isCompatibleWith(const ViewProps &props, OdUInt32 nFlags, bool bCompareFrozenLayers=true) const
Definition: GsViewProps.h:325
OdGsView::RenderMode m_renderMode
Definition: GsViewProps.h:77
void setInvalid(bool bValue)
Definition: GsViewProps.h:169
OdUInt32 m_vpId
Definition: GsViewProps.h:68
OdUInt32 m_nViewChanges
Definition: GsViewProps.h:128
OdGePoint3d m_cameraTarget
Definition: GsViewProps.h:86
const void * m_renderModule
Definition: GsViewProps.h:116
void set(const OdGsViewImpl &view)
OdGiRegenType m_regenType
Definition: GsViewProps.h:74
OdIntPtr m_filterFunction
Definition: GsViewProps.h:122
OdDbStub * m_visualStyle
Definition: GsViewProps.h:125
double m_linetypeScaleMultiplier
Definition: GsViewProps.h:113
OdGeMatrix3d m_worldToEye
Definition: GsViewProps.h:80
OdGePoint2d m_vpLowerLeft
Definition: GsViewProps.h:95
OdDbStub * m_annoScale
Definition: GsViewProps.h:119
OdUInt32 difference(const ViewProps &props) const