CONTEXT_TRACK_VIA_SIZE_MENU: generic context menu that displays track/via sizes.
This commit is contained in:
parent
3a908b8b8a
commit
df15be4f01
|
@ -289,6 +289,7 @@ set( PCBNEW_CLASS_SRCS
|
|||
|
||||
tools/grid_menu.cpp
|
||||
tools/zoom_menu.cpp
|
||||
tools/size_menu.cpp
|
||||
)
|
||||
|
||||
set( PCBNEW_SRCS ${PCBNEW_AUTOROUTER_SRCS} ${PCBNEW_CLASS_SRCS} ${PCBNEW_DIALOGS} )
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <tool/tool_manager.h>
|
||||
#include <tool/tool_settings.h>
|
||||
#include <tools/common_actions.h>
|
||||
#include <tools/size_menu.h>
|
||||
|
||||
#include <ratsnest_data.h>
|
||||
|
||||
|
@ -86,9 +87,9 @@ static TOOL_ACTION ACT_PlaceMicroVia( "pcbnew.InteractiveRouter.PlaceMicroVia",
|
|||
_( "Place Microvia" ), _( "Adds a microvia at the end of currently routed track." ),
|
||||
via_microvia_xpm );
|
||||
|
||||
static TOOL_ACTION ACT_CustomTrackWidth( "pcbnew.InteractiveRouter.CustomTrackWidth",
|
||||
static TOOL_ACTION ACT_CustomTrackWidth( "pcbnew.InteractiveRouter.CustomTrackViaSize",
|
||||
AS_CONTEXT, 'W',
|
||||
_( "Custom Track Width" ),
|
||||
_( "Custom Track/Via Size" ),
|
||||
_( "Shows a dialog for changing the track width and via size." ),
|
||||
width_track_xpm );
|
||||
|
||||
|
@ -111,21 +112,17 @@ ROUTER_TOOL::ROUTER_TOOL() :
|
|||
}
|
||||
|
||||
|
||||
class CONTEXT_TRACK_WIDTH_MENU: public CONTEXT_MENU
|
||||
class CONTEXT_TRACK_WIDTH_MENU: public CONTEXT_TRACK_VIA_SIZE_MENU
|
||||
{
|
||||
public:
|
||||
CONTEXT_TRACK_WIDTH_MENU()
|
||||
: CONTEXT_TRACK_VIA_SIZE_MENU( true, true ), m_board( NULL )
|
||||
{
|
||||
m_board = NULL;
|
||||
SetIcon( width_track_via_xpm );
|
||||
SetMenuHandler( boost::bind( &CONTEXT_TRACK_WIDTH_MENU::EventHandler, this, _1 ) );
|
||||
}
|
||||
|
||||
void SetBoard( BOARD* aBoard )
|
||||
{
|
||||
BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
|
||||
|
||||
wxString msg;
|
||||
m_board = aBoard;
|
||||
|
||||
Append( ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, _( "Custom size" ),
|
||||
|
@ -134,44 +131,13 @@ public:
|
|||
Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH, _( "Use the starting track width" ),
|
||||
_( "Route using the width of the starting track." ), wxITEM_CHECK );
|
||||
|
||||
Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, _( "Use netclass values" ),
|
||||
Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, _( "Use net class values" ),
|
||||
_( "Use track and via sizes from the net class" ), wxITEM_CHECK );
|
||||
|
||||
for( unsigned i = 0; i < bds.m_TrackWidthList.size(); i++ )
|
||||
{
|
||||
msg = _( "Track ");
|
||||
msg << StringFromValue( g_UserUnit, bds.m_TrackWidthList[i], true );
|
||||
|
||||
if( i == 0 )
|
||||
msg << _( " (from netclass)" );
|
||||
|
||||
Append( ID_POPUP_PCB_SELECT_WIDTH1 + i, msg, wxEmptyString, wxITEM_CHECK );
|
||||
}
|
||||
|
||||
AppendSeparator();
|
||||
|
||||
for( unsigned i = 0; i < bds.m_ViasDimensionsList.size(); i++ )
|
||||
{
|
||||
msg = _( "Via " );
|
||||
msg << StringFromValue( g_UserUnit, bds.m_ViasDimensionsList[i].m_Diameter, true );
|
||||
wxString drill = StringFromValue( g_UserUnit,
|
||||
bds.m_ViasDimensionsList[i].m_Drill,
|
||||
true );
|
||||
|
||||
if( bds.m_ViasDimensionsList[i].m_Drill <= 0 )
|
||||
{
|
||||
msg << _( ", drill: default" );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg << _( ", drill: " ) << drill;
|
||||
}
|
||||
|
||||
if( i == 0 )
|
||||
msg << _( " (from netclass)" );
|
||||
|
||||
Append( ID_POPUP_PCB_SELECT_VIASIZE1 + i, msg, wxEmptyString, wxITEM_CHECK );
|
||||
}
|
||||
// Append the list of tracks & via sizes
|
||||
AppendSizes( aBoard );
|
||||
}
|
||||
|
||||
OPT_TOOL_EVENT EventHandler( const wxMenuEvent& aEvent )
|
||||
|
@ -223,6 +189,7 @@ public:
|
|||
return OPT_TOOL_EVENT( COMMON_ACTIONS::trackViaSizeChanged.MakeEvent() );
|
||||
}
|
||||
|
||||
private:
|
||||
BOARD* m_board;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "size_menu.h"
|
||||
|
||||
#include <class_board.h>
|
||||
#include <pcbnew_id.h>
|
||||
|
||||
CONTEXT_TRACK_VIA_SIZE_MENU::CONTEXT_TRACK_VIA_SIZE_MENU( bool aTrackSizes, bool aViaSizes ) :
|
||||
m_tracks( aTrackSizes ), m_vias( aViaSizes )
|
||||
{
|
||||
SetIcon( width_track_via_xpm );
|
||||
}
|
||||
|
||||
|
||||
void CONTEXT_TRACK_VIA_SIZE_MENU::AppendSizes( const BOARD* aBoard )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
const BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
|
||||
|
||||
if( m_tracks )
|
||||
{
|
||||
for( unsigned i = 0; i < bds.m_TrackWidthList.size(); i++ )
|
||||
{
|
||||
if( m_vias ) // == if( m_tracks && m_vias )
|
||||
msg = _( "Track ");
|
||||
|
||||
if( i == 0 )
|
||||
msg << _( "net class width" );
|
||||
else
|
||||
msg << StringFromValue( g_UserUnit, bds.m_TrackWidthList[i], true );
|
||||
|
||||
Append( ID_POPUP_PCB_SELECT_WIDTH1 + i, msg, wxEmptyString, wxITEM_CHECK );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_tracks && m_vias )
|
||||
AppendSeparator();
|
||||
|
||||
if( m_vias )
|
||||
{
|
||||
for( unsigned i = 0; i < bds.m_ViasDimensionsList.size(); i++ )
|
||||
{
|
||||
if( m_tracks ) // == if( m_tracks && m_vias )
|
||||
msg = _( "Via " );
|
||||
|
||||
if( i == 0 )
|
||||
{
|
||||
msg << _( "net class size" );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg << StringFromValue( g_UserUnit, bds.m_ViasDimensionsList[i].m_Diameter, true );
|
||||
wxString drill = StringFromValue( g_UserUnit,
|
||||
bds.m_ViasDimensionsList[i].m_Drill, true );
|
||||
|
||||
if( bds.m_ViasDimensionsList[i].m_Drill <= 0 )
|
||||
msg << _( ", drill: default" );
|
||||
else
|
||||
msg << _( ", drill: " ) << drill;
|
||||
}
|
||||
|
||||
Append( ID_POPUP_PCB_SELECT_VIASIZE1 + i, msg, wxEmptyString, wxITEM_CHECK );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <tool/context_menu.h>
|
||||
|
||||
class BOARD;
|
||||
|
||||
/**
|
||||
* @brief Context menu that displays track and/or via sizes basing on the board design settings
|
||||
* of a BOARD object.
|
||||
*/
|
||||
class CONTEXT_TRACK_VIA_SIZE_MENU: public CONTEXT_MENU
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param aTrackSizes decides if the context menu should contain track sizes.
|
||||
* @param aTrackSizes decides if the context menu should contain via sizes.
|
||||
*/
|
||||
CONTEXT_TRACK_VIA_SIZE_MENU( bool aTrackSizes, bool aViaSizes );
|
||||
|
||||
virtual ~CONTEXT_TRACK_VIA_SIZE_MENU() {}
|
||||
|
||||
/**
|
||||
* Function AppendSizes()
|
||||
* Appends the list of tracks/vias (depending on the parameters passed to the constructor).
|
||||
* @param aBoard is the BOARD object whose board settings will be used to generate the list.
|
||||
*/
|
||||
virtual void AppendSizes( const BOARD* aBoard );
|
||||
|
||||
protected:
|
||||
///> Whether the generated menu should contain track sizes.
|
||||
bool m_tracks;
|
||||
|
||||
///> Whether the generated menu should contain via sizes.
|
||||
bool m_vias;
|
||||
};
|
Loading…
Reference in New Issue