CFx SDK Documentation  2023 SP0
GsDefs.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 __GSDEFS_H_INCLUDED_
25 #define __GSDEFS_H_INCLUDED_
26 
27 #include "TD_PackPush.h"
28 #include "OdRound.h"
29 
30 //****************************************************************************
31 // Helper classes
32 //****************************************************************************
33 
34 // copied(with modification) from limits.h to avoid extra #includes
35 
36 #define SCALAR_MIN (-2147483647 - 1) // minimum(signed) int32 value
37 #define SCALAR_MAX 2147483647 // maximum(signed) int32 value
38 
53 {
54 public:
55  enum MaxFlag { Maximum };
56  enum MinFlag { Minimum };
57 
69  //FELIX_CHANGE_BEGIN
70  OdGsDCPoint(OdInt32 xx, OdInt32 yy) : x(xx), y(yy) { }
71  //FELIX_CHANGE_END
72 
75 
85 
86  void operator=(const OdGsDCPoint& dcPoint) { x = dcPoint.x; y = dcPoint.y; }
87  bool operator==(const OdGsDCPoint& dcPoint) const { return x == dcPoint.x && y == dcPoint.y; }
88  bool operator!=(const OdGsDCPoint& dcPoint) const { return x != dcPoint.x || y != dcPoint.y; }
89  inline long operator[](unsigned int i) const { return *(&x + i); }
90 
91  //FELIX_CHANGE_BEGIN
92  OdInt32 x; // X-coordinate.
93  OdInt32 y; // Y-coordinate.
94  //FELIX_CHANGE_END
95 };
96 
111 {
112 public:
113  enum NullFlag { Null };
122  OdGsDCRect(const OdGsDCPoint& minPoint, const OdGsDCPoint& maxPoint) : m_min(minPoint), m_max(maxPoint) { }
123  OdGsDCRect(long xMin, long xMax, long yMin, long yMax) : m_min(xMin,yMin), m_max(xMax,yMax) { }
125 
126  OdGsDCRect & operator=(const OdGsDCRect& dcRect)
127  {
128  m_min = dcRect.m_min;
129  m_max = dcRect.m_max;
130  return*this;
131  }
132  void operator|=(const OdGsDCRect& dcRect)
133  {
134  if(m_min.x > dcRect.m_min.x)
135  m_min.x = dcRect.m_min.x;
136  if(m_max.x < dcRect.m_max.x)
137  m_max.x = dcRect.m_max.x;
138 
139  if(m_min.y > dcRect.m_min.y)
140  m_min.y = dcRect.m_min.y;
141  if(m_max.y < dcRect.m_max.y)
142  m_max.y = dcRect.m_max.y;
143  }
144  void operator&=(const OdGsDCRect& dcRect)
145  {
146  intersectWith(dcRect);
147  }
148  bool operator==(const OdGsDCRect& dcRect) const
149  {
150  return m_min == dcRect.m_min && m_max == dcRect.m_max;
151  }
152  bool operator!=(const OdGsDCRect& dcRect) const
153  {
154  return !(*this == dcRect);
155  }
159  void set_null()
160  {
163  }
164 
168  bool is_null() const
169  {
170  ODA_ASSERT((m_min.x <= m_max.x && m_min.y <= m_max.y) ||
172  return m_min.x > m_max.x;
173  }
174 
182  bool within(const OdGsDCRect& dcRect) const
183  {
184  ODA_ASSERT(!is_null());
185  return m_min.x >= dcRect.m_min.x &&
186  m_min.y >= dcRect.m_min.y &&
187  m_max.x <= dcRect.m_max.x &&
188  m_max.y <= dcRect.m_max.y;
189  }
190 
191  void offset(long x, long y)
192  {
193  m_min.x += x;
194  m_max.x += x;
195  m_min.y += y;
196  m_max.y += y;
197  }
198 
199  void intersectWith(const OdGsDCRect& dcRect, bool bValidate = true)
200  {
201  if(m_min.x < dcRect.m_min.x)
202  m_min.x = dcRect.m_min.x;
203  if(m_max.x > dcRect.m_max.x)
204  m_max.x = dcRect.m_max.x;
205 
206  if(m_min.y < dcRect.m_min.y)
207  m_min.y = dcRect.m_min.y;
208  if(m_max.y > dcRect.m_max.y)
209  m_max.y = dcRect.m_max.y;
210 
211  if(bValidate && (m_min.x > m_max.x || m_min.y > m_max.y))
212  *this = Null;
213  }
214 
215  void normalize()
216  {
217  long tmp;
218  if (m_max.x < m_min.x)
219  tmp = m_max.x, m_max.x = m_min.x, m_min.x = tmp;
220  if (m_max.y < m_min.y)
221  tmp = m_max.y, m_max.y = m_min.y, m_min.y = tmp;
222  }
223 
226 };
227 
242 {
243 public:
252 
253  OdGsDCRectDouble(const OdGePoint2d& minPoint, const OdGePoint2d& maxPoint)
254  : m_min(minPoint), m_max(maxPoint) { }
255 
256  OdGsDCRectDouble(double xMin, double xMax, double yMin, double yMax)
257  : m_min(xMin,yMin), m_max(xMax,yMax) { }
258 
259  explicit OdGsDCRectDouble(const OdGsDCRect& rc)
260  : m_min(rc.m_min.x, rc.m_min.y), m_max(rc.m_max.x,rc.m_max.y) { }
261 
263  {
264  m_min.x = dcRect.m_min.x;
265  m_min.y = dcRect.m_min.y;
266  m_max.x = dcRect.m_max.x;
267  m_max.y = dcRect.m_max.y;
268  return *this;
269  }
270  bool operator==(const OdGsDCRectDouble& dcRect) const
271  {
272  return m_min == dcRect.m_min && m_max == dcRect.m_max;
273  }
274  bool operator!=(const OdGsDCRectDouble& dcRect) const
275  {
276  return !(*this == dcRect);
277  }
278 
280  {
281  return OdGsDCRect(OdGsDCRect(
286  }
287 
290 };
291 
292 //FELIX_CHANGE_BEGIN
293 template <class TRect>
294 void intersectWith(TRect& dcRectThis, const TRect& dcRect, bool bValidate = true)
295 {
296  if(dcRectThis.m_min.x < dcRect.m_min.x)
297  dcRectThis.m_min.x = dcRect.m_min.x;
298  if(dcRectThis.m_max.x > dcRect.m_max.x)
299  dcRectThis.m_max.x = dcRect.m_max.x;
300 
301  if(dcRectThis.m_min.y < dcRect.m_min.y)
302  dcRectThis.m_min.y = dcRect.m_min.y;
303  if(dcRectThis.m_max.y > dcRect.m_max.y)
304  dcRectThis.m_max.y = dcRect.m_max.y;
305 
306  if(bValidate && (dcRectThis.m_min.x > dcRectThis.m_max.x || dcRectThis.m_min.y > dcRectThis.m_max.y))
307  {
308  dcRectThis.m_min.x = SCALAR_MAX;
309  dcRectThis.m_min.y = SCALAR_MAX;
310  dcRectThis.m_max.x = SCALAR_MIN;
311  dcRectThis.m_max.y = SCALAR_MIN;
312  }
313 };
314 
315 template <class TRect, class T>
316 void offset(TRect& dcRectThis, T x, T y)
317 {
318  dcRectThis.m_min.x += x;
319  dcRectThis.m_max.x += x;
320  dcRectThis.m_min.y += y;
321  dcRectThis.m_max.y += y;
322 };
323 //FELIX_CHANGE_END
324 
325 typedef void* OdGsWindowingSystemID; // i.e. -- HWND
326 
328 {
329  kMfDisplay, //play for visualization. Default, valid for all metafile types.
330  //Following modes are valid only if metafile can be played as OdGiConveyorGeometry
331  //( if useMetafileAsGeometry() returns true).
332  kMfSelect, //play as geometry for selection
333  kMfNested, //play data of nested metafiles only
334  kMfExtents //play as geometry for extents calculation
335 };
336 
337 // Negative GETBIT
338 #ifndef GETBITNEG
339 #define GETBITNEG(flags, bit) (((flags) & (bit)) != (bit))
340 #endif
341 
342 #include "TD_PackPop.h"
343 
344 #endif // __GSDEFS_H_INCLUDED_
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
void * OdGsWindowingSystemID
Definition: GsDefs.h:322
#define SCALAR_MAX
Definition: GsDefs.h:37
EMetafilePlayMode
Definition: GsDefs.h:328
@ kMfDisplay
Definition: GsDefs.h:329
@ kMfExtents
Definition: GsDefs.h:334
@ kMfNested
Definition: GsDefs.h:333
@ kMfSelect
Definition: GsDefs.h:332
#define SCALAR_MIN
Definition: GsDefs.h:36
void offset(TRect &dcRectThis, T x, T y)
Definition: GsDefs.h:316
void intersectWith(TRect &dcRectThis, const TRect &dcRect, bool bValidate=true)
Definition: GsDefs.h:294
int OdInt32
long OdTruncateToLong(double a)
Definition: OdRound.h:60
double x
Definition: GePoint2d.h:299
double y
Definition: GePoint2d.h:300
@ Minimum
Definition: GsDefs.h:56
bool operator!=(const OdGsDCPoint &dcPoint) const
Definition: GsDefs.h:88
bool operator==(const OdGsDCPoint &dcPoint) const
Definition: GsDefs.h:87
void operator=(const OdGsDCPoint &dcPoint)
Definition: GsDefs.h:86
OdGsDCPoint()
Definition: GsDefs.h:68
OdGsDCPoint(MinFlag)
Definition: GsDefs.h:74
OdGsDCPoint(OdInt32 xx, OdInt32 yy)
Definition: GsDefs.h:70
@ Maximum
Definition: GsDefs.h:55
OdInt32 y
Definition: GsDefs.h:93
void operator=(MinFlag)
Definition: GsDefs.h:84
OdInt32 x
Definition: GsDefs.h:92
OdGsDCPoint(MaxFlag)
Definition: GsDefs.h:73
void operator=(MaxFlag)
Definition: GsDefs.h:83
long operator[](unsigned int i) const
Definition: GsDefs.h:89
bool operator!=(const OdGsDCRectDouble &dcRect) const
Definition: GsDefs.h:274
OdGePoint2d m_min
Definition: GsDefs.h:288
OdGsDCRectDouble(const OdGePoint2d &minPoint, const OdGePoint2d &maxPoint)
Definition: GsDefs.h:253
OdGsDCRectDouble(double xMin, double xMax, double yMin, double yMax)
Definition: GsDefs.h:256
bool operator==(const OdGsDCRectDouble &dcRect) const
Definition: GsDefs.h:270
OdGsDCRect round() const
Definition: GsDefs.h:279
OdGsDCRectDouble & operator=(const OdGsDCRect &dcRect)
Definition: GsDefs.h:262
OdGePoint2d m_max
Definition: GsDefs.h:289
OdGsDCRectDouble(const OdGsDCRect &rc)
Definition: GsDefs.h:259
void offset(long x, long y)
Definition: GsDefs.h:191
OdGsDCRect()
Definition: GsDefs.h:121
void set_null()
Definition: GsDefs.h:159
OdGsDCPoint m_min
Definition: GsDefs.h:224
void normalize()
Definition: GsDefs.h:215
OdGsDCRect(NullFlag)
Definition: GsDefs.h:124
bool operator!=(const OdGsDCRect &dcRect) const
Definition: GsDefs.h:152
bool within(const OdGsDCRect &dcRect) const
Definition: GsDefs.h:182
bool is_null() const
Definition: GsDefs.h:168
OdGsDCRect(long xMin, long xMax, long yMin, long yMax)
Definition: GsDefs.h:123
OdGsDCRect & operator=(const OdGsDCRect &dcRect)
Definition: GsDefs.h:126
OdGsDCPoint m_max
Definition: GsDefs.h:225
void operator&=(const OdGsDCRect &dcRect)
Definition: GsDefs.h:144
void intersectWith(const OdGsDCRect &dcRect, bool bValidate=true)
Definition: GsDefs.h:199
bool operator==(const OdGsDCRect &dcRect) const
Definition: GsDefs.h:148
void operator|=(const OdGsDCRect &dcRect)
Definition: GsDefs.h:132
OdGsDCRect(const OdGsDCPoint &minPoint, const OdGsDCPoint &maxPoint)
Definition: GsDefs.h:122
GLfloat x
Definition: gles2_ext.h:314
GLfloat GLfloat y
Definition: gles2_ext.h:316