27#include <wx/tokenzr.h>
41 aJson = nlohmann::json
51 aPoint.
x = aJson.at(
"x" ).get<
int>();
52 aPoint.
y = aJson.at(
"y" ).get<
int>();
88 for(
auto& item : items )
90 if( item && item->Parent() )
91 ent.
uuids.push_back( item->Parent()->m_Uuid );
101 std::vector<ITEM*> items;
102 items.push_back(
const_cast<ITEM*
>( item ) );
103 LogM( evt, pos, items, sizes, aLayer );
123 nlohmann::json events = nlohmann::json::array();
126 json[
"events"] = events;
128 nlohmann::json removed = nlohmann::json::array();
130 removed.push_back( uuid );
131 json[
"removedItems"] = removed;
133 nlohmann::json added = nlohmann::json::array();
136 json[
"addedItems"] = added;
138 nlohmann::json headItems = nlohmann::json::array();
141 json[
"headItems"] = headItems;
145 std::stringstream buffer;
146 buffer << std::setw( 2 ) <<
json << std::endl;
156 ret[
"position"] = aEvent.
p;
157 ret[
"type"] = aEvent.
type;
158 ret[
"layer"] = aEvent.
layer;
160 nlohmann::json uuids = nlohmann::json::array();
162 for(
int i = 0; i < (int) aEvent.
uuids.size(); i++ )
163 uuids.push_back( aEvent.
uuids[i].AsString() );
165 ret[
"uuids"] = uuids;
179 ret [
"kind"] = aItem->
KindStr();
188 switch( aItem->
Kind() )
197 auto via =
static_cast<const VIA*
>( aItem );
199 ret[
"drill"] =
via->Drill();
212 return nlohmann::json( {
220 {
"viaType", aSizes.
ViaType() } } );
226 switch( aShape->
Type() )
231 return nlohmann::json( {
232 {
"type",
"segment" },
233 {
"width", seg->GetWidth() },
234 {
"start", seg->GetStart() },
235 {
"end", seg->GetEnd() }
240 auto arc =
static_cast<const SHAPE_ARC*
>( aShape );
241 return nlohmann::json( {
243 {
"width", arc->GetWidth() },
244 {
"start", arc->GetStart() },
245 {
"end", arc->GetEnd() },
246 {
"mid", arc->GetArcMid() }
252 return nlohmann::json( {
253 {
"type",
"circle" },
254 {
"radius",
circle->GetRadius() },
255 {
"center",
circle->GetCenter() },
263 return nlohmann::json();
269 wxStringTokenizer tokens( aLine );
270 wxString cmd = tokens.GetNextToken();
274 wxCHECK_MSG( cmd == wxT(
"event" ),
EVENT_ENTRY(),
"Line doesn't contain an event!" );
277 evt.
p.
x = wxAtoi( tokens.GetNextToken() );
278 evt.
p.
y = wxAtoi( tokens.GetNextToken() );
280 evt.
layer = wxAtoi( tokens.GetNextToken() );
281 n_uuids = wxAtoi( tokens.GetNextToken() );
283 for(
int i = 0; i < n_uuids; i++)
284 evt.
uuids.push_back(
KIID( tokens.GetNextToken() ) );
294 evt.
p = aJSON.at(
"position").get<
VECTOR2I>();
295 evt.
type =
static_cast<EVENT_TYPE>( aJSON.at(
"type").get<int>() );
296 evt.
layer = aJSON.at(
"layer").get<
int>();
298 for(
auto &uuid : aJSON.at(
"uuids") )
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Base class for PNS router board items.
virtual const SHAPE * Shape(int aLayer) const
Return the geometrical shape of the item.
const PNS_LAYER_RANGE & Layers() const
virtual NET_HANDLE Net() const
PnsKind Kind() const
Return the type (kind) of the item.
virtual int Layer() const
std::string KindStr() const
static wxString FormatLogFileAsJSON(const LOG_DATA &aLogData)
void Log(EVENT_TYPE evt, const VECTOR2I &pos=VECTOR2I(), const ITEM *item=nullptr, const SIZES_SETTINGS *sizes=nullptr, int aLayer=0)
static nlohmann::json formatShapeAsJSON(const SHAPE *aShape)
static EVENT_ENTRY ParseEventFromJSON(const nlohmann::json &aJSON)
static nlohmann::json FormatEventAsJSON(const EVENT_ENTRY &aEvent)
void LogM(EVENT_TYPE evt, const VECTOR2I &pos=VECTOR2I(), std::vector< ITEM * > items={}, const SIZES_SETTINGS *sizes=nullptr, int aLayer=0)
std::vector< EVENT_ENTRY > m_events
static nlohmann::json formatRouterItemAsJSON(const PNS::ITEM *aItem)
static EVENT_ENTRY ParseEvent(const wxString &aLine)
static nlohmann::json formatSizesAsJSON(const SIZES_SETTINGS &aEvent)
virtual wxString GetNetName(PNS::NET_HANDLE aNet) const =0
ROUTER_IFACE * GetInterface() const
static ROUTER * GetInstance()
int GetLayerBottom() const
bool TrackWidthIsExplicit() const
SHAPE_TYPE Type() const
Return the type of the shape.
An abstract shape on 2D plane.
Push and Shove diff pair dimensions (gap) settings dialog.
void from_json(const nlohmann::json &aJson, VECTOR2I &aPoint)
void to_json(nlohmann::json &aJson, const VECTOR2I &aPoint)
std::vector< FAB_LAYER_COLOR > dummy
std::vector< KIID > uuids
std::optional< wxString > m_BoardHash
std::optional< TEST_CASE_TYPE > m_TestCaseType
std::vector< ITEM * > m_AddedItems
std::vector< EVENT_ENTRY > m_Events
std::set< KIID > m_RemovedItems
std::vector< ITEM * > m_Heads
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
VECTOR2< int32_t > VECTOR2I