From 60b4202766b99f643e4ca1e83c208f7906dd776a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 13 Aug 2025 09:33:57 +0100 Subject: [PATCH] CHANGED: Rework lock overrides architecture. We now use a checkbox in the aux toolbar rather than a query dialog (with "remember setting" checkbox). --- common/CMakeLists.txt | 2 - common/dialogs/dialog_locked_items_query.cpp | 84 ---- .../dialog_locked_items_query_base.cpp | 88 ---- .../dialog_locked_items_query_base.fbp | 462 ------------------ .../dialogs/dialog_locked_items_query_base.h | 60 --- common/eda_draw_frame.cpp | 137 +++--- common/tool/action_toolbar.cpp | 95 ++-- include/board_design_settings.h | 39 +- include/dialogs/dialog_locked_items_query.h | 44 -- include/eda_draw_frame.h | 3 + include/tool/action_toolbar.h | 3 +- pcbnew/autorouter/autoplace_tool.cpp | 41 +- pcbnew/board_design_settings.cpp | 15 +- .../dialog_global_edit_tracks_and_vias.cpp | 22 +- pcbnew/dialogs/panel_edit_options.cpp | 7 +- pcbnew/dialogs/panel_edit_options_base.cpp | 5 - pcbnew/dialogs/panel_edit_options_base.fbp | 65 --- pcbnew/dialogs/panel_edit_options_base.h | 1 - pcbnew/pcbnew_settings.cpp | 4 - pcbnew/pcbnew_settings.h | 8 - pcbnew/toolbars_pcb_editor.cpp | 7 +- pcbnew/tools/board_editor_control.cpp | 16 +- pcbnew/tools/pcb_selection_tool.cpp | 217 ++++---- pcbnew/tools/pcb_selection_tool.h | 4 +- 24 files changed, 243 insertions(+), 1186 deletions(-) delete mode 100644 common/dialogs/dialog_locked_items_query.cpp delete mode 100644 common/dialogs/dialog_locked_items_query_base.cpp delete mode 100644 common/dialogs/dialog_locked_items_query_base.fbp delete mode 100644 common/dialogs/dialog_locked_items_query_base.h delete mode 100644 include/dialogs/dialog_locked_items_query.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 46f21fe523..81515b7277 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -401,8 +401,6 @@ set( COMMON_DLG_SRCS dialogs/dialog_HTML_reporter_base.cpp dialogs/dialog_import_choose_project.cpp dialogs/dialog_import_choose_project_base.cpp - dialogs/dialog_locked_items_query.cpp - dialogs/dialog_locked_items_query_base.cpp dialogs/dialog_multi_unit_entry.cpp dialogs/dialog_page_settings_base.cpp dialogs/dialog_paste_special.cpp diff --git a/common/dialogs/dialog_locked_items_query.cpp b/common/dialogs/dialog_locked_items_query.cpp deleted file mode 100644 index bc1fe89453..0000000000 --- a/common/dialogs/dialog_locked_items_query.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright The 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 - - -DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent, std::size_t aLockedItemCount, - PCBNEW_SETTINGS::LOCKING_OPTIONS& aLockingOptions ) : - DIALOG_LOCKED_ITEMS_QUERY_BASE( aParent ), - m_lockingOptions( aLockingOptions ) -{ - // Potentially dangerous to save the state of the Do Not Show Again button between sessions. - OptOut( m_doNotShowBtn ); - - m_icon->SetBitmap( KiBitmapBundle( BITMAPS::locked ) ); - - m_messageLine1->SetLabel( wxString::Format( m_messageLine1->GetLabel(), aLockedItemCount ) ); - - SetupStandardButtons( { { wxID_OK, _( "Skip Locked Items" ) } } ); - m_sdbSizerOK->SetToolTip( _( "Remove locked items from the selection and only apply the " - "operation to the unlocked items (if any)." ) ); - - m_doNotShowBtn->SetToolTip( _( "Do not show this dialog again until KiCad restarts. " - "You can re-enable this dialog in Pcbnew preferences." ) ); - - // While this dialog can get called for a lot of different use-cases, we'll assume that it - // does make sense to store state *between* the use-cases. So we don't assign a separate - // hash key for each use case. - - SetInitialFocus( m_sdbSizerOK ); - - Layout(); - - // Now all widgets have the size fixed, call FinishDialogSettings - finishDialogSettings(); -} - - -void DIALOG_LOCKED_ITEMS_QUERY::onOverrideLocks( wxCommandEvent& event ) -{ - // This will choose the correct way to end the dialog no matter how is was shown. - EndDialog( wxID_APPLY ); -} - - -int DIALOG_LOCKED_ITEMS_QUERY::ShowModal() -{ - static int doNotShowValue = wxID_ANY; - - if( doNotShowValue != wxID_ANY && m_lockingOptions.m_sessionSkipPrompts ) - return doNotShowValue; - - int ret = DIALOG_SHIM::ShowModal(); - - // Has the user asked not to show the dialog again this session? - if( m_doNotShowBtn->IsChecked() && ret != wxID_CANCEL ) - { - doNotShowValue = ret; - m_lockingOptions.m_sessionSkipPrompts = true; - } - - return ret; -} diff --git a/common/dialogs/dialog_locked_items_query_base.cpp b/common/dialogs/dialog_locked_items_query_base.cpp deleted file mode 100644 index 566149fe6e..0000000000 --- a/common/dialogs/dialog_locked_items_query_base.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_locked_items_query_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_LOCKED_ITEMS_QUERY_BASE::DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxVERTICAL ); - - wxFlexGridSizer* fgSizer4; - fgSizer4 = new wxFlexGridSizer( 0, 2, 10, 0 ); - fgSizer4->SetFlexibleDirection( wxBOTH ); - fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_icon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer4->Add( m_icon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 10 ); - - wxBoxSizer* bSizer4; - bSizer4 = new wxBoxSizer( wxVERTICAL ); - - m_messageLine1 = new wxStaticText( this, wxID_ANY, _("The selection contains %zu locked items."), wxDefaultPosition, wxDefaultSize, 0 ); - m_messageLine1->Wrap( -1 ); - bSizer4->Add( m_messageLine1, 0, wxALL, 5 ); - - m_messageLine2 = new wxStaticText( this, wxID_ANY, _("These items will be skipped unless you override the locks."), wxDefaultPosition, wxDefaultSize, 0 ); - m_messageLine2->Wrap( -1 ); - bSizer4->Add( m_messageLine2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - - fgSizer4->Add( bSizer4, 1, wxEXPAND|wxRIGHT, 5 ); - - - fgSizer4->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_doNotShowBtn = new wxCheckBox( this, wxID_ANY, _("Remember decision for this session."), wxDefaultPosition, wxDefaultSize, 0 ); - m_doNotShowBtn->SetToolTip( _("Remember the option selected for the remainder of this session.\nThis dialog will not be shown again until KiCad is restarted.") ); - - fgSizer4->Add( m_doNotShowBtn, 0, wxALL, 5 ); - - - bSizerMain->Add( fgSizer4, 1, wxEXPAND|wxALL, 5 ); - - wxBoxSizer* bButtonSizer; - bButtonSizer = new wxBoxSizer( wxHORIZONTAL ); - - m_overrideBtn = new wxButton( this, wxID_ANY, _("Override Locks"), wxDefaultPosition, wxDefaultSize, 0 ); - m_overrideBtn->SetToolTip( _("Override locks and apply the operation on all the items selected.\nAny locked items will remain locked after the operation is complete.") ); - - bButtonSizer->Add( m_overrideBtn, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 ); - - m_sdbSizer = new wxStdDialogButtonSizer(); - m_sdbSizerOK = new wxButton( this, wxID_OK ); - m_sdbSizer->AddButton( m_sdbSizerOK ); - m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer->AddButton( m_sdbSizerCancel ); - m_sdbSizer->Realize(); - - bButtonSizer->Add( m_sdbSizer, 1, wxBOTTOM|wxTOP, 5 ); - - - bSizerMain->Add( bButtonSizer, 0, wxEXPAND, 5 ); - - - this->SetSizer( bSizerMain ); - this->Layout(); - bSizerMain->Fit( this ); - - // Connect Events - this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::OnInitDlg ) ); - m_overrideBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOverrideLocks ), NULL, this ); -} - -DIALOG_LOCKED_ITEMS_QUERY_BASE::~DIALOG_LOCKED_ITEMS_QUERY_BASE() -{ - // Disconnect Events - this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::OnInitDlg ) ); - m_overrideBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOverrideLocks ), NULL, this ); - -} diff --git a/common/dialogs/dialog_locked_items_query_base.fbp b/common/dialogs/dialog_locked_items_query_base.fbp deleted file mode 100644 index 8acd481d8f..0000000000 --- a/common/dialogs/dialog_locked_items_query_base.fbp +++ /dev/null @@ -1,462 +0,0 @@ - - - - - C++ - - 1 - connect - none - - - 0 - 0 - res - UTF-8 - dialog_locked_items_query_base - 1000 - 1 - 1 - UI - dialog_locked_items_query - . - 0 - source_name - 1 - 0 - source_name - - - 1 - 1 - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - - 1 - 0 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_LOCKED_ITEMS_QUERY_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Locked Items - - 0 - - - - OnInitDlg - - - bSizerMain - wxVERTICAL - none - - 5 - wxEXPAND|wxALL - 1 - - 2 - wxBOTH - - - 0 - - fgSizer4 - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 10 - - 10 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_icon - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - - - - - 5 - wxEXPAND|wxRIGHT - 1 - - - bSizer4 - wxVERTICAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - The selection contains %zu locked items. - 0 - - 0 - - - 0 - - 1 - m_messageLine1 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - These items will be skipped unless you override the locks. - 0 - - 0 - - - 0 - - 1 - m_messageLine2 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Remember decision for this session. - - 0 - - - 0 - - 1 - m_doNotShowBtn - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - Remember the option selected for the remainder of this session. This dialog will not be shown again until KiCad is restarted. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND - 0 - - - bButtonSizer - wxHORIZONTAL - none - - 10 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Override Locks - - 0 - - 0 - - - 0 - - 1 - m_overrideBtn - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - Override locks and apply the operation on all the items selected. Any locked items will remain locked after the operation is complete. - - wxFILTER_NONE - wxDefaultValidator - - - - - onOverrideLocks - - - - 5 - wxBOTTOM|wxTOP - 1 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - - - - - diff --git a/common/dialogs/dialog_locked_items_query_base.h b/common/dialogs/dialog_locked_items_query_base.h deleted file mode 100644 index a25b03c3d9..0000000000 --- a/common/dialogs/dialog_locked_items_query_base.h +++ /dev/null @@ -1,60 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_LOCKED_ITEMS_QUERY_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_LOCKED_ITEMS_QUERY_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxStaticBitmap* m_icon; - wxStaticText* m_messageLine1; - wxStaticText* m_messageLine2; - wxCheckBox* m_doNotShowBtn; - wxButton* m_overrideBtn; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - - // Virtual event handlers, override them in your derived class - virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } - virtual void onOverrideLocks( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Locked Items"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - - ~DIALOG_LOCKED_ITEMS_QUERY_BASE(); - -}; - diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 4d4bc635e5..89edb9c972 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -95,15 +95,14 @@ bool EDA_DRAW_FRAME::m_openGLFailureOccured = false; EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, - long aStyle, const wxString& aFrameName, - const EDA_IU_SCALE& aIuScale ) : - KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, - aIuScale ), + long aStyle, const wxString& aFrameName, const EDA_IU_SCALE& aIuScale ) : + KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, aIuScale ), m_socketServer( nullptr ), m_lastToolbarIconSize( 0 ) { m_gridSelectBox = nullptr; m_zoomSelectBox = nullptr; + m_overrideLocksCb = nullptr; m_searchPane = nullptr; m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS; @@ -197,65 +196,70 @@ void EDA_DRAW_FRAME::configureToolbars() // Grid selection auto gridSelectorFactory = - [this]( ACTION_TOOLBAR* aToolbar ) - { - if( !m_gridSelectBox ) + [this]( ACTION_TOOLBAR* aToolbar ) { - m_gridSelectBox = new wxChoice( aToolbar, ID_ON_GRID_SELECT, wxDefaultPosition, - wxDefaultSize, 0, nullptr ); - } + if( !m_gridSelectBox ) + m_gridSelectBox = new wxChoice( aToolbar, ID_ON_GRID_SELECT ); - UpdateGridSelectBox(); + UpdateGridSelectBox(); - aToolbar->Add( m_gridSelectBox ); - }; + aToolbar->Add( m_gridSelectBox ); + }; RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::gridSelect, gridSelectorFactory ); // Zoom selection auto zoomSelectorFactory = - [this]( ACTION_TOOLBAR* aToolbar ) - { - if( !m_zoomSelectBox ) + [this]( ACTION_TOOLBAR* aToolbar ) { - m_zoomSelectBox = new wxChoice( aToolbar, ID_ON_ZOOM_SELECT, wxDefaultPosition, - wxDefaultSize, 0, nullptr ); - } + if( !m_zoomSelectBox ) + m_zoomSelectBox = new wxChoice( aToolbar, ID_ON_ZOOM_SELECT ); - UpdateZoomSelectBox(); - aToolbar->Add( m_zoomSelectBox ); - }; + UpdateZoomSelectBox(); + aToolbar->Add( m_zoomSelectBox ); + }; RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::zoomSelect, zoomSelectorFactory ); + + auto overrideLocksFactory = + [this]( ACTION_TOOLBAR* aToolbar ) + { + if( !m_overrideLocksCb ) + m_overrideLocksCb = new wxCheckBox( aToolbar, wxID_ANY, _( "Override locks" ) ); + + aToolbar->Add( m_overrideLocksCb ); + }; + + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::overrideLocks, overrideLocksFactory ); } void EDA_DRAW_FRAME::ReleaseFile() { - if( m_file_checker.get() != nullptr ) + if( m_file_checker ) m_file_checker->UnlockFile(); } bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName ) { - // We need to explicitly reset here to get the deletion before - // we create a new unique_ptr that may be for the same file + // We need to explicitly reset here to get the deletion before we create a new unique_ptr that + // may be for the same file. m_file_checker.reset(); m_file_checker = std::make_unique( aFileName ); if( !m_file_checker->Valid() && m_file_checker->IsLockedByMe() ) { - // If we cannot acquire the lock but we appear to be the one who - // locked it, check to see if there is another KiCad instance running. - // If there is not, then we can override the lock. This could happen if - // KiCad crashed or was interrupted + // If we cannot acquire the lock but we appear to be the one who locked it, check to see if + // there is another KiCad instance running. If there is not, then we can override the lock. + // This could happen if KiCad crashed or was interrupted. if( !Pgm().SingleInstance()->IsAnotherRunning() ) m_file_checker->OverrideLock(); } - // If the file is valid, return true. This could mean that the file is - // locked or it could mean that the file is read-only + + // If the file is valid, return true. This could mean that the file is locked or it could mean + // that the file is read-only. return m_file_checker->Valid(); } @@ -451,9 +455,9 @@ void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ) wxCHECK( config(), /* void */ ); const std::vector& zoomList = config()->m_Window.zoom_factors; - int curr_selection = m_zoomSelectBox->GetSelection(); - int new_selection = 0; // select zoom auto - double last_approx = 1e9; // large value to start calculation + int curr_selection = m_zoomSelectBox->GetSelection(); + int new_selection = 0; // select zoom auto + double last_approx = 1e9; // large value to start calculation // Search for the nearest available value to the current zoom setting, and select it for( size_t jj = 0; jj < zoomList.size(); ++jj ) @@ -465,7 +469,7 @@ void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ) last_approx = rel_error; // zoom IDs in m_zoomSelectBox start with 1 (leaving 0 for auto-zoom choice) - new_selection = jj + 1; + new_selection = (int) jj + 1; } } @@ -514,6 +518,15 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) } +bool EDA_DRAW_FRAME::GetOverrideLocks() const +{ + if( m_overrideLocksCb ) + return m_overrideLocksCb->GetValue(); + + return false; +} + + bool EDA_DRAW_FRAME::IsGridVisible() const { wxCHECK( config(), true ); @@ -579,14 +592,14 @@ void EDA_DRAW_FRAME::UpdateZoomSelectBox() wxCHECK( config(), /* void */ ); - for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i ) + for( unsigned ii = 0; ii < config()->m_Window.zoom_factors.size(); ++ii ) { - double current = config()->m_Window.zoom_factors[i]; + double current = config()->m_Window.zoom_factors[ii]; m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) ); if( zoom == current ) - m_zoomSelectBox->SetSelection( i + 1 ); + m_zoomSelectBox->SetSelection( (int) ii + 1 ); } } @@ -604,8 +617,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) UpdateStatusBar(); m_canvas->Refresh(); - // Needed on Windows because clicking on m_zoomSelectBox remove the focus from m_canvas - // (Windows specific + // Needed on Windows (only) because clicking on m_zoomSelectBox removes the focus from m_canvas m_canvas->SetFocus(); } @@ -675,8 +687,7 @@ void EDA_DRAW_FRAME::DisplayGridMsg() GRID_SETTINGS& gridSettings = m_toolManager->GetSettings()->m_Window.grid; int currentIdx = m_toolManager->GetSettings()->m_Window.grid.last_size_idx; - msg.Printf( _( "grid %s" ), - gridSettings.grids[currentIdx].UserUnitsMessageText( this, false ) ); + msg.Printf( _( "grid %s" ), gridSettings.grids[currentIdx].UserUnitsMessageText( this, false ) ); SetStatusText( msg, 4 ); } @@ -792,8 +803,7 @@ void EDA_DRAW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) m_findReplaceData->findString = aCfg->m_FindReplace.find_string; m_findReplaceData->replaceString = aCfg->m_FindReplace.replace_string; - m_findReplaceData->matchMode = - static_cast( aCfg->m_FindReplace.match_mode ); + m_findReplaceData->matchMode = static_cast( aCfg->m_FindReplace.match_mode ); m_findReplaceData->matchCase = aCfg->m_FindReplace.match_case; m_findReplaceData->searchAndReplace = aCfg->m_FindReplace.search_and_replace; @@ -827,23 +837,17 @@ void EDA_DRAW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) aCfg->m_FindReplace.replace_history.clear(); for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ ) - { aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() ); - } for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ ) - { - aCfg->m_FindReplace.replace_history.push_back( - m_replaceStringHistoryList[ i ].ToStdString() ); - } + aCfg->m_FindReplace.replace_history.push_back( m_replaceStringHistoryList[ i ].ToStdString() ); // Save the units used in this frame if( m_toolManager ) { if( COMMON_TOOLS* cmnTool = m_toolManager->GetTool() ) { - aCfg->m_System.last_imperial_units = - static_cast( cmnTool->GetLastImperialUnits() ); + aCfg->m_System.last_imperial_units = static_cast( cmnTool->GetLastImperialUnits() ); aCfg->m_System.last_metric_units = static_cast( cmnTool->GetLastMetricUnits() ); } } @@ -966,13 +970,12 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas // Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some // have a fixed type, or do not have a option to set the canvas type (they inherit from // a parent frame) - static std::vector s_allowedFrames = - { - FRAME_SCH, FRAME_SCH_SYMBOL_EDITOR, - FRAME_PCB_EDITOR, FRAME_FOOTPRINT_EDITOR, - FRAME_GERBER, - FRAME_PL_EDITOR - }; + static std::vector s_allowedFrames = { FRAME_SCH, + FRAME_SCH_SYMBOL_EDITOR, + FRAME_PCB_EDITOR, + FRAME_FOOTPRINT_EDITOR, + FRAME_GERBER, + FRAME_PL_EDITOR }; if( !alg::contains( s_allowedFrames, m_ident ) ) return false; @@ -983,8 +986,7 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas return false; } - if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE - || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST ) + if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST ) { wxASSERT( false ); return false; @@ -1063,7 +1065,7 @@ void EDA_DRAW_FRAME::FocusOnLocation( const VECTOR2I& aPos ) BOX2D r = GetCanvas()->GetView()->GetViewport(); // Center if we're off the current view, or within 10% of its edge - r.Inflate( - (int) r.GetWidth() / 10 ); + r.Inflate( - r.GetWidth() / 10.0 ); if( !r.Contains( aPos ) ) centerView = true; @@ -1072,9 +1074,8 @@ void EDA_DRAW_FRAME::FocusOnLocation( const VECTOR2I& aPos ) for( wxWindow* dialog : findDialogs() ) { - dialogScreenRects.emplace_back( - ToVECTOR2D( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ) ), - ToVECTOR2D( dialog->GetSize() ) ); + dialogScreenRects.emplace_back( ToVECTOR2D( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ) ), + ToVECTOR2D( dialog->GetSize() ) ); } // Center if we're behind an obscuring dialog, or within 10% of its edge @@ -1094,8 +1095,7 @@ void EDA_DRAW_FRAME::FocusOnLocation( const VECTOR2I& aPos ) } catch( const Clipper2Lib::Clipper2Exception& e ) { - wxFAIL_MSG( wxString::Format( wxT( "Clipper2 exception occurred centering object: %s" ), - e.what() ) ); + wxFAIL_MSG( wxString::Format( wxT( "Clipper2 exception occurred centering object: %s" ), e.what() ) ); } } @@ -1103,9 +1103,6 @@ void EDA_DRAW_FRAME::FocusOnLocation( const VECTOR2I& aPos ) } -static const wxString productName = wxT( "KiCad E.D.A. " ); - - void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo, const wxString& aSheetName, const wxString& aSheetPath, const wxString& aFileName, const TITLE_BLOCK& aTitleBlock, diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index 5f36808c78..68198c6edb 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -202,51 +202,40 @@ void ACTION_TOOLBAR_PALETTE::onCharHook( wxKeyEvent& aEvent ) } -ACTION_TOOLBAR::ACTION_TOOLBAR( EDA_BASE_FRAME* parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long style ) : - wxAuiToolBar( parent, id, pos, size, style ), - m_paletteTimer( nullptr ), - m_auiManager( nullptr ), - m_toolManager( parent->GetToolManager() ), - m_palette( nullptr ) +ACTION_TOOLBAR::ACTION_TOOLBAR( EDA_BASE_FRAME* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, + long style ) : + wxAuiToolBar( parent, id, pos, size, style ), + m_paletteTimer( nullptr ), + m_auiManager( nullptr ), + m_toolManager( parent->GetToolManager() ), + m_palette( nullptr ) { m_paletteTimer = new wxTimer( this ); SetArtProvider( new WX_AUI_TOOLBAR_ART ); - Connect( wxEVT_COMMAND_TOOL_CLICKED, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolEvent ), - nullptr, this ); - Connect( wxEVT_AUITOOLBAR_RIGHT_CLICK, - wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolRightClick ), - nullptr, this ); - Connect( wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onItemDrag ), - nullptr, this ); + Connect( wxEVT_COMMAND_TOOL_CLICKED, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolEvent ), nullptr, this ); + Connect( wxEVT_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onRightClick ), nullptr, this ); + Connect( wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onItemDrag ), nullptr, this ); Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, this ); Connect( wxEVT_LEFT_UP, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, this ); - Connect( m_paletteTimer->GetId(), wxEVT_TIMER, - wxTimerEventHandler( ACTION_TOOLBAR::onTimerDone ), nullptr, this ); + Connect( m_paletteTimer->GetId(), wxEVT_TIMER, wxTimerEventHandler( ACTION_TOOLBAR::onTimerDone ), nullptr, this ); - Bind( wxEVT_SYS_COLOUR_CHANGED, - wxSysColourChangedEventHandler( ACTION_TOOLBAR::onThemeChanged ), this ); + Bind( wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler( ACTION_TOOLBAR::onThemeChanged ), this ); } ACTION_TOOLBAR::~ACTION_TOOLBAR() { - Disconnect( wxEVT_COMMAND_TOOL_CLICKED, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolEvent ), - nullptr, this ); - Disconnect( wxEVT_AUITOOLBAR_RIGHT_CLICK, - wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolRightClick ), nullptr, this ); - Disconnect( wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onItemDrag ), - nullptr, this ); - Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, - this ); + Disconnect( wxEVT_COMMAND_TOOL_CLICKED, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onToolEvent ), nullptr, this ); + Disconnect( wxEVT_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onRightClick ), nullptr, this ); + Disconnect( wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEventHandler( ACTION_TOOLBAR::onItemDrag ), nullptr, this ); + Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, this ); Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( ACTION_TOOLBAR::onMouseClick ), nullptr, this ); - Disconnect( m_paletteTimer->GetId(), wxEVT_TIMER, - wxTimerEventHandler( ACTION_TOOLBAR::onTimerDone ), nullptr, this ); + Disconnect( m_paletteTimer->GetId(), wxEVT_TIMER, wxTimerEventHandler( ACTION_TOOLBAR::onTimerDone ), nullptr, + this ); - Unbind( wxEVT_SYS_COLOUR_CHANGED, - wxSysColourChangedEventHandler( ACTION_TOOLBAR::onThemeChanged ), this ); + Unbind( wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler( ACTION_TOOLBAR::onThemeChanged ), this ); delete m_paletteTimer; @@ -290,7 +279,7 @@ void ACTION_TOOLBAR::ApplyConfiguration( const TOOLBAR_CONFIGURATION& aConfig ) break; case TOOLBAR_ITEM_TYPE::TB_GROUP: - { + { // Add a group of items to the toolbar std::string groupName = item.m_GroupName.ToStdString(); std::vector tools; @@ -330,10 +319,10 @@ void ACTION_TOOLBAR::ApplyConfiguration( const TOOLBAR_CONFIGURATION& aConfig ) AddGroup( std::move( group ) ); break; - } + } case TOOLBAR_ITEM_TYPE::CONTROL: - { + { // Add a custom control to the toolbar EDA_BASE_FRAME* frame = static_cast( GetParent() ); ACTION_TOOLBAR_CONTROL_FACTORY* factory = frame->GetCustomToolbarControlFactory( item.m_ControlName ); @@ -347,10 +336,10 @@ void ACTION_TOOLBAR::ApplyConfiguration( const TOOLBAR_CONFIGURATION& aConfig ) // The factory functions are responsible for adding the controls to the toolbar themselves (*factory)( this ); break; - } + } case TOOLBAR_ITEM_TYPE::TOOL: - { + { TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( item.m_ActionName ); if( !action ) @@ -361,7 +350,7 @@ void ACTION_TOOLBAR::ApplyConfiguration( const TOOLBAR_CONFIGURATION& aConfig ) Add( *action ); break; - } + } } } @@ -552,8 +541,7 @@ void ACTION_TOOLBAR::UpdateControlWidth( int aID ) // The control on the toolbar is stored inside the window field of the item wxControl* control = dynamic_cast( item->GetWindow() ); - wxASSERT_MSG( control, - wxString::Format( "No control located in toolbar item with ID %d", aID ) ); + wxASSERT_MSG( control, wxString::Format( "No control located in toolbar item with ID %d", aID ) ); // Update the size the item has stored using the best size of the control control->InvalidateBestSize(); @@ -604,10 +592,7 @@ void ACTION_TOOLBAR::SetToolBitmap( const TOOL_ACTION& aAction, const wxBitmap& wxAuiToolBarItem* tb_item = wxAuiToolBar::FindTool( toolId ); if( tb_item ) - { - tb_item->SetDisabledBitmap( - aBitmap.ConvertToDisabled( KIPLATFORM::UI::IsDarkTheme() ? 70 : 255 ) ); - } + tb_item->SetDisabledBitmap( aBitmap.ConvertToDisabled( KIPLATFORM::UI::IsDarkTheme() ? 70 : 255 ) ); } @@ -668,7 +653,7 @@ void ACTION_TOOLBAR::onToolEvent( wxAuiToolBarEvent& aEvent ) } -void ACTION_TOOLBAR::onToolRightClick( wxAuiToolBarEvent& aEvent ) +void ACTION_TOOLBAR::onRightClick( wxAuiToolBarEvent& aEvent ) { int toolId = aEvent.GetToolId(); @@ -676,9 +661,8 @@ void ACTION_TOOLBAR::onToolRightClick( wxAuiToolBarEvent& aEvent ) if( toolId == -1 ) return; - // Ensure that the ID used maps to a proper tool ID. - // If right-clicked on a group item, this is needed to get the ID of the currently selected - // action, since the event's ID is that of the group. + // Ensure that the ID maps to a proper tool ID. If right-clicked on a group item, this is needed + // to get the ID of the currently selected action, since the event's ID is that of the group. const auto actionIt = m_toolActions.find( toolId ); if( actionIt != m_toolActions.end() ) @@ -891,8 +875,7 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem ) // We handle the button events in the toolbar class, so connect the right handler m_palette->SetGroup( group ); m_palette->SetButtonSize( toolRect ); - m_palette->Connect( wxEVT_BUTTON, wxCommandEventHandler( ACTION_TOOLBAR::onPaletteEvent ), - nullptr, this ); + m_palette->Connect( wxEVT_BUTTON, wxCommandEventHandler( ACTION_TOOLBAR::onPaletteEvent ), nullptr, this ); // Add the actions in the group to the palette and update their enabled state @@ -991,13 +974,9 @@ bool ACTION_TOOLBAR::KiRealize() } if( retval && RealizeHelper( dc, true ) ) - { m_horzHintSize = GetSize(); - } else - { retval = false; - } } else { @@ -1008,13 +987,9 @@ bool ACTION_TOOLBAR::KiRealize() } if( retval && RealizeHelper( dc, false ) ) - { m_vertHintSize = GetSize(); - } else - { retval = false; - } } Refresh( false ); @@ -1038,9 +1013,8 @@ void ACTION_TOOLBAR::RefreshBitmaps() { wxAuiToolBarItem* tool = FindTool( pair.first ); - tool->SetBitmap( - KiBitmapBundle( pair.second->GetIcon(), - Pgm().GetCommonSettings()->m_Appearance.toolbar_icon_size ) ); + tool->SetBitmap( KiBitmapBundle( pair.second->GetIcon(), + Pgm().GetCommonSettings()->m_Appearance.toolbar_icon_size ) ); tool->SetDisabledBitmap( KiDisabledBitmapBundle( pair.second->GetIcon() ) ); } @@ -1064,3 +1038,6 @@ ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::layerSelector( "control.LayerSel ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::unitSelector( "control.UnitSelector", _( "Symbol unit selector" ), _( "Displays the current unit" ) ); + +ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::overrideLocks( "control.OverrideLocks", _( "Override locks" ), + _( "Allow moving of locked items with the mouse" ) ); \ No newline at end of file diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 75d7dc54dc..41b4c50ef8 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -335,14 +335,14 @@ public: /** * @return the current track width list index. */ - inline unsigned GetTrackWidthIndex() const { return m_trackWidthIndex; } + inline int GetTrackWidthIndex() const { return m_trackWidthIndex; } /** * Set the current track width list index to \a aIndex. * * @param aIndex is the track width list index. */ - void SetTrackWidthIndex( unsigned aIndex ); + void SetTrackWidthIndex( int aIndex ); /** * @return the current track width according to the selected options @@ -359,33 +359,20 @@ public: * * @param aWidth is the new track width. */ - inline void SetCustomTrackWidth( int aWidth ) - { - m_customTrackWidth = aWidth; - } - - /** - * @return Current custom width for a track. - */ - inline int GetCustomTrackWidth() const - { - return m_customTrackWidth; - } + inline void SetCustomTrackWidth( int aWidth ) { m_customTrackWidth = aWidth; } + inline int GetCustomTrackWidth() const { return m_customTrackWidth; } /** * @return the current via size list index. */ - inline unsigned GetViaSizeIndex() const - { - return m_viaSizeIndex; - } + inline int GetViaSizeIndex() const { return m_viaSizeIndex; } /** * Set the current via size list index to \a aIndex. * * @param aIndex is the via size list index. */ - void SetViaSizeIndex( unsigned aIndex ); + void SetViaSizeIndex( int aIndex ); /** * @return the current via size, according to the selected options @@ -467,12 +454,12 @@ public: /** * @return the current diff pair dimension list index. */ - inline unsigned GetDiffPairIndex() const { return m_diffPairIndex; } + inline int GetDiffPairIndex() const { return m_diffPairIndex; } /** * @param aIndex is the diff pair dimensions list index to set. */ - void SetDiffPairIndex( unsigned aIndex ); + void SetDiffPairIndex( int aIndex ); /** * Sets custom track width for differential pairs (i.e. not available in netclasses or @@ -806,14 +793,14 @@ public: bool m_UseHeightForLengthCalcs; private: - VECTOR2I m_auxOrigin; ///< origin for plot exports - VECTOR2I m_gridOrigin; ///< origin for grid offsets + VECTOR2I m_auxOrigin; ///< origin for plot exports + VECTOR2I m_gridOrigin; ///< origin for grid offsets // Indices into the trackWidth, viaSizes and diffPairDimensions lists. // The 0 index is always the current netclass value(s) - unsigned m_trackWidthIndex; - unsigned m_viaSizeIndex; - unsigned m_diffPairIndex; + int m_trackWidthIndex; + int m_viaSizeIndex; + int m_diffPairIndex; // Custom values for track/via sizes (specified via dialog instead of netclass or lists) bool m_useCustomTrackVia; diff --git a/include/dialogs/dialog_locked_items_query.h b/include/dialogs/dialog_locked_items_query.h deleted file mode 100644 index 4b1844b65e..0000000000 --- a/include/dialogs/dialog_locked_items_query.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright The 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 - */ - -#pragma once - -#include -#include - - -class DIALOG_LOCKED_ITEMS_QUERY : public DIALOG_LOCKED_ITEMS_QUERY_BASE -{ -public: - /// This has no dependencies on calling wxFrame derivative, such as PCB_BASE_FRAME. - DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent, std::size_t aLockedItemCount, - PCBNEW_SETTINGS::LOCKING_OPTIONS& aLockingOptions ); - - int ShowModal() override; - -private: - void onOverrideLocks( wxCommandEvent& event ) override; - -private: - PCBNEW_SETTINGS::LOCKING_OPTIONS& m_lockingOptions; -}; diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 2d77b94a36..c40ba8cef7 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -368,6 +368,8 @@ public: */ virtual void DisplayGridMsg(); + bool GetOverrideLocks() const; + void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; @@ -587,6 +589,7 @@ protected: wxChoice* m_gridSelectBox; wxChoice* m_zoomSelectBox; + wxCheckBox* m_overrideLocksCb; std::unique_ptr m_findReplaceData; wxArrayString m_findStringHistoryList; diff --git a/include/tool/action_toolbar.h b/include/tool/action_toolbar.h index b30aa7ad82..fb12cf32e2 100644 --- a/include/tool/action_toolbar.h +++ b/include/tool/action_toolbar.h @@ -378,7 +378,7 @@ protected: void onToolEvent( wxAuiToolBarEvent& aEvent ); ///< Handle a right-click on a menu item - void onToolRightClick( wxAuiToolBarEvent& aEvent ); + void onRightClick( wxAuiToolBarEvent& aEvent ); ///< Handle the button select inside the palette void onPaletteEvent( wxCommandEvent& aEvent ); @@ -468,6 +468,7 @@ public: static ACTION_TOOLBAR_CONTROL ipcScripting; static ACTION_TOOLBAR_CONTROL unitSelector; static ACTION_TOOLBAR_CONTROL layerSelector; + static ACTION_TOOLBAR_CONTROL overrideLocks; }; #endif diff --git a/pcbnew/autorouter/autoplace_tool.cpp b/pcbnew/autorouter/autoplace_tool.cpp index 14f5ccd72b..d454ea465c 100644 --- a/pcbnew/autorouter/autoplace_tool.cpp +++ b/pcbnew/autorouter/autoplace_tool.cpp @@ -23,11 +23,8 @@ #include -#include #include #include -#include -#include #include #include "ar_autoplacer.h" @@ -76,38 +73,14 @@ int AUTOPLACE_TOOL::autoplace( std::vector& aFootprints ) return 0; } - int locked_count = std::count_if( aFootprints.begin(), aFootprints.end(), - [](FOOTPRINT* fp) - { - return fp->IsLocked(); - } ); - - PCBNEW_SETTINGS* settings = frame()->GetPcbNewSettings(); - - if( locked_count > 0 && !settings->m_LockingOptions.m_sessionSkipPrompts ) + if( !frame()->GetOverrideLocks() ) { - DIALOG_LOCKED_ITEMS_QUERY dlg( frame(), locked_count, settings->m_LockingOptions ); - - switch( dlg.ShowModal() ) - { - case wxID_OK: - // Remove locked items from aFootprints - aFootprints.erase( std::remove_if( aFootprints.begin(), aFootprints.end(), - []( FOOTPRINT* fp ) - { - return fp->IsLocked(); - } ), - aFootprints.end() ); - break; - - case wxID_CANCEL: - // cancel operation - return 0; - - case wxID_APPLY: - // Proceed with all items (do nothing) - break; - } + aFootprints.erase( std::remove_if( aFootprints.begin(), aFootprints.end(), + []( FOOTPRINT* fp ) + { + return fp->IsLocked(); + } ), + aFootprints.end() ); } Activate(); diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index 036c8a6dff..8429525f60 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -1339,9 +1339,9 @@ int BOARD_DESIGN_SETTINGS::GetSmallestClearanceValue() const } -void BOARD_DESIGN_SETTINGS::SetViaSizeIndex( unsigned aIndex ) +void BOARD_DESIGN_SETTINGS::SetViaSizeIndex( int aIndex ) { - m_viaSizeIndex = std::min( aIndex, (unsigned) m_ViasDimensionsList.size() ); + m_viaSizeIndex = std::min( aIndex, (int) m_ViasDimensionsList.size() ); m_useCustomTrackVia = false; } @@ -1372,9 +1372,9 @@ int BOARD_DESIGN_SETTINGS::GetCurrentViaDrill() const } -void BOARD_DESIGN_SETTINGS::SetTrackWidthIndex( unsigned aIndex ) +void BOARD_DESIGN_SETTINGS::SetTrackWidthIndex( int aIndex ) { - m_trackWidthIndex = std::min( aIndex, (unsigned) m_TrackWidthList.size() ); + m_trackWidthIndex = std::min( aIndex, (int) m_TrackWidthList.size() ); m_useCustomTrackVia = false; } @@ -1390,13 +1390,10 @@ int BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth() const } -void BOARD_DESIGN_SETTINGS::SetDiffPairIndex( unsigned aIndex ) +void BOARD_DESIGN_SETTINGS::SetDiffPairIndex( int aIndex ) { if( !m_DiffPairDimensionsList.empty() ) - { - m_diffPairIndex = std::min( aIndex, - static_cast( m_DiffPairDimensionsList.size() ) - 1 ); - } + m_diffPairIndex = std::min( aIndex, (int) m_DiffPairDimensionsList.size() - 1 ); m_useCustomDiffPair = false; } diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index 45b0590996..eb16f32cf1 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -197,11 +197,11 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi { if( ( isArc || isTrack ) && m_trackWidthCtrl->GetStringSelection() != INDETERMINATE_ACTION ) { - unsigned int prevTrackWidthIndex = brdSettings.GetTrackWidthIndex(); + int prevTrackWidthIndex = brdSettings.GetTrackWidthIndex(); int trackWidthIndex = m_trackWidthCtrl->GetSelection(); if( trackWidthIndex >= 0 ) - brdSettings.SetTrackWidthIndex( static_cast( trackWidthIndex + 1 ) ); + brdSettings.SetTrackWidthIndex( trackWidthIndex + 1 ); m_parent->SetTrackSegmentWidth( aItem, aUndoList, false ); @@ -210,11 +210,11 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi if( isVia && m_viaSizesCtrl->GetStringSelection() != INDETERMINATE_ACTION ) { - unsigned int prevViaSizeIndex = brdSettings.GetViaSizeIndex(); - int viaSizeIndex = m_viaSizesCtrl->GetSelection(); + int prevViaSizeIndex = brdSettings.GetViaSizeIndex(); + int viaSizeIndex = m_viaSizesCtrl->GetSelection(); if( viaSizeIndex >= 0 ) - brdSettings.SetViaSizeIndex( static_cast( viaSizeIndex + 1 ) ); + brdSettings.SetViaSizeIndex( viaSizeIndex + 1 ); m_parent->SetTrackSegmentWidth( aItem, aUndoList, false ); @@ -228,20 +228,16 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi switch( m_annularRingsCtrl->GetSelection() ) { case 0: - v->Padstack().SetUnconnectedLayerMode( - PADSTACK::UNCONNECTED_LAYER_MODE::KEEP_ALL ); + v->Padstack().SetUnconnectedLayerMode( PADSTACK::UNCONNECTED_LAYER_MODE::KEEP_ALL ); break; case 1: - v->Padstack().SetUnconnectedLayerMode( - PADSTACK::UNCONNECTED_LAYER_MODE::REMOVE_EXCEPT_START_AND_END ); + v->Padstack().SetUnconnectedLayerMode( PADSTACK::UNCONNECTED_LAYER_MODE::REMOVE_EXCEPT_START_AND_END ); break; case 2: - v->Padstack().SetUnconnectedLayerMode( - PADSTACK::UNCONNECTED_LAYER_MODE::REMOVE_ALL ); + v->Padstack().SetUnconnectedLayerMode( PADSTACK::UNCONNECTED_LAYER_MODE::REMOVE_ALL ); break; case 3: - v->Padstack().SetUnconnectedLayerMode( - PADSTACK::UNCONNECTED_LAYER_MODE::START_END_ONLY ); + v->Padstack().SetUnconnectedLayerMode( PADSTACK::UNCONNECTED_LAYER_MODE::START_END_ONLY ); break; default: break; diff --git a/pcbnew/dialogs/panel_edit_options.cpp b/pcbnew/dialogs/panel_edit_options.cpp index 5c87baa7e7..5f79fbe0b5 100644 --- a/pcbnew/dialogs/panel_edit_options.cpp +++ b/pcbnew/dialogs/panel_edit_options.cpp @@ -80,10 +80,7 @@ static int arcEditModeToComboIndex( ARC_EDIT_MODE aMode ) case ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS: return 0; case ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION: return 1; case ARC_EDIT_MODE::KEEP_CENTER_ENDS_ADJUST_ANGLE: return 2; - - default: - wxFAIL_MSG( "Invalid ARC_EDIT_MODE" ); - return 0; + default: wxFAIL_MSG( "Invalid ARC_EDIT_MODE" ); return 0; } }; @@ -116,7 +113,6 @@ void PANEL_EDIT_OPTIONS::loadPCBSettings( PCBNEW_SETTINGS* aCfg ) m_rbFlipTopBottom->SetValue( true ); m_allowFreePads->SetValue( aCfg->m_AllowFreePads ); - m_overrideLocks->SetValue( aCfg->m_LockingOptions.m_sessionSkipPrompts ); m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones ); m_magneticPadChoice->SetSelection( static_cast( aCfg->m_MagneticItems.pads ) ); @@ -202,7 +198,6 @@ bool PANEL_EDIT_OPTIONS::TransferDataFromWindow() : FLIP_DIRECTION::TOP_BOTTOM; cfg->m_AllowFreePads = m_allowFreePads->GetValue(); - cfg->m_LockingOptions.m_sessionSkipPrompts = m_overrideLocks->GetValue(); cfg->m_AutoRefillZones = m_autoRefillZones->GetValue(); cfg->m_MagneticItems.pads = static_cast( m_magneticPadChoice->GetSelection() ); diff --git a/pcbnew/dialogs/panel_edit_options_base.cpp b/pcbnew/dialogs/panel_edit_options_base.cpp index 9282643994..9ac30ed5d2 100644 --- a/pcbnew/dialogs/panel_edit_options_base.cpp +++ b/pcbnew/dialogs/panel_edit_options_base.cpp @@ -111,11 +111,6 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i m_sizerBoardEdit->Add( m_allowFreePads, 0, wxTOP|wxBOTTOM|wxLEFT, 5 ); - m_overrideLocks = new wxCheckBox( this, wxID_ANY, _("Do not prompt for lock overrides for this session"), wxDefaultPosition, wxDefaultSize, 0 ); - m_overrideLocks->SetToolTip( _("If checked, no prompt will be shown when attempting to edit locked items. This setting is reset when KiCad restarts.") ); - - m_sizerBoardEdit->Add( m_overrideLocks, 0, wxBOTTOM|wxLEFT, 5 ); - bMiddleLeftSizer->Add( m_sizerBoardEdit, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); diff --git a/pcbnew/dialogs/panel_edit_options_base.fbp b/pcbnew/dialogs/panel_edit_options_base.fbp index 181c798b0b..412f0d5bea 100644 --- a/pcbnew/dialogs/panel_edit_options_base.fbp +++ b/pcbnew/dialogs/panel_edit_options_base.fbp @@ -1046,71 +1046,6 @@ - - 5 - wxBOTTOM|wxLEFT - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Do not prompt for lock overrides for this session - - 0 - - - 0 - - 1 - m_overrideLocks - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - If checked, no prompt will be shown when attempting to edit locked items. This setting is reset when KiCad restarts. - - wxFILTER_NONE - wxDefaultValidator - - - - - - diff --git a/pcbnew/dialogs/panel_edit_options_base.h b/pcbnew/dialogs/panel_edit_options_base.h index aa2d93bfe4..3e542d8c86 100644 --- a/pcbnew/dialogs/panel_edit_options_base.h +++ b/pcbnew/dialogs/panel_edit_options_base.h @@ -55,7 +55,6 @@ class PANEL_EDIT_OPTIONS_BASE : public RESETTABLE_PANEL wxRadioButton* m_rbFlipLeftRight; wxRadioButton* m_rbFlipTopBottom; wxCheckBox* m_allowFreePads; - wxCheckBox* m_overrideLocks; wxStaticText* m_staticText32; wxStaticLine* m_staticline4; wxBoxSizer* m_mouseCmdsWinLin; diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index 66dec21daa..e95e10e339 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -36,8 +36,6 @@ #include #include #include -#include -#include #include #include "../3d-viewer/3d_viewer/eda_3d_viewer_settings.h" @@ -76,8 +74,6 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_MagneticItems.graphics = false; m_MagneticItems.allLayers = false; - m_LockingOptions.m_sessionSkipPrompts = false; - m_params.emplace_back( new PARAM( "aui.show_layer_manager", &m_AuiPanels.show_layer_manager, true ) ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index 6de61781eb..c7ced5daeb 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -214,12 +214,6 @@ public: bool m_Live3DRefresh; }; - struct LOCKING_OPTIONS - { - // Skip lock prompts for the current session - bool m_sessionSkipPrompts; - }; - PCBNEW_SETTINGS(); virtual ~PCBNEW_SETTINGS(); @@ -276,8 +270,6 @@ public: wxString m_LastFootprintLibDir; wxString m_LastFootprint3dDir; - LOCKING_OPTIONS m_LockingOptions; - ACTION_PLUGIN_SETTINGS_LIST m_VisibleActionPlugins; }; diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 946bc3fe7d..1d5b652867 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -353,6 +352,9 @@ std::optional PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarCo config.AppendSeparator() .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect ); + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::overrideLocks ); + break; } @@ -616,8 +618,7 @@ void PCB_EDIT_FRAME::ToggleNetInspector() if( m_show_net_inspector ) { - SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width, - -1 ); + SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width, -1 ); m_netInspectorPanel->OnShowPanel(); } else diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 9e7e567c1d..46d86e7b42 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -831,7 +831,7 @@ int BOARD_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent ) if( routerTool && routerTool->IsToolActive() && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR ) { - int widthIndex = (int) bds.GetDiffPairIndex() + 1; + int widthIndex = bds.GetDiffPairIndex() + 1; // If we go past the last track width entry in the list, start over at the beginning if( widthIndex >= (int) bds.m_DiffPairDimensionsList.size() ) @@ -844,7 +844,7 @@ int BOARD_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent ) } else { - int widthIndex = (int) bds.GetTrackWidthIndex(); + int widthIndex = bds.GetTrackWidthIndex(); if( routerTool && routerTool->IsToolActive() && routerTool->Router()->GetState() == PNS::ROUTER::RouterState::ROUTE_TRACK @@ -913,11 +913,11 @@ int BOARD_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent ) if( routerTool && routerTool->IsToolActive() && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR ) { - int widthIndex = (int) bds.GetDiffPairIndex() - 1; + int widthIndex = bds.GetDiffPairIndex() - 1; // If we get to the lowest entry start over at the highest if( widthIndex < 0 ) - widthIndex = (int) bds.m_DiffPairDimensionsList.size() - 1; + widthIndex = bds.m_DiffPairDimensionsList.size() - 1; bds.SetDiffPairIndex( widthIndex ); bds.UseCustomDiffPairDimensions( false ); @@ -926,7 +926,7 @@ int BOARD_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent ) } else { - int widthIndex = (int) bds.GetTrackWidthIndex(); + int widthIndex = bds.GetTrackWidthIndex(); if( routerTool && routerTool->IsToolActive() && routerTool->Router()->GetState() == PNS::ROUTER::RouterState::ROUTE_TRACK @@ -993,7 +993,7 @@ int BOARD_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent ) } else { - int sizeIndex = (int) bds.GetViaSizeIndex() + 1; + int sizeIndex = bds.GetViaSizeIndex() + 1; // If we go past the last via entry in the list, start over at the beginning if( sizeIndex >= (int) bds.m_ViasDimensionsList.size() ) @@ -1054,11 +1054,11 @@ int BOARD_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent ) // If there are more, cycle through them backwards if( bds.m_ViasDimensionsList.size() > 0 ) { - sizeIndex = (int) bds.GetViaSizeIndex() - 1; + sizeIndex = bds.GetViaSizeIndex() - 1; // If we get to the lowest entry start over at the highest if( sizeIndex < 0 ) - sizeIndex = (int) bds.m_ViasDimensionsList.size() - 1; + sizeIndex = bds.m_ViasDimensionsList.size() - 1; } bds.SetViaSizeIndex( sizeIndex ); diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 20a0266017..7dea5e7eec 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -51,7 +51,6 @@ using namespace std::placeholders; #include #include #include -#include #include #include #include @@ -713,10 +712,8 @@ PCB_SELECTION& PCB_SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aCl m_frame->GetCanvas()->ForceRefresh(); } - if( aConfirmLockedItems ) + if( aConfirmLockedItems && !m_frame->GetOverrideLocks() ) { - std::vector lockedItems; - for( EDA_ITEM* item : m_selection ) { if( !item->IsBOARD_ITEM() ) @@ -734,33 +731,7 @@ PCB_SELECTION& PCB_SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aCl RECURSE_MODE::RECURSE ); if( boardItem->IsLocked() || lockedDescendant ) - lockedItems.push_back( boardItem ); - } - - PCBNEW_SETTINGS* settings = m_frame->GetPcbNewSettings(); - - if( !lockedItems.empty() ) - { - DIALOG_LOCKED_ITEMS_QUERY dlg( frame(), lockedItems.size(), settings->m_LockingOptions ); - - switch( dlg.ShowModal() ) - { - case wxID_OK: - // remove locked items from selection - for( BOARD_ITEM* item : lockedItems ) - unselect( item ); - - break; - - case wxID_CANCEL: - // cancel operation - ClearSelection(); - break; - - case wxID_APPLY: - // continue with operation with current selection - break; - } + unselect( boardItem ); } } @@ -770,8 +741,8 @@ PCB_SELECTION& PCB_SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aCl const GENERAL_COLLECTORS_GUIDE PCB_SELECTION_TOOL::getCollectorsGuide() const { - GENERAL_COLLECTORS_GUIDE guide( board()->GetVisibleLayers(), - (PCB_LAYER_ID) view()->GetTopLayer(), view() ); + GENERAL_COLLECTORS_GUIDE guide( board()->GetVisibleLayers(), (PCB_LAYER_ID) view()->GetTopLayer(), + view() ); bool padsDisabled = !board()->IsElementVisible( LAYER_PADS ); @@ -857,8 +828,8 @@ bool PCB_SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag, } catch( const std::exception& exc ) { - wxLogWarning( wxS( "Exception \"%s\" occurred attempting to guess selection " - "candidates." ), exc.what() ); + wxLogWarning( wxS( "Exception '%s' occurred attempting to guess selection candidates." ), + exc.what() ); return false; } } @@ -1085,7 +1056,7 @@ int PCB_SELECTION_TOOL::SelectRectArea( const TOOL_EVENT& aEvent ) greedySelection = !greedySelection; m_frame->GetCanvas()->SetCurrentCursor( !greedySelection ? KICURSOR::SELECT_WINDOW - : KICURSOR::SELECT_LASSO ); + : KICURSOR::SELECT_LASSO ); if( evt->IsCancelInteractive() || evt->IsActivate() ) { @@ -1110,9 +1081,8 @@ int PCB_SELECTION_TOOL::SelectRectArea( const TOOL_EVENT& aEvent ) area.SetAdditive( m_drag_additive ); area.SetSubtractive( m_drag_subtractive ); area.SetExclusiveOr( false ); - area.SetMode( greedySelection - ? SELECTION_MODE::TOUCHING_RECTANGLE - : SELECTION_MODE::INSIDE_RECTANGLE ); + area.SetMode( greedySelection ? SELECTION_MODE::TOUCHING_RECTANGLE + : SELECTION_MODE::INSIDE_RECTANGLE ); view->SetVisible( &area, true ); view->Update( &area ); @@ -1297,11 +1267,11 @@ void PCB_SELECTION_TOOL::SelectMultiple( KIGFX::PREVIEW::SELECTION_AREA& aArea, std::unordered_set& newset = group->GetItems(); auto boxContained = - [&]( const BOX2I& aBox ) - { - return boxMode ? selectionBox.Contains( aBox ) - : KIGEOM::BoxHitTest( aArea.GetPoly(), aBox, true ); - }; + [&]( const BOX2I& aBox ) + { + return boxMode ? selectionBox.Contains( aBox ) + : KIGEOM::BoxHitTest( aArea.GetPoly(), aBox, true ); + }; // If we are not greedy and have selected the whole group, add just one item // to allow it to be promoted to the group later @@ -1322,11 +1292,11 @@ void PCB_SELECTION_TOOL::SelectMultiple( KIGFX::PREVIEW::SELECTION_AREA& aArea, } auto hitTest = - [&]( const EDA_ITEM* aItem ) - { - return boxMode ? aItem->HitTest( selectionBox, containedMode ) - : aItem->HitTest( aArea.GetPoly(), containedMode ); - }; + [&]( const EDA_ITEM* aItem ) + { + return boxMode ? aItem->HitTest( selectionBox, containedMode ) + : aItem->HitTest( aArea.GetPoly(), containedMode ); + }; for( const auto& [item, layer] : candidates ) { @@ -1405,8 +1375,7 @@ int PCB_SELECTION_TOOL::disambiguateCursor( const TOOL_EVENT& aEvent ) { wxMouseState keyboardState = wxGetMouseState(); - setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(), - keyboardState.AltDown() ); + setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(), keyboardState.AltDown() ); m_skip_heuristics = true; selectPoint( m_originalCursor, false, &m_canceledMenu ); @@ -1566,9 +1535,7 @@ int PCB_SELECTION_TOOL::unrouteSegment( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selectedItems ) { if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T || item->Type() == PCB_VIA_T ) - { toUnroute.push_back( static_cast( item ) ); - } } // Get the tracks connecting to our starting objects @@ -1720,8 +1687,7 @@ void PCB_SELECTION_TOOL::selectAllConnectedTracks( const std::vectorHasFlag( SKIP_STRUCT ) ) // Skip already visited items continue; - auto connectedItems = connectivity->GetConnectedItems( startItem, - EXCLUDE_ZONES | IGNORE_NETS ); + auto connectedItems = connectivity->GetConnectedItems( startItem, EXCLUDE_ZONES | IGNORE_NETS ); // Build maps of connected items for( BOARD_CONNECTED_ITEM* item : connectedItems ) @@ -1817,14 +1783,9 @@ void PCB_SELECTION_TOOL::selectAllConnectedTracks( const std::vectorsecond->GetLayerSet() ) ).any(); - - bool gotPad = ( padIt != padMap.end() ) - && ( layerSetCu & ( padIt->second->GetLayerSet() ) ).any(); - - bool gotNonStartPad = - gotPad && ( startPadSet.find( padIt->second ) == startPadSet.end() ); + bool gotVia = viaIt != viaMap.end() && ( viaIt->second->GetLayerSet() & layerSetCu ).any(); + bool gotPad = padIt != padMap.end() && ( padIt->second->GetLayerSet() & layerSetCu ).any(); + bool gotNonStartPad = gotPad && ( startPadSet.find( padIt->second ) == startPadSet.end() ); if( aStopCondition == STOP_AT_JUNCTION ) { @@ -2021,16 +1982,17 @@ void PCB_SELECTION_TOOL::selectAllConnectedShapes( const std::vector GENERAL_COLLECTOR collector; GENERAL_COLLECTORS_GUIDE guide = getCollectorsGuide(); - auto searchPoint = [&]( const VECTOR2I& aWhere ) - { - collector.Collect( board(), { PCB_SHAPE_T }, aWhere, guide ); + auto searchPoint = + [&]( const VECTOR2I& aWhere ) + { + collector.Collect( board(), { PCB_SHAPE_T }, aWhere, guide ); - for( EDA_ITEM* item : collector ) - { - if( isExpandableGraphicShape( item ) ) - toSearch.push( static_cast( item ) ); - } - }; + for( EDA_ITEM* item : collector ) + { + if( isExpandableGraphicShape( item ) ) + toSearch.push( static_cast( item ) ); + } + }; while( !toSearch.empty() ) { @@ -2515,8 +2477,7 @@ void PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox( const BOX2I& aBBox ) #ifndef DEFAULT_PCBNEW_CODE // Do the scaled zoom auto bbSize = bbox.Inflate( KiROUND( bbox.GetWidth() * 0.2 ) ).GetSize(); - VECTOR2D screenSize = view->ToWorld( ToVECTOR2D( m_frame->GetCanvas()->GetClientSize() ), - false ); + VECTOR2D screenSize = view->ToWorld( ToVECTOR2D( m_frame->GetCanvas()->GetClientSize() ), false ); // This code tries to come up with a zoom factor that doesn't simply zoom in // to the cross probed component, but instead shows a reasonable amount of the @@ -2609,8 +2570,7 @@ void PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox( const BOX2I& aBBox ) // Use standard KiCad zoom algorithm for parts too wide to fit screen/ ratio = kicadRatio; compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio - wxLogTrace( "CROSS_PROBE_SCALE", - "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio ); + wxLogTrace( "CROSS_PROBE_SCALE", "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio ); } // Now that "compRatioBent" holds our final scaling factor we apply it to the original @@ -3131,21 +3091,18 @@ bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibili if( aItem->GetParentGroup() && aItem->GetParentGroup()->AsEdaItem()->Type() == PCB_GENERATOR_T ) return false; - const ZONE* zone = nullptr; - const PCB_VIA* via = nullptr; - const PAD* pad = nullptr; - const PCB_TEXT* text = nullptr; - const PCB_FIELD* field = nullptr; + const ZONE* zone = nullptr; + const PCB_VIA* via = nullptr; + const PAD* pad = nullptr; + const PCB_TEXT* text = nullptr; + const PCB_FIELD* field = nullptr; const PCB_MARKER* marker = nullptr; // Most footprint children can only be selected in the footprint editor. if( aItem->GetParentFootprint() && !m_isFootprintEditor && !checkVisibilityOnly ) { - if( aItem->Type() != PCB_FIELD_T && aItem->Type() != PCB_PAD_T - && aItem->Type() != PCB_TEXT_T ) - { + if( aItem->Type() != PCB_FIELD_T && aItem->Type() != PCB_PAD_T && aItem->Type() != PCB_TEXT_T ) return false; - } } switch( aItem->Type() ) @@ -3326,9 +3283,8 @@ void PCB_SELECTION_TOOL::select( EDA_ITEM* aItem ) return; } - if( m_enteredGroup && - !PCB_GROUP::WithinScope( static_cast( aItem ), m_enteredGroup, - m_isFootprintEditor ) ) + if( m_enteredGroup && !PCB_GROUP::WithinScope( static_cast( aItem ), m_enteredGroup, + m_isFootprintEditor ) ) { ExitGroup(); } @@ -3454,8 +3410,7 @@ bool PCB_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const } -int PCB_SELECTION_TOOL::hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aItem, - int aMaxDistance ) const +int PCB_SELECTION_TOOL::hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aItem, int aMaxDistance ) const { BOX2D viewportD = getView()->GetViewport(); BOX2I viewport = BOX2ISafe( viewportD ); @@ -3563,12 +3518,12 @@ int PCB_SELECTION_TOOL::hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aIt case PCB_PAD_T: { static_cast( aItem )->Padstack().ForEachUniqueLayer( - [&]( PCB_LAYER_ID aLayer ) - { - int layerDistance = INT_MAX; - aItem->GetEffectiveShape( aLayer )->Collide( loc, aMaxDistance, &layerDistance ); - distance = std::min( distance, layerDistance ); - } ); + [&]( PCB_LAYER_ID aLayer ) + { + int layerDistance = INT_MAX; + aItem->GetEffectiveShape( aLayer )->Collide( loc, aMaxDistance, &layerDistance ); + distance = std::min( distance, layerDistance ); + } ); break; } @@ -3748,8 +3703,8 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector static const LSET silkLayers( { B_SilkS, F_SilkS } ); static const LSET courtyardLayers( { B_CrtYd, F_CrtYd } ); static std::vector singleLayerSilkTypes = { PCB_FIELD_T, - PCB_TEXT_T, PCB_TEXTBOX_T, - PCB_TABLE_T, PCB_TABLECELL_T, + PCB_TEXT_T, PCB_TEXTBOX_T, + PCB_TABLE_T, PCB_TABLECELL_T, PCB_SHAPE_T }; if( ADVANCED_CFG::GetCfg().m_PcbSelectionVisibilityRatio != 1.0 ) @@ -4322,43 +4277,41 @@ int PCB_SELECTION_TOOL::SelectTable( const TOOL_EVENT& aEvent ) void PCB_SELECTION_TOOL::setTransitions() { - Go( &PCB_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::Main, ACTIONS::selectionActivate.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::CursorSelection, ACTIONS::selectionCursor.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::ClearSelection, ACTIONS::selectionClear.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::Main, ACTIONS::selectionActivate.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::CursorSelection, ACTIONS::selectionCursor.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::ClearSelection, ACTIONS::selectionClear.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::AddItemToSel, ACTIONS::selectItem.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::AddItemsToSel, ACTIONS::selectItems.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::RemoveItemFromSel, ACTIONS::unselectItem.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::RemoveItemsFromSel, ACTIONS::unselectItems.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::ReselectItem, ACTIONS::reselectItem.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::SelectionMenu, ACTIONS::selectionMenu.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::AddItemToSel, ACTIONS::selectItem.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::AddItemsToSel, ACTIONS::selectItems.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::RemoveItemFromSel, ACTIONS::unselectItem.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::RemoveItemsFromSel, ACTIONS::unselectItems.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::ReselectItem, ACTIONS::reselectItem.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::SelectionMenu, ACTIONS::selectionMenu.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::filterSelection, PCB_ACTIONS::filterSelection.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::expandConnection, PCB_ACTIONS::selectConnection.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::unrouteSelected, PCB_ACTIONS::unrouteSelected.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::unrouteSegment, PCB_ACTIONS::unrouteSegment.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::selectNet, PCB_ACTIONS::selectNet.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::selectNet, PCB_ACTIONS::deselectNet.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::selectUnconnected, PCB_ACTIONS::selectUnconnected.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::grabUnconnected, PCB_ACTIONS::grabUnconnected.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::syncSelection, PCB_ACTIONS::syncSelection.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::syncSelectionWithNets, - PCB_ACTIONS::syncSelectionWithNets.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::selectSameSheet, PCB_ACTIONS::selectSameSheet.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::selectSheetContents, - PCB_ACTIONS::selectOnSheetFromEeschema.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::updateSelection, EVENTS::SelectedItemsModified ); - Go( &PCB_SELECTION_TOOL::updateSelection, EVENTS::SelectedItemsMoved ); - Go( &PCB_SELECTION_TOOL::SelectColumns, ACTIONS::selectColumns.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::SelectRows, ACTIONS::selectRows.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::SelectTable, ACTIONS::selectTable.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::filterSelection, PCB_ACTIONS::filterSelection.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::expandConnection, PCB_ACTIONS::selectConnection.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::unrouteSelected, PCB_ACTIONS::unrouteSelected.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::unrouteSegment, PCB_ACTIONS::unrouteSegment.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::selectNet, PCB_ACTIONS::selectNet.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::selectNet, PCB_ACTIONS::deselectNet.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::selectUnconnected, PCB_ACTIONS::selectUnconnected.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::grabUnconnected, PCB_ACTIONS::grabUnconnected.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::syncSelection, PCB_ACTIONS::syncSelection.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::syncSelectionWithNets, PCB_ACTIONS::syncSelectionWithNets.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::selectSameSheet, PCB_ACTIONS::selectSameSheet.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::selectSheetContents, PCB_ACTIONS::selectOnSheetFromEeschema.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::updateSelection, EVENTS::SelectedItemsModified ); + Go( &PCB_SELECTION_TOOL::updateSelection, EVENTS::SelectedItemsMoved ); + Go( &PCB_SELECTION_TOOL::SelectColumns, ACTIONS::selectColumns.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::SelectRows, ACTIONS::selectRows.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::SelectTable, ACTIONS::selectTable.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::SetSelectPoly, ACTIONS::selectSetLasso.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::SetSelectRect, ACTIONS::selectSetRect.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::SelectAll, ACTIONS::selectAll.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::UnselectAll, ACTIONS::unselectAll.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::SetSelectPoly, ACTIONS::selectSetLasso.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::SetSelectRect, ACTIONS::selectSetRect.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::SelectAll, ACTIONS::selectAll.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::UnselectAll, ACTIONS::unselectAll.MakeEvent() ); - Go( &PCB_SELECTION_TOOL::disambiguateCursor, EVENTS::DisambiguatePoint ); + Go( &PCB_SELECTION_TOOL::disambiguateCursor, EVENTS::DisambiguatePoint ); } diff --git a/pcbnew/tools/pcb_selection_tool.h b/pcbnew/tools/pcb_selection_tool.h index 42ae4668e4..df052a80eb 100644 --- a/pcbnew/tools/pcb_selection_tool.h +++ b/pcbnew/tools/pcb_selection_tool.h @@ -97,8 +97,8 @@ public: * If the set is empty, performs the legacy-style hover selection. * * @param aClientFilter A callback to allow tool- or action-specific filtering. - * @param aConfirmLockedItems [optional] Signals that the user shall be asked if they want - * to drop locked items from the selection or override the locks. + * @param aConfirmLockedItems [optional] Signals that locked items should be skipped/included + * according PCB_EDIT_FRAME::GetOverrideLocks(). */ PCB_SELECTION& RequestSelection( CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems = false );