CFx SDK Documentation  2023 SP0
GsPageParams.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 _GSPAGEPARAMS_INCLUDED_
25 #define _GSPAGEPARAMS_INCLUDED_ /
26 
27 #include "TD_PackPush.h"
28 
29 #include "Ge/GeGbl.h" //FELIX_CHANGE
30 
43 {
44  double m_dPaperWidth; // All are in mm.
45  double m_dPaperHeight;
46 
47  double m_dLeftMargin;
48  double m_dRightMargin;
49  double m_dTopMargin;
50  double m_dBottomMargin;
51 public:
53  : m_dPaperWidth(210.)
54  , m_dPaperHeight(297.)
55  , m_dLeftMargin(0.)
56  , m_dRightMargin(0.)
57  , m_dTopMargin(0.)
58  , m_dBottomMargin(0.)
59  {
60  }
61 
62  OdGsPageParams(double dPaperWidth, double dPaperHeight)
63  : m_dPaperWidth(dPaperWidth)
64  , m_dPaperHeight(dPaperHeight)
65  , m_dLeftMargin(0.)
66  , m_dRightMargin(0.)
67  , m_dTopMargin(0.)
68  , m_dBottomMargin(0.)
69  {
70  }
71 
73  {
74  }
75 
77  {
78  *this = data;
79  }
80 
82  {
83  m_dPaperWidth = from.m_dPaperWidth; // All are in mm.
84  m_dPaperHeight = from.m_dPaperHeight;
85  m_dLeftMargin = from.m_dLeftMargin;
86  m_dRightMargin = from.m_dRightMargin;
87  m_dTopMargin = from.m_dTopMargin;
88  m_dBottomMargin = from.m_dBottomMargin;
89  return *this;
90  }
91 
92  double getPaperWidth() const { return m_dPaperWidth; }
93  double getPaperHeight() const { return m_dPaperHeight; }
94  double getLeftMargin() const { return m_dLeftMargin; }
95  double getRightMargin() const { return m_dRightMargin; }
96  double getTopMargin() const { return m_dTopMargin; }
97  double getBottomMargin() const { return m_dBottomMargin; }
98 
99  void set(
100  double dPaperWidth,
101  double dPaperHeight,
102  double dLeftMargin = 0.,
103  double dRightMargin = 0.,
104  double dTopMargin = 0.,
105  double dBottomMargin = 0.
106  )
107  {
108  //FELIX_CHANGE_BEGIN
109  const double dTol = odmax( 1e-10, OdGeContext::gZeroTol.equalPoint() );
110  if ( !OdPositive( dPaperWidth, dTol ) || !OdPositive( dPaperHeight, dTol ) || OdNegative( dLeftMargin, dTol ) || OdNegative( dRightMargin, dTol ) || OdNegative( dTopMargin, dTol ) || OdNegative( dBottomMargin, dTol ) )
111  {
112  ODA_FAIL_ONCE();
113  return;
114  }
115 
116  if ( OdGreaterOrEqual( dLeftMargin + dRightMargin, dPaperWidth, dTol ) )
117  {
118  ODA_FAIL_ONCE();
119  return;
120  }
121 
122  if ( OdGreaterOrEqual( dTopMargin + dBottomMargin, dPaperHeight, dTol ) )
123  {
124  ODA_FAIL_ONCE();
125  return;
126  }
127  //FELIX_CHANGE_END
128 
129  m_dPaperWidth = dPaperWidth;
130  m_dPaperHeight = dPaperHeight;
131  m_dLeftMargin = dLeftMargin;
132  m_dRightMargin = dRightMargin;
133  m_dTopMargin = dTopMargin;
134  m_dBottomMargin = dBottomMargin;
135  }
136 
137  void scale(double dScale)
138  {
139  if (dScale > 1e-8)
140  {
141  m_dPaperWidth *= dScale;
142  m_dPaperHeight *= dScale;
143  m_dLeftMargin *= dScale;
144  m_dRightMargin *= dScale;
145  m_dTopMargin *= dScale;
146  m_dBottomMargin *= dScale;
147  }
148  }
149 };
150 
151 #include "TD_PackPop.h"
152 
153 #endif //_GSPAGEPARAMS_INCLUDED_
#define ODA_FAIL_ONCE()
Definition: DebugStuff.h:66
#define odmax(X, Y)
Definition: OdPlatform.h:35
bool OdNegative(double x, double tol=1.e-10)
Definition: OdaDefs.h:510
bool OdPositive(double x, double tol=1.e-10)
Definition: OdaDefs.h:505
bool OdGreaterOrEqual(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:545
double getRightMargin() const
Definition: GsPageParams.h:95
double getPaperHeight() const
Definition: GsPageParams.h:93
OdGsPageParams(const OdGsPageParams &data)
Definition: GsPageParams.h:76
void scale(double dScale)
Definition: GsPageParams.h:137
OdGsPageParams(double dPaperWidth, double dPaperHeight)
Definition: GsPageParams.h:62
void set(double dPaperWidth, double dPaperHeight, double dLeftMargin=0., double dRightMargin=0., double dTopMargin=0., double dBottomMargin=0.)
Definition: GsPageParams.h:99
double getTopMargin() const
Definition: GsPageParams.h:96
double getBottomMargin() const
Definition: GsPageParams.h:97
double getPaperWidth() const
Definition: GsPageParams.h:92
double getLeftMargin() const
Definition: GsPageParams.h:94
OdGsPageParams & operator=(const OdGsPageParams &from)
Definition: GsPageParams.h:81
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition: gles2_ext.h:110
static GE_STATIC_EXPORT OdGeTol gZeroTol
Definition: GeGbl.h:67