Immediate actions for PlEditor, PcbNew, etc.

This commit is contained in:
Jeff Young 2019-06-24 16:27:05 +01:00
parent cda3a82c66
commit f9702aab87
59 changed files with 748 additions and 916 deletions

View File

@ -139,7 +139,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
// units display, Inches is bigger than mm // units display, Inches is bigger than mm
GetTextSize( _( "Inches" ), stsbar ).x + 10, GetTextSize( _( "Inches" ), stsbar ).x + 10,
// Size for the "Current Tool" panel; longest string from SetToolID() // Size for the "Current Tool" panel; longest string from SetTool()
GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10, GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
}; };
@ -480,31 +480,12 @@ void EDA_DRAW_FRAME::ClearToolStack()
} }
void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg ) bool EDA_DRAW_FRAME::IsCurrentTool( const TOOL_ACTION& aAction )
{ {
// Keep default cursor in toolbars if( m_toolStack.empty() )
SetCursor( wxNullCursor ); return &aAction == &ACTIONS::selectionTool;
else
// Change GAL canvas cursor if requested. return m_toolStack.back() == aAction.GetName();
if( aCursor >= 0 )
GetCanvas()->SetCurrentCursor( aCursor );
DisplayToolMsg( aToolMsg );
if( aId < 0 )
return;
wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );
m_toolId = aId;
}
void EDA_DRAW_FRAME::SetNoToolSelected()
{
// Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
SetToolID( ID_NO_TOOL_SELECTED, GetCanvas()->GetDefaultCursor(), wxEmptyString );
} }
@ -628,9 +609,6 @@ void EDA_DRAW_FRAME::ActivateGalCanvas()
{ {
GetCanvas()->SetEvtHandlerEnabled( true ); GetCanvas()->SetEvtHandlerEnabled( true );
GetCanvas()->StartDrawing(); GetCanvas()->StartDrawing();
// Reset current tool on switch();
SetNoToolSelected();
} }

View File

@ -46,12 +46,17 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason )
int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
{ {
m_frame->SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); m_frame->PushTool( aEvent.GetCommandStr().get() );
while( auto evt = Wait() ) while( auto evt = Wait() )
{ {
if( evt->IsCancel() || evt->IsActivate() ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
m_frame->ClearToolStack();
break; break;
}
else if( evt->IsDrag( BUT_LEFT ) || evt->IsDrag( BUT_RIGHT ) ) else if( evt->IsDrag( BUT_LEFT ) || evt->IsDrag( BUT_RIGHT ) )
{ {
@ -64,7 +69,7 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
} }
// Exit zoom tool // Exit zoom tool
m_frame->SetNoToolSelected(); m_frame->PopTool();
return 0; return 0;
} }

View File

@ -33,6 +33,7 @@ set( CVPCB_SRCS
../pcbnew/board_items_to_polygon_shape_transform.cpp ../pcbnew/board_items_to_polygon_shape_transform.cpp
../pcbnew/pcb_general_settings.cpp ../pcbnew/pcb_general_settings.cpp
../pcbnew/drc_item.cpp ../pcbnew/drc_item.cpp
../pcbnew/tools/pcb_actions.cpp
../pcbnew/tools/grid_helper.cpp ../pcbnew/tools/grid_helper.cpp
auto_associate.cpp auto_associate.cpp
cfg.cpp cfg.cpp

View File

@ -445,11 +445,11 @@ void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel()
void DISPLAY_FOOTPRINTS_FRAME::SyncToolbars() void DISPLAY_FOOTPRINTS_FRAME::SyncToolbars()
{ {
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); m_mainToolBar->Toggle( ACTIONS::zoomTool, IsCurrentTool( ACTIONS::zoomTool ) );
m_mainToolBar->Refresh(); m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED ); m_optionsToolBar->Toggle( ACTIONS::selectionTool, IsCurrentTool( ACTIONS::selectionTool ) );
m_optionsToolBar->Toggle( ACTIONS::measureTool, GetToolId() == ID_TB_MEASUREMENT_TOOL ); m_optionsToolBar->Toggle( ACTIONS::measureTool, IsCurrentTool( ACTIONS::measureTool ) );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES ); m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES ); m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES );
m_optionsToolBar->Refresh(); m_optionsToolBar->Refresh();

View File

@ -60,7 +60,7 @@ int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// There doesn't seem to be any other good way to tell when another tool // There doesn't seem to be any other good way to tell when another tool
// is canceled and control returns to the selection tool, except by the // is canceled and control returns to the selection tool, except by the
// fact that the selection tool starts to get events again. // fact that the selection tool starts to get events again.
if( m_frame->GetToolId() == ID_NO_TOOL_SELECTED) if( m_frame->IsCurrentTool( ACTIONS::selectionTool ) )
{ {
getViewControls()->SetAdditionalPanButtons( false, true ); getViewControls()->SetAdditionalPanButtons( false, true );
} }
@ -105,8 +105,8 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
auto& controls = *getViewControls(); auto& controls = *getViewControls();
auto previous_settings = controls.GetSettings(); auto previous_settings = controls.GetSettings();
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_frame->SetToolID( ID_TB_MEASUREMENT_TOOL, wxCURSOR_PENCIL, _( "Measure distance" ) );
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() ); KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() );
@ -126,12 +126,25 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
if( evt->IsCancel() || evt->IsActivate() ) if( evt->IsCancel() || evt->IsActivate() )
{ {
break; if( originSet )
{
view.SetVisible( &ruler, false );
controls.SetAutoPan( false );
controls.CaptureCursor( false );
originSet = false;
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->ClearToolStack();
break;
}
if( evt->IsActivate() )
break;
} }
// click or drag starts // click or drag starts
else if( !originSet && else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
{ {
if( !evt->IsDrag( BUT_LEFT ) ) if( !evt->IsDrag( BUT_LEFT ) )
{ {
@ -154,8 +167,7 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
} }
// second click or mouse up after drag ends // second click or mouse up after drag ends
else if( originSet && else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
{ {
originSet = false; originSet = false;
@ -166,8 +178,7 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
} }
// move or drag when origin set updates rules // move or drag when origin set updates rules
else if( originSet && else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
{ {
twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) ); twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
twoPtMgr.SetEnd( cursorPos ); twoPtMgr.SetEnd( cursorPos );
@ -187,8 +198,6 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
controls.ApplySettings( previous_settings ); controls.ApplySettings( previous_settings );
m_frame->SetNoToolSelected();
return 0; return 0;
} }

View File

@ -77,7 +77,7 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( strcmp( idcmd, "$NET:" ) == 0 ) if( strcmp( idcmd, "$NET:" ) == 0 )
{ {
if( GetCurrentToolName() == EE_ACTIONS::highlightNetCursor.GetName() ) if( IsCurrentTool( EE_ACTIONS::highlightNetCursor ) )
{ {
m_SelectedNetName = FROM_UTF8( text ); m_SelectedNetName = FROM_UTF8( text );

View File

@ -50,7 +50,7 @@ void LIB_EDIT_FRAME::ReCreateVToolbar()
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
// Set up toolbar // Set up toolbar
m_drawToolBar->Add( EE_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_drawToolBar, this ); KiScaledSeparator( m_drawToolBar, this );
m_drawToolBar->Add( EE_ACTIONS::placeSymbolPin, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::placeSymbolPin, ACTION_TOOLBAR::TOGGLE );
@ -164,7 +164,7 @@ void LIB_EDIT_FRAME::SyncToolbars()
m_mainToolBar->Toggle( ACTIONS::saveAll, modified ); m_mainToolBar->Toggle( ACTIONS::saveAll, modified );
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); m_mainToolBar->Toggle( ACTIONS::zoomTool, IsCurrentTool( ACTIONS::zoomTool ) );
m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, GetCurPart() != nullptr ); m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, GetCurPart() != nullptr );
m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard,
GetShowDeMorgan(), GetShowDeMorgan(),
@ -185,15 +185,15 @@ void LIB_EDIT_FRAME::SyncToolbars()
m_optionsToolBar->Toggle( EE_ACTIONS::showComponentTree, IsSearchTreeShown() ); m_optionsToolBar->Toggle( EE_ACTIONS::showComponentTree, IsSearchTreeShown() );
m_optionsToolBar->Refresh(); m_optionsToolBar->Refresh();
#define TOGGLE_TOOL( tool ) m_drawToolBar->Toggle( tool, GetCurrentToolName() == tool.GetName() ) #define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
TOGGLE_TOOL( EE_ACTIONS::selectionTool ); TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );
TOGGLE_TOOL( EE_ACTIONS::placeSymbolPin ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeSymbolPin );
TOGGLE_TOOL( EE_ACTIONS::placeSymbolText ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeSymbolText );
TOGGLE_TOOL( EE_ACTIONS::drawSymbolRectangle ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawSymbolRectangle );
TOGGLE_TOOL( EE_ACTIONS::drawSymbolCircle ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawSymbolCircle );
TOGGLE_TOOL( EE_ACTIONS::drawSymbolArc ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawSymbolArc );
TOGGLE_TOOL( EE_ACTIONS::drawSymbolLines ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawSymbolLines );
TOGGLE_TOOL( EE_ACTIONS::deleteItemCursor ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::deleteItemCursor );
m_drawToolBar->Refresh(); m_drawToolBar->Refresh();
} }

View File

@ -441,12 +441,3 @@ void SCH_BASE_FRAME::SyncView()
} }
std::string SCH_BASE_FRAME::GetCurrentToolName()
{
if( m_toolStack.empty() )
return EE_ACTIONS::selectionTool.GetName();
else
return m_toolStack.back();
}

View File

@ -302,8 +302,6 @@ public:
void HardRedraw() override; void HardRedraw() override;
std::string GetCurrentToolName();
/** /**
* Add an item to the screen (and view) * Add an item to the screen (and view)
* aScreen is the screen the item is located on, if not the current screen * aScreen is the screen the item is located on, if not the current screen

View File

@ -113,7 +113,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar()
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
// Set up toolbar // Set up toolbar
m_drawToolBar->Add( EE_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::highlightNetCursor, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::highlightNetCursor, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_drawToolBar, this ); KiScaledSeparator( m_drawToolBar, this );
@ -166,13 +166,15 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar()
void SCH_EDIT_FRAME::SyncToolbars() void SCH_EDIT_FRAME::SyncToolbars()
{ {
#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions(); KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
SCH_SHEET_LIST sheetList( g_RootSheet ); SCH_SHEET_LIST sheetList( g_RootSheet );
m_mainToolBar->Toggle( ACTIONS::saveAll, sheetList.IsModified() ); m_mainToolBar->Toggle( ACTIONS::saveAll, sheetList.IsModified() );
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); TOGGLE_TOOL( m_mainToolBar, ACTIONS::zoomTool );
m_mainToolBar->Refresh(); m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
@ -183,27 +185,25 @@ void SCH_EDIT_FRAME::SyncToolbars()
m_optionsToolBar->Toggle( EE_ACTIONS::toggleForceHV, GetForceHVLines() ); m_optionsToolBar->Toggle( EE_ACTIONS::toggleForceHV, GetForceHVLines() );
m_optionsToolBar->Refresh(); m_optionsToolBar->Refresh();
#define TOGGLE_TOOL( tool ) m_drawToolBar->Toggle( tool, GetCurrentToolName() == tool.GetName() ) TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );
TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::highlightNetCursor );
TOGGLE_TOOL( ACTIONS::selectionTool ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeSymbol );
TOGGLE_TOOL( EE_ACTIONS::highlightNetCursor ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placePower );
TOGGLE_TOOL( EE_ACTIONS::placeSymbol ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawWire );
TOGGLE_TOOL( EE_ACTIONS::placePower ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawBus );
TOGGLE_TOOL( EE_ACTIONS::drawWire ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeBusWireEntry );
TOGGLE_TOOL( EE_ACTIONS::drawBus ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeBusBusEntry );
TOGGLE_TOOL( EE_ACTIONS::placeBusWireEntry ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeNoConnect );
TOGGLE_TOOL( EE_ACTIONS::placeBusBusEntry ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeJunction );
TOGGLE_TOOL( EE_ACTIONS::placeNoConnect ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeLabel );
TOGGLE_TOOL( EE_ACTIONS::placeJunction ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeGlobalLabel );
TOGGLE_TOOL( EE_ACTIONS::placeLabel ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeHierLabel );
TOGGLE_TOOL( EE_ACTIONS::placeGlobalLabel ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawSheet );
TOGGLE_TOOL( EE_ACTIONS::placeHierLabel ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::importSheetPin );
TOGGLE_TOOL( EE_ACTIONS::drawSheet ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeSheetPin );
TOGGLE_TOOL( EE_ACTIONS::importSheetPin ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawLines );
TOGGLE_TOOL( EE_ACTIONS::placeSheetPin ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeSchematicText );
TOGGLE_TOOL( EE_ACTIONS::drawLines ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeImage );
TOGGLE_TOOL( EE_ACTIONS::placeSchematicText ); TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::deleteItemCursor );
TOGGLE_TOOL( EE_ACTIONS::placeImage );
TOGGLE_TOOL( EE_ACTIONS::deleteItemCursor );
m_drawToolBar->Refresh(); m_drawToolBar->Refresh();
} }

View File

@ -291,19 +291,62 @@ static bool deleteItem( SCH_BASE_FRAME* aFrame, const VECTOR2D& aPosition )
} }
#define HITTEST_THRESHOLD_PIXELS 5
int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{ {
m_frame->PushTool( aEvent.GetCommandStr().get() ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>(); EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
wxCHECK( picker, 0 ); m_pickerItem = nullptr;
picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool
{
if( m_pickerItem )
{
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
selectionTool->AddItemToSel( m_pickerItem, true );
m_toolMgr->RunAction( EE_ACTIONS::doDelete, true );
m_pickerItem = nullptr;
}
return true;
} );
picker->SetMotionHandler( [this] ( const VECTOR2D& aPos )
{
EE_COLLECTOR collector;
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos );
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
if( m_pickerItem != item )
{
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
if( m_pickerItem )
selectionTool->UnbrightenItem( m_pickerItem );
m_pickerItem = item;
if( m_pickerItem )
selectionTool->BrightenItem( m_pickerItem );
}
} );
picker->SetFinalizeHandler( [&]( const int& aFinalState )
{
if( aFinalState == EE_PICKER_TOOL::EVT_CANCEL )
m_frame->ClearToolStack();
} );
picker->SetClickHandler( std::bind( deleteItem, m_frame, std::placeholders::_1 ) );
picker->Activate(); picker->Activate();
Wait(); Wait();
m_frame->PopTool();
return 0; return 0;
} }

View File

@ -71,6 +71,9 @@ private:
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions() override; void setTransitions() override;
private:
EDA_ITEM* m_pickerItem;
}; };
#endif //KICAD_LIB_EDIT_TOOL_H #endif //KICAD_LIB_EDIT_TOOL_H

View File

@ -99,8 +99,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
m_selectionTool->AddItemToSel( component ); m_selectionTool->AddItemToSel( component );
} }
m_frame->PushTool( aEvent.GetCommandStr().get() ); m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
// Prime the pump // Prime the pump
@ -460,7 +459,6 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
getViewControls()->ShowCursor( true ); getViewControls()->ShowCursor( true );
m_frame->SetTool( aEvent.GetCommandStr().get() ); m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
// Prime the pump // Prime the pump

View File

@ -136,14 +136,14 @@ bool SCH_EDIT_TOOL::Init()
wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" ); wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
auto sheetTool = [ this ] ( const SELECTION& aSel ) { auto sheetTool = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetCurrentToolName() == EE_ACTIONS::drawSheet.GetName() ); return ( m_frame->IsCurrentTool( EE_ACTIONS::drawSheet ) );
}; };
auto anyTextTool = [ this ] ( const SELECTION& aSel ) { auto anyTextTool = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetCurrentToolName() == EE_ACTIONS::placeLabel.GetName() return ( m_frame->IsCurrentTool( EE_ACTIONS::placeLabel )
|| m_frame->GetCurrentToolName() == EE_ACTIONS::placeGlobalLabel.GetName() || m_frame->IsCurrentTool( EE_ACTIONS::placeGlobalLabel )
|| m_frame->GetCurrentToolName() == EE_ACTIONS::placeHierLabel.GetName() || m_frame->IsCurrentTool( EE_ACTIONS::placeHierLabel )
|| m_frame->GetCurrentToolName() == EE_ACTIONS::placeSchematicText.GetName() ); || m_frame->IsCurrentTool( EE_ACTIONS::placeSchematicText ) );
}; };
auto duplicateCondition = [] ( const SELECTION& aSel ) { auto duplicateCondition = [] ( const SELECTION& aSel ) {
@ -947,51 +947,58 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
Activate(); Activate();
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>(); EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
wxCHECK( picker, 0 );
m_pickerItem = nullptr; m_pickerItem = nullptr;
picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool { picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool
if( m_pickerItem )
{ {
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem ); if( m_pickerItem )
if( sch_item && sch_item->IsLocked() )
{ {
STATUS_TEXT_POPUP statusPopup( m_frame ); SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
statusPopup.SetText( _( "Item locked." ) );
statusPopup.PopupFor( 2000 ); if( sch_item && sch_item->IsLocked() )
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) ); {
return true; STATUS_TEXT_POPUP statusPopup( m_frame );
statusPopup.SetText( _( "Item locked." ) );
statusPopup.PopupFor( 2000 );
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
return true;
}
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
selectionTool->AddItemToSel( m_pickerItem, true );
m_toolMgr->RunAction( EE_ACTIONS::doDelete, true );
m_pickerItem = nullptr;
} }
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>(); return true;
selectionTool->AddItemToSel( m_pickerItem, true ); } );
m_toolMgr->RunAction( EE_ACTIONS::doDelete, true );
m_pickerItem = nullptr;
}
return true; picker->SetMotionHandler( [this] ( const VECTOR2D& aPos )
} );
picker->SetMotionHandler( [this] ( const VECTOR2D& aPos ) {
EE_COLLECTOR collector;
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
collector.Collect( m_frame->GetScreen()->GetDrawItems(), deletableItems, (wxPoint) aPos );
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
if( m_pickerItem != item )
{ {
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>(); EE_COLLECTOR collector;
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
collector.Collect( m_frame->GetScreen()->GetDrawItems(), deletableItems, (wxPoint) aPos );
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
if( m_pickerItem ) if( m_pickerItem != item )
selectionTool->UnbrightenItem( m_pickerItem ); {
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
m_pickerItem = item; if( m_pickerItem )
selectionTool->UnbrightenItem( m_pickerItem );
if( m_pickerItem ) m_pickerItem = item;
selectionTool->BrightenItem( m_pickerItem );
} if( m_pickerItem )
} ); selectionTool->BrightenItem( m_pickerItem );
}
} );
picker->SetFinalizeHandler( [&]( const int& aFinalState )
{
if( aFinalState == EE_PICKER_TOOL::EVT_CANCEL )
m_frame->ClearToolStack();
} );
picker->Activate(); picker->Activate();
Wait(); Wait();

View File

@ -149,26 +149,25 @@ SCH_LINE_WIRE_BUS_TOOL::~SCH_LINE_WIRE_BUS_TOOL()
} }
using E_C = EE_CONDITIONS;
bool SCH_LINE_WIRE_BUS_TOOL::Init() bool SCH_LINE_WIRE_BUS_TOOL::Init()
{ {
EE_TOOL_BASE::Init(); EE_TOOL_BASE::Init();
auto wireOrBusTool = [ this ] ( const SELECTION& aSel ) { auto wireOrBusTool = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetCurrentToolName() == EE_ACTIONS::drawWire.GetName() return ( m_frame->IsCurrentTool( EE_ACTIONS::drawWire )
|| m_frame->GetCurrentToolName() == EE_ACTIONS::drawBus.GetName() ); || m_frame->IsCurrentTool( EE_ACTIONS::drawBus ) );
}; };
auto lineTool = [ this ] ( const SELECTION& aSel ) { auto lineTool = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetCurrentToolName() == EE_ACTIONS::drawLines.GetName() ); return ( m_frame->IsCurrentTool( EE_ACTIONS::drawLines ) );
}; };
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) { auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return g_CurrentSheet->Last() != g_RootSheet; return g_CurrentSheet->Last() != g_RootSheet;
}; };
auto busSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_BUS_T ); auto busSelection = EE_CONDITIONS::MoreThan( 0 )
&& EE_CONDITIONS::OnlyType( SCH_LINE_LOCATE_BUS_T );
auto& ctxMenu = m_menu.GetMenu(); auto& ctxMenu = m_menu.GetMenu();
@ -177,9 +176,9 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init()
ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 ); ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
ctxMenu.AddSeparator( 10 ); ctxMenu.AddSeparator( 10 );
ctxMenu.AddItem( EE_ACTIONS::drawWire, wireOrBusTool && E_C::Idle, 10 ); ctxMenu.AddItem( EE_ACTIONS::drawWire, wireOrBusTool && EE_CONDITIONS::Idle, 10 );
ctxMenu.AddItem( EE_ACTIONS::drawBus, wireOrBusTool && E_C::Idle, 10 ); ctxMenu.AddItem( EE_ACTIONS::drawBus, wireOrBusTool && EE_CONDITIONS::Idle, 10 );
ctxMenu.AddItem( EE_ACTIONS::drawLines, lineTool && E_C::Idle, 10 ); ctxMenu.AddItem( EE_ACTIONS::drawLines, lineTool && EE_CONDITIONS::Idle, 10 );
ctxMenu.AddItem( EE_ACTIONS::finishWire, IsDrawingWire, 10 ); ctxMenu.AddItem( EE_ACTIONS::finishWire, IsDrawingWire, 10 );
ctxMenu.AddItem( EE_ACTIONS::finishBus, IsDrawingBus, 10 ); ctxMenu.AddItem( EE_ACTIONS::finishBus, IsDrawingBus, 10 );
ctxMenu.AddItem( EE_ACTIONS::finishLine, IsDrawingLine, 10 ); ctxMenu.AddItem( EE_ACTIONS::finishLine, IsDrawingLine, 10 );
@ -190,16 +189,16 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init()
ctxMenu.AddMenu( busUnfoldMenu.get(), EE_CONDITIONS::Idle, 10 ); ctxMenu.AddMenu( busUnfoldMenu.get(), EE_CONDITIONS::Idle, 10 );
ctxMenu.AddSeparator( 100 ); ctxMenu.AddSeparator( 100 );
ctxMenu.AddItem( EE_ACTIONS::placeJunction, wireOrBusTool && E_C::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::placeJunction, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
ctxMenu.AddItem( EE_ACTIONS::placeLabel, wireOrBusTool && E_C::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::placeLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
ctxMenu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusTool && E_C::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
ctxMenu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusTool && E_C::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
ctxMenu.AddItem( EE_ACTIONS::breakWire, wireOrBusTool && E_C::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::breakWire, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
ctxMenu.AddItem( EE_ACTIONS::breakBus, wireOrBusTool && E_C::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::breakBus, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
ctxMenu.AddSeparator( 200 ); ctxMenu.AddSeparator( 200 );
ctxMenu.AddItem( EE_ACTIONS::selectNode, wireOrBusTool && E_C::Idle, 200 ); ctxMenu.AddItem( EE_ACTIONS::selectNode, wireOrBusTool && EE_CONDITIONS::Idle, 200 );
ctxMenu.AddItem( EE_ACTIONS::selectConnection, wireOrBusTool && E_C::Idle, 200 ); ctxMenu.AddItem( EE_ACTIONS::selectConnection, wireOrBusTool && EE_CONDITIONS::Idle, 200 );
// Add bus unfolding to the selection tool // Add bus unfolding to the selection tool
// //
@ -208,7 +207,7 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init()
std::shared_ptr<BUS_UNFOLD_MENU> selBusUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>(); std::shared_ptr<BUS_UNFOLD_MENU> selBusUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
selBusUnfoldMenu->SetTool( m_selectionTool ); selBusUnfoldMenu->SetTool( m_selectionTool );
m_selectionTool->GetToolMenu().AddSubMenu( selBusUnfoldMenu ); m_selectionTool->GetToolMenu().AddSubMenu( selBusUnfoldMenu );
selToolMenu.AddMenu( selBusUnfoldMenu.get(), busSelection && E_C::Idle, 100 ); selToolMenu.AddMenu( selBusUnfoldMenu.get(), busSelection && EE_CONDITIONS::Idle, 100 );
return true; return true;
} }
@ -476,13 +475,10 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
m_view->ClearPreview(); m_view->ClearPreview();
m_view->ShowPreview( false ); m_view->ShowPreview( false );
} }
else else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) m_frame->ClearToolStack();
{ break;
m_frame->ClearToolStack();
break;
}
} }
if( evt->IsActivate() ) if( evt->IsActivate() )

View File

@ -1260,3 +1260,4 @@ void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
Layout(); Layout();
SendSizeEvent(); SendSizeEvent();
} }

View File

@ -586,8 +586,8 @@ public:
// currently: do nothing in GerbView. // currently: do nothing in GerbView.
} }
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas ///> @copydoc EDA_DRAW_FRAME::ActivateGalCanvas
virtual void ActivateGalCanvas() override; void ActivateGalCanvas() override;
/** /**
* Allows Gerbview to install its preferences panels into the preferences dialog. * Allows Gerbview to install its preferences panels into the preferences dialog.

View File

@ -202,7 +202,7 @@ void GERBVIEW_FRAME::ReCreateVToolbar()
m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize, m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
m_optionsToolBar->Add( GERBVIEW_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->AddSeparator(); m_drawToolBar->AddSeparator();
m_drawToolBar->Realize(); m_drawToolBar->Realize();
@ -467,10 +467,12 @@ void GERBVIEW_FRAME::SyncToolbars()
{ {
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions(); KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); #define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
TOGGLE_TOOL( m_mainToolBar, ACTIONS::zoomTool );
m_mainToolBar->Refresh(); m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( GERBVIEW_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED ); TOGGLE_TOOL( m_optionsToolBar, ACTIONS::selectionTool );
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES ); m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES ); m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES );

View File

@ -187,7 +187,7 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// There doesn't seem to be any other good way to tell when another tool // There doesn't seem to be any other good way to tell when another tool
// is canceled and control returns to the selection tool, except by the // is canceled and control returns to the selection tool, except by the
// fact that the selection tool starts to get events again. // fact that the selection tool starts to get events again.
if( m_frame->GetToolId() == ID_NO_TOOL_SELECTED) if( m_frame->IsCurrentTool( ACTIONS::selectionTool ) )
{ {
getViewControls()->SetAdditionalPanButtons( false, true ); getViewControls()->SetAdditionalPanButtons( false, true );
} }
@ -747,8 +747,8 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
auto& controls = *getViewControls(); auto& controls = *getViewControls();
auto previous_settings = controls.GetSettings(); auto previous_settings = controls.GetSettings();
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_frame->SetToolID( ID_TB_MEASUREMENT_TOOL, wxCURSOR_PENCIL, _( "Measure distance" ) );
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() ); KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() );
@ -768,12 +768,25 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
if( evt->IsCancel() || evt->IsActivate() ) if( evt->IsCancel() || evt->IsActivate() )
{ {
break; if( originSet )
{
view.SetVisible( &ruler, false );
controls.SetAutoPan( false );
controls.CaptureCursor( false );
originSet = false;
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->ClearToolStack();
break;
}
if( evt->IsActivate() )
break;
} }
// click or drag starts // click or drag starts
else if( !originSet && else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
{ {
if( !evt->IsDrag( BUT_LEFT ) ) if( !evt->IsDrag( BUT_LEFT ) )
{ {
@ -796,8 +809,7 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
} }
// second click or mouse up after drag ends // second click or mouse up after drag ends
else if( originSet && else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
{ {
originSet = false; originSet = false;
@ -808,8 +820,7 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
} }
// move or drag when origin set updates rules // move or drag when origin set updates rules
else if( originSet && else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
{ {
twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) ); twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
twoPtMgr.SetEnd( cursorPos ); twoPtMgr.SetEnd( cursorPos );
@ -829,8 +840,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
controls.ApplySettings( previous_settings ); controls.ApplySettings( previous_settings );
m_frame->SetNoToolSelected();
return 0; return 0;
} }

View File

@ -310,32 +310,16 @@ public:
virtual void SetTool( const std::string& actionName ); virtual void SetTool( const std::string& actionName );
virtual void PushTool( const std::string& actionName ); virtual void PushTool( const std::string& actionName );
virtual void PopTool(); virtual void PopTool();
/** /**
* The selection tool runs underneath the tool stack, so clearing the stack is equivalent * The selection tool runs underneath the tool stack, so clearing the stack is equivalent
* to selecting the selection tool. * to selecting the selection tool.
*/ */
virtual void ClearToolStack(); virtual void ClearToolStack();
/** bool ToolStackIsEmpty() { return m_toolStack.empty(); }
* Set the tool command ID to \a aId and sets the cursor to \a aCursor.
* bool IsCurrentTool( const TOOL_ACTION& aAction );
* The command ID must be greater or equal ::ID_NO_TOOL_SELECTED. If the command
* ID is less than ::ID_NO_TOOL_SELECTED, the tool command ID is set to
* ::ID_NO_TOOL_SELECTED. On debug builds, an assertion will be raised when
* \a aId is invalid.
*
* @param aId New tool command ID if greater than or equal to ::ID_NO_TOOL_SELECTED.
If less than zero, the current tool command ID is retained.
* @param aCursor Sets the cursor shape if greater than or equal to zero.
* @param aToolMsg The tool message to set in the status bar.
*/
virtual void SetToolID( int aId, int aCursor, const wxString& aToolMsg );
/**
* Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
*/
virtual void SetNoToolSelected();
/** /**
* @return the current tool ID * @return the current tool ID

View File

@ -200,7 +200,6 @@ public:
virtual void ReCreateOptToolbar() { } virtual void ReCreateOptToolbar() { }
virtual void ShowChangedLanguage() override; virtual void ShowChangedLanguage() override;
virtual void ReCreateMenuBar() override; virtual void ReCreateMenuBar() override;
virtual void SetToolID( int aId, int aCursor, const wxString& aToolMsg ) override;
virtual void UpdateStatusBar() override; virtual void UpdateStatusBar() override;
PCB_SCREEN* GetScreen() const override { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); } PCB_SCREEN* GetScreen() const override { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }

View File

@ -737,3 +737,4 @@ const wxString PL_EDITOR_FRAME::GetZoomLevelIndicator() const
{ {
return EDA_DRAW_FRAME::GetZoomLevelIndicator(); return EDA_DRAW_FRAME::GetZoomLevelIndicator();
} }

View File

@ -42,13 +42,6 @@ enum pl_editor_ids
ID_APPEND_DESCR_FILE, ID_APPEND_DESCR_FILE,
ID_PL_MOVE_TOOL,
ID_PL_LINE_TOOL,
ID_PL_RECTANGLE_TOOL,
ID_PL_TEXT_TOOL,
ID_PL_IMAGE_TOOL,
ID_PL_DELETE_TOOL,
ID_PLEDITOR_END_LIST ID_PLEDITOR_END_LIST
}; };

View File

@ -125,7 +125,7 @@ void PL_EDITOR_FRAME::ReCreateVToolbar()
m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize, m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
m_drawToolBar->Add( PL_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_drawToolBar, this ); KiScaledSeparator( m_drawToolBar, this );
m_drawToolBar->Add( PL_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PL_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE );
@ -148,18 +148,20 @@ void PL_EDITOR_FRAME::ReCreateOptToolbar()
void PL_EDITOR_FRAME::SyncToolbars() void PL_EDITOR_FRAME::SyncToolbars()
{ {
#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
m_mainToolBar->Toggle( ACTIONS::save, GetScreen() && GetScreen()->IsModify() ); m_mainToolBar->Toggle( ACTIONS::save, GetScreen() && GetScreen()->IsModify() );
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); TOGGLE_TOOL( m_mainToolBar, ACTIONS::zoomTool );
m_mainToolBar->Refresh(); m_mainToolBar->Refresh();
m_drawToolBar->Toggle( PL_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED ); TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );
m_drawToolBar->Toggle( PL_ACTIONS::drawLine, GetToolId() == ID_PL_LINE_TOOL ); TOGGLE_TOOL( m_drawToolBar, PL_ACTIONS::drawLine );
m_drawToolBar->Toggle( PL_ACTIONS::drawRectangle, GetToolId() == ID_PL_RECTANGLE_TOOL ); TOGGLE_TOOL( m_drawToolBar, PL_ACTIONS::drawRectangle );
m_drawToolBar->Toggle( PL_ACTIONS::placeText, GetToolId() == ID_PL_TEXT_TOOL ); TOGGLE_TOOL( m_drawToolBar, PL_ACTIONS::placeText );
m_drawToolBar->Toggle( PL_ACTIONS::placeImage, GetToolId() == ID_PL_IMAGE_TOOL ); TOGGLE_TOOL( m_drawToolBar, PL_ACTIONS::placeImage );
m_drawToolBar->Toggle( PL_ACTIONS::deleteItemCursor, GetToolId() == ID_PL_DELETE_TOOL ); TOGGLE_TOOL( m_drawToolBar, PL_ACTIONS::deleteItemCursor );
m_drawToolBar->Toggle( PL_ACTIONS::appendImportedWorksheet, false ); // Not really a tool m_drawToolBar->Toggle( PL_ACTIONS::appendImportedWorksheet, false ); // Not really a tool
m_drawToolBar->Refresh(); m_drawToolBar->Refresh();

View File

@ -293,8 +293,7 @@ int PL_EDIT_TOOL::ImportWorksheetContent( const TOOL_EVENT& aEvent )
wxCommandEvent evt( wxEVT_NULL, ID_APPEND_DESCR_FILE ); wxCommandEvent evt( wxEVT_NULL, ID_APPEND_DESCR_FILE );
m_frame->Files_io( evt ); m_frame->Files_io( evt );
m_frame->SetNoToolSelected(); m_frame->ClearToolStack();
return 0; return 0;
} }
@ -352,13 +351,20 @@ static bool deleteItem( PL_EDITOR_FRAME* aFrame, const VECTOR2D& aPosition )
int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{ {
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
PL_PICKER_TOOL* picker = m_toolMgr->GetTool<PL_PICKER_TOOL>(); PL_PICKER_TOOL* picker = m_toolMgr->GetTool<PL_PICKER_TOOL>();
wxCHECK( picker, 0 ); wxCHECK( picker, 0 );
m_frame->SetToolID( ID_PL_DELETE_TOOL, wxCURSOR_BULLSEYE, _( "Delete item" ) );
picker->SetClickHandler( std::bind( deleteItem, m_frame, std::placeholders::_1 ) ); picker->SetClickHandler( std::bind( deleteItem, m_frame, std::placeholders::_1 ) );
picker->SetFinalizeHandler( [&]( const int& aFinalState )
{
if( aFinalState == PL_PICKER_TOOL::EVT_CANCEL )
m_frame->ClearToolStack();
} );
picker->Activate(); picker->Activate();
Wait(); Wait();

View File

@ -147,8 +147,6 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
resetPicker(); resetPicker();
controls->ForceCursorPosition( false ); controls->ForceCursorPosition( false );
getEditFrame<PL_EDITOR_FRAME>()->SetNoToolSelected();
return 0; return 0;
} }

View File

@ -89,7 +89,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( strcmp( idcmd, "$NET:" ) == 0 ) if( strcmp( idcmd, "$NET:" ) == 0 )
{ {
if( GetToolId() == ID_PCB_HIGHLIGHT_BUTT ) if( IsCurrentTool( PCB_ACTIONS::highlightNetTool ) )
{ {
wxString net_name = FROM_UTF8( text ); wxString net_name = FROM_UTF8( text );
NETINFO_ITEM* netinfo = pcb->FindNet( net_name ); NETINFO_ITEM* netinfo = pcb->FindNet( net_name );

View File

@ -64,22 +64,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
int id = event.GetId(); int id = event.GetId();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions(); auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
switch( id ) // Some (not all ) edit commands must be finished or aborted
{
case ID_TOOLBARH_PCB_SELECT_LAYER:
break;
default: // Finish (abort) the command
if( GetToolId() != id )
{
if( m_lastDrawToolId != GetToolId() )
m_lastDrawToolId = GetToolId();
SetNoToolSelected();
}
break;
}
switch( id ) // Execute command switch( id ) // Execute command
{ {
case 0: case 0:

View File

@ -144,16 +144,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
wxGetMousePosition( &pos.x, &pos.y ); wxGetMousePosition( &pos.x, &pos.y );
pos.y += 20; pos.y += 20;
switch( id )
{
case ID_TOOLBARH_PCB_SELECT_LAYER:
break;
default:
SetNoToolSelected();
break;
}
switch( id ) switch( id )
{ {
case ID_MODEDIT_NEW_MODULE: case ID_MODEDIT_NEW_MODULE:

View File

@ -120,7 +120,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
return GetScreen() && GetScreen()->GetRedoCommandCount() > 0; return GetScreen() && GetScreen()->GetRedoCommandCount() > 0;
}; };
auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) { auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
return GetToolId() == ID_NO_TOOL_SELECTED; return ToolStackIsEmpty();
}; };
editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); editMenu->AddItem( ACTIONS::undo, enableUndoCondition );

View File

@ -218,7 +218,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
return GetScreen() && GetScreen()->GetRedoCommandCount() > 0; return GetScreen() && GetScreen()->GetRedoCommandCount() > 0;
}; };
auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) { auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
return GetToolId() == ID_NO_TOOL_SELECTED; return ToolStackIsEmpty();
}; };
editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); editMenu->AddItem( ACTIONS::undo, enableUndoCondition );
@ -417,8 +417,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
routeMenu->AddItem( PCB_ACTIONS::selectLayerPair, SELECTION_CONDITIONS::ShowAlways ); routeMenu->AddItem( PCB_ACTIONS::selectLayerPair, SELECTION_CONDITIONS::ShowAlways );
routeMenu->AddSeparator(); routeMenu->AddSeparator();
routeMenu->AddItem( PCB_ACTIONS::routerActivateSingle, SELECTION_CONDITIONS::ShowAlways ); routeMenu->AddItem( PCB_ACTIONS::routeSingleTrack, SELECTION_CONDITIONS::ShowAlways );
routeMenu->AddItem( PCB_ACTIONS::routerActivateDiffPair, SELECTION_CONDITIONS::ShowAlways ); routeMenu->AddItem( PCB_ACTIONS::routeDiffPair, SELECTION_CONDITIONS::ShowAlways );
routeMenu->AddSeparator(); routeMenu->AddSeparator();
routeMenu->AddItem( PCB_ACTIONS::routerTuneSingleTrace, SELECTION_CONDITIONS::ShowAlways ); routeMenu->AddItem( PCB_ACTIONS::routerTuneSingleTrace, SELECTION_CONDITIONS::ShowAlways );

View File

@ -564,31 +564,6 @@ GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide()
return guide; return guide;
} }
void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
{
bool redraw = false;
EDA_DRAW_FRAME::SetToolID( aId, aCursor, aToolMsg );
if( aId < 0 )
return;
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
// 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 ) )
{
if( displ_opts->m_ContrastModeDisplay )
redraw = true;
}
// must do this after the tool has been set, otherwise pad::Draw() does
// not show proper color when GetDisplayOptions().ContrastModeDisplay is true.
if( redraw )
GetCanvas()->Refresh();
}
/* /*
* Display the grid status. * Display the grid status.

View File

@ -173,8 +173,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
PCB_EDIT_FRAME::OnUpdateSelectTrackWidth ) PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
EVT_UPDATE_UI_RANGE( ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, EVT_UPDATE_UI_RANGE( ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8,
PCB_EDIT_FRAME::OnUpdateSelectViaSize ) PCB_EDIT_FRAME::OnUpdateSelectViaSize )
EVT_UPDATE_UI_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD,
PCB_EDIT_FRAME::OnUpdateMuWaveToolbar )
EVT_COMMAND( wxID_ANY, LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, PCB_EDIT_FRAME::OnLayerColorChange ) EVT_COMMAND( wxID_ANY, LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, PCB_EDIT_FRAME::OnLayerColorChange )
END_EVENT_TABLE() END_EVENT_TABLE()

View File

@ -87,7 +87,7 @@ class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
friend class PCB_LAYER_WIDGET; friend class PCB_LAYER_WIDGET;
/// The auxiliary right vertical tool bar used to access the microwave tools. /// The auxiliary right vertical tool bar used to access the microwave tools.
wxAuiToolBar* m_microWaveToolBar; ACTION_TOOLBAR* m_microWaveToolBar;
protected: protected:
PCB_LAYER_WIDGET* m_Layers; PCB_LAYER_WIDGET* m_Layers;
@ -302,7 +302,6 @@ public:
bool MicrowaveToolbarShown(); bool MicrowaveToolbarShown();
void OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent ); void OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent );
void OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent );
void OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent );
void OnLayerColorChange( wxCommandEvent& aEvent ); void OnLayerColorChange( wxCommandEvent& aEvent );
void OnRunEeschema( wxCommandEvent& event ); void OnRunEeschema( wxCommandEvent& event );

View File

@ -119,28 +119,8 @@ enum pcbnew_ids
ID_PCB_GEN_BOM_FILE_FROM_BOARD, ID_PCB_GEN_BOM_FILE_FROM_BOARD,
ID_PCB_3DSHAPELIB_WIZARD, ID_PCB_3DSHAPELIB_WIZARD,
ID_PCB_MUWAVE_START_CMD,
ID_PCB_MUWAVE_TOOL_SELF_CMD,
ID_PCB_MUWAVE_TOOL_GAP_CMD,
ID_PCB_MUWAVE_TOOL_STUB_CMD,
ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD,
ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD,
ID_PCB_MUWAVE_END_CMD,
ID_TOOLBARH_PCB_SELECT_LAYER, ID_TOOLBARH_PCB_SELECT_LAYER,
// Module editor right vertical tool bar commands.
ID_MODEDIT_PAD_TOOL,
ID_MODEDIT_LINE_TOOL,
ID_MODEDIT_CIRCLE_TOOL,
ID_MODEDIT_ARC_TOOL,
ID_MODEDIT_POLYGON_TOOL,
ID_MODEDIT_TEXT_TOOL,
ID_MODEDIT_ANCHOR_TOOL,
ID_MODEDIT_DELETE_TOOL,
ID_MODEDIT_PLACE_GRID_COORD,
ID_MODEDIT_MEASUREMENT_TOOL,
// ID used in module editor: // ID used in module editor:
ID_MODEDIT_CHECK, ID_MODEDIT_CHECK,
ID_MODEDIT_SAVE, ID_MODEDIT_SAVE,

View File

@ -247,43 +247,23 @@ void LENGTH_TUNER_TOOL::performTuning()
} }
int LENGTH_TUNER_TOOL::TuneSingleTrace( const TOOL_EVENT& aEvent )
{
frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Trace Length" ) );
return mainLoop( PNS::PNS_MODE_TUNE_SINGLE );
}
int LENGTH_TUNER_TOOL::TuneDiffPair( const TOOL_EVENT& aEvent )
{
frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Diff Pair Length" ) );
return mainLoop( PNS::PNS_MODE_TUNE_DIFF_PAIR );
}
int LENGTH_TUNER_TOOL::TuneDiffPairSkew( const TOOL_EVENT& aEvent )
{
frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Diff Pair Skew" ) );
return mainLoop( PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW );
}
void LENGTH_TUNER_TOOL::setTransitions() void LENGTH_TUNER_TOOL::setTransitions()
{ {
Go( &LENGTH_TUNER_TOOL::TuneSingleTrace, PCB_ACTIONS::routerTuneSingleTrace.MakeEvent() ); Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneSingleTrace.MakeEvent() );
Go( &LENGTH_TUNER_TOOL::TuneDiffPair, PCB_ACTIONS::routerTuneDiffPair.MakeEvent() ); Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneDiffPair.MakeEvent() );
Go( &LENGTH_TUNER_TOOL::TuneDiffPairSkew, PCB_ACTIONS::routerTuneDiffPairSkew.MakeEvent() ); Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneDiffPairSkew.MakeEvent() );
} }
int LENGTH_TUNER_TOOL::mainLoop( PNS::ROUTER_MODE aMode ) int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
{ {
// Deselect all items // Deselect all items
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
frame()->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_router->SetMode( aMode ); m_router->SetMode( aEvent.Parameter<PNS::ROUTER_MODE>() );
controls()->SetSnapping( true ); controls()->SetSnapping( true );
controls()->ShowCursor( true ); controls()->ShowCursor( true );
@ -315,7 +295,6 @@ int LENGTH_TUNER_TOOL::mainLoop( PNS::ROUTER_MODE aMode )
} }
} }
frame()->SetNoToolSelected();
frame()->UndoRedoBlock( false ); frame()->UndoRedoBlock( false );
// Store routing settings till the next invocation // Store routing settings till the next invocation

View File

@ -36,15 +36,12 @@ public:
void Reset( RESET_REASON aReason ) override; void Reset( RESET_REASON aReason ) override;
int TuneSingleTrace( const TOOL_EVENT& aEvent ); int MainLoop( const TOOL_EVENT& aEvent );
int TuneDiffPair( const TOOL_EVENT& aEvent );
int TuneDiffPairSkew( const TOOL_EVENT& aEvent );
void setTransitions() override; void setTransitions() override;
private: private:
void performTuning(); void performTuning();
int mainLoop( PNS::ROUTER_MODE aMode );
void updateStatusPopup( PNS_TUNE_STATUS_POPUP& aPopup ); void updateStatusPopup( PNS_TUNE_STATUS_POPUP& aPopup );
int routerOptionsDialog( const TOOL_EVENT& aEvent ); int routerOptionsDialog( const TOOL_EVENT& aEvent );

View File

@ -83,22 +83,16 @@ enum VIA_ACTION_FLAGS
#undef _ #undef _
#define _(s) s #define _(s) s
static const TOOL_ACTION ACT_NewTrack( "pcbnew.InteractiveRouter.NewTrack", static const TOOL_ACTION ACT_EndTrack( "pcbnew.InteractiveRouter.EndTrack",
AS_CONTEXT,
'X', LEGACY_HK_NAME( "Add New Track" ),
_( "New Track" ), _( "Starts laying a new track." ),
add_tracks_xpm );
static const TOOL_ACTION ACT_EndTrack( "pcbnew.InteractiveRouter.EndTrack",
AS_CONTEXT, AS_CONTEXT,
WXK_END, "", WXK_END, "",
_( "End Track" ), _( "Stops laying the current track." ), _( "Finish Track" ), _( "Stops laying the current track." ),
checked_ok_xpm ); checked_ok_xpm );
static const TOOL_ACTION ACT_AutoEndRoute( "pcbnew.InteractiveRouter.AutoEndRoute", static const TOOL_ACTION ACT_AutoEndRoute( "pcbnew.InteractiveRouter.AutoEndRoute",
AS_CONTEXT, AS_CONTEXT,
'F', "", 'F', "",
_( "Auto-end Track" ), _( "Automagically finishes currently routed track." ) ); _( "Auto-finish Track" ), _( "Automagically finishes laying the current track." ) );
static const TOOL_ACTION ACT_PlaceThroughVia( "pcbnew.InteractiveRouter.PlaceVia", static const TOOL_ACTION ACT_PlaceThroughVia( "pcbnew.InteractiveRouter.PlaceVia",
AS_CONTEXT, AS_CONTEXT,
@ -394,7 +388,8 @@ public:
AppendSeparator(); AppendSeparator();
Add( ACT_NewTrack ); Add( PCB_ACTIONS::routeSingleTrack );
Add( PCB_ACTIONS::routeDiffPair );
Add( ACT_EndTrack ); Add( ACT_EndTrack );
Add( PCB_ACTIONS::breakTrack ); Add( PCB_ACTIONS::breakTrack );
@ -770,7 +765,7 @@ void ROUTER_TOOL::performRouting()
updateEndItem( *evt ); updateEndItem( *evt );
m_router->Move( m_endSnapPoint, m_endItem ); m_router->Move( m_endSnapPoint, m_endItem );
} }
else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) ) else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
{ {
updateEndItem( *evt ); updateEndItem( *evt );
bool needLayerSwitch = m_router->IsPlacingVia(); bool needLayerSwitch = m_router->IsPlacingVia();
@ -849,42 +844,6 @@ int ROUTER_TOOL::SettingsDialog( const TOOL_EVENT& aEvent )
} }
void ROUTER_TOOL::setTransitions()
{
Go( &ROUTER_TOOL::SelectCopperLayerPair, PCB_ACTIONS::selectLayerPair.MakeEvent() );
Go( &ROUTER_TOOL::RouteSingleTrace, PCB_ACTIONS::routerActivateSingle.MakeEvent() );
Go( &ROUTER_TOOL::RouteDiffPair, PCB_ACTIONS::routerActivateDiffPair.MakeEvent() );
Go( &ROUTER_TOOL::DpDimensionsDialog, PCB_ACTIONS::routerDiffPairDialog.MakeEvent() );
Go( &ROUTER_TOOL::SettingsDialog, PCB_ACTIONS::routerSettingsDialog.MakeEvent() );
Go( &ROUTER_TOOL::InlineDrag, PCB_ACTIONS::routerInlineDrag.MakeEvent() );
Go( &ROUTER_TOOL::InlineBreakTrack, PCB_ACTIONS::inlineBreakTrack.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceThroughVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceBlindVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceMicroVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_SelLayerAndPlaceThroughVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_SelLayerAndPlaceBlindVia.MakeEvent() );
Go( &ROUTER_TOOL::CustomTrackWidthDialog, ACT_CustomTrackWidth.MakeEvent() );
Go( &ROUTER_TOOL::onTrackViaSizeChanged, PCB_ACTIONS::trackViaSizeChanged.MakeEvent() );
}
int ROUTER_TOOL::RouteSingleTrace( const TOOL_EVENT& aEvent )
{
frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Route Track" ) );
return mainLoop( PNS::PNS_MODE_ROUTE_SINGLE );
}
int ROUTER_TOOL::RouteDiffPair( const TOOL_EVENT& aEvent )
{
frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Router Differential Pair" ) );
return mainLoop( PNS::PNS_MODE_ROUTE_DIFF_PAIR );
}
void ROUTER_TOOL::breakTrack() void ROUTER_TOOL::breakTrack()
{ {
if( m_startItem && m_startItem->OfKind( PNS::ITEM::SEGMENT_T ) ) if( m_startItem && m_startItem->OfKind( PNS::ITEM::SEGMENT_T ) )
@ -894,30 +853,39 @@ void ROUTER_TOOL::breakTrack()
} }
int ROUTER_TOOL::mainLoop( PNS::ROUTER_MODE aMode ) int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
{ {
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>(); PNS::ROUTER_MODE mode = aEvent.Parameter<PNS::ROUTER_MODE>();
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
// Deselect all items // Deselect all items
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_router->SetMode( aMode ); m_router->SetMode( mode );
VIEW_CONTROLS* ctls = getViewControls(); VIEW_CONTROLS* ctls = getViewControls();
ctls->ShowCursor( true ); ctls->ShowCursor( true );
ctls->ForceCursorPosition( false ); ctls->ForceCursorPosition( false );
m_startSnapPoint = ctls->GetCursorPosition(); m_startSnapPoint = ctls->GetCursorPosition();
std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( *frame, aMode ) ); std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( *frame, mode ) );
SetContextMenu( ctxMenu.get() ); SetContextMenu( ctxMenu.get() );
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events // Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
frame->ClearToolStack();
break; // Finish break; // Finish
} }
else if( evt->Action() == TA_UNDO_REDO_PRE ) else if( evt->Action() == TA_UNDO_REDO_PRE )
@ -947,8 +915,16 @@ int ROUTER_TOOL::mainLoop( PNS::ROUTER_MODE aMode )
updateStartItem( *evt, true ); updateStartItem( *evt, true );
breakTrack( ); breakTrack( );
} }
else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) ) else if( evt->IsClick( BUT_LEFT )
|| evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
|| evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
{ {
if( evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
|| evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
{
mode = evt->Parameter<PNS::ROUTER_MODE>();
}
updateStartItem( *evt ); updateStartItem( *evt );
if( evt->Modifier( MD_CTRL ) ) if( evt->Modifier( MD_CTRL ) )
@ -962,7 +938,6 @@ int ROUTER_TOOL::mainLoop( PNS::ROUTER_MODE aMode )
} }
} }
frame->SetNoToolSelected();
SetContextMenu( nullptr ); SetContextMenu( nullptr );
// Store routing settings till the next invocation // Store routing settings till the next invocation
@ -1256,3 +1231,27 @@ int ROUTER_TOOL::onTrackViaSizeChanged( const TOOL_EVENT& aEvent )
return 0; return 0;
} }
void ROUTER_TOOL::setTransitions()
{
Go( &ROUTER_TOOL::SelectCopperLayerPair, PCB_ACTIONS::selectLayerPair.MakeEvent() );
Go( &ROUTER_TOOL::MainLoop, PCB_ACTIONS::routeSingleTrack.MakeEvent() );
Go( &ROUTER_TOOL::MainLoop, PCB_ACTIONS::routeDiffPair.MakeEvent() );
Go( &ROUTER_TOOL::DpDimensionsDialog, PCB_ACTIONS::routerDiffPairDialog.MakeEvent() );
Go( &ROUTER_TOOL::SettingsDialog, PCB_ACTIONS::routerSettingsDialog.MakeEvent() );
Go( &ROUTER_TOOL::InlineDrag, PCB_ACTIONS::routerInlineDrag.MakeEvent() );
Go( &ROUTER_TOOL::InlineBreakTrack, PCB_ACTIONS::inlineBreakTrack.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceThroughVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceBlindVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceMicroVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_SelLayerAndPlaceThroughVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_SelLayerAndPlaceBlindVia.MakeEvent() );
Go( &ROUTER_TOOL::CustomTrackWidthDialog, ACT_CustomTrackWidth.MakeEvent() );
Go( &ROUTER_TOOL::onTrackViaSizeChanged, PCB_ACTIONS::trackViaSizeChanged.MakeEvent() );
}

View File

@ -34,8 +34,8 @@ public:
bool Init() override; bool Init() override;
void Reset( RESET_REASON aReason ) override; void Reset( RESET_REASON aReason ) override;
int RouteSingleTrace( const TOOL_EVENT& aEvent ); int MainLoop( const TOOL_EVENT& aEvent );
int RouteDiffPair( const TOOL_EVENT& aEvent );
int InlineBreakTrack( const TOOL_EVENT& aEvent ); int InlineBreakTrack( const TOOL_EVENT& aEvent );
bool CanInlineDrag(); bool CanInlineDrag();
int InlineDrag( const TOOL_EVENT& aEvent ); int InlineDrag( const TOOL_EVENT& aEvent );
@ -53,8 +53,6 @@ public:
static void NeighboringSegmentFilter( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ); static void NeighboringSegmentFilter( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector );
private: private:
int mainLoop( PNS::ROUTER_MODE aMode );
void performRouting(); void performRouting();
void performDragging( int aMode = PNS::DM_ANY ); void performDragging( int aMode = PNS::DM_ANY );
void breakTrack(); void breakTrack();

View File

@ -126,7 +126,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar()
m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize, m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
m_drawToolBar->Add( PCB_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_drawToolBar, this ); KiScaledSeparator( m_drawToolBar, this );
m_drawToolBar->Add( PCB_ACTIONS::placePad, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::placePad, ACTION_TOOLBAR::TOGGLE );
@ -174,6 +174,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
void FOOTPRINT_EDIT_FRAME::SyncToolbars() void FOOTPRINT_EDIT_FRAME::SyncToolbars()
{ {
#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions(); PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions();
if( IsCurrentFPFromBoard() ) if( IsCurrentFPFromBoard() )
@ -183,7 +185,7 @@ void FOOTPRINT_EDIT_FRAME::SyncToolbars()
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); TOGGLE_TOOL( m_mainToolBar, ACTIONS::zoomTool );
m_mainToolBar->Toggle( PCB_ACTIONS::footprintProperties, GetBoard()->GetFirstModule() ); m_mainToolBar->Toggle( PCB_ACTIONS::footprintProperties, GetBoard()->GetFirstModule() );
m_mainToolBar->Refresh(); m_mainToolBar->Refresh();
@ -197,16 +199,16 @@ void FOOTPRINT_EDIT_FRAME::SyncToolbars()
m_optionsToolBar->Toggle( PCB_ACTIONS::toggleFootprintTree, IsSearchTreeShown() ); m_optionsToolBar->Toggle( PCB_ACTIONS::toggleFootprintTree, IsSearchTreeShown() );
m_optionsToolBar->Refresh(); m_optionsToolBar->Refresh();
m_drawToolBar->Toggle( ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED ); TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );
m_drawToolBar->Toggle( PCB_ACTIONS::placePad, GetToolId() == ID_MODEDIT_PAD_TOOL ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placePad );
m_drawToolBar->Toggle( PCB_ACTIONS::drawLine, GetToolId() == ID_MODEDIT_LINE_TOOL ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawLine );
m_drawToolBar->Toggle( PCB_ACTIONS::drawCircle, GetToolId() == ID_MODEDIT_CIRCLE_TOOL ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawCircle );
m_drawToolBar->Toggle( PCB_ACTIONS::drawArc, GetToolId() == ID_MODEDIT_ARC_TOOL ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawArc );
m_drawToolBar->Toggle( PCB_ACTIONS::drawPolygon, GetToolId() == ID_MODEDIT_POLYGON_TOOL ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawPolygon );
m_drawToolBar->Toggle( PCB_ACTIONS::placeText, GetToolId() == ID_MODEDIT_TEXT_TOOL ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeText );
m_drawToolBar->Toggle( PCB_ACTIONS::deleteTool, GetToolId() == ID_MODEDIT_DELETE_TOOL ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::deleteTool );
m_drawToolBar->Toggle( PCB_ACTIONS::setAnchor, GetToolId() == ID_MODEDIT_ANCHOR_TOOL ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::setAnchor );
m_drawToolBar->Toggle( PCB_ACTIONS::gridSetOrigin, GetToolId() == ID_MODEDIT_PLACE_GRID_COORD ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::gridSetOrigin );
m_drawToolBar->Toggle( ACTIONS::measureTool, GetToolId() == ID_MODEDIT_MEASUREMENT_TOOL ); TOGGLE_TOOL( m_drawToolBar, ACTIONS::measureTool );
m_drawToolBar->Refresh(); m_drawToolBar->Refresh();
} }

View File

@ -367,13 +367,13 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize, m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
m_drawToolBar->Add( PCB_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::highlightNetTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::highlightNetTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::localRatsnestTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::localRatsnestTool, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_drawToolBar, this ); KiScaledSeparator( m_drawToolBar, this );
m_drawToolBar->Add( PCB_ACTIONS::placeModule, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::placeModule, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::routerActivateSingle, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::routeSingleTrack, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::drawVia, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawVia, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::drawZone, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawZone, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::drawZoneKeepout, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawZoneKeepout, ACTION_TOOLBAR::TOGGLE );
@ -406,37 +406,18 @@ void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
if( m_microWaveToolBar ) if( m_microWaveToolBar )
m_microWaveToolBar->Clear(); m_microWaveToolBar->Clear();
else else
m_microWaveToolBar = new wxAuiToolBar( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition, m_microWaveToolBar = new ACTION_TOOLBAR( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition,
wxDefaultSize, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
// Set up toolbar // Set up toolbar
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString, m_microWaveToolBar->Add( PCB_ACTIONS::microwaveCreateLine, ACTION_TOOLBAR::TOGGLE );
KiScaledBitmap( mw_add_line_xpm, this ), m_microWaveToolBar->Add( PCB_ACTIONS::microwaveCreateGap, ACTION_TOOLBAR::TOGGLE );
_( "Create line of specified length for microwave applications" ),
wxITEM_CHECK );
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
KiScaledBitmap( mw_add_gap_xpm, this ),
_( "Create gap of specified length for microwave applications" ),
wxITEM_CHECK );
KiScaledSeparator( m_microWaveToolBar, this ); KiScaledSeparator( m_microWaveToolBar, this );
m_microWaveToolBar->Add( PCB_ACTIONS::microwaveCreateStub, ACTION_TOOLBAR::TOGGLE );
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString, m_microWaveToolBar->Add( PCB_ACTIONS::microwaveCreateStubArc, ACTION_TOOLBAR::TOGGLE );
KiScaledBitmap( mw_add_stub_xpm, this ), m_microWaveToolBar->Add( PCB_ACTIONS::microwaveCreateFunctionShape, ACTION_TOOLBAR::TOGGLE );
_( "Create stub of specified length for microwave applications" ),
wxITEM_CHECK );
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
KiScaledBitmap( mw_add_stub_arc_xpm, this ),
_( "Create stub (arc) of specified length for microwave applications" ),
wxITEM_CHECK );
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, wxEmptyString,
KiScaledBitmap( mw_add_shape_xpm, this ),
_( "Create a polynomial shape for microwave applications" ),
wxITEM_CHECK );
m_microWaveToolBar->Realize(); m_microWaveToolBar->Realize();
} }
@ -684,15 +665,10 @@ bool PCB_EDIT_FRAME::MicrowaveToolbarShown()
} }
void PCB_EDIT_FRAME::OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent )
{
if( aEvent.GetEventObject() == m_microWaveToolBar )
aEvent.Check( GetToolId() == aEvent.GetId() );
}
void PCB_EDIT_FRAME::SyncToolbars() void PCB_EDIT_FRAME::SyncToolbars()
{ {
#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions(); PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions();
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions(); KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
int zoneMode = opts->m_DisplayZonesMode; int zoneMode = opts->m_DisplayZonesMode;
@ -700,7 +676,7 @@ void PCB_EDIT_FRAME::SyncToolbars()
m_mainToolBar->Toggle( ACTIONS::save, GetScreen() && GetScreen()->IsModify() ); m_mainToolBar->Toggle( ACTIONS::save, GetScreen() && GetScreen()->IsModify() );
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); TOGGLE_TOOL( m_mainToolBar, ACTIONS::zoomTool );
#if defined(KICAD_SCRIPTING_WXPYTHON) #if defined(KICAD_SCRIPTING_WXPYTHON)
if( IsWxPythonLoaded() ) if( IsWxPythonLoaded() )
{ {
@ -731,24 +707,31 @@ void PCB_EDIT_FRAME::SyncToolbars()
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts->m_ContrastModeDisplay ); m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts->m_ContrastModeDisplay );
m_optionsToolBar->Refresh(); m_optionsToolBar->Refresh();
m_drawToolBar->Toggle( PCB_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED ); TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );
m_drawToolBar->Toggle( PCB_ACTIONS::highlightNetTool, GetToolId() == ID_PCB_HIGHLIGHT_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::highlightNetTool );
m_drawToolBar->Toggle( PCB_ACTIONS::localRatsnestTool,GetToolId() == ID_LOCAL_RATSNEST_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::localRatsnestTool );
m_drawToolBar->Toggle( PCB_ACTIONS::placeModule, GetToolId() == ID_PCB_MODULE_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeModule );
m_drawToolBar->Toggle( PCB_ACTIONS::routerActivateSingle, GetToolId() == ID_TRACK_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::routeSingleTrack );
m_drawToolBar->Toggle( PCB_ACTIONS::drawVia, GetToolId() == ID_PCB_DRAW_VIA_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawVia );
m_drawToolBar->Toggle( PCB_ACTIONS::drawZone, GetToolId() == ID_PCB_ZONES_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZone );
m_drawToolBar->Toggle( PCB_ACTIONS::drawZoneKeepout, GetToolId() == ID_PCB_KEEPOUT_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZoneKeepout );
m_drawToolBar->Toggle( PCB_ACTIONS::drawLine, GetToolId() == ID_PCB_ADD_LINE_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawLine );
m_drawToolBar->Toggle( PCB_ACTIONS::drawCircle, GetToolId() == ID_PCB_CIRCLE_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawCircle );
m_drawToolBar->Toggle( PCB_ACTIONS::drawArc, GetToolId() == ID_PCB_ARC_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawArc );
m_drawToolBar->Toggle( PCB_ACTIONS::drawPolygon, GetToolId() == ID_PCB_ADD_POLYGON_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawPolygon );
m_drawToolBar->Toggle( PCB_ACTIONS::placeText, GetToolId() == ID_PCB_ADD_TEXT_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeText );
m_drawToolBar->Toggle( PCB_ACTIONS::drawDimension, GetToolId() == ID_PCB_DIMENSION_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawDimension );
m_drawToolBar->Toggle( PCB_ACTIONS::placeTarget, GetToolId() == ID_PCB_TARGET_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeTarget );
m_drawToolBar->Toggle( PCB_ACTIONS::deleteTool, GetToolId() == ID_PCB_DELETE_ITEM_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::deleteTool );
m_drawToolBar->Toggle( PCB_ACTIONS::drillOrigin, GetToolId() == ID_PCB_PLACE_OFFSET_COORD_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drillOrigin );
m_drawToolBar->Toggle( PCB_ACTIONS::gridSetOrigin, GetToolId() == ID_PCB_PLACE_GRID_COORD_BUTT ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::gridSetOrigin );
m_drawToolBar->Toggle( ACTIONS::measureTool, GetToolId() == ID_PCB_MEASUREMENT_TOOL ); TOGGLE_TOOL( m_drawToolBar, ACTIONS::measureTool );
m_drawToolBar->Refresh(); m_drawToolBar->Refresh();
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateLine );
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateGap );
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateStub );
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateStubArc );
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateFunctionShape );
m_microWaveToolBar->Refresh();
} }

View File

@ -137,18 +137,18 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
if( m_editModules && !m_frame->GetModel() ) if( m_editModules && !m_frame->GetModel() )
return 0; return 0;
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel(); MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT; DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
BOARD_COMMIT commit( m_frame );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
OPT<VECTOR2D> startingPoint = NULLOPT;
line->SetFlags( IS_NEW ); line->SetFlags( IS_NEW );
auto startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) ); if( aEvent.HasPosition() )
BOARD_COMMIT commit( m_frame ); startingPoint = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
m_frame->SetToolID( m_editModules ? ID_MODEDIT_LINE_TOOL : ID_PCB_ADD_LINE_BUTT,
wxCURSOR_PENCIL, _( "Add graphic line" ) );
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
while( drawSegment( S_SEGMENT, line, startingPoint ) ) while( drawSegment( S_SEGMENT, line, startingPoint ) )
@ -170,12 +170,10 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
startingPoint = NULLOPT; startingPoint = NULLOPT;
} }
line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT; line = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
line->SetFlags( IS_NEW ); line->SetFlags( IS_NEW );
} }
m_frame->SetNoToolSelected();
return 0; return 0;
} }
@ -185,20 +183,21 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
if( m_editModules && !m_frame->GetModel() ) if( m_editModules && !m_frame->GetModel() )
return 0; return 0;
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel(); MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
DRAWSEGMENT* circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT; DRAWSEGMENT* circle = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::CIRCLE );
OPT<VECTOR2D> startingPoint = NULLOPT;
circle->SetFlags( IS_NEW ); circle->SetFlags( IS_NEW );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::CIRCLE ); if( aEvent.HasPosition() )
startingPoint = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
m_frame->SetToolID( m_editModules ? ID_MODEDIT_CIRCLE_TOOL : ID_PCB_CIRCLE_BUTT,
wxCURSOR_PENCIL, _( "Add graphic circle" ) );
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
while( drawSegment( S_CIRCLE, circle ) ) while( drawSegment( S_CIRCLE, circle, startingPoint ) )
{ {
// This can be reset by some actions (e.g. Save Board), so ensure it stays set. // This can be reset by some actions (e.g. Save Board), so ensure it stays set.
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
@ -212,12 +211,11 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
commit.Push( _( "Draw a circle" ) ); commit.Push( _( "Draw a circle" ) );
} }
circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT; circle = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
circle->SetFlags( IS_NEW ); circle->SetFlags( IS_NEW );
startingPoint = NULLOPT;
} }
m_frame->SetNoToolSelected();
return 0; return 0;
} }
@ -227,18 +225,18 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
if( m_editModules && !m_frame->GetModel() ) if( m_editModules && !m_frame->GetModel() )
return 0; return 0;
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel(); MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
DRAWSEGMENT* arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT; DRAWSEGMENT* arc = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC );
bool immediateMode = aEvent.HasPosition();
arc->SetFlags( IS_NEW ); arc->SetFlags( IS_NEW );
m_frame->SetToolID( m_editModules ? ID_MODEDIT_ARC_TOOL : ID_PCB_ARC_BUTT, m_frame->SetTool( aEvent.GetCommandStr().get() );
wxCURSOR_PENCIL, _( "Add graphic arc" ) ); Activate();
while( drawArc( arc ) ) while( drawArc( arc, immediateMode ) )
{ {
// This can be reset by some actions (e.g. Save Board), so ensure it stays set. // This can be reset by some actions (e.g. Save Board), so ensure it stays set.
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
@ -252,12 +250,11 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
commit.Push( _( "Draw an arc" ) ); commit.Push( _( "Draw an arc" ) );
} }
arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT; arc = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
arc->SetFlags( IS_NEW ); arc->SetFlags( IS_NEW );
immediateMode = false;
} }
m_frame->SetNoToolSelected();
return 0; return 0;
} }
@ -278,12 +275,15 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_frame->SetToolID( m_editModules ? ID_MODEDIT_TEXT_TOOL : ID_PCB_ADD_TEXT_BUTT,
wxCURSOR_PENCIL, _( "Add text" ) );
bool reselect = false; bool reselect = false;
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events // Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
{ {
@ -309,9 +309,15 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
} }
else else
break; {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->ClearToolStack();
break;
}
}
if( evt->IsActivate() ) // now finish unconditionally if( evt->IsActivate() )
break; break;
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
@ -432,8 +438,6 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
} }
frame()->SetMsgPanel( board() ); frame()->SetMsgPanel( board() );
frame()->SetNoToolSelected();
return 0; return 0;
} }
@ -467,8 +471,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_frame->SetToolID( ID_PCB_DIMENSION_BUTT, wxCURSOR_PENCIL, _( "Add dimension" ) );
enum DIMENSION_STEPS enum DIMENSION_STEPS
{ {
@ -479,6 +483,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
}; };
int step = SET_ORIGIN; int step = SET_ORIGIN;
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events // Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
{ {
@ -502,9 +510,15 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
step = SET_ORIGIN; step = SET_ORIGIN;
} }
else else
break; {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->ClearToolStack();
break;
}
}
if( evt->IsActivate() ) // now finish unconditionally if( evt->IsActivate() )
break; break;
} }
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN ) else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN )
@ -636,66 +650,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
m_view->Remove( &preview ); m_view->Remove( &preview );
frame()->SetMsgPanel( board() ); frame()->SetMsgPanel( board() );
m_frame->SetNoToolSelected();
return 0; return 0;
} }
int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
{
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zones" ) );
return drawZone( false, ZONE_MODE::ADD );
}
int DRAWING_TOOL::DrawZoneKeepout( const TOOL_EVENT& aEvent )
{
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::KEEPOUT );
m_frame->SetToolID( ID_PCB_KEEPOUT_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
return drawZone( true, ZONE_MODE::ADD );
}
int DRAWING_TOOL::DrawZoneCutout( const TOOL_EVENT& aEvent )
{
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zone cutout" ) );
return drawZone( false, ZONE_MODE::CUTOUT );
}
int DRAWING_TOOL::DrawGraphicPolygon( const TOOL_EVENT& aEvent )
{
if( m_editModules && !m_frame->GetModel() )
return 0;
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::GRAPHIC_POLYGON );
m_frame->SetToolID( m_editModules ? ID_MODEDIT_POLYGON_TOOL : ID_PCB_ADD_POLYGON_BUTT,
wxCURSOR_PENCIL, _( "Add graphic polygon" ) );
return drawZone( false, ZONE_MODE::GRAPHIC_POLYGON );
}
int DRAWING_TOOL::DrawSimilarZone( const TOOL_EVENT& aEvent )
{
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add similar zone" ) );
return drawZone( false, ZONE_MODE::SIMILAR );
}
int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
{ {
if( !m_frame->GetModel() ) if( !m_frame->GetModel() )
@ -718,7 +676,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
return 0; return 0;
} }
m_frame->SetNoToolSelected(); m_frame->ClearToolStack();
// Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item
PCBNEW_SELECTION preview; PCBNEW_SELECTION preview;
@ -767,6 +725,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
m_view->Update( &preview ); m_view->Update( &preview );
m_frame->PushTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
// Main loop: keep receiving events // Main loop: keep receiving events
@ -826,7 +785,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
preview.Clear(); preview.Clear();
m_view->Remove( &preview ); m_view->Remove( &preview );
m_frame->PopTool();
return 0; return 0;
} }
@ -840,8 +799,8 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
m_frame->PushTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_frame->SetToolID( ID_MODEDIT_ANCHOR_TOOL, wxCURSOR_PENCIL, _( "Place the footprint anchor" ) );
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->SetSnapping( true ); m_controls->SetSnapping( true );
@ -878,8 +837,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
break; break;
} }
m_frame->SetNoToolSelected(); m_frame->PopTool();
return 0; return 0;
} }
@ -905,27 +863,9 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
bool isLocalOriginSet = ( m_frame->GetScreen()->m_LocalOrigin != VECTOR2D( 0, 0 ) ); bool isLocalOriginSet = ( m_frame->GetScreen()->m_LocalOrigin != VECTOR2D( 0, 0 ) );
VECTOR2I cursorPos = m_controls->GetMousePosition(); VECTOR2I cursorPos = m_controls->GetMousePosition();
// Prime the pump
if( aStartingPoint ) if( aStartingPoint )
{ m_toolMgr->RunAction( ACTIONS::cursorClick );
// Init the new item attributes
aGraphic->SetShape( (STROKE_T) aShape );
aGraphic->SetWidth( m_lineWidth );
aGraphic->SetLayer( getDrawingLayer() );
aGraphic->SetStart( (wxPoint) aStartingPoint.get() );
cursorPos = grid.BestSnapAnchor( cursorPos, aGraphic );
m_controls->ForceCursorPosition( true, cursorPos );
aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
preview.Add( aGraphic );
m_controls->SetAutoPan( true );
m_controls->CaptureCursor( true );
if( !isLocalOriginSet )
m_frame->GetScreen()->m_LocalOrigin = aStartingPoint.get();
started = true;
}
// Main loop: keep receiving events // Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
@ -963,13 +903,20 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{ {
preview.Clear(); if( started )
m_view->Update( &preview ); {
delete aGraphic; preview.Clear();
aGraphic = nullptr; m_view->Update( &preview );
delete aGraphic;
aGraphic = nullptr;
if( !isLocalOriginSet ) if( !isLocalOriginSet )
m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 ); m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->ClearToolStack();
}
break; break;
} }
@ -989,6 +936,12 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
{ {
if( !started ) if( !started )
{ {
if( aStartingPoint )
{
cursorPos = aStartingPoint.get();
aStartingPoint = NULLOPT;
}
m_lineWidth = getSegmentWidth( getDrawingLayer() ); m_lineWidth = getSegmentWidth( getDrawingLayer() );
// Init the new item attributes // Init the new item attributes
@ -1116,7 +1069,7 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER
} }
bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode )
{ {
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
@ -1137,10 +1090,12 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->SetSnapping( true ); m_controls->SetSnapping( true );
Activate();
bool firstPoint = false; bool firstPoint = false;
// Prime the pump
if( aImmediateMode )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events // Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
{ {
@ -1187,9 +1142,17 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
} }
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{ {
preview.Clear(); if( firstPoint )
delete aGraphic; {
aGraphic = nullptr; preview.Clear();
delete aGraphic;
aGraphic = nullptr;
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->ClearToolStack();
}
break; break;
} }
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) ) else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
@ -1233,7 +1196,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
m_view->Update( &preview ); m_view->Update( &preview );
m_view->Update( &arcAsst ); m_view->Update( &arcAsst );
if(firstPoint) if( firstPoint )
frame()->SetMsgPanel( aGraphic ); frame()->SetMsgPanel( aGraphic );
else else
frame()->SetMsgPanel( board() ); frame()->SetMsgPanel( board() );
@ -1286,28 +1249,39 @@ bool DRAWING_TOOL::getSourceZoneForAction( ZONE_MODE aMode, ZONE_CONTAINER*& aZo
return true; return true;
} }
int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode ) int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
{ {
ZONE_MODE zoneMode = aEvent.Parameter<ZONE_MODE>();
MODE drawMode = MODE::ZONE;
if( aEvent.IsAction( &PCB_ACTIONS::drawZoneKeepout ) )
drawMode = MODE::KEEPOUT;
if( aEvent.IsAction( &PCB_ACTIONS::drawPolygon ) )
drawMode = MODE::GRAPHIC_POLYGON;
SCOPED_DRAW_MODE scopedDrawMode( m_mode, drawMode );
// get a source zone, if we need one. We need it for: // get a source zone, if we need one. We need it for:
// ZONE_MODE::CUTOUT (adding a hole to the source zone) // ZONE_MODE::CUTOUT (adding a hole to the source zone)
// ZONE_MODE::SIMILAR (creating a new zone using settings of source zone // ZONE_MODE::SIMILAR (creating a new zone using settings of source zone
ZONE_CONTAINER* sourceZone = nullptr; ZONE_CONTAINER* sourceZone = nullptr;
if( !getSourceZoneForAction( aMode, sourceZone ) ) if( !getSourceZoneForAction( zoneMode, sourceZone ) )
{ {
m_frame->SetNoToolSelected(); m_frame->ClearToolStack();
return 0; return 0;
} }
ZONE_CREATE_HELPER::PARAMS params; ZONE_CREATE_HELPER::PARAMS params;
params.m_keepout = aKeepout; params.m_keepout = drawMode == MODE::KEEPOUT;
params.m_mode = aMode; params.m_mode = zoneMode;
params.m_sourceZone = sourceZone; params.m_sourceZone = sourceZone;
if( aMode == ZONE_MODE::GRAPHIC_POLYGON ) if( zoneMode == ZONE_MODE::GRAPHIC_POLYGON )
params.m_layer = getDrawingLayer(); params.m_layer = getDrawingLayer();
else if( aMode == ZONE_MODE::SIMILAR ) else if( zoneMode == ZONE_MODE::SIMILAR )
params.m_layer = sourceZone->GetLayer(); params.m_layer = sourceZone->GetLayer();
else else
params.m_layer = m_frame->GetActiveLayer(); params.m_layer = m_frame->GetActiveLayer();
@ -1318,6 +1292,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
// hands the calculated points over to the zone creator tool // hands the calculated points over to the zone creator tool
POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool ); POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool );
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); // register for events Activate(); // register for events
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
@ -1329,6 +1304,11 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
status.SetTextColor( wxColour( 255, 0, 0 ) ); status.SetTextColor( wxColour( 255, 0, 0 ) );
status.SetText( _( "Self-intersecting polygons are not allowed" ) ); status.SetText( _( "Self-intersecting polygons are not allowed" ) );
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
{ {
// This can be reset by some actions (e.g. Save Board), so ensure it stays set. // This can be reset by some actions (e.g. Save Board), so ensure it stays set.
@ -1342,25 +1322,30 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{ {
// pre-empted by another tool, give up if( polyGeomMgr.IsPolygonInProgress() )
// cancelled without an inprogress polygon, give up
if( !polyGeomMgr.IsPolygonInProgress() || evt->IsActivate() )
{ {
polyGeomMgr.Reset();
// start again
started = false;
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->ClearToolStack();
break; break;
} }
polyGeomMgr.Reset(); // pre-empted by another tool, give up
// start again if( evt->IsActivate() )
started = false; break;
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
} }
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) ) else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
{ {
if( aMode == ZONE_MODE::GRAPHIC_POLYGON ) if( zoneMode == ZONE_MODE::GRAPHIC_POLYGON )
params.m_layer = getDrawingLayer(); params.m_layer = getDrawingLayer();
else if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::CUTOUT ) else if( zoneMode == ZONE_MODE::ADD || zoneMode == ZONE_MODE::CUTOUT )
params.m_layer = frame()->GetActiveLayer(); params.m_layer = frame()->GetActiveLayer();
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
@ -1435,9 +1420,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
} // end while } // end while
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_frame->SetNoToolSelected();
m_controls->ForceCursorPosition( false ); m_controls->ForceCursorPosition( false );
return 0; return 0;
} }
@ -1719,36 +1702,15 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
VIA_PLACER placer( frame() ); VIA_PLACER placer( frame() );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
frame()->SetTool( aEvent.GetCommandStr().get() );
frame()->SetToolID( ID_PCB_DRAW_VIA_BUTT, wxCURSOR_PENCIL, _( "Add vias" ) );
doInteractiveItemPlacement( &placer, _( "Place via" ), doInteractiveItemPlacement( &placer, _( "Place via" ),
IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP ); IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
frame()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0; return 0;
} }
void DRAWING_TOOL::setTransitions()
{
Go( &DRAWING_TOOL::DrawLine, PCB_ACTIONS::drawLine.MakeEvent() );
Go( &DRAWING_TOOL::DrawGraphicPolygon, PCB_ACTIONS::drawPolygon.MakeEvent() );
Go( &DRAWING_TOOL::DrawCircle, PCB_ACTIONS::drawCircle.MakeEvent() );
Go( &DRAWING_TOOL::DrawArc, PCB_ACTIONS::drawArc.MakeEvent() );
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawDimension.MakeEvent() );
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZone.MakeEvent() );
Go( &DRAWING_TOOL::DrawZoneKeepout, PCB_ACTIONS::drawZoneKeepout.MakeEvent() );
Go( &DRAWING_TOOL::DrawZoneCutout, PCB_ACTIONS::drawZoneCutout.MakeEvent() );
Go( &DRAWING_TOOL::DrawSimilarZone, PCB_ACTIONS::drawSimilarZone.MakeEvent() );
Go( &DRAWING_TOOL::DrawVia, PCB_ACTIONS::drawVia.MakeEvent() );
Go( &DRAWING_TOOL::PlaceText, PCB_ACTIONS::placeText.MakeEvent() );
Go( &DRAWING_TOOL::PlaceImportedGraphics, PCB_ACTIONS::placeImportedGraphics.MakeEvent() );
Go( &DRAWING_TOOL::SetAnchor, PCB_ACTIONS::setAnchor.MakeEvent() );
}
int DRAWING_TOOL::getSegmentWidth( PCB_LAYER_ID aLayer ) const int DRAWING_TOOL::getSegmentWidth( PCB_LAYER_ID aLayer ) const
{ {
assert( m_board ); assert( m_board );
@ -1778,3 +1740,21 @@ PCB_LAYER_ID DRAWING_TOOL::getDrawingLayer() const
const unsigned int DRAWING_TOOL::WIDTH_STEP = Millimeter2iu( 0.1 ); const unsigned int DRAWING_TOOL::WIDTH_STEP = Millimeter2iu( 0.1 );
void DRAWING_TOOL::setTransitions()
{
Go( &DRAWING_TOOL::DrawLine, PCB_ACTIONS::drawLine.MakeEvent() );
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawPolygon.MakeEvent() );
Go( &DRAWING_TOOL::DrawCircle, PCB_ACTIONS::drawCircle.MakeEvent() );
Go( &DRAWING_TOOL::DrawArc, PCB_ACTIONS::drawArc.MakeEvent() );
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawDimension.MakeEvent() );
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZone.MakeEvent() );
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZoneKeepout.MakeEvent() );
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZoneCutout.MakeEvent() );
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawSimilarZone.MakeEvent() );
Go( &DRAWING_TOOL::DrawVia, PCB_ACTIONS::drawVia.MakeEvent() );
Go( &DRAWING_TOOL::PlaceText, PCB_ACTIONS::placeText.MakeEvent() );
Go( &DRAWING_TOOL::PlaceImportedGraphics, PCB_ACTIONS::placeImportedGraphics.MakeEvent() );
Go( &DRAWING_TOOL::SetAnchor, PCB_ACTIONS::setAnchor.MakeEvent() );
}

View File

@ -25,10 +25,10 @@
#ifndef __DRAWING_TOOL_H #ifndef __DRAWING_TOOL_H
#define __DRAWING_TOOL_H #define __DRAWING_TOOL_H
#include <tools/pcb_tool_base.h>
#include <core/optional.h> #include <core/optional.h>
#include <tool/tool_menu.h> #include <tool/tool_menu.h>
#include <tools/pcb_tool_base.h>
#include <tools/pcb_actions.h>
namespace KIGFX namespace KIGFX
{ {
@ -128,39 +128,16 @@ public:
* is displayed. After confirmation it allows the user to set points that are going to be used * is displayed. After confirmation it allows the user to set points that are going to be used
* as a boundary polygon of the zone. Double click or clicking on the origin of the boundary * as a boundary polygon of the zone. Double click or clicking on the origin of the boundary
* polyline finishes the drawing. * polyline finishes the drawing.
*
* The event parameter indicates which type of zone to draw:
* ADD add a new zone/keepout with fresh settings
* CUTOUT add a cutout to an existing zone
* SIMILAR add a new zone with the same settings as an existing one
*/ */
int DrawZone( const TOOL_EVENT& aEvent ); int DrawZone( const TOOL_EVENT& aEvent );
int DrawGraphicPolygon( const TOOL_EVENT& aEvent );
int DrawVia( const TOOL_EVENT& aEvent ); int DrawVia( const TOOL_EVENT& aEvent );
/**
* Function DrawZoneKeepout()
* Starts interactively drawing a keepout area. After invoking the function an area settings
* dialog is displayed. After confirmation it allows the user to set points that are going to
* be used as a boundary polygon of the area. Double click or clicking on the origin of the
* boundary polyline finishes the drawing.
*/
int DrawZoneKeepout( const TOOL_EVENT& aEvent );
/**
* Function DrawZoneCutout()
* Starts interactively drawing a zone cutout area of an existing zone.
* The normal zone interactive tool is used, but the zone settings
* dialog is not shown (since the cutout affects only shape of an
* existing zone).
*/
int DrawZoneCutout( const TOOL_EVENT& aEvent );
/**
* Function DrawSimilarZone()
* Starts interactively drawing a zone with same settings as
* an existing zone.
* The normal zone interactive tool is used, but the zone settings
* dialog is not shown at the start.
*/
int DrawSimilarZone( const TOOL_EVENT& aEvent );
/** /**
* Function PlaceImportedGraphics() * Function PlaceImportedGraphics()
* Places a drawing imported from a DXF or SVG file in module editor. * Places a drawing imported from a DXF or SVG file in module editor.
@ -178,14 +155,6 @@ public:
private: private:
enum class ZONE_MODE
{
ADD, ///< Add a new zone/keepout with fresh settings
CUTOUT, ///< Make a cutout to an existing zone
SIMILAR, ///< Add a new zone with the same settings as an existing one
GRAPHIC_POLYGON
};
///> Starts drawing a selected shape (i.e. DRAWSEGMENT). ///> Starts drawing a selected shape (i.e. DRAWSEGMENT).
///> @param aShape is the type of created shape (@see STROKE_T). ///> @param aShape is the type of created shape (@see STROKE_T).
///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to ///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to
@ -195,15 +164,14 @@ private:
///> and its settings (width, layer) set to the current default values. ///> and its settings (width, layer) set to the current default values.
///> @return False if the tool was cancelled before the origin was set or origin and end are ///> @return False if the tool was cancelled before the origin was set or origin and end are
///> the same point. ///> the same point.
bool drawSegment( int aShape, DRAWSEGMENT*& aGraphic, bool drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D> aStartingPoint );
OPT<VECTOR2D> aStartingPoint = NULLOPT );
///> Starts drawing an arc. ///> Starts drawing an arc.
///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to ///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to
///> be already created. The tool deletes the object if it is not added to a BOARD. ///> be already created. The tool deletes the object if it is not added to a BOARD.
///> @return False if the tool was cancelled before the origin was set or origin and end are ///> @return False if the tool was cancelled before the origin was set or origin and end are
///> the same point. ///> the same point.
bool drawArc( DRAWSEGMENT*& aGraphic ); bool drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode );
/** /**
* Draws a polygon, that is added as a zone or a keepout area. * Draws a polygon, that is added as a zone or a keepout area.
@ -215,7 +183,6 @@ private:
* CUTOUT add a cutout to an existing zone * CUTOUT add a cutout to an existing zone
* SIMILAR add a new zone with the same settings as an existing one * SIMILAR add a new zone with the same settings as an existing one
*/ */
int drawZone( bool aKeepout, ZONE_MODE aMode );
/** /**
* Function getSourceZoneForAction() * Function getSourceZoneForAction()

View File

@ -4,7 +4,7 @@
* Copyright (C) 2013-2017 CERN * Copyright (C) 2013-2017 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -137,7 +137,7 @@ bool EDIT_TOOL::Init()
&& SELECTION_CONDITIONS::Count( 1 ); && SELECTION_CONDITIONS::Count( 1 );
auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) { auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
return ( frame()->GetToolId() == ID_NO_TOOL_SELECTED ); return frame()->ToolStackIsEmpty();
}; };
// Add context menu entries that are displayed when selection tool is active // Add context menu entries that are displayed when selection tool is active
@ -183,7 +183,7 @@ bool EDIT_TOOL::Init()
// Populate the context menu displayed during the edit tool (primarily the measure tool) // Populate the context menu displayed during the edit tool (primarily the measure tool)
auto activeToolCondition = [ this ] ( const SELECTION& aSel ) { auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
return ( frame()->GetToolId() != ID_NO_TOOL_SELECTED ); return frame()->ToolStackIsEmpty();
}; };
auto frame = getEditFrame<PCB_BASE_FRAME>(); auto frame = getEditFrame<PCB_BASE_FRAME>();
@ -1104,10 +1104,9 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
auto& view = *getView(); auto& view = *getView();
auto& controls = *getViewControls(); auto& controls = *getViewControls();
int toolID = EditingModules() ? ID_MODEDIT_MEASUREMENT_TOOL : ID_PCB_MEASUREMENT_TOOL;
frame()->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
frame()->SetToolID( toolID, wxCURSOR_PENCIL, _( "Measure distance" ) );
EDA_UNITS_T units = frame()->GetUserUnits(); EDA_UNITS_T units = frame()->GetUserUnits();
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
@ -1136,7 +1135,21 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{ {
break; if( originSet )
{
view.SetVisible( &ruler, false );
controls.SetAutoPan( false );
controls.CaptureCursor( false );
originSet = false;
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
frame()->ClearToolStack();
break;
}
if( evt->IsActivate() )
break;
} }
// click or drag starts // click or drag starts
@ -1190,8 +1203,6 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
view.Remove( &ruler ); view.Remove( &ruler );
frame()->SetNoToolSelected();
return 0; return 0;
} }

View File

@ -313,13 +313,10 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
PAD_PLACER placer; PAD_PLACER placer;
m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) ); frame()->SetTool( aEvent.GetCommandStr().get() );
wxASSERT( board()->GetFirstModule() ); doInteractiveItemPlacement( &placer, _( "Place pad" ),
IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
doInteractiveItemPlacement( &placer, _( "Place pad" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
m_frame->SetNoToolSelected();
return 0; return 0;
} }

View File

@ -56,93 +56,52 @@ void MICROWAVE_TOOL::Reset( RESET_REASON aReason )
} }
struct MICROWAVE_TOOL_INFO int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent )
{ {
using MOD_CREATOR = std::function<std::unique_ptr<MODULE>()>; auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
wxString name; std::function<std::unique_ptr<MODULE>()> creator;
int toolId;
MOD_CREATOR creatorFunc;
};
switch( aEvent.Parameter<intptr_t>() )
MICROWAVE_TOOL_INFO getMicrowaveItemCreator( PCB_EDIT_FRAME& frame, int aParam )
{
MICROWAVE_TOOL_INFO info;
switch( aParam )
{ {
case MWAVE_TOOL_SIMPLE_ID::GAP: case MWAVE_TOOL_SIMPLE_ID::GAP:
info.name = _( "Add Gap" ); creator = [&frame] () {
info.toolId = ID_PCB_MUWAVE_TOOL_GAP_CMD;
info.creatorFunc = [&frame] () {
return std::unique_ptr<MODULE>( frame.Create_MuWaveComponent( 0 ) ); return std::unique_ptr<MODULE>( frame.Create_MuWaveComponent( 0 ) );
}; };
break; break;
case MWAVE_TOOL_SIMPLE_ID::STUB: case MWAVE_TOOL_SIMPLE_ID::STUB:
info.name = _( "Add Stub" ); creator = [&frame] () {
info.toolId = ID_PCB_MUWAVE_TOOL_STUB_CMD;
info.creatorFunc = [&frame] () {
return std::unique_ptr<MODULE>( frame.Create_MuWaveComponent( 1 ) ); return std::unique_ptr<MODULE>( frame.Create_MuWaveComponent( 1 ) );
}; };
break; break;
case MWAVE_TOOL_SIMPLE_ID::STUB_ARC: case MWAVE_TOOL_SIMPLE_ID::STUB_ARC:
info.name = _( "Add Stub (Arc)" ); creator = [&frame] () {
info.toolId = ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD;
info.creatorFunc = [&frame] () {
return std::unique_ptr<MODULE>( frame.Create_MuWaveComponent( 2 ) ); return std::unique_ptr<MODULE>( frame.Create_MuWaveComponent( 2 ) );
}; };
break; break;
case MWAVE_TOOL_SIMPLE_ID::FUNCTION_SHAPE: case MWAVE_TOOL_SIMPLE_ID::FUNCTION_SHAPE:
info.name = _( "Add Polynomial Shape" ); creator = [&frame] () {
info.toolId = ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD;
info.creatorFunc = [&frame] () {
return std::unique_ptr<MODULE>( frame.Create_MuWavePolygonShape() ); return std::unique_ptr<MODULE>( frame.Create_MuWavePolygonShape() );
}; };
break; break;
default: default:
// Avoid uninitilized value:
info.toolId = 0;
// info.name is already set to empty string
break; break;
}; };
return info;
}
int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent )
{
auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
const int param = aEvent.Parameter<intptr_t>();
MICROWAVE_TOOL_INFO info = getMicrowaveItemCreator( frame, param );
// failed to find suitable item info - shouldn't be possible
// if all the id's are handled
if( !info.name )
{
wxASSERT_MSG( 0, "Failed to find suitable microwave tool info" );
return 0;
}
frame.SetToolID( info.toolId, wxCURSOR_PENCIL, info.name );
struct MICROWAVE_PLACER : public INTERACTIVE_PLACER_BASE struct MICROWAVE_PLACER : public INTERACTIVE_PLACER_BASE
{ {
MICROWAVE_TOOL_INFO& m_info; const std::function<std::unique_ptr<MODULE>()>& m_creator;
MICROWAVE_PLACER( MICROWAVE_TOOL_INFO& aInfo ) : MICROWAVE_PLACER( const std::function<std::unique_ptr<MODULE>()>& aCreator ) :
m_info( aInfo ) {}; m_creator( aCreator ) {};
std::unique_ptr<BOARD_ITEM> CreateItem() override std::unique_ptr<BOARD_ITEM> CreateItem() override
{ {
auto module = m_info.creatorFunc(); auto module = m_creator();
// Module has been added in the legacy backend, // Module has been added in the legacy backend,
// so we have to remove it before committing the change // so we have to remove it before committing the change
@ -156,13 +115,13 @@ int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent )
} }
}; };
MICROWAVE_PLACER placer ( info ); MICROWAVE_PLACER placer( creator );
frame.SetTool( aEvent.GetCommandStr().get() );
doInteractiveItemPlacement( &placer, _( "Place microwave feature" ), doInteractiveItemPlacement( &placer, _( "Place microwave feature" ),
IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP | IPO_PROPERTIES ); IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP | IPO_PROPERTIES );
frame.SetNoToolSelected();
return 0; return 0;
} }
@ -196,9 +155,7 @@ void MICROWAVE_TOOL::createInductorBetween( const VECTOR2I& aStart, const VECTOR
if ( !inductorModule || !errorMessage.IsEmpty() ) if ( !inductorModule || !errorMessage.IsEmpty() )
{ {
if ( !errorMessage.IsEmpty() ) if ( !errorMessage.IsEmpty() )
{
DisplayError( &frame, errorMessage ); DisplayError( &frame, errorMessage );
}
} }
else else
{ {
@ -229,8 +186,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
KIGFX::VIEW_CONTROLS& controls = *getViewControls(); KIGFX::VIEW_CONTROLS& controls = *getViewControls();
auto& frame = *getEditFrame<PCB_EDIT_FRAME>(); auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
frame.SetToolID( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxCURSOR_PENCIL, _( "Add Microwave Inductor" ) ); frame.SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
TWO_POINT_GEOMETRY_MANAGER tpGeomMgr; TWO_POINT_GEOMETRY_MANAGER tpGeomMgr;
@ -256,21 +212,25 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{ {
// overriding action, or we're cancelling without if( originSet )
// an in-progress preview area
if ( evt->IsActivate() || !originSet )
{ {
// had an in-progress area, so start again but don't
// cancel the tool
originSet = false;
controls.CaptureCursor( false );
controls.SetAutoPan( false );
view.SetVisible( &previewRect, false );
view.Update( &previewRect, KIGFX::GEOMETRY );
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
frame.ClearToolStack();
break; break;
} }
// had an in-progress area, so start again but don't if( evt->IsActivate() )
// cancel the tool break;
originSet = false;
controls.CaptureCursor( false );
controls.SetAutoPan( false );
view.SetVisible( &previewRect, false );
view.Update( &previewRect, KIGFX::GEOMETRY );
} }
// A click or drag starts // A click or drag starts
@ -287,8 +247,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
// another click after origin set is the end // another click after origin set is the end
// left up is also the end, as you'll only get that after a drag // left up is also the end, as you'll only get that after a drag
else if( originSet && else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
{ {
// second click, we're done: // second click, we're done:
// delegate to the point-to-point inductor creator function // delegate to the point-to-point inductor creator function
@ -305,8 +264,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
// any move or drag once the origin was set updates // any move or drag once the origin was set updates
// the end point // the end point
else if( originSet && else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
{ {
tpGeomMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) ); tpGeomMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
tpGeomMgr.SetEnd( cursorPos ); tpGeomMgr.SetEnd( cursorPos );
@ -325,8 +283,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
controls.SetAutoPan( false ); controls.SetAutoPan( false );
view.Remove( &previewRect ); view.Remove( &previewRect );
frame.SetNoToolSelected();
return 0; return 0;
} }

View File

@ -149,9 +149,9 @@ bool PAD_TOOL::haveFootprints()
bool PAD_TOOL::Init() bool PAD_TOOL::Init()
{ {
auto contextMenu = std::make_shared<PAD_CONTEXT_MENU>( EditingModules(), auto ctxMenu = std::make_shared<PAD_CONTEXT_MENU>( EditingModules(),
[this]() { return m_padCopied; } ); [this]() { return m_padCopied; } );
contextMenu->SetTool( this ); ctxMenu->SetTool( this );
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>(); SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
@ -160,21 +160,18 @@ bool PAD_TOOL::Init()
auto& toolMenu = selTool->GetToolMenu(); auto& toolMenu = selTool->GetToolMenu();
auto& menu = toolMenu.GetMenu(); auto& menu = toolMenu.GetMenu();
toolMenu.AddSubMenu( contextMenu ); toolMenu.AddSubMenu( ctxMenu );
auto canShowMenuCond = [this, contextMenu] ( const SELECTION& aSel ) { auto canShowMenuCond = [this, ctxMenu] ( const SELECTION& aSel ) {
contextMenu->UpdateAll(); ctxMenu->UpdateAll();
return frame()->GetToolId() == ID_NO_TOOL_SELECTED return frame()->ToolStackIsEmpty() && haveFootprints() && ctxMenu->HasEnabledItems();
&& haveFootprints()
&& contextMenu->HasEnabledItems();
}; };
// show menu when there is a footprint, and the menu has any items // show menu when there is a footprint, and the menu has any items
auto showCond = canShowMenuCond && auto showCond = canShowMenuCond &&
( SELECTION_CONDITIONS::HasType( PCB_PAD_T ) ( SELECTION_CONDITIONS::HasType( PCB_PAD_T ) || SELECTION_CONDITIONS::Count( 0 ) );
|| SELECTION_CONDITIONS::Count( 0 ) );
menu.AddMenu( contextMenu.get(), showCond, 1000 ); menu.AddMenu( ctxMenu.get(), showCond, 1000 );
// we need a separator only when the selection is empty // we need a separator only when the selection is empty
auto separatorCond = canShowMenuCond && SELECTION_CONDITIONS::Count( 0 ); auto separatorCond = canShowMenuCond && SELECTION_CONDITIONS::Count( 0 );
@ -331,6 +328,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
if( settingsDlg.ShowModal() != wxID_OK ) if( settingsDlg.ShowModal() != wxID_OK )
return 0; return 0;
frame()->PushTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
GENERAL_COLLECTOR collector; GENERAL_COLLECTOR collector;
@ -347,9 +345,6 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
wxString padPrefix = settingsDlg.GetPrefix(); wxString padPrefix = settingsDlg.GetPrefix();
std::deque<int> storedPadNumbers; std::deque<int> storedPadNumbers;
frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_HAND,
_( "Click on successive pads to renumber them" ) );
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
getViewControls()->ShowCursor( true ); getViewControls()->ShowCursor( true );
@ -435,9 +430,11 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
else else
newval = seqPadNum; newval = seqPadNum;
statusPopup.SetText( wxString::Format( statusPopup.SetText( wxString::Format( _( "Click on pad %s%d\n"
_( "Click on pad %s%d\nPress Escape to cancel or double-click to commit" ), "Press Escape to cancel or "
padPrefix.c_str(), newval ) ); "double-click to commit" ),
padPrefix.c_str(),
newval ) );
} }
// ..or restore the old name if it was enumerated and clicked again // ..or restore the old name if it was enumerated and clicked again
@ -452,9 +449,11 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
pad->SetName( it->second.second ); pad->SetName( it->second.second );
oldNames.erase( it ); oldNames.erase( it );
statusPopup.SetText( wxString::Format( statusPopup.SetText( wxString::Format( _( "Click on pad %s%d\n"
_( "Click on pad %s%d\nPress Escape to cancel or double-click to commit" ), "Press Escape to cancel or "
padPrefix.c_str(), storedPadNumbers.front() ) ); "double-click to commit" ),
padPrefix.c_str(),
storedPadNumbers.front() ) );
} }
pad->ClearSelected(); pad->ClearSelected();
@ -470,8 +469,8 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
break; break;
} }
// This is a cancel-current-action (ie: <esc>). // This is a cancel-current-action (ie: <esc>).
// Note that this must go before IsCancelInteractive() as it also checks IsCancel(). // Note that this must go before IsCancelInteractive() as it also checks IsCancel().
else if( evt->IsCancel() ) else if( evt->IsCancel() )
{ {
// Clear current selection list to avoid selection of deleted items // Clear current selection list to avoid selection of deleted items
@ -481,7 +480,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
break; break;
} }
// Now that cancel-current-action has been handled, check for cancel-tool. // Now that cancel-current-action has been handled, check for cancel-tool.
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{ {
commit.Push( _( "Renumber pads" ) ); commit.Push( _( "Renumber pads" ) );
@ -506,9 +505,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
} }
statusPopup.Hide(); statusPopup.Hide();
frame()->SetNoToolSelected(); frame()->PopTool();
frame()->GetCanvas()->SetCursor( wxCURSOR_ARROW );
return 0; return 0;
} }

View File

@ -29,7 +29,7 @@
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <router/pns_router.h>
OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId ) OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
{ {
@ -37,24 +37,6 @@ OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
{ {
case ID_GEN_IMPORT_GRAPHICS_FILE: case ID_GEN_IMPORT_GRAPHICS_FILE:
return PCB_ACTIONS::placeImportedGraphics.MakeEvent(); return PCB_ACTIONS::placeImportedGraphics.MakeEvent();
case ID_NO_TOOL_SELECTED:
return PCB_ACTIONS::selectionTool.MakeEvent();
case ID_PCB_MUWAVE_TOOL_GAP_CMD:
return PCB_ACTIONS::microwaveCreateGap.MakeEvent();
case ID_PCB_MUWAVE_TOOL_STUB_CMD:
return PCB_ACTIONS::microwaveCreateStub.MakeEvent();
case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD:
return PCB_ACTIONS::microwaveCreateStubArc.MakeEvent();
case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD:
return PCB_ACTIONS::microwaveCreateFunctionShape.MakeEvent();
case ID_PCB_MUWAVE_TOOL_SELF_CMD:
return PCB_ACTIONS::microwaveCreateLine.MakeEvent();
} }
return OPT<TOOL_EVENT>(); return OPT<TOOL_EVENT>();
@ -81,7 +63,7 @@ TOOL_ACTION PCB_ACTIONS::drawPolygon( "pcbnew.InteractiveDrawing.graphicPolygon"
AS_GLOBAL, AS_GLOBAL,
MD_SHIFT + MD_CTRL + 'P', LEGACY_HK_NAME( "Draw Graphic Polygon" ), MD_SHIFT + MD_CTRL + 'P', LEGACY_HK_NAME( "Draw Graphic Polygon" ),
_( "Draw Graphic Polygon" ), _( "Draw a graphic polygon" ), _( "Draw Graphic Polygon" ), _( "Draw a graphic polygon" ),
add_graphical_polygon_xpm, AF_ACTIVATE ); add_graphical_polygon_xpm, AF_ACTIVATE, (void*) ZONE_MODE::GRAPHIC_POLYGON );
TOOL_ACTION PCB_ACTIONS::drawCircle( "pcbnew.InteractiveDrawing.circle", TOOL_ACTION PCB_ACTIONS::drawCircle( "pcbnew.InteractiveDrawing.circle",
AS_GLOBAL, AS_GLOBAL,
@ -116,7 +98,7 @@ TOOL_ACTION PCB_ACTIONS::drawZone( "pcbnew.InteractiveDrawing.zone",
#endif #endif
LEGACY_HK_NAME( "Add Filled Zone" ), LEGACY_HK_NAME( "Add Filled Zone" ),
_( "Add Filled Zone" ), _( "Add a filled zone" ), _( "Add Filled Zone" ), _( "Add a filled zone" ),
add_zone_xpm, AF_ACTIVATE ); add_zone_xpm, AF_ACTIVATE, (void*) ZONE_MODE::ADD );
TOOL_ACTION PCB_ACTIONS::drawVia( "pcbnew.InteractiveDrawing.via", TOOL_ACTION PCB_ACTIONS::drawVia( "pcbnew.InteractiveDrawing.via",
AS_GLOBAL, AS_GLOBAL,
@ -128,19 +110,19 @@ TOOL_ACTION PCB_ACTIONS::drawZoneKeepout( "pcbnew.InteractiveDrawing.keepout",
AS_GLOBAL, AS_GLOBAL,
MD_SHIFT + MD_CTRL + 'K', LEGACY_HK_NAME( "Add Keepout Area" ), MD_SHIFT + MD_CTRL + 'K', LEGACY_HK_NAME( "Add Keepout Area" ),
_( "Add Keepout Area" ), _( "Add a keepout area" ), _( "Add Keepout Area" ), _( "Add a keepout area" ),
add_keepout_area_xpm, AF_ACTIVATE ); add_keepout_area_xpm, AF_ACTIVATE, (void*) ZONE_MODE::ADD );
TOOL_ACTION PCB_ACTIONS::drawZoneCutout( "pcbnew.InteractiveDrawing.zoneCutout", TOOL_ACTION PCB_ACTIONS::drawZoneCutout( "pcbnew.InteractiveDrawing.zoneCutout",
AS_GLOBAL, AS_GLOBAL,
MD_SHIFT + 'C', LEGACY_HK_NAME( "Add a Zone Cutout" ), MD_SHIFT + 'C', LEGACY_HK_NAME( "Add a Zone Cutout" ),
_( "Add a Zone Cutout" ), _( "Add a cutout area of an existing zone" ), _( "Add a Zone Cutout" ), _( "Add a cutout area of an existing zone" ),
add_zone_cutout_xpm, AF_ACTIVATE ); add_zone_cutout_xpm, AF_ACTIVATE, (void*) ZONE_MODE::CUTOUT );
TOOL_ACTION PCB_ACTIONS::drawSimilarZone( "pcbnew.InteractiveDrawing.similarZone", TOOL_ACTION PCB_ACTIONS::drawSimilarZone( "pcbnew.InteractiveDrawing.similarZone",
AS_GLOBAL, AS_GLOBAL,
MD_SHIFT + MD_CTRL + '.', LEGACY_HK_NAME( "Add a Similar Zone" ), MD_SHIFT + MD_CTRL + '.', LEGACY_HK_NAME( "Add a Similar Zone" ),
_( "Add a Similar Zone" ), _( "Add a zone with the same settings as an existing zone" ), _( "Add a Similar Zone" ), _( "Add a zone with the same settings as an existing zone" ),
add_zone_xpm, AF_ACTIVATE ); add_zone_xpm, AF_ACTIVATE, (void*) ZONE_MODE::SIMILAR );
TOOL_ACTION PCB_ACTIONS::placeImportedGraphics( "pcbnew.InteractiveDrawing.placeImportedGraphics", TOOL_ACTION PCB_ACTIONS::placeImportedGraphics( "pcbnew.InteractiveDrawing.placeImportedGraphics",
AS_GLOBAL, AS_GLOBAL,
@ -924,11 +906,6 @@ TOOL_ACTION PCB_ACTIONS::layerChanged( "pcbnew.Control.layerChanged",
nullptr, AF_NOTIFY ); nullptr, AF_NOTIFY );
// Miscellaneous // Miscellaneous
TOOL_ACTION PCB_ACTIONS::selectionTool( "pcbnew.Control.selectionTool",
AS_GLOBAL, 0, "",
_( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::deleteTool( "pcbnew.Control.deleteTool", TOOL_ACTION PCB_ACTIONS::deleteTool( "pcbnew.Control.deleteTool",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Delete Items Tool" ), _( "Click on items to delete them" ), _( "Delete Items Tool" ), _( "Click on items to delete them" ),
@ -1127,17 +1104,17 @@ TOOL_ACTION PCB_ACTIONS::autoplaceOffboardComponents( "pcbnew.Autoplacer.autopla
// ROUTER_TOOL // ROUTER_TOOL
// //
TOOL_ACTION PCB_ACTIONS::routerActivateSingle( "pcbnew.InteractiveRouter.SingleTrack", TOOL_ACTION PCB_ACTIONS::routeSingleTrack( "pcbnew.InteractiveRouter.SingleTrack",
AS_GLOBAL, AS_GLOBAL,
'X', LEGACY_HK_NAME( "Add New Track" ), 'X', LEGACY_HK_NAME( "Add New Track" ),
_( "Interactive Router (Single Tracks)" ), _( "Run push & shove router (single tracks)" ), _( "Route Single Track" ), _( "Run push & shove router (single tracks)" ),
add_tracks_xpm, AF_ACTIVATE ); add_tracks_xpm, AF_ACTIVATE, (void*) PNS::PNS_MODE_ROUTE_SINGLE );
TOOL_ACTION PCB_ACTIONS::routerActivateDiffPair( "pcbnew.InteractiveRouter.DiffPair", TOOL_ACTION PCB_ACTIONS::routeDiffPair( "pcbnew.InteractiveRouter.DiffPair",
AS_GLOBAL, AS_GLOBAL,
'6', LEGACY_HK_NAME( "Route Differential Pair (Modern Toolset only)" ), '6', LEGACY_HK_NAME( "Route Differential Pair (Modern Toolset only)" ),
_( "Interactive Router (Differential Pairs)" ), _( "Run push & shove router (differential pairs)" ), _( "Route Differential Pair" ), _( "Run push & shove router (differential pairs)" ),
ps_diff_pair_xpm, AF_ACTIVATE ); ps_diff_pair_xpm, AF_ACTIVATE, (void*) PNS::PNS_MODE_ROUTE_DIFF_PAIR );
TOOL_ACTION PCB_ACTIONS::routerSettingsDialog( "pcbnew.InteractiveRouter.SettingsDialog", TOOL_ACTION PCB_ACTIONS::routerSettingsDialog( "pcbnew.InteractiveRouter.SettingsDialog",
AS_GLOBAL, AS_GLOBAL,
@ -1157,21 +1134,21 @@ TOOL_ACTION PCB_ACTIONS::selectLayerPair( "pcbnew.InteractiveRouter.SelectLayerP
TOOL_ACTION PCB_ACTIONS::routerTuneSingleTrace( "pcbnew.LengthTuner.TuneSingleTrack", TOOL_ACTION PCB_ACTIONS::routerTuneSingleTrace( "pcbnew.LengthTuner.TuneSingleTrack",
AS_GLOBAL, AS_GLOBAL,
'7', LEGACY_HK_NAME( "Tune Single Track (Modern Toolset only)" ), '7', LEGACY_HK_NAME( "Tune Single Track" ),
_( "Tune length of a single track" ), "", _( "Tune length of a single track" ), "",
ps_tune_length_xpm, AF_ACTIVATE ); ps_tune_length_xpm, AF_ACTIVATE, (void*) PNS::PNS_MODE_TUNE_SINGLE );
TOOL_ACTION PCB_ACTIONS::routerTuneDiffPair( "pcbnew.LengthTuner.TuneDiffPair", TOOL_ACTION PCB_ACTIONS::routerTuneDiffPair( "pcbnew.LengthTuner.TuneDiffPair",
AS_GLOBAL, AS_GLOBAL,
'8', LEGACY_HK_NAME( "Tune Differential Pair Length (Modern Toolset only)" ), '8', LEGACY_HK_NAME( "Tune Differential Pair Length" ),
_( "Tune length of a differential pair" ), "", _( "Tune length of a differential pair" ), "",
nullptr, AF_ACTIVATE ); nullptr, AF_ACTIVATE, (void*) PNS::PNS_MODE_TUNE_DIFF_PAIR );
TOOL_ACTION PCB_ACTIONS::routerTuneDiffPairSkew( "pcbnew.LengthTuner.TuneDiffPairSkew", TOOL_ACTION PCB_ACTIONS::routerTuneDiffPairSkew( "pcbnew.LengthTuner.TuneDiffPairSkew",
AS_GLOBAL, AS_GLOBAL,
'9', LEGACY_HK_NAME( "Tune Differential Pair Skew (Modern Toolset only)" ), '9', LEGACY_HK_NAME( "Tune Differential Pair Skew" ),
_( "Tune skew of a differential pair" ), "", _( "Tune skew of a differential pair" ), "",
nullptr, AF_ACTIVATE ); nullptr, AF_ACTIVATE, (void*) PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW );
TOOL_ACTION PCB_ACTIONS::routerInlineDrag( "pcbnew.InteractiveRouter.InlineDrag", TOOL_ACTION PCB_ACTIONS::routerInlineDrag( "pcbnew.InteractiveRouter.InlineDrag",
AS_CONTEXT, 0, "", AS_CONTEXT, 0, "",

View File

@ -43,6 +43,16 @@ enum MWAVE_TOOL_SIMPLE_ID
FUNCTION_SHAPE, FUNCTION_SHAPE,
}; };
enum class ZONE_MODE
{
ADD, ///< Add a new zone/keepout with fresh settings
CUTOUT, ///< Make a cutout to an existing zone
SIMILAR, ///< Add a new zone with the same settings as an existing one
GRAPHIC_POLYGON
};
/** /**
* Class PCB_ACTIONS * Class PCB_ACTIONS
* *
@ -170,10 +180,10 @@ public:
// Push and Shove Router Tool // Push and Shove Router Tool
/// Activation of the Push and Shove router /// Activation of the Push and Shove router
static TOOL_ACTION routerActivateSingle; static TOOL_ACTION routeSingleTrack;
/// Activation of the Push and Shove router (differential pair mode) /// Activation of the Push and Shove router (differential pair mode)
static TOOL_ACTION routerActivateDiffPair; static TOOL_ACTION routeDiffPair;
/// Activation of the Push and Shove router (tune single line mode) /// Activation of the Push and Shove router (tune single line mode)
static TOOL_ACTION routerTuneSingleTrace; static TOOL_ACTION routerTuneSingleTrace;

View File

@ -181,15 +181,15 @@ void PCB_EDITOR_CONTROL::Reset( RESET_REASON aReason )
bool PCB_EDITOR_CONTROL::Init() bool PCB_EDITOR_CONTROL::Init()
{ {
auto activeToolCondition = [ this ] ( const SELECTION& aSel ) { auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED ); return ( !m_frame->ToolStackIsEmpty() );
}; };
auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) { auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetToolId() == ID_NO_TOOL_SELECTED && aSel.Size() == 0 ); return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
}; };
auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) { auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
return ( m_frame->GetToolId() == ID_PCB_MODULE_BUTT && aSel.GetSize() == 0 ); return ( m_frame->IsCurrentTool( PCB_ACTIONS::placeModule ) && aSel.GetSize() == 0 );
}; };
auto& ctxMenu = m_menu.GetMenu(); auto& ctxMenu = m_menu.GetMenu();
@ -518,19 +518,20 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
controls->ShowCursor( true ); controls->ShowCursor( true );
controls->SetSnapping( true ); controls->SetSnapping( true );
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_PENCIL, _( "Add footprint" ) );
// Add all the drawable parts to preview
VECTOR2I cursorPos = controls->GetCursorPosition(); VECTOR2I cursorPos = controls->GetCursorPosition();
bool reselect = false;
// Prime the pump
if( module ) if( module )
{ {
module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module ); m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
} }
else if( aEvent.HasPosition() )
bool reselect = false; m_toolMgr->RunAction( PCB_ACTIONS::cursorClick );
// Main loop: keep receiving events // Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
@ -550,8 +551,14 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
commit.Revert(); commit.Revert();
module = NULL; module = NULL;
} }
else // let's have another chance placing a module else
break; {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->ClearToolStack();
break;
}
}
if( evt->IsActivate() ) // now finish unconditionally if( evt->IsActivate() ) // now finish unconditionally
break; break;
@ -618,7 +625,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
controls->CaptureCursor( !!module ); controls->CaptureCursor( !!module );
} }
m_frame->SetNoToolSelected(); m_frame->PopTool();
return 0; return 0;
} }
@ -709,8 +716,8 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
controls->SetSnapping( true ); controls->SetSnapping( true );
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
m_frame->SetToolID( ID_PCB_TARGET_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
// Main loop: keep receiving events // Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
@ -720,7 +727,12 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) ); cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
m_frame->ClearToolStack();
break; break;
}
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) ) else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
{ {
@ -771,9 +783,6 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
controls->SetSnapping( false ); controls->SetSnapping( false );
view->Remove( &preview ); view->Remove( &preview );
m_frame->SetNoToolSelected();
return 0; return 0;
} }
@ -956,7 +965,7 @@ int PCB_EDITOR_CONTROL::CrossProbeSchToPcb( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
// If it is a pad and the net highlighting tool is enabled, highlight the net // If it is a pad and the net highlighting tool is enabled, highlight the net
if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT ) if( item->Type() == PCB_PAD_T && m_frame->IsCurrentTool( PCB_ACTIONS::highlightNetTool ) )
{ {
int net = static_cast<D_PAD*>( item )->GetNetCode(); int net = static_cast<D_PAD*>( item )->GetNetCode();
m_toolMgr->RunAction( PCB_ACTIONS::highlightNet, false, net ); m_toolMgr->RunAction( PCB_ACTIONS::highlightNet, false, net );
@ -986,28 +995,25 @@ void PCB_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* a
} }
bool PCB_EDITOR_CONTROL::SetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
{
aFrame->SaveCopyInUndoList( originViewItem, UR_DRILLORIGIN );
DoSetDrillOrigin( aView, aFrame, originViewItem, aPosition );
return false; // drill origin is a one-shot; don't continue with tool
}
int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent ) int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
{ {
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
assert( picker ); assert( picker );
m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) ); picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool
picker->SetClickHandler( std::bind( SetDrillOrigin, getView(), m_frame, {
m_placeOrigin.get(), _1 ) ); m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UR_DRILLORIGIN );
DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
return false; // drill origin is a one-shot; don't continue with tool
} );
picker->Activate(); picker->Activate();
Wait(); Wait();
m_frame->ClearToolStack();
return 0; return 0;
} }
@ -1174,19 +1180,27 @@ int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
// there is no selection, then behave like a ctrl-left-click. // there is no selection, then behave like a ctrl-left-click.
if( aEvent.IsAction( &PCB_ACTIONS::highlightNetSelection ) ) if( aEvent.IsAction( &PCB_ACTIONS::highlightNetSelection ) )
{ {
bool use_selection = ( m_frame->GetToolId() != ID_PCB_HIGHLIGHT_BUTT ); bool use_selection = m_frame->IsCurrentTool( PCB_ACTIONS::highlightNetTool );
highlightNet( getViewControls()->GetMousePosition(), use_selection ); highlightNet( getViewControls()->GetMousePosition(), use_selection );
} }
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
assert( picker );
m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) ); picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool
picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool { {
return highlightNet( pt, false ); highlightNet( pt, false );
} ); return true;
} );
picker->SetFinalizeHandler( [&]( const int& aFinalState )
{
if( aFinalState == PCBNEW_PICKER_TOOL::EVT_CANCEL )
m_frame->ClearToolStack();
} );
picker->SetLayerSet( LSET::AllCuMask() ); picker->SetLayerSet( LSET::AllCuMask() );
picker->Activate(); picker->Activate();
Wait(); Wait();
@ -1231,9 +1245,7 @@ static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, bool aShow
bool enable = !( *( mod->Pads().begin() ) )->GetLocalRatsnestVisible(); bool enable = !( *( mod->Pads().begin() ) )->GetLocalRatsnestVisible();
for( auto modpad : mod->Pads() ) for( auto modpad : mod->Pads() )
{
modpad->SetLocalRatsnestVisible( enable ); modpad->SetLocalRatsnestVisible( enable );
}
} }
} }
} }
@ -1246,6 +1258,7 @@ static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, bool aShow
int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent ) int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
{ {
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
auto picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>(); auto picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
@ -1254,17 +1267,22 @@ int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
wxASSERT( picker ); wxASSERT( picker );
wxASSERT( board ); wxASSERT( board );
m_frame->SetToolID( ID_LOCAL_RATSNEST_BUTT, wxCURSOR_PENCIL, picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, board,
_( "Pick Components for Local Ratsnest" ) ); opt->m_ShowGlobalRatsnest, _1 ) );
picker->SetClickHandler( std::bind(
showLocalRatsnest, m_toolMgr, board, opt->m_ShowGlobalRatsnest, _1 ) ); picker->SetFinalizeHandler( [ this, board, opt ]( int aCondition )
picker->SetFinalizeHandler( [ board, opt ]( int aCondition ){
if( aCondition != PCBNEW_PICKER_TOOL::END_ACTIVATE )
{ {
for( auto mod : board->Modules() ) if( aCondition != PCBNEW_PICKER_TOOL::END_ACTIVATE )
for( auto pad : mod->Pads() ) {
pad->SetLocalRatsnestVisible( opt->m_ShowGlobalRatsnest ); for( auto mod : board->Modules() )
} {
for( auto pad : mod->Pads() )
pad->SetLocalRatsnestVisible( opt->m_ShowGlobalRatsnest );
}
}
if( aCondition == PCBNEW_PICKER_TOOL::EVT_CANCEL )
m_frame->ClearToolStack();
} ); } );
picker->Activate(); picker->Activate();

View File

@ -114,10 +114,6 @@ public:
///> Runs the drill origin tool for setting the origin for drill and pick-and-place files. ///> Runs the drill origin tool for setting the origin for drill and pick-and-place files.
int DrillOrigin( const TOOL_EVENT& aEvent ); int DrillOrigin( const TOOL_EVENT& aEvent );
///> UI-level access (including undo) to setting the drill origin
static bool SetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
BOARD_ITEM* aItem, const VECTOR2D& aPoint );
///> Low-level access (below undo) to setting the drill origin ///> Low-level access (below undo) to setting the drill origin
static void DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame, static void DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
BOARD_ITEM* aItem, const VECTOR2D& aPoint ); BOARD_ITEM* aItem, const VECTOR2D& aPoint );

View File

@ -86,7 +86,10 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer
preview.Clear(); preview.Clear();
if( aOptions & IPO_SINGLE_CLICK ) if( aOptions & IPO_SINGLE_CLICK )
{
frame()->ClearToolStack();
break; break;
}
controls()->SetAutoPan( false ); controls()->SetAutoPan( false );
controls()->CaptureCursor( false ); controls()->CaptureCursor( false );
@ -94,6 +97,9 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
frame()->ClearToolStack();
break; break;
} }

View File

@ -443,15 +443,6 @@ void PCBNEW_CONTROL::DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame
} }
bool PCBNEW_CONTROL::SetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
BOARD_ITEM* originViewItem, const VECTOR2D& aPoint )
{
aFrame->SaveCopyInUndoList( originViewItem, UR_GRIDORIGIN );
DoSetGridOrigin( aView, aFrame, originViewItem, aPoint );
return false; // Set grid origin is a one-shot; don't keep tool active
}
int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
{ {
VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>(); VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
@ -465,16 +456,22 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
} }
else else
{ {
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
wxCHECK( picker, 0 );
// TODO it will not check the toolbar button in module editor, as it uses a different ID.. picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool
m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) ); {
picker->SetClickHandler( std::bind( SetGridOrigin, getView(), m_frame, m_gridOrigin.get(), _1 ) ); m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UR_GRIDORIGIN );
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
return false; // drill origin is a one-shot; don't continue with tool
} );
picker->Activate(); picker->Activate();
Wait(); Wait();
m_frame->ClearToolStack();
} }
return 0; return 0;
@ -483,8 +480,8 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent )
{ {
SetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) ); m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UR_GRIDORIGIN );
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
return 0; return 0;
} }
@ -512,14 +509,20 @@ static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{ {
m_frame->SetTool( aEvent.GetCommandStr().get() );
Activate(); Activate();
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
wxCHECK( picker, 0 ); wxCHECK( picker, 0 );
m_frame->SetToolID( m_editModules ? ID_MODEDIT_DELETE_TOOL : ID_PCB_DELETE_ITEM_BUTT,
wxCURSOR_BULLSEYE, _( "Delete item" ) );
picker->SetClickHandler( std::bind( deleteItem, m_toolMgr, _1 ) ); picker->SetClickHandler( std::bind( deleteItem, m_toolMgr, _1 ) );
picker->SetFinalizeHandler( [&]( const int& aFinalState )
{
if( aFinalState == PCBNEW_PICKER_TOOL::EVT_CANCEL )
m_frame->ClearToolStack();
} );
picker->Activate(); picker->Activate();
Wait(); Wait();

View File

@ -78,10 +78,6 @@ public:
int GridSetOrigin( const TOOL_EVENT& aEvent ); int GridSetOrigin( const TOOL_EVENT& aEvent );
int GridResetOrigin( const TOOL_EVENT& aEvent ); int GridResetOrigin( const TOOL_EVENT& aEvent );
// UI-level access (including undo) to setting the grid origin
static bool SetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
BOARD_ITEM* originViewItem, const VECTOR2D& aPoint );
// Low-level access (below undo) to setting the grid origin // Low-level access (below undo) to setting the grid origin
static void DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame, static void DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
BOARD_ITEM* originViewItem, const VECTOR2D& aPoint ); BOARD_ITEM* originViewItem, const VECTOR2D& aPoint );

View File

@ -130,8 +130,6 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
reset(); reset();
controls->ForceCursorPosition( false ); controls->ForceCursorPosition( false );
getEditFrame<PCB_BASE_FRAME>()->SetNoToolSelected();
return 0; return 0;
} }

View File

@ -185,6 +185,15 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
} }
int SELECTION_TOOL::SelectionTool( const TOOL_EVENT& aEvent )
{
// Since the selection tool is always running underneath the toolStack, all we need to
// do is clear the stack.
m_frame->ClearToolStack();
return 0;
}
int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{ {
// Main loop: keep receiving events // Main loop: keep receiving events
@ -2195,6 +2204,7 @@ void SELECTION_TOOL::setTransitions()
Go( &SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() ); Go( &SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() );
Go( &SELECTION_TOOL::Main, PCB_ACTIONS::selectionActivate.MakeEvent() ); Go( &SELECTION_TOOL::Main, PCB_ACTIONS::selectionActivate.MakeEvent() );
Go( &SELECTION_TOOL::SelectionTool, ACTIONS::selectionTool.MakeEvent() );
Go( &SELECTION_TOOL::CursorSelection, PCB_ACTIONS::selectionCursor.MakeEvent() ); Go( &SELECTION_TOOL::CursorSelection, PCB_ACTIONS::selectionCursor.MakeEvent() );
Go( &SELECTION_TOOL::ClearSelection, PCB_ACTIONS::selectionClear.MakeEvent() ); Go( &SELECTION_TOOL::ClearSelection, PCB_ACTIONS::selectionClear.MakeEvent() );

View File

@ -79,6 +79,8 @@ public:
*/ */
int Main( const TOOL_EVENT& aEvent ); int Main( const TOOL_EVENT& aEvent );
int SelectionTool( const TOOL_EVENT& aEvent );
/** /**
* Function GetSelection() * Function GetSelection()
* *

View File

@ -66,7 +66,7 @@ std::unique_ptr<ZONE_CONTAINER> ZONE_CREATE_HELPER::createNewZone( bool aKeepout
zoneInfo.m_NetcodeSelection = board.GetHighLightNetCode(); zoneInfo.m_NetcodeSelection = board.GetHighLightNetCode();
zoneInfo.SetIsKeepout( m_params.m_keepout ); zoneInfo.SetIsKeepout( m_params.m_keepout );
if( m_params.m_mode != DRAWING_TOOL::ZONE_MODE::GRAPHIC_POLYGON ) if( m_params.m_mode != ZONE_MODE::GRAPHIC_POLYGON )
{ {
// Get the current default settings for zones // Get the current default settings for zones
@ -165,13 +165,13 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
switch ( m_params.m_mode ) switch ( m_params.m_mode )
{ {
case DRAWING_TOOL::ZONE_MODE::CUTOUT: case ZONE_MODE::CUTOUT:
// For cutouts, subtract from the source // For cutouts, subtract from the source
performZoneCutout( *m_params.m_sourceZone, *aZone ); performZoneCutout( *m_params.m_sourceZone, *aZone );
break; break;
case DRAWING_TOOL::ZONE_MODE::ADD: case ZONE_MODE::ADD:
case DRAWING_TOOL::ZONE_MODE::SIMILAR: case ZONE_MODE::SIMILAR:
{ {
BOARD_COMMIT bCommit( &m_tool ); BOARD_COMMIT bCommit( &m_tool );
@ -188,7 +188,7 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
break; break;
} }
case DRAWING_TOOL::ZONE_MODE::GRAPHIC_POLYGON: case ZONE_MODE::GRAPHIC_POLYGON:
{ {
BOARD_COMMIT bCommit( &m_tool ); BOARD_COMMIT bCommit( &m_tool );
BOARD_ITEM_CONTAINER* parent = frame.GetModel(); BOARD_ITEM_CONTAINER* parent = frame.GetModel();

View File

@ -56,7 +56,7 @@ public:
PCB_LAYER_ID m_layer; PCB_LAYER_ID m_layer;
///> The zone mode to operate in ///> The zone mode to operate in
DRAWING_TOOL::ZONE_MODE m_mode; ZONE_MODE m_mode;
///> Zone settings source (for similar and cutout zones) ///> Zone settings source (for similar and cutout zones)
ZONE_CONTAINER* m_sourceZone; ZONE_CONTAINER* m_sourceZone;