mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
Switch plot drawing to the timeline items system.
This commit is contained in:
parent
55a82ea714
commit
b481bb367c
@ -138,6 +138,7 @@
|
||||
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineController.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItem.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItemPlot.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyUserData.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyUtility.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyView.cpp" />
|
||||
@ -275,6 +276,7 @@
|
||||
<ClInclude Include="..\..\..\server\TracyThreadCompress.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineController.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItem.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItemPlot.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyUserData.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyUtility.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyVarArray.hpp" />
|
||||
|
@ -357,6 +357,9 @@
|
||||
<ClCompile Include="..\..\..\server\TracyUtility.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItemPlot.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItem.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
@ -731,6 +734,9 @@
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItem.hpp">
|
||||
<Filter>server</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItemPlot.hpp">
|
||||
<Filter>server</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="DebugVis.natvis" />
|
||||
|
@ -750,6 +750,8 @@ struct PlotData
|
||||
uint8_t showSteps;
|
||||
uint8_t fill;
|
||||
uint32_t color;
|
||||
|
||||
double rMin, rMax, num;
|
||||
};
|
||||
|
||||
struct MemData
|
||||
|
104
server/TracyTimelineItemPlot.cpp
Normal file
104
server/TracyTimelineItemPlot.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include "TracyImGui.hpp"
|
||||
#include "TracyPrint.hpp"
|
||||
#include "TracyTimelineItemPlot.hpp"
|
||||
#include "TracyUtility.hpp"
|
||||
#include "TracyView.hpp"
|
||||
#include "TracyWorker.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
TimelineItemPlot::TimelineItemPlot( View& view, const Worker& worker, PlotData* plot )
|
||||
: TimelineItem( view, worker )
|
||||
, m_plot( plot )
|
||||
{
|
||||
}
|
||||
|
||||
const char* TimelineItemPlot::HeaderLabel() const
|
||||
{
|
||||
static char tmp[1024];
|
||||
switch( m_plot->type )
|
||||
{
|
||||
case PlotType::User:
|
||||
return m_worker.GetString( m_plot->name );
|
||||
case PlotType::Memory:
|
||||
if( m_plot->name == 0 )
|
||||
{
|
||||
return ICON_FA_MEMORY " Memory usage";
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( tmp, ICON_FA_MEMORY " %s", m_worker.GetString( m_plot->name ) );
|
||||
return tmp;
|
||||
}
|
||||
case PlotType::SysTime:
|
||||
return ICON_FA_GAUGE_HIGH " CPU usage";
|
||||
default:
|
||||
assert( false );
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineItemPlot::HeaderTooltip( const char* label ) const
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
SmallColorBox( GetPlotColor( *m_plot, m_worker ) );
|
||||
ImGui::SameLine();
|
||||
TextFocused( "Plot", label );
|
||||
ImGui::Separator();
|
||||
|
||||
const auto first = RangeBegin();
|
||||
const auto last = RangeEnd();
|
||||
const auto activity = last - first;
|
||||
const auto traceLen = m_worker.GetLastTime();
|
||||
|
||||
TextFocused( "Appeared at", TimeToString( first ) );
|
||||
TextFocused( "Last event at", TimeToString( last ) );
|
||||
TextFocused( "Activity time:", TimeToString( activity ) );
|
||||
ImGui::SameLine();
|
||||
char buf[64];
|
||||
PrintStringPercent( buf, activity / double( traceLen ) * 100 );
|
||||
TextDisabledUnformatted( buf );
|
||||
ImGui::Separator();
|
||||
TextFocused( "Data points:", RealToString( m_plot->data.size() ) );
|
||||
TextFocused( "Data range:", FormatPlotValue( m_plot->max - m_plot->min, m_plot->format ) );
|
||||
TextFocused( "Min value:", FormatPlotValue( m_plot->min, m_plot->format ) );
|
||||
TextFocused( "Max value:", FormatPlotValue( m_plot->max, m_plot->format ) );
|
||||
TextFocused( "Avg value:", FormatPlotValue( m_plot->sum / m_plot->data.size(), m_plot->format ) );
|
||||
TextFocused( "Data/second:", RealToString( double( m_plot->data.size() ) / activity * 1000000000ll ) );
|
||||
|
||||
const auto it = std::lower_bound( m_plot->data.begin(), m_plot->data.end(), last - 1000000000ll * 10, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||
const auto tr10 = last - it->time.Val();
|
||||
if( tr10 != 0 )
|
||||
{
|
||||
TextFocused( "D/s (10s):", RealToString( double( std::distance( it, m_plot->data.end() ) ) / tr10 * 1000000000ll ) );
|
||||
}
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
void TimelineItemPlot::HeaderExtraContents( int offset, const ImVec2& wpos, float labelWidth )
|
||||
{
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
const auto ty = ImGui::GetTextLineHeight();
|
||||
|
||||
char tmp[128];
|
||||
sprintf( tmp, "(y-range: %s, visible data points: %s)", FormatPlotValue( m_plot->rMax - m_plot->rMin, m_plot->format ), RealToString( m_plot->num ) );
|
||||
draw->AddText( wpos + ImVec2( ty * 1.5f + labelWidth, offset ), 0xFF226E6E, tmp );
|
||||
}
|
||||
|
||||
int64_t TimelineItemPlot::RangeBegin() const
|
||||
{
|
||||
return m_plot->data.front().time.Val();
|
||||
}
|
||||
|
||||
int64_t TimelineItemPlot::RangeEnd() const
|
||||
{
|
||||
return m_plot->data.back().time.Val();
|
||||
}
|
||||
|
||||
void TimelineItemPlot::DrawContents( double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax )
|
||||
{
|
||||
m_view.DrawPlot( *m_plot, pxns, offset, wpos, hover, yMin, yMax );
|
||||
}
|
||||
|
||||
}
|
35
server/TracyTimelineItemPlot.hpp
Normal file
35
server/TracyTimelineItemPlot.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef __TRACYTIMELINEITEMPLOT_HPP__
|
||||
#define __TRACYTIMELINEITEMPLOT_HPP__
|
||||
|
||||
#include "TracyEvent.hpp"
|
||||
#include "TracyTimelineItem.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
class TimelineItemPlot final : public TimelineItem
|
||||
{
|
||||
public:
|
||||
TimelineItemPlot( View& view, const Worker& worker, PlotData* plot );
|
||||
|
||||
void DrawContents( double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax ) override;
|
||||
|
||||
protected:
|
||||
uint32_t HeaderColor() const override { return 0xFF44DDDD; }
|
||||
uint32_t HeaderColorInactive() const override { return 0xFF226E6E; }
|
||||
uint32_t HeaderLineColor() const override { return 0x8844DDDD; }
|
||||
const char* HeaderLabel() const override;
|
||||
|
||||
int64_t RangeBegin() const override;
|
||||
int64_t RangeEnd() const override;
|
||||
|
||||
void HeaderTooltip( const char* label ) const override;
|
||||
void HeaderExtraContents( int offset, const ImVec2& wpos, float labelWidth ) override;
|
||||
|
||||
private:
|
||||
PlotData* m_plot;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -114,6 +114,7 @@ public:
|
||||
ShortenName GetShortenName() const { return m_shortenName; }
|
||||
|
||||
void ZoomToRange( int64_t start, int64_t end, bool pause = true );
|
||||
void DrawPlot( PlotData& plot, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax );
|
||||
|
||||
bool m_showRanges = false;
|
||||
Range m_statRange;
|
||||
@ -211,7 +212,6 @@ private:
|
||||
int SkipGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift );
|
||||
void DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset, uint8_t tid );
|
||||
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax );
|
||||
int DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax );
|
||||
void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, const PlotItem* item, double prev, bool merged, PlotType type, PlotValueFormatting format, float PlotHeight, uint64_t name );
|
||||
void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, double val, double prev, bool merged, PlotValueFormatting format, float PlotHeight );
|
||||
int DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax );
|
||||
@ -317,8 +317,6 @@ private:
|
||||
#endif
|
||||
|
||||
std::vector<MemoryPage> GetMemoryPages() const;
|
||||
const char* GetPlotName( const PlotData* plot ) const;
|
||||
uint32_t GetPlotColor( const PlotData* plot ) const;
|
||||
|
||||
void SmallCallstackButton( const char* name, uint32_t callstack, int& idx, bool tooltip = true );
|
||||
void DrawCallstackCalls( uint32_t callstack, uint16_t limit ) const;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "TracyImGui.hpp"
|
||||
#include "TracyMouse.hpp"
|
||||
#include "TracyPrint.hpp"
|
||||
#include "TracyUtility.hpp"
|
||||
#include "TracyView.hpp"
|
||||
|
||||
namespace tracy
|
||||
@ -562,9 +563,9 @@ void View::DrawOptions()
|
||||
|
||||
for( const auto& p : m_worker.GetPlots() )
|
||||
{
|
||||
SmallColorBox( GetPlotColor( p ) );
|
||||
SmallColorBox( GetPlotColor( *p, m_worker ) );
|
||||
ImGui::SameLine();
|
||||
SmallCheckbox( GetPlotName( p ), &m_tc.Vis( p ).visible );
|
||||
m_tc.GetItem( p ).VisibilityCheckbox();
|
||||
ImGui::SameLine();
|
||||
ImGui::TextDisabled( "%s data points", RealToString( p->data.size() ) );
|
||||
}
|
||||
|
@ -4,75 +4,13 @@
|
||||
#include "TracyImGui.hpp"
|
||||
#include "TracyMouse.hpp"
|
||||
#include "TracyPrint.hpp"
|
||||
#include "TracyUtility.hpp"
|
||||
#include "TracyView.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
const char* View::GetPlotName( const PlotData* plot ) const
|
||||
{
|
||||
static char tmp[1024];
|
||||
switch( plot->type )
|
||||
{
|
||||
case PlotType::User:
|
||||
return m_worker.GetString( plot->name );
|
||||
case PlotType::Memory:
|
||||
if( plot->name == 0 )
|
||||
{
|
||||
return ICON_FA_MEMORY " Memory usage";
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( tmp, ICON_FA_MEMORY " %s", m_worker.GetString( plot->name ) );
|
||||
return tmp;
|
||||
}
|
||||
case PlotType::SysTime:
|
||||
return ICON_FA_GAUGE_HIGH " CPU usage";
|
||||
default:
|
||||
assert( false );
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t View::GetPlotColor( const PlotData* plot ) const
|
||||
{
|
||||
switch( plot->type )
|
||||
{
|
||||
case PlotType::User:
|
||||
if( plot->color != 0 ) return plot->color | 0xFF000000;
|
||||
return GetHsvColor( charutil::hash( m_worker.GetString( plot->name ) ), -10 );
|
||||
case PlotType::Memory:
|
||||
return 0xFF2266CC;
|
||||
case PlotType::SysTime:
|
||||
return 0xFFBAB220;
|
||||
default:
|
||||
assert( false );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* FormatPlotValue( double val, PlotValueFormatting format )
|
||||
{
|
||||
static char buf[64];
|
||||
switch( format )
|
||||
{
|
||||
case PlotValueFormatting::Number:
|
||||
return RealToString( val );
|
||||
break;
|
||||
case PlotValueFormatting::Memory:
|
||||
return MemSizeToString( val );
|
||||
break;
|
||||
case PlotValueFormatting::Percentage:
|
||||
sprintf( buf, "%.2f%%", val );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax )
|
||||
void View::DrawPlot( PlotData& plot, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax )
|
||||
{
|
||||
const auto PlotHeight = 100 * GetScale();
|
||||
|
||||
@ -82,105 +20,16 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
const auto w = ImGui::GetContentRegionAvail().x - 1;
|
||||
const auto ty = ImGui::GetTextLineHeight();
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
const auto to = 9.f;
|
||||
const auto th = ( ty - to ) * sqrt( 3 ) * 0.5;
|
||||
const auto nspx = 1.0 / pxns;
|
||||
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
|
||||
|
||||
for( const auto& v : m_worker.GetPlots() )
|
||||
{
|
||||
auto& vis = m_tc.Vis( v );
|
||||
if( !vis.visible )
|
||||
{
|
||||
vis.height = 0;
|
||||
vis.offset = 0;
|
||||
continue;
|
||||
}
|
||||
if( v->data.empty() ) continue;
|
||||
bool& showFull = vis.showFull;
|
||||
ImGui::PushID( &vis );
|
||||
|
||||
float txtx = 0;
|
||||
const auto yPos = m_tc.AdjustThreadPosition( vis, wpos.y, offset );
|
||||
const auto oldOffset = offset;
|
||||
ImGui::PushClipRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + vis.height ), true );
|
||||
if( yPos + ty >= yMin && yPos <= yMax )
|
||||
{
|
||||
if( showFull )
|
||||
{
|
||||
draw->AddTriangleFilled( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( ty - to/2, offset + to/2 ), wpos + ImVec2( ty * 0.5, offset + to/2 + th ), 0xFF44DDDD );
|
||||
}
|
||||
else
|
||||
{
|
||||
draw->AddTriangle( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( to/2, offset + ty - to/2 ), wpos + ImVec2( to/2 + th, offset + ty * 0.5 ), 0xFF226E6E, 2.0f );
|
||||
}
|
||||
const auto txt = GetPlotName( v );
|
||||
txtx = ImGui::CalcTextSize( txt ).x;
|
||||
DrawTextContrast( draw, wpos + ImVec2( ty, offset ), showFull ? 0xFF44DDDD : 0xFF226E6E, txt );
|
||||
DrawLine( draw, dpos + ImVec2( 0, offset + ty - 1 ), dpos + ImVec2( w, offset + ty - 1 ), 0x8844DDDD );
|
||||
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( ty + txtx, offset + ty ) ) )
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
SmallColorBox( GetPlotColor( v ) );
|
||||
ImGui::SameLine();
|
||||
TextFocused( "Plot", txt );
|
||||
ImGui::Separator();
|
||||
|
||||
const auto first = v->data.front().time.Val();
|
||||
const auto last = v->data.back().time.Val();
|
||||
const auto activity = last - first;
|
||||
const auto traceLen = m_worker.GetLastTime();
|
||||
|
||||
TextFocused( "Appeared at", TimeToString( first ) );
|
||||
TextFocused( "Last event at", TimeToString( last ) );
|
||||
TextFocused( "Activity time:", TimeToString( activity ) );
|
||||
ImGui::SameLine();
|
||||
char buf[64];
|
||||
PrintStringPercent( buf, activity / double( traceLen ) * 100 );
|
||||
TextDisabledUnformatted( buf );
|
||||
ImGui::Separator();
|
||||
TextFocused( "Data points:", RealToString( v->data.size() ) );
|
||||
TextFocused( "Data range:", FormatPlotValue( v->max - v->min, v->format ) );
|
||||
TextFocused( "Min value:", FormatPlotValue( v->min, v->format ) );
|
||||
TextFocused( "Max value:", FormatPlotValue( v->max, v->format ) );
|
||||
TextFocused( "Avg value:", FormatPlotValue( v->sum / v->data.size(), v->format ) );
|
||||
TextFocused( "Data/second:", RealToString( double( v->data.size() ) / activity * 1000000000ll ) );
|
||||
|
||||
const auto it = std::lower_bound( v->data.begin(), v->data.end(), last - 1000000000ll * 10, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||
const auto tr10 = last - it->time.Val();
|
||||
if( tr10 != 0 )
|
||||
{
|
||||
TextFocused( "D/s (10s):", RealToString( double( std::distance( it, v->data.end() ) ) / tr10 * 1000000000ll ) );
|
||||
}
|
||||
ImGui::EndTooltip();
|
||||
|
||||
if( IsMouseClicked( 0 ) )
|
||||
{
|
||||
showFull = !showFull;
|
||||
}
|
||||
if( IsMouseClicked( 2 ) )
|
||||
{
|
||||
ZoomToRange( first, last );
|
||||
}
|
||||
if( IsMouseClicked( 1 ) )
|
||||
{
|
||||
ImGui::OpenPopup( "menuPopup" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
offset += ty;
|
||||
|
||||
if( showFull )
|
||||
{
|
||||
auto yPos = wpos.y + offset;
|
||||
if( yPos + PlotHeight >= yMin && yPos <= yMax )
|
||||
{
|
||||
auto& vec = v->data;
|
||||
auto& vec = plot.data;
|
||||
vec.ensure_sorted();
|
||||
|
||||
const auto color = GetPlotColor( v );
|
||||
const auto color = GetPlotColor( plot, m_worker );
|
||||
const auto bg = 0x22000000 | ( DarkenColorMore( color ) & 0xFFFFFF );
|
||||
const auto fill = 0x22000000 | ( DarkenColor( color ) & 0xFFFFFF );
|
||||
|
||||
@ -197,8 +46,8 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
const auto num = std::distance( it, end );
|
||||
if( num > 1000000 )
|
||||
{
|
||||
min = v->min;
|
||||
max = v->max;
|
||||
min = plot.min;
|
||||
max = plot.max;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -217,13 +66,14 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
max++;
|
||||
}
|
||||
|
||||
const auto rMin = min;
|
||||
const auto rMax = max;
|
||||
plot.rMin = min;
|
||||
plot.rMax = max;
|
||||
plot.num = num;
|
||||
|
||||
auto pvit = m_plotView.find( v );
|
||||
auto pvit = m_plotView.find( &plot );
|
||||
if( pvit == m_plotView.end() )
|
||||
{
|
||||
pvit = m_plotView.emplace( v, PlotView { min, max } ).first;
|
||||
pvit = m_plotView.emplace( &plot, PlotView { min, max } ).first;
|
||||
}
|
||||
auto& pv = pvit->second;
|
||||
if( pv.min != min || pv.max != max )
|
||||
@ -251,7 +101,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
{
|
||||
const auto x = ( it->time.Val() - m_vd.zvStart ) * pxns;
|
||||
const auto y = PlotHeight - ( it->val - min ) * revrange * PlotHeight;
|
||||
DrawPlotPoint( wpos, x, y, offset, color, hover, false, it, 0, false, v->type, v->format, PlotHeight, v->name );
|
||||
DrawPlotPoint( wpos, x, y, offset, color, hover, false, it, 0, false, plot.type, plot.format, PlotHeight, plot.name );
|
||||
}
|
||||
|
||||
auto prevx = it;
|
||||
@ -265,9 +115,9 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
const auto y0 = PlotHeight - ( prevy->val - min ) * revrange * PlotHeight;
|
||||
const auto y1 = PlotHeight - ( it->val - min ) * revrange * PlotHeight;
|
||||
|
||||
if( v->showSteps )
|
||||
if( plot.showSteps )
|
||||
{
|
||||
if( v->fill )
|
||||
if( plot.fill )
|
||||
{
|
||||
draw->AddRectFilled( dpos + ImVec2( x0, offset + PlotHeight ), dpos + ImVec2( x1, offset + y0 ), fill );
|
||||
}
|
||||
@ -276,7 +126,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
}
|
||||
else
|
||||
{
|
||||
if( v->fill )
|
||||
if( plot.fill )
|
||||
{
|
||||
draw->AddQuadFilled( dpos + ImVec2( x0, offset + PlotHeight ), dpos + ImVec2( x0, offset + y0 ), dpos + ImVec2( x1, offset + y1 ), dpos + ImVec2( x1, offset + PlotHeight ), fill );
|
||||
}
|
||||
@ -290,7 +140,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
const auto rsz = std::distance( it, range );
|
||||
if( rsz == 1 )
|
||||
{
|
||||
DrawPlotPoint( wpos, x1, y1, offset, color, hover, true, it, prevy->val, false, v->type, v->format, PlotHeight, v->name );
|
||||
DrawPlotPoint( wpos, x1, y1, offset, color, hover, true, it, prevy->val, false, plot.type, plot.format, PlotHeight, plot.name );
|
||||
prevx = it;
|
||||
prevy = it;
|
||||
++it;
|
||||
@ -324,9 +174,9 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
TextFocused( "Number of values:", RealToString( rsz ) );
|
||||
TextDisabledUnformatted( "Estimated range:" );
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( "%s - %s", FormatPlotValue( tmpvec[0], v->format ), FormatPlotValue( dst[-1], v->format ) );
|
||||
ImGui::Text( "%s - %s", FormatPlotValue( tmpvec[0], plot.format ), FormatPlotValue( dst[-1], plot.format ) );
|
||||
ImGui::SameLine();
|
||||
ImGui::TextDisabled( "(%s)", FormatPlotValue( dst[-1] - tmpvec[0], v->format ) );
|
||||
ImGui::TextDisabled( "(%s)", FormatPlotValue( dst[-1] - tmpvec[0], plot.format ) );
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
@ -341,11 +191,11 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
assert( vrange > vit );
|
||||
if( std::distance( vit, vrange ) == 1 )
|
||||
{
|
||||
DrawPlotPoint( wpos, x1, PlotHeight - ( *vit - min ) * revrange * PlotHeight, offset, color, hover, false, *vit, 0, false, v->format, PlotHeight );
|
||||
DrawPlotPoint( wpos, x1, PlotHeight - ( *vit - min ) * revrange * PlotHeight, offset, color, hover, false, *vit, 0, false, plot.format, PlotHeight );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawPlotPoint( wpos, x1, PlotHeight - ( *vit - min ) * revrange * PlotHeight, offset, color, hover, false, *vit, 0, true, v->format, PlotHeight );
|
||||
DrawPlotPoint( wpos, x1, PlotHeight - ( *vit - min ) * revrange * PlotHeight, offset, color, hover, false, *vit, 0, true, plot.format, PlotHeight );
|
||||
}
|
||||
vit = vrange;
|
||||
}
|
||||
@ -355,11 +205,11 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
}
|
||||
}
|
||||
|
||||
if( v->type == PlotType::Memory )
|
||||
if( plot.type == PlotType::Memory )
|
||||
{
|
||||
auto& mem = m_worker.GetMemoryNamed( v->name );
|
||||
auto& mem = m_worker.GetMemoryNamed( plot.name );
|
||||
|
||||
if( m_memoryAllocInfoPool == v->name && m_memoryAllocInfoWindow >= 0 )
|
||||
if( m_memoryAllocInfoPool == plot.name && m_memoryAllocInfoWindow >= 0 )
|
||||
{
|
||||
const auto& ev = mem.data[m_memoryAllocInfoWindow];
|
||||
|
||||
@ -371,7 +221,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
draw->AddRectFilled( ImVec2( wpos.x + px0, yPos ), ImVec2( wpos.x + px1, yPos + PlotHeight ), 0x2288DD88 );
|
||||
draw->AddRect( ImVec2( wpos.x + px0, yPos ), ImVec2( wpos.x + px1, yPos + PlotHeight ), 0x4488DD88 );
|
||||
}
|
||||
if( m_memoryAllocHover >= 0 && m_memoryAllocHoverPool == v->name && ( m_memoryAllocInfoPool != v->name || m_memoryAllocHover != m_memoryAllocInfoWindow ) )
|
||||
if( m_memoryAllocHover >= 0 && m_memoryAllocHoverPool == plot.name && ( m_memoryAllocInfoPool != plot.name || m_memoryAllocHover != m_memoryAllocInfoWindow ) )
|
||||
{
|
||||
const auto& ev = mem.data[m_memoryAllocHover];
|
||||
|
||||
@ -394,16 +244,10 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
}
|
||||
}
|
||||
|
||||
if( yPos + ty >= yMin && yPos <= yMax )
|
||||
{
|
||||
char tmp[64];
|
||||
sprintf( tmp, "(y-range: %s, visible data points: %s)", FormatPlotValue( rMax - rMin, v->format ), RealToString( num ) );
|
||||
draw->AddText( wpos + ImVec2( ty * 1.5f + txtx, offset - ty ), 0xFF226E6E, tmp );
|
||||
}
|
||||
auto tmp = FormatPlotValue( rMax, v->format );
|
||||
auto tmp = FormatPlotValue( plot.rMax, plot.format );
|
||||
DrawTextSuperContrast( draw, wpos + ImVec2( 0, offset ), color, tmp );
|
||||
offset += PlotHeight - ty;
|
||||
tmp = FormatPlotValue( rMin, v->format );
|
||||
tmp = FormatPlotValue( plot.rMin, plot.format );
|
||||
DrawTextSuperContrast( draw, wpos + ImVec2( 0, offset ), color, tmp );
|
||||
|
||||
DrawLine( draw, dpos + ImVec2( 0, offset + ty - 1 ), dpos + ImVec2( w, offset + ty - 1 ), 0xFF226E6E );
|
||||
@ -415,25 +259,6 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
}
|
||||
}
|
||||
|
||||
if( ImGui::BeginPopup( "menuPopup" ) )
|
||||
{
|
||||
if( ImGui::MenuItem( ICON_FA_EYE_SLASH " Hide" ) )
|
||||
{
|
||||
vis.visible = false;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
offset += 0.2 * ty;
|
||||
m_tc.AdjustThreadHeight( vis, oldOffset, offset );
|
||||
ImGui::PopClipRect();
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
void View::DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, double val, double prev, bool merged, PlotValueFormatting format, float PlotHeight )
|
||||
{
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "TracyMouse.hpp"
|
||||
#include "TracyPrint.hpp"
|
||||
#include "TracySourceView.hpp"
|
||||
#include "TracyTimelineItemPlot.hpp"
|
||||
#include "TracyView.hpp"
|
||||
|
||||
namespace tracy
|
||||
@ -1037,7 +1038,10 @@ void View::DrawTimeline()
|
||||
|
||||
if( m_vd.drawPlots )
|
||||
{
|
||||
offset = DrawPlots( offset, pxns, wpos, hover, yMin, yMax );
|
||||
for( const auto& v : m_worker.GetPlots() )
|
||||
{
|
||||
m_tc.AddItem<TimelineItemPlot>( v );
|
||||
}
|
||||
}
|
||||
|
||||
m_tc.End( pxns, offset, wpos, hover, yMin, yMax );
|
||||
|
Loading…
Reference in New Issue
Block a user