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.

88 lines
2.8 KiB

11 years ago
11 years ago
11 years ago
11 years ago
  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2014-2015 CERN
  5. * Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
  6. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * Push and Shove diff pair dimensions (gap) settings dialog.
  23. */
  24. #include "dialog_pns_diff_pair_dimensions.h"
  25. #include <widgets/text_ctrl_eval.h>
  26. #include <router/pns_sizes_settings.h>
  27. #include <draw_frame.h>
  28. DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( EDA_DRAW_FRAME* aParent,
  29. PNS::SIZES_SETTINGS& aSizes ) :
  30. DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE( aParent ),
  31. m_traceWidth( aParent, m_traceWidthLabel, m_traceWidthText, m_traceWidthUnit, true ),
  32. m_traceGap( aParent, m_traceGapLabel, m_traceGapText, m_traceGapUnit, true ),
  33. m_viaGap( aParent, m_viaGapLabel, m_viaGapText, m_viaGapUnit, true ),
  34. m_sizes( aSizes )
  35. {
  36. Layout();
  37. GetSizer()->SetSizeHints( this );
  38. Centre();
  39. m_stdButtonsOK->SetDefault();
  40. }
  41. bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow()
  42. {
  43. if( !wxDialog::TransferDataFromWindow() )
  44. return false;
  45. // Save widgets' values to settings
  46. m_sizes.SetDiffPairGap( m_traceGap.GetValue() );
  47. m_sizes.SetDiffPairViaGap( m_viaGap.GetValue() );
  48. m_sizes.SetDiffPairWidth( m_traceWidth.GetValue() );
  49. return true;
  50. }
  51. bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataToWindow()
  52. {
  53. if( !wxDialog::TransferDataToWindow() )
  54. return false;
  55. m_traceWidth.SetValue( m_sizes.DiffPairWidth() );
  56. m_traceGap.SetValue( m_sizes.DiffPairGap() );
  57. m_viaGap.SetValue( m_sizes.DiffPairViaGap() );
  58. m_viaTraceGapEqual->SetValue( m_sizes.DiffPairViaGapSameAsTraceGap() );
  59. updateCheckbox();
  60. return true;
  61. }
  62. void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::updateCheckbox()
  63. {
  64. m_sizes.SetDiffPairViaGapSameAsTraceGap( m_viaTraceGapEqual->GetValue() );
  65. m_viaGapText->Enable( !m_viaTraceGapEqual->GetValue() );
  66. m_viaGapLabel->Enable( !m_viaTraceGapEqual->GetValue() );
  67. m_viaGapUnit->Enable( !m_viaTraceGapEqual->GetValue() );
  68. }
  69. void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::OnViaTraceGapEqualCheck( wxCommandEvent& event )
  70. {
  71. updateCheckbox();
  72. }