KiCad PCB EDA Suite
pcbnew/onrightclick.cpp File Reference

Right mouse button functions. More...

#include <fctsys.h>
#include <class_drawpanel.h>
#include <macros.h>
#include <base_units.h>
#include <bitmaps.h>
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <class_pcb_text.h>
#include <class_zone.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <pcbnew_id.h>
#include <hotkeys.h>
#include <collectors.h>
#include <menus_helpers.h>

Go to the source code of this file.

Functions

static wxMenu * Append_Track_Width_List (BOARD *aBoard)
 Function Append_Track_Width_List creates a wxMenu * which shows the last used track widths and via diameters. More...
 

Detailed Description

Right mouse button functions.

Definition in file pcbnew/onrightclick.cpp.

Function Documentation

static wxMenu * Append_Track_Width_List ( BOARD aBoard)
static

Function Append_Track_Width_List creates a wxMenu * which shows the last used track widths and via diameters.

Returns
a pointer to the menu

Definition at line 1030 of file pcbnew/onrightclick.cpp.

References g_UserUnit, GetChars(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetTrackWidthIndex(), BOARD_DESIGN_SETTINGS::GetViaSizeIndex(), ID_POPUP_PCB_SELECT_AUTO_WIDTH, ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_WIDTH1, BOARD_DESIGN_SETTINGS::m_TrackWidthList, BOARD_DESIGN_SETTINGS::m_UseConnectedTrackWidth, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, and StringFromValue().

Referenced by PCB_EDIT_FRAME::createPopupMenuForTracks(), and PCB_EDIT_FRAME::OnRightClick().

1031 {
1032  wxString msg;
1033  wxMenu* trackwidth_menu;
1034  wxString value;
1035 
1036  trackwidth_menu = new wxMenu;
1037 
1038  trackwidth_menu->Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH, _( "Auto Width" ),
1039  _( "Use the track width when starting on a track, otherwise the current track width" ),
1040  true );
1041 
1043  trackwidth_menu->Check( ID_POPUP_PCB_SELECT_AUTO_WIDTH, true );
1044 
1045  if( aBoard->GetDesignSettings().GetViaSizeIndex() != 0
1046  || aBoard->GetDesignSettings().GetTrackWidthIndex() != 0
1048  trackwidth_menu->Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES,
1049  _( "Use Netclass Values" ),
1050  _( "Use track and via sizes from their Netclass values" ),
1051  true );
1052 
1053  for( unsigned ii = 0; ii < aBoard->GetDesignSettings().m_TrackWidthList.size(); ii++ )
1054  {
1055  value = StringFromValue( g_UserUnit, aBoard->GetDesignSettings().m_TrackWidthList[ii], true );
1056  msg.Printf( _( "Track %s" ), GetChars( value ) );
1057 
1058  if( ii == 0 )
1059  msg << _( " uses NetClass" );
1060 
1061  trackwidth_menu->Append( ID_POPUP_PCB_SELECT_WIDTH1 + ii, msg, wxEmptyString, true );
1062  }
1063 
1064  trackwidth_menu->AppendSeparator();
1065 
1066  for( unsigned ii = 0; ii < aBoard->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
1067  {
1068  value = StringFromValue( g_UserUnit,
1069  aBoard->GetDesignSettings().m_ViasDimensionsList[ii].m_Diameter,
1070  true );
1071  wxString drill = StringFromValue( g_UserUnit,
1072  aBoard->GetDesignSettings().m_ViasDimensionsList[ii].m_Drill,
1073  true );
1074 
1075  if( aBoard->GetDesignSettings().m_ViasDimensionsList[ii].m_Drill <= 0 )
1076  {
1077  msg.Printf( _( "Via %s" ), GetChars( value ) );
1078  }
1079  else
1080  {
1081  msg.Printf( _( "Via %s, drill %s" ), GetChars( value ), GetChars( drill ) );
1082  }
1083 
1084  if( ii == 0 )
1085  msg << _( " uses NetClass" );
1086 
1087  trackwidth_menu->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, true );
1088  }
1089 
1090  return trackwidth_menu;
1091 }
std::vector< int > m_TrackWidthList
Track width list.
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
bool m_UseConnectedTrackWidth
if true, when creating a new track starting on an existing track, use this track width ...
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Vias size and drill list.
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.