KiCad PCB EDA Suite
class_pl_editor_screen.cpp
Go to the documentation of this file.
1 
4 /*
5  * This program source code file is part of KiCad, a free EDA CAD application.
6  *
7  * Copyright (C) 2013 CERN
8  * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, you may find one here:
22  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23  * or you may search the http://www.gnu.org website for the version 2 license,
24  * or you may write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  */
27 
28 #include <fctsys.h>
29 #include <common.h>
30 #include <macros.h>
31 #include <class_pl_editor_screen.h>
32 #include <base_units.h>
33 #include <pl_editor_id.h>
34 
35 
36 #define MM_GRID( x ) wxRealPoint( x * IU_PER_MM, x * IU_PER_MM )
37 #define ZOOM_FACTOR( x ) ( x * IU_PER_MM / 1000 )
38 
39 
44 static const double pl_editorZoomList[] =
45 {
46  ZOOM_FACTOR( 5 ),
47  ZOOM_FACTOR( 7.0 ),
48  ZOOM_FACTOR( 10.0 ),
49  ZOOM_FACTOR( 15.0 ),
50  ZOOM_FACTOR( 22.0 ),
51  ZOOM_FACTOR( 35.0 ),
52  ZOOM_FACTOR( 50.0 ),
53  ZOOM_FACTOR( 80.0 ),
54  ZOOM_FACTOR( 120.0 ),
55  ZOOM_FACTOR( 160.0 ),
56  ZOOM_FACTOR( 230.0 ),
57  ZOOM_FACTOR( 290.0 ),
58  ZOOM_FACTOR( 380.0 ),
59  ZOOM_FACTOR( 500.0 ),
60  ZOOM_FACTOR( 750.0 ),
61  ZOOM_FACTOR( 1000.0 ),
62  ZOOM_FACTOR( 1500.0 ),
63  ZOOM_FACTOR( 2000.0 ),
64  ZOOM_FACTOR( 3000.0 ),
65 };
66 
67 
68 // Default grid sizes for PCB editor screens.
70 {
71  // predefined grid list in mm
72  { ID_POPUP_GRID_LEVEL_1MM, MM_GRID( 1.0 ) },
77 };
78 
79 
80 PL_EDITOR_SCREEN::PL_EDITOR_SCREEN( const wxSize& aPageSizeIU ) :
82 {
83  for( unsigned i = 0; i < DIM( pl_editorZoomList ); ++i )
84  m_ZoomList.push_back( pl_editorZoomList[i] );
85 
86  for( unsigned i = 0; i < DIM( pl_editorGridList ); ++i )
87  AddGrid( pl_editorGridList[i] );
88 
89  // pl_editor uses the same frame position as schematic and board editors
90  m_Center = false;
91 
92  // Set the working grid size to a reasonable value
93  SetGrid( MM_GRID( 1.0 ) );
94 
95  SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom
96 
97  InitDataPoints( aPageSizeIU );
99 }
100 
101 
103 {
105 }
106 
107 
108 // virtual function
110 {
111  return (int)IU_PER_MILS;
112 }
113 
114 
115 /* Virtual function needed by classes derived from BASE_SCREEN
116  * this is a virtual pure function in BASE_SCREEN
117  */
119  int aItemCount )
120 {
121  if( aItemCount == 0 )
122  return;
123 
124  unsigned icnt = aList.m_CommandsList.size();
125 
126  if( aItemCount > 0 )
127  icnt = aItemCount;
128 
129  for( unsigned ii = 0; ii < icnt; ii++ )
130  {
131  if( aList.m_CommandsList.size() == 0 )
132  break;
133 
134  PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
135  aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
136 
137  curr_cmd->ClearListAndDeleteItems();
138  delete curr_cmd; // Delete command
139  }
140 }
virtual int MilsToIuScalar() override
Function MilsToIuScalar returns the scalar required to convert mils to internal units.
#define DIM(x)
of elements in an array
Definition: macros.h:98
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[]
not really an item, used to identify a screen
Definition: typeinfo.h:98
This file contains miscellaneous commonly used macros and functions.
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:69
Class UNDO_REDO_CONTAINER is a holder to handle alist of undo (or redo) command.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
bool m_Center
Center on screen.
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
void AddGrid(const GRID_TYPE &grid)
#define ZOOM_FACTOR(x)
Class GRID_TYPE is for grid arrays.
static const double pl_editorZoomList[]
Default zoom values.
The common library.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
#define MM_GRID(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.
PL_EDITOR_SCREEN(const wxSize &aPageSizeIU)
Constructor.