KiCad PCB EDA Suite
pns_routing_settings.cpp
Go to the documentation of this file.
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 
22 #include <geometry/direction45.h>
23 #include <settings/parameters.h>
24 
25 #include "pns_routing_settings.h"
26 
27 namespace PNS {
28 
29 const int pnsSchemaVersion = 0;
30 
31 
32 ROUTING_SETTINGS::ROUTING_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
33  NESTED_SETTINGS( "pns", pnsSchemaVersion, aParent, aPath )
34 {
37  m_removeLoops = true;
38  m_smartPads = true;
39  m_shoveVias = true;
40  m_suggestFinish = false;
41  m_followMouse = true;
42  m_startDiagonal = false;
44  m_shoveTimeLimit = 1000;
46  m_jumpOverObstacles = false;
48  m_canViolateDRC = false;
49  m_freeAngleMode = false;
50  m_inlineDragEnabled = false;
51  m_snapToTracks = false;
52  m_snapToPads = false;
54  m_minRadius = 0;
55  m_maxRadius = 1000000;
56  m_roundedCorners = false;
57 
58  m_params.emplace_back( new PARAM<int>( "mode", reinterpret_cast<int*>( &m_routingMode ),
59  static_cast<int>( RM_Walkaround ) ) );
60 
61  m_params.emplace_back( new PARAM<int>( "effort", reinterpret_cast<int*>( &m_optimizerEffort ),
62  static_cast<int>( OE_MEDIUM ) ) );
63 
64  m_params.emplace_back( new PARAM<bool>( "remove_loops", &m_removeLoops, true ) );
65  m_params.emplace_back( new PARAM<bool>( "smart_pads", &m_smartPads, true ) );
66  m_params.emplace_back( new PARAM<bool>( "shove_vias", &m_shoveVias, true ) );
67  m_params.emplace_back( new PARAM<bool>( "suggest_finish", &m_suggestFinish, false ) );
68  m_params.emplace_back( new PARAM<bool>( "follow_mouse", &m_followMouse, true ) );
69  m_params.emplace_back( new PARAM<bool>( "start_diagonal", &m_startDiagonal, false ) );
70  m_params.emplace_back( new PARAM<int>( "shove_iteration_limit", &m_shoveIterationLimit, 250 ) );
71 
72  m_params.emplace_back( new PARAM_LAMBDA<int>( "shove_time_limit",
73  [this] () -> int
74  {
75  return m_shoveTimeLimit.Get();
76  },
77  [this] ( int aVal )
78  {
79  m_shoveTimeLimit.Set( aVal );
80  },
81  1000 ) );
82 
83  m_params.emplace_back( new PARAM<int>( "walkaround_iteration_limit", &m_walkaroundIterationLimit, 40 ) );
84  m_params.emplace_back( new PARAM<bool>( "jump_over_obstacles", &m_jumpOverObstacles, false ) );
85 
86  m_params.emplace_back( new PARAM<bool>( "smooth_dragged_segments", &m_smoothDraggedSegments, true ) );
87 
88  m_params.emplace_back( new PARAM<bool>( "can_violate_drc", &m_canViolateDRC, false ) );
89  m_params.emplace_back( new PARAM<bool>( "free_angle_mode", &m_freeAngleMode, false ) );
90  m_params.emplace_back( new PARAM<bool>( "inline_drag", &m_inlineDragEnabled, false ) );
91  m_params.emplace_back( new PARAM<bool>( "snap_to_tracks", &m_snapToTracks, false ) );
92  m_params.emplace_back( new PARAM<bool>( "snap_to_pads", &m_snapToPads, false ) );
93  m_params.emplace_back( new PARAM<bool>( "optimize_dragged_track", &m_optimizeDraggedTrack, true ) );
94 
95  m_params.emplace_back( new PARAM<int>( "min_radius", &m_minRadius, 0 ) );
96  m_params.emplace_back( new PARAM<int>( "max_radius", &m_maxRadius, 1000000 ) );
97  m_params.emplace_back( new PARAM<bool>( "use_rounded", &m_roundedCorners, false ) );
98 
99  LoadFromFile();
100 }
101 
102 
104 {
105  if( m_startDiagonal )
106  return DIRECTION_45( DIRECTION_45::NE );
107  else
108  return DIRECTION_45( DIRECTION_45::N );
109 }
110 
111 
113 {
114  return TIME_LIMIT ( m_shoveTimeLimit );
115 }
116 
117 
119 {
120  return m_shoveIterationLimit;
121 }
122 
123 }
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:296
const DIRECTION_45 InitialDirection() const
void Set(int aMilliseconds)
Definition: time_limit.cpp:51
PNS_OPTIMIZATION_EFFORT m_optimizerEffort
bool LoadFromFile(const wxString &aDirectory="") override
Loads the JSON document from the parent and then calls Load()
NESTED_SETTINGS is a JSON_SETTINGS that lives inside a JSON_SETTINGS.
DIRECTION_45.
Definition: direction45.h:37
const int pnsSchemaVersion
ROUTING_SETTINGS(JSON_SETTINGS *aParent, const std::string &aPath)
Push and Shove diff pair dimensions (gap) settings dialog.
int Get() const
Definition: time_limit.h:39
TIME_LIMIT ShoveTimeLimit() const