KiCad PCB EDA Suite
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-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
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 
28 namespace PNS {
29 
31 {
32 }
33 
34 
36 {
37 }
38 
39 
41 {
42  m_events.clear();
43 }
44 
45 
46 void LOGGER::Save( const std::string& aFilename )
47 {
48  FILE* f = fopen( aFilename.c_str(), "wb" );
49 
50  wxLogTrace( "PNS", "Saving to '%s' [%p]", aFilename.c_str(), f );
51 
52  for( const EVENT_ENTRY& evt : m_events )
53  {
54  uint64_t id = 0;
55 
56  fprintf( f, "event %d %d %d %s\n", evt.type, evt.p.x, evt.p.y,
57  (const char*) evt.uuid.c_str() );
58  }
59 
60  fclose( f );
61 }
62 
63 
64 void LOGGER::Log( LOGGER::EVENT_TYPE evt, const VECTOR2I& pos, const ITEM* item )
65 {
67 
68  ent.type = evt;
69  ent.p = pos;
70  ent.uuid = "null";
71 
72 
73  if( item && item->Parent() )
74  ent.uuid = item->Parent()->m_Uuid.AsString();
75 
76  m_events.push_back( ent );
77 }
78 
79 }
Base class for PNS router board items.
Definition: pns_item.h:55
wxString uuid
Definition: pns_logger.h:54
wxString AsString() const
Definition: kiid.cpp:218
BOARD_ITEM * Parent() const
Definition: pns_item.h:147
std::vector< EVENT_ENTRY > m_events
Definition: pns_logger.h:70
Definition: pns_logger.h:51
EVENT_TYPE type
Definition: pns_logger.h:53
void Clear()
Definition: pns_logger.cpp:40
const KIID m_Uuid
Definition: eda_item.h:475
void Save(const std::string &aFilename)
Definition: pns_logger.cpp:46
VECTOR2I p
Definition: pns_logger.h:52
Push and Shove diff pair dimensions (gap) settings dialog.
void Log(EVENT_TYPE evt, const VECTOR2I &pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:64