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 <[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::Save( const std::string& aFilename )
47{
48 FILE* f = fopen( aFilename.c_str(), "wb" );
49
50 wxLogTrace( wxT( "PNS" ), wxT( "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 static_cast<const char*>( evt.uuid.AsString().c_str() ) );
58 }
59
60 fclose( f );
61}
62
63
64void 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 = KIID(0);
71
72
73 if( item && item->Parent() )
74 ent.uuid = item->Parent()->m_Uuid;
75
76 m_events.push_back( ent );
77}
78
79}
const KIID m_Uuid
Definition: eda_item.h:492
Definition: kiid.h:47
Base class for PNS router board items.
Definition: pns_item.h:56
BOARD_ITEM * Parent() const
Definition: pns_item.h:151
void Save(const std::string &aFilename)
Definition: pns_logger.cpp:46
void Clear()
Definition: pns_logger.cpp:40
std::vector< EVENT_ENTRY > m_events
Definition: pns_logger.h:72
void Log(EVENT_TYPE evt, const VECTOR2I &pos=VECTOR2I(), const ITEM *item=nullptr)
Definition: pns_logger.cpp:64
Push and Shove diff pair dimensions (gap) settings dialog.
Definition: pns_logger.h:53
KIID uuid
Definition: pns_logger.h:56
EVENT_TYPE type
Definition: pns_logger.h:55
VECTOR2I p
Definition: pns_logger.h:54