KiCad PCB EDA Suite
base_screen.cpp
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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #include <base_screen.h>
28 #include <eda_item.h>
29 #include <trace_helpers.h>
30 
31 
32 wxString BASE_SCREEN::m_PageLayoutDescrFileName; // the name of the page layout descr file.
33 
34 
36  EDA_ITEM( aParent, aType )
37 {
39  m_pageCount = 1; // Hierarchy: Root: ScreenNumber = 1
40  m_Center = true;
41 
42  m_flagModified = false; // Set when any change is made on board.
43  m_flagSave = false; // Used in auto save set when an auto save is required.
44 }
45 
46 
47 void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeIU )
48 {
49  if( m_Center )
50  {
51  m_crossHairPosition.x = 0;
52  m_crossHairPosition.y = 0;
53 
54  m_DrawOrg.x = -aPageSizeIU.x / 2;
55  m_DrawOrg.y = -aPageSizeIU.y / 2;
56  }
57  else
58  {
59  m_crossHairPosition.x = aPageSizeIU.x / 2;
60  m_crossHairPosition.y = aPageSizeIU.y / 2;
61 
62  m_DrawOrg.x = 0;
63  m_DrawOrg.y = 0;
64  }
65 
66  m_LocalOrigin = { 0, 0 };
67 }
68 
69 
70 void BASE_SCREEN::SetPageCount( int aPageCount )
71 {
72  wxCHECK( aPageCount > 0, /* void */ );
73 
74  m_pageCount = aPageCount;
75 }
76 
77 
78 const wxString& BASE_SCREEN::GetPageNumber() const
79 {
80  static wxString pageNumber;
81 
82  if( m_pageNumber.IsEmpty() )
83  pageNumber.Printf( "%d", m_virtualPageNumber );
84  else
85  pageNumber = m_pageNumber;
86 
87  return pageNumber;
88 }
89 
90 
91 #if defined(DEBUG)
92 
93 void BASE_SCREEN::Show( int nestLevel, std::ostream& os ) const
94 {
95  // for now, make it look like XML, expand on this later.
96  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
97 
98  NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
99 }
100 
101 #endif
bool m_flagModified
Indicates current drawing has been modified.
Definition: base_screen.h:136
virtual wxString GetClass() const override
Return the class name.
Definition: base_screen.h:71
wxPoint m_crossHairPosition
The cross hair position in logical (drawing) units.
Definition: base_screen.h:144
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
const wxString & GetPageNumber() const
Definition: base_screen.cpp:78
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:89
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:47
wxString m_pageNumber
A user defined string page number used for printing and plotting.
Definition: base_screen.h:133
bool m_Center
Center on screen.
Definition: base_screen.h:100
int m_pageCount
The number of BASE_SCREEN objects in this design.
Definition: base_screen.h:115
wxLogTrace helper definitions.
BASE_SCREEN(EDA_ITEM *aParent, KICAD_T aType=SCREEN_T)
Definition: base_screen.cpp:35
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:92
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
BASE_SCREEN class implementation.
void SetPageCount(int aPageCount)
Definition: base_screen.cpp:70
bool m_flagSave
Indicates automatic file save.
Definition: base_screen.h:137
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:94
int m_virtualPageNumber
An integer based page number used for printing a range of pages.
Definition: base_screen.h:123