From 3912c7407f150a99139b08df7e1d7fe71c754a7d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 3 Jun 2019 21:06:58 +0100 Subject: [PATCH] Move global commands to ACTIONs. Also fixes a crash bug opening Edit Tracks and Vias dialog. --- gerbview/events_called_functions.cpp | 3 - include/id.h | 8 - include/pcb_base_frame.h | 5 - pcbnew/CMakeLists.txt | 1 + pcbnew/dialogs/dialog_global_deletion.cpp | 9 +- .../dialog_global_edit_text_and_graphics.cpp | 8 +- .../dialog_global_edit_tracks_and_vias.cpp | 9 +- pcbnew/dialogs/dialog_swap_layers.cpp | 99 +------- pcbnew/dialogs/dialog_swap_layers.h | 54 ++++ pcbnew/edit.cpp | 19 -- pcbnew/files.cpp | 3 - pcbnew/footprint_edit_frame.cpp | 19 -- pcbnew/footprint_edit_frame.h | 5 - pcbnew/footprint_editor_utils.cpp | 4 - pcbnew/footprint_tree_pane.cpp | 2 +- pcbnew/menubar_footprint_editor.cpp | 13 +- pcbnew/menubar_pcb_editor.cpp | 103 +++----- pcbnew/pcb_edit_frame.cpp | 31 +-- pcbnew/pcb_edit_frame.h | 13 - pcbnew/pcbnew_id.h | 19 -- pcbnew/router/length_tuner_tool.cpp | 6 +- pcbnew/router/router_tool.cpp | 45 ++-- pcbnew/router/router_tool.h | 1 + pcbnew/sel_layer.cpp | 14 +- pcbnew/toolbars_pcb_editor.cpp | 71 ++---- pcbnew/tools/edit_tool.cpp | 70 ----- pcbnew/tools/edit_tool.h | 8 - pcbnew/tools/footprint_editor_tools.cpp | 14 +- pcbnew/tools/footprint_editor_tools.h | 3 +- pcbnew/tools/global_edit_tool.cpp | 239 ++++++++++++++++++ pcbnew/tools/global_edit_tool.h | 75 ++++++ pcbnew/tools/pcb_actions.cpp | 30 --- pcbnew/tools/pcb_actions.h | 34 ++- pcbnew/tools/pcb_editor_control.cpp | 15 ++ pcbnew/tools/pcb_editor_control.h | 2 + pcbnew/tracks_cleaner.cpp | 36 +-- 36 files changed, 542 insertions(+), 548 deletions(-) create mode 100644 pcbnew/dialogs/dialog_swap_layers.h create mode 100644 pcbnew/tools/global_edit_tool.cpp create mode 100644 pcbnew/tools/global_edit_tool.h diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 16a365f2b5..49fb11362a 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -90,9 +90,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnSelectActiveDCode ) - EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, - GERBVIEW_FRAME::Process_Special_Functions ) - // Option toolbar EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, GERBVIEW_FRAME::OnToggleShowLayerManager ) diff --git a/include/id.h b/include/id.h index c71e00ab5e..86f77431ef 100644 --- a/include/id.h +++ b/include/id.h @@ -82,7 +82,6 @@ enum main_id ID_SAVE_PROJECT, ID_SAVE_PROJECT_AS, ID_LOAD_FILE, - ID_APPEND_FILE, ID_NEW_BOARD, ID_SAVE_BOARD, ID_SAVE_BOARD_AS, @@ -164,11 +163,6 @@ enum main_id // Popup Menu (mouse Right button) (id consecutifs) - ID_POPUP_GENERAL_START_RANGE, // first number - ID_POPUP_CANCEL_CURRENT_COMMAND, - ID_POPUP_CLOSE_CURRENT_TOOL, - ID_POPUP_GENERAL_END_RANGE, // last number - ID_ON_ZOOM_SELECT, ID_POPUP_ZOOM_START_RANGE, // first zoom id ID_POPUP_CANCEL, @@ -195,8 +189,6 @@ enum main_id ID_POPUP_ZOOM_END_RANGE, // last zoom id ID_ON_GRID_SELECT, - ID_POPUP_GRID_NEXT, - ID_POPUP_GRID_PREV, ID_POPUP_GRID_SELECT, ID_POPUP_GRID_FIRST, ID_POPUP_GRID_LEVEL_1000 = ID_POPUP_GRID_FIRST, // These must be in same order as menu diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index 2de39cea0f..793ad64f96 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -385,11 +385,6 @@ public: LSET aNotAllowedLayersMask = LSET(), wxPoint aDlgPosition = wxDefaultPosition ); - /* Display a list of two copper layers to choose a pair of copper layers - * the layer pair is used to fast switch between copper layers when placing vias - */ - void SelectCopperLayerPair(); - virtual void SwitchLayer( wxDC* DC, PCB_LAYER_ID layer ); /** diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 5a2c178228..3bfa338a55 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -293,6 +293,7 @@ set( PCBNEW_CLASS_SRCS tools/drawing_tool.cpp tools/edit_tool.cpp + tools/global_edit_tool.cpp tools/grid_helper.cpp tools/microwave_tool.cpp tools/footprint_editor_tools.cpp diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index 099bfc5211..defaddacb6 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -36,6 +36,7 @@ using namespace std::placeholders; #include #include #include +#include #include @@ -57,12 +58,12 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent ) : } -void PCB_EDIT_FRAME::InstallPcbGlobalDeleteFrame( const wxPoint& pos ) +int GLOBAL_EDIT_TOOL::GlobalDeletions( const TOOL_EVENT& aEvent ) { - DIALOG_GLOBAL_DELETION dlg( this ); - dlg.SetCurrentLayer( GetActiveLayer() ); - + DIALOG_GLOBAL_DELETION dlg( frame() ); + dlg.SetCurrentLayer( frame()->GetActiveLayer() ); dlg.ShowModal(); + return 0; } diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index 1c1023c5c0..753b9202a7 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -32,7 +32,7 @@ #include #include #include - +#include #include @@ -408,10 +408,12 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() } -void PCB_EDIT_FRAME::OnEditTextAndGraphics( wxCommandEvent& event ) +int GLOBAL_EDIT_TOOL::EditTextAndGraphics( const TOOL_EVENT& aEvent ) { - DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS dlg( this ); + DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS dlg( frame() ); dlg.ShowModal(); + + return 0; } diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index 9db981d937..4f8340ff4e 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "dialog_global_edit_tracks_and_vias_base.h" // Columns of netclasses grid @@ -219,7 +220,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid() bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow() { - SELECTION& selection = GetToolManager()->GetTool()->GetSelection(); + SELECTION& selection = m_parent->GetToolManager()->GetTool()->GetSelection(); auto item = dynamic_cast( selection.Front() ); m_tracks->SetValue( g_modifyTracks ); @@ -368,9 +369,11 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnSizeNetclassGrid( wxSizeEvent& event } -void PCB_EDIT_FRAME::OnEditTracksAndVias( wxCommandEvent& event ) +int GLOBAL_EDIT_TOOL::EditTracksAndVias( const TOOL_EVENT& aEvent ) { - DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this ); + DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( frame() ); dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR + + return 0; } diff --git a/pcbnew/dialogs/dialog_swap_layers.cpp b/pcbnew/dialogs/dialog_swap_layers.cpp index e904899724..31293de2e1 100644 --- a/pcbnew/dialogs/dialog_swap_layers.cpp +++ b/pcbnew/dialogs/dialog_swap_layers.cpp @@ -22,16 +22,14 @@ */ #include -#include #include -#include #include #include #include #include #include - -#include "dialog_swap_layers_base.h" +#include +#include "dialog_swap_layers.h" class LAYER_GRID_TABLE : public wxGridTableBase @@ -71,28 +69,6 @@ public: }; -class DIALOG_SWAP_LAYERS : public DIALOG_SWAP_LAYERS_BASE -{ -private: - PCB_EDIT_FRAME* m_parent; - PCB_LAYER_ID* m_layerDestinations; - - LAYER_GRID_TABLE* m_gridTable; - -public: - DIALOG_SWAP_LAYERS( PCB_EDIT_FRAME* aParent, PCB_LAYER_ID* aArray ); - ~DIALOG_SWAP_LAYERS() override; - -private: - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - void OnSize( wxSizeEvent& event ) override; - - void adjustGridColumns( int aWidth ); -}; - - DIALOG_SWAP_LAYERS::DIALOG_SWAP_LAYERS( PCB_EDIT_FRAME* aParent, PCB_LAYER_ID* aArray ) : DIALOG_SWAP_LAYERS_BASE( aParent ), m_parent( aParent ), @@ -185,74 +161,3 @@ void DIALOG_SWAP_LAYERS::OnSize( wxSizeEvent& event ) } -bool processBoardItem( PCB_EDIT_FRAME* aFrame, BOARD_COMMIT& commit, BOARD_ITEM* aItem, - PCB_LAYER_ID* new_layer ) -{ - if( new_layer[ aItem->GetLayer() ] != aItem->GetLayer() ) - { - commit.Modify( aItem ); - aItem->SetLayer( new_layer[ aItem->GetLayer() ] ); - aFrame->GetGalCanvas()->GetView()->Update( aItem, KIGFX::GEOMETRY ); - return true; - } - - return false; -} - - -void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event ) -{ - PCB_LAYER_ID new_layer[PCB_LAYER_ID_COUNT]; - - DIALOG_SWAP_LAYERS dlg( this, new_layer ); - - if( dlg.ShowModal() != wxID_OK ) - return; - - BOARD_COMMIT commit( this ); - bool hasChanges = false; - - // Change tracks. - for( auto segm : GetBoard()->Tracks() ) - { - if( segm->Type() == PCB_VIA_T ) - { - VIA* via = (VIA*) segm; - PCB_LAYER_ID top_layer, bottom_layer; - - if( via->GetViaType() == VIA_THROUGH ) - continue; - - via->LayerPair( &top_layer, &bottom_layer ); - - if( new_layer[bottom_layer] != bottom_layer || new_layer[top_layer] != top_layer ) - { - commit.Modify( via ); - via->SetLayerPair( new_layer[top_layer], new_layer[bottom_layer] ); - GetGalCanvas()->GetView()->Update( via, KIGFX::GEOMETRY ); - hasChanges = true; - } - } - else - { - hasChanges |= processBoardItem( this, commit, segm, new_layer ); - } - } - - for( BOARD_ITEM* zone : GetBoard()->Zones() ) - { - hasChanges |= processBoardItem( this, commit, zone, new_layer ); - } - - for( BOARD_ITEM* drawing : GetBoard()->Drawings() ) - { - hasChanges |= processBoardItem( this, commit, drawing, new_layer ); - } - - if( hasChanges ) - { - OnModify(); - commit.Push( "Layers moved" ); - GetGalCanvas()->Refresh(); - } -} diff --git a/pcbnew/dialogs/dialog_swap_layers.h b/pcbnew/dialogs/dialog_swap_layers.h new file mode 100644 index 0000000000..26175dc57b --- /dev/null +++ b/pcbnew/dialogs/dialog_swap_layers.h @@ -0,0 +1,54 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _DIALOG_SCRIPTING_H_ +#define _DIALOG_SCRIPTING_H_ + +#include "dialog_swap_layers_base.h" + +class PCB_EDIT_FRAME; +class LAYER_GRID_TABLE; + + +class DIALOG_SWAP_LAYERS : public DIALOG_SWAP_LAYERS_BASE +{ +private: + PCB_EDIT_FRAME* m_parent; + PCB_LAYER_ID* m_layerDestinations; + + LAYER_GRID_TABLE* m_gridTable; + +public: + DIALOG_SWAP_LAYERS( PCB_EDIT_FRAME* aParent, PCB_LAYER_ID* aArray ); + ~DIALOG_SWAP_LAYERS() override; + +private: + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + + void OnSize( wxSizeEvent& event ) override; + + void adjustGridColumns( int aWidth ); +}; + +#endif \ No newline at end of file diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 6d6aa9b492..852a75b7a6 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -66,10 +66,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) switch( id ) // Some (not all ) edit commands must be finished or aborted { - case wxID_CUT: - case wxID_COPY: case ID_TOOLBARH_PCB_SELECT_LAYER: - case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: break; default: // Finish (abort) the command @@ -139,18 +136,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) } break; - case ID_PCB_GLOBAL_DELETE: - InstallPcbGlobalDeleteFrame( wxDefaultPosition ); - break; - case ID_GET_NETLIST: InstallNetlistFrame(); break; - case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: - SelectCopperLayerPair(); - break; - case ID_TOOLBARH_PCB_SELECT_LAYER: SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); @@ -158,14 +147,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) GetGalCanvas()->Refresh(); break; - case ID_MENU_PCB_CLEAN: - Clean_Pcb(); - break; - - case ID_MENU_PCB_SWAP_LAYERS: - Swap_Layers( event ); - break; - case ID_MENU_ARCHIVE_MODULES_IN_LIBRARY: ArchiveModulesOnBoard( false ); break; diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index f95ee2e0d8..cdfc843bc4 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -273,9 +273,6 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id ) return false; } - case ID_APPEND_FILE: - wxFAIL_MSG( "OBSOLETE! Should have gone though modern toolset." ); - case ID_NEW_BOARD: { if( !Clear_Pcb( true ) ) diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 9db13d0ac8..d42dd697fd 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -87,7 +87,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_MODEDIT_SAVE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_SAVE_AS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) - EVT_TOOL( ID_MODEDIT_REVERT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_OPEN_MODULE_VIEWER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng ) @@ -115,12 +114,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( wxID_PREFERENCES, FOOTPRINT_EDIT_FRAME::ProcessPreferences ) // popup commands - EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, - FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) - - EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, - FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) - EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings ) // UI update events. @@ -130,9 +123,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard ) - EVT_UPDATE_UI_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, - FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar ) - EVT_UPDATE_UI( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected ) EVT_UPDATE_UI( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected ) @@ -517,15 +507,6 @@ void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event ) } -void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ) -{ - aEvent.Enable( GetBoard()->GetFirstModule() != NULL ); - - if( aEvent.GetEventObject() == m_drawToolBar ) - aEvent.Check( GetToolId() == aEvent.GetId() ); -} - - void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent ) { aEvent.Enable( GetBoard()->GetFirstModule() != NULL ); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 624b9292e1..c04ecec55b 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -145,11 +145,6 @@ public: ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; - /** - * Handle most of tools og the vertical right toolbar ("Tools" toolbar) - */ - void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ); - void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent ); void OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent ); void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent ); diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index a2a421c1e8..d28a5aa7fe 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -353,10 +353,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_treePane->GetLibTree()->Refresh(); break; - case ID_MODEDIT_REVERT_PART: - RevertFootprint(); - break; - case ID_MODEDIT_CUT_PART: case ID_MODEDIT_COPY_PART: if( getTargetFPID().IsValid() ) diff --git a/pcbnew/footprint_tree_pane.cpp b/pcbnew/footprint_tree_pane.cpp index 0f15251b14..714168df3c 100644 --- a/pcbnew/footprint_tree_pane.cpp +++ b/pcbnew/footprint_tree_pane.cpp @@ -68,7 +68,7 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent ) menuPart->Add( _( "Save" ), ID_MODEDIT_SAVE, save_xpm ); menuPart->Add( _( "Save a Copy As..." ), ID_MODEDIT_SAVE_AS, save_as_xpm ); menuPart->Add( _( "Delete" ), ID_MODEDIT_DELETE_PART, delete_xpm ); - menuPart->Add( _( "Revert" ), ID_MODEDIT_REVERT_PART, undo_xpm ); + menuPart->Add( ACTIONS::revert ); menuPart->AppendSeparator(); menuPart->Add( _( "Cut" ), ID_MODEDIT_CUT_PART, cut_xpm ); diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index b95e435bf4..f8b01bc80e 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -80,10 +80,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddSeparator(); fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition ); fileMenu->AddItem( ACTIONS::saveAs, libraryPartCondition ); - fileMenu->AddItem( ID_MODEDIT_REVERT_PART, - _( "Revert" ), - _( "Throw away changes" ), - undo_xpm, modifiedDocumentCondition ); + fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition ); fileMenu->AddSeparator(); @@ -276,12 +273,10 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() //-- Inspect menu ------------------------------------------------------- // - wxMenu* inspectMenu = new wxMenu; + CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); - AddMenuItem( inspectMenu, ID_MODEDIT_MEASUREMENT_TOOL, - AddHotkeyName( _( "&Measure" ), m_hotkeysDescrList, HK_MEASURE_TOOL ), - _( "Measure distance" ), - KiBitmap( measurement_xpm ) ); + inspectMenu->AddItem( ACTIONS::measureTool, SELECTION_CONDITIONS::ShowAlways ); + inspectMenu->Resolve(); //-- Tools menu ------------------------------------------------------- // diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 0909814e82..9999d250f4 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -178,13 +178,13 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() _( "Create bill of materials from current schematic" ), ID_PCB_GEN_BOM_FILE_FROM_BOARD, bom_xpm ); - fileMenu->AddMenu( submenuFabOutputs, SELECTION_CONDITIONS::ShowAlways ); + fileMenu->AddMenu( submenuFabOutputs, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); fileMenu->AddItem( ID_BOARD_SETUP_DIALOG, _( "&Board Setup..." ), _( "Edit board setup including layers, design rules and various defaults" ), - options_board_xpm, SELECTION_CONDITIONS::ShowAlways ); + options_board_xpm, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); fileMenu->AddItem( ACTIONS::pageSettings, SELECTION_CONDITIONS::ShowAlways ); @@ -230,46 +230,33 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() return GetToolId() == ID_NO_TOOL_SELECTED; }; - editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); - editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); + editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); + editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); editMenu->AddSeparator(); - editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::paste, noActiveToolCondition ); + editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty ); + editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty ); + editMenu->AddItem( ACTIONS::paste, noActiveToolCondition ); editMenu->AddSeparator(); - editMenu->AddItem( PCB_ACTIONS::deleteTool, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::deleteTool, SELECTION_CONDITIONS::ShowAlways ); editMenu->AddSeparator(); - editMenu->AddItem( ACTIONS::find, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( ACTIONS::find, SELECTION_CONDITIONS::ShowAlways ); editMenu->AddSeparator(); - editMenu->AddItem( ID_PCB_EDIT_TRACKS_AND_VIAS, - _( "Edit Track && Via Properties..." ), "", - width_track_via_xpm, SELECTION_CONDITIONS::ShowAlways ); - editMenu->AddItem( ID_MENU_PCB_EDIT_TEXT_AND_GRAPHICS, - _( "Edit Text && Graphic Properties..." ), "", - reset_text_xpm, SELECTION_CONDITIONS::ShowAlways ); - editMenu->AddItem( PCB_ACTIONS::changeFootprints, SELECTION_CONDITIONS::ShowAlways ); - editMenu->AddItem( ID_MENU_PCB_SWAP_LAYERS, - _( "Swap Layers..." ), - _( "Move tracks or drawings from a layer to another layer" ), - swap_layer_xpm, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::editTracksAndVias, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::editTextAndGraphics, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::changeFootprints, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::swapLayers, SELECTION_CONDITIONS::ShowAlways ); editMenu->AddSeparator(); - editMenu->AddItem( PCB_ACTIONS::zoneFillAll, SELECTION_CONDITIONS::ShowAlways ); - editMenu->AddItem( PCB_ACTIONS::zoneUnfillAll, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::zoneFillAll, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::zoneUnfillAll, SELECTION_CONDITIONS::ShowAlways ); editMenu->AddSeparator(); - editMenu->AddItem( ID_PCB_GLOBAL_DELETE, - _( "Global Deletions..." ), - _( "Delete tracks, footprints and graphic items from board" ), - general_deletions_xpm, SELECTION_CONDITIONS::ShowAlways ); - editMenu->AddItem( ID_MENU_PCB_CLEAN, - _( "Cleanup Tracks and Vias..." ), - _( "Clean stubs, vias, delete break points or unconnected tracks" ), - delete_xpm, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::globalDeletions, SELECTION_CONDITIONS::ShowAlways ); + editMenu->AddItem( PCB_ACTIONS::cleanupTracksAndVias, SELECTION_CONDITIONS::ShowAlways ); editMenu->Resolve(); @@ -395,9 +382,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaInc, SELECTION_CONDITIONS::ShowAlways ); viewMenu->AddMenu( contrastModeSubMenu ); - viewMenu->AddCheckItem( ID_MENU_PCB_FLIP_VIEW, - _( "Flip &Board View" ), _( "Flip (mirror) the board view" ), - flip_board_xpm, boardFlippedCondition ); + viewMenu->AddCheckItem( PCB_ACTIONS::flipBoard, boardFlippedCondition ); #ifdef __APPLE__ viewMenu->AppendSeparator(); @@ -447,57 +432,29 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() // CONDITIONAL_MENU* routeMenu = new CONDITIONAL_MENU( false, selTool ); - routeMenu->AddItem( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, - _( "Set &Layer Pair..." ), _( "Change active layer pair" ), - select_layer_pair_xpm, SELECTION_CONDITIONS::ShowAlways ); + routeMenu->AddItem( PCB_ACTIONS::selectLayerPair, SELECTION_CONDITIONS::ShowAlways ); routeMenu->AddSeparator(); - routeMenu->AddItem( ID_TRACK_BUTT, - AddHotkeyName( _( "&Single Track" ), g_Board_Editor_Hotkeys_Descr, - HK_ADD_NEW_TRACK, IS_ACCELERATOR ), - _( "Interactively route single track" ), - add_tracks_xpm, SELECTION_CONDITIONS::ShowAlways ); - - routeMenu->AddItem( ID_DIFF_PAIR_BUTT, - AddHotkeyName( _( "&Differential Pair" ), g_Board_Editor_Hotkeys_Descr, - HK_ROUTE_DIFF_PAIR, IS_ACCELERATOR ), - _( "Interactively route differential pair" ), - ps_diff_pair_xpm, SELECTION_CONDITIONS::ShowAlways ); + routeMenu->AddItem( PCB_ACTIONS::routerActivateSingle, SELECTION_CONDITIONS::ShowAlways ); + routeMenu->AddItem( PCB_ACTIONS::routerActivateDiffPair, SELECTION_CONDITIONS::ShowAlways ); routeMenu->AddSeparator(); - routeMenu->AddItem( ID_TUNE_SINGLE_TRACK_LEN_BUTT, - AddHotkeyName( _( "&Tune Track Length" ), g_Board_Editor_Hotkeys_Descr, - HK_ROUTE_TUNE_SINGLE, IS_ACCELERATOR ), - _( "Tune length of single track" ), - ps_tune_length_xpm, SELECTION_CONDITIONS::ShowAlways ); - - routeMenu->AddItem( ID_TUNE_DIFF_PAIR_LEN_BUTT, - AddHotkeyName( _( "Tune Differential Pair &Length" ), g_Board_Editor_Hotkeys_Descr, - HK_ROUTE_TUNE_DIFF_PAIR, IS_ACCELERATOR ), - _( "Tune length of differential pair" ), - ps_diff_pair_tune_length_xpm, SELECTION_CONDITIONS::ShowAlways ); - - routeMenu->AddItem( ID_TUNE_DIFF_PAIR_SKEW_BUTT, - AddHotkeyName( _( "Tune Differential Pair S&kew/Phase" ), g_Board_Editor_Hotkeys_Descr, - HK_ROUTE_TUNE_SKEW, IS_ACCELERATOR ), - _( "Tune skew/phase of a differential pair" ), - ps_diff_pair_tune_phase_xpm, SELECTION_CONDITIONS::ShowAlways ); + routeMenu->AddItem( PCB_ACTIONS::routerTuneSingleTrace, SELECTION_CONDITIONS::ShowAlways ); + routeMenu->AddItem( PCB_ACTIONS::routerTuneDiffPair, SELECTION_CONDITIONS::ShowAlways ); + routeMenu->AddItem( PCB_ACTIONS::routerTuneDiffPairSkew, SELECTION_CONDITIONS::ShowAlways ); routeMenu->AddSeparator(); - routeMenu->AddItem( ID_MENU_INTERACTIVE_ROUTER_SETTINGS, - _( "&Interactive Router Settings..." ), - _( "Configure interactive router" ), - tools_xpm, SELECTION_CONDITIONS::ShowAlways ); + routeMenu->AddItem( PCB_ACTIONS::routerSettingsDialog, SELECTION_CONDITIONS::ShowAlways ); //-- Inspect Menu -------------------------------------------------------- // CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); - inspectMenu->AddItem( PCB_ACTIONS::listNets, SELECTION_CONDITIONS::ShowAlways ); - inspectMenu->AddItem( ACTIONS::measureTool, SELECTION_CONDITIONS::ShowAlways ); + inspectMenu->AddItem( PCB_ACTIONS::listNets, SELECTION_CONDITIONS::ShowAlways ); + inspectMenu->AddItem( ACTIONS::measureTool, SELECTION_CONDITIONS::ShowAlways ); inspectMenu->AddSeparator(); - inspectMenu->AddItem( PCB_ACTIONS::runDRC, SELECTION_CONDITIONS::ShowAlways ); + inspectMenu->AddItem( PCB_ACTIONS::runDRC, SELECTION_CONDITIONS::ShowAlways ); inspectMenu->Resolve(); @@ -505,8 +462,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() // CONDITIONAL_MENU* toolsMenu = new CONDITIONAL_MENU( false, selTool ); - toolsMenu->AddItem( ACTIONS::updatePcbFromSchematic, SELECTION_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( PCB_ACTIONS::updateFootprints, SELECTION_CONDITIONS::ShowAlways ); + toolsMenu->AddItem( ACTIONS::updatePcbFromSchematic, SELECTION_CONDITIONS::ShowAlways ); + toolsMenu->AddItem( PCB_ACTIONS::updateFootprints, SELECTION_CONDITIONS::ShowAlways ); #if defined(KICAD_SCRIPTING_WXPYTHON) auto pythonConsoleShownCondition = [] ( const SELECTION& aSel ) { diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 8b17f75ccd..b6944b15cb 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -123,9 +124,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) // Menu Files: EVT_MENU( ID_MAIN_MENUBAR, PCB_EDIT_FRAME::Process_Special_Functions ) - EVT_MENU( ID_MENU_PCB_FLIP_VIEW, PCB_EDIT_FRAME::OnFlipPcbView ) - EVT_MENU( ID_APPEND_FILE, PCB_EDIT_FRAME::Files_io ) EVT_MENU( ID_IMPORT_NON_KICAD_BOARD, PCB_EDIT_FRAME::Files_io ) EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PCB_EDIT_FRAME::OnFileHistory ) @@ -161,13 +160,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_PCB_GEN_CMP_FILE, PCB_EDIT_FRAME::RecreateCmpFileFromBoard ) EVT_MENU( ID_PCB_GEN_BOM_FILE_FROM_BOARD, PCB_EDIT_FRAME::RecreateBOMFileFromBoard ) - // menu Miscellaneous - EVT_MENU( ID_PCB_EDIT_TRACKS_AND_VIAS, PCB_EDIT_FRAME::OnEditTracksAndVias ) - EVT_MENU( ID_PCB_GLOBAL_DELETE, PCB_EDIT_FRAME::Process_Special_Functions ) - EVT_MENU( ID_MENU_PCB_CLEAN, PCB_EDIT_FRAME::Process_Special_Functions ) - EVT_MENU( ID_MENU_PCB_SWAP_LAYERS, PCB_EDIT_FRAME::Process_Special_Functions ) - EVT_MENU( ID_MENU_PCB_EDIT_TEXT_AND_GRAPHICS, PCB_EDIT_FRAME::OnEditTextAndGraphics ) - // Menu Get Design Rules Editor EVT_MENU( ID_BOARD_SETUP_DIALOG, PCB_EDIT_FRAME::ShowBoardSetupDialog ) @@ -195,31 +187,20 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR, PCB_EDIT_FRAME::OnSelectOptionToolbar ) - EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, - PCB_EDIT_FRAME::Process_Special_Functions ) - // Tracks and vias sizes general options EVT_MENU_RANGE( ID_POPUP_PCB_SELECT_WIDTH_START_RANGE, ID_POPUP_PCB_SELECT_WIDTH_END_RANGE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) - // popup menus - EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, - PCB_EDIT_FRAME::Process_Special_Functions ) - // User interface update event handlers. EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::OnUpdateLayerPair ) EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::OnUpdateLayerSelectBox ) - EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PCB_EDIT_FRAME::OnUpdateVerticalToolbar ) - EVT_UPDATE_UI( ID_ZOOM_SELECTION, PCB_EDIT_FRAME::OnUpdateVerticalToolbar ) EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth ) EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::OnUpdateSelectViaSize ) EVT_UPDATE_UI_RANGE( ID_POPUP_PCB_SELECT_WIDTH1, ID_POPUP_PCB_SELECT_WIDTH8, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth ) EVT_UPDATE_UI_RANGE( ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, PCB_EDIT_FRAME::OnUpdateSelectViaSize ) - EVT_UPDATE_UI_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_MEASUREMENT_TOOL, - PCB_EDIT_FRAME::OnUpdateVerticalToolbar ) EVT_UPDATE_UI_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD, PCB_EDIT_FRAME::OnUpdateMuWaveToolbar ) @@ -470,6 +451,7 @@ void PCB_EDIT_FRAME::setupTools() m_toolManager->RegisterTool( new ROUTER_TOOL ); m_toolManager->RegisterTool( new LENGTH_TUNER_TOOL ); m_toolManager->RegisterTool( new EDIT_TOOL ); + m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL ); m_toolManager->RegisterTool( new PAD_TOOL ); m_toolManager->RegisterTool( new DRAWING_TOOL ); m_toolManager->RegisterTool( new POINT_EDITOR ); @@ -1107,15 +1089,6 @@ void PCB_EDIT_FRAME::OnRunEeschema( wxCommandEvent& event ) } -void PCB_EDIT_FRAME::OnFlipPcbView( wxCommandEvent& evt ) -{ - auto view = GetGalCanvas()->GetView(); - view->SetMirror( evt.IsChecked(), false ); - view->RecacheAllItems(); - Refresh(); -} - - void PCB_EDIT_FRAME::PythonPluginsReload() { // Reload Python plugins if they are newer than diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 95bd1f5588..8d7a016e68 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -301,7 +301,6 @@ public: void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ); bool LayerManagerShown(); bool MicrowaveToolbarShown(); - void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ); void OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent ); void OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent ); @@ -564,8 +563,6 @@ public: void OnSelectOptionToolbar( wxCommandEvent& event ); void OnFlipPcbView( wxCommandEvent& event ); - void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); - /** * Function GenFootprintsPositionFile * Calls DoGenFootprintsPositionFile to create a footprint position file @@ -627,7 +624,6 @@ public: * ID_LOAD_FILE * ID_MENU_READ_BOARD_BACKUP_FILE * ID_MENU_RECOVER_BOARD_AUTOSAVE - * ID_APPEND_FILE * ID_NEW_BOARD * ID_SAVE_BOARD * ID_COPY_BOARD_AS @@ -1001,15 +997,6 @@ public: bool aPrepareUndoCommand = true ); - /** - * Function Clean_Pcb - * Clean up the board (remove redundant vias, not connected tracks - * and merges collinear track segments) - * Install the cleanup dialog frame to know what should be cleaned - * and run the cleanup function - */ - void Clean_Pcb(); - /** * Function SendMessageToEESCHEMA * sends a message to the schematic editor so that it may move its cursor diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 3744c460e4..645a254bdd 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -41,19 +41,6 @@ enum pcbnew_ids ID_PCB_PLACE_GRID_COORD_BUTT, ID_PCB_MEASUREMENT_TOOL, - ID_DIFF_PAIR_BUTT, - ID_TUNE_SINGLE_TRACK_LEN_BUTT, - ID_TUNE_DIFF_PAIR_LEN_BUTT, - ID_TUNE_DIFF_PAIR_SKEW_BUTT, - ID_MENU_DIFF_PAIR_DIMENSIONS, - ID_MENU_INTERACTIVE_ROUTER_SETTINGS, - - ID_MENU_PCB_FLIP_VIEW, - - ID_POPUP_PCB_START_RANGE, - ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST, - ID_POPUP_PCB_END_RANGE, - // Tracks and vias sizes general options ID_AUX_TOOLBAR_PCB_VIA_SIZE, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, @@ -118,10 +105,6 @@ enum pcbnew_ids ID_MENU_RECOVER_BOARD_AUTOSAVE, ID_MENU_ARCHIVE_MODULES_IN_LIBRARY, ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, - ID_PCB_EDIT_TRACKS_AND_VIAS, - ID_MENU_PCB_CLEAN, - ID_MENU_PCB_SWAP_LAYERS, - ID_MENU_PCB_EDIT_TEXT_AND_GRAPHICS, ID_GEN_EXPORT_FILE_IDF3, ID_GEN_EXPORT_FILE_VRML, @@ -159,7 +142,6 @@ enum pcbnew_ids ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, ID_PCB_MUWAVE_END_CMD, - ID_PCB_GLOBAL_DELETE, ID_TOOLBARH_PCB_SELECT_LAYER, // Module editor right vertical tool bar commands. @@ -179,7 +161,6 @@ enum pcbnew_ids ID_MODEDIT_SAVE, ID_MODEDIT_SAVE_AS, ID_MODEDIT_SAVE_PNG, - ID_MODEDIT_REVERT_PART, ID_MODEDIT_DELETE_PART, ID_MODEDIT_COPY_PART, ID_MODEDIT_CUT_PART, diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 589fab1919..1a7330ddfa 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -254,9 +254,9 @@ int LENGTH_TUNER_TOOL::TuneDiffPairSkew( const TOOL_EVENT& aEvent ) void LENGTH_TUNER_TOOL::setTransitions() { - Go( &LENGTH_TUNER_TOOL::TuneSingleTrace, PCB_ACTIONS::routerActivateTuneSingleTrace.MakeEvent() ); - Go( &LENGTH_TUNER_TOOL::TuneDiffPair, PCB_ACTIONS::routerActivateTuneDiffPair.MakeEvent() ); - Go( &LENGTH_TUNER_TOOL::TuneDiffPairSkew, PCB_ACTIONS::routerActivateTuneDiffPairSkew.MakeEvent() ); + Go( &LENGTH_TUNER_TOOL::TuneSingleTrace, PCB_ACTIONS::routerTuneSingleTrace.MakeEvent() ); + Go( &LENGTH_TUNER_TOOL::TuneDiffPair, PCB_ACTIONS::routerTuneDiffPair.MakeEvent() ); + Go( &LENGTH_TUNER_TOOL::TuneDiffPairSkew, PCB_ACTIONS::routerTuneDiffPairSkew.MakeEvent() ); } diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 0a4dd7401a..17be6fa1af 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -91,29 +91,34 @@ TOOL_ACTION PCB_ACTIONS::routerActivateDiffPair( "pcbnew.InteractiveRouter.DiffP _( "Run push & shove router (differential pairs)" ), ps_diff_pair_xpm, AF_ACTIVATE ); -TOOL_ACTION PCB_ACTIONS::routerActivateSettingsDialog( "pcbnew.InteractiveRouter.SettingsDialog", +TOOL_ACTION PCB_ACTIONS::routerSettingsDialog( "pcbnew.InteractiveRouter.SettingsDialog", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTING_OPTIONS ), _( "Interactive Router Settings..." ), _( "Open Interactive Router settings" ), tools_xpm ); -TOOL_ACTION PCB_ACTIONS::routerActivateDpDimensionsDialog( "pcbnew.InteractiveRouter.DpDimensionsDialog", +TOOL_ACTION PCB_ACTIONS::routerDiffPairDialog( "pcbnew.InteractiveRouter.DiffPairDialog", AS_GLOBAL, 0, _( "Differential Pair Dimension Settings..." ), _( "Open Differential Pair Dimension settings" ), ps_diff_pair_gap_xpm ); -TOOL_ACTION PCB_ACTIONS::routerActivateTuneSingleTrace( "pcbnew.LengthTuner.TuneSingleTrack", +TOOL_ACTION PCB_ACTIONS::selectLayerPair( "pcbnew.InteractiveRouter.SelectLayerPair", + AS_GLOBAL, 0, + _( "Set Layer Pair..." ), _( "Change active layer pair for routing" ), + select_layer_pair_xpm, AF_ACTIVATE ); + +TOOL_ACTION PCB_ACTIONS::routerTuneSingleTrace( "pcbnew.LengthTuner.TuneSingleTrack", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_SINGLE ), _( "Tune length of a single track" ), "", ps_tune_length_xpm, AF_ACTIVATE ); -TOOL_ACTION PCB_ACTIONS::routerActivateTuneDiffPair( "pcbnew.LengthTuner.TuneDiffPair", +TOOL_ACTION PCB_ACTIONS::routerTuneDiffPair( "pcbnew.LengthTuner.TuneDiffPair", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_DIFF_PAIR ), _( "Tune length of a differential pair" ), "", NULL, AF_ACTIVATE ); -TOOL_ACTION PCB_ACTIONS::routerActivateTuneDiffPairSkew( "pcbnew.LengthTuner.TuneDiffPairSkew", +TOOL_ACTION PCB_ACTIONS::routerTuneDiffPairSkew( "pcbnew.LengthTuner.TuneDiffPairSkew", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROUTE_TUNE_SKEW ), _( "Tune skew of a differential pair" ), "", NULL, AF_ACTIVATE ); @@ -409,7 +414,7 @@ protected: { bds.UseCustomDiffPairDimensions( true ); TOOL_MANAGER* toolManager = m_frame.GetToolManager(); - toolManager->RunAction( PCB_ACTIONS::routerActivateDpDimensionsDialog, true ); + toolManager->RunAction( PCB_ACTIONS::routerDiffPairDialog, true ); } else if( id == ID_POPUP_PCB_SELECT_USE_NETCLASS_DIFFPAIR ) { @@ -466,7 +471,7 @@ public: if( m_mode == PNS::PNS_MODE_ROUTE_DIFF_PAIR ) Add( &m_diffPairMenu ); - Add( PCB_ACTIONS::routerActivateSettingsDialog ); + Add( PCB_ACTIONS::routerSettingsDialog ); AppendSeparator(); @@ -899,21 +904,23 @@ int ROUTER_TOOL::SettingsDialog( const TOOL_EVENT& aEvent ) void ROUTER_TOOL::setTransitions() { - Go( &ROUTER_TOOL::RouteSingleTrace, PCB_ACTIONS::routerActivateSingle.MakeEvent() ); - Go( &ROUTER_TOOL::RouteDiffPair, PCB_ACTIONS::routerActivateDiffPair.MakeEvent() ); - Go( &ROUTER_TOOL::DpDimensionsDialog, PCB_ACTIONS::routerActivateDpDimensionsDialog.MakeEvent() ); - Go( &ROUTER_TOOL::SettingsDialog, PCB_ACTIONS::routerActivateSettingsDialog.MakeEvent() ); - Go( &ROUTER_TOOL::InlineDrag, PCB_ACTIONS::routerInlineDrag.MakeEvent() ); - Go( &ROUTER_TOOL::InlineBreakTrack, PCB_ACTIONS::inlineBreakTrack.MakeEvent() ); + Go( &ROUTER_TOOL::SelectCopperLayerPair, PCB_ACTIONS::selectLayerPair.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::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() ); + Go( &ROUTER_TOOL::onTrackViaSizeChanged, PCB_ACTIONS::trackViaSizeChanged.MakeEvent() ); } diff --git a/pcbnew/router/router_tool.h b/pcbnew/router/router_tool.h index 9d99dd62c9..eba2942dbc 100644 --- a/pcbnew/router/router_tool.h +++ b/pcbnew/router/router_tool.h @@ -40,6 +40,7 @@ public: bool CanInlineDrag(); int InlineDrag( const TOOL_EVENT& aEvent ); + int SelectCopperLayerPair( const TOOL_EVENT& aEvent ); // TODO make this private? int DpDimensionsDialog( const TOOL_EVENT& aEvent ); int SettingsDialog( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index 1e4b5837be..d2b2013af5 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -34,6 +34,7 @@ #include #include #include +#include // Column position by function: @@ -256,13 +257,12 @@ private: }; -void PCB_BASE_FRAME::SelectCopperLayerPair() +int ROUTER_TOOL::SelectCopperLayerPair( const TOOL_EVENT& aEvent ) { - PCB_SCREEN* screen = GetScreen(); + PCB_SCREEN* screen = frame()->GetScreen(); - SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( this, GetBoard(), - screen->m_Route_Layer_TOP, - screen->m_Route_Layer_BOTTOM ); + SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( frame(), frame()->GetBoard(), screen->m_Route_Layer_TOP, + screen->m_Route_Layer_BOTTOM ); if( dlg.ShowModal() == wxID_OK ) { @@ -271,8 +271,10 @@ void PCB_BASE_FRAME::SelectCopperLayerPair() // select the same layer for both layers is allowed (normal in some boards) // but could be a mistake. So display an info message if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM ) - DisplayInfoMessage( this, _( "Warning: top and bottom layers are same." ) ); + DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) ); } + + return 0; } diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 148bfa2c6b..02c3d7bd89 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -177,21 +177,10 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator() switch( s_BitmapLayerIcon[ii][jj] ) { default: - case 0: - pen.SetColour( active_layer_color.ToColour() ); - break; - - case 1: - pen.SetColour( Route_Layer_TOP_color.ToColour() ); - break; - - case 2: - pen.SetColour( Route_Layer_BOTTOM_color.ToColour() ); - break; - - case 3: - pen.SetColour( via_color.ToColour() ); - break; + case 0: pen.SetColour( active_layer_color.ToColour() ); break; + case 1: pen.SetColour( Route_Layer_TOP_color.ToColour() ); break; + case 2: pen.SetColour( Route_Layer_BOTTOM_color.ToColour() ); break; + case 3: pen.SetColour( via_color.ToColour() ); break; } buttonColor = s_BitmapLayerIcon[ii][jj]; @@ -366,16 +355,11 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar() // Tools to show/hide toolbars: KiScaledSeparator( m_optionsToolBar, this ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR, - wxEmptyString, - KiScaledBitmap( layers_manager_xpm, this ), - HELP_SHOW_HIDE_LAYERMANAGER, - wxITEM_CHECK ); + wxEmptyString, KiScaledBitmap( layers_manager_xpm, this ), + HELP_SHOW_HIDE_LAYERMANAGER, wxITEM_CHECK ); m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE, - wxEmptyString, - KiScaledBitmap( mw_toolbar_xpm, this ), - HELP_SHOW_HIDE_MICROWAVE_TOOLS, - wxITEM_CHECK ); - + wxEmptyString, KiScaledBitmap( mw_toolbar_xpm, this ), + HELP_SHOW_HIDE_MICROWAVE_TOOLS, wxITEM_CHECK ); KiScaledSeparator( m_optionsToolBar, this ); m_optionsToolBar->Realize(); @@ -495,10 +479,8 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar() // Creates box to display and choose tracks widths: if( m_SelTrackWidthBox == nullptr ) - m_SelTrackWidthBox = new wxChoice( m_auxiliaryToolBar, - ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, - wxDefaultPosition, wxDefaultSize, - 0, NULL ); + m_SelTrackWidthBox = new wxChoice( m_auxiliaryToolBar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, + wxDefaultPosition, wxDefaultSize, 0, NULL ); UpdateTrackWidthSelectBox( m_SelTrackWidthBox ); m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox ); @@ -506,18 +488,15 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar() // Creates box to display and choose vias diameters: if( m_SelViaSizeBox == nullptr ) - m_SelViaSizeBox = new wxChoice( m_auxiliaryToolBar, - ID_AUX_TOOLBAR_PCB_VIA_SIZE, - wxDefaultPosition, wxDefaultSize, - 0, NULL ); + m_SelViaSizeBox = new wxChoice( m_auxiliaryToolBar, ID_AUX_TOOLBAR_PCB_VIA_SIZE, + wxDefaultPosition, wxDefaultSize, 0, NULL ); UpdateViaSizeSelectBox( m_SelViaSizeBox ); m_auxiliaryToolBar->AddControl( m_SelViaSizeBox ); KiScaledSeparator( m_auxiliaryToolBar, this ); // Creates box to display and choose strategy to handle tracks an vias sizes: - m_auxiliaryToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, - wxEmptyString, + m_auxiliaryToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, wxEmptyString, KiScaledBitmap( auto_track_width_xpm, this ), _( "Auto track width: when starting on an existing track " "use its width\notherwise, use current width setting" ), @@ -527,10 +506,8 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar() KiScaledSeparator( m_auxiliaryToolBar, this ); if( m_gridSelectBox == nullptr ) - m_gridSelectBox = new wxChoice( m_auxiliaryToolBar, - ID_ON_GRID_SELECT, - wxDefaultPosition, wxDefaultSize, - 0, NULL ); + m_gridSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_GRID_SELECT, + wxDefaultPosition, wxDefaultSize, 0, NULL ); UpdateGridSelectBox(); @@ -540,10 +517,8 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar() KiScaledSeparator( m_auxiliaryToolBar, this ); if( m_zoomSelectBox == nullptr ) - m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar, - ID_ON_ZOOM_SELECT, - wxDefaultPosition, wxDefaultSize, - 0, NULL ); + m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_ZOOM_SELECT, + wxDefaultPosition, wxDefaultSize, 0, NULL ); updateZoomSelectBox(); m_auxiliaryToolBar->AddControl( m_zoomSelectBox ); @@ -571,11 +546,9 @@ void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, double value_mm = To_User_Unit( MILLIMETRES, size ); if( mmFirst ) - msg.Printf( _( "Track: %.3f mm (%.2f mils)" ), - value_mm, valueMils ); + msg.Printf( _( "Track: %.3f mm (%.2f mils)" ), value_mm, valueMils ); else - msg.Printf( _( "Track: %.2f mils (%.3f mm)" ), - valueMils, value_mm ); + msg.Printf( _( "Track: %.2f mils (%.3f mm)" ), valueMils, value_mm ); // Mark the netclass track width value (the first in list) if( ii == 0 ) @@ -738,12 +711,6 @@ bool PCB_EDIT_FRAME::MicrowaveToolbarShown() } -void PCB_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ) -{ - if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar ) - aEvent.Check( GetToolId() == aEvent.GetId() ); -} - void PCB_EDIT_FRAME::OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent ) { if( aEvent.GetEventObject() == m_microWaveToolBar ) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 78003320c8..e5ad845b8b 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -134,28 +134,6 @@ TOOL_ACTION PCB_ACTIONS::removeAlt( "pcbnew.InteractiveEdit.removeAlt", _( "Delete Full Track" ), _( "Deletes selected item(s) and copper connections" ), delete_xpm, AF_NONE, (void*) REMOVE_FLAGS::ALT ); -TOOL_ACTION PCB_ACTIONS::updateFootprint( "pcbnew.InteractiveEdit.updateFootprint", - AS_GLOBAL, 0, - _( "Update Footprint..." ), - _( "Update footprint to include any changes from the library" ), - reload_xpm ); - -TOOL_ACTION PCB_ACTIONS::updateFootprints( "pcbnew.InteractiveEdit.updateFootprints", - AS_GLOBAL, 0, - _( "Update Footprints from Library..." ), - _( "Update footprints to include any changes from the library" ), - reload_xpm ); - -TOOL_ACTION PCB_ACTIONS::changeFootprint( "pcbnew.InteractiveEdit.changeFootprint", - AS_GLOBAL, 0, - _( "Change Footprint..." ), _( "Assign a different footprint from the library" ), - exchange_xpm ); - -TOOL_ACTION PCB_ACTIONS::changeFootprints( "pcbnew.InteractiveEdit.changeFootprints", - AS_GLOBAL, 0, - _( "Change Footprints..." ), _( "Assign different footprints from the library" ), - exchange_xpm ); - TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_ITEM ), _( "Properties..." ), _( "Displays item properties dialog" ), @@ -1201,50 +1179,6 @@ void EDIT_TOOL::FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector } -int EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) -{ - SELECTION& selection = m_selectionTool->RequestSelection( FootprintFilter ); - MODULE* mod = (selection.Empty() ? nullptr : selection.FirstOfKind () ); - bool updateMode = false; - bool currentMode = false; - - if( aEvent.IsAction( &PCB_ACTIONS::updateFootprint ) ) - { - updateMode = true; - currentMode = true; - } - else if( aEvent.IsAction( &PCB_ACTIONS::updateFootprints ) ) - { - updateMode = true; - currentMode = false; - } - else if( aEvent.IsAction( &PCB_ACTIONS::changeFootprint ) ) - { - updateMode = false; - currentMode = true; - } - else if( aEvent.IsAction( &PCB_ACTIONS::changeFootprints ) ) - { - updateMode = false; - currentMode = false; - } - else - wxFAIL_MSG( "ExchangeFootprints: unexpected action" ); - - // Footprint exchange could remove modules, so they have to be - // removed from the selection first - m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - - // invoke the exchange dialog process - { - DIALOG_EXCHANGE_FOOTPRINTS dialog( frame(), mod, updateMode, currentMode ); - dialog.ShowQuasiModal(); - } - - return 0; -} - - int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) { if( EditingModules() && !frame()->GetModel()) @@ -1517,10 +1451,6 @@ void EDIT_TOOL::setTransitions() Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirror.MakeEvent() ); Go( &EDIT_TOOL::EditFpInFpEditor, PCB_ACTIONS::editFootprintInFpEditor.MakeEvent() ); - Go( &EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::updateFootprint.MakeEvent() ); - Go( &EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::updateFootprints.MakeEvent() ); - Go( &EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::changeFootprint.MakeEvent() ); - Go( &EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::changeFootprints.MakeEvent() ); Go( &EDIT_TOOL::MeasureTool, ACTIONS::measureTool.MakeEvent() ); Go( &EDIT_TOOL::copyToClipboard, ACTIONS::copy.MakeEvent() ); diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index bd5388e9d0..dcae3df4d8 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -139,14 +139,6 @@ public: */ int CreateArray( const TOOL_EVENT& aEvent ); - /** - * Function ExchangeFootprints() - * - * Invoke the dialog used to update or exchange the footprints used for - * modules. The mode depends on the PCB_ACTIONS held by the TOOL_EVENT. - */ - int ExchangeFootprints( const TOOL_EVENT& aEvent ); - ///> Launches a tool to measure between points int MeasureTool( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index 04dcfc541d..a2f6170dbc 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -26,18 +26,15 @@ #include "kicad_clipboard.h" #include "selection_tool.h" #include "pcb_actions.h" - #include - #include - #include #include #include #include #include #include - +#include #include #include #include @@ -45,7 +42,6 @@ #include #include #include - #include #include #include @@ -97,6 +93,12 @@ void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason ) } +int MODULE_EDITOR_TOOLS::Revert( const TOOL_EVENT& aEvent ) +{ + getEditFrame()->RevertFootprint(); + return 0; +} + int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) { @@ -542,6 +544,8 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) void MODULE_EDITOR_TOOLS::setTransitions() { + Go( &MODULE_EDITOR_TOOLS::Revert, ACTIONS::revert.MakeEvent() ); + Go( &MODULE_EDITOR_TOOLS::PlacePad, PCB_ACTIONS::placePad.MakeEvent() ); Go( &MODULE_EDITOR_TOOLS::CreatePadFromShapes, PCB_ACTIONS::createPadFromShapes.MakeEvent() ); Go( &MODULE_EDITOR_TOOLS::ExplodePadToShapes, PCB_ACTIONS::explodePadToShapes.MakeEvent() ); diff --git a/pcbnew/tools/footprint_editor_tools.h b/pcbnew/tools/footprint_editor_tools.h index 8c6e6227d7..50200fc898 100644 --- a/pcbnew/tools/footprint_editor_tools.h +++ b/pcbnew/tools/footprint_editor_tools.h @@ -49,6 +49,8 @@ public: /// @copydoc TOOL_INTERACTIVE::Reset() void Reset( RESET_REASON aReason ) override; + int Revert( const TOOL_EVENT& aEvent ); + /** * Function PlacePad() * Places a pad in module editor. @@ -82,7 +84,6 @@ public: */ int ExplodePadToShapes( const TOOL_EVENT& aEvent ); - ///> Sets up handlers for various events. void setTransitions() override; diff --git a/pcbnew/tools/global_edit_tool.cpp b/pcbnew/tools/global_edit_tool.cpp new file mode 100644 index 0000000000..579d9f0c70 --- /dev/null +++ b/pcbnew/tools/global_edit_tool.cpp @@ -0,0 +1,239 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see AUTHORS.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +TOOL_ACTION PCB_ACTIONS::updateFootprint( "pcbnew.GlobalEdit.updateFootprint", + AS_GLOBAL, 0, + _( "Update Footprint..." ), + _( "Update footprint to include any changes from the library" ), + reload_xpm ); + +TOOL_ACTION PCB_ACTIONS::updateFootprints( "pcbnew.GlobalEdit.updateFootprints", + AS_GLOBAL, 0, + _( "Update Footprints from Library..." ), + _( "Update footprints to include any changes from the library" ), + reload_xpm ); + +TOOL_ACTION PCB_ACTIONS::changeFootprint( "pcbnew.GlobalEdit.changeFootprint", + AS_GLOBAL, 0, + _( "Change Footprint..." ), _( "Assign a different footprint from the library" ), + exchange_xpm ); + +TOOL_ACTION PCB_ACTIONS::changeFootprints( "pcbnew.GlobalEdit.changeFootprints", + AS_GLOBAL, 0, + _( "Change Footprints..." ), _( "Assign different footprints from the library" ), + exchange_xpm ); + +TOOL_ACTION PCB_ACTIONS::swapLayers( "pcbnew.GlobalEdit.swapLayers", + AS_GLOBAL, 0, + _( "Swap Layers..." ), _( "Move tracks or drawings from one layer to another" ), + swap_layer_xpm ); + +TOOL_ACTION PCB_ACTIONS::editTracksAndVias( "pcbnew.GlobalEdit.editTracksAndVias", + AS_GLOBAL, 0, + _( "Edit Track && Via Properties..." ), "", + width_track_via_xpm ); + +TOOL_ACTION PCB_ACTIONS::editTextAndGraphics( "pcbnew.GlobalEdit.editTextAndGraphics", + AS_GLOBAL, 0, + _( "Edit Text && Graphic Properties..." ), "", + reset_text_xpm ); + +TOOL_ACTION PCB_ACTIONS::globalDeletions( "pcbnew.GlobalEdit.globalDeletions", + AS_GLOBAL, 0, + _( "Global Deletions..." ), + _( "Delete tracks, footprints and graphic items from board" ), + general_deletions_xpm ); + +TOOL_ACTION PCB_ACTIONS::cleanupTracksAndVias( "pcbnew.GlobalEdit.cleanupTracksAndVias", + AS_GLOBAL, 0, + _( "Cleanup Tracks && Vias..." ), + _( "Clean stubs, vias, delete break points or unconnected tracks" ), + delete_xpm ); + + +GLOBAL_EDIT_TOOL::GLOBAL_EDIT_TOOL() : + PCB_TOOL_BASE( "pcbnew.GlobalEdit" ) +{ +} + + +void GLOBAL_EDIT_TOOL::Reset( RESET_REASON aReason ) +{ + if( aReason != RUN ) + m_commit.reset( new BOARD_COMMIT( this ) ); +} + + +bool GLOBAL_EDIT_TOOL::Init() +{ + // Find the selection tool, so they can cooperate + m_selectionTool = static_cast( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) ); + + wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" ); + + return true; +} + + +int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) +{ + SELECTION& selection = m_selectionTool->RequestSelection( EDIT_TOOL::FootprintFilter ); + MODULE* mod = (selection.Empty() ? nullptr : selection.FirstOfKind () ); + bool updateMode = false; + bool currentMode = false; + + if( aEvent.IsAction( &PCB_ACTIONS::updateFootprint ) ) + { + updateMode = true; + currentMode = true; + } + else if( aEvent.IsAction( &PCB_ACTIONS::updateFootprints ) ) + { + updateMode = true; + currentMode = false; + } + else if( aEvent.IsAction( &PCB_ACTIONS::changeFootprint ) ) + { + updateMode = false; + currentMode = true; + } + else if( aEvent.IsAction( &PCB_ACTIONS::changeFootprints ) ) + { + updateMode = false; + currentMode = false; + } + else + wxFAIL_MSG( "ExchangeFootprints: unexpected action" ); + + // Footprint exchange could remove modules, so they have to be + // removed from the selection first + m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + + // invoke the exchange dialog process + { + DIALOG_EXCHANGE_FOOTPRINTS dialog( frame(), mod, updateMode, currentMode ); + dialog.ShowQuasiModal(); + } + + return 0; +} + + +bool GLOBAL_EDIT_TOOL::swapBoardItem( BOARD_ITEM* aItem, PCB_LAYER_ID* new_layer ) +{ + if( new_layer[ aItem->GetLayer() ] != aItem->GetLayer() ) + { + m_commit->Modify( aItem ); + aItem->SetLayer( new_layer[ aItem->GetLayer() ] ); + frame()->GetGalCanvas()->GetView()->Update( aItem, KIGFX::GEOMETRY ); + return true; + } + + return false; +} + + +int GLOBAL_EDIT_TOOL::SwapLayers( const TOOL_EVENT& aEvent ) +{ + PCB_LAYER_ID new_layer[PCB_LAYER_ID_COUNT]; + + DIALOG_SWAP_LAYERS dlg( frame(), new_layer ); + + if( dlg.ShowModal() != wxID_OK ) + return 0; + + bool hasChanges = false; + + // Change tracks. + for( auto segm : frame()->GetBoard()->Tracks() ) + { + if( segm->Type() == PCB_VIA_T ) + { + VIA* via = (VIA*) segm; + PCB_LAYER_ID top_layer, bottom_layer; + + if( via->GetViaType() == VIA_THROUGH ) + continue; + + via->LayerPair( &top_layer, &bottom_layer ); + + if( new_layer[bottom_layer] != bottom_layer || new_layer[top_layer] != top_layer ) + { + m_commit->Modify( via ); + via->SetLayerPair( new_layer[top_layer], new_layer[bottom_layer] ); + frame()->GetGalCanvas()->GetView()->Update( via, KIGFX::GEOMETRY ); + hasChanges = true; + } + } + else + { + hasChanges |= swapBoardItem( segm, new_layer ); + } + } + + for( BOARD_ITEM* zone : frame()->GetBoard()->Zones() ) + hasChanges |= swapBoardItem( zone, new_layer ); + + for( BOARD_ITEM* drawing : frame()->GetBoard()->Drawings() ) + hasChanges |= swapBoardItem( drawing, new_layer ); + + if( hasChanges ) + { + frame()->OnModify(); + m_commit->Push( "Layers moved" ); + frame()->GetGalCanvas()->Refresh(); + } + + return 0; +} + + +void GLOBAL_EDIT_TOOL::setTransitions() +{ + Go( &GLOBAL_EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::updateFootprint.MakeEvent() ); + Go( &GLOBAL_EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::updateFootprints.MakeEvent() ); + Go( &GLOBAL_EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::changeFootprint.MakeEvent() ); + Go( &GLOBAL_EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::changeFootprints.MakeEvent() ); + + Go( &GLOBAL_EDIT_TOOL::SwapLayers, PCB_ACTIONS::swapLayers.MakeEvent() ); + + Go( &GLOBAL_EDIT_TOOL::EditTracksAndVias, PCB_ACTIONS::editTracksAndVias.MakeEvent() ); + Go( &GLOBAL_EDIT_TOOL::EditTextAndGraphics, PCB_ACTIONS::editTextAndGraphics.MakeEvent() ); + Go( &GLOBAL_EDIT_TOOL::GlobalDeletions, PCB_ACTIONS::globalDeletions.MakeEvent() ); + Go( &GLOBAL_EDIT_TOOL::CleanupTracksAndVias, PCB_ACTIONS::cleanupTracksAndVias.MakeEvent() ); +} + + diff --git a/pcbnew/tools/global_edit_tool.h b/pcbnew/tools/global_edit_tool.h new file mode 100644 index 0000000000..5d9434b2ca --- /dev/null +++ b/pcbnew/tools/global_edit_tool.h @@ -0,0 +1,75 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see AUTHORS.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef GLOBAL_EDIT_TOOL_H +#define GLOBAL_EDIT_TOOL_H + +#include +#include +#include +#include + + +class BOARD_COMMIT; +class BOARD_ITEM; +class CONNECTIVITY_DATA; + + +class GLOBAL_EDIT_TOOL : public PCB_TOOL_BASE +{ +public: + GLOBAL_EDIT_TOOL(); + + /// @copydoc TOOL_INTERACTIVE::Reset() + void Reset( RESET_REASON aReason ) override; + + /// @copydoc TOOL_INTERACTIVE::Init() + bool Init() override; + + /** + * Function ExchangeFootprints() + * + * Invoke the dialog used to update or exchange the footprints used for + * modules. The mode depends on the PCB_ACTIONS held by the TOOL_EVENT. + */ + int ExchangeFootprints( const TOOL_EVENT& aEvent ); + + int SwapLayers( const TOOL_EVENT& aEvent ); + + int EditTracksAndVias( const TOOL_EVENT& aEvent ); + int EditTextAndGraphics( const TOOL_EVENT& aEvent ); + int GlobalDeletions( const TOOL_EVENT& aEvent ); + int CleanupTracksAndVias( const TOOL_EVENT& aEvent ); + +private: + bool swapBoardItem( BOARD_ITEM* aItem, PCB_LAYER_ID* new_layer ); + + ///> Sets up handlers for various events. + void setTransitions() override; + +private: + SELECTION_TOOL* m_selectionTool; + std::unique_ptr m_commit; +}; + +#endif diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 1047e67640..f92a09d22c 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -33,42 +33,12 @@ OPT PCB_ACTIONS::TranslateLegacyId( int aId ) { switch( aId ) { - case ID_DIFF_PAIR_BUTT: - return PCB_ACTIONS::routerActivateDiffPair.MakeEvent(); - - case ID_TUNE_SINGLE_TRACK_LEN_BUTT: - return PCB_ACTIONS::routerActivateTuneSingleTrace.MakeEvent(); - - case ID_TUNE_DIFF_PAIR_LEN_BUTT: - return PCB_ACTIONS::routerActivateTuneDiffPair.MakeEvent(); - - case ID_TUNE_DIFF_PAIR_SKEW_BUTT: - return PCB_ACTIONS::routerActivateTuneDiffPairSkew.MakeEvent(); - - case ID_MENU_INTERACTIVE_ROUTER_SETTINGS: - return PCB_ACTIONS::routerActivateSettingsDialog.MakeEvent(); - - case ID_MENU_DIFF_PAIR_DIMENSIONS: - return PCB_ACTIONS::routerActivateDpDimensionsDialog.MakeEvent(); - case ID_GEN_IMPORT_GRAPHICS_FILE: return PCB_ACTIONS::placeImportedGraphics.MakeEvent(); - case ID_POPUP_GRID_NEXT: - return ACTIONS::gridNext.MakeEvent(); - - case ID_POPUP_GRID_PREV: - return ACTIONS::gridPrev.MakeEvent(); - - case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: - return PCB_ACTIONS::findMove.MakeEvent(); - case ID_NO_TOOL_SELECTED: return PCB_ACTIONS::selectionTool.MakeEvent(); - case ID_APPEND_FILE: - return PCB_ACTIONS::appendBoard.MakeEvent(); - case ID_PCB_MUWAVE_TOOL_GAP_CMD: return PCB_ACTIONS::microwaveCreateGap.MakeEvent(); diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 73117a0bec..bb32d5f6b3 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -113,18 +113,12 @@ public: /// Activation of the duplication tool with incrementing (e.g. pad number) static TOOL_ACTION duplicateIncrement; - /// Update footprints to reflect any changes in the library - static TOOL_ACTION updateFootprint; - static TOOL_ACTION updateFootprints; - - /// Exchange footprints of modules - static TOOL_ACTION changeFootprint; - static TOOL_ACTION changeFootprints; - /// Deleting a BOARD_ITEM static TOOL_ACTION remove; static TOOL_ACTION removeAlt; + static TOOL_ACTION selectLayerPair; + /// Break a single track into two segments at the cursor static TOOL_ACTION breakTrack; @@ -170,17 +164,17 @@ public: static TOOL_ACTION routerActivateDiffPair; /// Activation of the Push and Shove router (tune single line mode) - static TOOL_ACTION routerActivateTuneSingleTrace; + static TOOL_ACTION routerTuneSingleTrace; /// Activation of the Push and Shove router (diff pair tuning mode) - static TOOL_ACTION routerActivateTuneDiffPair; + static TOOL_ACTION routerTuneDiffPair; /// Activation of the Push and Shove router (skew tuning mode) - static TOOL_ACTION routerActivateTuneDiffPairSkew; + static TOOL_ACTION routerTuneDiffPairSkew; /// Activation of the Push and Shove settings dialogs - static TOOL_ACTION routerActivateSettingsDialog; - static TOOL_ACTION routerActivateDpDimensionsDialog; + static TOOL_ACTION routerSettingsDialog; + static TOOL_ACTION routerDiffPairDialog; /// Activation of the Push and Shove router (inline dragging mode) @@ -238,6 +232,8 @@ public: static TOOL_ACTION layerChanged; // notification + static TOOL_ACTION flipBoard; + // Track & via size control static TOOL_ACTION trackWidthInc; static TOOL_ACTION trackWidthDec; @@ -256,6 +252,18 @@ public: /// Duplicate zone onto another layer static TOOL_ACTION zoneDuplicate; + // Global edit tool + static TOOL_ACTION editTracksAndVias; + static TOOL_ACTION editTextAndGraphics; + static TOOL_ACTION globalDeletions; + static TOOL_ACTION cleanupTracksAndVias; + static TOOL_ACTION updateFootprint; + static TOOL_ACTION updateFootprints; + static TOOL_ACTION changeFootprint; + static TOOL_ACTION changeFootprints; + static TOOL_ACTION swapLayers; + + static TOOL_ACTION listNets; static TOOL_ACTION runDRC; static TOOL_ACTION updatePcbFromSchematic; diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 8694d4ff12..867ce8b3bb 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -176,6 +176,11 @@ TOOL_ACTION PCB_ACTIONS::showPythonConsole( "pcbnew.Control.showPythonConsole", _( "Scripting Console" ), _( "Show the Python scripting console" ), py_script_xpm ); +TOOL_ACTION PCB_ACTIONS::flipBoard( "pcbnew.Control.flipBoard", + AS_GLOBAL, 0, + _( "Flip Board View" ), _( "Flip (mirror) the board view" ), + flip_board_xpm ); + class ZONE_CONTEXT_MENU : public ACTION_MENU { @@ -1383,6 +1388,15 @@ void PCB_EDITOR_CONTROL::calculateSelectionRatsnest() } +int PCB_EDITOR_CONTROL::FlipPcbView( const TOOL_EVENT& aEvent ) +{ + view()->SetMirror( !view()->IsMirroredX(), false ); + view()->RecacheAllItems(); + frame()->Refresh(); + return 0; +} + + void PCB_EDITOR_CONTROL::setTransitions() { Go( &PCB_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() ); @@ -1430,6 +1444,7 @@ void PCB_EDITOR_CONTROL::setTransitions() Go( &PCB_EDITOR_CONTROL::ListNets, PCB_ACTIONS::listNets.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::UpdatePCBFromSchematic, ACTIONS::updatePcbFromSchematic.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::TogglePythonConsole, PCB_ACTIONS::showPythonConsole.MakeEvent() ); + Go( &PCB_EDITOR_CONTROL::FlipPcbView, PCB_ACTIONS::flipBoard.MakeEvent() ); } diff --git a/pcbnew/tools/pcb_editor_control.h b/pcbnew/tools/pcb_editor_control.h index 3d00c14235..57b259e676 100644 --- a/pcbnew/tools/pcb_editor_control.h +++ b/pcbnew/tools/pcb_editor_control.h @@ -132,6 +132,8 @@ public: ///> Shows local ratsnest of a component int LocalRatsnestTool( const TOOL_EVENT& aEvent ); + int FlipPcbView( const TOOL_EVENT& aEvent ); + int ListNets( const TOOL_EVENT& aEvent ); private: diff --git a/pcbnew/tracks_cleaner.cpp b/pcbnew/tracks_cleaner.cpp index 5018f4ae86..85979b5cd5 100644 --- a/pcbnew/tracks_cleaner.cpp +++ b/pcbnew/tracks_cleaner.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,12 +23,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file tracks_cleaner.cpp - * @brief functions to clean tracks: remove null length and redundant segments - */ - - #include #include #include @@ -39,20 +33,19 @@ #include #include #include - #include #include - +#include #include /* Install the cleanup dialog frame to know what should be cleaned */ -void PCB_EDIT_FRAME::Clean_Pcb() +int GLOBAL_EDIT_TOOL::CleanupTracksAndVias( const TOOL_EVENT& aEvent ) { - DIALOG_CLEANUP_TRACKS_AND_VIAS dlg( this ); - + DIALOG_CLEANUP_TRACKS_AND_VIAS dlg( frame() ); dlg.ShowModal(); + return 0; } @@ -104,8 +97,7 @@ bool TRACKS_CLEANER::CleanupBoard( bool aDryRun, DRC_LIST* aItemsList, bool aRem modified = true; // Removed tracks can leave aligned segments - // (when a T was formed by tracks and the "vertical" segment - // is removed) + // (when a T was formed by tracks and the "vertical" segment is removed) if( aMergeSegments ) cleanupSegments(); } @@ -180,9 +172,9 @@ bool TRACKS_CLEANER::cleanupVias() if( via1->GetStart() != via1->GetEnd() ) via1->SetEnd( via1->GetStart() ); - /* To delete through Via on THT pads at same location - * Examine the list of connected pads: - * if one through pad is found, the via can be removed */ + // To delete through Via on THT pads at same location + // Examine the list of connected pads: + // if one through pad is found, the via can be removed const auto pads = m_brd->GetConnectivity()->GetConnectedPads( via1 ); for( const auto pad : pads ) @@ -282,18 +274,15 @@ bool TRACKS_CLEANER::deleteDanglingTracks() { item_erased = false; - for( auto track_it = m_brd->Tracks().begin(); track_it != m_brd->Tracks().end(); - track_it++ ) + for( TRACK* track : m_brd->Tracks() ) { - auto track = *track_it; bool flag_erase = false; // Start without a good reason to erase it if( track->Type() != PCB_TRACE_T ) continue; - /* if a track endpoint is not connected to a pad, test if - * the endpoint is connected to another track or to a zone. - */ + // if a track endpoint is not connected to a pad, test if + // the endpoint is connected to another track or to a zone. if( !testTrackHasPad( track ) ) flag_erase |= testTrackEndpointDangling( track ); @@ -321,7 +310,6 @@ bool TRACKS_CLEANER::deleteDanglingTracks() } } while( item_erased ); - return modified; }