From ed1924b975e8279c4e5def5fe24d27154b09a01d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 20 Nov 2023 13:23:16 +0100 Subject: [PATCH] Pcbnew, place menu: some enhancements: - move place dimensions to a sub menu (they are not frequently used, and it reduce the size of the place menu - add reset drill origin, similar to reset grid origin. --- pcbnew/menubar_pcb_editor.cpp | 17 ++++++++++------- pcbnew/tools/board_editor_control.cpp | 8 ++++++++ pcbnew/tools/pcb_actions.cpp | 6 ++++++ pcbnew/tools/pcb_actions.h | 1 + 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 3afc918069..8840e5fce5 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -313,11 +313,15 @@ void PCB_EDIT_FRAME::doReCreateMenuBar() placeMenu->Add( PCB_ACTIONS::drawTextBox ); placeMenu->AppendSeparator(); - placeMenu->Add( PCB_ACTIONS::drawAlignedDimension ); - placeMenu->Add( PCB_ACTIONS::drawOrthogonalDimension ); - placeMenu->Add( PCB_ACTIONS::drawCenterDimension ); - placeMenu->Add( PCB_ACTIONS::drawRadialDimension ); - placeMenu->Add( PCB_ACTIONS::drawLeader ); + ACTION_MENU* dimensionSubmenu = new ACTION_MENU( false, selTool ); + dimensionSubmenu->SetTitle( _( "Add Dimension" ) ); + dimensionSubmenu->SetIcon( BITMAPS::add_aligned_dimension ); + dimensionSubmenu->Add( PCB_ACTIONS::drawAlignedDimension ); + dimensionSubmenu->Add( PCB_ACTIONS::drawOrthogonalDimension ); + dimensionSubmenu->Add( PCB_ACTIONS::drawCenterDimension ); + dimensionSubmenu->Add( PCB_ACTIONS::drawRadialDimension ); + dimensionSubmenu->Add( PCB_ACTIONS::drawLeader ); + placeMenu->Add( dimensionSubmenu ); placeMenu->AppendSeparator(); placeMenu->Add( PCB_ACTIONS::placeCharacteristics ); @@ -325,12 +329,11 @@ void PCB_EDIT_FRAME::doReCreateMenuBar() placeMenu->AppendSeparator(); placeMenu->Add( PCB_ACTIONS::drillOrigin ); + placeMenu->Add( PCB_ACTIONS::drillResetOrigin ); placeMenu->Add( ACTIONS::gridSetOrigin ); - placeMenu->AppendSeparator(); placeMenu->Add( ACTIONS::gridResetOrigin ); placeMenu->AppendSeparator(); - ACTION_MENU* autoplaceSubmenu = new ACTION_MENU( false, selTool ); autoplaceSubmenu->SetTitle( _( "Auto-Place Footprints" ) ); autoplaceSubmenu->SetIcon( BITMAPS::mode_module ); diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index f14a12ea45..8dfaf09f4c 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -1598,6 +1598,13 @@ void BOARD_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent ) { + if( aEvent.IsAction( &PCB_ACTIONS::drillResetOrigin ) ) + { + m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN ); + DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), VECTOR2D( 0, 0 ) ); + return 0; + } + PCB_PICKER_TOOL* picker = m_toolMgr->GetTool(); // Deactivate other tools; particularly important if another PICKER is currently running @@ -1662,6 +1669,7 @@ void BOARD_EDITOR_CONTROL::setTransitions() // Placing tools Go( &BOARD_EDITOR_CONTROL::PlaceFootprint, PCB_ACTIONS::placeFootprint.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::DrillOrigin, PCB_ACTIONS::drillOrigin.MakeEvent() ); + Go( &BOARD_EDITOR_CONTROL::DrillOrigin, PCB_ACTIONS::drillResetOrigin.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::EditFpInFpEditor, PCB_ACTIONS::editFpInFpEditor.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::EditFpInFpEditor, PCB_ACTIONS::editLibFpInFpEditor.MakeEvent() ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index d3147c1d37..a16417c609 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -1147,6 +1147,12 @@ TOOL_ACTION PCB_ACTIONS::drillOrigin( TOOL_ACTION_ARGS() .Icon( BITMAPS::set_origin ) .Flags( AF_ACTIVATE ) ); +TOOL_ACTION PCB_ACTIONS::drillResetOrigin( TOOL_ACTION_ARGS() + .Name( "pcbnew.EditorControl.drillResetOrigin" ) + .Scope( AS_GLOBAL ) + .LegacyHotkeyName( "Reset Drill Origin" ) + .FriendlyName( _( "Reset Drill Origin" ) ) ); + TOOL_ACTION PCB_ACTIONS::toggleLock( TOOL_ACTION_ARGS() .Name( "pcbnew.EditorControl.toggleLock" ) .Scope( AS_GLOBAL ) diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index df30b31aa5..3ed41770fd 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -528,6 +528,7 @@ public: static TOOL_ACTION pickerTool; static TOOL_ACTION measureTool; static TOOL_ACTION drillOrigin; + static TOOL_ACTION drillResetOrigin; static TOOL_ACTION placeFileOrigin; static TOOL_ACTION appendBoard; static TOOL_ACTION showEeschema;