40#include <../../tests/common/console_log.h>
44 std::vector<BOARD_CONNECTED_ITEM*> parents;
46 parents.resize( evt.
uuids.size() );
48 printf(
"u %zu p %zu\n", evt.
uuids.size(), parents.size() );
52 for(
int i = 0; i < evt.
uuids.size(); i++ )
54 if( item->m_Uuid == evt.
uuids[i] )
68 if ( parents.size() > 0 )
78 fgets( str,
sizeof( str ) - 1, f );
79 return wxString( str );
84 m_mode(
PNS::ROUTER_MODE::PNS_MODE_ROUTE_SINGLE )
94 if( type == SHAPE_TYPE::SH_SEGMENT )
98 a.
x = wxAtoi( aTokens.GetNextToken() );
99 a.
y = wxAtoi( aTokens.GetNextToken() );
100 b.
x = wxAtoi( aTokens.GetNextToken() );
101 b.
y = wxAtoi( aTokens.GetNextToken() );
102 int width = wxAtoi( aTokens.GetNextToken() );
103 sh->SetSeg(
SEG( a, b ));
104 sh->SetWidth( width );
107 else if( type == SHAPE_TYPE::SH_CIRCLE )
111 a.
x = wxAtoi( aTokens.GetNextToken() );
112 a.
y = wxAtoi( aTokens.GetNextToken() );
113 int radius = wxAtoi( aTokens.GetNextToken() );
115 sh->SetRadius( radius );
123 wxStringTokenizer& aTokens )
125 if( cmd == wxS(
"net" ) )
127 aItem->
SetNet(
m_board->FindNet( wxAtoi( aTokens.GetNextToken() ) ) );
130 else if( cmd == wxS(
"layers" ) )
132 int start = wxAtoi( aTokens.GetNextToken() );
133 int end = wxAtoi( aTokens.GetNextToken() );
142 std::unique_ptr<PNS::SEGMENT> seg(
new PNS::SEGMENT() );
144 while( aTokens.CountTokens() )
146 wxString cmd = aTokens.GetNextToken();
150 if( cmd == wxS(
"shape" ) )
170 while( aTokens.CountTokens() )
172 wxString cmd = aTokens.GetNextToken();
176 if( cmd == wxS(
"shape" ) )
188 else if( cmd == wxS(
"drill" ) )
190 via->SetDrill( wxAtoi( aTokens.GetNextToken() ) );
201 wxString type = aTokens.GetNextToken();
203 if( type == wxS(
"segment" ) )
205 else if( type == wxS(
"via" ) )
216 if( a->
Net() != b->
Net() )
234 if( va->
Pos() != vb->
Pos() )
243 if( sa->
Seg() != sb->
Seg() )
254const std::set<PNS::ITEM*>
deduplicate(
const std::vector<PNS::ITEM*>& items )
256 std::set<PNS::ITEM*> rv;
260 bool isDuplicate =
false;
303 chkAddedItems.erase( chk );
311 if( chkAddedItems.empty() && check.
m_removedIds.empty() )
320 FILE* log_f = wxFopen( logFileName.GetFullPath(),
"wb" );
325 fprintf( log_f,
"%s\n", logString.c_str().AsChar() );
334 wxFileName fname_log( logFileName );
335 fname_log.SetExt( wxT(
"log" ) );
337 wxFileName fname_dump( logFileName );
338 fname_dump.SetExt( wxT(
"dump" ) );
340 wxFileName fname_project( logFileName );
341 fname_project.SetExt( wxT(
"kicad_pro" ) );
342 fname_project.MakeAbsolute();
344 wxFileName fname_settings( logFileName );
345 fname_settings.SetExt( wxT(
"settings" ) );
347 aRpt->
Report( wxString::Format( wxT(
"Loading router settings from '%s'" ),
348 fname_settings.GetFullPath() ) );
350 bool ok =
m_routerSettings->LoadFromRawFile( fname_settings.GetFullPath() );
354 aRpt->
Report( wxT(
"Failed to load routing settings. Using defaults." ),
358 aRpt->
Report( wxString::Format( wxT(
"Loading project settings from '%s'" ),
359 fname_settings.GetFullPath() ) );
369 aRpt->
Report( wxString::Format( wxT(
"Loading board snapshot from '%s'"),
370 fname_dump.GetFullPath() ) );
372 m_board.reset( io.
LoadBoard( fname_dump.GetFullPath(),
nullptr,
nullptr ) );
375 std::shared_ptr<DRC_ENGINE> drcEngine(
new DRC_ENGINE );
382 m_board->SynchronizeNetsAndNetClasses(
true );
384 drcEngine->SetBoard(
m_board.get() );
385 drcEngine->SetDesignSettings( &bds );
386 drcEngine->SetLogReporter( aRpt );
387 drcEngine->InitEngine( wxFileName() );
391 aRpt->
Report( wxString::Format(
"parse error : %s (%s)\n",
393 parse_error.
What() ),
399 FILE* f = fopen( fname_log.GetFullPath().c_str(),
"rb" );
401 aRpt->
Report( wxString::Format(
"Loading log from '%s'", fname_log.GetFullPath() ) );
412 wxStringTokenizer tokens( line );
414 if( !tokens.CountTokens() )
417 wxString cmd = tokens.GetNextToken();
419 if( cmd == wxT(
"mode" ) )
423 else if( cmd == wxT(
"event" ) )
427 else if ( cmd == wxT(
"added" ) )
432 else if ( cmd == wxT(
"removed" ) )
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
bool m_UseConnectedTrackWidth
Design Rule Checker object that performs all the DRC tests.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const wxString Problem() const
what was the problem?
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
Base class for PNS router board items.
void SetLayers(const PNS_LAYER_RANGE &aLayers)
const PNS_LAYER_RANGE & Layers() const
virtual NET_HANDLE Net() const
PnsKind Kind() const
Return the type (kind) of the item.
void SetNet(NET_HANDLE aNet)
static wxString FormatLogFileAsString(int aMode, const std::vector< ITEM * > &aAddedItems, const std::set< KIID > &aRemovedItems, const std::vector< ITEM * > &aHeads, const std::vector< EVENT_ENTRY > &aEvents)
static EVENT_ENTRY ParseEvent(const wxString &aLine)
Contain all persistent settings of the router, such as the mode, optimization effort,...
int Width() const override
int Diameter(int aLayer) const
const VECTOR2I & Pos() const
static constexpr int ALL_LAYERS
Represent a contiguous set of PCB layers.
BOARD_CONNECTED_ITEM * ItemById(const PNS::LOGGER::EVENT_ENTRY &evt)
bool Load(const wxFileName &logFileName, REPORTER *aRpt)
bool SaveLog(const wxFileName &logFileName, REPORTER *aRpt)
std::unique_ptr< PNS::SEGMENT > parsePnsSegmentFromString(wxStringTokenizer &aTokens)
std::shared_ptr< BOARD > m_board
std::shared_ptr< SETTINGS_MANAGER > m_settingsMgr
std::shared_ptr< SHAPE > parseShape(SHAPE_TYPE expectedType, wxStringTokenizer &aTokens)
std::vector< std::unique_ptr< PNS::ITEM > > m_parsed_items
std::unique_ptr< PNS::ITEM > parseItemFromString(wxStringTokenizer &aTokens)
std::unique_ptr< PNS::VIA > parsePnsViaFromString(wxStringTokenizer &aTokens)
bool parseCommonPnsProps(PNS::ITEM *aItem, const wxString &cmd, wxStringTokenizer &aTokens)
COMMIT_STATE m_commitState
std::vector< PNS::LOGGER::EVENT_ENTRY > m_events
std::vector< BOARD_CONNECTED_ITEM * > ItemsById(const PNS::LOGGER::EVENT_ENTRY &evt)
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
Container for project specific data.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
const VECTOR2I GetCenter() const
Push and Shove diff pair dimensions (gap) settings dialog.
bool comparePnsItems(const PNS::ITEM *a, const PNS::ITEM *b)
static const wxString readLine(FILE *f)
const std::set< PNS::ITEM * > deduplicate(const std::vector< PNS::ITEM * > &items)
SHAPE_TYPE
Lists all supported shapes.
A filename or source description, a problem input line, a line number, a byte offset,...
std::vector< KIID > uuids
std::set< KIID > m_removedIds
bool Compare(const COMMIT_STATE &aOther)
std::vector< PNS::ITEM * > m_addedItems
std::vector< PNS::ITEM * > m_heads