KiCad PCB EDA Suite
PNS_LOG_VIEWER_FRAME Class Reference

#include <pns_log_viewer_frame.h>

Inheritance diagram for PNS_LOG_VIEWER_FRAME:
PNS_LOG_VIEWER_FRAME_BASE PCB_TEST_FRAME_BASE

Public Member Functions

 PNS_LOG_VIEWER_FRAME (wxFrame *frame)
 
virtual ~PNS_LOG_VIEWER_FRAME ()
 
void SetLogFile (PNS_LOG_FILE *aLog)
 
void SetBoard2 (std::shared_ptr< BOARD > aBoard)
 
std::shared_ptr< PNS_LOG_VIEWER_OVERLAYGetOverlay () const
 
virtual void SetBoard (std::shared_ptr< BOARD > b)
 
virtual BOARDLoadAndDisplayBoard (const std::string &filename)
 
std::shared_ptr< PCB_DRAW_PANEL_GALGetPanel ()
 
std::shared_ptr< BOARDGetBoard ()
 
void LoadSettings ()
 

Protected Member Functions

virtual void onRewindCountText2 (wxCommandEvent &event)
 
void createView (wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL_TYPE aGalType=PCB_DRAW_PANEL_GAL::GAL_TYPE_OPENGL)
 

Protected Attributes

wxMenuBar * m_menubar1
 
wxMenu * m_menu1
 
wxBoxSizer * m_mainSizer
 
wxStaticText * m_rewindText
 
wxButton * m_rewindLeft
 
wxSlider * m_rewindSlider
 
wxButton * m_rewindRight
 
wxTextCtrl * m_rewindPos
 
wxBoxSizer * m_viewSizer
 
wxTreeListCtrl * m_itemList
 
wxStatusBar * m_statusBar
 
std::shared_ptr< PCB_DRAW_PANEL_GALm_galPanel
 
std::shared_ptr< BOARDm_board
 
KIGFX::GAL_DISPLAY_OPTIONS m_displayOptions
 

Private Member Functions

void drawLoggedItems (int iter)
 
void updateDumpPanel (int iter)
 
virtual void createUserTools () override
 
void buildListTree (wxTreeListItem item, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT *ent, int depth=0)
 
void syncModel ()
 
PNS_TEST_DEBUG_DECORATOR::STAGEgetCurrentStage ()
 
virtual void onReload (wxCommandEvent &event) override
 
virtual void onExit (wxCommandEvent &event) override
 
virtual void onRewindScroll (wxScrollEvent &event) override
 
virtual void onRewindCountText (wxCommandEvent &event) override
 
virtual void onListRightClick (wxMouseEvent &event)
 
virtual void onListSelect (wxCommandEvent &event)
 
virtual void onBtnRewindLeft (wxCommandEvent &event) override
 
virtual void onBtnRewindRight (wxCommandEvent &event) override
 
virtual void onListChecked (wxCommandEvent &event)
 

Private Attributes

std::shared_ptr< PNS_LOG_VIEWER_OVERLAYm_overlay
 
std::shared_ptr< PNS_LOG_FILEm_logFile
 
std::shared_ptr< PNS_TEST_ENVIRONMENTm_env
 
int m_rewindIter
 
wxMenu * m_listPopupMenu
 

Detailed Description

Definition at line 43 of file pns_log_viewer_frame.h.

Constructor & Destructor Documentation

◆ PNS_LOG_VIEWER_FRAME()

PNS_LOG_VIEWER_FRAME::PNS_LOG_VIEWER_FRAME ( wxFrame *  frame)

Definition at line 278 of file pns_log_viewer.cpp.

278  : PNS_LOG_VIEWER_FRAME_BASE( frame )
279 {
280  LoadSettings();
282 
283  m_viewSizer->Add( m_galPanel.get(), 1, wxEXPAND, 5 );
284 
285  Layout();
286 
287  Show( true );
288  Maximize();
289  Raise();
290 
291  auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
292  m_galPanel->GetView()->GetPainter()->GetSettings() );
293 
294  settings->SetZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED );
295 
296  m_listPopupMenu = new wxMenu( wxT( "" ) );
297  m_listPopupMenu->Append( ID_LIST_COPY, wxT( "Copy selected geometry" ), wxT( "" ),
298  wxITEM_NORMAL );
299  m_listPopupMenu->Append( ID_LIST_SHOW_ALL, wxT( "Show all" ), wxT( "" ), wxITEM_NORMAL );
300  m_listPopupMenu->Append( ID_LIST_SHOW_NONE, wxT( "Show none" ), wxT( "" ), wxITEM_NORMAL );
301 
302  m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CONTEXT_MENU,
303  wxMouseEventHandler( PNS_LOG_VIEWER_FRAME::onListRightClick ), nullptr,
304  this );
305  //m_itemList->Connect(m_itemList->GetId(),wxEVT_LISTBOX,wxCommandEventHandler(PNS_LOG_VIEWER_FRAME::onListSelect),nullptr,this);
306  m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_SELECTION_CHANGED,
307  wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListSelect ),
308  nullptr, this );
309  m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CHECKED,
310  wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListChecked ),
311  nullptr, this );
312 
313  m_itemList->AppendColumn( "Type" );
314  m_itemList->AppendColumn( "Value" );
315  m_itemList->AppendColumn( "File" );
316  m_itemList->AppendColumn( "Method" );
317  m_itemList->AppendColumn( "Line" );
318 
319  m_overlay.reset( new PNS_LOG_VIEWER_OVERLAY ( m_galPanel->GetGAL() ) );
320  m_galPanel->GetView()->Add( m_overlay.get() );
321 }
#define ID_LIST_COPY
void createView(wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL_TYPE aGalType=PCB_DRAW_PANEL_GAL::GAL_TYPE_OPENGL)
#define ID_LIST_SHOW_ALL
#define ID_LIST_SHOW_NONE
PNS_LOG_VIEWER_FRAME_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT("P&S Log Viewer"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > m_overlay
virtual void onListRightClick(wxMouseEvent &event)
virtual void onListSelect(wxCommandEvent &event)
virtual void onListChecked(wxCommandEvent &event)

References PCB_TEST_FRAME_BASE::createView(), EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, ID_LIST_COPY, ID_LIST_SHOW_ALL, ID_LIST_SHOW_NONE, PCB_TEST_FRAME_BASE::LoadSettings(), PCB_TEST_FRAME_BASE::m_galPanel, PNS_LOG_VIEWER_FRAME_BASE::m_itemList, m_listPopupMenu, m_overlay, PNS_LOG_VIEWER_FRAME_BASE::m_viewSizer, onListChecked(), onListRightClick(), onListSelect(), and SHOW_FILLED.

◆ ~PNS_LOG_VIEWER_FRAME()

PNS_LOG_VIEWER_FRAME::~PNS_LOG_VIEWER_FRAME ( )
virtual

Definition at line 324 of file pns_log_viewer.cpp.

325 {
326  m_overlay = nullptr;
327 }
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > m_overlay

References m_overlay.

Member Function Documentation

◆ buildListTree()

void PNS_LOG_VIEWER_FRAME::buildListTree ( wxTreeListItem  item,
PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT ent,
int  depth = 0 
)
private

Definition at line 668 of file pns_log_viewer.cpp.

670 {
671 #ifdef EXTRA_VERBOSE
672  for( int i = 0; i < depth * 2; i++ )
673  printf( " " );
674 
675  if( ent->m_msg.length() )
676  printf( "MSG: %s\n", ent->m_msg.c_str() );
677  else
678  printf( "SHAPES: %s [%d]\n", ent->m_name.c_str(), ent->m_children.size() );
679 #endif
680 
681  wxTreeListItem ritem;
682 
683  printf("depth %d\n", depth );
684 
685  if( ent->m_msg.length() )
686  {
687  ritem = m_itemList->AppendItem( item, "Child" );
688  m_itemList->SetItemText( ritem, 0, "Message" );
689  m_itemList->SetItemText( ritem, 1, ent->m_msg );
690  }
691  else
692  {
693  ritem = m_itemList->AppendItem( item, "Child" );
694  m_itemList->SetItemText( ritem, 0, "Shapes" );
695  m_itemList->SetItemText( ritem, 1, ent->m_name );
696  }
697 
698  m_itemList->SetItemText( ritem, 2, wxFileNameFromPath( ent->m_srcLoc.fileName ) );
699  m_itemList->SetItemText( ritem, 3, ent->m_srcLoc.funcName );
700  m_itemList->SetItemText( ritem, 4, wxString::Format("%d", ent->m_srcLoc.line ) );
701 
702  m_itemList->SetItemData( ritem, new WX_SHAPE_TREE_ITEM_DATA( ent ) );
703 
704  if( !ent->m_children.size() )
705  return;
706 
707  for( auto child : ent->m_children )
708  {
709  buildListTree( ritem, child, depth + 1 );
710  }
711 }
void buildListTree(wxTreeListItem item, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT *ent, int depth=0)
std::vector< DEBUG_ENT * > m_children
Definition: pns_log.h:174
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO m_srcLoc
Definition: pns_log.h:181

References PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO::fileName, Format(), PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO::funcName, PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO::line, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT::m_children, PNS_LOG_VIEWER_FRAME_BASE::m_itemList, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT::m_msg, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT::m_name, and PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT::m_srcLoc.

Referenced by updateDumpPanel().

◆ createUserTools()

void PNS_LOG_VIEWER_FRAME::createUserTools ( )
overrideprivatevirtual

Reimplemented from PCB_TEST_FRAME_BASE.

Definition at line 330 of file pns_log_viewer.cpp.

331 {
332 
333 }

◆ createView()

void PCB_TEST_FRAME_BASE::createView ( wxWindow *  aParent,
PCB_DRAW_PANEL_GAL::GAL_TYPE  aGalType = PCB_DRAW_PANEL_GAL::GAL_TYPE_OPENGL 
)
protectedinherited

Definition at line 128 of file pcb_test_frame.cpp.

129 {
130  // SUPERSAMPLING_X4;
132 
133  m_galPanel = std::make_shared<PCB_DRAW_PANEL_GAL>( aParent, -1, wxPoint( 0, 0 ),
134  wxDefaultSize, m_displayOptions, aGalType );
135  m_galPanel->UpdateColors();
136 
137  m_galPanel->SetEvtHandlerEnabled( true );
138  m_galPanel->SetFocus();
139  m_galPanel->Show( true );
140  m_galPanel->Raise();
141  m_galPanel->StartDrawing();
142 
143  auto gal = m_galPanel->GetGAL();
144 
145  gal->SetGridVisibility( true );
146  gal->SetGridSize( VECTOR2D( 100000.0, 100000.0 ) );
147  gal->SetGridOrigin( VECTOR2D( 0.0, 0.0 ) );
148 
149  //m_galPanel->Connect( wxEVT_MOTION,
150  //wxMouseEventHandler( PCB_TEST_FRAME::OnMotion ), nullptr, this );
151 
152  m_galPanel->GetViewControls()->ShowCursor( true );
153 
154 #ifdef USE_TOOL_MANAGER
155  m_toolManager = std::make_unique<TOOL_MANAGER>( );
156  m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(),
157  m_galPanel->GetViewControls(), nullptr );
158 
159  m_pcbActions = std::make_unique<TEST_ACTIONS>( );
160  m_toolDispatcher = std::make_unique<TOOL_DISPATCHER>( m_toolManager.get() );
161 
162  //m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
163  createUserTools();
164 
165  m_toolManager->InitTools();
166  m_toolManager->InvokeTool( "test.DefaultTool" );
167 #endif
168 
169  //SetBoard( std::make_shared<BOARD>( new BOARD ));
170 }
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
KIGFX::GAL_DISPLAY_OPTIONS m_displayOptions
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void createUserTools()
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel
std::shared_ptr< BOARD > m_board

References KIGFX::NONE.

Referenced by PNS_LOG_VIEWER_FRAME().

◆ drawLoggedItems()

void PNS_LOG_VIEWER_FRAME::drawLoggedItems ( int  iter)
private

Definition at line 356 of file pns_log_viewer.cpp.

357 {
358  if( !m_env )
359  return;
360 
362 
363  if( !st )
364  return;
365 
366  m_overlay.reset( new PNS_LOG_VIEWER_OVERLAY ( m_galPanel->GetGAL() ) );
367  m_galPanel->GetView()->Add( m_overlay.get() );
368 
369  auto drawShapes = [&]( PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* ent ) -> bool
370  {
371  bool isEnabled = ent->IsVisible();
372  bool isSelected = false;
373 
374  if( !isEnabled )
375  return true;
376 
377  for( auto& sh : ent->m_shapes )
378  {
379  COLOR4D color = ent->m_color;
380  int lineWidth = ent->m_width;
381 
382  m_overlay->SetIsStroke( true );
383  m_overlay->SetIsFill( false );
384 
385  if( isSelected )
386  {
387  color.Brighten( 0.5 );
388  }
389 
390  m_overlay->SetStrokeColor( color );
391  m_overlay->SetLineWidth( ent->m_width );
392 
393  switch( sh->Type() )
394  {
395  case SH_CIRCLE:
396  {
397  auto cir = static_cast<SHAPE_CIRCLE*>( sh );
398  m_overlay->Circle( cir->GetCenter(), cir->GetRadius() );
399 
400  break;
401  }
402  case SH_RECT:
403  {
404  auto rect = static_cast<SHAPE_RECT*>( sh );
405  m_overlay->Rectangle( rect->GetPosition(), rect->GetPosition() + rect->GetSize() );
406 
407  break;
408  }
409  case SH_LINE_CHAIN:
410  {
411  auto lc = static_cast<SHAPE_LINE_CHAIN*>( sh );
412  m_overlay->AnnotatedPolyline( *lc, ent->m_name, ent->m_hasLabels && isSelected );
413 
414  break;
415 
416  }
417  default:
418  break;
419  }
420  }
421 
422  return true;
423  };
424 
426 
427  m_overlay->DrawAnnotations();
428 
429  m_galPanel->GetView()->MarkDirty();
430  m_galPanel->GetParent()->Refresh();
431 }
int color
Definition: DXF_plotter.cpp:57
PNS_TEST_DEBUG_DECORATOR::STAGE * getCurrentStage()
int drawShapes(int argc, char *argv[])
Definition: playground.cpp:230
circle
Definition: shape.h:46
void IterateTree(std::function< bool(DEBUG_ENT *)> visitor, int depth=0)
Definition: pns_log.cpp:440
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > m_overlay
std::shared_ptr< PNS_TEST_ENVIRONMENT > m_env
line chain (polyline)
Definition: shape.h:45
axis-aligned rectangle
Definition: shape.h:43
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, drawShapes(), getCurrentStage(), PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT::IterateTree(), PNS_TEST_DEBUG_DECORATOR::STAGE::m_entries, m_env, PCB_TEST_FRAME_BASE::m_galPanel, m_overlay, SH_CIRCLE, SH_LINE_CHAIN, and SH_RECT.

Referenced by onBtnRewindLeft(), onBtnRewindRight(), onListChecked(), onListRightClick(), onListSelect(), onRewindCountText(), onRewindScroll(), and SetLogFile().

◆ GetBoard()

std::shared_ptr< BOARD > PCB_TEST_FRAME_BASE::GetBoard ( )
inlineinherited

Definition at line 59 of file pcb_test_frame.h.

59 { return m_board; }
std::shared_ptr< BOARD > m_board

References PCB_TEST_FRAME_BASE::m_board.

◆ getCurrentStage()

PNS_TEST_DEBUG_DECORATOR::STAGE * PNS_LOG_VIEWER_FRAME::getCurrentStage ( )
private

Definition at line 336 of file pns_log_viewer.cpp.

337 {
338  PNS_TEST_DEBUG_DECORATOR* dbgd = m_env->GetDebugDecorator();
339  int count = dbgd->GetStageCount();
340 
341  int iter = m_rewindIter;
342 
343  if( count <= 0 )
344  return nullptr;
345 
346  if( iter < 0 )
347  iter = 0;
348 
349  if( iter >= count )
350  iter = count - 1;
351 
352  return dbgd->GetStage( iter );
353 }
STAGE * GetStage(int index)
Definition: pns_log.h:243
int GetStageCount() const
Definition: pns_log.h:241
std::shared_ptr< PNS_TEST_ENVIRONMENT > m_env

References PNS_TEST_DEBUG_DECORATOR::GetStage(), PNS_TEST_DEBUG_DECORATOR::GetStageCount(), m_env, and m_rewindIter.

Referenced by drawLoggedItems(), and onListRightClick().

◆ GetOverlay()

std::shared_ptr<PNS_LOG_VIEWER_OVERLAY> PNS_LOG_VIEWER_FRAME::GetOverlay ( ) const
inline

Definition at line 52 of file pns_log_viewer_frame.h.

52 { return m_overlay; }
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > m_overlay

References m_overlay.

◆ GetPanel()

std::shared_ptr< PCB_DRAW_PANEL_GAL > PCB_TEST_FRAME_BASE::GetPanel ( )
inlineinherited

Definition at line 58 of file pcb_test_frame.h.

58 { return m_galPanel; }
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel

References PCB_TEST_FRAME_BASE::m_galPanel.

◆ LoadAndDisplayBoard()

BOARD * PCB_TEST_FRAME_BASE::LoadAndDisplayBoard ( const std::string &  filename)
virtualinherited

Definition at line 102 of file pcb_test_frame.cpp.

103 {
104  PLUGIN::RELEASER pi( new PCB_PLUGIN );
105  BOARD* brd = nullptr;
106 
107  try
108  {
109  brd = pi->Load( wxString( filename.c_str() ), nullptr, nullptr );
110  }
111  catch( const IO_ERROR& ioe )
112  {
113  wxPrintf( "Board Loading Error: '%s'\n", ioe.Problem() );
114  return nullptr;
115  }
116 
117  //SetBoard( brd );
118 
119  return brd;
120 }
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Definition: pcb_plugin.h:141
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:46
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:555
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75

References IO_ERROR::Problem().

◆ LoadSettings()

void PCB_TEST_FRAME_BASE::LoadSettings ( )
inherited

Definition at line 184 of file pcb_test_frame.cpp.

185 {
186  auto cs = Pgm().GetSettingsManager().GetColorSettings();
187  //cs->SetColorContext( COLOR_CONTEXT::PCB );
188  cs->Load();
189 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106

References Pgm().

Referenced by PNS_LOG_VIEWER_FRAME().

◆ onBtnRewindLeft()

void PNS_LOG_VIEWER_FRAME::onBtnRewindLeft ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PNS_LOG_VIEWER_FRAME_BASE.

Definition at line 531 of file pns_log_viewer.cpp.

532 {
533  if( m_rewindIter > 0 )
534  {
535  m_rewindIter--;
538  char str[128];
539  sprintf( str, "%d", m_rewindIter );
540  m_rewindPos->SetValue( str );
541  }
542 }
void updateDumpPanel(int iter)
void drawLoggedItems(int iter)

References drawLoggedItems(), m_rewindIter, PNS_LOG_VIEWER_FRAME_BASE::m_rewindPos, and updateDumpPanel().

◆ onBtnRewindRight()

void PNS_LOG_VIEWER_FRAME::onBtnRewindRight ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PNS_LOG_VIEWER_FRAME_BASE.

Definition at line 545 of file pns_log_viewer.cpp.

546 {
547  auto dbgd = m_env->GetDebugDecorator();
548  int count = dbgd->GetStageCount();
549 
550  if( m_rewindIter < count )
551  {
552  m_rewindIter++;
555  char str[128];
556  sprintf( str, "%d", m_rewindIter );
557  m_rewindPos->SetValue( str );
558  }
559 }
void updateDumpPanel(int iter)
std::shared_ptr< PNS_TEST_ENVIRONMENT > m_env
void drawLoggedItems(int iter)

References drawLoggedItems(), m_env, m_rewindIter, PNS_LOG_VIEWER_FRAME_BASE::m_rewindPos, and updateDumpPanel().

◆ onExit()

void PNS_LOG_VIEWER_FRAME::onExit ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PNS_LOG_VIEWER_FRAME_BASE.

Definition at line 506 of file pns_log_viewer.cpp.

507 {
508  event.Skip();
509 }

◆ onListChecked()

void PNS_LOG_VIEWER_FRAME::onListChecked ( wxCommandEvent &  event)
privatevirtual

Definition at line 512 of file pns_log_viewer.cpp.

References drawLoggedItems(), m_rewindIter, and syncModel().

Referenced by PNS_LOG_VIEWER_FRAME().

◆ onListRightClick()

void PNS_LOG_VIEWER_FRAME::onListRightClick ( wxMouseEvent &  event)
privatevirtual

Definition at line 606 of file pns_log_viewer.cpp.

607 {
608  auto sel = m_itemList->GetPopupMenuSelectionFromUser( *m_listPopupMenu );
609 
610  switch( sel )
611  {
612  case ID_LIST_SHOW_NONE:
613  m_itemList->CheckItemRecursively( m_itemList->GetRootItem(), wxCHK_UNCHECKED );
614  syncModel();
616  break;
617  case ID_LIST_SHOW_ALL:
618  m_itemList->CheckItemRecursively( m_itemList->GetRootItem(), wxCHK_CHECKED );
619  syncModel();
621  break;
622  case ID_LIST_COPY:
623  {
624  wxString s;
625 
627 
628  if( !st )
629  return;
630 
631  auto formatShapes = [&]( PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* ent ) -> bool
632  {
633  if( ent->m_selected )
634  {
635  for( auto sh : ent->m_shapes )
636  {
637  s += "// " + ent->m_name + "\n " + sh->Format() + "; \n";
638  }
639  }
640 
641  return true;
642  };
643 
644  st->m_entries->IterateTree( formatShapes );
645 
646  if( wxTheClipboard->Open() )
647  {
648  // This data objects are held by the clipboard,
649  // so do not delete them in the app.
650  wxTheClipboard->SetData( new wxTextDataObject( s ) );
651  wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
652  wxTheClipboard->Close();
653  }
654 
655  return;
656  }
657  }
658 }
#define ID_LIST_COPY
PNS_TEST_DEBUG_DECORATOR::STAGE * getCurrentStage()
#define ID_LIST_SHOW_ALL
#define ID_LIST_SHOW_NONE
void IterateTree(std::function< bool(DEBUG_ENT *)> visitor, int depth=0)
Definition: pns_log.cpp:440
void drawLoggedItems(int iter)

References drawLoggedItems(), getCurrentStage(), ID_LIST_COPY, ID_LIST_SHOW_ALL, ID_LIST_SHOW_NONE, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT::IterateTree(), PNS_TEST_DEBUG_DECORATOR::STAGE::m_entries, PNS_LOG_VIEWER_FRAME_BASE::m_itemList, m_listPopupMenu, m_rewindIter, and syncModel().

Referenced by PNS_LOG_VIEWER_FRAME().

◆ onListSelect()

void PNS_LOG_VIEWER_FRAME::onListSelect ( wxCommandEvent &  event)
privatevirtual

Definition at line 661 of file pns_log_viewer.cpp.

References drawLoggedItems(), m_rewindIter, and syncModel().

Referenced by PNS_LOG_VIEWER_FRAME().

◆ onReload()

void PNS_LOG_VIEWER_FRAME::onReload ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PNS_LOG_VIEWER_FRAME_BASE.

Definition at line 501 of file pns_log_viewer.cpp.

502 {
503  event.Skip();
504 }

◆ onRewindCountText()

void PNS_LOG_VIEWER_FRAME::onRewindCountText ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PNS_LOG_VIEWER_FRAME_BASE.

Definition at line 562 of file pns_log_viewer.cpp.

563 {
564  if( !m_env )
565  return;
566 
567  int val = wxAtoi( m_rewindPos->GetValue() );
568 
569  auto dbgd = m_env->GetDebugDecorator();
570  int count = dbgd->GetStageCount();
571 
572  if( val < 0 )
573  val = 0;
574 
575  if( val >= count )
576  val = count - 1;
577 
578  m_rewindIter = val;
579  m_rewindSlider->SetValue( m_rewindIter );
582 
583  event.Skip();
584 }
void updateDumpPanel(int iter)
std::shared_ptr< PNS_TEST_ENVIRONMENT > m_env
void drawLoggedItems(int iter)

References drawLoggedItems(), m_env, m_rewindIter, PNS_LOG_VIEWER_FRAME_BASE::m_rewindPos, PNS_LOG_VIEWER_FRAME_BASE::m_rewindSlider, and updateDumpPanel().

◆ onRewindCountText2()

virtual void PNS_LOG_VIEWER_FRAME_BASE::onRewindCountText2 ( wxCommandEvent &  event)
inlineprotectedvirtualinherited

◆ onRewindScroll()

void PNS_LOG_VIEWER_FRAME::onRewindScroll ( wxScrollEvent &  event)
overrideprivatevirtual

Reimplemented from PNS_LOG_VIEWER_FRAME_BASE.

Definition at line 519 of file pns_log_viewer.cpp.

520 {
521  m_rewindIter = event.GetPosition();
524  char str[128];
525  sprintf( str, "%d", m_rewindIter );
526  m_rewindPos->SetValue( str );
527  event.Skip();
528 }
void updateDumpPanel(int iter)
void drawLoggedItems(int iter)

References drawLoggedItems(), m_rewindIter, PNS_LOG_VIEWER_FRAME_BASE::m_rewindPos, and updateDumpPanel().

◆ SetBoard()

void PCB_TEST_FRAME_BASE::SetBoard ( std::shared_ptr< BOARD b)
virtualinherited

Definition at line 76 of file pcb_test_frame.cpp.

77 {
78  m_board = b;
79 
80  PROF_COUNTER cntConnectivity( "connectivity-build" );
81  m_board->GetConnectivity()->Build( m_board.get() );
82  cntConnectivity.Stop();
83 
84  PROF_COUNTER cntView("view-build");
85  m_galPanel->DisplayBoard( m_board.get() );
86  cntView.Stop();
87 
88  m_galPanel->UpdateColors();
89 
90  KI_TRACE( traceGalProfile, "%s\n", cntConnectivity.to_string() );
91  KI_TRACE( traceGalProfile, "%s\n", cntView.to_string() );
92 
93 #ifdef USE_TOOL_MANAGER
94  m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(),
95  m_galPanel->GetViewControls(), nullptr );
96 
97  m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
98 #endif
99 }
Model changes (required full reload)
Definition: tool_base.h:80
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
A small class to help profiling.
Definition: profile.h:45
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel
std::shared_ptr< BOARD > m_board
#define KI_TRACE(...)

References KI_TRACE, TOOL_BASE::MODEL_RELOAD, PROF_COUNTER::Stop(), PROF_COUNTER::to_string(), and traceGalProfile.

Referenced by SetBoard2(), and SetLogFile().

◆ SetBoard2()

void PNS_LOG_VIEWER_FRAME::SetBoard2 ( std::shared_ptr< BOARD aBoard)

Definition at line 486 of file pns_log_viewer.cpp.

487 {
488  SetBoard( aBoard );
489 
490  auto extents = m_board->GetBoundingBox();
491 
492  BOX2D bbd;
493  bbd.SetOrigin( extents.GetOrigin() );
494  bbd.SetWidth( extents.GetWidth() );
495  bbd.SetHeight( extents.GetHeight() );
496  bbd.Inflate( std::min( bbd.GetWidth(), bbd.GetHeight() ) / 5 );
497 
498  m_galPanel->GetView()->SetViewport( bbd );
499 }
coord_type GetWidth() const
Definition: box2.h:180
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel
std::shared_ptr< BOARD > m_board
void SetHeight(coord_type val)
Definition: box2.h:206
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:281
virtual void SetBoard(std::shared_ptr< BOARD > b)
void SetOrigin(const Vec &pos)
Definition: box2.h:193
coord_type GetHeight() const
Definition: box2.h:181
void SetWidth(coord_type val)
Definition: box2.h:205

References BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), PCB_TEST_FRAME_BASE::m_board, PCB_TEST_FRAME_BASE::m_galPanel, PCB_TEST_FRAME_BASE::SetBoard(), BOX2< Vec >::SetHeight(), BOX2< Vec >::SetOrigin(), and BOX2< Vec >::SetWidth().

◆ SetLogFile()

void PNS_LOG_VIEWER_FRAME::SetLogFile ( PNS_LOG_FILE aLog)

Definition at line 452 of file pns_log_viewer.cpp.

453 {
454  m_logFile.reset( aLog );
455 
456  SetBoard( m_logFile->GetBoard() );
457 
458  m_env.reset( new PNS_TEST_ENVIRONMENT );
459 
460  m_env->SetMode( PNS::PNS_MODE_ROUTE_SINGLE );
461  m_env->ReplayLog( m_logFile.get() );
462 
463  auto dbgd = m_env->GetDebugDecorator();
464  int n_stages = dbgd->GetStageCount();
465  m_rewindSlider->SetMax( n_stages - 1 );
466  m_rewindSlider->SetValue( n_stages - 1 );
467  m_rewindIter = n_stages - 1;
468 
469  auto extents = m_board->GetBoundingBox();
470 
471 
472  BOX2D bbd;
473  bbd.SetOrigin( extents.GetOrigin() );
474  bbd.SetWidth( extents.GetWidth() );
475  bbd.SetHeight( extents.GetHeight() );
476  bbd.Inflate( std::min( bbd.GetWidth(), bbd.GetHeight() ) / 5 );
477 
478  m_galPanel->GetView()->SetViewport( bbd );
479 
482 }
std::shared_ptr< PNS_LOG_FILE > m_logFile
void updateDumpPanel(int iter)
coord_type GetWidth() const
Definition: box2.h:180
std::shared_ptr< PCB_DRAW_PANEL_GAL > m_galPanel
std::shared_ptr< BOARD > m_board
void SetHeight(coord_type val)
Definition: box2.h:206
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:281
std::shared_ptr< PNS_TEST_ENVIRONMENT > m_env
virtual void SetBoard(std::shared_ptr< BOARD > b)
void SetOrigin(const Vec &pos)
Definition: box2.h:193
coord_type GetHeight() const
Definition: box2.h:181
void drawLoggedItems(int iter)
void SetWidth(coord_type val)
Definition: box2.h:205

References drawLoggedItems(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), PCB_TEST_FRAME_BASE::m_board, m_env, PCB_TEST_FRAME_BASE::m_galPanel, m_logFile, m_rewindIter, PNS_LOG_VIEWER_FRAME_BASE::m_rewindSlider, PNS::PNS_MODE_ROUTE_SINGLE, PCB_TEST_FRAME_BASE::SetBoard(), BOX2< Vec >::SetHeight(), BOX2< Vec >::SetOrigin(), BOX2< Vec >::SetWidth(), and updateDumpPanel().

◆ syncModel()

void PNS_LOG_VIEWER_FRAME::syncModel ( )
private

Definition at line 587 of file pns_log_viewer.cpp.

588 {
589  for( wxTreeListItem item = m_itemList->GetFirstItem(); item.IsOk();
590  item = m_itemList->GetNextItem( item ) )
591  {
592  WX_SHAPE_TREE_ITEM_DATA* idata =
593  static_cast<WX_SHAPE_TREE_ITEM_DATA*>( m_itemList->GetItemData( item ) );
594 
595  if( idata )
596  {
597  bool checked = m_itemList->GetCheckedState( item ) == wxCHK_CHECKED;
598  bool selected = m_itemList->IsSelected( item );
599  idata->m_item->m_visible = checked || selected;
600  idata->m_item->m_selected = selected;
601  }
602  }
603 }
PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT * m_item

References WX_SHAPE_TREE_ITEM_DATA::m_item, PNS_LOG_VIEWER_FRAME_BASE::m_itemList, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT::m_selected, and PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT::m_visible.

Referenced by onListChecked(), onListRightClick(), and onListSelect().

◆ updateDumpPanel()

void PNS_LOG_VIEWER_FRAME::updateDumpPanel ( int  iter)
private

Definition at line 726 of file pns_log_viewer.cpp.

727 {
728  if( !m_env )
729  return;
730 
731  auto dbgd = m_env->GetDebugDecorator();
732  int count = dbgd->GetStageCount();
733 
734  wxArrayString dumpStrings;
735 
736  if( count <= 0 )
737  return;
738 
739  if( iter < 0 )
740  iter = 0;
741 
742  if( iter >= count )
743  iter = count - 1;
744 
745  auto st = dbgd->GetStage( iter );
746  auto rootItem = m_itemList->GetRootItem();
747 
748  m_itemList->DeleteAllItems();
749  buildListTree( rootItem, st->m_entries );
750  m_itemList->CheckItemRecursively( rootItem, wxCHK_UNCHECKED );
751 
753 
754  m_itemList->Refresh();
755 }
void buildListTree(wxTreeListItem item, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT *ent, int depth=0)
static void expandAllChildren(wxTreeListCtrl *tree)
std::shared_ptr< PNS_TEST_ENVIRONMENT > m_env

References buildListTree(), expandAllChildren(), m_env, and PNS_LOG_VIEWER_FRAME_BASE::m_itemList.

Referenced by onBtnRewindLeft(), onBtnRewindRight(), onRewindCountText(), onRewindScroll(), and SetLogFile().

Member Data Documentation

◆ m_board

std::shared_ptr< BOARD > PCB_TEST_FRAME_BASE::m_board
protectedinherited

Definition at line 69 of file pcb_test_frame.h.

Referenced by PCB_TEST_FRAME_BASE::GetBoard(), SetBoard2(), and SetLogFile().

◆ m_displayOptions

KIGFX::GAL_DISPLAY_OPTIONS PCB_TEST_FRAME_BASE::m_displayOptions
protectedinherited

Definition at line 70 of file pcb_test_frame.h.

◆ m_env

std::shared_ptr<PNS_TEST_ENVIRONMENT> PNS_LOG_VIEWER_FRAME::m_env
private

◆ m_galPanel

std::shared_ptr< PCB_DRAW_PANEL_GAL > PCB_TEST_FRAME_BASE::m_galPanel
protectedinherited

◆ m_itemList

wxTreeListCtrl* PNS_LOG_VIEWER_FRAME_BASE::m_itemList
protectedinherited

◆ m_listPopupMenu

wxMenu* PNS_LOG_VIEWER_FRAME::m_listPopupMenu
private

Definition at line 77 of file pns_log_viewer_frame.h.

Referenced by onListRightClick(), and PNS_LOG_VIEWER_FRAME().

◆ m_logFile

std::shared_ptr<PNS_LOG_FILE> PNS_LOG_VIEWER_FRAME::m_logFile
private

Definition at line 74 of file pns_log_viewer_frame.h.

Referenced by SetLogFile().

◆ m_mainSizer

wxBoxSizer* PNS_LOG_VIEWER_FRAME_BASE::m_mainSizer
protectedinherited

◆ m_menu1

wxMenu* PNS_LOG_VIEWER_FRAME_BASE::m_menu1
protectedinherited

◆ m_menubar1

wxMenuBar* PNS_LOG_VIEWER_FRAME_BASE::m_menubar1
protectedinherited

◆ m_overlay

std::shared_ptr<PNS_LOG_VIEWER_OVERLAY> PNS_LOG_VIEWER_FRAME::m_overlay
private

◆ m_rewindIter

int PNS_LOG_VIEWER_FRAME::m_rewindIter
private

◆ m_rewindLeft

wxButton* PNS_LOG_VIEWER_FRAME_BASE::m_rewindLeft
protectedinherited

◆ m_rewindPos

◆ m_rewindRight

wxButton* PNS_LOG_VIEWER_FRAME_BASE::m_rewindRight
protectedinherited

◆ m_rewindSlider

wxSlider* PNS_LOG_VIEWER_FRAME_BASE::m_rewindSlider
protectedinherited

◆ m_rewindText

wxStaticText* PNS_LOG_VIEWER_FRAME_BASE::m_rewindText
protectedinherited

◆ m_statusBar

wxStatusBar* PNS_LOG_VIEWER_FRAME_BASE::m_statusBar
protectedinherited

◆ m_viewSizer

wxBoxSizer* PNS_LOG_VIEWER_FRAME_BASE::m_viewSizer
protectedinherited

The documentation for this class was generated from the following files: