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 <base_struct.h>
29 #include <fctsys.h>
30 #include <trace_helpers.h>
31 
32 
33 wxString BASE_SCREEN::m_PageLayoutDescrFileName; // the name of the page layout descr file.
34 
35 
37  EDA_ITEM( aParent, aType )
38 {
40  m_Initialized = false;
41  m_ScreenNumber = 1;
42  m_NumberOfScreens = 1; // Hierarchy: Root: ScreenNumber = 1
43  m_Center = true;
44 
45  m_FlagModified = false; // Set when any change is made on board.
46  m_FlagSave = false; // Used in auto save set when an auto save is required.
47 }
48 
49 
50 void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeIU )
51 {
52  if( m_Center )
53  {
56 
57  m_DrawOrg.x = -aPageSizeIU.x / 2;
58  m_DrawOrg.y = -aPageSizeIU.y / 2;
59  }
60  else
61  {
62  m_crossHairPosition.x = aPageSizeIU.x / 2;
63  m_crossHairPosition.y = aPageSizeIU.y / 2;
64 
65  m_DrawOrg.x = 0;
66  m_DrawOrg.y = 0;
67  }
68 
69  m_LocalOrigin = { 0, 0 };
70 }
71 
72 
74 {
77 }
78 
79 
81 {
82  m_UndoList.PushCommand( aNewitem );
83 
84  // Delete the extra items, if count max reached
85  if( m_UndoRedoCountMax > 0 )
86  {
87  int extraitems = GetUndoCommandCount() - m_UndoRedoCountMax;
88 
89  if( extraitems > 0 )
90  ClearUndoORRedoList( m_UndoList, extraitems );
91  }
92 }
93 
94 
96 {
97  m_RedoList.PushCommand( aNewitem );
98 
99  // Delete the extra items, if count max reached
100  if( m_UndoRedoCountMax > 0 )
101  {
102  int extraitems = GetRedoCommandCount() - m_UndoRedoCountMax;
103 
104  if( extraitems > 0 )
105  ClearUndoORRedoList( m_RedoList, extraitems );
106  }
107 }
108 
109 
111 {
112  return m_UndoList.PopCommand();
113 }
114 
115 
117 {
118  return m_RedoList.PopCommand();
119 }
120 
121 
122 #if defined(DEBUG)
123 
124 void BASE_SCREEN::Show( int nestLevel, std::ostream& os ) const
125 {
126  // for now, make it look like XML, expand on this later.
127  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
128 
129  NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
130 }
131 
132 #endif
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToUndoList add a command to undo in undo list delete the very old commands when t...
Definition: base_screen.cpp:80
int m_UndoRedoCountMax
undo/Redo command Max depth
Definition: base_screen.h:49
int m_ScreenNumber
Definition: base_screen.h:85
bool m_FlagModified
Indicates current drawing has been modified.
Definition: base_screen.h:47
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: base_screen.h:195
wxPoint m_crossHairPosition
The cross hair position in logical (drawing) units.
Definition: base_screen.h:56
int GetUndoCommandCount() const
Definition: base_screen.h:160
#define DEFAULT_MAX_UNDO_ITEMS
PICKED_ITEMS_LIST * PopCommand()
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
void PushCommand(PICKED_ITEMS_LIST *aCommand)
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:59
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
PopCommandFromUndoList return the last command to undo and remove it from list nothing is deleted.
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:50
virtual void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1)
Function ClearUndoORRedoList (virtual).
Definition: base_screen.h:119
bool m_Center
Center on screen.
Definition: base_screen.h:71
UNDO_REDO_CONTAINER m_UndoList
Objects list for the undo command (old data)
Definition: base_screen.h:82
bool m_Initialized
Definition: base_screen.h:79
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
PopCommandFromRedoList return the last command to undo and remove it from list nothing is deleted.
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
Definition: base_screen.cpp:73
wxLogTrace helper definitions.
PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
UNDO_REDO_CONTAINER m_RedoList
Objects list for the redo command (old data)
Definition: base_screen.h:83
BASE_SCREEN(EDA_ITEM *aParent, KICAD_T aType=SCREEN_T)
Definition: base_screen.cpp:36
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToRedoList add a command to redo in redo list delete the very old commands when t...
Definition: base_screen.cpp:95
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:62
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
bool m_FlagSave
Indicates automatic file save.
Definition: base_screen.h:48
int m_NumberOfScreens
Definition: base_screen.h:86
BASE_SCREEN class implementation.
int GetRedoCommandCount() const
Definition: base_screen.h:165
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:64