Plots may now be drawn as staircases.

This commit is contained in:
Bartosz Taudul 2022-07-24 12:37:30 +02:00
parent f8115168a6
commit 16627d7313
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
3 changed files with 20 additions and 2 deletions

View File

@ -747,6 +747,7 @@ struct PlotData
SortedVector<PlotItem, PlotItemSort> data; SortedVector<PlotItem, PlotItemSort> data;
PlotType type; PlotType type;
PlotValueFormatting format; PlotValueFormatting format;
uint8_t showSteps;
}; };
struct MemData struct MemData

View File

@ -259,8 +259,17 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
const auto y0 = PlotHeight - ( prevy->val - min ) * revrange * PlotHeight; const auto y0 = PlotHeight - ( prevy->val - min ) * revrange * PlotHeight;
const auto y1 = PlotHeight - ( it->val - min ) * revrange * PlotHeight; const auto y1 = PlotHeight - ( it->val - min ) * revrange * PlotHeight;
draw->AddQuadFilled( dpos + ImVec2( x0, offset + PlotHeight ), dpos + ImVec2( x0, offset + y0 ), dpos + ImVec2( x1, offset + y1 ), dpos + ImVec2( x1, offset + PlotHeight ), fill ); if( v->showSteps )
DrawLine( draw, dpos + ImVec2( x0, offset + y0 ), dpos + ImVec2( x1, offset + y1 ), color ); {
draw->AddRectFilled( dpos + ImVec2( x0, offset + PlotHeight ), dpos + ImVec2( x1, offset + y0 ), fill );
const ImVec2 data[3] = { dpos + ImVec2( x0, offset + y0 ), dpos + ImVec2( x1, offset + y0 ), dpos + ImVec2( x1, offset + y1 ) };
draw->AddPolyline( data, 3, color, 0, 1.0f );
}
else
{
draw->AddQuadFilled( dpos + ImVec2( x0, offset + PlotHeight ), dpos + ImVec2( x0, offset + y0 ), dpos + ImVec2( x1, offset + y1 ), dpos + ImVec2( x1, offset + PlotHeight ), fill );
DrawLine( draw, dpos + ImVec2( x0, offset + y0 ), dpos + ImVec2( x1, offset + y1 ), color );
}
const auto rx = skip == 0 ? 2.0 : ( skip == 1 ? 2.5 : 4.0 ); const auto rx = skip == 0 ? 2.0 : ( skip == 1 ? 2.5 : 4.0 );

View File

@ -454,6 +454,7 @@ Worker::Worker( const char* name, const char* program, const std::vector<ImportE
plot->name = nptr; plot->name = nptr;
plot->type = PlotType::User; plot->type = PlotType::User;
plot->format = v.format; plot->format = v.format;
plot->showSteps = false;
double sum = 0; double sum = 0;
double min = v.data.begin()->second; double min = v.data.begin()->second;
@ -1104,6 +1105,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
auto pd = m_slab.AllocInit<PlotData>(); auto pd = m_slab.AllocInit<PlotData>();
uint64_t psz; uint64_t psz;
f.Read7( pd->type, pd->format, pd->name, pd->min, pd->max, pd->sum, psz ); f.Read7( pd->type, pd->format, pd->name, pd->min, pd->max, pd->sum, psz );
pd->showSteps = false;
pd->data.reserve_exact( psz, m_slab ); pd->data.reserve_exact( psz, m_slab );
auto ptr = pd->data.data(); auto ptr = pd->data.data();
int64_t refTime = 0; int64_t refTime = 0;
@ -1127,6 +1129,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
uint64_t psz; uint64_t psz;
f.Read6( pd->type, pd->format, pd->name, pd->min, pd->max, psz ); f.Read6( pd->type, pd->format, pd->name, pd->min, pd->max, psz );
pd->sum = 0; pd->sum = 0;
pd->showSteps = false;
pd->data.reserve_exact( psz, m_slab ); pd->data.reserve_exact( psz, m_slab );
auto ptr = pd->data.data(); auto ptr = pd->data.data();
int64_t refTime = 0; int64_t refTime = 0;
@ -5620,6 +5623,7 @@ void Worker::ProcessPlotData( const QueuePlotData& ev )
plot->name = name; plot->name = name;
plot->type = PlotType::User; plot->type = PlotType::User;
plot->format = PlotValueFormatting::Number; plot->format = PlotValueFormatting::Number;
plot->showSteps = false;
return plot; return plot;
}, [this]( uint64_t name ) { }, [this]( uint64_t name ) {
Query( ServerQueryPlotName, name ); Query( ServerQueryPlotName, name );
@ -5650,6 +5654,7 @@ void Worker::ProcessPlotConfig( const QueuePlotConfig& ev )
auto plot = m_slab.AllocInit<PlotData>(); auto plot = m_slab.AllocInit<PlotData>();
plot->name = name; plot->name = name;
plot->type = PlotType::User; plot->type = PlotType::User;
plot->showSteps = false;
return plot; return plot;
}, [this]( uint64_t name ) { }, [this]( uint64_t name ) {
Query( ServerQueryPlotName, name ); Query( ServerQueryPlotName, name );
@ -6777,6 +6782,7 @@ void Worker::ProcessSysTime( const QueueSysTime& ev )
m_sysTimePlot->name = 0; m_sysTimePlot->name = 0;
m_sysTimePlot->type = PlotType::SysTime; m_sysTimePlot->type = PlotType::SysTime;
m_sysTimePlot->format = PlotValueFormatting::Percentage; m_sysTimePlot->format = PlotValueFormatting::Percentage;
m_sysTimePlot->showSteps = false;
m_sysTimePlot->min = val; m_sysTimePlot->min = val;
m_sysTimePlot->max = val; m_sysTimePlot->max = val;
m_sysTimePlot->sum = val; m_sysTimePlot->sum = val;
@ -7093,6 +7099,7 @@ void Worker::CreateMemAllocPlot( MemData& memdata )
memdata.plot->name = memdata.name; memdata.plot->name = memdata.name;
memdata.plot->type = PlotType::Memory; memdata.plot->type = PlotType::Memory;
memdata.plot->format = PlotValueFormatting::Memory; memdata.plot->format = PlotValueFormatting::Memory;
memdata.plot->showSteps = true;
memdata.plot->data.push_back( { GetFrameBegin( *m_data.framesBase, 0 ), 0. } ); memdata.plot->data.push_back( { GetFrameBegin( *m_data.framesBase, 0 ), 0. } );
m_data.plots.Data().push_back( memdata.plot ); m_data.plots.Data().push_back( memdata.plot );
} }
@ -7116,6 +7123,7 @@ void Worker::ReconstructMemAllocPlot( MemData& mem )
plot->name = mem.name; plot->name = mem.name;
plot->type = PlotType::Memory; plot->type = PlotType::Memory;
plot->format = PlotValueFormatting::Memory; plot->format = PlotValueFormatting::Memory;
plot->showSteps = true;
plot->data.reserve_exact( psz, m_slab ); plot->data.reserve_exact( psz, m_slab );
auto aptr = mem.data.begin(); auto aptr = mem.data.begin();