KiCad PCB EDA Suite
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-2022 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
36#include <richio.h> // for OUTPUTFORMATTER and IO_ERROR
37
39#define MIN_PAGE_SIZE_MILS 1000
40#define MAX_PAGE_SIZE_PCBNEW_MILS 48000
41#define MAX_PAGE_SIZE_EESCHEMA_MILS 120000
42
43
54{
55public:
56 PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false );
57
58 // paper size names which are part of the public API, pass to SetType() or
59 // above constructor.
60
61 // these were once wxStrings, but it caused static construction sequence problems:
62 static const wxChar A5[];
63 static const wxChar A4[];
64 static const wxChar A3[];
65 static const wxChar A2[];
66 static const wxChar A1[];
67 static const wxChar A0[];
68 static const wxChar A[];
69 static const wxChar B[];
70 static const wxChar C[];
71 static const wxChar D[];
72 static const wxChar E[];
73 static const wxChar GERBER[];
74 static const wxChar USLetter[];
75 static const wxChar USLegal[];
76 static const wxChar USLedger[];
77 static const wxChar Custom[];
78
79
93 bool SetType( const wxString& aStandardPageDescriptionName, bool aIsPortrait = false );
94 const wxString& GetType() const { return m_type; }
95
99 bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; }
100
104 bool IsCustom() const;
105
116 void SetPortrait( bool aIsPortrait );
117 bool IsPortrait() const { return m_portrait; }
118
122 wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
123
127 wxPaperSize GetPaperId() const { return m_paper_id; }
128
129 void SetWidthMils( int aWidthInMils );
130 int GetWidthMils() const { return m_size.x; }
131
132 void SetHeightMils( int aHeightInMils );
133 int GetHeightMils() const { return m_size.y; }
134
135 const VECTOR2I& GetSizeMils() const { return m_size; }
136
144 int GetWidthIU( double aIUScale ) const { return aIUScale * GetWidthMils(); }
145
153 int GetHeightIU( double aIUScale ) const { return aIUScale * GetHeightMils(); }
154
162 const wxSize GetSizeIU( double aIUScale ) const
163 {
164 return wxSize( GetWidthIU( aIUScale ), GetHeightIU( aIUScale ) );
165 }
166
171 static void SetCustomWidthMils( int aWidthInMils );
172
177 static void SetCustomHeightMils( int aHeightInMils );
178
182 static int GetCustomWidthMils() { return s_user_width; }
183
187 static int GetCustomHeightMils() { return s_user_height; }
188
197 void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
198
199protected:
200 // only the class implementation(s) may use this constructor
201 PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId );
202
203private:
204 // standard pre-defined sizes
205 static const PAGE_INFO pageA5;
206 static const PAGE_INFO pageA4;
207 static const PAGE_INFO pageA3;
208 static const PAGE_INFO pageA2;
209 static const PAGE_INFO pageA1;
210 static const PAGE_INFO pageA0;
211 static const PAGE_INFO pageA;
212 static const PAGE_INFO pageB;
213 static const PAGE_INFO pageC;
214 static const PAGE_INFO pageD;
215 static const PAGE_INFO pageE;
216 static const PAGE_INFO pageGERBER;
217
219 static const PAGE_INFO pageUSLegal;
221
222 static const PAGE_INFO pageUser;
223
224 // all dimensions here are in mils
225
226 wxString m_type;
228
230
231 wxPaperSize m_paper_id;
232
233 static int s_user_height;
234 static int s_user_width;
235
236 void updatePortrait();
237
239};
240
241#endif // PAGE_INFO_H
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:310
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
static const wxChar A3[]
Definition: page_info.h:64
static const wxChar USLedger[]
Definition: page_info.h:76
static const wxChar USLetter[]
Definition: page_info.h:74
static const PAGE_INFO pageD
Definition: page_info.h:214
static const wxChar USLegal[]
Definition: page_info.h:75
static const wxChar A0[]
Definition: page_info.h:67
static void SetCustomWidthMils(int aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
Definition: page_info.cpp:232
static const PAGE_INFO pageC
Definition: page_info.h:213
static const wxChar A4[]
Definition: page_info.h:63
bool m_portrait
true if portrait, false if landscape
Definition: page_info.h:229
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:244
static const PAGE_INFO pageA5
Definition: page_info.h:205
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
Definition: page_info.cpp:272
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:187
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:153
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:77
static const PAGE_INFO pageUSLedger
Definition: page_info.h:220
static const PAGE_INFO pageE
Definition: page_info.h:215
static const PAGE_INFO pageA4
Definition: page_info.h:206
static const PAGE_INFO pageUser
Definition: page_info.h:222
static const wxChar A1[]
Definition: page_info.h:66
static const PAGE_INFO pageUSLetter
Definition: page_info.h:218
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:258
static int GetCustomHeightMils()
Definition: page_info.h:187
static void SetCustomHeightMils(int aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
Definition: page_info.cpp:238
const VECTOR2I & GetSizeMils() const
Definition: page_info.h:135
static const wxChar A2[]
Definition: page_info.h:65
wxPrintOrientation GetWxOrientation() const
Definition: page_info.h:122
VECTOR2I m_size
mils
Definition: page_info.h:227
void updatePortrait()
Definition: page_info.cpp:96
wxString m_type
paper type: A4, A3, etc.
Definition: page_info.h:226
int GetHeightMils() const
Definition: page_info.h:133
wxPaperSize GetPaperId() const
Definition: page_info.h:127
static const PAGE_INFO pageB
Definition: page_info.h:212
static const PAGE_INFO pageA3
Definition: page_info.h:207
static const wxChar GERBER[]
Definition: page_info.h:73
int GetWidthMils() const
Definition: page_info.h:130
const wxString & GetType() const
Definition: page_info.h:94
static const PAGE_INFO pageA
Definition: page_info.h:211
static const PAGE_INFO pageA1
Definition: page_info.h:209
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:144
bool IsCustom() const
Definition: page_info.cpp:181
bool IsPortrait() const
Definition: page_info.h:117
PAGE_INFO(const wxString &aType=PAGE_INFO::A3, bool IsPortrait=false)
Definition: page_info.cpp:114
static int s_user_height
Definition: page_info.h:233
static int s_user_width
Definition: page_info.h:234
static const PAGE_INFO pageA0
Definition: page_info.h:210
bool IsDefault() const
Definition: page_info.h:99
static const PAGE_INFO pageUSLegal
Definition: page_info.h:219
void setMargins()
static const PAGE_INFO pageA2
Definition: page_info.h:208
static const wxChar A5[]
Definition: page_info.h:62
const wxSize GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:162
wxPaperSize m_paper_id
wx' style paper id.
Definition: page_info.h:231
static int GetCustomWidthMils()
Definition: page_info.h:182
static const PAGE_INFO pageGERBER
Definition: page_info.h:216
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:120