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.

118 lines
4.4 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2010-2014 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 modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <vector>
  21. #include <pgm_base.h>
  22. #include <settings/settings_manager.h>
  23. #include <gerbview_settings.h>
  24. #include <dialogs/panel_gal_options.h>
  25. #include "panel_gerbview_display_options.h"
  26. PANEL_GERBVIEW_DISPLAY_OPTIONS::PANEL_GERBVIEW_DISPLAY_OPTIONS( wxWindow* aParent ) :
  27. PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( aParent, wxID_ANY )
  28. {
  29. GERBVIEW_SETTINGS* cfg = GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" );
  30. m_galOptsPanel = new PANEL_GAL_OPTIONS( this, cfg );
  31. m_galOptionsSizer->Add( m_galOptsPanel, 0, wxEXPAND|wxRIGHT, 15 );
  32. }
  33. void PANEL_GERBVIEW_DISPLAY_OPTIONS::loadSettings( GERBVIEW_SETTINGS* aCfg )
  34. {
  35. // Show Option Draw polygons
  36. m_OptDisplayPolygons->SetValue( !aCfg->m_Display.m_DisplayPolygonsFill );
  37. // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
  38. m_OptDisplayLines->SetValue( !aCfg->m_Display.m_DisplayLinesFill );
  39. m_OptDisplayFlashedItems->SetValue( !aCfg->m_Display.m_DisplayFlashedItemsFill );
  40. m_OptDisplayDCodes->SetValue( aCfg->m_Appearance.show_dcodes );
  41. m_spOpacityCtrl->SetValue( aCfg->m_Display.m_OpacityModeAlphaValue );
  42. if( aCfg->m_Appearance.page_type == wxT( "A4" ) )
  43. m_pageSizeA4->SetValue( true );
  44. else if( aCfg->m_Appearance.page_type == wxT( "A3" ) )
  45. m_pageSizeA3->SetValue( true );
  46. else if( aCfg->m_Appearance.page_type == wxT( "A2" ) )
  47. m_pageSizeA2->SetValue( true );
  48. else if( aCfg->m_Appearance.page_type == wxT( "A" ) )
  49. m_pageSizeA->SetValue( true );
  50. else if( aCfg->m_Appearance.page_type == wxT( "B" ) )
  51. m_pageSizeB->SetValue( true );
  52. else if( aCfg->m_Appearance.page_type == wxT( "C" ) )
  53. m_pageSizeC->SetValue( true );
  54. else
  55. m_pageSizeFull->SetValue( true );
  56. m_ShowPageLimitsOpt->SetValue( aCfg->m_Display.m_DisplayPageLimits );
  57. }
  58. bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow()
  59. {
  60. m_galOptsPanel->TransferDataToWindow();
  61. loadSettings( GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" ) );
  62. return true;
  63. }
  64. bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataFromWindow()
  65. {
  66. m_galOptsPanel->TransferDataFromWindow();
  67. if( GERBVIEW_SETTINGS* cfg = GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" ) )
  68. {
  69. cfg->m_Display.m_DisplayLinesFill = !m_OptDisplayLines->GetValue();
  70. cfg->m_Display.m_DisplayFlashedItemsFill = !m_OptDisplayFlashedItems->GetValue();
  71. cfg->m_Display.m_DisplayPolygonsFill = !m_OptDisplayPolygons->GetValue();
  72. cfg->m_Appearance.show_dcodes = m_OptDisplayDCodes->GetValue();
  73. // clang-format off
  74. if( m_pageSizeA4->GetValue() ) cfg->m_Appearance.page_type = wxT( "A4" );
  75. else if( m_pageSizeA3->GetValue() ) cfg->m_Appearance.page_type = wxT( "A3" );
  76. else if( m_pageSizeA2->GetValue() ) cfg->m_Appearance.page_type = wxT( "A2" );
  77. else if( m_pageSizeA->GetValue() ) cfg->m_Appearance.page_type = wxT( "A" );
  78. else if( m_pageSizeB->GetValue() ) cfg->m_Appearance.page_type = wxT( "B" );
  79. else if( m_pageSizeC->GetValue() ) cfg->m_Appearance.page_type = wxT( "C" );
  80. else cfg->m_Appearance.page_type = wxT( "GERBER" );
  81. // clang-format on
  82. cfg->m_Display.m_DisplayPageLimits = m_ShowPageLimitsOpt->GetValue();
  83. cfg->m_Display.m_OpacityModeAlphaValue = m_spOpacityCtrl->GetValue();
  84. }
  85. return true;
  86. }
  87. void PANEL_GERBVIEW_DISPLAY_OPTIONS::ResetPanel()
  88. {
  89. GERBVIEW_SETTINGS cfg;
  90. cfg.Load(); // Loading without a file will init to defaults
  91. loadSettings( &cfg );
  92. m_galOptsPanel->ResetPanel( &cfg );
  93. }