CHANGED: Rework lock overrides architecture.

We now use a checkbox in the aux toolbar rather
than a query dialog (with "remember setting" checkbox).
This commit is contained in:
Jeff Young 2025-08-13 09:33:57 +01:00
parent 9883c798fe
commit 60b4202766
24 changed files with 243 additions and 1186 deletions

View File

@ -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

View File

@ -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 <dialogs/dialog_locked_items_query.h>
#include <bitmaps.h>
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;
}

View File

@ -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 );
}

View File

@ -1,462 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="18"/>
<object class="Project" expanded="true">
<property name="code_generation">C++</property>
<property name="cpp_class_decoration"></property>
<property name="cpp_disconnect_events">1</property>
<property name="cpp_event_generation">connect</property>
<property name="cpp_help_provider">none</property>
<property name="cpp_namespace"></property>
<property name="cpp_precompiled_header"></property>
<property name="cpp_use_array_enum">0</property>
<property name="cpp_use_enum">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="file">dialog_locked_items_query_base</property>
<property name="first_id">1000</property>
<property name="internationalize">1</property>
<property name="lua_skip_events">1</property>
<property name="lua_ui_table">UI</property>
<property name="name">dialog_locked_items_query</property>
<property name="path">.</property>
<property name="php_disconnect_events">0</property>
<property name="php_disconnect_mode">source_name</property>
<property name="php_skip_events">1</property>
<property name="python_disconnect_events">0</property>
<property name="python_disconnect_mode">source_name</property>
<property name="python_image_path_wrapper_function_name"></property>
<property name="python_indent_with_spaces"></property>
<property name="python_skip_events">1</property>
<property name="relative_path">1</property>
<property name="use_microsoft_bom">0</property>
<property name="use_native_eol">0</property>
<object class="Dialog" expanded="true">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_LOCKED_ITEMS_QUERY_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Locked Items</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnInitDialog">OnInitDlg</event>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">bSizerMain</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="true">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer4</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">10</property>
<object class="sizeritem" expanded="true">
<property name="border">10</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticBitmap" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer">0</property>
<property name="aui_name"></property>
<property name="aui_position">0</property>
<property name="aui_row">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_icon</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">bSizer4</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer">0</property>
<property name="aui_name"></property>
<property name="aui_position">0</property>
<property name="aui_row">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">The selection contains %zu locked items.</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_messageLine1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer">0</property>
<property name="aui_name"></property>
<property name="aui_position">0</property>
<property name="aui_row">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">These items will be skipped unless you override the locks.</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_messageLine2</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="true">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer">0</property>
<property name="aui_name"></property>
<property name="aui_position">0</property>
<property name="aui_row">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Remember decision for this session.</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_doNotShowBtn</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Remember the option selected for the remainder of this session.&#x0A;This dialog will not be shown again until KiCad is restarted.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">bButtonSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="false">
<property name="border">10</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="false">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer">0</property>
<property name="aui_name"></property>
<property name="aui_position">0</property>
<property name="aui_row">0</property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Override Locks</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_overrideBtn</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Override locks and apply the operation on all the items selected.&#x0A;Any locked items will remain locked after the operation is complete.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onOverrideLocks</event>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxTOP</property>
<property name="proportion">1</property>
<object class="wxStdDialogButtonSizer" expanded="true">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/statbmp.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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();
};

View File

@ -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<LOCKFILE>( 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<double>& 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<EDA_SEARCH_MATCH_MODE>( aCfg->m_FindReplace.match_mode );
m_findReplaceData->matchMode = static_cast<EDA_SEARCH_MATCH_MODE>( 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<COMMON_TOOLS>() )
{
aCfg->m_System.last_imperial_units =
static_cast<int>( cmnTool->GetLastImperialUnits() );
aCfg->m_System.last_imperial_units = static_cast<int>( cmnTool->GetLastImperialUnits() );
aCfg->m_System.last_metric_units = static_cast<int>( 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<FRAME_T> s_allowedFrames =
{
FRAME_SCH, FRAME_SCH_SYMBOL_EDITOR,
FRAME_PCB_EDITOR, FRAME_FOOTPRINT_EDITOR,
FRAME_GERBER,
FRAME_PL_EDITOR
};
static std::vector<FRAME_T> 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,

View File

@ -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<const TOOL_ACTION*> 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<EDA_BASE_FRAME*>( 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<wxControl*>( 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" ) );

View File

@ -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;

View File

@ -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 <dialog_locked_items_query_base.h>
#include <pcbnew_settings.h>
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;
};

View File

@ -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<EDA_SEARCH_DATA> m_findReplaceData;
wxArrayString m_findStringHistoryList;

View File

@ -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

View File

@ -23,11 +23,8 @@
#include <board_commit.h>
#include <dialogs/dialog_locked_items_query.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/pcb_selection_tool.h>
#include <widgets/wx_infobar.h>
#include <widgets/wx_progress_reporters.h>
#include "ar_autoplacer.h"
@ -76,38 +73,14 @@ int AUTOPLACE_TOOL::autoplace( std::vector<FOOTPRINT*>& 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();

View File

@ -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<unsigned>( m_DiffPairDimensionsList.size() ) - 1 );
}
m_diffPairIndex = std::min( aIndex, (int) m_DiffPairDimensionsList.size() - 1 );
m_useCustomDiffPair = false;
}

View File

@ -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<unsigned>( 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<unsigned>( 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;

View File

@ -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<int>( 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<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );

View File

@ -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 );

View File

@ -1046,71 +1046,6 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="false">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="false">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer">0</property>
<property name="aui_name"></property>
<property name="aui_position">0</property>
<property name="aui_row">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Do not prompt for lock overrides for this session</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_overrideLocks</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">If checked, no prompt will be shown when attempting to edit locked items. This setting is reset when KiCad restarts.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="false">

View File

@ -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;

View File

@ -36,8 +36,6 @@
#include <settings/settings_manager.h>
#include <wx/config.h>
#include <wx/tokenzr.h>
#include <zones.h>
#include <widgets/ui_common.h>
#include <base_units.h>
#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<bool>( "aui.show_layer_manager",
&m_AuiPanels.show_layer_manager, true ) );

View File

@ -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;
};

View File

@ -48,7 +48,6 @@
#include <tool/common_tools.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/pcb_selection_tool.h>
#include <widgets/appearance_controls.h>
#include <widgets/pcb_design_block_pane.h>
#include <widgets/layer_box_selector.h>
@ -353,6 +352,9 @@ std::optional<TOOLBAR_CONFIGURATION> 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

View File

@ -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 );

View File

@ -51,7 +51,6 @@ using namespace std::placeholders;
#include <zone.h>
#include <collectors.h>
#include <dialog_filter_selection.h>
#include <dialogs/dialog_locked_items_query.h>
#include <class_draw_panel_gal.h>
#include <view/view_controls.h>
#include <gal/painter.h>
@ -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<BOARD_ITEM*> 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<EDA_ITEM*>& 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<BOARD_CONNECTED_ITEM*>( item ) );
}
}
// Get the tracks connecting to our starting objects
@ -1720,8 +1687,7 @@ void PCB_SELECTION_TOOL::selectAllConnectedTracks( const std::vector<BOARD_CONNE
if( startItem->HasFlag( 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::vector<BOARD_CONNE
auto viaIt = viaMap.find( pt );
auto padIt = padMap.find( pt );
bool gotVia = ( viaIt != viaMap.end() )
&& ( layerSetCu & ( viaIt->second->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<PCB_SHAPE*>
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<PCB_SHAPE*>( item ) );
}
};
for( EDA_ITEM* item : collector )
{
if( isExpandableGraphicShape( item ) )
toSearch.push( static_cast<PCB_SHAPE*>( 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<BOARD_ITEM*>( aItem ), m_enteredGroup,
m_isFootprintEditor ) )
if( m_enteredGroup && !PCB_GROUP::WithinScope( static_cast<BOARD_ITEM*>( 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<PAD*>( 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<KICAD_T> 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 );
}

View File

@ -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 );