KiCad PCB EDA Suite
size_menu.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) 2015 CERN
5  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "size_menu.h"
23 
24 #include <class_board.h>
25 #include <pcbnew_id.h>
26 #include <bitmaps.h>
27 
28 
29 TRACK_VIA_SIZE_MENU::TRACK_VIA_SIZE_MENU( bool aTrackSizes, bool aViaSizes ) :
30  m_tracks( aTrackSizes ), m_vias( aViaSizes )
31 {
32  SetIcon( width_track_via_xpm );
33 }
34 
35 
37 {
38  wxString msg;
39 
40  const BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
41 
42  if( m_tracks )
43  {
44  for( unsigned i = 0; i < bds.m_TrackWidthList.size(); i++ )
45  {
46  if( m_vias ) // == if( m_tracks && m_vias )
47  msg = _( "Track ");
48 
49  if( i == 0 )
50  msg << _( "net class width" );
51  else
52  msg << StringFromValue( g_UserUnit, bds.m_TrackWidthList[i], true );
53 
54  Append( ID_POPUP_PCB_SELECT_WIDTH1 + i, msg, wxEmptyString, wxITEM_CHECK );
55  }
56  }
57 
58  if( m_tracks && m_vias )
59  AppendSeparator();
60 
61  if( m_vias )
62  {
63  for( unsigned i = 0; i < bds.m_ViasDimensionsList.size(); i++ )
64  {
65  if( m_tracks ) // == if( m_tracks && m_vias )
66  msg = _( "Via " );
67 
68  if( i == 0 )
69  {
70  msg << _( "net class size" );
71  }
72  else
73  {
74  msg << StringFromValue( g_UserUnit, bds.m_ViasDimensionsList[i].m_Diameter, true );
75  wxString drill = StringFromValue( g_UserUnit,
76  bds.m_ViasDimensionsList[i].m_Drill, true );
77 
78  if( bds.m_ViasDimensionsList[i].m_Drill <= 0 )
79  msg << _( ", drill: default" );
80  else
81  msg << _( ", drill: " ) << drill;
82  }
83 
84  Append( ID_POPUP_PCB_SELECT_VIASIZE1 + i, msg, wxEmptyString, wxITEM_CHECK );
85  }
86  }
87 }
std::vector< int > m_TrackWidthList
Track width list.
TRACK_VIA_SIZE_MENU(bool aTrackSizes, bool aViaSizes)
Constructor.
Definition: size_menu.cpp:29
Class BOARD to handle a board.
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:203
virtual void AppendSizes(const BOARD *aBoard)
Function AppendSizes() Appends the list of tracks/vias (depending on the parameters passed to the con...
Definition: size_menu.cpp:36
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
bool m_vias
Whether the generated menu should contain via sizes.
Definition: size_menu.h:59
bool m_tracks
Whether the generated menu should contain track sizes.
Definition: size_menu.h:56
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
Definition: context_menu.h:74
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Vias size and drill list.
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.