qa/pns: follow up changes in PNS::DEBUG_DECORATOR in the log viewer tool

This commit is contained in:
Tomasz Wlostowski 2021-05-29 00:12:45 +02:00
parent ebd957b08e
commit a0e28f1475
4 changed files with 90 additions and 97 deletions

View File

@ -191,9 +191,9 @@ void PNS_TEST_ENVIRONMENT::ReplayLog ( PNS_LOG_FILE* aLog, int aStartEventIndex,
PNS::NODE* node = nullptr;
if( m_router->GetState() == PNS::ROUTER::ROUTE_TRACK )
{
#if 0
m_debugDecorator.BeginGroup( "head");
auto traces = m_router->Placer()->Traces();
@ -206,6 +206,7 @@ void PNS_TEST_ENVIRONMENT::ReplayLog ( PNS_LOG_FILE* aLog, int aStartEventIndex,
}
m_debugDecorator.EndGroup();
#endif
node = m_router->Placer()->CurrentNode(true);
}
@ -221,6 +222,7 @@ void PNS_TEST_ENVIRONMENT::ReplayLog ( PNS_LOG_FILE* aLog, int aStartEventIndex,
node->GetUpdatedItems( removed, added );
#if 0
if( ! added.empty() )
{
bool first = true;
@ -238,6 +240,7 @@ void PNS_TEST_ENVIRONMENT::ReplayLog ( PNS_LOG_FILE* aLog, int aStartEventIndex,
m_debugDecorator.EndGroup();
}
#endif
}
}
@ -251,7 +254,7 @@ PNS_TEST_DEBUG_DECORATOR::STAGE* PNS_TEST_DEBUG_DECORATOR::currentStage()
}
void PNS_TEST_DEBUG_DECORATOR::BeginGroup( std::string name )
void PNS_TEST_DEBUG_DECORATOR::BeginGroup( std::string name, const SRC_LOCATION_INFO& aSrcLoc )
{
STAGE* st = currentStage();
DEBUG_ENT *ent = new DEBUG_ENT();
@ -271,7 +274,7 @@ void PNS_TEST_DEBUG_DECORATOR::BeginGroup( std::string name )
}
void PNS_TEST_DEBUG_DECORATOR::EndGroup( )
void PNS_TEST_DEBUG_DECORATOR::EndGroup( const SRC_LOCATION_INFO& aSrcLoc )
{
printf("LOG EndGroup\n" );
@ -290,7 +293,18 @@ void PNS_TEST_DEBUG_DECORATOR::addEntry( DEBUG_ENT* ent )
m_activeEntry->AddChild( ent );
}
void PNS_TEST_DEBUG_DECORATOR::AddPoint( VECTOR2I aP, int aColor, int aSize, const std::string aName )
/* virtual void AddLine( const SHAPE_LINE_CHAIN& aLine, const KIGFX::COLOR4D& aColor,
int aWidth, const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void AddSegment( SEG aS, const KIGFX::COLOR4D& aColor,
const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void AddBox( BOX2I aB, const KIGFX::COLOR4D& aColor,
const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
*/
void PNS_TEST_DEBUG_DECORATOR::AddPoint( VECTOR2I aP, const KIGFX::COLOR4D& aColor, int aSize, const std::string aName, const SRC_LOCATION_INFO& aSrcLoc )
{
auto sh = new SHAPE_LINE_CHAIN;
@ -308,72 +322,75 @@ void PNS_TEST_DEBUG_DECORATOR::AddPoint( VECTOR2I aP, int aColor, int aSize, con
ent->m_iter = m_iter;
ent->m_name = aName;
ent->m_hasLabels = false;
ent->m_srcLoc = aSrcLoc;
addEntry( ent );
}
void PNS_TEST_DEBUG_DECORATOR::AddLine( const SHAPE_LINE_CHAIN& aLine, int aType, int aWidth,
const std::string aName )
void PNS_TEST_DEBUG_DECORATOR::AddLine( const SHAPE_LINE_CHAIN& aLine, const KIGFX::COLOR4D& aColor,
int aWidth, const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc )
{
auto sh = new SHAPE_LINE_CHAIN( aLine );
DEBUG_ENT* ent = new DEBUG_ENT();
ent->m_shapes.push_back( sh );
ent->m_color = aType;
ent->m_color = aColor;
ent->m_width = aWidth;
ent->m_name = aName;
ent->m_iter = m_iter;
ent->m_srcLoc = aSrcLoc;
addEntry( ent );
}
void PNS_TEST_DEBUG_DECORATOR::AddSegment( SEG aS, int aColor, const std::string aName )
void PNS_TEST_DEBUG_DECORATOR::AddSegment( SEG aS, const KIGFX::COLOR4D& aColor,
const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc )
{
auto sh = new SHAPE_LINE_CHAIN ( { aS.A, aS.B } );
DEBUG_ENT* ent = new DEBUG_ENT();
ent->m_shapes.push_back( sh );
ent->m_color = aColor;
ent->m_width = 10000;
ent->m_name = aName;
ent->m_iter = m_iter;
addEntry( ent );
ent->m_shapes.push_back( sh );
ent->m_color = aColor;
ent->m_width = 10000;
ent->m_name = aName;
ent->m_iter = m_iter;
ent->m_srcLoc = aSrcLoc;
addEntry( ent );
}
void PNS_TEST_DEBUG_DECORATOR::AddBox( BOX2I aB, int aColor, const std::string aName )
void PNS_TEST_DEBUG_DECORATOR::AddBox( BOX2I aB, const KIGFX::COLOR4D& aColor,
const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc )
{
auto sh = new SHAPE_RECT ( aB.GetPosition(), aB.GetWidth(), aB.GetHeight() );
DEBUG_ENT* ent = new DEBUG_ENT();
ent->m_shapes.push_back( sh );
ent->m_color = aColor;
ent->m_width = 10000;
ent->m_name = aName;
ent->m_iter = m_iter;
addEntry( ent );
ent->m_shapes.push_back( sh );
ent->m_color = aColor;
ent->m_width = 10000;
ent->m_name = aName;
ent->m_iter = m_iter;
ent->m_srcLoc = aSrcLoc;
addEntry( ent );
}
void PNS_TEST_DEBUG_DECORATOR::AddDirections( VECTOR2D aP, int aMask, int aColor, const std::string aName )
{
}
void PNS_TEST_DEBUG_DECORATOR::Message( const wxString msg )
void PNS_TEST_DEBUG_DECORATOR::Message( const wxString msg, const SRC_LOCATION_INFO& aSrcLoc )
{
DEBUG_ENT* ent = new DEBUG_ENT();
ent->m_msg = msg.c_str();
ent->m_srcLoc = aSrcLoc;
addEntry( ent );
}
void PNS_TEST_DEBUG_DECORATOR::Clear()
{
//dec_dbg("clear");
}
void PNS_TEST_DEBUG_DECORATOR::NewStage(const std::string& name, int iter)
void PNS_TEST_DEBUG_DECORATOR::NewStage(const std::string& name, int iter, const SRC_LOCATION_INFO& aSrcLoc)
{
m_stages.push_back( new STAGE );
m_activeEntry = m_stages.back()->m_entries;

View File

@ -108,12 +108,13 @@ private:
class PNS_TEST_DEBUG_DECORATOR : public PNS::DEBUG_DECORATOR
{
public:
struct DEBUG_ENT
{
DEBUG_ENT( DEBUG_ENT* aParent = nullptr )
{
m_iter = 0;
m_color = 0;
m_color = KIGFX::COLOR4D::WHITE;
m_width = 10000;
m_name = "<unknown>";
m_parent = aParent;
@ -171,13 +172,13 @@ public:
DEBUG_ENT* m_parent;
std::vector<SHAPE*> m_shapes;
std::vector<DEBUG_ENT*> m_children;
int m_color;
KIGFX::COLOR4D m_color;
int m_width;
bool m_hasLabels = true;
int m_iter;
std::string m_name;
std::string m_msg;
//wxTreeListItem m_item;
PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO m_srcLoc;
bool m_visible;
bool m_selected;
};
@ -205,26 +206,37 @@ public:
m_iter = 0;
m_grouping = false;
m_activeEntry = nullptr;
SetDebugEnabled( true );
}
virtual ~PNS_TEST_DEBUG_DECORATOR() {}
virtual ~PNS_TEST_DEBUG_DECORATOR()
{
// fixme: I know it's a hacky tool but it should clean after itself at some point...
}
virtual void SetIteration( int iter ) override { m_iter = iter; }
virtual void Message( const wxString msg ) override;
virtual void AddPoint( VECTOR2I aP, int aColor, int aSize = 100000,
const std::string aName = "" ) override;
virtual void AddLine( const SHAPE_LINE_CHAIN& aLine, int aType = 0, int aWidth = 0,
const std::string aName = "" ) override;
virtual void AddSegment( SEG aS, int aColor, const std::string aName = "" ) override;
virtual void AddBox( BOX2I aB, int aColor, const std::string aName = "" ) override;
virtual void AddDirections( VECTOR2D aP, int aMask, int aColor,
const std::string aName = "" ) override;
virtual void Clear() override;
virtual void NewStage( const std::string& name, int iter ) override;
virtual void BeginGroup( const std::string name ) override;
virtual void EndGroup() override;
virtual void Message( const wxString msg,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void NewStage( const std::string& name, int iter,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void BeginGroup( const std::string name,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void EndGroup( const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void AddPoint( VECTOR2I aP, const KIGFX::COLOR4D& aColor, int aSize,
const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void AddLine( const SHAPE_LINE_CHAIN& aLine, const KIGFX::COLOR4D& aColor,
int aWidth, const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void AddSegment( SEG aS, const KIGFX::COLOR4D& aColor,
const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void AddBox( BOX2I aB, const KIGFX::COLOR4D& aColor,
const std::string aName,
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
virtual void Clear(){};
int GetStageCount() const { return m_stages.size(); }

View File

@ -245,51 +245,6 @@ void PNS_LOG_VIEWER_FRAME::createUserTools()
}
static const COLOR4D assignColor( int aStyle )
{
COLOR4D color;
switch( aStyle )
{
case 0:
color = COLOR4D( 0, 1, 0, 1 );
break;
case 1:
color = COLOR4D( 1, 0, 0, 1 );
break;
case 2:
color = COLOR4D( 1, 1, 0, 1 );
break;
case 3:
color = COLOR4D( 0, 0, 1, 1 );
break;
case 4:
color = COLOR4D( 1, 1, 1, 1 );
break;
case 5:
color = COLOR4D( 1, 1, 0, 1 );
break;
case 6:
color = COLOR4D( 0, 1, 1, 1 );
break;
case 32:
color = COLOR4D( 0, 0, 1, 1 );
break;
default:
color = COLOR4D( 0.4, 0.4, 0.4, 1 );
break;
}
return color;
}
PNS_TEST_DEBUG_DECORATOR::STAGE* PNS_LOG_VIEWER_FRAME::getCurrentStage()
{
@ -333,7 +288,7 @@ void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter )
for( auto& sh : ent->m_shapes )
{
COLOR4D color = assignColor( ent->m_color );
COLOR4D color = ent->m_color;
int lineWidth = ent->m_width;
m_overlay->SetIsStroke( true );
@ -375,7 +330,6 @@ void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter )
m_overlay->Line( s.A, s.B );
}
if( ent->m_hasLabels)
labelMgr.Add( *lc, color );
@ -643,6 +597,10 @@ void PNS_LOG_VIEWER_FRAME::buildListTree( wxTreeListItem i
m_itemList->SetItemText( ritem, 1, ent->m_name );
}
m_itemList->SetItemText( ritem, 2, wxFileNameFromPath( ent->m_srcLoc.fileName ) );
m_itemList->SetItemText( ritem, 3, ent->m_srcLoc.funcName );
m_itemList->SetItemText( ritem, 4, wxString::Format("%d", ent->m_srcLoc.line ) );
m_itemList->SetItemData( ritem, new WX_SHAPE_TREE_ITEM_DATA( ent ) );
if( !ent->m_children.size() )

View File

@ -78,9 +78,15 @@ public:
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() {}
virtual ~PNS_LOG_VIEWER_FRAME()
{
m_overlay = nullptr;
}
void SetLogFile( PNS_LOG_FILE* aLog );