CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GsDefs.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 __GSDEFS_H_INCLUDED_
25#define __GSDEFS_H_INCLUDED_
26
27#include "TD_PackPush.h"
28#include "OdRound.h"
29#include "Ge/GePoint2d.h"
30
31//****************************************************************************
32// Helper classes
33//****************************************************************************
34
35// copied(with modification) from limits.h to avoid extra #includes
36
37#define SCALAR_MIN (-2147483647 - 1) // minimum(signed) int32 value
38#define SCALAR_MAX 2147483647 // maximum(signed) int32 value
39
54{
55public:
57 enum MaxFlag { Maximum };
59 enum MinFlag { Minimum };
60
64 OdGsDCPoint() : x(0), y(0) { }
65
72 //FELIX_CHANGE_BEGIN
73 /*
74 OdGsDCPoint(long xx, long yy) : x(xx), y(yy) { }
75 */
76 OdGsDCPoint(OdInt32 xx, OdInt32 yy) : x(xx), y(yy) { }
77 //FELIX_CHANGE_END
78
86
94
101
108
114 void operator=(const OdGsDCPoint& dcPoint) { x = dcPoint.x; y = dcPoint.y; }
115
124 bool operator==(const OdGsDCPoint& dcPoint) const { return x == dcPoint.x && y == dcPoint.y; }
125
134 bool operator!=(const OdGsDCPoint& dcPoint) const { return x != dcPoint.x || y != dcPoint.y; }
135
141 inline long operator[](unsigned int i) const { return *(&x + i); }
142
143 //FELIX_CHANGE_BEGIN
144 OdInt32 x; // X-coordinate.
145 OdInt32 y; // Y-coordinate.
146 //FELIX_CHANGE_END
147};
148
163{
164public:
165 enum NullFlag { Null };
170
177 OdGsDCRect(const OdGsDCPoint& minPoint, const OdGsDCPoint& maxPoint) : m_min(minPoint), m_max(maxPoint) { }
178
187 OdGsDCRect(long xMin, long xMax, long yMin, long yMax) : m_min(xMin,yMin), m_max(xMax,yMax) { }
188
193
200 {
201 m_min = dcRect.m_min;
202 m_max = dcRect.m_max;
203 return*this;
204 }
212 void operator|=(const OdGsDCRect& dcRect)
213 {
214 if(m_min.x > dcRect.m_min.x)
215 m_min.x = dcRect.m_min.x;
216 if(m_max.x < dcRect.m_max.x)
217 m_max.x = dcRect.m_max.x;
218
219 if(m_min.y > dcRect.m_min.y)
220 m_min.y = dcRect.m_min.y;
221 if(m_max.y < dcRect.m_max.y)
222 m_max.y = dcRect.m_max.y;
223 }
224
232 void operator&=(const OdGsDCRect& dcRect)
233 {
234 intersectWith(dcRect);
235 }
236
245 bool operator==(const OdGsDCRect& dcRect) const
246 {
247 return m_min == dcRect.m_min && m_max == dcRect.m_max;
248 }
249
258 bool operator!=(const OdGsDCRect& dcRect) const
259 {
260 return !(*this == dcRect);
261 }
265 void set_null()
266 {
269 }
270
276 bool is_null() const
277 {
278 ODA_ASSERT((m_min.x <= m_max.x && m_min.y <= m_max.y) ||
280 return m_min.x > m_max.x;
281 }
282
292 bool within(const OdGsDCRect& dcRect) const
293 {
294 ODA_ASSERT(!is_null());
295 return m_min.x >= dcRect.m_min.x &&
296 m_min.y >= dcRect.m_min.y &&
297 m_max.x <= dcRect.m_max.x &&
298 m_max.y <= dcRect.m_max.y;
299 }
300
306 void offset(long x, long y)
307 {
308 m_min.x += x;
309 m_max.x += x;
310 m_min.y += y;
311 m_max.y += y;
312 }
313
319 void intersectWith(const OdGsDCRect& dcRect, bool bValidate = true)
320 {
321 if(m_min.x < dcRect.m_min.x)
322 m_min.x = dcRect.m_min.x;
323 if(m_max.x > dcRect.m_max.x)
324 m_max.x = dcRect.m_max.x;
325
326 if(m_min.y < dcRect.m_min.y)
327 m_min.y = dcRect.m_min.y;
328 if(m_max.y > dcRect.m_max.y)
329 m_max.y = dcRect.m_max.y;
330
331 if(bValidate && (m_min.x > m_max.x || m_min.y > m_max.y))
332 *this = Null;
333 }
334
339 {
340 long tmp;
341 if (m_max.x < m_min.x)
342 tmp = m_max.x, m_max.x = m_min.x, m_min.x = tmp;
343 if (m_max.y < m_min.y)
344 tmp = m_max.y, m_max.y = m_min.y, m_min.y = tmp;
345 }
346
355 bool isDisjoint(const OdGsDCRect& r) const
356 {
357 return (r.m_min.x > m_max.x || r.m_min.y > m_max.y ||
358 m_min.x > r.m_max.x || m_min.y > r.m_max.y);
359 }
360
365};
366
381{
382public:
387
394 OdGsDCRectDouble(const OdGePoint2d& minPoint, const OdGePoint2d& maxPoint)
395 : m_min(minPoint), m_max(maxPoint) { }
396
405 OdGsDCRectDouble(double xMin, double xMax, double yMin, double yMax)
406 : m_min(xMin,yMin), m_max(xMax,yMax) { }
407
413 explicit OdGsDCRectDouble(const OdGsDCRect& rc)
414 : m_min(rc.m_min.x, rc.m_min.y), m_max(rc.m_max.x,rc.m_max.y) { }
415
422 {
423 m_min.x = dcRect.m_min.x;
424 m_min.y = dcRect.m_min.y;
425 m_max.x = dcRect.m_max.x;
426 m_max.y = dcRect.m_max.y;
427 return *this;
428 }
429
438 bool operator==(const OdGsDCRectDouble& dcRect) const
439 {
440 return m_min == dcRect.m_min && m_max == dcRect.m_max;
441 }
442
451 bool operator!=(const OdGsDCRectDouble& dcRect) const
452 {
453 return !(*this == dcRect);
454 }
455
460 {
461 return OdGsDCRect(OdGsDCRect(
466 }
471};
472
473//FELIX_CHANGE_BEGIN
474template <class TRect>
475void intersectWith(TRect& dcRectThis, const TRect& dcRect, bool bValidate = true)
476{
477 if(dcRectThis.m_min.x < dcRect.m_min.x)
478 dcRectThis.m_min.x = dcRect.m_min.x;
479 if(dcRectThis.m_max.x > dcRect.m_max.x)
480 dcRectThis.m_max.x = dcRect.m_max.x;
481
482 if(dcRectThis.m_min.y < dcRect.m_min.y)
483 dcRectThis.m_min.y = dcRect.m_min.y;
484 if(dcRectThis.m_max.y > dcRect.m_max.y)
485 dcRectThis.m_max.y = dcRect.m_max.y;
486
487 if(bValidate && (dcRectThis.m_min.x > dcRectThis.m_max.x || dcRectThis.m_min.y > dcRectThis.m_max.y))
488 {
489 dcRectThis.m_min.x = SCALAR_MAX;
490 dcRectThis.m_min.y = SCALAR_MAX;
491 dcRectThis.m_max.x = SCALAR_MIN;
492 dcRectThis.m_max.y = SCALAR_MIN;
493 }
494};
495
496template <class TRect, class T>
497void offset(TRect& dcRectThis, T x, T y)
498{
499 dcRectThis.m_min.x += x;
500 dcRectThis.m_max.x += x;
501 dcRectThis.m_min.y += y;
502 dcRectThis.m_max.y += y;
503};
504//FELIX_CHANGE_END
505
510
515{
525
526// Negative GETBIT
527#ifndef GETBITNEG
528#define GETBITNEG(flags, bit) (((flags) & (bit)) != (bit))
529#endif
530
531#include "TD_PackPop.h"
532
533#endif // __GSDEFS_H_INCLUDED_
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
void * OdGsWindowingSystemID
Definition: GsDefs.h:509
#define SCALAR_MAX
Definition: GsDefs.h:38
EMetafilePlayMode
Definition: GsDefs.h:515
@ kMfDisplay
Definition: GsDefs.h:517
@ kMfExtents
Definition: GsDefs.h:523
@ kMfNested
Definition: GsDefs.h:521
@ kMfSelect
Definition: GsDefs.h:519
#define SCALAR_MIN
Definition: GsDefs.h:37
void intersectWith(TRect &dcRectThis, const TRect &dcRect, bool bValidate=true)
Definition: GsDefs.h:475
int OdInt32
long OdTruncateToLong(double a)
Definition: OdRound.h:61
double x
Definition: GePoint2d.h:409
double y
Definition: GePoint2d.h:410
@ Minimum
Definition: GsDefs.h:59
bool operator!=(const OdGsDCPoint &dcPoint) const
Definition: GsDefs.h:134
bool operator==(const OdGsDCPoint &dcPoint) const
Definition: GsDefs.h:124
void operator=(const OdGsDCPoint &dcPoint)
Definition: GsDefs.h:114
OdGsDCPoint()
Definition: GsDefs.h:64
OdGsDCPoint(MinFlag)
Definition: GsDefs.h:93
OdGsDCPoint(OdInt32 xx, OdInt32 yy)
Definition: GsDefs.h:76
@ Maximum
Definition: GsDefs.h:57
OdInt32 y
Definition: GsDefs.h:145
void operator=(MinFlag)
Definition: GsDefs.h:107
OdInt32 x
Definition: GsDefs.h:144
OdGsDCPoint(MaxFlag)
Definition: GsDefs.h:85
void operator=(MaxFlag)
Definition: GsDefs.h:100
long operator[](unsigned int i) const
Definition: GsDefs.h:141
bool operator!=(const OdGsDCRectDouble &dcRect) const
Definition: GsDefs.h:451
OdGePoint2d m_min
Definition: GsDefs.h:468
OdGsDCRectDouble(const OdGePoint2d &minPoint, const OdGePoint2d &maxPoint)
Definition: GsDefs.h:394
OdGsDCRectDouble(double xMin, double xMax, double yMin, double yMax)
Definition: GsDefs.h:405
bool operator==(const OdGsDCRectDouble &dcRect) const
Definition: GsDefs.h:438
OdGsDCRect round() const
Definition: GsDefs.h:459
OdGsDCRectDouble & operator=(const OdGsDCRect &dcRect)
Definition: GsDefs.h:421
OdGePoint2d m_max
Definition: GsDefs.h:470
OdGsDCRectDouble(const OdGsDCRect &rc)
Definition: GsDefs.h:413
void offset(long x, long y)
Definition: GsDefs.h:306
OdGsDCRect()
Definition: GsDefs.h:169
void set_null()
Definition: GsDefs.h:265
OdGsDCPoint m_min
Definition: GsDefs.h:362
void normalize()
Definition: GsDefs.h:338
OdGsDCRect(NullFlag)
Definition: GsDefs.h:192
bool operator!=(const OdGsDCRect &dcRect) const
Definition: GsDefs.h:258
bool within(const OdGsDCRect &dcRect) const
Definition: GsDefs.h:292
bool is_null() const
Definition: GsDefs.h:276
OdGsDCRect(long xMin, long xMax, long yMin, long yMax)
Definition: GsDefs.h:187
OdGsDCPoint m_max
Definition: GsDefs.h:364
void operator&=(const OdGsDCRect &dcRect)
Definition: GsDefs.h:232
void intersectWith(const OdGsDCRect &dcRect, bool bValidate=true)
Definition: GsDefs.h:319
bool isDisjoint(const OdGsDCRect &r) const
Definition: GsDefs.h:355
bool operator==(const OdGsDCRect &dcRect) const
Definition: GsDefs.h:245
void operator|=(const OdGsDCRect &dcRect)
Definition: GsDefs.h:212
OdGsDCRect(const OdGsDCPoint &minPoint, const OdGsDCPoint &maxPoint)
Definition: GsDefs.h:177
OdGsDCRect & operator=(const OdGsDCRect &dcRect)
Definition: GsDefs.h:199
GLfloat x
Definition: gles2_ext.h:314
GLintptr offset
Definition: gles2_ext.h:183
GLfloat GLfloat y
Definition: gles2_ext.h:316