Tools available under toolbar buttons: delete items, highlight net, set drill/place origin (GAL).
This commit is contained in:
parent
057bd1b886
commit
f63170ca84
|
@ -383,10 +383,18 @@ TOOL_ACTION COMMON_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule",
|
|||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_MODULE ),
|
||||
_( "Add modules" ), _( "Add modules" ), NULL, AF_ACTIVATE );
|
||||
|
||||
TOOL_ACTION COMMON_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin",
|
||||
AS_GLOBAL, 0,
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION COMMON_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
|
||||
AS_GLOBAL, 0,
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION COMMON_ACTIONS::highlightNetCursor( "pcbnew.EditorControl.highlightNetCursor",
|
||||
AS_GLOBAL, 0,
|
||||
"", "" );
|
||||
|
||||
|
||||
// Module editor tools
|
||||
TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad",
|
||||
|
@ -433,6 +441,10 @@ TOOL_ACTION COMMON_ACTIONS::switchUnits( "pcbnew.Control.switchUnits",
|
|||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_UNITS ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION COMMON_ACTIONS::deleteItemCursor( "pcbnew.Control.deleteItemCursor",
|
||||
AS_GLOBAL, 0,
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION COMMON_ACTIONS::showHelp( "pcbnew.Control.showHelp",
|
||||
AS_GLOBAL, '?',
|
||||
"", "" );
|
||||
|
@ -637,14 +649,17 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
|
|||
return COMMON_ACTIONS::selectionTool.MakeEvent();
|
||||
|
||||
case ID_PCB_DELETE_ITEM_BUTT:
|
||||
case ID_PCB_HIGHLIGHT_BUTT:
|
||||
case ID_PCB_SHOW_1_RATSNEST_BUTT:
|
||||
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
|
||||
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
|
||||
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE:
|
||||
case ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR:
|
||||
case ID_MICROWAVE_V_TOOLBAR:
|
||||
case ID_MODEDIT_DELETE_TOOL:
|
||||
return COMMON_ACTIONS::deleteItemCursor.MakeEvent();
|
||||
|
||||
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
|
||||
return COMMON_ACTIONS::drillOrigin.MakeEvent();
|
||||
|
||||
case ID_PCB_HIGHLIGHT_BUTT:
|
||||
return COMMON_ACTIONS::highlightNetCursor.MakeEvent();
|
||||
|
||||
case ID_PCB_SHOW_1_RATSNEST_BUTT:
|
||||
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
|
||||
return COMMON_ACTIONS::toBeDone.MakeEvent();
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,10 @@ public:
|
|||
static TOOL_ACTION resetCoords;
|
||||
static TOOL_ACTION switchCursor;
|
||||
static TOOL_ACTION switchUnits;
|
||||
static TOOL_ACTION deleteItemCursor;
|
||||
static TOOL_ACTION highlightNet;
|
||||
static TOOL_ACTION highlightNetCursor;
|
||||
static TOOL_ACTION drillOrigin;
|
||||
static TOOL_ACTION showHelp;
|
||||
static TOOL_ACTION toBeDone;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <tool/tool_manager.h>
|
||||
|
||||
#include "selection_tool.h"
|
||||
#include "picker_tool.h"
|
||||
|
||||
#include <painter.h>
|
||||
#include <project.h>
|
||||
|
@ -468,6 +469,26 @@ int PCB_EDITOR_CONTROL::SelectionCrossProbe( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
static bool setDrillOrigin( PCB_BASE_FRAME* aFrame, const VECTOR2D& aPosition )
|
||||
{
|
||||
aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
assert( picker );
|
||||
|
||||
m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust zero" ) );
|
||||
picker->SetClickHandler( boost::bind( setDrillOrigin, m_frame, _1 ) );
|
||||
picker->Activate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function highlightNet()
|
||||
* Looks for a BOARD_CONNECTED_ITEM in a given spot, and if one is found - it enables
|
||||
|
@ -509,6 +530,19 @@ int PCB_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
assert( picker );
|
||||
|
||||
m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_PENCIL, _( "Highlight net" ) );
|
||||
picker->SetClickHandler( boost::bind( highlightNet, m_toolMgr, _1 ) );
|
||||
picker->Activate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void PCB_EDITOR_CONTROL::SetTransitions()
|
||||
{
|
||||
// Track & via size control
|
||||
|
@ -529,7 +563,9 @@ void PCB_EDITOR_CONTROL::SetTransitions()
|
|||
|
||||
// Other
|
||||
Go( &PCB_EDITOR_CONTROL::SelectionCrossProbe, SELECTION_TOOL::SelectedEvent );
|
||||
Go( &PCB_EDITOR_CONTROL::DrillOrigin, COMMON_ACTIONS::drillOrigin.MakeEvent() );
|
||||
Go( &PCB_EDITOR_CONTROL::HighlightNet, COMMON_ACTIONS::highlightNet.MakeEvent() );
|
||||
Go( &PCB_EDITOR_CONTROL::HighlightNetCursor, COMMON_ACTIONS::highlightNetCursor.MakeEvent() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,9 +72,15 @@ public:
|
|||
///> Notifies eeschema about the selected item.
|
||||
int SelectionCrossProbe( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Places the origin point for drill and pick-and-place files.
|
||||
int DrillOrigin( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Highlights net belonging to the item under the cursor.
|
||||
int HighlightNet( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Launches a tool to pick the item whose net is going to be highlighted.
|
||||
int HighlightNetCursor( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Sets up handlers for various events.
|
||||
void SetTransitions();
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "pcbnew_control.h"
|
||||
#include "common_actions.h"
|
||||
#include "selection_tool.h"
|
||||
#include "picker_tool.h"
|
||||
|
||||
#include <pcbnew_id.h>
|
||||
#include <wxPcbStruct.h>
|
||||
|
@ -34,11 +36,14 @@
|
|||
#include <class_draw_panel_gal.h>
|
||||
#include <class_pcb_screen.h>
|
||||
#include <confirm.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <pcb_painter.h>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
|
||||
PCBNEW_CONTROL::PCBNEW_CONTROL() :
|
||||
TOOL_INTERACTIVE( "pcbnew.Control" ), m_frame( NULL )
|
||||
|
@ -437,32 +442,25 @@ int PCBNEW_CONTROL::GridPrev( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
static bool setOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame, const VECTOR2D& aPoint )
|
||||
{
|
||||
aFrame->SetGridOrigin( wxPoint( aPoint.x, aPoint.y ) );
|
||||
aView->GetGAL()->SetGridOrigin( aPoint );
|
||||
aView->MarkDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
Activate();
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
assert( picker );
|
||||
|
||||
// TODO it will not check the toolbar button in module editor, as it uses a different ID..
|
||||
m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
|
||||
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
controls->ShowCursor( true );
|
||||
controls->SetSnapping( true );
|
||||
controls->SetAutoPan( true );
|
||||
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
getView()->GetGAL()->SetGridOrigin( controls->GetCursorPosition() );
|
||||
getView()->MarkDirty();
|
||||
}
|
||||
|
||||
else if( evt->IsCancel() || evt->IsActivate() )
|
||||
break;
|
||||
}
|
||||
|
||||
controls->SetAutoPan( false );
|
||||
controls->SetSnapping( false );
|
||||
controls->ShowCursor( false );
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
picker->SetClickHandler( boost::bind( setOrigin, getView(), m_frame, _1 ) );
|
||||
picker->Activate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -523,6 +521,42 @@ int PCBNEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
||||
{
|
||||
SELECTION_TOOL* selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
|
||||
assert( selectionTool );
|
||||
|
||||
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
aToolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true );
|
||||
selectionTool->SanitizeSelection();
|
||||
|
||||
if( selectionTool->GetSelection().Empty() )
|
||||
return true;
|
||||
|
||||
if( IsOK( aToolMgr->GetEditFrame(), _( "Are you sure you want to delete item?" ) ) )
|
||||
aToolMgr->RunAction( COMMON_ACTIONS::remove, true );
|
||||
|
||||
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
assert( picker );
|
||||
|
||||
// TODO it will not check the toolbar button in the module editor, as it uses a different ID..
|
||||
m_frame->SetToolID( ID_PCB_DELETE_ITEM_BUTT, wxCURSOR_PENCIL, _( "Delete item" ) );
|
||||
picker->SetSnapping( false );
|
||||
picker->SetClickHandler( boost::bind( deleteItem, m_toolMgr, _1 ) );
|
||||
picker->Activate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
// TODO
|
||||
|
@ -534,7 +568,7 @@ int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
|
||||
DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -589,6 +623,7 @@ void PCBNEW_CONTROL::SetTransitions()
|
|||
Go( &PCBNEW_CONTROL::ResetCoords, COMMON_ACTIONS::resetCoords.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::SwitchCursor, COMMON_ACTIONS::switchCursor.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::SwitchUnits, COMMON_ACTIONS::switchUnits.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::DeleteItemCursor, COMMON_ACTIONS::deleteItemCursor.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ShowHelp, COMMON_ACTIONS::showHelp.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ToBeDone, COMMON_ACTIONS::toBeDone.MakeEvent() );
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ public:
|
|||
int ResetCoords( const TOOL_EVENT& aEvent );
|
||||
int SwitchCursor( const TOOL_EVENT& aEvent );
|
||||
int SwitchUnits( const TOOL_EVENT& aEvent );
|
||||
int DeleteItemCursor( const TOOL_EVENT& aEvent );
|
||||
int ShowHelp( const TOOL_EVENT& aEvent );
|
||||
int ToBeDone( const TOOL_EVENT& aEvent );
|
||||
|
||||
|
|
Loading…
Reference in New Issue