Grids: Support X and Y for all grids, add optional names

This commit is contained in:
Mike Williams 2023-08-30 11:21:56 -04:00
parent 9002ade554
commit b1a388ca69
25 changed files with 1374 additions and 183 deletions

View File

@ -114,6 +114,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_HTML_reporter_base.cpp
dialogs/dialog_locked_items_query.cpp
@ -468,6 +470,7 @@ set( COMMON_SRCS
settings/color_settings.cpp
settings/cvpcb_settings.cpp
settings/common_settings.cpp
settings/grid_settings.cpp
settings/json_settings.cpp
settings/nested_settings.cpp
settings/parameters.cpp

View File

@ -0,0 +1,81 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2023 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 <bitmaps.h>
#include <confirm.h>
#include <wx/textdlg.h>
#include <dialogs/dialog_grid_settings.h>
#include <widgets/std_bitmap_button.h>
#include <common.h>
#include <settings/app_settings.h>
#include <eda_draw_frame.h>
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <tool/grid_menu.h>
#include <tool/common_tools.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( wxWindow* aParent, wxWindow* aEventSource,
UNITS_PROVIDER* aProvider, GRID& aGrid ) :
DIALOG_GRID_SETTINGS_BASE( aParent ),
m_unitsProvider( aProvider ), m_grid( aGrid ),
m_gridSizeX( aProvider, aEventSource, m_staticTextX, m_textX, m_staticTextXUnits, true ),
m_gridSizeY( aProvider, aEventSource, m_staticTextY, m_textY, m_staticTextYUnits, true )
{
SetupStandardButtons();
SetInitialFocus( m_textName );
Layout();
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();
}
bool DIALOG_GRID_SETTINGS::TransferDataFromWindow()
{
double gridX = m_gridSizeX.GetDoubleValue();
double gridY = m_checkLinked->IsChecked() ? gridX : m_gridSizeY.GetDoubleValue();
if( gridX <= 0.0f || gridY <= 0.0f )
{
wxMessageBox( _( "Grid size must be greater than zero." ), _( "Error" ),
wxOK | wxICON_ERROR );
return false;
}
m_grid.name = m_textName->GetValue();
// Grid X/Y are always stored in millimeters so we can compare them easily
m_grid.x = EDA_UNIT_UTILS::UI::StringFromValue( m_unitsProvider->GetIuScale(),
EDA_UNITS::MILLIMETRES, gridX );
m_grid.y = EDA_UNIT_UTILS::UI::StringFromValue( m_unitsProvider->GetIuScale(),
EDA_UNITS::MILLIMETRES, gridY );
return true;
}
void DIALOG_GRID_SETTINGS::OnLinkedChecked( wxCommandEvent& event )
{
m_textY->Enable( !m_checkLinked->IsChecked() );
}

View File

@ -0,0 +1,746 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration">; </property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_grid_settings_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">0</property>
<property name="name">DIALOG_GRID_SETTINGS</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</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_GRID_SETTINGS_BASE</property>
<property name="pos"></property>
<property name="size">288,233</property>
<property name="style">wxDEFAULT_DIALOG_STYLE</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property>
<property name="title">Grid Settings</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>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bMainSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">3</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">m_fgGrid</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="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">Name:</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_staticTextName</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="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="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="maxlength"></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_textName</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="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="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">(optional)</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_staticTextOptional</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="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="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">X:</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_staticTextX</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="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="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="maxlength"></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_textX</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="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="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">unit</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_staticTextXUnits</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="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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">1</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="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">Linked</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_checkLinked</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="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="OnCheckBox">OnLinkedChecked</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="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">Y:</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_staticTextY</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="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="enabled">0</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="maxlength"></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_textY</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="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></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="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">unit</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_staticTextYUnits</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="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<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_stdButtons</property>
<property name="permission">protected</property>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -0,0 +1,97 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_grid_settings_base.h"
///////////////////////////////////////////////////////////////////////////
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 );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer* m_fgGrid;
m_fgGrid = new wxFlexGridSizer( 0, 3, 0, 0 );
m_fgGrid->AddGrowableCol( 1 );
m_fgGrid->SetFlexibleDirection( wxBOTH );
m_fgGrid->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextName->Wrap( -1 );
m_fgGrid->Add( m_staticTextName, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fgGrid->Add( m_textName, 1, wxALL|wxEXPAND, 5 );
m_staticTextOptional = new wxStaticText( this, wxID_ANY, wxT("(optional)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextOptional->Wrap( -1 );
m_fgGrid->Add( m_staticTextOptional, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxLEFT, 5 );
m_staticTextX = new wxStaticText( this, wxID_ANY, wxT("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextX->Wrap( -1 );
m_fgGrid->Add( m_staticTextX, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_textX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fgGrid->Add( m_textX, 1, wxALL|wxEXPAND, 5 );
m_staticTextXUnits = new wxStaticText( this, wxID_ANY, wxT("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextXUnits->Wrap( -1 );
m_fgGrid->Add( m_staticTextXUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 );
m_fgGrid->Add( 0, 0, 0, wxEXPAND, 5 );
m_checkLinked = new wxCheckBox( this, wxID_ANY, wxT("Linked"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkLinked->SetValue(true);
m_fgGrid->Add( m_checkLinked, 1, wxALL|wxEXPAND, 5 );
m_fgGrid->Add( 0, 0, 0, wxEXPAND, 5 );
m_staticTextY = new wxStaticText( this, wxID_ANY, wxT("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextY->Wrap( -1 );
m_fgGrid->Add( m_staticTextY, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_textY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textY->Enable( false );
m_fgGrid->Add( m_textY, 1, wxALL|wxEXPAND, 5 );
m_staticTextYUnits = new wxStaticText( this, wxID_ANY, wxT("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextYUnits->Wrap( -1 );
m_fgGrid->Add( m_staticTextYUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 );
bMainSizer->Add( m_fgGrid, 0, wxEXPAND, 5 );
m_stdButtons = new wxStdDialogButtonSizer();
m_stdButtonsOK = new wxButton( this, wxID_OK );
m_stdButtons->AddButton( m_stdButtonsOK );
m_stdButtonsCancel = new wxButton( this, wxID_CANCEL );
m_stdButtons->AddButton( m_stdButtonsCancel );
m_stdButtons->Realize();
bMainSizer->Add( m_stdButtons, 1, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_checkLinked->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnLinkedChecked ), NULL, this );
}
DIALOG_GRID_SETTINGS_BASE::~DIALOG_GRID_SETTINGS_BASE()
{
// Disconnect Events
m_checkLinked->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GRID_SETTINGS_BASE::OnLinkedChecked ), NULL, this );
}

View File

@ -0,0 +1,61 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_GRID_SETTINGS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_GRID_SETTINGS_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_staticTextName;
wxTextCtrl* m_textName;
wxStaticText* m_staticTextOptional;
wxStaticText* m_staticTextX;
wxTextCtrl* m_textX;
wxStaticText* m_staticTextXUnits;
wxCheckBox* m_checkLinked;
wxStaticText* m_staticTextY;
wxTextCtrl* m_textY;
wxStaticText* m_staticTextYUnits;
wxStdDialogButtonSizer* m_stdButtons;
wxButton* m_stdButtonsOK;
wxButton* m_stdButtonsCancel;
// Virtual event handlers, override them in your derived class
virtual void OnLinkedChecked( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Grid Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 288,233 ), long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_GRID_SETTINGS_BASE();
};

View File

@ -25,6 +25,7 @@
#include <confirm.h>
#include <wx/textdlg.h>
#include <dialogs/panel_grid_settings.h>
#include <dialogs/dialog_grid_settings.h>
#include <widgets/std_bitmap_button.h>
#include <common.h>
#include <settings/app_settings.h>
@ -40,17 +41,16 @@ PANEL_GRID_SETTINGS::PANEL_GRID_SETTINGS( wxWindow* aParent, UNITS_PROVIDER* aUn
wxWindow* aEventSource, APP_SETTINGS_BASE* aCfg,
FRAME_T aFrameType ) :
PANEL_GRID_SETTINGS_BASE( aParent ),
m_unitsProvider( aUnitsProvider ),
m_cfg( aCfg ),
m_frameType( aFrameType ),
m_unitsProvider( aUnitsProvider ), m_cfg( aCfg ), m_frameType( aFrameType ),
m_eventSource( aEventSource ),
m_gridOverrideConnected( aUnitsProvider, aEventSource, m_staticTextConnected,
m_GridOverrideConnectedSize, m_staticTextConnectedUnits ),
m_gridOverrideWires( aUnitsProvider, aEventSource, m_staticTextWires,
m_GridOverrideWiresSize, m_staticTextWiresUnits ),
m_gridOverrideVias( aUnitsProvider, aEventSource, m_staticTextVias,
m_GridOverrideViasSize, m_staticTextViasUnits ),
m_gridOverrideText( aUnitsProvider, aEventSource, m_staticTextText,
m_GridOverrideTextSize, m_staticTextTextUnits ),
m_gridOverrideVias( aUnitsProvider, aEventSource, m_staticTextVias, m_GridOverrideViasSize,
m_staticTextViasUnits ),
m_gridOverrideText( aUnitsProvider, aEventSource, m_staticTextText, m_GridOverrideTextSize,
m_staticTextTextUnits ),
m_gridOverrideGraphics( aUnitsProvider, aEventSource, m_staticTextGraphics,
m_GridOverrideGraphicsSize, m_staticTextGraphicsUnits )
{
@ -97,7 +97,7 @@ PANEL_GRID_SETTINGS::PANEL_GRID_SETTINGS( wxWindow* aParent, UNITS_PROVIDER* aUn
void PANEL_GRID_SETTINGS::ResetPanel()
{
m_cfg->m_Window.grid.sizes = m_cfg->DefaultGridSizeList();
m_cfg->m_Window.grid.grids = m_cfg->DefaultGridSizeList();
RebuildGridSizes();
m_cfg->m_Window.grid.last_size_idx = m_currentGridCtrl->GetSelection();
}
@ -117,14 +117,15 @@ void PANEL_GRID_SETTINGS::RebuildGridSizes()
m_unitsProvider->GetUnitPair( primaryUnit, secondaryUnit );
for( const wxString& gridSize : m_cfg->m_Window.grid.sizes )
for( const struct GRID& grid : m_cfg->m_Window.grid.grids )
{
double val = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MILLIMETRES,
gridSize );
wxString name = grid.name;
msg.Printf( _( "%s (%s)" ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( scale, primaryUnit, val ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( scale, secondaryUnit, val ) );
if( !name.IsEmpty() )
name += wxT( ": " );
msg.Printf( _( "%s%s (%s)" ), name, grid.MessageText( scale, primaryUnit, true ),
grid.MessageText( scale, secondaryUnit, true ) );
grids.Add( msg );
}
@ -205,38 +206,26 @@ bool PANEL_GRID_SETTINGS::TransferDataToWindow()
void PANEL_GRID_SETTINGS::OnAddGrid( wxCommandEvent& event )
{
wxTextEntryDialog dlg( this, _( "New grid:" ), _( "Add Grid" ) );
GRID newGrid = GRID{ wxEmptyString, "", "" };
DIALOG_GRID_SETTINGS dlg( this->GetParent(), m_eventSource, m_unitsProvider, newGrid );
if( dlg.ShowModal() != wxID_OK )
return;
int row = m_currentGridCtrl->GetSelection();
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
EDA_IU_SCALE scale = m_unitsProvider->GetIuScale();
EDA_UNITS units = m_unitsProvider->GetUserUnits();
double gridSize = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, units, dlg.GetValue() );
if( gridSize == 0.0f )
for( GRID& g : gridCfg.grids )
{
DisplayError( this, _( "Grid must have a valid size." ) );
return;
}
wxString gridSizeStr =
EDA_UNIT_UTILS::UI::StringFromValue( scale, EDA_UNITS::MILLIMETRES, gridSize );
for( const wxString& size : gridCfg.sizes )
{
if( gridSizeStr == size )
if( newGrid == g )
{
DisplayError( this,
wxString::Format( _( "Grid size '%s' already exists." ), gridSizeStr ) );
DisplayError( this, wxString::Format( _( "Grid size '%s' already exists." ),
g.UserUnitsMessageText( m_unitsProvider ) ) );
return;
}
}
gridCfg.sizes.insert( gridCfg.sizes.begin() + row, gridSizeStr );
gridCfg.grids.insert( gridCfg.grids.begin() + row, newGrid );
RebuildGridSizes();
m_currentGridCtrl->SetSelection( row );
}
@ -247,13 +236,13 @@ void PANEL_GRID_SETTINGS::OnRemoveGrid( wxCommandEvent& event )
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
int row = m_currentGridCtrl->GetSelection();
if( gridCfg.sizes.size() <= 1 )
if( gridCfg.grids.size() <= 1 )
{
DisplayError( this, wxString::Format( _( "At least one grid size is required." ) ) );
return;
}
gridCfg.sizes.erase( gridCfg.sizes.begin() + row );
gridCfg.grids.erase( gridCfg.grids.begin() + row );
RebuildGridSizes();
if( row != 0 )
@ -266,10 +255,10 @@ void PANEL_GRID_SETTINGS::OnMoveGridUp( wxCommandEvent& event )
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
int row = m_currentGridCtrl->GetSelection();
if( gridCfg.sizes.size() <= 1 || row == 0 )
if( gridCfg.grids.size() <= 1 || row == 0 )
return;
std::swap( gridCfg.sizes[row], gridCfg.sizes[row - 1] );
std::swap( gridCfg.grids[row], gridCfg.grids[row - 1] );
RebuildGridSizes();
if( row != 0 )
@ -282,10 +271,10 @@ void PANEL_GRID_SETTINGS::OnMoveGridDown( wxCommandEvent& event )
GRID_SETTINGS& gridCfg = m_cfg->m_Window.grid;
int row = m_currentGridCtrl->GetSelection();
if( gridCfg.sizes.size() <= 1 || row == ( (int) gridCfg.sizes.size() - 1 ) )
if( gridCfg.grids.size() <= 1 || row == ( (int) gridCfg.grids.size() - 1 ) )
return;
std::swap( gridCfg.sizes[row], gridCfg.sizes[row + 1] );
std::swap( gridCfg.grids[row], gridCfg.grids[row + 1] );
RebuildGridSizes();
if( row != 0 )

View File

@ -631,8 +631,11 @@ void EDA_DRAW_FRAME::DisplayGridMsg()
{
wxString msg;
msg.Printf( _( "grid %s" ), MessageTextFromValue( GetCanvas()->GetGAL()->GetGridSize().x,
false ) );
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 ) );
SetStatusText( msg, 4 );
}

View File

@ -27,6 +27,7 @@
#include <settings/json_settings_internals.h>
#include <settings/color_settings.h>
#include <settings/common_settings.h>
#include <settings/grid_settings.h>
#include <settings/parameters.h>
@ -337,8 +338,8 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
defaultGridIdx = 4;
}
m_params.emplace_back( new PARAM_LIST<wxString>( aJsonPath + ".grid.sizes",
&aWindow->grid.sizes, DefaultGridSizeList() ) );
m_params.emplace_back( new PARAM_LIST<GRID>( aJsonPath + ".grid.sizes", &aWindow->grid.grids,
DefaultGridSizeList() ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
&aWindow->grid.last_size_idx, defaultGridIdx ) );
@ -349,7 +350,7 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_2",
&aWindow->grid.fast_grid_2, defaultGridIdx + 1 ) );
// for grid user, use a default value compatible with eeschema and pcbnew (10 mils)
// legacy values, leave blank by default so we don't convert them
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_x",
&aWindow->grid.user_grid_x, wxEmptyString ) );
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_y",
@ -441,39 +442,39 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
}
const std::vector<wxString> APP_SETTINGS_BASE::DefaultGridSizeList() const
const std::vector<GRID> APP_SETTINGS_BASE::DefaultGridSizeList() const
{
if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
{
return { wxS( "100 mil" ),
wxS( "50 mil" ),
wxS( "25 mil" ),
wxS( "10 mil" ) };
return { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) } };
}
else
{
return { wxS( "1000 mil" ),
wxS( "500 mil" ),
wxS( "250 mil" ),
wxS( "200 mil" ),
wxS( "100 mil" ),
wxS( "50 mil" ),
wxS( "25 mil" ),
wxS( "20 mil" ),
wxS( "10 mil" ),
wxS( "5 mil" ),
wxS( "2 mil" ),
wxS( "1 mil" ),
wxS( "5.0 mm" ),
wxS( "2.5 mm" ),
wxS( "1.0 mm" ),
wxS( "0.5 mm" ),
wxS( "0.25 mm" ),
wxS( "0.2 mm" ),
wxS( "0.1 mm" ),
wxS( "0.05 mm" ),
wxS( "0.025 mm" ),
wxS( "0.01 mm" ) };
return { GRID{ wxEmptyString, wxS( "1000 mil" ), wxS( "1000 mil" ) },
GRID{ wxEmptyString, wxS( "500 mil" ), wxS( "500 mil" ) },
GRID{ wxEmptyString, wxS( "250 mil" ), wxS( "250 mil" ) },
GRID{ wxEmptyString, wxS( "200 mil" ), wxS( "200 mil" ) },
GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
GRID{ wxEmptyString, wxS( "2.5 mm" ), wxS( "2.5 mm" ) },
GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.05 mm" ) },
GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.025 mm" ) },
GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.01 mm" ) } };
}
}

View File

@ -0,0 +1,99 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 Mike Williams <mike@mikebwilliams.com>
* Copyright (C) 2023 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <settings/grid_settings.h>
#include <nlohmann/json.hpp>
#include <wx/translation.h>
#include <units_provider.h>
namespace nlohmann
{
template <>
struct adl_serializer<wxString>
{
static void to_json( json& j, const wxString& s ) { j = s.ToUTF8(); }
static void from_json( const json& j, wxString& s )
{
s = wxString::FromUTF8( j.get<std::string>().c_str() );
}
};
} // namespace nlohmann
wxString GRID::MessageText( EDA_IU_SCALE aScale, EDA_UNITS aUnits, bool aDisplayUnits ) const
{
EDA_DATA_TYPE type = EDA_DATA_TYPE::DISTANCE;
wxString xStr = EDA_UNIT_UTILS::UI::MessageTextFromValue(
aScale, aUnits,
EDA_UNIT_UTILS::UI::DoubleValueFromString( aScale, EDA_UNITS::MILLIMETRES, x, type ),
aDisplayUnits );
wxString yStr = EDA_UNIT_UTILS::UI::MessageTextFromValue(
aScale, aUnits,
EDA_UNIT_UTILS::UI::DoubleValueFromString( aScale, EDA_UNITS::MILLIMETRES, y, type ),
aDisplayUnits );
if( xStr == yStr )
return xStr;
return wxString::Format( wxS( "%s x %s" ), xStr, yStr );
}
wxString GRID::UserUnitsMessageText( UNITS_PROVIDER* aProvider, bool aDisplayUnits ) const
{
return MessageText( aProvider->GetIuScale(), aProvider->GetUserUnits(), aDisplayUnits );
}
bool GRID::operator==( const GRID& aOther ) const
{
return x == aOther.x && y == aOther.y;
}
bool operator!=( const GRID& lhs, const GRID& rhs )
{
return !( lhs == rhs );
}
bool operator<( const GRID& lhs, const GRID& rhs )
{
return lhs.name < rhs.name;
}
void to_json( nlohmann::json& j, const GRID& g )
{
j = nlohmann::json{
{ "name", g.name },
{ "x", g.x },
{ "y", g.y },
};
}
void from_json( const nlohmann::json& j, GRID& g )
{
j.at( "name" ).get_to( g.name );
j.at( "x" ).get_to( g.x );
j.at( "y" ).get_to( g.y );
}

View File

@ -31,6 +31,7 @@
#include <settings/nested_settings.h>
#include <settings/parameters.h>
#include <settings/bom_settings.h>
#include <settings/grid_settings.h>
#include <settings/aui_settings.h>
#include <wx/aui/framemanager.h>
#include <wx/config.h>
@ -574,6 +575,7 @@ template std::optional<KIGFX::COLOR4D> JSON_SETTINGS::Get<KIGFX::COLOR4D>( const
template std::optional<BOM_FIELD> JSON_SETTINGS::Get<BOM_FIELD>( const std::string& aPath ) const;
template std::optional<BOM_PRESET> JSON_SETTINGS::Get<BOM_PRESET>( const std::string& aPath ) const;
template std::optional<BOM_FMT_PRESET> JSON_SETTINGS::Get<BOM_FMT_PRESET>( const std::string& aPath ) const;
template std::optional<GRID> JSON_SETTINGS::Get<GRID>( const std::string& aPath ) const;
template std::optional<wxPoint> JSON_SETTINGS::Get<wxPoint>( const std::string& aPath ) const;
template std::optional<wxSize> JSON_SETTINGS::Get<wxSize>( const std::string& aPath ) const;
template std::optional<wxRect> JSON_SETTINGS::Get<wxRect>( const std::string& aPath ) const;
@ -600,6 +602,7 @@ template void JSON_SETTINGS::Set<KIGFX::COLOR4D>( const std::string& aPath, KIGF
template void JSON_SETTINGS::Set<BOM_FIELD>( const std::string& aPath, BOM_FIELD aValue );
template void JSON_SETTINGS::Set<BOM_PRESET>( const std::string& aPath, BOM_PRESET aValue );
template void JSON_SETTINGS::Set<BOM_FMT_PRESET>( const std::string& aPath, BOM_FMT_PRESET aValue );
template void JSON_SETTINGS::Set<GRID>( const std::string& aPath, GRID aValue );
template void JSON_SETTINGS::Set<wxPoint>( const std::string& aPath, wxPoint aValue );
template void JSON_SETTINGS::Set<wxSize>( const std::string& aPath, wxSize aValue );
template void JSON_SETTINGS::Set<wxRect>( const std::string& aPath, wxRect aValue );

View File

@ -26,6 +26,7 @@
#include <project/project_file.h>
#include <settings/parameters.h>
#include <settings/bom_settings.h>
#include <settings/grid_settings.h>
template <typename ValueType>
void PARAM_LAMBDA<ValueType>::Load( JSON_SETTINGS* aSettings, bool aResetIfMissing ) const
@ -137,6 +138,7 @@ template class PARAM_LIST<KIGFX::COLOR4D>;
template class PARAM_LIST<FILE_INFO_PAIR>;
template class PARAM_LIST<BOM_PRESET>;
template class PARAM_LIST<BOM_FMT_PRESET>;
template class PARAM_LIST<GRID>;
template <typename ValueType>

View File

@ -61,12 +61,15 @@ void COMMON_TOOLS::Reset( RESET_REASON aReason )
m_grids.clear();
for( const wxString& gridDef : settings.sizes )
for( GRID& gridDef : settings.grids )
{
double gridSize = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MILLIMETRES,
gridDef );
double gridSizeX = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MILLIMETRES,
gridDef.x );
double gridSizeY = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MILLIMETRES,
gridDef.y );
m_grids.emplace_back( KiROUND<double, int>( gridSize ), KiROUND<double, int>( gridSize ) );
m_grids.emplace_back( KiROUND<double, int>( gridSizeX ),
KiROUND<double, int>( gridSizeY ) );
}
OnGridChanged( false );

View File

@ -84,6 +84,7 @@ void GRID_MENU::update()
}
}
void GRID_MENU::BuildChoiceList( wxArrayString* aGridsList, APP_SETTINGS_BASE* aCfg,
EDA_DRAW_FRAME* aParent )
{
@ -94,14 +95,15 @@ void GRID_MENU::BuildChoiceList( wxArrayString* aGridsList, APP_SETTINGS_BASE* a
aParent->GetUnitPair( primaryUnit, secondaryUnit );
for( const wxString& gridSize : aCfg->m_Window.grid.sizes )
for( GRID& gridSize : aCfg->m_Window.grid.grids )
{
double val = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MILLIMETRES,
gridSize );
wxString name;
msg.Printf( _( "%s (%s)" ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( scale, primaryUnit, val ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( scale, secondaryUnit, val ) );
if( !gridSize.name.IsEmpty() )
name = gridSize.name + ": ";
msg.Printf( _( "%s%s (%s)" ), name, gridSize.MessageText( scale, primaryUnit, true ),
gridSize.MessageText( scale, secondaryUnit, true ) );
aGridsList->Add( msg );
}

View File

@ -244,24 +244,25 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
EDA_DRAW_FRAME::LoadSettings( aCfg );
if( aCfg->m_Window.grid.sizes.empty() )
aCfg->m_Window.grid.sizes = aCfg->DefaultGridSizeList();
if( aCfg->m_Window.grid.grids.empty() )
aCfg->m_Window.grid.grids = aCfg->DefaultGridSizeList();
// Move legacy user grids to grid list
if( !aCfg->m_Window.grid.user_grid_x.empty() )
{
aCfg->m_Window.grid.sizes.emplace_back( aCfg->m_Window.grid.user_grid_x );
aCfg->m_Window.grid.grids.emplace_back( GRID{ "User Grid", aCfg->m_Window.grid.user_grid_x,
aCfg->m_Window.grid.user_grid_y } );
aCfg->m_Window.grid.user_grid_x = wxEmptyString;
aCfg->m_Window.grid.user_grid_y = wxEmptyString;
}
if( aCfg->m_Window.grid.last_size_idx > (int) aCfg->m_Window.grid.sizes.size() )
if( aCfg->m_Window.grid.last_size_idx > (int) aCfg->m_Window.grid.grids.size() )
aCfg->m_Window.grid.last_size_idx = 1;
if( aCfg->m_Window.grid.fast_grid_1 > (int) aCfg->m_Window.grid.sizes.size() )
if( aCfg->m_Window.grid.fast_grid_1 > (int) aCfg->m_Window.grid.grids.size() )
aCfg->m_Window.grid.fast_grid_1 = 1;
if( aCfg->m_Window.grid.fast_grid_2 > (int) aCfg->m_Window.grid.sizes.size() )
if( aCfg->m_Window.grid.fast_grid_2 > (int) aCfg->m_Window.grid.grids.size() )
aCfg->m_Window.grid.fast_grid_2 = 2;
if( aCfg->m_Window.zoom_factors.empty() )

View File

@ -2387,13 +2387,13 @@ int SCH_EDITOR_CONTROL::GridFeedback( const TOOL_EVENT& aEvent )
if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
return 0;
const std::vector<VECTOR2I>& grids = m_toolMgr->GetTool<COMMON_TOOLS>()->Grids();
GRID_SETTINGS& gridSettings = m_toolMgr->GetSettings()->m_Window.grid;
int currentIdx = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
wxArrayString gridsLabels;
for( const VECTOR2I& grid : grids )
gridsLabels.Add( m_frame->StringFromValue( grid.x, true ) );
for( const GRID& grid : gridSettings.grids )
gridsLabels.Add( grid.UserUnitsMessageText( m_frame ) );
if( !m_frame->GetHotkeyPopup() )
m_frame->CreateHotkeyPopup();

View File

@ -310,30 +310,30 @@ void GERBVIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
EDA_DRAW_FRAME::LoadSettings( aCfg );
if( aCfg->m_Window.grid.sizes.empty() )
if( aCfg->m_Window.grid.grids.empty() )
{
aCfg->m_Window.grid.sizes = { wxT( "100 mil" ),
wxT( "50 mil" ),
wxT( "25 mil" ),
wxT( "20 mil" ),
wxT( "10 mil" ),
wxT( "5 mil" ),
wxT( "2.5 mil" ),
wxT( "2 mil" ),
wxT( "1 mil" ),
wxT( "0.5 mil" ),
wxT( "0.2 mil" ),
wxT( "0.1 mil" ),
wxT( "5.0 mm" ),
wxT( "2.5 mm" ),
wxT( "1.0 mm" ),
wxT( "0.5 mm" ),
wxT( "0.25 mm" ),
wxT( "0.2 mm" ),
wxT( "0.1 mm" ),
wxT( "0.05 mm" ),
wxT( "0.025 mm" ),
wxT( "0.01 mm" ) };
aCfg->m_Window.grid.grids = { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
GRID{ wxEmptyString, wxS( "2.5 mil" ), wxS( "2.5 mil" ) },
GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
GRID{ wxEmptyString, wxS( "0.5 mil" ), wxS( "0.5 mil" ) },
GRID{ wxEmptyString, wxS( "0.2 mil" ), wxS( "0.2 mil" ) },
GRID{ wxEmptyString, wxS( "0.1 mil" ), wxS( "0.1 mil" ) },
GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
GRID{ wxEmptyString, wxS( "1.5 mm" ), wxS( "2.5 mm" ) },
GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.0 mm" ) },
GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.0 mm" ) },
GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.0 mm" ) } };
}
if( aCfg->m_Window.zoom_factors.empty() )

View File

@ -0,0 +1,54 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 Mike Williams <mike@mikebwilliams.com>
* Copyright (C) 1992-2023 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 <dialog_grid_settings_base.h>
#include <widgets/unit_binder.h>
struct GRID;
class DIALOG_GRID_SETTINGS : public DIALOG_GRID_SETTINGS_BASE
{
EDA_DRAW_FRAME* m_parent;
public:
DIALOG_GRID_SETTINGS( wxWindow* aParent, wxWindow* aEventSource, UNITS_PROVIDER* aProvider,
GRID& aGrid );
~DIALOG_GRID_SETTINGS() override = default;
bool TransferDataFromWindow() override;
protected:
void OnLinkedChecked( wxCommandEvent& event ) override;
private:
UNITS_PROVIDER* m_unitsProvider;
GRID& m_grid;
UNIT_BINDER m_gridSizeX;
UNIT_BINDER m_gridSizeY;
};
#endif // DIALOG_GRID_SETTINGS_H

View File

@ -55,6 +55,7 @@ private:
UNITS_PROVIDER* m_unitsProvider;
APP_SETTINGS_BASE* m_cfg;
FRAME_T m_frameType;
wxWindow* m_eventSource;
UNIT_BINDER m_gridOverrideConnected;
UNIT_BINDER m_gridOverrideWires;

View File

@ -379,11 +379,6 @@ public:
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
/**
* Display the current grid pane on the status bar.
*/
void DisplayGridMsg() override;
PCB_DRAW_PANEL_GAL* GetCanvas() const override;
virtual void ActivateGalCanvas() override;

View File

@ -23,6 +23,7 @@
#include <gal/color4d.h>
#include <settings/json_settings.h>
#include <settings/grid_settings.h>
/**
* Cross-probing behavior
@ -44,37 +45,6 @@ struct CURSOR_SETTINGS
bool fullscreen_cursor;
};
/**
* Common grid settings, available to every frame
*/
struct GRID_SETTINGS
{
bool axes_enabled;
std::vector<wxString> sizes;
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;
int style;
int snap;
bool force_component_snap;
bool overrides_enabled;
bool override_connected;
wxString override_connected_size;
bool override_wires;
wxString override_wires_size;
bool override_vias;
wxString override_vias_size;
bool override_text;
wxString override_text_size;
bool override_graphics;
wxString override_graphics_size;
};
/**
* Settings for arc editing. Used by pcbnew and footprint editor
*/
@ -179,7 +149,7 @@ public:
virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
const std::vector<wxString> DefaultGridSizeList() const;
const std::vector<GRID> DefaultGridSizeList() const;
public:
CROSS_PROBING_SETTINGS m_CrossProbing;

View File

@ -0,0 +1,89 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 Mike Williams <mike@mikebwilliams.com>
* Copyright (C) 2023 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GRID_SETTINGS_H
#define _GRID_SETTINGS_H
#include <eda_units.h>
#include <wx/string.h>
#include <nlohmann/json_fwd.hpp>
class UNITS_PROVIDER;
/**
* Common grid settings, available to every frame
*/
struct GRID
{
bool operator==( const GRID& aOther ) const;
/**
* Returns a string representation of the grid in specified units.
* Will reduce to a single dimension if the grid is square.
*/
wxString MessageText( EDA_IU_SCALE aScale, EDA_UNITS aUnits, bool aDisplayUnits = true ) const;
/**
* Returns a string representation of the grid in the user's units.
* Will reduce to a single dimension if the grid is square.
*/
wxString UserUnitsMessageText( UNITS_PROVIDER* aProvider, bool aDisplayUnits = true ) const;
wxString name;
wxString x;
wxString y;
};
bool operator!=( const GRID& lhs, const GRID& rhs );
bool operator<( const GRID& lhs, const GRID& rhs );
void to_json( nlohmann::json& j, const GRID& g );
void from_json( const nlohmann::json& j, GRID& g );
struct GRID_SETTINGS
{
bool axes_enabled;
std::vector<GRID> grids;
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;
int style;
int snap;
bool force_component_snap;
bool overrides_enabled;
bool override_connected;
wxString override_connected_size;
bool override_wires;
wxString override_wires_size;
bool override_vias;
wxString override_vias_size;
bool override_text;
wxString override_text_size;
bool override_graphics;
wxString override_graphics_size;
};
#endif

View File

@ -495,16 +495,16 @@ void PL_EDITOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
EDA_DRAW_FRAME::LoadSettings( aCfg );
if( aCfg->m_Window.grid.sizes.empty() )
if( aCfg->m_Window.grid.grids.empty() )
{
aCfg->m_Window.grid.sizes = { "5.00 mm",
"2.50 mm",
"2.00 mm",
"1.00 mm",
"0.50 mm",
"0.25 mm",
"0.20 mm",
"0.10 mm" };
aCfg->m_Window.grid.grids = { GRID{ wxEmptyString, wxS( "5.00 mm" ), wxS( "5.00 mm" ) },
GRID{ wxEmptyString, wxS( "2.50 mm" ), wxS( "2.50 mm" ) },
GRID{ wxEmptyString, wxS( "2.00 mm" ), wxS( "2.00 mm" ) },
GRID{ wxEmptyString, wxS( "1.00 mm" ), wxS( "1.00 mm" ) },
GRID{ wxEmptyString, wxS( "0.50 mm" ), wxS( "0.50 mm" ) },
GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
GRID{ wxEmptyString, wxS( "0.20 mm" ), wxS( "0.20 mm" ) },
GRID{ wxEmptyString, wxS( "0.10 mm" ), wxS( "0.10 mm" ) } };
}
// Currently values read from config file are not used because the user cannot

View File

@ -404,8 +404,9 @@ void DIALOG_BOARD_REANNOTATE::GetParameters()
m_gridIndex = m_GridChoice->GetSelection();
m_sortGridx = EDA_UNIT_UTILS::UI::DoubleValueFromString(
pcbIUScale, EDA_UNITS::MILS, m_settings->m_Window.grid.sizes[m_gridIndex] );
m_sortGridy = m_sortGridx;
pcbIUScale, EDA_UNITS::MILS, m_settings->m_Window.grid.grids[m_gridIndex].x );
m_sortGridy = EDA_UNIT_UTILS::UI::DoubleValueFromString(
pcbIUScale, EDA_UNITS::MILS, m_settings->m_Window.grid.grids[m_gridIndex].y );
m_annotationScope = ANNOTATE_ALL;

View File

@ -249,8 +249,8 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow*
{
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
if( cfg->m_Window.grid.sizes.empty() )
cfg->m_Window.grid.sizes = cfg->DefaultGridSizeList();
if( cfg->m_Window.grid.grids.empty() )
cfg->m_Window.grid.grids = cfg->DefaultGridSizeList();
// Currently values read from config file are not used because the user cannot
// change this config
@ -277,10 +277,12 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow*
panel->GetGAL()->SetGridVisibility( gridCfg.show );
//Bounds checking cannot include number of elements as an index!
int gridIdx = alg::clamp( 0, gridCfg.last_size_idx, (int) gridCfg.sizes.size() - 1 );
double gridSize = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::MILS,
gridCfg.sizes[ gridIdx ] );
panel->GetGAL()->SetGridSize( VECTOR2D( gridSize, gridSize ) );
int gridIdx = alg::clamp( 0, gridCfg.last_size_idx, (int) gridCfg.grids.size() - 1 );
double gridSizeX = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::MILS,
gridCfg.grids[gridIdx].x );
double gridSizeY = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::MILS,
gridCfg.grids[gridIdx].y );
panel->GetGAL()->SetGridSize( VECTOR2D( gridSizeX, gridSizeY ) );
auto painter = static_cast<KIGFX::PCB_PAINTER*>( panel->GetView()->GetPainter() );
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );

View File

@ -810,19 +810,6 @@ GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide()
}
void PCB_BASE_FRAME::DisplayGridMsg()
{
VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
wxString line;
line.Printf( wxT( "grid X %s Y %s" ),
MessageTextFromValue( gridSize.x, false ),
MessageTextFromValue( gridSize.y, false ) );
SetStatusText( line, 4 );
}
void PCB_BASE_FRAME::UpdateStatusBar()
{
EDA_DRAW_FRAME::UpdateStatusBar();
@ -895,13 +882,14 @@ void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
EDA_DRAW_FRAME::LoadSettings( aCfg );
if( aCfg->m_Window.grid.sizes.empty() )
aCfg->m_Window.grid.sizes = aCfg->DefaultGridSizeList();
if( aCfg->m_Window.grid.grids.empty() )
aCfg->m_Window.grid.grids = aCfg->DefaultGridSizeList();
// Move legacy user grids to grid list
if( !aCfg->m_Window.grid.user_grid_x.empty() )
{
aCfg->m_Window.grid.sizes.emplace_back( aCfg->m_Window.grid.user_grid_x );
aCfg->m_Window.grid.grids.emplace_back( GRID{ "User Grid", aCfg->m_Window.grid.user_grid_x,
aCfg->m_Window.grid.user_grid_y } );
aCfg->m_Window.grid.user_grid_x = wxEmptyString;
aCfg->m_Window.grid.user_grid_y = wxEmptyString;
}