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 <>
5  * Copyright (C) 2008-2013 Wayne Stambaugh <>
6  * Copyright (C) 1992-2013 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/wx.h>
35 #include <richio.h> // for OUTPUTFORMATTER and IO_ERROR
36 #include <base_units.h> // for IU_PER_MILS
39 #define MIN_PAGE_SIZE 4000
40 #define MAX_PAGE_SIZE_PCBNEW_MILS 48000
41 #define MAX_PAGE_SIZE_EDITORS_MILS 120000
54 class PAGE_INFO
55 {
56 public:
58  PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false );
60  // paper size names which are part of the public API, pass to SetType() or
61  // above constructor.
63  // these were once wxStrings, but it caused static construction sequence problems:
64  static const wxChar A4[];
65  static const wxChar A3[];
66  static const wxChar A2[];
67  static const wxChar A1[];
68  static const wxChar A0[];
69  static const wxChar A[];
70  static const wxChar B[];
71  static const wxChar C[];
72  static const wxChar D[];
73  static const wxChar E[];
74  static const wxChar GERBER[];
75  static const wxChar USLetter[];
76  static const wxChar USLegal[];
77  static const wxChar USLedger[];
78  static const wxChar Custom[];
96  bool SetType( const wxString& aStandardPageDescriptionName, bool aIsPortrait = false );
97  const wxString& GetType() const { return m_type; }
103  bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; }
109  bool IsCustom() const;
120  void SetPortrait( bool aIsPortrait );
121  bool IsPortrait() const { return m_portrait; }
127  wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
134  wxPaperSize GetPaperId() const { return m_paper_id; }
136  void SetWidthMils( int aWidthInMils );
137  int GetWidthMils() const { return m_size.x; }
139  void SetHeightMils( int aHeightInMils );
140  int GetHeightMils() const { return m_size.y; }
142  const wxSize& GetSizeMils() const { return m_size; }
144  // Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA,
145  // and either deci-mils or nanometers in PCBNew.
146 #if defined(PCBNEW) || defined(EESCHEMA) || defined(GERBVIEW) || defined(PL_EDITOR)
147  int GetWidthIU() const { return IU_PER_MILS * GetWidthMils(); }
148  int GetHeightIU() const { return IU_PER_MILS * GetHeightMils(); }
149  const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
150 #endif
157  static void SetCustomWidthMils( int aWidthInMils );
164  static void SetCustomHeightMils( int aHeightInMils );
170  static int GetCustomWidthMils() { return s_user_width; }
176  static int GetCustomHeightMils() { return s_user_height; }
193  void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
195 protected:
196  // only the class implementation(s) may use this constructor
197  PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId );
200 private:
202  // standard pre-defined sizes
203  static const PAGE_INFO pageA4;
204  static const PAGE_INFO pageA3;
205  static const PAGE_INFO pageA2;
206  static const PAGE_INFO pageA1;
207  static const PAGE_INFO pageA0;
208  static const PAGE_INFO pageA;
209  static const PAGE_INFO pageB;
210  static const PAGE_INFO pageC;
211  static const PAGE_INFO pageD;
212  static const PAGE_INFO pageE;
213  static const PAGE_INFO pageGERBER;
215  static const PAGE_INFO pageUSLetter;
216  static const PAGE_INFO pageUSLegal;
217  static const PAGE_INFO pageUSLedger;
219  static const PAGE_INFO pageUser;
221  // all dimensions here are in mils
223  wxString m_type;
224  wxSize m_size;
226  bool m_portrait;
228  wxPaperSize m_paper_id;
230  static int s_user_height;
231  static int s_user_width;
233  void updatePortrait();
235  void setMargins();
236 };
238 #endif // PAGE_INFO_H
static const PAGE_INFO pageA4
Definition: page_info.h:203
static const PAGE_INFO pageGERBER
Definition: page_info.h:213
static const wxChar A[]
Definition: page_info.h:69
wxPrintOrientation GetWxOrientation() const
Function GetWxOrientation.
Definition: page_info.h:127
static int GetCustomHeightMils()
Function GetCustomHeightMils.
Definition: page_info.h:176
Implementation of conversion functions that require both schematic and board internal units.
int GetHeightMils() const
Definition: page_info.h:140
static const wxChar E[]
Definition: page_info.h:73
void updatePortrait()
Definition: page_info.cpp:93
static const wxChar GERBER[]
Definition: page_info.h:74
static const wxChar A3[]
Definition: page_info.h:65
wxSize m_size
Definition: page_info.h:224
static const PAGE_INFO pageA1
Definition: page_info.h:206
static void SetCustomWidthMils(int aWidthInMils)
Function SetCustomWidthMils sets the width of Custom page in mils, for any custom page constructed or...
Definition: page_info.cpp:227
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:117
static const PAGE_INFO pageA2
Definition: page_info.h:205
static const PAGE_INFO pageUSLetter
Definition: page_info.h:215
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:78
const wxString & GetType() const
Definition: page_info.h:97
static const wxChar D[]
Definition: page_info.h:72
bool IsCustom() const
Function IsCustom returns true if the type is Custom.
Definition: page_info.cpp:176
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function GetStandardSizes returns the standard page types, such as "A4", "A3", etc.
Definition: page_info.cpp:267
static const PAGE_INFO pageC
Definition: page_info.h:210
wxString m_type
paper type: A4, A3, etc.
Definition: page_info.h:223
static const PAGE_INFO pageUser
Definition: page_info.h:219
wxPaperSize GetPaperId() const
Function GetPaperId.
Definition: page_info.h:134
static const PAGE_INFO pageA
Definition: page_info.h:208
static const PAGE_INFO pageB
Definition: page_info.h:209
static const PAGE_INFO pageE
Definition: page_info.h:212
static const wxChar USLegal[]
Definition: page_info.h:76
static const wxChar B[]
Definition: page_info.h:70
static const wxChar C[]
Definition: page_info.h:71
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
static const PAGE_INFO pageUSLedger
Definition: page_info.h:217
bool IsDefault() const
Function IsDefault.
Definition: page_info.h:103
bool m_portrait
true if portrait, false if landscape
Definition: page_info.h:226
static const wxChar A4[]
Definition: page_info.h:64
const wxSize & GetSizeMils() const
Definition: page_info.h:142
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:253
static const wxChar USLedger[]
Definition: page_info.h:77
static const wxChar A1[]
Definition: page_info.h:67
static const wxChar USLetter[]
Definition: page_info.h:75
bool IsPortrait() const
Definition: page_info.h:121
static const PAGE_INFO pageUSLegal
Definition: page_info.h:216
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:239
#define IU_PER_MILS
Definition: plotter.cpp:134
static int GetCustomWidthMils()
Function GetCustomWidthMils.
Definition: page_info.h:170
static int s_user_height
Definition: page_info.h:230
void setMargins()
static const wxChar A2[]
Definition: page_info.h:66
static int s_user_width
Definition: page_info.h:231
PAGE_INFO(const wxString &aType=PAGE_INFO::A3, bool IsPortrait=false)
Definition: page_info.cpp:111
static const PAGE_INFO pageA3
Definition: page_info.h:204
void SetPortrait(bool aIsPortrait)
Function SetPortrait will rotate the paper page 90 degrees.
Definition: page_info.cpp:182
static const PAGE_INFO pageA0
Definition: page_info.h:207
wxPaperSize m_paper_id
wx' style paper id.
Definition: page_info.h:228
static void SetCustomHeightMils(int aHeightInMils)
Function SetCustomHeightMils sets the height of Custom page in mils, for any custom page constructed ...
Definition: page_info.cpp:233
int GetWidthMils() const
Definition: page_info.h:137
static const PAGE_INFO pageD
Definition: page_info.h:211
static const wxChar A0[]
Definition: page_info.h:68