KiCad PCB EDA Suite
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-2020 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
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  *
21  * or you may search the 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  */
30 #ifndef PAGE_INFO_H
31 #define PAGE_INFO_H
33 #include <wx/string.h>
35 #include <richio.h> // for OUTPUTFORMATTER and IO_ERROR
36 #include <base_units.h> // for IU_PER_MILS
39 #define MIN_PAGE_SIZE_MILS 100
40 #define MAX_PAGE_SIZE_PCBNEW_MILS 48000
53 class PAGE_INFO
54 {
55 public:
56  PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false );
58  // paper size names which are part of the public API, pass to SetType() or
59  // above constructor.
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[];
93  bool SetType( const wxString& aStandardPageDescriptionName, bool aIsPortrait = false );
94  const wxString& GetType() const { return m_type; }
99  bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; }
104  bool IsCustom() const;
116  void SetPortrait( bool aIsPortrait );
117  bool IsPortrait() const { return m_portrait; }
122  wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
127  wxPaperSize GetPaperId() const { return m_paper_id; }
129  void SetWidthMils( int aWidthInMils );
130  int GetWidthMils() const { return m_size.x; }
132  void SetHeightMils( int aHeightInMils );
133  int GetHeightMils() const { return m_size.y; }
135  const wxSize& GetSizeMils() const { return m_size; }
137  // Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA,
138  // and either deci-mils or nanometers in PCBNew.
139 #if defined(PCBNEW) || defined(EESCHEMA) || defined(GERBVIEW) || defined(PL_EDITOR)
140  int GetWidthIU() const { return IU_PER_MILS * GetWidthMils(); }
141  int GetHeightIU() const { return IU_PER_MILS * GetHeightMils(); }
142  const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
143 #endif
149  static void SetCustomWidthMils( int aWidthInMils );
155  static void SetCustomHeightMils( int aHeightInMils );
160  static int GetCustomWidthMils() { return s_user_width; }
165  static int GetCustomHeightMils() { return s_user_height; }
175  void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
177 protected:
178  // only the class implementation(s) may use this constructor
179  PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId );
181 private:
182  // standard pre-defined sizes
183  static const PAGE_INFO pageA5;
184  static const PAGE_INFO pageA4;
185  static const PAGE_INFO pageA3;
186  static const PAGE_INFO pageA2;
187  static const PAGE_INFO pageA1;
188  static const PAGE_INFO pageA0;
189  static const PAGE_INFO pageA;
190  static const PAGE_INFO pageB;
191  static const PAGE_INFO pageC;
192  static const PAGE_INFO pageD;
193  static const PAGE_INFO pageE;
194  static const PAGE_INFO pageGERBER;
196  static const PAGE_INFO pageUSLetter;
197  static const PAGE_INFO pageUSLegal;
198  static const PAGE_INFO pageUSLedger;
200  static const PAGE_INFO pageUser;
202  // all dimensions here are in mils
204  wxString m_type;
205  wxSize m_size;
207  bool m_portrait;
209  wxPaperSize m_paper_id;
211  static int s_user_height;
212  static int s_user_width;
214  void updatePortrait();
216  void setMargins();
217 };
219 #endif // PAGE_INFO_H
static const PAGE_INFO pageA4
Definition: page_info.h:184
static const PAGE_INFO pageGERBER
Definition: page_info.h:194
wxPrintOrientation GetWxOrientation() const
Definition: page_info.h:122
static int GetCustomHeightMils()
Definition: page_info.h:165
Implementation of conversion functions that require both schematic and board internal units.
int GetHeightMils() const
Definition: page_info.h:133
void updatePortrait()
Definition: page_info.cpp:95
static const wxChar GERBER[]
Definition: page_info.h:73
static const wxChar A3[]
Definition: page_info.h:64
wxSize m_size
Definition: page_info.h:205
static const PAGE_INFO pageA1
Definition: page_info.h:187
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:231
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:119
static const PAGE_INFO pageA2
Definition: page_info.h:186
static const PAGE_INFO pageUSLetter
Definition: page_info.h:196
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:309
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:77
const wxString & GetType() const
Definition: page_info.h:94
bool IsCustom() const
Definition: page_info.cpp:180
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
Definition: page_info.cpp:271
static const PAGE_INFO pageC
Definition: page_info.h:191
wxString m_type
paper type: A4, A3, etc.
Definition: page_info.h:204
static const PAGE_INFO pageUser
Definition: page_info.h:200
wxPaperSize GetPaperId() const
Definition: page_info.h:127
static const PAGE_INFO pageA
Definition: page_info.h:189
static const PAGE_INFO pageB
Definition: page_info.h:190
static const PAGE_INFO pageE
Definition: page_info.h:193
static const wxChar USLegal[]
Definition: page_info.h:75
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
static const PAGE_INFO pageUSLedger
Definition: page_info.h:198
bool IsDefault() const
Definition: page_info.h:99
bool m_portrait
true if portrait, false if landscape
Definition: page_info.h:207
static const wxChar A4[]
Definition: page_info.h:63
const wxSize & GetSizeMils() const
Definition: page_info.h:135
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:257
static const wxChar USLedger[]
Definition: page_info.h:76
static const wxChar A1[]
Definition: page_info.h:66
static const wxChar USLetter[]
Definition: page_info.h:74
bool IsPortrait() const
Definition: page_info.h:117
static const PAGE_INFO pageUSLegal
Definition: page_info.h:197
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:243
static const wxChar A5[]
Definition: page_info.h:62
#define IU_PER_MILS
Definition: plotter.cpp:130
static int GetCustomWidthMils()
Definition: page_info.h:160
static int s_user_height
Definition: page_info.h:211
void setMargins()
static const wxChar A2[]
Definition: page_info.h:65
static int s_user_width
Definition: page_info.h:212
PAGE_INFO(const wxString &aType=PAGE_INFO::A3, bool IsPortrait=false)
Definition: page_info.cpp:113
static const PAGE_INFO pageA3
Definition: page_info.h:185
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:186
static const PAGE_INFO pageA0
Definition: page_info.h:188
static const PAGE_INFO pageA5
Definition: page_info.h:183
wxPaperSize m_paper_id
wx' style paper id.
Definition: page_info.h:209
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:237
int GetWidthMils() const
Definition: page_info.h:130
static const PAGE_INFO pageD
Definition: page_info.h:192
static const wxChar A0[]
Definition: page_info.h:67