CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GsDefs.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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 OdGsDCPoint& operator=(const OdGsDCPoint& dcPoint) = default;
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
199 OdGsDCRect& operator=(const OdGsDCRect& dcRect) = default;
200
208 void operator|=(const OdGsDCRect& dcRect)
209 {
210 if(m_min.x > dcRect.m_min.x)
211 m_min.x = dcRect.m_min.x;
212 if(m_max.x < dcRect.m_max.x)
213 m_max.x = dcRect.m_max.x;
214
215 if(m_min.y > dcRect.m_min.y)
216 m_min.y = dcRect.m_min.y;
217 if(m_max.y < dcRect.m_max.y)
218 m_max.y = dcRect.m_max.y;
219 }
220
228 void operator&=(const OdGsDCRect& dcRect)
229 {
230 intersectWith(dcRect);
231 }
232
241 bool operator==(const OdGsDCRect& dcRect) const
242 {
243 return m_min == dcRect.m_min && m_max == dcRect.m_max;
244 }
245
254 bool operator!=(const OdGsDCRect& dcRect) const
255 {
256 return !(*this == dcRect);
257 }
258
266
272 bool is_null() const
273 {
274 ODA_ASSERT((m_min.x <= m_max.x && m_min.y <= m_max.y) ||
276 return m_min.x > m_max.x;
277 }
278
288 bool within(const OdGsDCRect& dcRect) const
289 {
290 ODA_ASSERT(!is_null());
291 return m_min.x >= dcRect.m_min.x &&
292 m_min.y >= dcRect.m_min.y &&
293 m_max.x <= dcRect.m_max.x &&
294 m_max.y <= dcRect.m_max.y;
295 }
296
302 void offset(long x, long y)
303 {
304 m_min.x += x;
305 m_max.x += x;
306 m_min.y += y;
307 m_max.y += y;
308 }
309
315 void intersectWith(const OdGsDCRect& dcRect, bool bValidate = true)
316 {
317 if(m_min.x < dcRect.m_min.x)
318 m_min.x = dcRect.m_min.x;
319 if(m_max.x > dcRect.m_max.x)
320 m_max.x = dcRect.m_max.x;
321
322 if(m_min.y < dcRect.m_min.y)
323 m_min.y = dcRect.m_min.y;
324 if(m_max.y > dcRect.m_max.y)
325 m_max.y = dcRect.m_max.y;
326
327 if(bValidate && (m_min.x > m_max.x || m_min.y > m_max.y))
328 *this = Null;
329 }
330
335 {
336 long tmp;
337 if (m_max.x < m_min.x)
338 tmp = m_max.x, m_max.x = m_min.x, m_min.x = tmp;
339 if (m_max.y < m_min.y)
340 tmp = m_max.y, m_max.y = m_min.y, m_min.y = tmp;
341 }
342
351 bool isDisjoint(const OdGsDCRect& r) const
352 {
353 return (r.m_min.x > m_max.x || r.m_min.y > m_max.y ||
354 m_min.x > r.m_max.x || m_min.y > r.m_max.y);
355 }
356
361};
362
377{
378public:
383
390 OdGsDCRectDouble(const OdGePoint2d& minPoint, const OdGePoint2d& maxPoint)
391 : m_min(minPoint), m_max(maxPoint) { }
392
401 OdGsDCRectDouble(double xMin, double xMax, double yMin, double yMax)
402 : m_min(xMin,yMin), m_max(xMax,yMax) { }
403
409 explicit OdGsDCRectDouble(const OdGsDCRect& rc)
410 : m_min(rc.m_min.x, rc.m_min.y), m_max(rc.m_max.x,rc.m_max.y) { }
411
418 {
419 m_min.x = dcRect.m_min.x;
420 m_min.y = dcRect.m_min.y;
421 m_max.x = dcRect.m_max.x;
422 m_max.y = dcRect.m_max.y;
423 return *this;
424 }
425
434 bool operator==(const OdGsDCRectDouble& dcRect) const
435 {
436 return m_min == dcRect.m_min && m_max == dcRect.m_max;
437 }
438
447 bool operator!=(const OdGsDCRectDouble& dcRect) const
448 {
449 return !(*this == dcRect);
450 }
451
463
467};
468
469//FELIX_CHANGE_BEGIN
470template <class TRect>
471void intersectWith(TRect& dcRectThis, const TRect& dcRect, bool bValidate = true)
472{
473 if(dcRectThis.m_min.x < dcRect.m_min.x)
474 dcRectThis.m_min.x = dcRect.m_min.x;
475 if(dcRectThis.m_max.x > dcRect.m_max.x)
476 dcRectThis.m_max.x = dcRect.m_max.x;
477
478 if(dcRectThis.m_min.y < dcRect.m_min.y)
479 dcRectThis.m_min.y = dcRect.m_min.y;
480 if(dcRectThis.m_max.y > dcRect.m_max.y)
481 dcRectThis.m_max.y = dcRect.m_max.y;
482
483 if(bValidate && (dcRectThis.m_min.x > dcRectThis.m_max.x || dcRectThis.m_min.y > dcRectThis.m_max.y))
484 {
485 dcRectThis.m_min.x = SCALAR_MAX;
486 dcRectThis.m_min.y = SCALAR_MAX;
487 dcRectThis.m_max.x = SCALAR_MIN;
488 dcRectThis.m_max.y = SCALAR_MIN;
489 }
490};
491
492template <class TRect, class T>
493void offset(TRect& dcRectThis, T x, T y)
494{
495 dcRectThis.m_min.x += x;
496 dcRectThis.m_max.x += x;
497 dcRectThis.m_min.y += y;
498 dcRectThis.m_max.y += y;
499};
500//FELIX_CHANGE_END
501
506
523
524// Negative GETBIT
525#ifndef GETBITNEG
526#define GETBITNEG(flags, bit) (((flags) & (bit)) != (bit))
527#endif
528
529#include "TD_PackPop.h"
530
531#endif // __GSDEFS_H_INCLUDED_
#define ODA_ASSERT(exp)
Definition DebugStuff.h:57
void * OdGsWindowingSystemID
Definition GsDefs.h:505
#define SCALAR_MAX
Definition GsDefs.h:38
EMetafilePlayMode
Definition GsDefs.h:511
@ kMfDisplay
Definition GsDefs.h:515
@ kMfExtents
Definition GsDefs.h:521
@ kMfNested
Definition GsDefs.h:519
@ kMfSelect
Definition GsDefs.h:517
@ kMfUndefined
Definition GsDefs.h:513
#define SCALAR_MIN
Definition GsDefs.h:37
void intersectWith(TRect &dcRectThis, const TRect &dcRect, bool bValidate=true)
Definition GsDefs.h:471
int OdInt32
long OdTruncateToLong(double a)
Definition OdRound.h:61
bool operator!=(const OdGsDCPoint &dcPoint) const
Definition GsDefs.h:134
bool operator==(const OdGsDCPoint &dcPoint) const
Definition GsDefs.h:124
OdGsDCPoint()
Definition GsDefs.h:64
OdGsDCPoint(MinFlag)
Definition GsDefs.h:93
OdGsDCPoint(OdInt32 xx, OdInt32 yy)
Definition GsDefs.h:76
OdGsDCPoint & operator=(const OdGsDCPoint &dcPoint)=default
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:447
OdGePoint2d m_min
Definition GsDefs.h:464
OdGsDCRectDouble(const OdGePoint2d &minPoint, const OdGePoint2d &maxPoint)
Definition GsDefs.h:390
OdGsDCRectDouble(double xMin, double xMax, double yMin, double yMax)
Definition GsDefs.h:401
bool operator==(const OdGsDCRectDouble &dcRect) const
Definition GsDefs.h:434
OdGsDCRect round() const
Definition GsDefs.h:455
OdGsDCRectDouble & operator=(const OdGsDCRect &dcRect)
Definition GsDefs.h:417
OdGePoint2d m_max
Definition GsDefs.h:466
OdGsDCRectDouble(const OdGsDCRect &rc)
Definition GsDefs.h:409
void offset(long x, long y)
Definition GsDefs.h:302
OdGsDCRect()
Definition GsDefs.h:169
void set_null()
Definition GsDefs.h:261
OdGsDCPoint m_min
Definition GsDefs.h:358
void normalize()
Definition GsDefs.h:334
OdGsDCRect(NullFlag)
Definition GsDefs.h:192
bool operator!=(const OdGsDCRect &dcRect) const
Definition GsDefs.h:254
bool within(const OdGsDCRect &dcRect) const
Definition GsDefs.h:288
bool is_null() const
Definition GsDefs.h:272
OdGsDCRect(long xMin, long xMax, long yMin, long yMax)
Definition GsDefs.h:187
OdGsDCPoint m_max
Definition GsDefs.h:360
void operator&=(const OdGsDCRect &dcRect)
Definition GsDefs.h:228
void intersectWith(const OdGsDCRect &dcRect, bool bValidate=true)
Definition GsDefs.h:315
bool isDisjoint(const OdGsDCRect &r) const
Definition GsDefs.h:351
bool operator==(const OdGsDCRect &dcRect) const
Definition GsDefs.h:241
void operator|=(const OdGsDCRect &dcRect)
Definition GsDefs.h:208
OdGsDCRect(const OdGsDCPoint &minPoint, const OdGsDCPoint &maxPoint)
Definition GsDefs.h:177
OdGsDCRect & operator=(const OdGsDCRect &dcRect)=default
GLfloat x
Definition gles2_ext.h:314
GLintptr offset
Definition gles2_ext.h:183
GLfloat GLfloat y
Definition gles2_ext.h:316