Add context menu to route and zone toolbar items

ADDED: Context menu for route and zone toolbar items
This commit is contained in:
Ian McInerney 2020-06-23 11:44:39 +01:00 committed by Jon Evans
parent fb10406e67
commit 17adb6c3c6
3 changed files with 47 additions and 0 deletions

View File

@ -912,6 +912,12 @@ int ROUTER_TOOL::ChangeRouterMode( const TOOL_EVENT& aEvent )
}
PNS::PNS_MODE ROUTER_TOOL::GetRouterMode()
{
return m_router->Settings().Mode();
}
void ROUTER_TOOL::breakTrack()
{
if( m_startItem && m_startItem->OfKind( PNS::ITEM::SEGMENT_T ) )

View File

@ -46,6 +46,8 @@ public:
int ChangeRouterMode( const TOOL_EVENT& aEvent );
int CustomTrackWidthDialog( const TOOL_EVENT& aEvent );
PNS::PNS_MODE GetRouterMode();
void setTransitions() override;
// A filter for narrowing a collection representing a simple corner

View File

@ -37,11 +37,15 @@
#include <pcbnew_id.h>
#include <pcbnew_settings.h>
#include <pgm_base.h>
#include <router/pns_routing_settings.h>
#include <router/router_tool.h>
#include <settings/color_settings.h>
#include <settings/common_settings.h>
#include <tool/action_toolbar.h>
#include <tool/actions.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/selection_tool.h>
#include <view/view.h>
#include <wx/wupdlock.h>
@ -380,6 +384,41 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
auto isHighlightMode =
[this]( const SELECTION& aSel )
{
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
return tool->GetRouterMode() == PNS::RM_MarkObstacles;
};
auto isShoveMode =
[this]( const SELECTION& aSel )
{
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
return tool->GetRouterMode() == PNS::RM_Shove;
};
auto isWalkaroundMode =
[this]( const SELECTION& aSel )
{
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
return tool->GetRouterMode() == PNS::RM_Walkaround;
};
SELECTION_TOOL* selTool = m_toolManager->GetTool<SELECTION_TOOL>();
CONDITIONAL_MENU* routeMenu = new CONDITIONAL_MENU( false, selTool );
routeMenu->AddCheckItem( PCB_ACTIONS::routerHighlightMode, isHighlightMode );
routeMenu->AddCheckItem( PCB_ACTIONS::routerShoveMode, isShoveMode );
routeMenu->AddCheckItem( PCB_ACTIONS::routerWalkaroundMode, isWalkaroundMode );
routeMenu->AddSeparator();
routeMenu->AddItem( PCB_ACTIONS::routerSettingsDialog, SELECTION_CONDITIONS::ShowAlways );
m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, routeMenu );
CONDITIONAL_MENU* zoneMenu = new CONDITIONAL_MENU( false, selTool );
zoneMenu->AddItem( PCB_ACTIONS::zoneFillAll, SELECTION_CONDITIONS::ShowAlways );
zoneMenu->AddItem( PCB_ACTIONS::zoneUnfillAll, SELECTION_CONDITIONS::ShowAlways );
m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, zoneMenu );
m_drawToolBar->Realize();
}