mirror of
https://github.com/gwm17/implot.git
synced 2024-11-26 12:18:52 -05:00
Merge branch 'master' into guides
This commit is contained in:
commit
c6aff1362c
|
@ -24,6 +24,7 @@ ImPlot is an immediate mode, GPU accelerated plotting library for [Dear ImGui](h
|
|||
- stem plots
|
||||
- pie charts
|
||||
- heatmap charts
|
||||
- images
|
||||
- and more likely to come
|
||||
- mix/match multiple plot items on a single plot
|
||||
- configurable axes ranges and scaling (linear/log)
|
||||
|
|
|
@ -845,6 +845,7 @@ int FormatTime12(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt)
|
|||
case ImPlotTimeFmt_SUs: return snprintf(buffer, size, ":%02d.%03d %03d", sec, ms, us);
|
||||
case ImPlotTimeFmt_SMs: return snprintf(buffer, size, ":%02d.%03d", sec, ms);
|
||||
case ImPlotTimeFmt_S: return snprintf(buffer, size, ":%02d", sec);
|
||||
case ImPlotTimeFmt_HrMinSMs: return snprintf(buffer, size, "%d:%02d:%02d.%03d%s", hr, min, sec, ms, ap);
|
||||
case ImPlotTimeFmt_HrMinS: return snprintf(buffer, size, "%d:%02d:%02d%s", hr, min, sec, ap);
|
||||
case ImPlotTimeFmt_HrMin: return snprintf(buffer, size, "%d:%02d%s", hr, min, ap);
|
||||
case ImPlotTimeFmt_Hr: return snprintf(buffer, size, "%d%s", hr, ap);
|
||||
|
@ -881,6 +882,7 @@ int FormatTime24(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt)
|
|||
case ImPlotTimeFmt_SUs: return snprintf(buffer, size, ":%02d.%03d %03d", sec, ms, us);
|
||||
case ImPlotTimeFmt_SMs: return snprintf(buffer, size, ":%02d.%03d", sec, ms);
|
||||
case ImPlotTimeFmt_S: return snprintf(buffer, size, ":%02d", sec);
|
||||
case ImPlotTimeFmt_HrMinSMs: return snprintf(buffer, size, "%02d:%02d:%02d.%03d", hr, min, sec, ms);
|
||||
case ImPlotTimeFmt_HrMinS: return snprintf(buffer, size, "%02d:%02d:%02d", hr, min, sec);
|
||||
case ImPlotTimeFmt_HrMin: return snprintf(buffer, size, "%02d:%02d", hr, min);
|
||||
case ImPlotTimeFmt_Hr: return snprintf(buffer, size, "%02d:00", hr);
|
||||
|
@ -905,6 +907,7 @@ inline float GetTimeLabelWidth12(ImPlotTimeFmt fmt) {
|
|||
case ImPlotTimeFmt_SUs: return ImGui::CalcTextSize(":88.888 888").x; // :29.428 552
|
||||
case ImPlotTimeFmt_SMs: return ImGui::CalcTextSize(":88.888").x; // :29.428
|
||||
case ImPlotTimeFmt_S: return ImGui::CalcTextSize(":88").x; // :29
|
||||
case ImPlotTimeFmt_HrMinSMs: return ImGui::CalcTextSize("88:88:88.888pm").x; // 7:21:29.428pm
|
||||
case ImPlotTimeFmt_HrMinS: return ImGui::CalcTextSize("88:88:88pm").x; // 7:21:29pm
|
||||
case ImPlotTimeFmt_HrMin: return ImGui::CalcTextSize("88:88pm").x; // 7:21pm
|
||||
case ImPlotTimeFmt_Hr: return ImGui::CalcTextSize("88pm").x; // 7pm
|
||||
|
@ -929,6 +932,7 @@ inline float GetTimeLabelWidth24(ImPlotTimeFmt fmt) {
|
|||
case ImPlotTimeFmt_SUs: return ImGui::CalcTextSize(":88.888 888").x; // :29.428 552
|
||||
case ImPlotTimeFmt_SMs: return ImGui::CalcTextSize(":88.888").x; // :29.428
|
||||
case ImPlotTimeFmt_S: return ImGui::CalcTextSize(":88").x; // :29
|
||||
case ImPlotTimeFmt_HrMinSMs: return ImGui::CalcTextSize("88:88:88.888").x; // 19:21:29.428
|
||||
case ImPlotTimeFmt_HrMinS: return ImGui::CalcTextSize("88:88:88").x; // 19:21:29
|
||||
case ImPlotTimeFmt_HrMin: return ImGui::CalcTextSize("88:88").x; // 19:21
|
||||
case ImPlotTimeFmt_Hr: return ImGui::CalcTextSize("88:00").x; // 19:00
|
||||
|
|
4
implot.h
4
implot.h
|
@ -188,6 +188,7 @@ struct ImPlotPoint {
|
|||
double x, y;
|
||||
ImPlotPoint() { x = y = 0.0; }
|
||||
ImPlotPoint(double _x, double _y) { x = _x; y = _y; }
|
||||
ImPlotPoint(const ImVec2& p) { x = p.x; y = p.y; }
|
||||
double operator[] (size_t idx) const { return (&x)[idx]; }
|
||||
double& operator[] (size_t idx) { return (&x)[idx]; }
|
||||
#ifdef IMPLOT_POINT_CLASS_EXTRA
|
||||
|
@ -393,6 +394,9 @@ template <typename T> IMPLOT_API void PlotHeatmap(const char* label_id, const T*
|
|||
template <typename T> IMPLOT_API void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||
IMPLOT_API void PlotDigitalG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset=0);
|
||||
|
||||
// Plots an axis-aligned image. #bounds_min/bounds_max are in plot coordinatse (y-up) and #uv0/uv1 are in texture coordinates (y-down).
|
||||
IMPLOT_API void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max, const ImVec2& uv0=ImVec2(0,0), const ImVec2& uv1=ImVec2(1,1), const ImVec4& tint_col=ImVec4(1,1,1,1));
|
||||
|
||||
// Plots a centered text label at point x,y with optional pixel offset. Text color can be changed with ImPlot::PushStyleColor(ImPlotCol_InlayText, ...).
|
||||
IMPLOT_API void PlotText(const char* text, double x, double y, bool vertical=false, const ImVec2& pixel_offset=ImVec2(0,0));
|
||||
|
||||
|
|
|
@ -508,6 +508,26 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImPlot::PopColormap();
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Images")) {
|
||||
ImGui::BulletText("Below we are displaying the font texture, which is the only texture we have\naccess to in this demo.");
|
||||
ImGui::BulletText("Use the 'ImTextureID' type as storage to pass pointers or identifiers to your\nown texture data.");
|
||||
ImGui::BulletText("See ImGui Wiki page 'Image Loading and Displaying Examples'.");
|
||||
static ImVec2 bmin(0,0);
|
||||
static ImVec2 bmax(1,1);
|
||||
static ImVec2 uv0(0,0);
|
||||
static ImVec2 uv1(1,1);
|
||||
static ImVec4 tint(1,1,1,1);
|
||||
ImGui::SliderFloat2("Min", &bmin.x, -2, 2, "%.1f");
|
||||
ImGui::SliderFloat2("Max", &bmax.x, -2, 2, "%.1f");
|
||||
ImGui::SliderFloat2("UV0", &uv0.x, -2, 2, "%.1f");
|
||||
ImGui::SliderFloat2("UV1", &uv1.x, -2, 2, "%.1f");
|
||||
ImGui::ColorEdit4("Tint",&tint.x);
|
||||
if (ImPlot::BeginPlot("##image")) {
|
||||
ImPlot::PlotImage("my image",ImGui::GetIO().Fonts->TexID, bmin, bmax, uv0, uv1, tint);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Realtime Plots")) {
|
||||
ImGui::BulletText("Move your mouse to change the data!");
|
||||
ImGui::BulletText("This example assumes 60 FPS. Higher FPS requires larger buffer size.");
|
||||
|
|
|
@ -187,6 +187,7 @@ enum ImPlotTimeFmt_ {
|
|||
ImPlotTimeFmt_SUs, // :29.428 552
|
||||
ImPlotTimeFmt_SMs, // :29.428
|
||||
ImPlotTimeFmt_S, // :29
|
||||
ImPlotTimeFmt_HrMinSMs, // 7:21:29.428pm (19:21:29.428)
|
||||
ImPlotTimeFmt_HrMinS, // 7:21:29pm (19:21:29)
|
||||
ImPlotTimeFmt_HrMin, // 7:21pm (19:21)
|
||||
ImPlotTimeFmt_Hr, // 7pm (19:00)
|
||||
|
|
|
@ -1705,6 +1705,27 @@ void PlotRects(const char* label_id, ImPlotPoint (*getter_func)(void* data, int
|
|||
return PlotRectsEx(label_id, getter);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PLOT IMAGE
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPoint& bmin, const ImPlotPoint& bmax, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col) {
|
||||
if (BeginItem(label_id)) {
|
||||
if (FitThisFrame()) {
|
||||
FitPoint(bmin);
|
||||
FitPoint(bmax);
|
||||
}
|
||||
GetCurrentItem()->Color = tint_col;
|
||||
ImDrawList& DrawList = *GetPlotDrawList();
|
||||
ImVec2 p1 = PlotToPixels(bmin.x, bmax.y);
|
||||
ImVec2 p2 = PlotToPixels(bmax.x, bmin.y);
|
||||
PushPlotClipRect();
|
||||
DrawList.AddImage(user_texture_id, p1, p2, uv0, uv1, ImGui::ColorConvertFloat4ToU32(tint_col));
|
||||
PopPlotClipRect();
|
||||
EndItem();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PLOT TEXT
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user