KiCad PCB EDA Suite
class_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 <class_gbr_screen.h>
33 #include <gerbview_id.h>
34 
35 
36 #define MIL_GRID( x ) wxRealPoint( x * IU_PER_MILS,\
37  x * IU_PER_MILS)
38 #define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\
39  x * IU_PER_MM )
40 
41 
46 static const double gbrZoomList[] =
47 {
48  ZOOM_FACTOR( 0.05 ),
49  ZOOM_FACTOR( 0.075 ),
50  ZOOM_FACTOR( 0.1 ),
51  ZOOM_FACTOR( 0.15 ),
52  ZOOM_FACTOR( 0.2 ),
53  ZOOM_FACTOR( 0.3 ),
54  ZOOM_FACTOR( 0.45 ),
55  ZOOM_FACTOR( 0.7 ),
56  ZOOM_FACTOR( 1.0 ),
57  ZOOM_FACTOR( 1.5 ),
58  ZOOM_FACTOR( 2.2 ),
59  ZOOM_FACTOR( 3.5 ),
60  ZOOM_FACTOR( 5.0 ),
61  ZOOM_FACTOR( 8.0 ),
62  ZOOM_FACTOR( 11.0 ),
63  ZOOM_FACTOR( 15.0 ),
64  ZOOM_FACTOR( 20.0 ),
65  ZOOM_FACTOR( 35.0 ),
66  ZOOM_FACTOR( 50.0 ),
67  ZOOM_FACTOR( 100.0 ),
68  ZOOM_FACTOR( 200.0 )
69 };
70 
71 
72 // Default grid sizes for PCB editor screens.
74 {
75  // predefined grid list in mils
82  { ID_POPUP_GRID_LEVEL_25, MIL_GRID( 2.5 ) },
85  { ID_POPUP_GRID_LEVEL_5, MIL_GRID( 0.5 ) },
86  { ID_POPUP_GRID_LEVEL_2, MIL_GRID( 0.2 ) },
87  { ID_POPUP_GRID_LEVEL_1, MIL_GRID( 0.1 ) },
88 
89  // predefined grid list in mm
90  { ID_POPUP_GRID_LEVEL_5MM, MM_GRID( 5.0 ) },
92  { ID_POPUP_GRID_LEVEL_1MM, MM_GRID( 1.0 ) },
100 };
101 
102 
103 GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) :
105 {
106  for( unsigned i = 0; i < DIM( gbrZoomList ); ++i )
107  m_ZoomList.push_back( gbrZoomList[i] );
108 
109  for( unsigned i = 0; i < DIM( gbrGridList ); ++i )
110  AddGrid( gbrGridList[i] );
111 
112  // Set the working grid size to a reasonable value
113  SetGrid( MIL_GRID( 50 ) );
114  SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom
115 
116  m_Active_Layer = 0; // default active layer = first graphic layer
117 
118  InitDataPoints( aPageSizeIU );
119 }
120 
121 
123 {
125 }
126 
127 
128 // virtual function
130 {
131  return (int)IU_PER_MILS;
132 }
133 
134 
135 /* Virtual function needed by classes derived from BASE_SCREEN
136  * this is a virtual pure function in BASE_SCREEN
137  * do nothing in GerbView
138  * could be removed later
139  */
141 {
142 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
static const double gbrZoomList[]
Default GerbView zoom values.
#define ZOOM_FACTOR(x)
Definition: classpcb.cpp:48
#define MM_GRID(x)
virtual int MilsToIuScalar() override
Function MilsToIuScalar returns the scalar required to convert mils to internal units.
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.
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.
void AddGrid(const GRID_TYPE &grid)
Class GRID_TYPE is for grid arrays.
void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1) override
Function ClearUndoORRedoList virtual pure in BASE_SCREEN, so it must be defined here.
The common library.
GBR_SCREEN(const wxSize &aPageSizeIU)
Constructor.
#define MIL_GRID(x)
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
static GRID_TYPE gbrGridList[]
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.