qa/pns: playground tool now can draw lines with annotated vertices

This commit is contained in:
Tomasz Wlostowski 2021-06-03 22:44:39 +02:00
parent 5c01b0a32e
commit 5a325c59db
4 changed files with 325 additions and 252 deletions

38
qa/pns/label_manager.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef __LABEL_MANAGER_H
#define __LABEL_MANAGER_H
#include <gal/graphics_abstraction_layer.h>
#include <gal/color4d.h>
#include <math/vector2d.h>
#include <math/box2.h>
class LABEL_MANAGER
{
public:
struct LABEL
{
COLOR4D m_color;
std::string m_msg;
VECTOR2I m_target;
BOX2I m_bbox;
};
LABEL_MANAGER( KIGFX::GAL* aGal );
~LABEL_MANAGER( );
void Add( VECTOR2I target, std::string msg, COLOR4D color );
void Add( const SHAPE_LINE_CHAIN& aL, COLOR4D color );
void Redraw( KIGFX::VIEW_OVERLAY* aOvl );
private:
VECTOR2I nearestBoxCorner( BOX2I b, VECTOR2I p );
VECTOR2I boxMtv( BOX2I b1, BOX2I b2 );
void recalculate();
KIGFX::GAL* m_gal;
int m_textSize = 100000;
std::vector<LABEL> m_labels;
};
#endif

View File

@ -29,6 +29,11 @@
#include <qa_utils/utility_registry.h>
#include "pns_log_viewer_frame.h"
#include "label_manager.h"
namespace PNS {
extern SHAPE_LINE_CHAIN g_pnew, g_hnew;
};
int playground_main_func( int argc, char* argv[] )
{
@ -36,22 +41,45 @@ int playground_main_func( int argc, char* argv[] )
Pgm().App().SetTopWindow( frame ); // wxApp gets a face.
frame->Show();
auto overlay = frame->GetPanel()->DebugOverlay();
auto overlay = frame->GetOverlay();
overlay->SetIsFill(false);
overlay->SetLineWidth(10000);
auto hull = SHAPE_LINE_CHAIN( { VECTOR2I( 66280505, 107710033), VECTOR2I( 65914967, 107344495), VECTOR2I( 65914967, 106827549), VECTOR2I( 66280505, 106462011), VECTOR2I( 74810033, 106462009), VECTOR2I( 75175571, 106827547), VECTOR2I( 75175571, 107344493), VECTOR2I( 74810033, 107710031)}, true );
auto path = SHAPE_LINE_CHAIN( { VECTOR2I( 143928480, 109445996), VECTOR2I( 111066480, 109445996), VECTOR2I( 106254391, 104633907), VECTOR2I( 105909001, 104633907), VECTOR2I( 105775094, 104500000), VECTOR2I( 76250000, 104500000), VECTOR2I( 74287991, 106462009), VECTOR2I( 66280505, 106462011), VECTOR2I( 66012989, 106462011)}, false );
//auto hull = SHAPE_LINE_CHAIN( { VECTOR2I( 111435489, 74692234), VECTOR2I( 111812234, 74315489), VECTOR2I( 112507766, 74315489), VECTOR2I( 112884511, 74692234), VECTOR2I( 112884511, 75387766), VECTOR2I( 112507766, 75764511), VECTOR2I( 111812234, 75764511), VECTOR2I( 111435489, 75387766)}, true );;
//auto path = SHAPE_LINE_CHAIN( { VECTOR2I( 112609520, 74417243), VECTOR2I( 112609520, 73774520), VECTOR2I( 112670046, 73774520), VECTOR2I( 112999520, 73445046), VECTOR2I( 112999520, 72054954), VECTOR2I( 112670046, 71725480), VECTOR2I( 111654954, 71725480), VECTOR2I( 111325480, 72054954), VECTOR2I( 111325480, 73445046), VECTOR2I( 111654954, 73774520), VECTOR2I( 111710480, 73774520), VECTOR2I( 111710480, 75226197), VECTOR2I( 111973803, 75489520), VECTOR2I( 112346197, 75489520), VECTOR2I( 112609520, 75226197), VECTOR2I( 112609520, 74417243)}, false );;
// hull-cw-1
//auto hull = SHAPE_LINE_CHAIN( { VECTOR2I( 111435489, 74692234), VECTOR2I( 111812234, 74315489), VECTOR2I( 112507766, 74315489), VECTOR2I( 112884511, 74692234), VECTOR2I( 112884511, 75387766), VECTOR2I( 112507766, 75764511), VECTOR2I( 111812234, 75764511), VECTOR2I( 111435489, 75387766)}, true );;
// path-cw-1
//auto path = SHAPE_LINE_CHAIN( { VECTOR2I( 112609520, 74417243), VECTOR2I( 112609520, 75226197), VECTOR2I( 112346197, 75489520), VECTOR2I( 111973803, 75489520), VECTOR2I( 111710480, 75226197), VECTOR2I( 111710480, 72566303), VECTOR2I( 111973803, 72302980), VECTOR2I( 112346197, 72302980), VECTOR2I( 112609520, 72566303), VECTOR2I( 112609520, 74417243)}, false );;
// hull
auto hull = SHAPE_LINE_CHAIN( { VECTOR2I( 106035489, 85253452), VECTOR2I( 106313452, 84975489), VECTOR2I( 106706548, 84975489), VECTOR2I( 106984511, 85253452), VECTOR2I( 106984511, 85976548), VECTOR2I( 106706548, 86254511), VECTOR2I( 106313452, 86254511), VECTOR2I( 106035489, 85976548)}, true );;
// path
auto path = SHAPE_LINE_CHAIN( { VECTOR2I( 101092000, 85246500), VECTOR2I( 101971211, 86125711), VECTOR2I( 106380778, 86125711), VECTOR2I( 106509572, 86254505)}, false );;
SHAPE_LINE_CHAIN path_w;
BOX2D bb ( path.BBox().GetPosition(), path.BBox().GetSize() );
LABEL_MANAGER labelMgr( frame->GetPanel()->GetGAL() );
frame->GetPanel()->GetView()->SetViewport(bb);
PNS::LINE l;
l.SetShape( path );
l.Walkaround( hull, path_w, true );
overlay->SetStrokeColor( WHITE );
overlay->SetLineWidth( 100000.0 );
overlay->Polyline( path );
overlay->SetLineWidth( 10000.0 );
overlay->AnnotatedPolyline( PNS::g_pnew, "path", true );
overlay->SetStrokeColor( RED );
overlay->Polyline( hull );
overlay->AnnotatedPolyline( PNS::g_hnew, "hull", true );
overlay->SetLineWidth( 20000.0 );
overlay->SetStrokeColor( YELLOW );
overlay->AnnotatedPolyline( path_w, "walk", "true" );
overlay->DrawAnnotations();
overlay = nullptr;

View File

@ -42,194 +42,171 @@
#include "qa/drc_proto/drc_proto.h"
#include "label_manager.h"
#define TOM_EXTRA_DEBUG
class LABEL_MANAGER
LABEL_MANAGER::LABEL_MANAGER( KIGFX::GAL* aGal ) : m_gal( aGal )
{
public:
struct LABEL
{
COLOR4D m_color;
std::string m_msg;
VECTOR2I m_target;
BOX2I m_bbox;
};
LABEL_MANAGER( KIGFX::GAL* aGal ) :
m_gal( aGal ) {};
void Add( VECTOR2I target, std::string msg, COLOR4D color )
{
LABEL lbl;
lbl.m_target = target;
lbl.m_msg = msg;
lbl.m_color = color;
m_gal->SetGlyphSize( VECTOR2D(m_textSize, m_textSize) );
VECTOR2I textDims = m_gal->GetTextLineSize( msg );
lbl.m_bbox.SetOrigin( lbl.m_target - textDims - VECTOR2I( m_textSize, m_textSize ) );
lbl.m_bbox.SetSize( textDims );
m_labels.push_back( lbl );
}
void Add( const SHAPE_LINE_CHAIN& aL, COLOR4D color )
{
for( int i = 0; i < aL.PointCount(); i++ )
{
char msg[1024];
snprintf(msg, sizeof(msg), "%d", i );
Add( aL.CPoint(i), msg, color );
}
}
void Redraw( std::shared_ptr<KIGFX::VIEW_OVERLAY> aOvl )
{
recalculate();
for ( auto & lbl : m_labels )
{
//printf("Draw lbl %d %d '%s'\n", lbl.m_bbox.GetOrigin().x, lbl.m_bbox.GetOrigin().y, lbl.m_msg.c_str() );
aOvl->SetIsFill( false );
aOvl->SetIsStroke( true );
aOvl->SetLineWidth( 10000 );
aOvl->SetStrokeColor( lbl.m_color.Brighten( 0.7 ) );
aOvl->Rectangle( lbl.m_bbox.GetOrigin(), lbl.m_bbox.GetEnd() );
aOvl->BitmapText( lbl.m_msg, lbl.m_bbox.Centre(), 0.0 );
VECTOR2I nearest = nearestBoxCorner( lbl.m_bbox, lbl.m_target );
aOvl->Line( lbl.m_target, nearest );
}
}
private:
VECTOR2I nearestBoxCorner( BOX2I b, VECTOR2I p )
{
VECTOR2I ptest[4] =
{
b.GetPosition(),
b.GetPosition() + VECTOR2I( b.GetWidth(), 0 ),
b.GetPosition() + VECTOR2I( b.GetWidth(), b.GetHeight() ),
b.GetPosition() + VECTOR2I( 0, b.GetHeight() )
};
int bestDist = INT_MAX;
VECTOR2I rv;
for(int i = 0; i< 4;i++)
{
int dist = ( ptest[i] - p ).EuclideanNorm();
if(dist < bestDist)
{
bestDist = dist;
rv = ptest[i];
}
}
return rv;
}
VECTOR2I boxMtv( BOX2I b1, BOX2I b2 )
{
VECTOR2I rv(0, 0);
b1.Normalize();
b2.Normalize();
if( !b1.Intersects(b2) )
return rv;
int bestDist = INT_MAX;
VECTOR2I p[4] =
{
b2.GetPosition(),
b2.GetPosition() + VECTOR2I( b2.GetWidth(), 0 ),
b2.GetPosition() + VECTOR2I( b2.GetWidth(), b2.GetHeight() ),
b2.GetPosition() + VECTOR2I( 0, b2.GetHeight() )
};
for (int i = 0; i < 4 ; i++ )
{
if ( b1.Contains( p[i] ))
{
// printf("CONT %d\n", i );
VECTOR2I dp[4] =
{
VECTOR2I( b1.GetEnd().x - p[i].x + 1, 0 ),
VECTOR2I( b1.GetPosition().x - p[i].x - 1, 0 ),
VECTOR2I( 0, b1.GetEnd().y - p[i].y + 1 ),
VECTOR2I( 0, b1.GetPosition().y - p[i].y - 1 )
};
for(int j = 0; j < 4; j++ )
{
BOX2I btest(b2);
btest.Move( dp[j] );
if( !b1.Intersects(btest) )
{
int dist = dp[j].EuclideanNorm();
if( dist < bestDist )
{
bestDist = dist;
rv = dp[j];
}
}
}
}
}
return rv;
}
void recalculate()
{
int iterLimit = 5;
while ( iterLimit > 0 )
{
printf("Iter %d\n", iterLimit );
bool collisionsFound = false;
for(int i = 0; i < m_labels.size(); i++ )
{
for(int j = 0; j < m_labels.size(); j++ )
{
if (i == j )
continue;
auto bb_i = m_labels[i].m_bbox;
auto bb_j = m_labels[j].m_bbox;
bb_i.Inflate(100000);
bb_j.Inflate(100000);
VECTOR2I mtv = boxMtv(bb_i, bb_j);
if( mtv.x || mtv.y )
{
// printf("%d %d mtv %d %d\n", i, j, mtv.x, mtv.y );
m_labels[i].m_bbox.Move( -mtv );
collisionsFound = true;
}
}
}
if( ! collisionsFound )
break;
iterLimit--;
}
}
KIGFX::GAL* m_gal;
int m_textSize = 100000;
std::vector<LABEL> m_labels;
};
LABEL_MANAGER::~LABEL_MANAGER()
{
}
void LABEL_MANAGER::Add( VECTOR2I target, std::string msg, COLOR4D color )
{
LABEL lbl;
lbl.m_target = target;
lbl.m_msg = msg;
lbl.m_color = color;
m_gal->SetGlyphSize( VECTOR2D( m_textSize, m_textSize ) );
VECTOR2I textDims = m_gal->GetTextLineSize( msg );
lbl.m_bbox.SetOrigin( lbl.m_target - textDims - VECTOR2I( m_textSize, m_textSize ) );
lbl.m_bbox.SetSize( textDims );
m_labels.push_back( lbl );
}
void LABEL_MANAGER::Add( const SHAPE_LINE_CHAIN& aL, COLOR4D color )
{
for( int i = 0; i < aL.PointCount(); i++ )
{
char msg[1024];
snprintf( msg, sizeof( msg ), "%d", i );
Add( aL.CPoint( i ), msg, color );
}
}
void LABEL_MANAGER::Redraw( KIGFX::VIEW_OVERLAY* aOvl )
{
recalculate();
for( auto& lbl : m_labels )
{
//printf("Draw lbl %d %d '%s'\n", lbl.m_bbox.GetOrigin().x, lbl.m_bbox.GetOrigin().y, lbl.m_msg.c_str() );
aOvl->SetIsFill( false );
aOvl->SetIsStroke( true );
aOvl->SetLineWidth( 10000 );
aOvl->SetStrokeColor( lbl.m_color.Brighten( 0.7 ) );
aOvl->Rectangle( lbl.m_bbox.GetOrigin(), lbl.m_bbox.GetEnd() );
aOvl->BitmapText( lbl.m_msg, lbl.m_bbox.Centre(), 0.0 );
VECTOR2I nearest = nearestBoxCorner( lbl.m_bbox, lbl.m_target );
aOvl->Line( lbl.m_target, nearest );
}
}
VECTOR2I LABEL_MANAGER::nearestBoxCorner( BOX2I b, VECTOR2I p )
{
VECTOR2I ptest[4] = { b.GetPosition(), b.GetPosition() + VECTOR2I( b.GetWidth(), 0 ),
b.GetPosition() + VECTOR2I( b.GetWidth(), b.GetHeight() ),
b.GetPosition() + VECTOR2I( 0, b.GetHeight() ) };
int bestDist = INT_MAX;
VECTOR2I rv;
for( int i = 0; i < 4; i++ )
{
int dist = ( ptest[i] - p ).EuclideanNorm();
if( dist < bestDist )
{
bestDist = dist;
rv = ptest[i];
}
}
return rv;
}
VECTOR2I LABEL_MANAGER::boxMtv( BOX2I b1, BOX2I b2 )
{
VECTOR2I rv( 0, 0 );
b1.Normalize();
b2.Normalize();
if( !b1.Intersects( b2 ) )
return rv;
int bestDist = INT_MAX;
VECTOR2I p[4] = { b2.GetPosition(), b2.GetPosition() + VECTOR2I( b2.GetWidth(), 0 ),
b2.GetPosition() + VECTOR2I( b2.GetWidth(), b2.GetHeight() ),
b2.GetPosition() + VECTOR2I( 0, b2.GetHeight() ) };
for( int i = 0; i < 4; i++ )
{
if( b1.Contains( p[i] ) )
{
// printf("CONT %d\n", i );
VECTOR2I dp[4] = { VECTOR2I( b1.GetEnd().x - p[i].x + 1, 0 ),
VECTOR2I( b1.GetPosition().x - p[i].x - 1, 0 ),
VECTOR2I( 0, b1.GetEnd().y - p[i].y + 1 ),
VECTOR2I( 0, b1.GetPosition().y - p[i].y - 1 ) };
for( int j = 0; j < 4; j++ )
{
BOX2I btest( b2 );
btest.Move( dp[j] );
if( !b1.Intersects( btest ) )
{
int dist = dp[j].EuclideanNorm();
if( dist < bestDist )
{
bestDist = dist;
rv = dp[j];
}
}
}
}
}
return rv;
}
void LABEL_MANAGER::recalculate()
{
int iterLimit = 5;
while( iterLimit > 0 )
{
printf( "Iter %d\n", iterLimit );
bool collisionsFound = false;
for( int i = 0; i < m_labels.size(); i++ )
{
for( int j = 0; j < m_labels.size(); j++ )
{
if( i == j )
continue;
auto bb_i = m_labels[i].m_bbox;
auto bb_j = m_labels[j].m_bbox;
bb_i.Inflate( 100000 );
bb_j.Inflate( 100000 );
VECTOR2I mtv = boxMtv( bb_i, bb_j );
if( mtv.x || mtv.y )
{
// printf("%d %d mtv %d %d\n", i, j, mtv.x, mtv.y );
m_labels[i].m_bbox.Move( -mtv );
collisionsFound = true;
}
}
}
if( !collisionsFound )
break;
iterLimit--;
}
}
class WX_SHAPE_TREE_ITEM_DATA : public wxClientData
{
@ -239,13 +216,81 @@ public:
PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* m_item;
};
PNS_LOG_VIEWER_OVERLAY::PNS_LOG_VIEWER_OVERLAY( KIGFX::GAL* aGal )
{
m_labelMgr.reset( new LABEL_MANAGER( aGal ) );
}
void PNS_LOG_VIEWER_OVERLAY::AnnotatedPolyline( const SHAPE_LINE_CHAIN& aL, std::string name, bool aShowVertexNumbers )
{
Polyline( aL );
if( aShowVertexNumbers)
m_labelMgr->Add( aL, GetStrokeColor() );
}
void PNS_LOG_VIEWER_OVERLAY::DrawAnnotations()
{
m_labelMgr->Redraw( this );
}
PNS_LOG_VIEWER_FRAME::PNS_LOG_VIEWER_FRAME( wxFrame* frame ) : PNS_LOG_VIEWER_FRAME_BASE( frame )
{
LoadSettings();
createView( this, PCB_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
m_viewSizer->Add( m_galPanel.get(), 1, wxEXPAND, 5 );
Layout();
Show( true );
Maximize();
Raise();
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
m_galPanel->GetView()->GetPainter()->GetSettings() );
settings->SetZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE );
m_listPopupMenu = new wxMenu( wxT( "" ) );
m_listPopupMenu->Append( ID_LIST_COPY, wxT( "Copy selected geometry" ), wxT( "" ),
wxITEM_NORMAL );
m_listPopupMenu->Append( ID_LIST_SHOW_ALL, wxT( "Show all" ), wxT( "" ), wxITEM_NORMAL );
m_listPopupMenu->Append( ID_LIST_SHOW_NONE, wxT( "Show none" ), wxT( "" ), wxITEM_NORMAL );
m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CONTEXT_MENU,
wxMouseEventHandler( PNS_LOG_VIEWER_FRAME::onListRightClick ), NULL,
this );
//m_itemList->Connect(m_itemList->GetId(),wxEVT_LISTBOX,wxCommandEventHandler(PNS_LOG_VIEWER_FRAME::onListSelect),NULL,this);
m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_SELECTION_CHANGED,
wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListSelect ), NULL, this );
m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CHECKED,
wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListChecked ), NULL, this );
m_itemList->AppendColumn( "Type" );
m_itemList->AppendColumn( "Value" );
m_itemList->AppendColumn( "File" );
m_itemList->AppendColumn( "Method" );
m_itemList->AppendColumn( "Line" );
m_overlay.reset( new PNS_LOG_VIEWER_OVERLAY ( m_galPanel->GetGAL() ) );
m_galPanel->GetView()->Add( m_overlay.get() );
}
PNS_LOG_VIEWER_FRAME::~PNS_LOG_VIEWER_FRAME()
{
m_overlay = nullptr;
}
void PNS_LOG_VIEWER_FRAME::createUserTools()
{
}
PNS_TEST_DEBUG_DECORATOR::STAGE* PNS_LOG_VIEWER_FRAME::getCurrentStage()
{
PNS_TEST_DEBUG_DECORATOR* dbgd = m_env->GetDebugDecorator();
@ -270,15 +315,15 @@ void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter )
if( !m_env )
return;
m_overlay = m_galPanel->DebugOverlay();
m_overlay->Clear();
PNS_TEST_DEBUG_DECORATOR::STAGE* st = getCurrentStage();
if( !st )
return;
LABEL_MANAGER labelMgr( m_galPanel->GetGAL() );
m_overlay.reset( new PNS_LOG_VIEWER_OVERLAY ( m_galPanel->GetGAL() ) );
m_galPanel->GetView()->Add( m_overlay.get() );
//
printf("draw %d\n", iter);
auto drawShapes = [&]( PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* ent ) -> bool {
bool isEnabled = ent->IsVisible();
@ -296,11 +341,9 @@ void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter )
if( isSelected )
{
color = COLOR4D( 1.0, 1.0, 1.0, 1.0 );
lineWidth *= 2;
color.Brighten( 0.5 );
}
m_overlay->SetStrokeColor( color );
m_overlay->SetLineWidth( ent->m_width );
@ -323,15 +366,7 @@ void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter )
case SH_LINE_CHAIN:
{
auto lc = static_cast<SHAPE_LINE_CHAIN*>( sh );
for( int i = 0; i < lc->SegmentCount(); i++ )
{
auto s = lc->CSegment( i );
m_overlay->Line( s.A, s.B );
}
if( ent->m_hasLabels)
labelMgr.Add( *lc, color );
m_overlay->AnnotatedPolyline( *lc, ent->m_name, ent->m_hasLabels && isSelected );
break;
@ -346,7 +381,7 @@ void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter )
st->m_entries->IterateTree( drawShapes );
labelMgr.Redraw( m_overlay );
m_overlay->DrawAnnotations();
m_galPanel->GetView()->MarkDirty();
m_galPanel->GetParent()->Refresh();

View File

@ -38,57 +38,16 @@
#define ID_LIST_SHOW_ALL 10002
#define ID_LIST_SHOW_NONE 10003
class PNS_LOG_VIEWER_OVERLAY;
class PNS_LOG_VIEWER_FRAME : public PNS_LOG_VIEWER_FRAME_BASE, public PCB_TEST_FRAME_BASE
{
public:
PNS_LOG_VIEWER_FRAME( wxFrame* frame ) : PNS_LOG_VIEWER_FRAME_BASE( frame )
{
LoadSettings();
createView( this, PCB_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
m_viewSizer->Add( m_galPanel.get(), 1, wxEXPAND, 5 );
Layout();
Show( true );
Maximize();
Raise();
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
m_galPanel->GetView()->GetPainter()->GetSettings() );
settings->SetZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE );
m_listPopupMenu = new wxMenu( wxT( "" ) );
m_listPopupMenu->Append( ID_LIST_COPY, wxT( "Copy selected geometry" ), wxT( "" ),
wxITEM_NORMAL );
m_listPopupMenu->Append( ID_LIST_SHOW_ALL, wxT( "Show all" ), wxT( "" ), wxITEM_NORMAL );
m_listPopupMenu->Append( ID_LIST_SHOW_NONE, wxT( "Show none" ), wxT( "" ), wxITEM_NORMAL );
m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CONTEXT_MENU,
wxMouseEventHandler( PNS_LOG_VIEWER_FRAME::onListRightClick ), NULL,
this );
//m_itemList->Connect(m_itemList->GetId(),wxEVT_LISTBOX,wxCommandEventHandler(PNS_LOG_VIEWER_FRAME::onListSelect),NULL,this);
m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_SELECTION_CHANGED,
wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListSelect ), NULL,
this );
m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CHECKED,
wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListChecked ), NULL,
this );
m_itemList->AppendColumn( "Type" );
m_itemList->AppendColumn( "Value" );
m_itemList->AppendColumn( "File" );
m_itemList->AppendColumn( "Method" );
m_itemList->AppendColumn( "Line" );
}
virtual ~PNS_LOG_VIEWER_FRAME()
{
m_overlay = nullptr;
}
PNS_LOG_VIEWER_FRAME( wxFrame* frame );
virtual ~PNS_LOG_VIEWER_FRAME();
void SetLogFile( PNS_LOG_FILE* aLog );
std::shared_ptr<PNS_LOG_VIEWER_OVERLAY> GetOverlay() const { return m_overlay; }
private:
void drawLoggedItems( int iter );
@ -109,11 +68,24 @@ private:
virtual void onBtnRewindRight( wxCommandEvent& event ) override;
virtual void onListChecked( wxCommandEvent& event );
std::shared_ptr<KIGFX::VIEW_OVERLAY> m_overlay;
std::shared_ptr<PNS_LOG_VIEWER_OVERLAY> m_overlay;
std::shared_ptr<PNS_LOG_FILE> m_logFile;
std::shared_ptr<PNS_TEST_ENVIRONMENT> m_env;
int m_rewindIter;
wxMenu* m_listPopupMenu;
};
class LABEL_MANAGER;
class PNS_LOG_VIEWER_OVERLAY : public KIGFX::VIEW_OVERLAY
{
public:
PNS_LOG_VIEWER_OVERLAY( KIGFX::GAL* aGal );
void AnnotatedPolyline( const SHAPE_LINE_CHAIN& aL, std::string name, bool aShowVertexNumbers = false );
void DrawAnnotations();
private:
std::unique_ptr<LABEL_MANAGER> m_labelMgr;
};
#endif