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.

96 lines
3.7 KiB

  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2014 CERN
  5. * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
  6. * Author: Maciej Suminski <maciej.suminski@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.or/licenses/>.
  20. */
  21. /**
  22. * Push and Shove router settings dialog.
  23. */
  24. #include "dialog_pns_settings.h"
  25. #include <router/pns_routing_settings.h>
  26. DIALOG_PNS_SETTINGS::DIALOG_PNS_SETTINGS( wxWindow* aParent, PNS::ROUTING_SETTINGS& aSettings ) :
  27. DIALOG_PNS_SETTINGS_BASE( aParent ),
  28. m_settings( aSettings )
  29. {
  30. // Load widgets' values from settings
  31. switch( m_settings.Mode() )
  32. {
  33. case PNS::RM_MarkObstacles: m_rbMarkObstacles->SetValue( true ); break;
  34. case PNS::RM_Shove: m_rbShove->SetValue( true ); break;
  35. case PNS::RM_Walkaround: m_rbWalkaround->SetValue( true ); break;
  36. }
  37. m_shoveVias->SetValue( m_settings.ShoveVias() );
  38. m_backPressure->SetValue( m_settings.JumpOverObstacles() );
  39. m_removeLoops->SetValue( m_settings.RemoveLoops() );
  40. m_suggestEnding->SetValue( m_settings.SuggestFinish() );
  41. m_smartPads->SetValue( m_settings.SmartPads() );
  42. m_smoothDragged->SetValue( m_settings.SmoothDraggedSegments() );
  43. m_violateDrc->SetValue( m_settings.GetAllowDRCViolationsSetting() );
  44. m_freeAngleMode->SetValue( m_settings.GetFreeAngleMode() );
  45. m_optimizeEntireDraggedTrack->SetValue( m_settings.GetOptimizeEntireDraggedTrack() );
  46. m_autoPosture->SetValue( m_settings.GetAutoPosture() );
  47. m_fixAllSegments->SetValue( m_settings.GetFixAllSegments() );
  48. // Enable/disable some options
  49. wxCommandEvent event;
  50. onModeChange( event );
  51. // Don't show options that are not implemented
  52. m_suggestEnding->Hide();
  53. SetupStandardButtons();
  54. finishDialogSettings();
  55. }
  56. bool DIALOG_PNS_SETTINGS::TransferDataFromWindow()
  57. {
  58. // Save widgets' values to settings
  59. if ( m_rbMarkObstacles->GetValue() ) m_settings.SetMode( PNS::RM_MarkObstacles );
  60. else if( m_rbShove->GetValue() ) m_settings.SetMode( PNS::RM_Shove );
  61. else if( m_rbWalkaround->GetValue() ) m_settings.SetMode( PNS::RM_Walkaround );
  62. m_settings.SetShoveVias( m_shoveVias->GetValue() );
  63. m_settings.SetJumpOverObstacles( m_backPressure->GetValue() );
  64. m_settings.SetRemoveLoops( m_removeLoops->GetValue() );
  65. m_settings.SetSuggestFinish ( m_suggestEnding->GetValue() );
  66. m_settings.SetSmartPads( m_smartPads->GetValue() );
  67. m_settings.SetSmoothDraggedSegments( m_smoothDragged->GetValue() );
  68. m_settings.SetOptimizeEntireDraggedTrack( m_optimizeEntireDraggedTrack->GetValue() );
  69. m_settings.SetAutoPosture( m_autoPosture->GetValue() );
  70. m_settings.SetFixAllSegments( m_fixAllSegments->GetValue() );
  71. m_settings.SetAllowDRCViolations( m_violateDrc->GetValue() );
  72. m_settings.SetFreeAngleMode( m_freeAngleMode->GetValue() );
  73. return true;
  74. }
  75. void DIALOG_PNS_SETTINGS::onModeChange( wxCommandEvent& aEvent )
  76. {
  77. m_freeAngleMode->Enable( m_rbMarkObstacles->GetValue() );
  78. m_violateDrc->Enable( m_rbMarkObstacles->GetValue() );
  79. m_shoveVias->Enable( m_rbShove->GetValue() );
  80. m_backPressure->Enable( m_rbShove->GetValue() );
  81. }