26 #include <qa/common/console_log.h> 35 fgets( str,
sizeof( str ) - 1, f );
36 return wxString( str );
47 FILE* f = fopen( logName.c_str(),
"rb" );
54 wxStringTokenizer tokens(
readLine( f ) );
55 if( !tokens.CountTokens() )
58 wxString cmd = tokens.GetNextToken();
63 evt.
p.
x = wxAtoi( tokens.GetNextToken() );
64 evt.
p.
y = wxAtoi( tokens.GetNextToken() );
66 evt.
uuid =
KIID( tokens.GetNextToken() );
67 m_events.push_back(evt);
69 else if (cmd ==
"config")
71 m_routerSettings->SetMode( (
PNS::PNS_MODE) wxAtoi( tokens.GetNextToken() ) );
72 m_routerSettings->SetRemoveLoops( wxAtoi( tokens.GetNextToken() ) );
73 m_routerSettings->SetFixAllSegments( wxAtoi( tokens.GetNextToken() ) );
81 m_board.reset( io.
Load( boardName.c_str(),
nullptr, nullptr ) );
83 std::shared_ptr<DRC_ENGINE> drcEngine(
new DRC_ENGINE );
90 drcEngine->SetBoard( m_board.get() );
91 drcEngine->SetDesignSettings( &bds );
93 drcEngine->InitEngine(wxFileName());
96 printf(
"parse error : %s (%s)\n",
97 (
const char *) parse_error.
Problem().c_str(),
98 (
const char *) parse_error.
What().c_str() );
125 m_router.reset(
new ROUTER );
126 m_iface->SetBoard( m_board.get() );
127 m_router->SetInterface( m_iface.get() );
128 m_router->ClearWorld();
129 m_router->SetMode( m_mode );
130 m_router->SyncWorld();
133 m_router->Settings().SetOptimizeDraggedTrack(
true );
135 m_debugDecorator.Clear();
136 m_iface->SetDebugDecorator( &m_debugDecorator );
148 printf(
"Router mode: %d\n", m_router->Settings().Mode() );
150 for(
auto evt : aLog->
Events() )
153 ITEM* ritem = item ? m_router->GetWorld()->FindItemByParent( item ) :
nullptr;
159 m_debugDecorator.NewStage(
"route-start", 0);
160 printf(
" rtr start-route (%d, %d) %p \n", evt.p.x, evt.p.y, ritem);
161 m_router->StartRouting( evt.p, ritem, ritem ? ritem->
Layers().
Start() :
F_Cu );
167 m_debugDecorator.NewStage(
"drag-start", 0);
168 bool rv = m_router->StartDragging( evt.p, ritem, 0 );
169 printf(
" rtr start-drag (%d, %d) %p ret %d\n", evt.p.x, evt.p.y, ritem, rv?1:0);
180 m_debugDecorator.NewStage(
"move", 0);
181 printf(
" move -> (%d, %d)\n", evt.p.x, evt.p.y );
182 m_router->Move( evt.p, ritem );
195 m_debugDecorator.BeginGroup(
"head");
197 auto traces = m_router->Placer()->Traces();
198 for (
const auto& t : traces.CItems() )
200 const LINE *l = static_cast<LINE*>(t.item);
201 const auto& sh = l->
CLine();
203 m_debugDecorator.AddLine( sh, 4, 10000 );
206 m_debugDecorator.EndGroup();
208 node = m_router->Placer()->CurrentNode(
true);
212 node = m_router->GetDragger()->CurrentNode();
222 if( ! added.empty() )
225 m_debugDecorator.BeginGroup(
"node-added-items");
227 for(
auto t : added )
231 auto s = static_cast<PNS::SEGMENT*>(t);
232 m_debugDecorator.AddSegment( s->Seg(), 2 );
237 m_debugDecorator.EndGroup();
245 if (m_stages.empty() )
246 m_stages.push_back(
new STAGE() );
248 return m_stages.back();
254 STAGE* st = currentStage();
262 m_activeEntry->AddChild( ent );
265 printf(
"LOG BeginGroup %s %p\n",
name.c_str(), ent );
274 printf(
"LOG EndGroup\n" );
279 m_activeEntry = m_activeEntry->m_parent;
287 auto st = currentStage();
288 m_activeEntry->AddChild( ent );
295 sh->
Append( aP.
x - aSize, aP.
y - aSize);
296 sh->Append( aP.
x + aSize, aP.
y + aSize);
297 sh->Append( aP.
x, aP.
y );
298 sh->Append( aP.
x - aSize, aP.
y + aSize );
299 sh->Append( aP.
x + aSize, aP.
y - aSize );
314 const std::string aName )
333 ent->m_shapes.push_back( sh );
334 ent->m_color = aColor;
335 ent->m_width = 10000;
337 ent->m_iter = m_iter;
347 ent->m_shapes.push_back( sh );
348 ent->m_color = aColor;
349 ent->m_width = 10000;
351 ent->m_iter = m_iter;
364 ent->
m_msg = msg.c_str();
375 m_stages.push_back(
new STAGE );
376 m_activeEntry = m_stages.back()->m_entries;
382 printf(
"LOG D:%d iter: %p\n", depth,
this );
383 if( ! visitor(
this ) )
387 for(
auto child : m_children )
389 child->IterateTree( visitor, depth+1 );
395 STAGE* st = m_stages[stage];
399 auto visitor = [ & ] (
DEBUG_ENT *ent ) ->
bool 401 for(
auto sh : ent->m_shapes )
406 bb.
Merge( sh->BBox() );
const SHAPE_LINE_CHAIN & CLine() const
bool Load(const std::string &logName, const std::string boardName)
Base class for PNS router board items.
Contain all persistent settings of the router, such as the mode, optimization effort,...
Design Rule Checker object that performs all the DRC tests.
virtual void BeginGroup(const std::string name) override
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Keep the router "world" - i.e.
static const wxString readLine(FILE *f)
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
virtual void AddBox(BOX2I aB, int aColor, const std::string aName="") override
void addEntry(DEBUG_ENT *ent)
std::vector< SHAPE * > m_shapes
std::vector< EVENT_ENTRY > & Events()
virtual void AddPoint(VECTOR2I aP, int aColor, int aSize=100000, const std::string aName="") override
std::shared_ptr< BOARD > GetBoard() const
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
BOARD_CONNECTED_ITEM * ItemById(const EVENT_ENTRY &evt)
PNS::ROUTING_SETTINGS * GetRoutingSettings() const
virtual const wxString Problem() const
what was the problem?
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
virtual void NewStage(const std::string &name, int iter) override
virtual void EndGroup() override
virtual const wxString What() const
A composite of Problem() and Where()
void SetMode(PNS::ROUTER_MODE mode)
coord_type GetWidth() const
virtual void AddDirections(VECTOR2D aP, int aMask, int aColor, const std::string aName="") override
virtual void Clear() override
PNS::LOGGER::EVENT_TYPE type
virtual void Message(const wxString msg) override
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
virtual void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType=0, int aWidth=0, const std::string aName="") override
BOX2I GetStageExtents(int stage) const
const Vec & GetPosition() const
void IterateTree(std::function< bool(DEBUG_ENT *)> visitor, int depth=0)
A filename or source description, a problem input line, a line number, a byte offset,...
coord_type GetHeight() const
void GetUpdatedItems(ITEM_VECTOR &aRemoved, ITEM_VECTOR &aAdded)
Return the list of items removed and added in this branch with respect to the root branch.
virtual void AddSegment(SEG aS, int aColor, const std::string aName="") override
Push and Shove diff pair dimensions (gap) settings dialog.
void ReplayLog(PNS_LOG_FILE *aLog, int aStartEventIndex=0, int aFrom=0, int aTo=-1)
std::shared_ptr< DRC_ENGINE > m_DRCEngine
const LAYER_RANGE & Layers() const
std::vector< ITEM * > ITEM_VECTOR
Container for design settings for a BOARD object.