KiCad PCB EDA Suite
gbr_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-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #include <fctsys.h>
30 #include <common.h>
31 #include <macros.h>
32 #include <gbr_screen.h>
33 #include <gerbview_id.h>
34 
35 
36 #define MIL_GRID( x ) wxRealPoint( x * IU_PER_MILS, x * IU_PER_MILS)
37 #define MM_GRID( x ) wxRealPoint( x * IU_PER_MM, x * IU_PER_MM )
38 
39 
44 static const double gbrZoomList[] =
45 {
46  ZOOM_FACTOR( 0.022 ),
47  ZOOM_FACTOR( 0.035 ),
48  ZOOM_FACTOR( 0.05 ),
49  ZOOM_FACTOR( 0.08 ),
50  ZOOM_FACTOR( 0.13 ),
51  ZOOM_FACTOR( 0.22 ),
52  ZOOM_FACTOR( 0.35 ),
53  ZOOM_FACTOR( 0.6 ),
54  ZOOM_FACTOR( 1.0 ),
55  ZOOM_FACTOR( 1.5 ),
56  ZOOM_FACTOR( 2.2 ),
57  ZOOM_FACTOR( 3.5 ),
58  ZOOM_FACTOR( 5.0 ),
59  ZOOM_FACTOR( 8.0 ),
60  ZOOM_FACTOR( 13.0 ),
61  ZOOM_FACTOR( 20.0 ),
62  ZOOM_FACTOR( 35.0 ),
63  ZOOM_FACTOR( 50.0 ),
64  ZOOM_FACTOR( 80.0 ),
65  ZOOM_FACTOR( 130.0 ),
66  ZOOM_FACTOR( 220.0 )
67 };
68 
69 
70 // Default grid sizes for PCB editor screens.
72 {
73  // predefined grid list in mils
80  { ID_POPUP_GRID_LEVEL_25, MIL_GRID( 2.5 ) },
83  { ID_POPUP_GRID_LEVEL_5, MIL_GRID( 0.5 ) },
84  { ID_POPUP_GRID_LEVEL_2, MIL_GRID( 0.2 ) },
85  { ID_POPUP_GRID_LEVEL_1, MIL_GRID( 0.1 ) },
86 
87  // predefined grid list in mm
88  { ID_POPUP_GRID_LEVEL_5MM, MM_GRID( 5.0 ) },
90  { ID_POPUP_GRID_LEVEL_1MM, MM_GRID( 1.0 ) },
98 };
99 
100 
101 GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) :
103 {
104  for( unsigned i = 0; i < arrayDim( gbrZoomList ); ++i )
105  m_ZoomList.push_back( gbrZoomList[i] );
106 
107  for( unsigned i = 0; i < arrayDim( gbrGridList ); ++i )
108  AddGrid( gbrGridList[i] );
109 
110  // Set the working grid size to a reasonable value
111  SetGrid( MIL_GRID( 50 ) );
112  SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom
113 
114  m_Active_Layer = 0; // default active layer = first graphic layer
115 
116  InitDataPoints( aPageSizeIU );
117 }
118 
119 
121 {
123 }
124 
125 
126 /* Virtual function needed by classes derived from BASE_SCREEN
127  * this is a virtual pure function in BASE_SCREEN
128  * do nothing in GerbView
129  * could be removed later
130  */
132 {
133 }
void AddGrid(const GRID_TYPE &aGrid)
#define ZOOM_FACTOR(x)
Definition: sch_screen.cpp:74
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:65
UNDO_REDO_CONTAINER is a holder to handle alist of undo (or redo) command.
static const double gbrZoomList[]
Default GerbView zoom values.
Definition: gbr_screen.cpp:44
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
int m_Active_Layer
Definition: gbr_screen.h:43
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
virtual bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
Definition: base_screen.cpp:88
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
GRID_TYPE is for grid arrays.
Definition: base_screen.h:43
#define MM_GRID(x)
Definition: gbr_screen.cpp:37
void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1) override
Function ClearUndoORRedoList virtual pure in BASE_SCREEN, so it must be defined here.
Definition: gbr_screen.cpp:131
The common library.
GBR_SCREEN(const wxSize &aPageSizeIU)
Constructor.
Definition: gbr_screen.cpp:101
#define MIL_GRID(x)
Definition: gbr_screen.cpp:36
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
static GRID_TYPE gbrGridList[]
Definition: gbr_screen.cpp:71
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:138