KiCad PCB EDA Suite
pl_editor_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) 2013 CERN
5  * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
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 #include <fctsys.h>
27 #include <common.h>
28 #include <macros.h>
29 #include <pl_editor_screen.h>
30 #include <base_units.h>
31 #include <pl_editor_id.h>
32 
33 
34 #define MM_GRID( x ) wxRealPoint( x * IU_PER_MM, x * IU_PER_MM )
35 #define ZOOM_FACTOR( x ) ( x * IU_PER_MM / 1000 )
36 
37 
42 static const double pl_editorZoomList[] =
43 {
44  ZOOM_FACTOR( 10.0 ), // Zoom in
45  ZOOM_FACTOR( 15.0 ),
46  ZOOM_FACTOR( 22.0 ),
47  ZOOM_FACTOR( 35.0 ),
48  ZOOM_FACTOR( 50.0 ),
49  ZOOM_FACTOR( 80.0 ),
50  ZOOM_FACTOR( 120.0 ),
51  ZOOM_FACTOR( 160.0 ),
52  ZOOM_FACTOR( 230.0 ),
53  ZOOM_FACTOR( 290.0 ),
54  ZOOM_FACTOR( 380.0 ),
55  ZOOM_FACTOR( 500.0 ),
56  ZOOM_FACTOR( 750.0 ),
57  ZOOM_FACTOR( 1000.0 ),
58  ZOOM_FACTOR( 1500.0 ),
59  ZOOM_FACTOR( 2000.0 ),
60  ZOOM_FACTOR( 3000.0 ),
61  ZOOM_FACTOR( 4500.0 ), // Zoom out
62 };
63 
64 
65 // Default grid sizes for page layout editor screens.
67 {
68  // predefined grid list in mm
69  { ID_POPUP_GRID_LEVEL_1MM, MM_GRID( 1.0 ) },
74 };
75 
76 
77 PL_EDITOR_SCREEN::PL_EDITOR_SCREEN( const wxSize& aPageSizeIU ) :
79 {
80  for( double zoom : pl_editorZoomList )
81  m_ZoomList.push_back( zoom );
82 
83  for( GRID_TYPE grid : pl_editorGridList )
84  AddGrid( grid );
85 
86  // pl_editor uses the same frame position as schematic and board editors
87  m_Center = false;
88 
89  // Set the working grid size to a reasonable value
90  SetGrid( MM_GRID( 1.0 ) );
91 
92  InitDataPoints( aPageSizeIU );
94 }
95 
96 
98 {
100 }
101 
102 
104 {
105  if( aItemCount == 0 )
106  return;
107 
108  unsigned icnt = aList.m_CommandsList.size();
109 
110  if( aItemCount > 0 )
111  icnt = aItemCount;
112 
113  for( unsigned ii = 0; ii < icnt; ii++ )
114  {
115  if( aList.m_CommandsList.size() == 0 )
116  break;
117 
118  PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
119  aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
120 
121  curr_cmd->ClearListAndDeleteItems();
122  delete curr_cmd; // Delete command
123  }
124 }
void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1) override
Function ClearUndoORRedoList virtual pure in BASE_SCREEN, so it must be defined here.
Implementation of conversion functions that require both schematic and board internal units.
static GRID_TYPE pl_editorGridList[]
void AddGrid(const GRID_TYPE &aGrid)
not really an item, used to identify a screen
Definition: typeinfo.h:86
This file contains miscellaneous commonly used macros and functions.
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:63
Class UNDO_REDO_CONTAINER is a holder to handle alist of undo (or redo) command.
#define MM_GRID(x)
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
bool m_Center
Center on screen.
Definition: base_screen.h:121
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:43
static const double pl_editorZoomList[]
Default zoom values.
The common library.
int m_NumberOfScreens
Definition: base_screen.h:136
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
#define ZOOM_FACTOR(x)
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:138
PL_EDITOR_SCREEN(const wxSize &aPageSizeIU)
Constructor.