KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_logger.cpp
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2014 CERN
5 * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "pns_logger.h"
23#include "pns_item.h"
24#include "pns_via.h"
25
26#include <wx/log.h>
27
28namespace PNS {
29
31{
32}
33
34
36{
37}
38
39
41{
42 m_events.clear();
43}
44
45
46void LOGGER::Log( LOGGER::EVENT_TYPE evt, const VECTOR2I& pos, const ITEM* item,
47 const SIZES_SETTINGS* sizes )
48{
50
51 ent.type = evt;
52 ent.p = pos;
53 ent.uuid = KIID( 0 );
54
55 if( sizes )
56 {
57 ent.sizes = *sizes;
58 }
59
60 if( item && item->Parent() )
61 ent.uuid = item->Parent()->m_Uuid;
62
63 m_events.push_back( ent );
64}
65
66
68 const std::vector<ITEM*>& aAddedItems,
69 const std::set<KIID>& aRemovedItems,
70 const std::vector<ITEM*>& aHeads,
71 const std::vector<LOGGER::EVENT_ENTRY>& aEvents )
72{
73 wxString result = wxString::Format( "mode %d\n", aMode );
74
75 for( const EVENT_ENTRY& evt : aEvents )
76 result += PNS::LOGGER::FormatEvent( evt );
77
78 for( const KIID& uuid : aRemovedItems )
79 result += wxString::Format( "removed %s\n", uuid.AsString().c_str() );
80
81 for( ITEM* item : aAddedItems )
82 result += wxString::Format( "added %s\n", item->Format().c_str() );
83
84 for( ITEM* item : aHeads )
85 result += wxString::Format( "head %s\n", item->Format().c_str() );
86
87 return result;
88}
89
90
92{
93 return wxString::Format(
94 "event %d %d %d %s %d %d %d %d %d %d %d\n", aEvent.p.x, aEvent.p.y, aEvent.type,
95 static_cast<const char*>( aEvent.uuid.AsString().c_str() ), aEvent.sizes.TrackWidth(),
96 aEvent.sizes.ViaDiameter(), aEvent.sizes.ViaDrill(),
97 aEvent.sizes.TrackWidthIsExplicit() ? 1 : 0, aEvent.sizes.GetLayerBottom(),
98 aEvent.sizes.GetLayerTop(), static_cast<int>( aEvent.sizes.ViaType() ) );
99
100}
101
102
104{
105 wxStringTokenizer tokens( aLine );
106 wxString cmd = tokens.GetNextToken();
107
108 wxCHECK_MSG( cmd == wxT( "event" ), EVENT_ENTRY(), "Line doesn't contain an event!" );
109
110 EVENT_ENTRY evt;
111 evt.p.x = wxAtoi( tokens.GetNextToken() );
112 evt.p.y = wxAtoi( tokens.GetNextToken() );
113 evt.type = (PNS::LOGGER::EVENT_TYPE) wxAtoi( tokens.GetNextToken() );
114 evt.uuid = KIID( tokens.GetNextToken() );
115
116 return evt;
117}
118
119}
const KIID m_Uuid
Definition: eda_item.h:489
Definition: kiid.h:49
wxString AsString() const
Definition: kiid.cpp:238
Base class for PNS router board items.
Definition: pns_item.h:97
BOARD_ITEM * Parent() const
Definition: pns_item.h:186
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)
Definition: pns_logger.cpp:67
void Clear()
Definition: pns_logger.cpp:40
static wxString FormatEvent(const EVENT_ENTRY &aEvent)
Definition: pns_logger.cpp:91
std::vector< EVENT_ENTRY > m_events
Definition: pns_logger.h:94
void Log(EVENT_TYPE evt, const VECTOR2I &pos=VECTOR2I(), const ITEM *item=nullptr, const SIZES_SETTINGS *sizes=nullptr)
Definition: pns_logger.cpp:46
static EVENT_ENTRY ParseEvent(const wxString &aLine)
Definition: pns_logger.cpp:103
VIATYPE ViaType() const
bool TrackWidthIsExplicit() const
Push and Shove diff pair dimensions (gap) settings dialog.
Definition: pns_logger.h:56
SIZES_SETTINGS sizes
Definition: pns_logger.h:60
KIID uuid
Definition: pns_logger.h:59
EVENT_TYPE type
Definition: pns_logger.h:58
VECTOR2I p
Definition: pns_logger.h:57