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 <kicommon.h>
34#include <wx/string.h>
35#include <math/vector2d.h>
36
38#define MIN_PAGE_SIZE_MILS 1000
39#define MAX_PAGE_SIZE_PCBNEW_MILS 48000
40#define MAX_PAGE_SIZE_EESCHEMA_MILS 120000
41
43#define MIN_PAGE_SIZE_MM 25.4
44#define MAX_PAGE_SIZE_PCBNEW_MM 48000*.0254
45#define MAX_PAGE_SIZE_EESCHEMA_MM 120000*.0254
46
47class OUTPUTFORMATTER;
48
59{
60public:
61 PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false );
62
63 // paper size names which are part of the public API, pass to SetType() or
64 // above constructor.
65
66 // these were once wxStrings, but it caused static construction sequence problems:
67 static const wxChar A5[];
68 static const wxChar A4[];
69 static const wxChar A3[];
70 static const wxChar A2[];
71 static const wxChar A1[];
72 static const wxChar A0[];
73 static const wxChar A[];
74 static const wxChar B[];
75 static const wxChar C[];
76 static const wxChar D[];
77 static const wxChar E[];
78 static const wxChar GERBER[];
79 static const wxChar USLetter[];
80 static const wxChar USLegal[];
81 static const wxChar USLedger[];
82 static const wxChar Custom[];
83
84
98 bool SetType( const wxString& aStandardPageDescriptionName, bool aIsPortrait = false );
99 const wxString& GetType() const { return m_type; }
100
104 bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; }
105
109 bool IsCustom() const;
110
121 void SetPortrait( bool aIsPortrait );
122 bool IsPortrait() const { return m_portrait; }
123
127 wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
128
132 wxPaperSize GetPaperId() const { return m_paper_id; }
133
134 void SetWidthMM( double aWidthInMM ) { SetWidthMils( aWidthInMM * 1000 / 25.4 ); }
135 void SetWidthMils( double aWidthInMils );
136 double GetWidthMils() const { return m_size.x; }
137 double GetWidthMM() const { return m_size.x * 25.4 / 1000; }
138
139 void SetHeightMM( double aHeightInMM ) { SetHeightMils( aHeightInMM * 1000 / 25.4 ); }
140 void SetHeightMils( double aHeightInMils );
141 double GetHeightMils() const { return m_size.y; }
142 double GetHeightMM() const { return m_size.y * 25.4 / 1000; }
143
144 const VECTOR2D& GetSizeMils() const { return m_size; }
145
153 int GetWidthIU( double aIUScale ) const { return aIUScale * GetWidthMils(); }
154
162 int GetHeightIU( double aIUScale ) const { return aIUScale * GetHeightMils(); }
163
171 const VECTOR2D GetSizeIU( double aIUScale ) const
172 {
173 return VECTOR2D( GetWidthIU( aIUScale ), GetHeightIU( aIUScale ) );
174 }
175
180 static void SetCustomWidthMils( double aWidthInMils );
181
186 static void SetCustomHeightMils( double aHeightInMils );
187
191 static double GetCustomWidthMils() { return s_user_width; }
192
196 static double GetCustomHeightMils() { return s_user_height; }
197
206 void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
207
208protected:
209 // only the class implementation(s) may use this constructor
210 PAGE_INFO( const VECTOR2D& aSizeMils, const wxString& aName, wxPaperSize aPaperId );
211
212private:
213 // standard pre-defined sizes
214 static const PAGE_INFO pageA5;
215 static const PAGE_INFO pageA4;
216 static const PAGE_INFO pageA3;
217 static const PAGE_INFO pageA2;
218 static const PAGE_INFO pageA1;
219 static const PAGE_INFO pageA0;
220 static const PAGE_INFO pageA;
221 static const PAGE_INFO pageB;
222 static const PAGE_INFO pageC;
223 static const PAGE_INFO pageD;
224 static const PAGE_INFO pageE;
225 static const PAGE_INFO pageGERBER;
226
228 static const PAGE_INFO pageUSLegal;
230
231 static const PAGE_INFO pageUser;
232
233 // all dimensions here are in mils
234
235 wxString m_type;
237
239
240 wxPaperSize m_paper_id;
241
242 static double s_user_height;
243 static double s_user_width;
244
245 void updatePortrait();
246
248};
249
250#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:59
static const wxChar A3[]
Definition: page_info.h:69
VECTOR2D m_size
mils
Definition: page_info.h:236
static const PAGE_INFO pageD
Definition: page_info.h:223
static const PAGE_INFO pageC
Definition: page_info.h:222
bool m_portrait
true if portrait, false if landscape
Definition: page_info.h:238
static const PAGE_INFO pageA5
Definition: page_info.h:214
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:162
static const PAGE_INFO pageUSLedger
Definition: page_info.h:229
static const PAGE_INFO pageE
Definition: page_info.h:224
void SetWidthMM(double aWidthInMM)
Definition: page_info.h:134
static double s_user_width
Definition: page_info.h:243
static const PAGE_INFO pageA4
Definition: page_info.h:215
static const PAGE_INFO pageUser
Definition: page_info.h:231
static double s_user_height
Definition: page_info.h:242
static const PAGE_INFO pageUSLetter
Definition: page_info.h:227
void SetHeightMM(double aHeightInMM)
Definition: page_info.h:139
double GetHeightMM() const
Definition: page_info.h:142
double GetWidthMM() const
Definition: page_info.h:137
const VECTOR2D & GetSizeMils() const
Definition: page_info.h:144
wxPrintOrientation GetWxOrientation() const
Definition: page_info.h:127
static double GetCustomHeightMils()
Definition: page_info.h:196
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:171
wxString m_type
paper type: A4, A3, etc.
Definition: page_info.h:235
double GetHeightMils() const
Definition: page_info.h:141
wxPaperSize GetPaperId() const
Definition: page_info.h:132
static const PAGE_INFO pageB
Definition: page_info.h:221
static const PAGE_INFO pageA3
Definition: page_info.h:216
const wxString & GetType() const
Definition: page_info.h:99
static const PAGE_INFO pageA
Definition: page_info.h:220
static const PAGE_INFO pageA1
Definition: page_info.h:218
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:153
double GetWidthMils() const
Definition: page_info.h:136
bool IsPortrait() const
Definition: page_info.h:122
static double GetCustomWidthMils()
Definition: page_info.h:191
static const PAGE_INFO pageA0
Definition: page_info.h:219
bool IsDefault() const
Definition: page_info.h:104
static const PAGE_INFO pageUSLegal
Definition: page_info.h:228
void setMargins()
static const PAGE_INFO pageA2
Definition: page_info.h:217
wxPaperSize m_paper_id
wx' style paper id.
Definition: page_info.h:240
static const PAGE_INFO pageGERBER
Definition: page_info.h:225
#define KICOMMON_API
Definition: kicommon.h:28
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
VECTOR2< double > VECTOR2D
Definition: vector2d.h:690