KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_log_viewer_frame.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020, 2024 KiCad Developers.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25// WARNING - this Tom's crappy PNS hack tool code. Please don't complain about its quality
26// (unless you want to improve it).
27
28#ifndef __PNS_LOG_VIEWER_FRAME_H
29#define __PNS_LOG_VIEWER_FRAME_H
30
31#include <pcb_painter.h>
32#include <pcb_test_frame.h>
34#include <reporter.h>
35
36#include "pns_log_file.h"
37#include "pns_log_player.h"
40
41#include "label_manager.h"
42
43#define ID_LIST_COPY 10001
44#define ID_LIST_SHOW_ALL 10002
45#define ID_LIST_SHOW_NONE 10003
46#define ID_LIST_DISPLAY_LINE 10004
47
49
51{
52public:
53 PNS_VIEWER_IFACE( std::shared_ptr<BOARD> aBoard ){ m_board = aBoard; };
54 ~PNS_VIEWER_IFACE() override{};
55
56 void EraseView() override {};
57 void SyncWorld( PNS::NODE* aWorld ) override {};
58 bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override { return true; };
59 bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override { return false; };
60 bool IsFlashedOnLayer( const PNS::ITEM* aItem, const PNS_LAYER_RANGE& aLayer ) const override { return false; };
61 bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; };
62 bool IsPNSCopperLayer( int aLayer ) const override { return false; };
63 void HideItem( PNS::ITEM* aItem ) override {}
64 void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
65 int aFlags = 0 ) override {}
66 void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override {}
67 void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override {}
68 void AddItem( PNS::ITEM* aItem ) override {}
69 void UpdateItem( PNS::ITEM* aItem ) override {}
70 void RemoveItem( PNS::ITEM* aItem ) override {}
71 void Commit() override {}
72 bool ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* aStartItem,
73 PNS::NET_HANDLE aNet, VECTOR2D aStartPosition ) override { return false; }
74 int StackupHeight( int aFirstLayer, int aSecondLayer ) const override { return 0; }
75
76 int GetNetCode( PNS::NET_HANDLE aNet ) const override { return -1; }
77 wxString GetNetName( PNS::NET_HANDLE aNet ) const override { return wxEmptyString; }
78 void UpdateNet( PNS::NET_HANDLE aNet ) override {}
79 PNS::NET_HANDLE GetOrphanedNetHandle() override { return nullptr; }
80
81 virtual PNS::NODE* GetWorld() const override { return nullptr; };
82 PNS::RULE_RESOLVER* GetRuleResolver() override { return nullptr; }
83 PNS::DEBUG_DECORATOR* GetDebugDecorator() override { return nullptr; }
84
85 PCB_LAYER_ID GetBoardLayerFromPNSLayer( int aLayer ) const override
86 {
87 if( aLayer == 0 )
88 return F_Cu;
89
90 if( aLayer == m_board->GetCopperLayerCount() - 1 )
91 return B_Cu;
92
93 return ToLAYER_ID( ( aLayer + 1 ) * 2 );
94 }
95
96
97 int GetPNSLayerFromBoardLayer( PCB_LAYER_ID aLayer ) const override
98 {
99 if( aLayer == F_Cu )
100 return 0;
101
102 if( aLayer == B_Cu )
103 return m_board->GetCopperLayerCount() - 1;
104
105 return ( aLayer / 2 ) - 1;
106 }
107
108 private:
109 std::shared_ptr<BOARD> m_board;
110};
111
113{
114public:
115 PNS_LOG_VIEWER_FRAME( wxFrame* frame );
116 virtual ~PNS_LOG_VIEWER_FRAME();
117
118 void LoadLogFile( const wxString& aFile );
119 void SetLogFile( PNS_LOG_FILE* aLog );
120 void SetBoard2( std::shared_ptr<BOARD> aBoard );
122
123 std::shared_ptr<PNS_LOG_VIEWER_OVERLAY> GetOverlay() const { return m_overlay; }
124
125private:
126 void drawLoggedItems( int iter );
127 void updateDumpPanel( int iter );
128 virtual void createUserTools() override;
129 void buildListTree( wxTreeListItem item, PNS_DEBUG_SHAPE* ent, int depth = 0 );
130 void syncModel();
132 void updatePnsPreviewItems( int iter );
134 void updateViewerIface();
135
136 virtual void onOpen( wxCommandEvent& event ) override;
137 virtual void onSaveAs( wxCommandEvent& event ) override;
138 virtual void onExit( wxCommandEvent& event ) override;
139 virtual void onRewindScroll( wxScrollEvent& event ) override;
140 virtual void onRewindCountText( wxCommandEvent& event ) override;
141 virtual void onListRightClick( wxMouseEvent& event );
142 virtual void onListSelect( wxCommandEvent& event );
143 virtual void onBtnRewindLeft( wxCommandEvent& event ) override;
144 virtual void onBtnRewindRight( wxCommandEvent& event ) override;
145 virtual void onListChecked( wxCommandEvent& event );
146 virtual void onShowThinLinesChecked( wxCommandEvent& event ) override;
147 virtual void onShowRPIsChecked( wxCommandEvent& event ) override;
148 virtual void onShowVerticesChecked( wxCommandEvent& event ) override;
149 virtual void onFilterText( wxCommandEvent& event ) override;
150 void drawSimpleShape( SHAPE* aShape, bool aIsSelected, const std::string& aName );
151
152 std::shared_ptr<PNS_LOG_VIEWER_OVERLAY> m_overlay;
153 std::shared_ptr<PNS_LOG_FILE> m_logFile;
154 std::shared_ptr<PNS_LOG_PLAYER> m_logPlayer;
157 std::shared_ptr<KIGFX::VIEW_GROUP> m_previewItems;
158 std::shared_ptr<PNS_VIEWER_IFACE> m_viewerIface;
159 std::map<wxString,wxString> m_filenameToPathMap;
160
161 bool m_showThinLines = true;
162 bool m_showRPIs = true;
163 bool m_showVertices = false;
165 //KI_TEST::CONSOLE_LOG m_consoleLog;
166 std::shared_ptr<WX_TEXT_CTRL_REPORTER> m_reporter;
167};
168
169class LABEL_MANAGER;
170
172{
173public:
175 void AnnotatedPolyset( const SHAPE_POLY_SET& aL, std::string name = "",
176 bool aShowVertexNumbers = false );
177 void AnnotatedPolyline( const SHAPE_LINE_CHAIN& aL, std::string name,
178 bool aShowVertexNumbers = false );
179 void AnnotatedPoint( const VECTOR2I p, int size, std::string name = "",
180 bool aShowVertexNumbers = false );
181 void Arc( const SHAPE_ARC& arc );
182 void DrawAnnotations();
183
184private:
185
186
187 std::unique_ptr<LABEL_MANAGER> m_labelMgr;
188};
189
190#endif
const char * name
Definition: DXF_plotter.cpp:57
Abstract interface for drawing on a 2D-surface.
Base class for PNS router board items.
Definition: pns_item.h:97
Keep the router "world" - i.e.
Definition: pns_node.h:231
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
Class PNS_LOG_VIEWER_FRAME_BASE.
std::shared_ptr< WX_TEXT_CTRL_REPORTER > m_reporter
std::shared_ptr< PNS_LOG_FILE > m_logFile
virtual void onListRightClick(wxMouseEvent &event)
std::shared_ptr< PNS_LOG_PLAYER > m_logPlayer
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > GetOverlay() const
std::map< wxString, wxString > m_filenameToPathMap
void drawSimpleShape(SHAPE *aShape, bool aIsSelected, const std::string &aName)
virtual void onRewindCountText(wxCommandEvent &event) override
std::shared_ptr< KIGFX::VIEW_GROUP > m_previewItems
PNS_DEBUG_STAGE * getCurrentStage()
bool filterStringMatches(PNS_DEBUG_SHAPE *ent)
void SetBoard2(std::shared_ptr< BOARD > aBoard)
virtual void createUserTools() override
void buildListTree(wxTreeListItem item, PNS_DEBUG_SHAPE *ent, int depth=0)
virtual void onShowVerticesChecked(wxCommandEvent &event) override
void SetLogFile(PNS_LOG_FILE *aLog)
virtual void onShowThinLinesChecked(wxCommandEvent &event) override
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > m_overlay
void LoadLogFile(const wxString &aFile)
virtual void onListChecked(wxCommandEvent &event)
std::shared_ptr< PNS_VIEWER_IFACE > m_viewerIface
virtual void onListSelect(wxCommandEvent &event)
virtual void onSaveAs(wxCommandEvent &event) override
virtual void onRewindScroll(wxScrollEvent &event) override
virtual void onShowRPIsChecked(wxCommandEvent &event) override
void updatePnsPreviewItems(int iter)
virtual void onBtnRewindRight(wxCommandEvent &event) override
virtual void onFilterText(wxCommandEvent &event) override
virtual void onOpen(wxCommandEvent &event) override
virtual void onBtnRewindLeft(wxCommandEvent &event) override
virtual void onExit(wxCommandEvent &event) override
void AnnotatedPoint(const VECTOR2I p, int size, std::string name="", bool aShowVertexNumbers=false)
void AnnotatedPolyset(const SHAPE_POLY_SET &aL, std::string name="", bool aShowVertexNumbers=false)
void AnnotatedPolyline(const SHAPE_LINE_CHAIN &aL, std::string name, bool aShowVertexNumbers=false)
std::unique_ptr< LABEL_MANAGER > m_labelMgr
void Arc(const SHAPE_ARC &arc)
int StackupHeight(int aFirstLayer, int aSecondLayer) const override
void RemoveItem(PNS::ITEM *aItem) override
void AddItem(PNS::ITEM *aItem) override
int GetPNSLayerFromBoardLayer(PCB_LAYER_ID aLayer) const override
PNS::DEBUG_DECORATOR * GetDebugDecorator() override
bool IsFlashedOnLayer(const PNS::ITEM *aItem, int aLayer) const override
int GetNetCode(PNS::NET_HANDLE aNet) const override
PNS_VIEWER_IFACE(std::shared_ptr< BOARD > aBoard)
void DisplayPathLine(const SHAPE_LINE_CHAIN &aLine, int aImportance) override
PCB_LAYER_ID GetBoardLayerFromPNSLayer(int aLayer) const override
void SyncWorld(PNS::NODE *aWorld) override
bool IsPNSCopperLayer(int aLayer) const override
bool IsAnyLayerVisible(const PNS_LAYER_RANGE &aLayer) const override
void UpdateItem(PNS::ITEM *aItem) override
bool IsFlashedOnLayer(const PNS::ITEM *aItem, const PNS_LAYER_RANGE &aLayer) const override
void Commit() override
void UpdateNet(PNS::NET_HANDLE aNet) override
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, PNS::NET_HANDLE aNet, VECTOR2D aStartPosition) override
wxString GetNetName(PNS::NET_HANDLE aNet) const override
PNS::NET_HANDLE GetOrphanedNetHandle() override
~PNS_VIEWER_IFACE() override
void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, PNS::NET_HANDLE aNet) override
bool IsItemVisible(const PNS::ITEM *aItem) const override
virtual PNS::NODE * GetWorld() const override
PNS::RULE_RESOLVER * GetRuleResolver() override
std::shared_ptr< BOARD > m_board
void HideItem(PNS::ITEM *aItem) override
void EraseView() override
void DisplayItem(const PNS::ITEM *aItem, int aClearance, bool aEdit=false, int aFlags=0) override
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
An abstract shape on 2D plane.
Definition: shape.h:126
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Cu
Definition: layer_ids.h:65
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
void * NET_HANDLE
Definition: pns_item.h:54