KiCad PCB EDA Suite
Loading...
Searching...
No Matches
page_info.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright (C) 2008-2013 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2007-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
30#ifndef PAGE_INFO_H
31#define PAGE_INFO_H
32
33#include <wx/string.h>
34#include <math/vector2d.h>
35
37#define MIN_PAGE_SIZE_MILS 1000
38#define MAX_PAGE_SIZE_PCBNEW_MILS 48000
39#define MAX_PAGE_SIZE_EESCHEMA_MILS 120000
40
42#define MIN_PAGE_SIZE_MM 25.4
43#define MAX_PAGE_SIZE_PCBNEW_MM 48000*.0254
44#define MAX_PAGE_SIZE_EESCHEMA_MM 120000*.0254
45
46class OUTPUTFORMATTER;
47
58{
59public:
60 PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false );
61
62 // paper size names which are part of the public API, pass to SetType() or
63 // above constructor.
64
65 // these were once wxStrings, but it caused static construction sequence problems:
66 static const wxChar A5[];
67 static const wxChar A4[];
68 static const wxChar A3[];
69 static const wxChar A2[];
70 static const wxChar A1[];
71 static const wxChar A0[];
72 static const wxChar A[];
73 static const wxChar B[];
74 static const wxChar C[];
75 static const wxChar D[];
76 static const wxChar E[];
77 static const wxChar GERBER[];
78 static const wxChar USLetter[];
79 static const wxChar USLegal[];
80 static const wxChar USLedger[];
81 static const wxChar Custom[];
82
83
97 bool SetType( const wxString& aStandardPageDescriptionName, bool aIsPortrait = false );
98 const wxString& GetType() const { return m_type; }
99
103 bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; }
104
108 bool IsCustom() const;
109
120 void SetPortrait( bool aIsPortrait );
121 bool IsPortrait() const { return m_portrait; }
122
126 wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
127
131 wxPaperSize GetPaperId() const { return m_paper_id; }
132
133 void SetWidthMM( double aWidthInMM ) { SetWidthMils( aWidthInMM * 1000 / 25.4 ); }
134 void SetWidthMils( double aWidthInMils );
135 double GetWidthMils() const { return m_size.x; }
136 double GetWidthMM() const { return m_size.x * 25.4 / 1000; }
137
138 void SetHeightMM( double aHeightInMM ) { SetHeightMils( aHeightInMM * 1000 / 25.4 ); }
139 void SetHeightMils( double aHeightInMils );
140 double GetHeightMils() const { return m_size.y; }
141 double GetHeightMM() const { return m_size.y * 25.4 / 1000; }
142
143 const VECTOR2D& GetSizeMils() const { return m_size; }
144
152 int GetWidthIU( double aIUScale ) const { return aIUScale * GetWidthMils(); }
153
161 int GetHeightIU( double aIUScale ) const { return aIUScale * GetHeightMils(); }
162
170 const VECTOR2D GetSizeIU( double aIUScale ) const
171 {
172 return VECTOR2D( GetWidthIU( aIUScale ), GetHeightIU( aIUScale ) );
173 }
174
179 static void SetCustomWidthMils( double aWidthInMils );
180
185 static void SetCustomHeightMils( double aHeightInMils );
186
190 static double GetCustomWidthMils() { return s_user_width; }
191
195 static double GetCustomHeightMils() { return s_user_height; }
196
205 void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
206
207protected:
208 // only the class implementation(s) may use this constructor
209 PAGE_INFO( const VECTOR2D& aSizeMils, const wxString& aName, wxPaperSize aPaperId );
210
211private:
212 // standard pre-defined sizes
213 static const PAGE_INFO pageA5;
214 static const PAGE_INFO pageA4;
215 static const PAGE_INFO pageA3;
216 static const PAGE_INFO pageA2;
217 static const PAGE_INFO pageA1;
218 static const PAGE_INFO pageA0;
219 static const PAGE_INFO pageA;
220 static const PAGE_INFO pageB;
221 static const PAGE_INFO pageC;
222 static const PAGE_INFO pageD;
223 static const PAGE_INFO pageE;
224 static const PAGE_INFO pageGERBER;
225
227 static const PAGE_INFO pageUSLegal;
229
230 static const PAGE_INFO pageUser;
231
232 // all dimensions here are in mils
233
234 wxString m_type;
236
238
239 wxPaperSize m_paper_id;
240
241 static double s_user_height;
242 static double s_user_width;
243
244 void updatePortrait();
245
247};
248
249#endif // PAGE_INFO_H
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:58
static const wxChar A3[]
Definition: page_info.h:68
static const wxChar USLedger[]
Definition: page_info.h:80
VECTOR2D m_size
mils
Definition: page_info.h:235
static const wxChar USLetter[]
Definition: page_info.h:78
static const PAGE_INFO pageD
Definition: page_info.h:222
static const wxChar USLegal[]
Definition: page_info.h:79
static const wxChar A0[]
Definition: page_info.h:71
static const PAGE_INFO pageC
Definition: page_info.h:221
static const wxChar A4[]
Definition: page_info.h:67
bool m_portrait
true if portrait, false if landscape
Definition: page_info.h:237
static const PAGE_INFO pageA5
Definition: page_info.h:213
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
Definition: page_info.cpp:275
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:189
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:161
static void SetCustomWidthMils(double aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
Definition: page_info.cpp:235
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:81
static const PAGE_INFO pageUSLedger
Definition: page_info.h:228
static const PAGE_INFO pageE
Definition: page_info.h:223
void SetWidthMM(double aWidthInMM)
Definition: page_info.h:133
static double s_user_width
Definition: page_info.h:242
static const PAGE_INFO pageA4
Definition: page_info.h:214
static const PAGE_INFO pageUser
Definition: page_info.h:230
void SetHeightMils(double aHeightInMils)
Definition: page_info.cpp:261
static const wxChar A1[]
Definition: page_info.h:70
static double s_user_height
Definition: page_info.h:241
static const PAGE_INFO pageUSLetter
Definition: page_info.h:226
void SetHeightMM(double aHeightInMM)
Definition: page_info.h:138
double GetHeightMM() const
Definition: page_info.h:141
static const wxChar A2[]
Definition: page_info.h:69
double GetWidthMM() const
Definition: page_info.h:136
const VECTOR2D & GetSizeMils() const
Definition: page_info.h:143
wxPrintOrientation GetWxOrientation() const
Definition: page_info.h:126
static double GetCustomHeightMils()
Definition: page_info.h:195
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:170
void updatePortrait()
Definition: page_info.cpp:98
wxString m_type
paper type: A4, A3, etc.
Definition: page_info.h:234
double GetHeightMils() const
Definition: page_info.h:140
wxPaperSize GetPaperId() const
Definition: page_info.h:131
static const PAGE_INFO pageB
Definition: page_info.h:220
static const PAGE_INFO pageA3
Definition: page_info.h:215
static const wxChar GERBER[]
Definition: page_info.h:77
const wxString & GetType() const
Definition: page_info.h:98
static const PAGE_INFO pageA
Definition: page_info.h:219
static const PAGE_INFO pageA1
Definition: page_info.h:217
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:152
double GetWidthMils() const
Definition: page_info.h:135
bool IsCustom() const
Definition: page_info.cpp:183
bool IsPortrait() const
Definition: page_info.h:121
void SetWidthMils(double aWidthInMils)
Definition: page_info.cpp:247
static double GetCustomWidthMils()
Definition: page_info.h:190
static const PAGE_INFO pageA0
Definition: page_info.h:218
bool IsDefault() const
Definition: page_info.h:103
static void SetCustomHeightMils(double aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
Definition: page_info.cpp:241
static const PAGE_INFO pageUSLegal
Definition: page_info.h:227
void setMargins()
static const PAGE_INFO pageA2
Definition: page_info.h:216
static const wxChar A5[]
Definition: page_info.h:66
wxPaperSize m_paper_id
wx' style paper id.
Definition: page_info.h:239
static const PAGE_INFO pageGERBER
Definition: page_info.h:224
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:122
VECTOR2< double > VECTOR2D
Definition: vector2d.h:587