From 70b98c3b490ee7b8b974072b10cb06f783a555de Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 17 Apr 2020 00:35:44 +0200 Subject: [PATCH] router: dump entire event log + annotated PCB upon user request --- pcbnew/router/router_tool.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 34b38822b2..095ebd17f0 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -57,6 +57,10 @@ using namespace std::placeholders; #include "pns_kicad_iface.h" +#ifdef DEBUG +#include +#endif + using namespace KIGFX; /** @@ -474,9 +478,37 @@ void ROUTER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent ) switch( aEvent.KeyCode() ) { case '0': -// fixme: move to new logging infrastructure + { + auto logger = m_router->Logger(); + if( ! logger ) + return; + + FILE *f = fopen("/tmp/pns.log", "wb"); + wxLogTrace( "PNS", "saving drag/route log...\n" ); + + const auto& events = logger->GetEvents(); + + for( auto evt : events) + { + wxString id = "null"; + if( evt.item && evt.item->Parent() ) + id = evt.item->Parent()->m_Uuid.AsString(); + + fprintf(f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type, (const char*) id.c_str() ); + } + + fclose(f); + + // Export as *.kicad_pcb format, using a strategy which is specifically chosen + // as an example on how it could also be used to send it to the system clipboard. + + PCB_IO pcb_io; + + pcb_io.Save("/tmp/pns.dump", m_iface->GetBoard(), nullptr ); + break; } + } } #endif }