You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
5.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
  5. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <pgm_base.h>
  25. #include <settings/settings_manager.h>
  26. #include <eeschema_settings.h>
  27. #include <panel_eeschema_display_options.h>
  28. #include <widgets/gal_options_panel.h>
  29. #include <widgets/ui_common.h>
  30. #include <widgets/font_choice.h>
  31. // The "official" name of the building Kicad stroke font (always existing)
  32. #include <font/kicad_font_name.h>
  33. PANEL_EESCHEMA_DISPLAY_OPTIONS::PANEL_EESCHEMA_DISPLAY_OPTIONS( wxWindow* aParent,
  34. APP_SETTINGS_BASE* aAppSettings ) :
  35. PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE( aParent )
  36. {
  37. m_galOptsPanel = new GAL_OPTIONS_PANEL( this, aAppSettings );
  38. m_galOptionsSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
  39. m_highlightColorNote->SetFont( KIUI::GetInfoFont( this ).Italic() );
  40. }
  41. void PANEL_EESCHEMA_DISPLAY_OPTIONS::loadEEschemaSettings( EESCHEMA_SETTINGS* cfg )
  42. {
  43. m_defaultFontCtrl->SetStringSelection( cfg->m_Appearance.default_font );
  44. if( m_defaultFontCtrl->GetSelection() < 0 )
  45. m_defaultFontCtrl->SetSelection( 0 );
  46. m_checkShowHiddenPins->SetValue( cfg->m_Appearance.show_hidden_pins );
  47. m_checkShowHiddenFields->SetValue( cfg->m_Appearance.show_hidden_fields );
  48. m_checkShowERCErrors->SetValue( cfg->m_Appearance.show_erc_errors );
  49. m_checkShowERCWarnings->SetValue( cfg->m_Appearance.show_erc_warnings );
  50. m_checkShowERCExclusions->SetValue( cfg->m_Appearance.show_erc_exclusions );
  51. m_checkPageLimits->SetValue( cfg->m_Appearance.show_page_limits );
  52. m_checkSelDrawChildItems->SetValue( cfg->m_Selection.draw_selected_children );
  53. m_checkSelFillShapes->SetValue( cfg->m_Selection.fill_shapes );
  54. m_selWidthCtrl->SetValue( cfg->m_Selection.selection_thickness );
  55. m_highlightWidthCtrl->SetValue( cfg->m_Selection.highlight_thickness );
  56. m_checkCrossProbeOnSelection->SetValue( cfg->m_CrossProbing.on_selection );
  57. m_checkCrossProbeCenter->SetValue( cfg->m_CrossProbing.center_on_items );
  58. m_checkCrossProbeZoom->SetValue( cfg->m_CrossProbing.zoom_to_fit );
  59. m_checkCrossProbeAutoHighlight->SetValue( cfg->m_CrossProbing.auto_highlight );
  60. }
  61. bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow()
  62. {
  63. SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
  64. EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
  65. loadEEschemaSettings( cfg );
  66. m_galOptsPanel->TransferDataToWindow();
  67. return true;
  68. }
  69. bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow()
  70. {
  71. SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
  72. EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
  73. cfg->m_Appearance.default_font = m_defaultFontCtrl->GetSelection() <= 0
  74. ? KICAD_FONT_NAME // This is a keyword. Do not translate
  75. : m_defaultFontCtrl->GetStringSelection();
  76. cfg->m_Appearance.show_hidden_pins = m_checkShowHiddenPins->GetValue();
  77. cfg->m_Appearance.show_hidden_fields = m_checkShowHiddenFields->GetValue();
  78. cfg->m_Appearance.show_erc_warnings = m_checkShowERCWarnings->GetValue();
  79. cfg->m_Appearance.show_erc_errors = m_checkShowERCErrors->GetValue();
  80. cfg->m_Appearance.show_erc_exclusions = m_checkShowERCExclusions->GetValue();
  81. cfg->m_Appearance.show_page_limits = m_checkPageLimits->GetValue();
  82. cfg->m_Selection.draw_selected_children = m_checkSelDrawChildItems->GetValue();
  83. cfg->m_Selection.fill_shapes = m_checkSelFillShapes->GetValue();
  84. cfg->m_Selection.selection_thickness = KiROUND( m_selWidthCtrl->GetValue() );
  85. cfg->m_Selection.highlight_thickness = KiROUND( m_highlightWidthCtrl->GetValue() );
  86. cfg->m_CrossProbing.on_selection = m_checkCrossProbeOnSelection->GetValue();
  87. cfg->m_CrossProbing.center_on_items = m_checkCrossProbeCenter->GetValue();
  88. cfg->m_CrossProbing.zoom_to_fit = m_checkCrossProbeZoom->GetValue();
  89. cfg->m_CrossProbing.auto_highlight = m_checkCrossProbeAutoHighlight->GetValue();
  90. m_galOptsPanel->TransferDataFromWindow();
  91. return true;
  92. }
  93. void PANEL_EESCHEMA_DISPLAY_OPTIONS::ResetPanel()
  94. {
  95. EESCHEMA_SETTINGS cfg;
  96. cfg.Load(); // Loading without a file will init to defaults
  97. loadEEschemaSettings( &cfg );
  98. m_galOptsPanel->ResetPanel( &cfg );
  99. }