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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <map>
25#include <kicommon.h>
26#include <wx/string.h>
27#include <math/vector2d.h>
28
30#define MIN_PAGE_SIZE_MILS 1000
31#define MAX_PAGE_SIZE_PCBNEW_MILS 48000
32#define MAX_PAGE_SIZE_EESCHEMA_MILS 120000
33
35#define MIN_PAGE_SIZE_MM 25.4
36#define MAX_PAGE_SIZE_PCBNEW_MM 48000*.0254
37#define MAX_PAGE_SIZE_EESCHEMA_MM 120000*.0254
38
39class OUTPUTFORMATTER;
40
41/*
42 * @brief Standard paper sizes nicknames
43 * Do not rename entires as these names are saved to file and parsed back
44 */
64
75{
76public:
78
79 // paper size names which are part of the public API, pass to SetType() or
80 // above constructor.
81
82
96 bool SetType( PAGE_SIZE_TYPE aPageSize, bool aIsPortrait = false );
97 bool SetType( const wxString& aPageSize, bool aIsPortrait = false );
98 const PAGE_SIZE_TYPE& GetType() const { return m_type; }
99 wxString GetTypeAsString() const;
100
101 const wxString& GetPageFormatDescription() const { return m_description; }
102
106 bool IsDefault() const { return m_type == PAGE_SIZE_TYPE::A3 && !m_portrait; }
107
111 bool IsCustom() const;
112
123 void SetPortrait( bool aIsPortrait );
124 bool IsPortrait() const { return m_portrait; }
125
129 wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
130
134 wxPaperSize GetPaperId() const { return m_paper_id; }
135
136 void SetWidthMM( double aWidthInMM ) { SetWidthMils( aWidthInMM * 1000 / 25.4 ); }
137 void SetWidthMils( double aWidthInMils );
138 double GetWidthMils() const { return m_size.x; }
139 double GetWidthMM() const { return m_size.x * 25.4 / 1000; }
140
141 void SetHeightMM( double aHeightInMM ) { SetHeightMils( aHeightInMM * 1000 / 25.4 ); }
142 void SetHeightMils( double aHeightInMils );
143 double GetHeightMils() const { return m_size.y; }
144 double GetHeightMM() const { return m_size.y * 25.4 / 1000; }
145
146 const VECTOR2D& GetSizeMils() const { return m_size; }
147
155 int GetWidthIU( double aIUScale ) const { return aIUScale * GetWidthMils(); }
156
164 int GetHeightIU( double aIUScale ) const { return aIUScale * GetHeightMils(); }
165
173 const VECTOR2D GetSizeIU( double aIUScale ) const
174 {
175 return VECTOR2D( GetWidthIU( aIUScale ), GetHeightIU( aIUScale ) );
176 }
177
182 static void SetCustomWidthMils( double aWidthInMils );
183
188 static void SetCustomHeightMils( double aHeightInMils );
189
193 static double GetCustomWidthMils() { return s_user_width; }
194
198 static double GetCustomHeightMils() { return s_user_height; }
199
206 void Format( OUTPUTFORMATTER* aFormatter ) const;
207
208 static const std::vector<PAGE_INFO>& GetPageFormatsList();
209
210protected:
211 // only the class implementation(s) may use this constructor
212 PAGE_INFO( const VECTOR2D& aSizeMils, const PAGE_SIZE_TYPE& aType, wxPaperSize aPaperId,
213 const wxString& aDescription = wxEmptyString );
214
215 void updatePortrait();
216
217private:
218 static std::vector<PAGE_INFO> standardPageSizes;
219
220 // all dimensions here are in mils
221
224
226
227 wxPaperSize m_paper_id;
228 wxString m_description;
229
230 static double s_user_height;
231 static double s_user_width;
232};
An interface used to output 8 bit text in a convenient way.
Definition richio.h:291
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
VECTOR2D m_size
mils
Definition page_info.h:223
bool m_portrait
true if portrait, false if landscape
Definition page_info.h:225
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition page_info.h:164
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
void SetWidthMM(double aWidthInMM)
Definition page_info.h:136
static double s_user_width
Definition page_info.h:231
void SetHeightMils(double aHeightInMils)
static double s_user_height
Definition page_info.h:230
void SetHeightMM(double aHeightInMM)
Definition page_info.h:141
double GetHeightMM() const
Definition page_info.h:144
double GetWidthMM() const
Definition page_info.h:139
const VECTOR2D & GetSizeMils() const
Definition page_info.h:146
wxPrintOrientation GetWxOrientation() const
Definition page_info.h:129
static double GetCustomHeightMils()
Definition page_info.h:198
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition page_info.h:173
double GetHeightMils() const
Definition page_info.h:143
PAGE_INFO(PAGE_SIZE_TYPE aType=PAGE_SIZE_TYPE::A3, bool IsPortrait=false)
Definition page_info.cpp:92
wxPaperSize GetPaperId() const
Definition page_info.h:134
wxString m_description
more human friendly description of page size
Definition page_info.h:228
const wxString & GetPageFormatDescription() const
Definition page_info.h:101
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition page_info.h:155
double GetWidthMils() const
Definition page_info.h:138
bool IsPortrait() const
Definition page_info.h:124
void SetWidthMils(double aWidthInMils)
static double GetCustomWidthMils()
Definition page_info.h:193
bool IsDefault() const
Definition page_info.h:106
const PAGE_SIZE_TYPE & GetType() const
Definition page_info.h:98
PAGE_SIZE_TYPE m_type
paper type: A4, A3, etc.
Definition page_info.h:222
wxPaperSize m_paper_id
wx' style paper id.
Definition page_info.h:227
#define KICOMMON_API
Definition kicommon.h:27
PAGE_SIZE_TYPE
Definition page_info.h:46
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:194
#define D(x)
Definition ptree.cpp:37
VECTOR2< double > VECTOR2D
Definition vector2d.h:682