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.

91 lines
3.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright The 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 <3d_enums.h>
  25. #include <pgm_base.h>
  26. #include <settings/settings_manager.h>
  27. #include <eda_3d_viewer_settings.h>
  28. #include <widgets/color_swatch.h>
  29. #include "panel_3D_opengl_options.h"
  30. PANEL_3D_OPENGL_OPTIONS::PANEL_3D_OPENGL_OPTIONS( wxWindow* aParent ) :
  31. PANEL_3D_OPENGL_OPTIONS_BASE( aParent )
  32. {
  33. m_selectionColorSwatch->SetDefaultColor( COLOR4D( 0.0, 1.0, 0.0, 1.0 ) );
  34. m_selectionColorSwatch->SetSupportsOpacity( false );
  35. }
  36. void PANEL_3D_OPENGL_OPTIONS::loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg )
  37. {
  38. m_checkBoxCuThickness->SetValue( aCfg->m_Render.opengl_copper_thickness );
  39. m_checkBoxBoundingBoxes->SetValue( aCfg->m_Render.show_model_bbox );
  40. m_checkBoxHighlightOnRollOver->SetValue( aCfg->m_Render.highlight_on_rollover );
  41. m_choiceAntiAliasing->SetSelection( static_cast<int>( aCfg->m_Render.opengl_AA_mode ) );
  42. m_selectionColorSwatch->SetSwatchColor( aCfg->m_Render.opengl_selection_color, false );
  43. m_checkBoxDisableAAMove->SetValue( aCfg->m_Render.opengl_AA_disableOnMove );
  44. m_checkBoxDisableMoveThickness->SetValue( aCfg->m_Render.opengl_thickness_disableOnMove );
  45. m_checkBoxDisableMoveVias->SetValue( aCfg->m_Render.opengl_microvias_disableOnMove );
  46. m_checkBoxDisableMoveHoles->SetValue( aCfg->m_Render.opengl_holes_disableOnMove );
  47. }
  48. bool PANEL_3D_OPENGL_OPTIONS::TransferDataToWindow()
  49. {
  50. loadSettings( GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) );
  51. return true;
  52. }
  53. bool PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow()
  54. {
  55. if( EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) )
  56. {
  57. cfg->m_Render.opengl_copper_thickness = m_checkBoxCuThickness->GetValue();
  58. cfg->m_Render.show_model_bbox = m_checkBoxBoundingBoxes->GetValue();
  59. cfg->m_Render.highlight_on_rollover = m_checkBoxHighlightOnRollOver->GetValue();
  60. cfg->m_Render.opengl_AA_mode = static_cast<ANTIALIASING_MODE>( m_choiceAntiAliasing->GetSelection() );
  61. cfg->m_Render.opengl_selection_color = m_selectionColorSwatch->GetSwatchColor();
  62. cfg->m_Render.opengl_AA_disableOnMove = m_checkBoxDisableAAMove->GetValue();
  63. cfg->m_Render.opengl_thickness_disableOnMove = m_checkBoxDisableMoveThickness->GetValue();
  64. cfg->m_Render.opengl_microvias_disableOnMove = m_checkBoxDisableMoveVias->GetValue();
  65. cfg->m_Render.opengl_holes_disableOnMove = m_checkBoxDisableMoveHoles->GetValue();
  66. }
  67. return true;
  68. }
  69. void PANEL_3D_OPENGL_OPTIONS::ResetPanel()
  70. {
  71. EDA_3D_VIEWER_SETTINGS cfg;
  72. cfg.Load(); // Loading without a file will init to defaults
  73. loadSettings( &cfg );
  74. }