22 #ifndef __PNS_ROUTER_H
23 #define __PNS_ROUTER_H
28 #include <core/optional.h>
29 #include <boost/unordered_set.hpp>
31 #include <geometry/shape_line_chain.h>
33 #include "pns_routing_settings.h"
34 #include "pns_sizes_settings.h"
36 #include "pns_itemset.h"
38 #include "../wx_compat.h"
50 class DEBUG_DECORATOR;
52 class DIFF_PAIR_PLACER;
66 PNS_MODE_ROUTE_SINGLE = 1,
67 PNS_MODE_ROUTE_DIFF_PAIR,
69 PNS_MODE_TUNE_DIFF_PAIR,
70 PNS_MODE_TUNE_DIFF_PAIR_SKEW
93 virtual void SetRouter(
ROUTER* aRouter ) = 0;
94 virtual void SyncWorld(
NODE* aNode ) = 0;
95 virtual void AddItem(
ITEM* aItem ) = 0;
96 virtual void RemoveItem(
ITEM* aItem ) = 0;
97 virtual void DisplayItem(
const ITEM* aItem,
int aColor = -1,
int aClearance = -1 ) = 0;
98 virtual void HideItem(
ITEM* aItem ) = 0;
99 virtual void Commit() = 0;
102 virtual void EraseView() = 0;
103 virtual void UpdateNet(
int aNetCode ) = 0;
124 void SetMode ( ROUTER_MODE aMode );
125 ROUTER_MODE Mode()
const {
return m_mode; }
127 static ROUTER* GetInstance();
132 void SetView( KIGFX::VIEW* aView );
134 bool RoutingInProgress()
const;
135 bool StartRouting(
const VECTOR2I& aP,
ITEM* aItem,
int aLayer );
137 bool FixRoute(
const VECTOR2I& aP,
ITEM* aItem,
bool aForceFinish =
false );
142 int GetClearance(
const ITEM* aA,
const ITEM* aB )
const;
144 NODE* GetWorld()
const
146 return m_world.get();
151 void DisplayItem(
const ITEM* aItem,
int aColor = -1,
int aClearance = -1 );
152 void DisplayItems(
const ITEM_SET& aItems );
153 void DeleteTraces(
ITEM* aStartItem,
bool aWholeTrack );
154 void SwitchLayer(
int layer );
156 void ToggleViaPlacement();
157 void SetOrthoMode(
bool aEnable );
159 int GetCurrentLayer()
const;
160 const std::vector<int> GetCurrentNets()
const;
166 return m_iface->GetRuleResolver();
169 bool IsPlacingVia()
const;
174 bool StartDragging(
const VECTOR2I& aP,
ITEM* aItem,
int aDragMode = DM_ANY );
176 void SetIterLimit(
int aX ) { m_iterLimit = aX; }
177 int GetIterLimit()
const {
return m_iterLimit; };
179 void SetShowIntermediateSteps(
bool aX,
int aSnapshotIter = -1 )
181 m_showInterSteps = aX;
182 m_snapshotIter = aSnapshotIter;
185 bool GetShowIntermediateSteps()
const {
return m_showInterSteps; }
186 int GetShapshotIter()
const {
return m_snapshotIter; }
190 void CommitRouting(
NODE* aNode );
204 m_settings = aSettings;
212 void SetFailureReason(
const std::string& aReason ) { m_failureReason = aReason; }
213 const std::string& FailureReason()
const {
return m_failureReason; }
215 PLACEMENT_ALGO* Placer() {
return m_placer.get(); }
217 ROUTER_IFACE* GetInterface()
const
223 void movePlacing(
const VECTOR2I& aP, ITEM* aItem );
224 void moveDragging(
const VECTOR2I& aP, ITEM* aItem );
227 void updateView( NODE* aNode, ITEM_SET& aCurrent );
229 void clearViewFlags();
233 ITEM* pickSingleItem( ITEM_SET& aItems )
const;
234 void splitAdjacentSegments( NODE* aNode, ITEM* aSeg,
const VECTOR2I& aP );
236 ITEM* syncPad( D_PAD* aPad );
237 ITEM* syncTrack( TRACK* aTrack );
238 ITEM* syncVia( VIA* aVia );
240 void commitPad( SOLID* aPad );
241 void commitSegment( SEGMENT* aTrack );
242 void commitVia( VIA* aVia );
244 void highlightCurrent(
bool enabled );
246 void markViolations( NODE* aNode, ITEM_SET& aCurrent, NODE::ITEM_VECTOR& aRemoved );
247 bool isStartingPointRoutable(
const VECTOR2I& aWhere,
int aLayer );
252 std::unique_ptr< NODE > m_world;
255 std::unique_ptr< PLACEMENT_ALGO > m_placer;
256 std::unique_ptr< DRAGGER > m_dragger;
257 std::unique_ptr< SHOVE > m_shove;
259 ROUTER_IFACE* m_iface;
262 bool m_showInterSteps;
265 bool m_forceMarkObstaclesMode =
false;
267 ROUTING_SETTINGS m_settings;
268 SIZES_SETTINGS m_sizes;
271 std::string m_toolStatusbarName;
272 std::string m_failureReason;