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.

128 lines
4.9 KiB

10 years ago
10 years ago
  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2013-2014 CERN
  5. * Copyright (C) 2016 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. #include <geometry/direction45.h>
  22. #include <settings/parameters.h>
  23. #include "pns_routing_settings.h"
  24. namespace PNS {
  25. const int pnsSchemaVersion = 0;
  26. ROUTING_SETTINGS::ROUTING_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
  27. NESTED_SETTINGS( "pns", pnsSchemaVersion, aParent, aPath )
  28. {
  29. m_routingMode = RM_Walkaround;
  30. m_optimizerEffort = OE_MEDIUM;
  31. m_removeLoops = true;
  32. m_smartPads = true;
  33. m_shoveVias = true;
  34. m_suggestFinish = false;
  35. m_followMouse = true;
  36. m_startDiagonal = false;
  37. m_shoveIterationLimit = 250;
  38. m_shoveTimeLimit = 1000;
  39. m_walkaroundIterationLimit = 40;
  40. m_jumpOverObstacles = false;
  41. m_smoothDraggedSegments = true;
  42. m_allowDRCViolations = false;
  43. m_freeAngleMode = false;
  44. m_snapToTracks = false;
  45. m_snapToPads = false;
  46. m_optimizeEntireDraggedTrack = false;
  47. m_cornerMode = DIRECTION_45::CORNER_MODE::MITERED_45;
  48. m_walkaroundHugLengthThreshold = 1.5;
  49. m_autoPosture = true;
  50. m_fixAllSegments = true;
  51. m_params.emplace_back( new PARAM<int>( "mode", reinterpret_cast<int*>( &m_routingMode ),
  52. static_cast<int>( RM_Walkaround ) ) );
  53. m_params.emplace_back( new PARAM<int>( "effort", reinterpret_cast<int*>( &m_optimizerEffort ),
  54. static_cast<int>( OE_MEDIUM ) ) );
  55. m_params.emplace_back( new PARAM<bool>( "remove_loops", &m_removeLoops, true ) );
  56. m_params.emplace_back( new PARAM<bool>( "smart_pads", &m_smartPads, true ) );
  57. m_params.emplace_back( new PARAM<bool>( "shove_vias", &m_shoveVias, true ) );
  58. m_params.emplace_back( new PARAM<bool>( "suggest_finish", &m_suggestFinish, false ) );
  59. m_params.emplace_back( new PARAM<bool>( "follow_mouse", &m_followMouse, true ) );
  60. m_params.emplace_back( new PARAM<bool>( "start_diagonal", &m_startDiagonal, false ) );
  61. m_params.emplace_back( new PARAM<int>( "shove_iteration_limit", &m_shoveIterationLimit, 250 ) );
  62. m_params.emplace_back( new PARAM_LAMBDA<int>( "shove_time_limit",
  63. [this] () -> int
  64. {
  65. return m_shoveTimeLimit.Get();
  66. },
  67. [this] ( int aVal )
  68. {
  69. m_shoveTimeLimit.Set( aVal );
  70. },
  71. 1000 ) );
  72. m_params.emplace_back( new PARAM<int>( "walkaround_iteration_limit", &m_walkaroundIterationLimit, 40 ) );
  73. m_params.emplace_back( new PARAM<bool>( "jump_over_obstacles", &m_jumpOverObstacles, false ) );
  74. m_params.emplace_back( new PARAM<bool>( "smooth_dragged_segments", &m_smoothDraggedSegments, true ) );
  75. m_params.emplace_back( new PARAM<bool>( "can_violate_drc", &m_allowDRCViolations, false ) );
  76. m_params.emplace_back( new PARAM<bool>( "free_angle_mode", &m_freeAngleMode, false ) );
  77. m_params.emplace_back( new PARAM<bool>( "snap_to_tracks", &m_snapToTracks, false ) );
  78. m_params.emplace_back( new PARAM<bool>( "snap_to_pads", &m_snapToPads, false ) );
  79. m_params.emplace_back( new PARAM<bool>( "optimize_dragged_track",
  80. &m_optimizeEntireDraggedTrack, false ) );
  81. m_params.emplace_back( new PARAM<bool>( "auto_posture", &m_autoPosture, true ) );
  82. m_params.emplace_back( new PARAM<bool>( "fix_all_segments", &m_fixAllSegments, true ) );
  83. m_params.emplace_back( new PARAM_ENUM<DIRECTION_45::CORNER_MODE>(
  84. "corner_mode", &m_cornerMode, DIRECTION_45::CORNER_MODE::MITERED_45,
  85. DIRECTION_45::CORNER_MODE::ROUNDED_90, DIRECTION_45::CORNER_MODE::MITERED_45 ) );
  86. m_params.emplace_back( new PARAM<double>( "walkaround_hug_length_threshold", &m_walkaroundHugLengthThreshold, 1.5 ) );
  87. LoadFromFile();
  88. }
  89. const DIRECTION_45 ROUTING_SETTINGS::InitialDirection() const
  90. {
  91. if( m_startDiagonal )
  92. return DIRECTION_45( DIRECTION_45::NE );
  93. else
  94. return DIRECTION_45( DIRECTION_45::N );
  95. }
  96. TIME_LIMIT ROUTING_SETTINGS::ShoveTimeLimit() const
  97. {
  98. return TIME_LIMIT ( m_shoveTimeLimit );
  99. }
  100. int ROUTING_SETTINGS::ShoveIterationLimit() const
  101. {
  102. return m_shoveIterationLimit;
  103. }
  104. }