Added possibility of switching tools by the right toolbar buttons, without deactivating the current tool first (previously tools did not switch if there was one active).
This commit is contained in:
parent
bad6cdaa06
commit
4c5afc46af
|
@ -186,6 +186,26 @@ public:
|
|||
return m_editFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns id of the tool that is on the top of the active tools stack
|
||||
* (was invoked the most recently).
|
||||
* @return Id of the currently used tool.
|
||||
*/
|
||||
int GetCurrentToolId() const
|
||||
{
|
||||
return m_activeTools.front();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tool that is on the top of the active tools stack
|
||||
* (was invoked the most recently).
|
||||
* @return Pointer to the currently used tool.
|
||||
*/
|
||||
TOOL_BASE* GetCurrentTool() const
|
||||
{
|
||||
return FindTool( GetCurrentToolId() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a state transition - the events that cause a given handler method in the tool
|
||||
* to be called. Called by TOOL_INTERACTIVE::Go(). May be called from a coroutine context.
|
||||
|
|
|
@ -633,7 +633,7 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
|
|||
|
||||
// handle color changes for transitions in and out of ID_TRACK_BUTT
|
||||
if( ( GetToolId() == ID_TRACK_BUTT && aId != ID_TRACK_BUTT )
|
||||
|| ( GetToolId() != ID_TRACK_BUTT && aId== ID_TRACK_BUTT ) )
|
||||
|| ( GetToolId() != ID_TRACK_BUTT && aId == ID_TRACK_BUTT ) )
|
||||
{
|
||||
if( DisplayOpt.ContrastModeDisplay )
|
||||
redraw = true;
|
||||
|
@ -641,7 +641,7 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
|
|||
|
||||
// must do this after the tool has been set, otherwise pad::Draw() does
|
||||
// not show proper color when DisplayOpt.ContrastModeDisplay is true.
|
||||
if( redraw && m_canvas)
|
||||
if( redraw && m_canvas )
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
|
|
211
pcbnew/edit.cpp
211
pcbnew/edit.cpp
|
@ -1370,109 +1370,124 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
if( GetToolId() == id )
|
||||
return;
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
// Stop the current command and deselect the current tool.
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_NO_TOOL_SELECTED:
|
||||
SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString );
|
||||
break;
|
||||
|
||||
case ID_TRACK_BUTT:
|
||||
if( g_Drc_On )
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
|
||||
else
|
||||
SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
|
||||
|
||||
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
|
||||
{
|
||||
Compile_Ratsnest( &dc, true );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ID_PCB_MODULE_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add module" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_ZONES_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
|
||||
|
||||
if( DisplayOpt.DisplayZonesMode != 0 )
|
||||
DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
|
||||
|
||||
if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
|
||||
HighLight( &dc );
|
||||
|
||||
break;
|
||||
|
||||
case ID_PCB_KEEPOUT_AREA_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_MIRE_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_PLACE_GRID_COORD_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_ADD_LINE_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_ARC_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_CIRCLE_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_ADD_TEXT_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
|
||||
break;
|
||||
|
||||
case ID_COMPONENT_BUTT:
|
||||
SetToolID( id, wxCURSOR_HAND, _( "Add module" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_DIMENSION_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_DELETE_ITEM_BUTT:
|
||||
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_HIGHLIGHT_BUTT:
|
||||
SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_SHOW_1_RATSNEST_BUTT:
|
||||
SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
|
||||
|
||||
if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
|
||||
Compile_Ratsnest( &dc, true );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if( IsGalCanvasActive() )
|
||||
{
|
||||
std::string actionName = COMMON_ACTIONS::TranslateLegacyId( id );
|
||||
|
||||
if( !actionName.empty() )
|
||||
m_toolManager.RunAction( actionName );
|
||||
{
|
||||
const int MAX_TRIALS = 10;
|
||||
int trials = 0;
|
||||
|
||||
return;
|
||||
// Cancel the current tool
|
||||
// TODO while sending a lot of cancel events works for sure, it is not the most
|
||||
// elegant way to cancel a tool, this should be probably done another way
|
||||
while( m_toolManager.GetCurrentTool()->GetName() != "pcbnew.InteractiveSelection" &&
|
||||
trials++ < MAX_TRIALS )
|
||||
{
|
||||
TOOL_EVENT cancel( TC_ANY, TA_CANCEL_TOOL );
|
||||
m_toolManager.ProcessEvent( cancel );
|
||||
}
|
||||
|
||||
m_toolManager.RunAction( actionName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
// Stop the current command and deselect the current tool.
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_NO_TOOL_SELECTED:
|
||||
SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString );
|
||||
break;
|
||||
|
||||
case ID_TRACK_BUTT:
|
||||
if( g_Drc_On )
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
|
||||
else
|
||||
SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
|
||||
|
||||
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
|
||||
{
|
||||
Compile_Ratsnest( &dc, true );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ID_PCB_MODULE_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add module" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_ZONES_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
|
||||
|
||||
if( DisplayOpt.DisplayZonesMode != 0 )
|
||||
DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
|
||||
|
||||
if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
|
||||
HighLight( &dc );
|
||||
|
||||
break;
|
||||
|
||||
case ID_PCB_KEEPOUT_AREA_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_MIRE_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_PLACE_GRID_COORD_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_ADD_LINE_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_ARC_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_CIRCLE_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_ADD_TEXT_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
|
||||
break;
|
||||
|
||||
case ID_COMPONENT_BUTT:
|
||||
SetToolID( id, wxCURSOR_HAND, _( "Add module" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_DIMENSION_BUTT:
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_DELETE_ITEM_BUTT:
|
||||
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_HIGHLIGHT_BUTT:
|
||||
SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
|
||||
break;
|
||||
|
||||
case ID_PCB_SHOW_1_RATSNEST_BUTT:
|
||||
SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
|
||||
|
||||
if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
|
||||
Compile_Ratsnest( &dc, true );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <wxPcbStruct.h>
|
||||
#include <id.h>
|
||||
#include <pcbnew_id.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <pcbcommon.h>
|
||||
#include <pcb_painter.h>
|
||||
|
@ -432,6 +433,7 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
|
|||
|
||||
// SetContextMenu ( m_menu );
|
||||
// setMsgPanel(true, 0, wxT("KiRouter"), wxT("Pick an item to start routing"));
|
||||
getEditFrame<PCB_EDIT_FRAME>()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Add tracks" ) );
|
||||
|
||||
ctls->SetSnapping( true );
|
||||
ctls->ShowCursor( true );
|
||||
|
@ -469,4 +471,3 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <wxPcbStruct.h>
|
||||
#include <id.h>
|
||||
#include <pcbnew_id.h>
|
||||
#include <confirm.h>
|
||||
|
||||
#include <view/view_group.h>
|
||||
|
@ -69,12 +70,16 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
|
|||
|
||||
int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->SetToolID( ID_PCB_ADD_LINE_BUTT, wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
||||
|
||||
return drawSegment( S_SEGMENT, true );
|
||||
}
|
||||
|
||||
|
||||
int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->SetToolID( ID_PCB_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
||||
|
||||
return drawSegment( S_CIRCLE, false );
|
||||
}
|
||||
|
||||
|
@ -100,6 +105,7 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
|
|||
m_controls->SetSnapping( true );
|
||||
|
||||
Activate();
|
||||
m_frame->SetToolID( ID_PCB_ARC_BUTT, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
||||
|
||||
enum ARC_STEPS
|
||||
{
|
||||
|
@ -286,6 +292,7 @@ int DRAWING_TOOL::PlaceText( TOOL_EVENT& aEvent )
|
|||
m_controls->SetAutoPan( true );
|
||||
|
||||
Activate();
|
||||
m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
|
@ -390,6 +397,7 @@ int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent )
|
|||
m_controls->SetSnapping( true );
|
||||
|
||||
Activate();
|
||||
m_frame->SetToolID( ID_PCB_DIMENSION_BUTT, wxCURSOR_PENCIL, _( "Add dimension" ) );
|
||||
|
||||
enum DIMENSION_STEPS
|
||||
{
|
||||
|
@ -549,12 +557,16 @@ int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent )
|
|||
|
||||
int DRAWING_TOOL::DrawZone( TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zones" ) );
|
||||
|
||||
return drawZone( false );
|
||||
}
|
||||
|
||||
|
||||
int DRAWING_TOOL::DrawKeepout( TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
|
||||
|
||||
return drawZone( true );
|
||||
}
|
||||
|
||||
|
@ -581,6 +593,7 @@ int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent )
|
|||
m_controls->SetAutoPan( true );
|
||||
|
||||
Activate();
|
||||
m_frame->SetToolID( ID_PCB_MIRE_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
|
@ -656,6 +669,7 @@ int DRAWING_TOOL::PlaceModule( TOOL_EVENT& aEvent )
|
|||
m_controls->SetAutoPan( true );
|
||||
|
||||
Activate();
|
||||
m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_HAND, _( "Add module" ) );
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
|
|
|
@ -68,7 +68,7 @@ void PCB_EDIT_FRAME::setupTools()
|
|||
m_toolManager.RegisterTool( new PCBNEW_CONTROL );
|
||||
|
||||
m_toolManager.SetEnvironment( NULL, GetGalCanvas()->GetView(),
|
||||
GetGalCanvas()->GetViewControls(), this );
|
||||
GetGalCanvas()->GetViewControls(), this );
|
||||
m_toolManager.ResetTools( TOOL_BASE::RUN );
|
||||
|
||||
// Run the selection tool, it is supposed to be always active
|
||||
|
|
Loading…
Reference in New Issue