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, 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
26#pragma once
27
28#include <map>
29#include <kicommon.h>
30#include <wx/string.h>
31#include <math/vector2d.h>
32
34#define MIN_PAGE_SIZE_MILS 1000
35#define MAX_PAGE_SIZE_PCBNEW_MILS 48000
36#define MAX_PAGE_SIZE_EESCHEMA_MILS 120000
37
39#define MIN_PAGE_SIZE_MM 25.4
40#define MAX_PAGE_SIZE_PCBNEW_MM 48000*.0254
41#define MAX_PAGE_SIZE_EESCHEMA_MM 120000*.0254
42
43class OUTPUTFORMATTER;
44
45/*
46 * @brief Standard paper sizes nicknames
47 * Do not rename entires as these names are saved to file and parsed back
48 */
68
79{
80public:
82
83 // paper size names which are part of the public API, pass to SetType() or
84 // above constructor.
85
86
100 bool SetType( PAGE_SIZE_TYPE aPageSize, bool aIsPortrait = false );
101 bool SetType( const wxString& aPageSize, bool aIsPortrait = false );
102 const PAGE_SIZE_TYPE& GetType() const { return m_type; }
103 wxString GetTypeAsString() const;
104
105 const wxString& GetPageFormatDescription() const { return m_description; }
106
110 bool IsDefault() const { return m_type == PAGE_SIZE_TYPE::A3 && !m_portrait; }
111
115 bool IsCustom() const;
116
127 void SetPortrait( bool aIsPortrait );
128 bool IsPortrait() const { return m_portrait; }
129
133 wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
134
138 wxPaperSize GetPaperId() const { return m_paper_id; }
139
140 void SetWidthMM( double aWidthInMM ) { SetWidthMils( aWidthInMM * 1000 / 25.4 ); }
141 void SetWidthMils( double aWidthInMils );
142 double GetWidthMils() const { return m_size.x; }
143 double GetWidthMM() const { return m_size.x * 25.4 / 1000; }
144
145 void SetHeightMM( double aHeightInMM ) { SetHeightMils( aHeightInMM * 1000 / 25.4 ); }
146 void SetHeightMils( double aHeightInMils );
147 double GetHeightMils() const { return m_size.y; }
148 double GetHeightMM() const { return m_size.y * 25.4 / 1000; }
149
150 const VECTOR2D& GetSizeMils() const { return m_size; }
151
159 int GetWidthIU( double aIUScale ) const { return aIUScale * GetWidthMils(); }
160
168 int GetHeightIU( double aIUScale ) const { return aIUScale * GetHeightMils(); }
169
177 const VECTOR2D GetSizeIU( double aIUScale ) const
178 {
179 return VECTOR2D( GetWidthIU( aIUScale ), GetHeightIU( aIUScale ) );
180 }
181
186 static void SetCustomWidthMils( double aWidthInMils );
187
192 static void SetCustomHeightMils( double aHeightInMils );
193
197 static double GetCustomWidthMils() { return s_user_width; }
198
202 static double GetCustomHeightMils() { return s_user_height; }
203
210 void Format( OUTPUTFORMATTER* aFormatter ) const;
211
212 static const std::vector<PAGE_INFO>& GetPageFormatsList();
213
214protected:
215 // only the class implementation(s) may use this constructor
216 PAGE_INFO( const VECTOR2D& aSizeMils, const PAGE_SIZE_TYPE& aType, wxPaperSize aPaperId,
217 const wxString& aDescription = wxEmptyString );
218
219 void updatePortrait();
220
221private:
222 static std::vector<PAGE_INFO> standardPageSizes;
223
224 // all dimensions here are in mils
225
228
230
231 wxPaperSize m_paper_id;
232 wxString m_description;
233
234 static double s_user_height;
235 static double s_user_width;
236};
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:79
VECTOR2D m_size
mils
Definition page_info.h:227
bool m_portrait
true if portrait, false if landscape
Definition page_info.h:229
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition page_info.h:168
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:140
static double s_user_width
Definition page_info.h:235
void SetHeightMils(double aHeightInMils)
static double s_user_height
Definition page_info.h:234
void SetHeightMM(double aHeightInMM)
Definition page_info.h:145
double GetHeightMM() const
Definition page_info.h:148
double GetWidthMM() const
Definition page_info.h:143
const VECTOR2D & GetSizeMils() const
Definition page_info.h:150
wxPrintOrientation GetWxOrientation() const
Definition page_info.h:133
static double GetCustomHeightMils()
Definition page_info.h:202
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition page_info.h:177
double GetHeightMils() const
Definition page_info.h:147
PAGE_INFO(PAGE_SIZE_TYPE aType=PAGE_SIZE_TYPE::A3, bool IsPortrait=false)
Definition page_info.cpp:96
wxPaperSize GetPaperId() const
Definition page_info.h:138
wxString m_description
more human friendly description of page size
Definition page_info.h:232
const wxString & GetPageFormatDescription() const
Definition page_info.h:105
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition page_info.h:159
double GetWidthMils() const
Definition page_info.h:142
bool IsPortrait() const
Definition page_info.h:128
void SetWidthMils(double aWidthInMils)
static double GetCustomWidthMils()
Definition page_info.h:197
bool IsDefault() const
Definition page_info.h:110
const PAGE_SIZE_TYPE & GetType() const
Definition page_info.h:102
PAGE_SIZE_TYPE m_type
paper type: A4, A3, etc.
Definition page_info.h:226
wxPaperSize m_paper_id
wx' style paper id.
Definition page_info.h:231
#define KICOMMON_API
Definition kicommon.h:28
PAGE_SIZE_TYPE
Definition page_info.h:50
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:198
#define D(x)
Definition ptree.cpp:41
VECTOR2< double > VECTOR2D
Definition vector2d.h:694