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.

84 lines
2.7 KiB

8 years ago
11 years ago
  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2014 CERN
  5. * Author: Maciej Suminski <maciej.suminski@cern.ch>
  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.or/licenses/>.
  19. */
  20. /**
  21. * Push and Shove router track width and via size dialog.
  22. */
  23. #include "dialog_track_via_size.h"
  24. #include <base_units.h>
  25. #include <confirm.h>
  26. #include <widgets/text_ctrl_eval.h>
  27. #include <core/optional.h>
  28. #include <eda_draw_frame.h>
  29. #include "board_design_settings.h"
  30. const int minSize = (int)( 0.01 * IU_PER_MM );
  31. DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( EDA_DRAW_FRAME* aParent,
  32. BOARD_DESIGN_SETTINGS& aSettings ) :
  33. DIALOG_TRACK_VIA_SIZE_BASE( aParent ),
  34. m_trackWidth( aParent, m_trackWidthLabel, m_trackWidthText, m_trackWidthUnits, minSize ),
  35. m_viaDiameter( aParent, m_viaDiameterLabel, m_viaDiameterText, m_viaDiameterUnits, minSize ),
  36. m_viaDrill( aParent, m_viaDrillLabel, m_viaDrillText, m_viaDrillUnits, minSize ),
  37. m_settings( aSettings )
  38. {
  39. m_stdButtonsOK->SetDefault();
  40. // Now all widgets have the size fixed, call FinishDialogSettings
  41. finishDialogSettings();
  42. }
  43. bool DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow()
  44. {
  45. if( !wxDialog::TransferDataFromWindow() )
  46. return false;
  47. if( m_viaDrill.GetValue() >= m_viaDiameter.GetValue() )
  48. {
  49. DisplayError( GetParent(), _( "Via drill size has to be smaller than via diameter" ) );
  50. m_viaDrillText->SetFocus();
  51. return false;
  52. }
  53. // Store dialog values to the router settings
  54. m_settings.SetCustomTrackWidth( m_trackWidth.GetValue() );
  55. m_settings.SetCustomViaSize( m_viaDiameter.GetValue() );
  56. m_settings.SetCustomViaDrill( m_viaDrill.GetValue() );
  57. return true;
  58. }
  59. bool DIALOG_TRACK_VIA_SIZE::TransferDataToWindow()
  60. {
  61. if( !wxDialog::TransferDataToWindow() )
  62. return false;
  63. // Load router settings to dialog fields
  64. m_trackWidth.SetValue( m_settings.GetCustomTrackWidth() );
  65. m_viaDiameter.SetValue( m_settings.GetCustomViaSize() );
  66. m_viaDrill.SetValue( m_settings.GetCustomViaDrill() );
  67. return true;
  68. }