Horizon
pns_routing_settings.h
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2014 CERN
5  * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
8  *
9  * This program is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef __PNS_ROUTING_SETTINGS
24 #define __PNS_ROUTING_SETTINGS
25 
26 #include <cstdio>
27 
28 #include <geometry/direction45.h>
29 
30 #include "time_limit.h"
31 
32 class DIRECTION_45;
33 class TOOL_SETTINGS;
34 
35 namespace PNS {
36 
38 enum PNS_MODE
39 {
40  RM_MarkObstacles = 0,
41  RM_Shove,
42  RM_Walkaround,
43 };
44 
46 enum PNS_OPTIMIZATION_EFFORT
47 {
48  OE_LOW = 0,
49  OE_MEDIUM = 1,
50  OE_FULL = 2
51 };
52 
57 class ROUTING_SETTINGS //: public NESTED_SETTINGS
58 {
59 public:
61 
63  PNS_MODE Mode() const { return m_routingMode; }
64 
66  void SetMode( PNS_MODE aMode ) { m_routingMode = aMode; }
67 
69  PNS_OPTIMIZATION_EFFORT OptimizerEffort() const { return m_optimizerEffort; }
70 
72  void SetOptimizerEffort( PNS_OPTIMIZATION_EFFORT aEffort ) { m_optimizerEffort = aEffort; }
73 
75  bool ShoveVias() const { return m_shoveVias; }
76 
78  void SetShoveVias( bool aShoveVias ) { m_shoveVias = aShoveVias; }
79 
81  bool RemoveLoops() const { return m_removeLoops; }
82 
84  void SetRemoveLoops( bool aRemoveLoops ) { m_removeLoops = aRemoveLoops; }
85 
87  bool SuggestFinish() { return m_suggestFinish; }
88 
90  void SetSuggestFinish( bool aSuggestFinish ) { m_suggestFinish = aSuggestFinish; }
91 
93  bool SmartPads() const { return m_smartPads; }
94 
96  void SetSmartPads( bool aSmartPads ) { m_smartPads = aSmartPads; }
97 
99  bool FollowMouse() const
100  {
101  return m_followMouse && !( Mode() == RM_MarkObstacles );
102  }
103 
105  bool SmoothDraggedSegments() const { return m_smoothDraggedSegments; }
106 
108  void SetSmoothDraggedSegments( bool aSmooth ) { m_smoothDraggedSegments = aSmooth; }
109 
111  bool JumpOverObstacles() const { return m_jumpOverObstacles; }
112  void SetJumpOverObstacles( bool aJump ) { m_jumpOverObstacles = aJump; }
113 
114  void SetStartDiagonal( bool aStartDiagonal ) { m_startDiagonal = aStartDiagonal; }
115 
116  bool AllowDRCViolations() const
117  {
118  return m_routingMode == PNS_MODE::RM_MarkObstacles && m_allowDRCViolations;
119  }
120 
121  bool GetAllowDRCViolationsSetting() const { return m_allowDRCViolations; }
122  void SetAllowDRCViolations( bool aViolate ) { m_allowDRCViolations = aViolate; }
123 
124  bool GetFreeAngleMode() const { return m_freeAngleMode; }
125 
126  void SetFreeAngleMode( bool aEnable ) { m_freeAngleMode = aEnable; }
127 
128  const DIRECTION_45 InitialDirection() const;
129 
130  int ShoveIterationLimit() const;
131  TIME_LIMIT ShoveTimeLimit() const;
132 
133  int WalkaroundIterationLimit() const { return m_walkaroundIterationLimit; };
134  TIME_LIMIT WalkaroundTimeLimit() const;
135 
136  void SetSnapToTracks( bool aSnap ) { m_snapToTracks = aSnap; }
137  void SetSnapToPads( bool aSnap ) { m_snapToPads = aSnap; }
138 
139  bool GetSnapToTracks() const { return m_snapToTracks; }
140  bool GetSnapToPads() const { return m_snapToPads; }
141 
142  DIRECTION_45::CORNER_MODE GetCornerMode() const { return m_cornerMode; }
143  void SetCornerMode( DIRECTION_45::CORNER_MODE aMode ) { m_cornerMode = aMode; }
144 
145  bool GetOptimizeEntireDraggedTrack() const { return m_optimizeEntireDraggedTrack; }
146  void SetOptimizeEntireDraggedTrack( bool aEnable ) { m_optimizeEntireDraggedTrack = aEnable; }
147 
148  bool GetAutoPosture() const { return m_autoPosture; }
149  void SetAutoPosture( bool aEnable ) { m_autoPosture = aEnable; }
150 
151  bool GetFixAllSegments() const { return m_fixAllSegments; }
152  void SetFixAllSegments( bool aEnable ) { m_fixAllSegments = aEnable; }
153 
154  double WalkaroundHugLengthThreshold() const { return m_walkaroundHugLengthThreshold; }
155 
156 private:
157  bool m_shoveVias;
158  bool m_startDiagonal;
159  bool m_removeLoops;
160  bool m_smartPads;
161  bool m_suggestFinish;
162  bool m_followMouse;
163  bool m_jumpOverObstacles;
164  bool m_smoothDraggedSegments;
165  bool m_allowDRCViolations;
166  bool m_freeAngleMode;
167  bool m_snapToTracks;
168  bool m_snapToPads;
169  bool m_optimizeEntireDraggedTrack;
170  bool m_autoPosture;
171  bool m_fixAllSegments;
172 
173  DIRECTION_45::CORNER_MODE m_cornerMode;
174 
175  PNS_MODE m_routingMode;
176  PNS_OPTIMIZATION_EFFORT m_optimizerEffort;
177 
178  int m_walkaroundIterationLimit;
179  int m_shoveIterationLimit;
180  double m_walkaroundHugLengthThreshold;
181 
182  TIME_LIMIT m_shoveTimeLimit;
183  TIME_LIMIT m_walkaroundTimeLimit;
184 };
185 
186 }
187 
188 #endif
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:37
CORNER_MODE
Corner modes.
Definition: direction45.h:67
Contain all persistent settings of the router, such as the mode, optimization effort,...
Definition: pns_routing_settings.h:58
ROUTING_SETTINGS()
Return the routing mode.
Definition: pns_routing_settings.cpp:30
bool RemoveLoops() const
Enable/disable loop (redundant track) removal.
Definition: pns_routing_settings.h:81
void SetShoveVias(bool aShoveVias)
Return true if loop (redundant track) removal is on.
Definition: pns_routing_settings.h:78
bool SmoothDraggedSegments() const
Enable/disable smoothing segments during dragging.
Definition: pns_routing_settings.h:105
PNS_OPTIMIZATION_EFFORT OptimizerEffort() const
Set the optimizer effort. Bigger means cleaner traces, but slower routing.
Definition: pns_routing_settings.h:69
bool FollowMouse() const
Return true if smoothing segments during dragging is enabled.
Definition: pns_routing_settings.h:99
void SetSmoothDraggedSegments(bool aSmooth)
Return true if jumping over unmovable obstacles is on.
Definition: pns_routing_settings.h:108
bool ShoveVias() const
Enable/disable shoving vias.
Definition: pns_routing_settings.h:75
bool SmartPads() const
Enable/disable Smart Pads (optimized connections).
Definition: pns_routing_settings.h:93
void SetSuggestFinish(bool aSuggestFinish)
Return true if Smart Pads (optimized connections) is enabled.
Definition: pns_routing_settings.h:90
bool SuggestFinish()
Enable displaying suggestions for finishing the currently placed track.
Definition: pns_routing_settings.h:87
void SetMode(PNS_MODE aMode)
Return the optimizer effort. Bigger means cleaner traces, but slower routing.
Definition: pns_routing_settings.h:66
PNS_MODE Mode() const
Set the routing mode.
Definition: pns_routing_settings.h:63
void SetSmartPads(bool aSmartPads)
Return true if follow mouse mode is active (permanently on for the moment).
Definition: pns_routing_settings.h:96
void SetOptimizerEffort(PNS_OPTIMIZATION_EFFORT aEffort)
Return true if shoving vias is enabled.
Definition: pns_routing_settings.h:72
void SetRemoveLoops(bool aRemoveLoops)
Return true if suggesting the finish of currently placed track is on.
Definition: pns_routing_settings.h:84