diff --git a/bitmap2component/CMakeLists.txt b/bitmap2component/CMakeLists.txt index ebf6a5a954..65f98ae1ff 100644 --- a/bitmap2component/CMakeLists.txt +++ b/bitmap2component/CMakeLists.txt @@ -10,7 +10,6 @@ include_directories( BEFORE ${INC_BEFORE} ) include_directories( ${INC_AFTER} ) set( BITMAP2COMPONENT_SRCS - ${CMAKE_SOURCE_DIR}/common/base_units.cpp ${CMAKE_SOURCE_DIR}/common/single_top.cpp bitmap2cmp_main.cpp bitmap2cmp_settings.cpp diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 8690928b5b..8ae63df59c 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -163,6 +163,8 @@ set( COMMON_DLG_SRCS dialogs/dialog_edit_library_tables.cpp dialogs/dialog_global_lib_table_config.cpp dialogs/dialog_global_lib_table_config_base.cpp + dialogs/dialog_grid_settings.cpp + dialogs/dialog_grid_settings_base.cpp dialogs/dialog_hotkey_list.cpp dialogs/dialog_image_editor.cpp dialogs/dialog_image_editor_base.cpp diff --git a/common/base_units.cpp b/common/base_units.cpp index 296ff4a70e..3ee7bd2dca 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -41,12 +41,16 @@ #include +#if defined( PCBNEW ) || defined( CVPCB ) || defined( EESCHEMA ) || defined( GERBVIEW ) || defined( PL_EDITOR ) #define IU_TO_MM( x ) ( x / IU_PER_MM ) #define IU_TO_IN( x ) ( x / IU_PER_MILS / 1000 ) #define IU_TO_MILS( x ) ( x / IU_PER_MILS ) #define MM_TO_IU( x ) ( x * IU_PER_MM ) #define IN_TO_IU( x ) ( x * IU_PER_MILS * 1000 ) #define MILS_TO_IU( x ) ( x * IU_PER_MILS ) +#else +#error "Cannot resolve internal units due to no definition of EESCHEMA, CVPCB or PCBNEW." +#endif // Helper function to print a float number without using scientific notation diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/common/dialogs/dialog_grid_settings.cpp similarity index 60% rename from pcbnew/dialogs/dialog_set_grid.cpp rename to common/dialogs/dialog_grid_settings.cpp index 412b5d930d..8341568d20 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/common/dialogs/dialog_grid_settings.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2020 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 @@ -21,48 +21,18 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include #include -#include -#include -#include -#include +#include #include -#include -#include -#include // for KiROUND +#include #include -// Max values for grid size -static const int MAX_GRID_SIZE = KiROUND( 1000.0 * IU_PER_MM ); -static const int MIN_GRID_SIZE = KiROUND( 0.001 * IU_PER_MM ); - -class DIALOG_SET_GRID : public DIALOG_SET_GRID_BASE -{ - PCB_BASE_FRAME* m_parent; - -public: - /// This has no dependencies on calling wxFrame derivative, such as PCB_BASE_FRAME. - DIALOG_SET_GRID( PCB_BASE_FRAME* aParent ); - - bool TransferDataFromWindow() override; - bool TransferDataToWindow() override; - -private: - void OnResetGridOrgClick( wxCommandEvent& event ) override; - - UNIT_BINDER m_gridOriginX; - UNIT_BINDER m_gridOriginY; - UNIT_BINDER m_userGridX; - UNIT_BINDER m_userGridY; -}; - - -DIALOG_SET_GRID::DIALOG_SET_GRID( PCB_BASE_FRAME* aParent ): - DIALOG_SET_GRID_BASE( aParent ), +DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( EDA_DRAW_FRAME* aParent ): + DIALOG_GRID_SETTINGS_BASE( aParent ), m_parent( aParent ), m_gridOriginX( aParent, m_staticTextGridPosX, m_GridOriginXCtrl, m_TextPosXUnits ), m_gridOriginY( aParent, m_staticTextGridPosY, m_GridOriginYCtrl, m_TextPosYUnits ), @@ -71,9 +41,23 @@ DIALOG_SET_GRID::DIALOG_SET_GRID( PCB_BASE_FRAME* aParent ): { wxArrayString grids; GRID_MENU::BuildChoiceList( &grids, m_parent->config(), GetUserUnits() != EDA_UNITS::INCHES ); + m_currentGridCtrl->Append( grids ); m_grid1Ctrl->Append( grids ); m_grid2Ctrl->Append( grids ); + if( m_parent->IsType( FRAME_SCH ) + || m_parent->IsType( FRAME_SCH_LIB_EDITOR ) + || m_parent->IsType( FRAME_SCH_VIEWER ) + || m_parent->IsType( FRAME_SCH_VIEWER_MODAL ) + || m_parent->IsType( FRAME_SIMULATOR ) ) + { + m_book->SetSelection( 1 ); + } + else + { + m_book->SetSelection( 0 ); + } + m_sdbSizerOK->SetDefault(); // set OK button as default response to 'Enter' key SetInitialFocus( m_GridOriginXCtrl ); @@ -84,25 +68,24 @@ DIALOG_SET_GRID::DIALOG_SET_GRID( PCB_BASE_FRAME* aParent ): } -bool DIALOG_SET_GRID::TransferDataFromWindow() +bool DIALOG_GRID_SETTINGS::TransferDataFromWindow() { // Validate new settings - if( !m_userGridX.Validate( MIN_GRID_SIZE, MAX_GRID_SIZE ) ) + if( !m_userGridX.Validate( 0.001, 1000.0, EDA_UNITS::MILLIMETRES ) ) return false; - if( !m_userGridY.Validate( MIN_GRID_SIZE, MAX_GRID_SIZE ) ) + if( !m_userGridY.Validate( 0.001, 1000.0, EDA_UNITS::MILLIMETRES ) ) return false; // Apply the new settings GRID_SETTINGS& gridCfg = m_parent->config()->m_Window.grid; - // Because grid origin is saved in board, show as modified - m_parent->OnModify(); + gridCfg.last_size_idx = m_currentGridCtrl->GetSelection(); m_parent->SetGridOrigin( wxPoint( m_gridOriginX.GetValue(), m_gridOriginY.GetValue() ) ); gridCfg.user_grid_x = StringFromValue( GetUserUnits(), m_userGridX.GetValue(), true, true ); gridCfg.user_grid_y = StringFromValue( GetUserUnits(), m_userGridY.GetValue(), true, true ); - m_parent->Settings().m_FastGrid1 = m_grid1Ctrl->GetSelection(); - m_parent->Settings().m_FastGrid2 = m_grid2Ctrl->GetSelection(); + gridCfg.fast_grid_1 = m_grid1Ctrl->GetSelection(); + gridCfg.fast_grid_2 = m_grid2Ctrl->GetSelection(); // Notify GAL TOOL_MANAGER* mgr = m_parent->GetToolManager(); @@ -115,18 +98,20 @@ bool DIALOG_SET_GRID::TransferDataFromWindow() } -bool DIALOG_SET_GRID::TransferDataToWindow() +bool DIALOG_GRID_SETTINGS::TransferDataToWindow() { - GRID_SETTINGS& settings = m_parent->config()->m_Window.grid; + GRID_SETTINGS& gridCfg = m_parent->config()->m_Window.grid; - m_userGridX.SetValue( ValueFromString( GetUserUnits(), settings.user_grid_x, true ) ); - m_userGridY.SetValue( ValueFromString( GetUserUnits(), settings.user_grid_y, true ) ); + m_currentGridCtrl->SetSelection( m_parent->config()->m_Window.grid.last_size_idx ); + + m_userGridX.SetValue( ValueFromString( GetUserUnits(), gridCfg.user_grid_x, true ) ); + m_userGridY.SetValue( ValueFromString( GetUserUnits(), gridCfg.user_grid_y, true ) ); m_gridOriginX.SetValue( m_parent->GetGridOrigin().x ); m_gridOriginY.SetValue( m_parent->GetGridOrigin().y ); - m_grid1Ctrl->SetSelection( m_parent->Settings().m_FastGrid1 ); - m_grid2Ctrl->SetSelection( m_parent->Settings().m_FastGrid2 ); + m_grid1Ctrl->SetSelection( gridCfg.fast_grid_1 ); + m_grid2Ctrl->SetSelection( gridCfg.fast_grid_2 ); int hk1 = ACTIONS::gridFast1.GetHotKey(); int hk2 = ACTIONS::gridFast2.GetHotKey(); @@ -137,19 +122,10 @@ bool DIALOG_SET_GRID::TransferDataToWindow() } -void DIALOG_SET_GRID::OnResetGridOrgClick( wxCommandEvent& event ) +void DIALOG_GRID_SETTINGS::OnResetGridOriginClick( wxCommandEvent& event ) { m_gridOriginX.SetValue( 0 ); m_gridOriginY.SetValue( 0 ); } -void PCB_BASE_EDIT_FRAME::OnGridSettings( wxCommandEvent& event ) -{ - DIALOG_SET_GRID dlg( this ); - - dlg.ShowModal(); - - UpdateStatusBar(); - GetCanvas()->Refresh(); -} diff --git a/common/dialogs/dialog_grid_settings.h b/common/dialogs/dialog_grid_settings.h new file mode 100644 index 0000000000..652b25692e --- /dev/null +++ b/common/dialogs/dialog_grid_settings.h @@ -0,0 +1,51 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef DIALOG_GRID_SETTINGS_H +#define DIALOG_GRID_SETTINGS_H + +#include +#include + + +class DIALOG_GRID_SETTINGS : public DIALOG_GRID_SETTINGS_BASE +{ + EDA_DRAW_FRAME* m_parent; + +public: + /// This has no dependencies on calling wxFrame derivative, such as PCB_BASE_FRAME. + DIALOG_GRID_SETTINGS( EDA_DRAW_FRAME* aParent ); + + bool TransferDataFromWindow() override; + bool TransferDataToWindow() override; + +private: + void OnResetGridOriginClick( wxCommandEvent& event ) override; + + UNIT_BINDER m_gridOriginX; + UNIT_BINDER m_gridOriginY; + UNIT_BINDER m_userGridX; + UNIT_BINDER m_userGridY; +}; + +#endif // DIALOG_GRID_SETTINGS_H \ No newline at end of file diff --git a/pcbnew/dialogs/dialog_set_grid_base.cpp b/common/dialogs/dialog_grid_settings_base.cpp similarity index 78% rename from pcbnew/dialogs/dialog_set_grid_base.cpp rename to common/dialogs/dialog_grid_settings_base.cpp index 7d10567315..88266c452c 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.cpp +++ b/common/dialogs/dialog_grid_settings_base.cpp @@ -5,11 +5,11 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_set_grid_base.h" +#include "dialog_grid_settings_base.h" /////////////////////////////////////////////////////////////////////////// -DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +DIALOG_GRID_SETTINGS_BASE::DIALOG_GRID_SETTINGS_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 ); @@ -19,8 +19,11 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con wxBoxSizer* bUpperSizer; bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); + m_book = new wxSimplebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + wxPanel* gridOriginPage; + gridOriginPage = new wxPanel( m_book, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxStaticBoxSizer* sbLeftSizer; - sbLeftSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Grid Origin") ), wxVERTICAL ); + sbLeftSizer = new wxStaticBoxSizer( new wxStaticBox( gridOriginPage, wxID_ANY, _("Grid Origin") ), wxVERTICAL ); wxFlexGridSizer* fgSizerGridOrigin; fgSizerGridOrigin = new wxFlexGridSizer( 2, 3, 0, 0 ); @@ -54,7 +57,27 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con sbLeftSizer->Add( fgSizerGridOrigin, 0, wxEXPAND|wxALL, 5 ); - bUpperSizer->Add( sbLeftSizer, 1, wxEXPAND|wxALL, 5 ); + gridOriginPage->SetSizer( sbLeftSizer ); + gridOriginPage->Layout(); + sbLeftSizer->Fit( gridOriginPage ); + m_book->AddPage( gridOriginPage, _("a page"), false ); + wxPanel* currentGridPage; + currentGridPage = new wxPanel( m_book, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxStaticBoxSizer* sbSizer5; + sbSizer5 = new wxStaticBoxSizer( new wxStaticBox( currentGridPage, wxID_ANY, _("Current Grid") ), wxVERTICAL ); + + wxArrayString m_currentGridCtrlChoices; + m_currentGridCtrl = new wxChoice( sbSizer5->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_currentGridCtrlChoices, 0 ); + m_currentGridCtrl->SetSelection( 0 ); + sbSizer5->Add( m_currentGridCtrl, 0, wxALL|wxEXPAND, 5 ); + + + currentGridPage->SetSizer( sbSizer5 ); + currentGridPage->Layout(); + sbSizer5->Fit( currentGridPage ); + m_book->AddPage( currentGridPage, _("a page"), false ); + + bUpperSizer->Add( m_book, 1, wxEXPAND | wxALL, 5 ); wxStaticBoxSizer* sbUserGridSizer; sbUserGridSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User Defined Grid") ), wxVERTICAL ); @@ -136,7 +159,7 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con fgSizer3->Add( m_grid2HotKey, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - sbFastSwitchSizer->Add( fgSizer3, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + sbFastSwitchSizer->Add( fgSizer3, 0, wxEXPAND|wxBOTTOM|wxLEFT, 5 ); bSizerMain->Add( sbFastSwitchSizer, 0, wxEXPAND|wxALL, 10 ); @@ -171,18 +194,18 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con bSizerMain->Fit( this ); // Connect Events - this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SET_GRID_BASE::OnInitDlg ) ); - m_buttonReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnResetGridOrgClick ), NULL, this ); - m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnOkClick ), NULL, this ); + this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRID_SETTINGS_BASE::OnInitDlg ) ); + m_buttonReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnResetGridOriginClick ), NULL, this ); + m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnCancelClick ), NULL, this ); + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnOkClick ), NULL, this ); } -DIALOG_SET_GRID_BASE::~DIALOG_SET_GRID_BASE() +DIALOG_GRID_SETTINGS_BASE::~DIALOG_GRID_SETTINGS_BASE() { // Disconnect Events - this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SET_GRID_BASE::OnInitDlg ) ); - m_buttonReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnResetGridOrgClick ), NULL, this ); - m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnOkClick ), NULL, this ); + this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRID_SETTINGS_BASE::OnInitDlg ) ); + m_buttonReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnResetGridOriginClick ), NULL, this ); + m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnCancelClick ), NULL, this ); + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnOkClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_set_grid_base.fbp b/common/dialogs/dialog_grid_settings_base.fbp similarity index 59% rename from pcbnew/dialogs/dialog_set_grid_base.fbp rename to common/dialogs/dialog_grid_settings_base.fbp index 7cb14fcf90..ec7c77b8c8 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.fbp +++ b/common/dialogs/dialog_grid_settings_base.fbp @@ -11,12 +11,12 @@ res UTF-8 connect - dialog_set_grid_base + dialog_grid_settings_base 1000 none 1 - dialog_set_grid + dialog_grid_settings . @@ -43,7 +43,7 @@ wxID_ANY - DIALOG_SET_GRID_BASE + DIALOG_GRID_SETTINGS_BASE -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER @@ -70,402 +70,639 @@ none 5 - wxEXPAND|wxALL + wxEXPAND | wxALL 1 - + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 wxID_ANY - Grid Origin + + 0 + + + 0 - sbLeftSizer - wxVERTICAL - 1 - none - - 5 - wxEXPAND|wxALL - 0 - - 3 - wxBOTH - 1 - - 0 + 1 + m_book + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 - fgSizerGridOrigin - wxFLEX_GROWMODE_SPECIFIED + 1 + gridOriginPage + 1 + + none - 2 - 0 - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - X: - 0 - - 0 - - - 0 - - 1 - m_staticTextGridPosX - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + wxID_ANY + Grid Origin + + sbLeftSizer + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxALL + 0 + + 3 + wxBOTH + 1 + + 0 + + fgSizerGridOrigin + wxFLEX_GROWMODE_SPECIFIED + none + 2 + 0 + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + X: + 0 + + 0 + + + 0 + + 1 + m_staticTextGridPosX + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxEXPAND|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_GridOriginXCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_TextPosXUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Y: + 0 + + 0 + + + 0 + + 1 + m_staticTextGridPosY + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_GridOriginYCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_TextPosYUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + - - 5 - wxEXPAND|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_GridOriginXCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_TextPosXUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Y: - 0 - - 0 - - - 0 - - 1 - m_staticTextGridPosY - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_GridOriginYCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_TextPosYUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + currentGridPage + 1 + + + none + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + wxID_ANY + Current Grid + + sbSizer5 + wxVERTICAL + 1 + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_currentGridCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + @@ -892,7 +1129,7 @@ none 5 - wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + wxEXPAND|wxBOTTOM|wxLEFT 0 3 @@ -1419,7 +1656,7 @@ - OnResetGridOrgClick + OnResetGridOriginClick diff --git a/pcbnew/dialogs/dialog_set_grid_base.h b/common/dialogs/dialog_grid_settings_base.h similarity index 78% rename from pcbnew/dialogs/dialog_set_grid_base.h rename to common/dialogs/dialog_grid_settings_base.h index 792deb7111..fd7babfa26 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.h +++ b/common/dialogs/dialog_grid_settings_base.h @@ -20,7 +20,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -32,19 +34,21 @@ /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_SET_GRID_BASE +/// Class DIALOG_GRID_SETTINGS_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_SET_GRID_BASE : public DIALOG_SHIM +class DIALOG_GRID_SETTINGS_BASE : public DIALOG_SHIM { private: protected: + wxSimplebook* m_book; wxStaticText* m_staticTextGridPosX; wxTextCtrl* m_GridOriginXCtrl; wxStaticText* m_TextPosXUnits; wxStaticText* m_staticTextGridPosY; wxTextCtrl* m_GridOriginYCtrl; wxStaticText* m_TextPosYUnits; + wxChoice* m_currentGridCtrl; wxStaticText* m_staticTextSizeX; wxTextCtrl* m_OptGridSizeX; wxStaticText* m_TextSizeXUnits; @@ -65,15 +69,15 @@ class DIALOG_SET_GRID_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } - virtual void OnResetGridOrgClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnResetGridOriginClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Grid Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_SET_GRID_BASE(); + DIALOG_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Grid Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_GRID_SETTINGS_BASE(); }; diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 611f27d65f..d92477f3da 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -257,10 +257,10 @@ void DIALOG_PAGES_SETTINGS::initDialog() void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event ) { - if( !m_customSizeX.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.x ) ) ) + if( !m_customSizeX.Validate( MIN_PAGE_SIZE_MILS, m_maxPageSizeMils.x, EDA_UNITS::INCHES, true ) ) return; - if( !m_customSizeY.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.y ) ) ) + if( !m_customSizeY.Validate( MIN_PAGE_SIZE_MILS, m_maxPageSizeMils.y, EDA_UNITS::INCHES, true ) ) return; if( SavePageSettings() ) @@ -701,8 +701,8 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() { int lyWidth, lyHeight; - wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE, m_layout_size.x, m_maxPageSizeMils.x ), - Clamp( MIN_PAGE_SIZE, m_layout_size.y, m_maxPageSizeMils.y ) ); + wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE_MILS, m_layout_size.x, m_maxPageSizeMils.x ), + Clamp( MIN_PAGE_SIZE_MILS, m_layout_size.y, m_maxPageSizeMils.y ) ); double lyRatio = clamped_layout_size.x < clamped_layout_size.y ? (double) clamped_layout_size.y / clamped_layout_size.x : diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index e9f4f0c921..476ded36e9 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -55,11 +55,17 @@ #include #include #include - +#include #define FR_HISTORY_LIST_CNT 10 ///< Maximum size of the find/replace history stacks. +BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER ) + EVT_UPDATE_UI( ID_ON_GRID_SELECT, EDA_DRAW_FRAME::OnUpdateSelectGrid ) + EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, EDA_DRAW_FRAME::OnUpdateSelectZoom ) +END_EVENT_TABLE() + + 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 ) : @@ -231,6 +237,30 @@ void EDA_DRAW_FRAME::EraseMsgBox() } +void EDA_DRAW_FRAME::UpdateGridSelectBox() +{ + UpdateStatusBar(); + DisplayUnitsMsg(); + + if( m_gridSelectBox == NULL ) + return; + + // Update grid values with the current units setting. + m_gridSelectBox->Clear(); + wxArrayString gridsList; + + GRID_MENU::BuildChoiceList( &gridsList, config(), GetUserUnits() != EDA_UNITS::INCHES ); + + for( const wxString& grid : gridsList ) + m_gridSelectBox->Append( grid ); + + m_gridSelectBox->Append( wxT( "---" ) ); + m_gridSelectBox->Append( _( "Edit User Grid..." ) ); + + m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx ); +} + + void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ) { // No need to update the grid select box if it doesn't exist or the grid setting change @@ -239,9 +269,9 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ) return; int idx = config()->m_Window.grid.last_size_idx; + idx = std::max( 0, std::min( idx, (int) m_gridSelectBox->GetCount() - 1 ) ); - if( idx >= 0 && idx < int( m_gridSelectBox->GetCount() ) - && idx != m_gridSelectBox->GetSelection() ) + if( idx != m_gridSelectBox->GetSelection() ) m_gridSelectBox->SetSelection( idx ); } @@ -288,6 +318,18 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) } +void EDA_DRAW_FRAME::OnGridSettings( wxCommandEvent& aEvent ) +{ + DIALOG_GRID_SETTINGS dlg( this ); + + if( dlg.ShowModal() == wxID_OK ) + { + UpdateStatusBar(); + GetCanvas()->Refresh(); + } +} + + bool EDA_DRAW_FRAME::IsGridVisible() const { return config()->m_Window.grid.show; @@ -314,12 +356,50 @@ void EDA_DRAW_FRAME::SetGridVisibility( bool aVisible ) } -void EDA_DRAW_FRAME::InitExitKey() +void EDA_DRAW_FRAME::UpdateZoomSelectBox() { - wxAcceleratorEntry entries[1]; - entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT ); - wxAcceleratorTable accel( 1, entries ); - SetAcceleratorTable( accel ); + if( m_zoomSelectBox == NULL ) + return; + + double zoom = m_canvas->GetGAL()->GetZoomFactor() / ZOOM_COEFF; + + m_zoomSelectBox->Clear(); + m_zoomSelectBox->Append( _( "Zoom Auto" ) ); + m_zoomSelectBox->SetSelection( 0 ); + + for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i ) + { + double current = config()->m_Window.zoom_factors[i]; + + m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) ); + + if( zoom == current ) + m_zoomSelectBox->SetSelection( i + 1 ); + } +} + + +void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ) +{ + if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL ) + return; + + int current = 0; // display Auto if no match found + + // check for a match within 1% + double zoom = GetCanvas()->GetGAL()->GetZoomFactor() / ZOOM_COEFF; + + for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); i++ ) + { + if( std::fabs( zoom - config()->m_Window.zoom_factors[i] ) < ( zoom / 100.0 ) ) + { + current = i + 1; + break; + } + } + + if( current != m_zoomSelectBox->GetSelection() ) + m_zoomSelectBox->SetSelection( current ); } @@ -384,6 +464,15 @@ void EDA_DRAW_FRAME::AddStandardSubMenus( TOOL_MENU& aToolMenu ) } +void EDA_DRAW_FRAME::InitExitKey() +{ + wxAcceleratorEntry entries[1]; + entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT ); + wxAcceleratorTable accel( 1, entries ); + SetAcceleratorTable( accel ); +} + + void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg ) { SetStatusText( msg, 6 ); diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index 8023e267a3..722c22ffdf 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -113,14 +113,14 @@ bool APP_SETTINGS_BASE::MigrateFromLegacy( wxConfigBase* aCfg ) migrateFindReplace( aCfg ); - ret &= fromLegacy( aCfg, "canvas_type", "graphics.canvas_type" ); + ret &= fromLegacy( aCfg, "canvas_type", "graphics.canvas_type" ); - ret &= fromLegacy( aCfg, "P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth", - "lib_tree.column_width" ); + ret &= fromLegacy( aCfg, "P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth", + "lib_tree.column_width" ); - ret &= fromLegacy( aCfg, "PrintMonochrome", "printing.monochrome" ); - ret &= fromLegacy( aCfg, "PrintScale", "printing.scale" ); - ret &= fromLegacy( aCfg, "PrintPageFrame", "printing.title_block" ); + ret &= fromLegacy( aCfg, "PrintMonochrome", "printing.monochrome" ); + ret &= fromLegacy( aCfg, "PrintScale", "printing.scale" ); + ret &= fromLegacy( aCfg, "PrintPageFrame", "printing.title_block" ); { nlohmann::json js = nlohmann::json::array(); @@ -194,7 +194,9 @@ bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::stri { bool ret = true; - const std::string gd = "GalDisplayOptions"; + const std::string frameGDO = aFrame + "GalDisplayOptions"; + const std::string cursorPath = aJsonPath + ".cursor"; + const std::string gridPath = aJsonPath + ".grid"; ret &= fromLegacy( aCfg, aFrame + "Maximized", aJsonPath + ".maximized" ); ret &= fromLegacyString( aCfg, aFrame + "MostRecentlyUsedPath", aJsonPath + ".mru_path" ); @@ -204,34 +206,20 @@ bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::stri ret &= fromLegacy( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" ); ret &= fromLegacy( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" ); - ret &= fromLegacy( aCfg, - aFrame + gd + "ForceDisplayCursor", aJsonPath + ".cursor.always_show_cursor" ); - ret &= fromLegacy( aCfg, - aFrame + gd + "CursorFullscreen", aJsonPath + ".cursor.fullscreen_cursor" ); + ret &= fromLegacy( aCfg, frameGDO + "ForceDisplayCursor", cursorPath + ".always_show_cursor" ); + ret &= fromLegacy( aCfg, frameGDO + "CursorFullscreen", cursorPath + ".fullscreen_cursor" ); - ret &= fromLegacy( aCfg, - aFrame + "_LastGridSize", aJsonPath + ".grid.last_size" ); + ret &= fromLegacy( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" ); - double x, y; + ret &= fromLegacy( aCfg, aFrame + "FastGrid1", gridPath + ".fast_grid_1" ); + ret &= fromLegacy( aCfg, aFrame + "FastGrid2", gridPath + ".fast_grid_2" ); - if( aCfg->Read( aFrame + "PcbUserGrid_X", &x ) && aCfg->Read( aFrame + "PcbUserGrid_Y", &y ) ) - { - EDA_UNITS u = static_cast( aCfg->ReadLong( aFrame + "PcbUserGrid_Unit", - static_cast( EDA_UNITS::INCHES ) ) ); - - ( *this )[PointerFromString( ".grid.user_grid_x" )] = StringFromValue( u, x, true, true ); - ( *this )[PointerFromString( ".grid.user_grid_y" )] = StringFromValue( u, y, true, true ); - } - - ret &= fromLegacy( aCfg, - aFrame + gd + "GridAxesEnabled", aJsonPath + ".grid.axes_enabled" ); - ret &= fromLegacy( aCfg, - aFrame + gd + "GridLineWidth", aJsonPath + ".grid.line_width" ); - ret &= fromLegacy( aCfg, - aFrame + gd + "GridMaxDensity", aJsonPath + ".grid.min_spacing" ); - ret &= fromLegacy( aCfg, aFrame + gd + "ShowGrid", aJsonPath + ".grid.show" ); - ret &= fromLegacy( aCfg, aFrame + gd + "GridStyle", aJsonPath + ".grid.style" ); - ret &= fromLegacyColor( aCfg, aFrame + gd + "GridColor", aJsonPath + ".grid.color" ); + ret &= fromLegacy( aCfg, frameGDO + "GridAxesEnabled", gridPath + ".axes_enabled" ); + ret &= fromLegacy( aCfg, frameGDO + "GridLineWidth", gridPath + ".line_width" ); + ret &= fromLegacy( aCfg, frameGDO + "GridMaxDensity", gridPath + ".min_spacing" ); + ret &= fromLegacy( aCfg, frameGDO + "ShowGrid", gridPath + ".show" ); + ret &= fromLegacy( aCfg, frameGDO + "GridStyle", gridPath + ".style" ); + ret &= fromLegacyColor( aCfg, frameGDO + "GridColor", gridPath + ".color" ); return ret; } @@ -262,16 +250,22 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std: m_params.emplace_back( new PARAM( aJsonPath + ".grid.axes_enabled", &aWindow->grid.axes_enabled, false ) ); - m_params.emplace_back( new PARAM( aJsonPath + ".grid.last_size", - &aWindow->grid.last_size_idx, 0 ) ); - m_params.emplace_back( new PARAM_LIST( aJsonPath + ".grid.sizes", &aWindow->grid.sizes, {} ) ); + m_params.emplace_back( new PARAM( aJsonPath + ".grid.last_size", + &aWindow->grid.last_size_idx, 0 ) ); + + m_params.emplace_back( new PARAM( aJsonPath + ".grid.fast_grid_1", + &aWindow->grid.fast_grid_1, 0 ) ); + + m_params.emplace_back( new PARAM( aJsonPath + ".grid.fast_grid_2", + &aWindow->grid.fast_grid_2, 1 ) ); + m_params.emplace_back( new PARAM( aJsonPath + ".grid.user_grid_x", &aWindow->grid.user_grid_x, "12.5 mil" ) ); - m_params.emplace_back( new PARAM( aJsonPath + ".grid.user_grid_x", - &aWindow->grid.user_grid_x, "12.5 mil" ) ); + m_params.emplace_back( new PARAM( aJsonPath + ".grid.user_grid_y", + &aWindow->grid.user_grid_y, "12.5 mil" ) ); m_params.emplace_back( new PARAM( aJsonPath + ".grid.line_width", &aWindow->grid.line_width, 1.0 ) ); diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 63bd643a39..451f609b8c 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -409,6 +409,18 @@ int COMMON_TOOLS::OnGridChanged() } +int COMMON_TOOLS::GridFast1( const TOOL_EVENT& aEvent ) +{ + return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1 ); +} + + +int COMMON_TOOLS::GridFast2( const TOOL_EVENT& aEvent ) +{ + return GridPreset( m_frame->config()->m_Window.grid.fast_grid_2 ); +} + + int COMMON_TOOLS::ToggleGrid( const TOOL_EVENT& aEvent ) { m_frame->SetGridVisibility( !m_frame->IsGridVisible() ); @@ -551,6 +563,8 @@ void COMMON_TOOLS::setTransitions() Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() ); Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() ); Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() ); + Go( &COMMON_TOOLS::GridFast1, ACTIONS::gridFast1.MakeEvent() ); + Go( &COMMON_TOOLS::GridFast2, ACTIONS::gridFast2.MakeEvent() ); Go( &COMMON_TOOLS::ToggleGrid, ACTIONS::toggleGrid.MakeEvent() ); Go( &COMMON_TOOLS::GridProperties, ACTIONS::gridProperties.MakeEvent() ); diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index f9aef2a0e5..eb68f21583 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -168,7 +168,7 @@ void UNIT_BINDER::delayedFocusHandler( wxCommandEvent& ) } -bool UNIT_BINDER::Validate( long long int aMin, long long int aMax, bool setFocusOnError ) +bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits, bool aUseMils ) { wxTextEntry* textEntry = dynamic_cast( m_value ); @@ -179,34 +179,28 @@ bool UNIT_BINDER::Validate( long long int aMin, long long int aMax, bool setFocu return true; } - if( GetValue() < aMin ) + if( GetValue() < From_User_Unit( aUnits, aMin, aUseMils ) ) { m_errorMessage = wxString::Format( _( "%s must be at least %s." ), valueDescriptionFromLabel( m_label ), StringFromValue( m_units, aMin, true ) ); - if( setFocusOnError ) - { - textEntry->SelectAll(); - // Don't focus directly; we might be inside a KillFocus event handler - wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) ); - } + textEntry->SelectAll(); + // Don't focus directly; we might be inside a KillFocus event handler + wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) ); return false; } - if( GetValue() > aMax ) + if( GetValue() > From_User_Unit( aUnits, aMax, aUseMils ) ) { m_errorMessage = wxString::Format( _( "%s must be less than %s." ), valueDescriptionFromLabel( m_label ), StringFromValue( m_units, aMax, true ) ); - if( setFocusOnError ) - { - textEntry->SelectAll(); - // Don't focus directly; we might be inside a KillFocus event handler - wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) ); - } + textEntry->SelectAll(); + // Don't focus directly; we might be inside a KillFocus event handler + wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) ); return false; } diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index e2e8168a8a..53a9446f1c 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -249,7 +249,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar() // Zoom selection choice box. m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT, wxDefaultPosition, wxDefaultSize, 0, NULL ); - updateZoomSelectBox(); + UpdateZoomSelectBox(); m_mainToolBar->AddControl( m_zoomSelectBox ); // after adding the buttons to the toolbar, must call Realize() to reflect diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 2a5ceaf436..953f859203 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -90,8 +90,6 @@ set( EESCHEMA_DLGS dialogs/dialog_schematic_find.cpp dialogs/dialog_schematic_find_base.cpp dialogs/dialog_schematic_setup.cpp - dialogs/dialog_set_grid.cpp - dialogs/dialog_set_grid_base.cpp dialogs/dialog_symbol_remap.cpp dialogs/dialog_symbol_remap_base.cpp dialogs/dialog_update_fields.cpp diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 4af932827e..13a4d6ea82 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -44,11 +44,6 @@ class SCH_EDIT_FRAME; class SCH_TEXT; -// Don't allow text to disappear; it can be difficult to correct if you can't select it -const int MIN_TEXTSIZE = (int)( 0.01 * IU_PER_MM ); -const int MAX_TEXTSIZE = INT_MAX; - - DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) : DIALOG_LABEL_EDITOR_BASE( aParent ), m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ), @@ -392,7 +387,8 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) return false; - if( !m_textSize.Validate( MIN_TEXTSIZE, MAX_TEXTSIZE ) ) + // Don't allow text to disappear; it can be difficult to correct if you can't select it + if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) ) return false; wxString text; diff --git a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp index 58fdee3ef8..767deaeb12 100644 --- a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -427,7 +427,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() { - if( !m_textSize.Validate( Mils2iu( 1 ), Mils2iu( 10000 ) ) ) // 1 mil .. 10 inches + if( !m_textSize.Validate( 1.0, 10000.0, EDA_UNITS::INCHES, true ) ) // 1 mil .. 10 inches return false; SCH_SHEET_PATH currentSheet = m_parent->GetCurrentSheet(); diff --git a/eeschema/dialogs/dialog_set_grid.cpp b/eeschema/dialogs/dialog_set_grid.cpp deleted file mode 100644 index 373ee595d3..0000000000 --- a/eeschema/dialogs/dialog_set_grid.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include - -class DIALOG_SET_GRID : public DIALOG_SET_GRID_BASE -{ - SCH_BASE_FRAME* m_frame; - -public: - DIALOG_SET_GRID( SCH_BASE_FRAME* aParent ); - - bool TransferDataFromWindow() override; - bool TransferDataToWindow() override; -}; - - -DIALOG_SET_GRID::DIALOG_SET_GRID( SCH_BASE_FRAME* aParent ): - DIALOG_SET_GRID_BASE( aParent ), - m_frame( aParent ) -{ - m_sdbSizerOK->SetDefault(); - - FinishDialogSettings(); -} - - -bool DIALOG_SET_GRID::TransferDataToWindow() -{ - int idx = m_frame->config()->m_Window.grid.last_size_idx; - wxArrayString grids; - - GRID_MENU::BuildChoiceList( &grids, m_frame->config(), GetUserUnits() != EDA_UNITS::INCHES ); - - for( const wxString& grid : grids ) - m_choiceGridSize->Append( grid ); - - if( idx >= 0 && idx < int( m_choiceGridSize->GetCount() ) ) - m_choiceGridSize->SetSelection( idx ); - - return true; -} - - -bool DIALOG_SET_GRID::TransferDataFromWindow() -{ - int idx = m_choiceGridSize->GetSelection(); - - m_frame->GetToolManager()->RunAction( "common.Control.gridPreset", true, idx ); - - return true; -} - - -void SCH_BASE_FRAME::OnGridSettings( wxCommandEvent& aEvent ) -{ - DIALOG_SET_GRID dlg( this ); - - dlg.ShowModal(); - - UpdateStatusBar(); - GetCanvas()->Refresh(); -} diff --git a/eeschema/dialogs/dialog_set_grid_base.cpp b/eeschema/dialogs/dialog_set_grid_base.cpp deleted file mode 100644 index 159b4dfceb..0000000000 --- a/eeschema/dialogs/dialog_set_grid_base.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_set_grid_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_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* fgSizer32; - fgSizer32 = new wxFlexGridSizer( 0, 3, 0, 0 ); - fgSizer32->AddGrowableCol( 1 ); - fgSizer32->SetFlexibleDirection( wxBOTH ); - fgSizer32->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_staticText3 = new wxStaticText( this, wxID_ANY, _("&Grid size:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText3->Wrap( -1 ); - fgSizer32->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - wxArrayString m_choiceGridSizeChoices; - m_choiceGridSize = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceGridSizeChoices, 0 ); - m_choiceGridSize->SetSelection( 0 ); - fgSizer32->Add( m_choiceGridSize, 0, wxEXPAND|wxLEFT, 5 ); - - m_units = new wxStaticText( this, wxID_ANY, _("mils"), wxDefaultPosition, wxDefaultSize, 0 ); - m_units->Wrap( -1 ); - fgSizer32->Add( m_units, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - - bSizerMain->Add( fgSizer32, 1, wxEXPAND|wxALL, 15 ); - - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - 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(); - - bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 ); - - - this->SetSizer( bSizerMain ); - this->Layout(); - bSizerMain->Fit( this ); - - // Connect Events - this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SET_GRID_BASE::OnInitDlg ) ); - m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnOkClick ), NULL, this ); -} - -DIALOG_SET_GRID_BASE::~DIALOG_SET_GRID_BASE() -{ - // Disconnect Events - this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SET_GRID_BASE::OnInitDlg ) ); - m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnOkClick ), NULL, this ); - -} diff --git a/eeschema/dialogs/dialog_set_grid_base.fbp b/eeschema/dialogs/dialog_set_grid_base.fbp deleted file mode 100644 index 380451173b..0000000000 --- a/eeschema/dialogs/dialog_set_grid_base.fbp +++ /dev/null @@ -1,478 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_set_grid_base - 1000 - none - 1 - dialog_set_grid - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_SET_GRID_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE - DIALOG_SHIM; dialog_shim.h - Grid Settings - - - - - - - - - - - - - - - - - - - - OnInitDlg - - - - - - - - - - - - - - - - - - - - - - - bSizerMain - wxVERTICAL - none - - 15 - wxEXPAND|wxALL - 1 - - 3 - wxBOTH - 1 - - 0 - -1,-1 - fgSizer32 - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 0 - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - &Grid size: - - 0 - - - 0 - - 1 - m_staticText3 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_choiceGridSize - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mils - - 0 - - - 0 - - 1 - m_units - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline1 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - ; forward_declare - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - OnCancelClick - - - - OnOkClick - - - - - - - - diff --git a/eeschema/dialogs/dialog_set_grid_base.h b/eeschema/dialogs/dialog_set_grid_base.h deleted file mode 100644 index 35a8140850..0000000000 --- a/eeschema/dialogs/dialog_set_grid_base.h +++ /dev/null @@ -1,59 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __DIALOG_SET_GRID_BASE_H__ -#define __DIALOG_SET_GRID_BASE_H__ - -#include -#include -#include -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_SET_GRID_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_SET_GRID_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxStaticText* m_staticText3; - wxChoice* m_choiceGridSize; - wxStaticText* m_units; - wxStaticLine* m_staticline1; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Grid Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE ); - ~DIALOG_SET_GRID_BASE(); - -}; - -#endif //__DIALOG_SET_GRID_BASE_H__ diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index e062d729f9..e4461d8235 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -416,10 +416,7 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) EDA_DRAW_FRAME::LoadSettings( aCfg ); - EESCHEMA_SETTINGS* cfg = dynamic_cast( aCfg ); - wxCHECK( cfg, /*void*/ ); - - if( cfg->m_Window.grid.sizes.empty() ) + if( aCfg->m_Window.grid.sizes.empty() ) { /* * Do NOT add others values (mainly grid values in mm), because they can break the @@ -431,13 +428,13 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) * The 100 mil grid is added to help conform to the KiCad Library Convention which * states: "Using a 100mil grid, pin ends and origin must lie on grid nodes IEC-60617" */ - cfg->m_Window.grid.sizes = { "100 mil", - "50 mil", - "25 mil", - "10 mil", - "5 mil", - "2 mil", - "1 mil" }; + aCfg->m_Window.grid.sizes = { "100 mil", + "50 mil", + "25 mil", + "10 mil", + "5 mil", + "2 mil", + "1 mil" }; } if( aCfg->m_Window.zoom_factors.empty() ) @@ -463,20 +460,25 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) for( double& factor : aCfg->m_Window.zoom_factors ) factor = std::min( factor, MAX_ZOOM_FACTOR ); - wxString templateFieldNames = cfg->m_Drawing.field_names; + EESCHEMA_SETTINGS* cfg = dynamic_cast( aCfg ); - if( !templateFieldNames.IsEmpty() ) + if( cfg ) { - TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) ); + wxString templateFieldNames = cfg->m_Drawing.field_names; - try + if( !templateFieldNames.IsEmpty() ) { - m_templateFieldNames.Parse( &lexer, true ); - } - catch( const IO_ERROR& DBG( e ) ) - { - // @todo show error msg - DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); ) + TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) ); + + try + { + m_templateFieldNames.Parse( &lexer, true ); + } + catch( const IO_ERROR& DBG( e ) ) + { + // @todo show error msg + DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); ) + } } } } diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index bb246a69c4..6e6bff2c97 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -144,8 +144,6 @@ public: } void SetGridOrigin( const wxPoint& aPoint ) override {} - void OnGridSettings( wxCommandEvent& aEvent ) override; - const TITLE_BLOCK& GetTitleBlock() const override; void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index a144e19303..8a3840231e 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -52,13 +52,11 @@ #include #include #include -#include #include #include #include #include #include -#include GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition, @@ -1095,7 +1093,7 @@ void GERBVIEW_FRAME::unitsChangeRefresh() // Called on units change (see EDA_DRAW_FRAME) EDA_DRAW_FRAME::unitsChangeRefresh(); updateDCodeSelectBox(); - updateGridSelectBox(); + UpdateGridSelectBox(); } @@ -1167,50 +1165,6 @@ void GERBVIEW_FRAME::setupTools() } -void GERBVIEW_FRAME::updateGridSelectBox() -{ - UpdateStatusBar(); - DisplayUnitsMsg(); - - if( m_gridSelectBox == NULL ) - return; - - // Update grid values with the current units setting. - m_gridSelectBox->Clear(); - wxArrayString gridsList; - - GRID_MENU::BuildChoiceList( &gridsList, config(), GetUserUnits() != EDA_UNITS::INCHES ); - - for( const wxString& grid : gridsList ) - m_gridSelectBox->Append( grid ); - - m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx ); -} - - -void GERBVIEW_FRAME::updateZoomSelectBox() -{ - if( m_zoomSelectBox == NULL ) - return; - - double zoom = GetCanvas()->GetGAL()->GetZoomFactor() / ZOOM_COEFF; - - m_zoomSelectBox->Clear(); - m_zoomSelectBox->Append( _( "Zoom Auto" ) ); - m_zoomSelectBox->SetSelection( 0 ); - - for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i ) - { - double current = config()->m_Window.zoom_factors[i]; - - m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) ); - - if( zoom == current ) - m_zoomSelectBox->SetSelection( i + 1 ); - } -} - - void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged ) { EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged ); diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 93f7371cf7..70bd56bcc2 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -169,8 +169,6 @@ private: void updateNetnameListSelectBox(); void updateAperAttributesSelectBox(); void updateDCodeSelectBox(); - void updateGridSelectBox(); - void updateZoomSelectBox(); void unitsChangeRefresh() override; // See class EDA_DRAW_FRAME void OnClearJobFileHistory( wxCommandEvent& aEvent ); diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 201021b72f..0b6be1145b 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -165,8 +165,8 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() updateNetnameListSelectBox(); updateAperAttributesSelectBox(); updateDCodeSelectBox(); - updateGridSelectBox(); - updateZoomSelectBox(); + UpdateGridSelectBox(); + UpdateZoomSelectBox(); // combobox sizes can have changed: apply new best sizes auto item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE ); diff --git a/include/convert_to_biu.h b/include/convert_to_biu.h index 1bd919e678..3627bc619d 100644 --- a/include/convert_to_biu.h +++ b/include/convert_to_biu.h @@ -25,10 +25,6 @@ #ifndef CONVERT_TO_BIU_H_ #define CONVERT_TO_BIU_H_ -/** - * @file convert_to_biu.h - */ - /** * @brief some define and functions to convert a value in mils, decimils or mm * to the internal unit used in pcbnew, cvpcb or gerbview (nanometer or deci-mil) @@ -86,13 +82,12 @@ constexpr inline int Iu2Mils( int iu ) return static_cast< int >( mils < 0 ? mils - 0.5 : mils + 0.5 ); } #else -// Here, we do not know the value of internal units: just use something safe to allow -// easier packaging of compilation units -constexpr double IU_PER_MM = 1; -constexpr double IU_PER_MILS = IU_PER_MM * 0.0254; +// Here, we do not know the value of internal units: do not define +// conversion functions (They do not have meaning) +#define UNKNOWN_IU #endif - +#ifndef UNKNOWN_IU // Other definitions used in a few files constexpr double MM_PER_IU = ( 1 / IU_PER_MM ); @@ -122,6 +117,8 @@ constexpr inline double Iu2Millimeter( int iu ) constexpr int ARC_LOW_DEF = Millimeter2iu( 0.02 ); constexpr int ARC_HIGH_DEF = Millimeter2iu( 0.005 ); +#endif + /* ZOOM LIMITS The largest distance that wx can support is INT_MAX, since it represents diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 747a989f3c..464a38365b 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -240,11 +240,6 @@ public: */ virtual void ExecuteRemoteCommand( const char* cmdline ){} - /** - * Return a human readable value for display in dialogs. - */ - const wxString GetZoomLevelIndicator() const; - void EraseMsgBox(); void ReCreateMenuBar() override { } @@ -273,9 +268,36 @@ public: * @param event - Command event passed by selecting grid size from the * grid size combobox on the toolbar. */ - virtual void OnSelectGrid( wxCommandEvent& event ); + void OnSelectGrid( wxCommandEvent& event ); - virtual void OnGridSettings( wxCommandEvent& event ) { }; + void OnGridSettings( wxCommandEvent& event ); + + /** + * Rebuild the grid combobox to respond to any changes in the GUI (units, user + * grid changes, etc.) + */ + void UpdateGridSelectBox(); + + /** + * Update the checked item in the grid combobox. + */ + void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ); + + /** + * Rebuild the grid combobox to respond to any changes in the GUI (units, user + * grid changes, etc.) + */ + void UpdateZoomSelectBox(); + + /** + * Update the checked item in the zoom combobox. + */ + void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ); + + /** + * Return a human readable value for display in dialogs. + */ + const wxString GetZoomLevelIndicator() const; /** * Set the zoom factor when selected by the zoom list box in the main tool bar. @@ -286,10 +308,6 @@ public: */ virtual void OnSelectZoom( wxCommandEvent& event ); - // Update user interface event handlers shared by all applications derived from - // EDA_DRAW_FRAME. - void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ); - /** * Recalculate the size of toolbars and display panel when the frame size changes. */ @@ -459,6 +477,8 @@ public: * Rebuild all toolbars, and update the checked state of ckeck tools */ void RecreateToolbars(); + + DECLARE_EVENT_TABLE() }; #endif // DRAW_FRAME_H_ diff --git a/include/page_info.h b/include/page_info.h index 91b2fff670..8ea136a997 100644 --- a/include/page_info.h +++ b/include/page_info.h @@ -36,7 +36,7 @@ #include // for IU_PER_MILS /// Min and max page sizes for clamping, in mils. -#define MIN_PAGE_SIZE 4000 +#define MIN_PAGE_SIZE_MILS 4000 #define MAX_PAGE_SIZE_PCBNEW_MILS 48000 #define MAX_PAGE_SIZE_MILS 120000 diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index 687b899346..c4e49e27db 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -79,7 +79,6 @@ protected: PCBNEW_SETTINGS* m_Settings; // No ownership, just a shortcut - void updateZoomSelectBox(); virtual void unitsChangeRefresh() override; /** @@ -225,8 +224,6 @@ public: PCB_SCREEN* GetScreen() const override { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); } - void UpdateGridSelectBox(); - /** * Shows the 3D view frame. * If it does not exist, it is created. @@ -394,9 +391,6 @@ public: void CommonSettingsChanged( bool aEnvVarsChanged ) override; - // User interface update event handlers. - void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ); - virtual void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) {} /** @@ -420,8 +414,6 @@ public: * Always returns false. Should be overriden in derived classes which support autozoom. */ virtual bool GetAutoZoom() { return false; } - - DECLARE_EVENT_TABLE() }; #endif // PCB_BASE_FRAME_H diff --git a/include/settings/app_settings.h b/include/settings/app_settings.h index 4f596a8131..8054143c06 100644 --- a/include/settings/app_settings.h +++ b/include/settings/app_settings.h @@ -43,6 +43,8 @@ struct GRID_SETTINGS wxString user_grid_x; wxString user_grid_y; int last_size_idx; + int fast_grid_1; + int fast_grid_2; double line_width; double min_spacing; bool show; diff --git a/include/tool/common_tools.h b/include/tool/common_tools.h index 7721bb787c..89a2bb62d0 100644 --- a/include/tool/common_tools.h +++ b/include/tool/common_tools.h @@ -78,6 +78,8 @@ public: int GridNext( const TOOL_EVENT& aEvent ); int GridPrev( const TOOL_EVENT& aEvent ); int GridPreset( const TOOL_EVENT& aEvent ); + int GridFast1( const TOOL_EVENT& aEvent ); + int GridFast2( const TOOL_EVENT& aEvent ); int ToggleGrid( const TOOL_EVENT& aEvent ); int GridProperties( const TOOL_EVENT& aEvent ); int GridPreset( int idx ); diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index 0c08890c71..16fc1dc6fa 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -121,11 +121,14 @@ public: * Function Validate * Validates the control against the given range, informing the user of any errors found. * - * @param aMin a minimum value (in internal units) for validation - * @param aMax a maximum value (in internal units) for validation + * @param aMin a minimum value for validation + * @param aMax a maximum value for validation + * @param aUnits the units of the min/max parameters (use UNSCALED for internal units) + * @param aUseMils if \a aUnits is EDA_UNITS::INCHES, interpret as mils * @return false on error. */ - virtual bool Validate( long long int aMin, long long int aMax, bool setFocusOnError = true ); + virtual bool Validate( double aMin, double aMax, EDA_UNITS aUnits = EDA_UNITS::UNSCALED, + bool aUseMils = false ); void SetLabel( const wxString& aLabel ); diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt index 3c7c43649a..dccd99739f 100644 --- a/kicad/CMakeLists.txt +++ b/kicad/CMakeLists.txt @@ -15,7 +15,6 @@ include_directories( set( KICAD_SRCS - ${CMAKE_SOURCE_DIR}/common/base_units.cpp dialogs/dialog_template_selector_base.cpp dialogs/dialog_template_selector.cpp files-io.cpp diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt index 8ef7ecbc86..5fa93b0d2d 100644 --- a/pcb_calculator/CMakeLists.txt +++ b/pcb_calculator/CMakeLists.txt @@ -10,7 +10,6 @@ include_directories( ) set( PCB_CALCULATOR_SRCS - ${CMAKE_SOURCE_DIR}/common/base_units.cpp attenuators.cpp board_classes_values.cpp colorcode.cpp diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 33576a5afd..403c611b9a 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -128,8 +128,6 @@ set( PCBNEW_DIALOGS dialogs/dialog_print_pcbnew.cpp dialogs/dialog_select_net_from_list.cpp dialogs/dialog_select_net_from_list_base.cpp - dialogs/dialog_set_grid.cpp - dialogs/dialog_set_grid_base.cpp dialogs/dialog_swap_layers.cpp dialogs/dialog_swap_layers_base.cpp dialogs/dialog_target_properties.cpp diff --git a/pcbnew/dialogs/panel_setup_feature_constraints.cpp b/pcbnew/dialogs/panel_setup_feature_constraints.cpp index 89ea9474f0..13a72c7365 100644 --- a/pcbnew/dialogs/panel_setup_feature_constraints.cpp +++ b/pcbnew/dialogs/panel_setup_feature_constraints.cpp @@ -80,25 +80,25 @@ bool PANEL_SETUP_FEATURE_CONSTRAINTS::TransferDataToWindow() bool PANEL_SETUP_FEATURE_CONSTRAINTS::TransferDataFromWindow() { - if( !m_minClearance.Validate( 0, Mils2iu( 10000 ) ) ) // 0 to 10 inches + if( !m_minClearance.Validate( 0, 10, EDA_UNITS::INCHES ) ) return false; - if( !m_trackMinWidth.Validate( 0, Mils2iu( 10000 ) ) ) // 0 to 10 inches + if( !m_trackMinWidth.Validate( 0, 10, EDA_UNITS::INCHES ) ) return false; - if( !m_viaMinAnnulus.Validate( 0, Mils2iu( 10000 ) ) ) // 0 to 10 inches + if( !m_viaMinAnnulus.Validate( 0, 10, EDA_UNITS::INCHES ) ) return false; - if( !m_viaMinSize.Validate( 0, Mils2iu( 10000 ) ) ) // 0 to 10 inches + if( !m_viaMinSize.Validate( 0, 10, EDA_UNITS::INCHES ) ) return false; - if( !m_edgeClearance.Validate( 0, Mils2iu( 10000 ) ) ) // 0 to 10 inches + if( !m_edgeClearance.Validate( 0, 10, EDA_UNITS::INCHES ) ) return false; - if( !m_throughHoleMin.Validate( Mils2iu( 2 ), Mils2iu( 1000 ) ) ) // #107 to 1 inch + if( !m_throughHoleMin.Validate( 2, 1000, EDA_UNITS::INCHES, true ) ) // #107 to 1 inch return false; - if( !m_holeToHoleMin.Validate( 0, Mils2iu( 10000 ) ) ) // 0 to 10 inches + if( !m_holeToHoleMin.Validate( 0, 10, EDA_UNITS::INCHES ) ) return false; m_BrdSettings->m_BlindBuriedViaAllowed = m_OptAllowBlindBuriedVias->GetValue(); diff --git a/pcbnew/footprint_editor_settings.cpp b/pcbnew/footprint_editor_settings.cpp index fd978f69ee..3a5a2846f6 100644 --- a/pcbnew/footprint_editor_settings.cpp +++ b/pcbnew/footprint_editor_settings.cpp @@ -26,7 +26,7 @@ #include #include #include - +#include extern const char* traceSettings; @@ -267,7 +267,7 @@ bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) ret &= fromLegacy( aCfg, "FpEditorValueDefaultLayer", "design_settings.default_footprint_text_items.1.2" ); - const std::string f = "ModEdit"; + std::string f = "ModEdit"; // Migrate color settings that were stored in the pcbnew config file // We create a copy of the user scheme for the footprint editor context @@ -315,6 +315,22 @@ bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) ( *this )[PointerFromString( "appearance.color_theme" )] = "user_footprints"; + double x, y; + f = "ModEditFrame"; + + if( aCfg->Read( f + "PcbUserGrid_X", &x ) && aCfg->Read( f + "PcbUserGrid_Y", &y ) ) + { + EDA_UNITS u = static_cast( aCfg->ReadLong( f + "PcbUserGrid_Unit", + static_cast( EDA_UNITS::INCHES ) ) ); + + // Convert to internal units + x = From_User_Unit( u, x ); + y = From_User_Unit( u, y ); + + ( *this )[PointerFromString( "window.grid.user_grid_x" )] = StringFromValue( u, x, true, true ); + ( *this )[PointerFromString( "window.grid.user_grid_y" )] = StringFromValue( u, y, true, true ); + } + return ret; } diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 172e8f3328..126b4518cd 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -36,14 +36,10 @@ #include #include #include -#include -#include #include #include #include -#include #include -#include #include #include #include @@ -85,8 +81,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME ) EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectZoom ) EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectGrid ) - EVT_UPDATE_UI( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnUpdateSelectGrid ) - EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnUpdateSelectZoom ) EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton ) EVT_TEXT( ID_MODVIEW_LIB_FILTER, FOOTPRINT_VIEWER_FRAME::OnLibFilter ) diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index 4385160414..b58ad462e7 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -36,6 +36,7 @@ #include #include #include +#include PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index d8efddc427..42f96d7307 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -182,8 +182,6 @@ public: ///> @copydoc PCB_BASE_FRAME::SetBoard() virtual void SetBoard( BOARD* aBoard ) override; - void OnGridSettings( wxCommandEvent& aEvent ) override; - COLOR_SETTINGS* GetColorSettings() override; protected: diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 0c83e4003a..2f93940ba0 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -54,12 +54,6 @@ wxDEFINE_EVENT( BOARD_CHANGED, wxCommandEvent ); -BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME ) - EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid ) - EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom ) -END_EVENT_TABLE() - - PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString & aFrameName ) : @@ -449,30 +443,6 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer ) } -void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ) -{ - if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL ) - return; - - int current = 0; // display Auto if no match found - - // check for a match within 1% - double zoom = GetCanvas()->GetGAL()->GetZoomFactor() / ZOOM_COEFF; - - for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); i++ ) - { - if( std::fabs( zoom - config()->m_Window.zoom_factors[i] ) < ( zoom / 100.0 ) ) - { - current = i + 1; - break; - } - } - - if( current != m_zoomSelectBox->GetSelection() ) - m_zoomSelectBox->SetSelection( current ); -} - - GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide() { GENERAL_COLLECTORS_GUIDE guide( m_Pcb->GetVisibleLayers(), GetActiveLayer(), @@ -749,53 +719,6 @@ void PCB_BASE_FRAME::OnModify() } -void PCB_BASE_FRAME::UpdateGridSelectBox() -{ - UpdateStatusBar(); - DisplayUnitsMsg(); - - if( m_gridSelectBox == NULL ) - return; - - // Update grid values with the current units setting. - m_gridSelectBox->Clear(); - wxArrayString gridsList; - - GRID_MENU::BuildChoiceList( &gridsList, config(), GetUserUnits() != EDA_UNITS::INCHES ); - - for( const wxString& grid : gridsList ) - m_gridSelectBox->Append( grid ); - - m_gridSelectBox->Append( wxT( "---" ) ); - m_gridSelectBox->Append( _( "Edit User Grid..." ) ); - - m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx ); -} - - -void PCB_BASE_FRAME::updateZoomSelectBox() -{ - if( m_zoomSelectBox == NULL ) - return; - - double zoom = GetCanvas()->GetGAL()->GetZoomFactor() / ZOOM_COEFF; - - m_zoomSelectBox->Clear(); - m_zoomSelectBox->Append( _( "Zoom Auto" ) ); - m_zoomSelectBox->SetSelection( 0 ); - - for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i ) - { - double current = config()->m_Window.zoom_factors[i]; - - m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) ); - - if( zoom == current ) - m_zoomSelectBox->SetSelection( i + 1 ); - } -} - - PCB_DRAW_PANEL_GAL* PCB_BASE_FRAME::GetCanvas() const { return static_cast( EDA_DRAW_FRAME::GetCanvas() ); diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index fd65ec6610..42482edd2c 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "../3d-viewer/3d_viewer/3d_viewer_settings.h" @@ -63,8 +64,6 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_FootprintViewer(), m_FootprintWizard(), m_Display(), - m_FastGrid1( 0 ), - m_FastGrid2( 0 ), m_Use45DegreeGraphicSegments( false ), m_FlipLeftRight( false ), m_PolarCoords( false ), @@ -97,10 +96,6 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_params.emplace_back( new PARAM( "footprint_chooser.sash_v", &m_FootprintChooser.sash_v, -1 ) ); - m_params.emplace_back( new PARAM( "grid.fast_grid_1", &m_FastGrid1, 0 ) ); - - m_params.emplace_back( new PARAM( "grid.fast_grid_2", &m_FastGrid2, 0 ) ); - m_params.emplace_back( new PARAM( "editing.flip_left_right", &m_FlipLeftRight, true ) ); m_params.emplace_back( @@ -441,9 +436,6 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) ret &= fromLegacy( aCfg, "FootprintChooserWidth", "footprint_chooser.width" ); ret &= fromLegacy( aCfg, "FootprintChooserHeight", "footprint_chooser.height" ); - ret &= fromLegacy( aCfg, f + "FastGrid1", "grid.fast_grid_1" ); - ret &= fromLegacy( aCfg, f + "FastGrid2", "grid.fast_grid_2" ); - ret &= fromLegacy( aCfg, "FlipLeftRight", "editing.flip_left_right" ); ret &= fromLegacy( aCfg, "MagneticGraphics", "editing.magnetic_graphics" ); ret &= fromLegacy( aCfg, "MagneticPads", "editing.magnetic_pads" ); @@ -635,11 +627,9 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) ret &= fromLegacy( aCfg, p + "StartDiagonal", "tools.pns.start_diagonal" ); ret &= fromLegacy( aCfg, p + "ShoveTimeLimit", "tools.pns.shove_time_limit" ); ret &= fromLegacy( aCfg, p + "ShoveIterationLimit", "tools.pns.shove_iteration_limit" ); - ret &= fromLegacy( aCfg, - p + "WalkaroundIterationLimit", "tools.pns.walkaround_iteration_limit" ); + ret &= fromLegacy( aCfg, p + "WalkaroundIterationLimit", "tools.pns.walkaround_iteration_limit" ); ret &= fromLegacy( aCfg, p + "JumpOverObstacles", "tools.pns.jump_over_obstacles" ); - ret &= fromLegacy( aCfg, - p + "SmoothDraggedSegments", "tools.pns.smooth_dragged_segments" ); + ret &= fromLegacy( aCfg, p + "SmoothDraggedSegments", "tools.pns.smooth_dragged_segments" ); ret &= fromLegacy( aCfg, p + "CanViolateDRC", "tools.pns.can_violate_drc" ); ret &= fromLegacy( aCfg, p + "SuggestFinish", "tools.pns.suggest_finish" ); ret &= fromLegacy( aCfg, p + "FreeAngleMode", "tools.pns.free_angle_mode" ); @@ -683,6 +673,21 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) Pgm().GetSettingsManager().SaveColorSettings( cs, "board" ); + double x, y; + + if( aCfg->Read( f + "PcbUserGrid_X", &x ) && aCfg->Read( f + "PcbUserGrid_Y", &y ) ) + { + EDA_UNITS u = static_cast( aCfg->ReadLong( f + "PcbUserGrid_Unit", + static_cast( EDA_UNITS::INCHES ) ) ); + + // Convert to internal units + x = From_User_Unit( u, x ); + y = From_User_Unit( u, y ); + + ( *this )[PointerFromString( "window.grid.user_grid_x" )] = StringFromValue( u, x, true, true ); + ( *this )[PointerFromString( "window.grid.user_grid_y" )] = StringFromValue( u, y, true, true ); + } + // Footprint editor settings were stored in pcbnew config file. Migrate them here. auto fpedit = Pgm().GetSettingsManager().GetAppSettings( false ); fpedit->MigrateFromLegacy( aCfg ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index 2d6af30d77..b9b5881401 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -242,10 +242,6 @@ public: MAGNETIC_SETTINGS m_MagneticItems; - int m_FastGrid1; - - int m_FastGrid2; - bool m_Use45DegreeGraphicSegments; // True to constraint graphic lines to horizontal, // vertical and 45ยบ bool m_FlipLeftRight; // True: Flip footprints across Y axis diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index 2241b30ceb..c274cca0df 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -111,7 +111,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT, wxDefaultPosition, wxDefaultSize, 0, NULL ); - updateZoomSelectBox(); + UpdateZoomSelectBox(); m_mainToolBar->AddControl( m_zoomSelectBox ); KiScaledSeparator( m_mainToolBar, this ); diff --git a/pcbnew/toolbars_footprint_viewer.cpp b/pcbnew/toolbars_footprint_viewer.cpp index da23a3e93a..a6755e9a03 100644 --- a/pcbnew/toolbars_footprint_viewer.cpp +++ b/pcbnew/toolbars_footprint_viewer.cpp @@ -89,7 +89,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar() m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT, wxDefaultPosition, wxDefaultSize, 0, NULL ); - updateZoomSelectBox(); + UpdateZoomSelectBox(); m_mainToolBar->AddControl( m_zoomSelectBox ); // after adding the buttons to the toolbar, must call Realize() to diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 010f286b04..60768a7799 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -488,7 +488,7 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar() m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_ZOOM_SELECT, wxDefaultPosition, wxDefaultSize, 0, NULL ); - updateZoomSelectBox(); + UpdateZoomSelectBox(); m_auxiliaryToolBar->AddControl( m_zoomSelectBox ); // after adding the buttons to the toolbar, must call Realize() diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index f4d604e3f8..2ffe96f85c 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -365,20 +365,6 @@ int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent ) // Grid control -int PCBNEW_CONTROL::GridFast1( const TOOL_EVENT& aEvent ) -{ - m_toolMgr->RunAction( "common.Control.gridPreset", true, m_frame->Settings().m_FastGrid1 ); - return 0; -} - - -int PCBNEW_CONTROL::GridFast2( const TOOL_EVENT& aEvent ) -{ - m_toolMgr->RunAction( "common.Control.gridPreset", true, m_frame->Settings().m_FastGrid2 ); - return 0; -} - - void PCBNEW_CONTROL::DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame, BOARD_ITEM* originViewItem, const VECTOR2D& aPoint ) { @@ -1082,8 +1068,6 @@ void PCBNEW_CONTROL::setTransitions() Go( &PCBNEW_CONTROL::LayerAlphaDec, PCB_ACTIONS::layerAlphaDec.MakeEvent() ); // Grid control - Go( &PCBNEW_CONTROL::GridFast1, ACTIONS::gridFast1.MakeEvent() ); - Go( &PCBNEW_CONTROL::GridFast2, ACTIONS::gridFast2.MakeEvent() ); Go( &PCBNEW_CONTROL::GridSetOrigin, ACTIONS::gridSetOrigin.MakeEvent() ); Go( &PCBNEW_CONTROL::GridResetOrigin, ACTIONS::gridResetOrigin.MakeEvent() ); diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h index 03e6b5fd99..998b5caeda 100644 --- a/pcbnew/tools/pcbnew_control.h +++ b/pcbnew/tools/pcbnew_control.h @@ -70,8 +70,6 @@ public: int LayerAlphaDec( const TOOL_EVENT& aEvent ); // Grid control - int GridFast1( const TOOL_EVENT& aEvent ); - int GridFast2( const TOOL_EVENT& aEvent ); int GridSetOrigin( const TOOL_EVENT& aEvent ); int GridResetOrigin( const TOOL_EVENT& aEvent );