mirror of
https://github.com/gwm17/implot.git
synced 2024-11-13 22:48:50 -05:00
trim white space
This commit is contained in:
parent
2b46c3eac3
commit
d8610c33c7
106
implot.cpp
106
implot.cpp
|
@ -422,7 +422,7 @@ void PushLinkedAxis(ImPlotAxis& axis) {
|
||||||
|
|
||||||
void PullLinkedAxis(ImPlotAxis& axis) {
|
void PullLinkedAxis(ImPlotAxis& axis) {
|
||||||
if (axis.LinkedMin) { axis.SetMin(*axis.LinkedMin); }
|
if (axis.LinkedMin) { axis.SetMin(*axis.LinkedMin); }
|
||||||
if (axis.LinkedMax) { axis.SetMax(*axis.LinkedMax); }
|
if (axis.LinkedMax) { axis.SetMax(*axis.LinkedMax); }
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -600,13 +600,13 @@ void AddTicksCustom(const double* values, const char** labels, int n, ImPlotTick
|
||||||
|
|
||||||
// this may not be thread safe?
|
// this may not be thread safe?
|
||||||
static const double TimeUnitSpans[ImPlotTimeUnit_COUNT] = {
|
static const double TimeUnitSpans[ImPlotTimeUnit_COUNT] = {
|
||||||
0.000001,
|
0.000001,
|
||||||
0.001,
|
0.001,
|
||||||
1,
|
1,
|
||||||
60,
|
60,
|
||||||
3600,
|
3600,
|
||||||
86400,
|
86400,
|
||||||
2629800,
|
2629800,
|
||||||
31557600
|
31557600
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -661,10 +661,10 @@ inline int GetTimeStep(int max_divs, ImPlotTimeUnit unit) {
|
||||||
ImPlotTime MkGmtTime(struct tm *ptm) {
|
ImPlotTime MkGmtTime(struct tm *ptm) {
|
||||||
time_t secs = 0;
|
time_t secs = 0;
|
||||||
int year = ptm->tm_year + 1900;
|
int year = ptm->tm_year + 1900;
|
||||||
for (int y = 1970; y < year; ++y)
|
for (int y = 1970; y < year; ++y)
|
||||||
secs += (IsLeapYear(y)? 366: 365) * 86400;
|
secs += (IsLeapYear(y)? 366: 365) * 86400;
|
||||||
for (int m = 0; m < ptm->tm_mon; ++m)
|
for (int m = 0; m < ptm->tm_mon; ++m)
|
||||||
secs += GetDaysInMonth(year, m) * 86400;
|
secs += GetDaysInMonth(year, m) * 86400;
|
||||||
secs += (ptm->tm_mday - 1) * 86400;
|
secs += (ptm->tm_mday - 1) * 86400;
|
||||||
secs += ptm->tm_hour * 3600;
|
secs += ptm->tm_hour * 3600;
|
||||||
secs += ptm->tm_min * 60;
|
secs += ptm->tm_min * 60;
|
||||||
|
@ -727,12 +727,12 @@ ImPlotTime AddTime(const ImPlotTime& t, ImPlotTimeUnit unit, int count) {
|
||||||
case ImPlotTimeUnit_Day: t_out.S += count * 86400; break;
|
case ImPlotTimeUnit_Day: t_out.S += count * 86400; break;
|
||||||
case ImPlotTimeUnit_Mo: for (int i = 0; i < count; ++i) { // this might have a bug
|
case ImPlotTimeUnit_Mo: for (int i = 0; i < count; ++i) { // this might have a bug
|
||||||
GetTime(t_out, &Tm);
|
GetTime(t_out, &Tm);
|
||||||
t_out.S += 86400 * GetDaysInMonth(Tm.tm_year + 1900, Tm.tm_mon);
|
t_out.S += 86400 * GetDaysInMonth(Tm.tm_year + 1900, Tm.tm_mon);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ImPlotTimeUnit_Yr: for (int i = 0; i < count; ++i) {
|
case ImPlotTimeUnit_Yr: for (int i = 0; i < count; ++i) {
|
||||||
if (IsLeapYear(GetYear(t_out)))
|
if (IsLeapYear(GetYear(t_out)))
|
||||||
t_out.S += 366 * 86400;
|
t_out.S += 366 * 86400;
|
||||||
else
|
else
|
||||||
t_out.S += 365 * 86400;
|
t_out.S += 365 * 86400;
|
||||||
}
|
}
|
||||||
|
@ -809,31 +809,31 @@ int FormatTime(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt) {
|
||||||
|
|
||||||
static const char mnames[12][4] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
|
static const char mnames[12][4] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
|
||||||
|
|
||||||
switch(fmt) {
|
switch(fmt) {
|
||||||
case ImPlotTimeFmt_Us: return snprintf(buffer, size, ".%03d %03d", ms, us);
|
case ImPlotTimeFmt_Us: return snprintf(buffer, size, ".%03d %03d", ms, us);
|
||||||
case ImPlotTimeFmt_SUs: return snprintf(buffer, size, ":%02d.%03d %03d", sec, ms, us);
|
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_SMs: return snprintf(buffer, size, ":%02d.%03d", sec, ms);
|
||||||
case ImPlotTimeFmt_S: return snprintf(buffer, size, ":%02d", sec);
|
case ImPlotTimeFmt_S: return snprintf(buffer, size, ":%02d", sec);
|
||||||
case ImPlotTimeFmt_HrMinS: return snprintf(buffer, size, "%d:%02d:%02d%s", hr, min, sec, 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_HrMin: return snprintf(buffer, size, "%d:%02d%s", hr, min, ap);
|
||||||
case ImPlotTimeFmt_Hr: return snprintf(buffer, size, "%d%s", hr, ap);
|
case ImPlotTimeFmt_Hr: return snprintf(buffer, size, "%d%s", hr, ap);
|
||||||
case ImPlotTimeFmt_DayMo: return snprintf(buffer, size, "%d/%d", mon, day);
|
case ImPlotTimeFmt_DayMo: return snprintf(buffer, size, "%d/%d", mon, day);
|
||||||
case ImPlotTimeFmt_DayMoHr: return snprintf(buffer, size, "%d/%d %d%s", mon, day, hr, ap);
|
case ImPlotTimeFmt_DayMoHr: return snprintf(buffer, size, "%d/%d %d%s", mon, day, hr, ap);
|
||||||
case ImPlotTimeFmt_DayMoHrMin: return snprintf(buffer, size, "%d/%d %d:%02d%s", mon, day, hr, min, ap);
|
case ImPlotTimeFmt_DayMoHrMin: return snprintf(buffer, size, "%d/%d %d:%02d%s", mon, day, hr, min, ap);
|
||||||
case ImPlotTimeFmt_DayMoYr: return snprintf(buffer, size, "%d/%d/%02d", mon, day, yr);
|
case ImPlotTimeFmt_DayMoYr: return snprintf(buffer, size, "%d/%d/%02d", mon, day, yr);
|
||||||
case ImPlotTimeFmt_DayMoYrHrMin: return snprintf(buffer, size, "%d/%d/%02d %d:%02d%s", mon, day, yr, hr, min, ap);
|
case ImPlotTimeFmt_DayMoYrHrMin: return snprintf(buffer, size, "%d/%d/%02d %d:%02d%s", mon, day, yr, hr, min, ap);
|
||||||
case ImPlotTimeFmt_DayMoYrHrMinS: return snprintf(buffer, size, "%d/%d/%02d %d:%02d:%02d%s", mon, day, yr, hr, min, sec, ap);
|
case ImPlotTimeFmt_DayMoYrHrMinS: return snprintf(buffer, size, "%d/%d/%02d %d:%02d:%02d%s", mon, day, yr, hr, min, sec, ap);
|
||||||
case ImPlotTimeFmt_MoYr: return snprintf(buffer, size, "%s %d", mnames[Tm.tm_mon], year);
|
case ImPlotTimeFmt_MoYr: return snprintf(buffer, size, "%s %d", mnames[Tm.tm_mon], year);
|
||||||
case ImPlotTimeFmt_Mo: return snprintf(buffer, size, "%s", mnames[Tm.tm_mon]);
|
case ImPlotTimeFmt_Mo: return snprintf(buffer, size, "%s", mnames[Tm.tm_mon]);
|
||||||
case ImPlotTimeFmt_Yr: return snprintf(buffer, size, "%d", year);
|
case ImPlotTimeFmt_Yr: return snprintf(buffer, size, "%d", year);
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintTime(const ImPlotTime& t, ImPlotTimeFmt fmt) {
|
void PrintTime(const ImPlotTime& t, ImPlotTimeFmt fmt) {
|
||||||
static char buff[32];
|
static char buff[32];
|
||||||
FormatTime(t, buff, 32, fmt);
|
FormatTime(t, buff, 32, fmt);
|
||||||
printf("%s\n",buff);
|
printf("%s\n",buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the nominally largest possible width for a time format
|
// Returns the nominally largest possible width for a time format
|
||||||
|
@ -949,8 +949,8 @@ void AddTicksTime(const ImPlotRange& range, float plot_width, ImPlotTickCollecti
|
||||||
// generate ticks
|
// generate ticks
|
||||||
ImPlotTime t1 = FloorTime(ImPlotTime::FromDouble(range.Min), unit1);
|
ImPlotTime t1 = FloorTime(ImPlotTime::FromDouble(range.Min), unit1);
|
||||||
while (t1 < t_max) {
|
while (t1 < t_max) {
|
||||||
// get next major
|
// get next major
|
||||||
const ImPlotTime t2 = AddTime(t1, unit1, 1);
|
const ImPlotTime t2 = AddTime(t1, unit1, 1);
|
||||||
// add major tick
|
// add major tick
|
||||||
if (t1 >= t_min && t1 <= t_max) {
|
if (t1 >= t_min && t1 <= t_max) {
|
||||||
// minor level 0 tick
|
// minor level 0 tick
|
||||||
|
@ -961,12 +961,12 @@ void AddTicksTime(const ImPlotRange& range, float plot_width, ImPlotTickCollecti
|
||||||
// major level 1 tick
|
// major level 1 tick
|
||||||
ImPlotTick tick_maj(t1.ToDouble(),true,true);
|
ImPlotTick tick_maj(t1.ToDouble(),true,true);
|
||||||
tick_maj.Level = 1;
|
tick_maj.Level = 1;
|
||||||
LabelTickTime(tick_maj,ticks.Labels,t1, last_major == NULL ? fmtf : fmt1);
|
LabelTickTime(tick_maj,ticks.Labels,t1, last_major == NULL ? fmtf : fmt1);
|
||||||
const char* this_major = ticks.Labels.Buf.Data + tick_maj.BufferOffset;
|
const char* this_major = ticks.Labels.Buf.Data + tick_maj.BufferOffset;
|
||||||
if (last_major && TimeLabelSame(last_major,this_major))
|
if (last_major && TimeLabelSame(last_major,this_major))
|
||||||
tick_maj.ShowLabel = false;
|
tick_maj.ShowLabel = false;
|
||||||
last_major = this_major;
|
last_major = this_major;
|
||||||
ticks.AddTick(tick_maj);
|
ticks.AddTick(tick_maj);
|
||||||
}
|
}
|
||||||
// add minor ticks up until next major
|
// add minor ticks up until next major
|
||||||
if (minor_per_major > 1 && (t_min <= t2 && t1 <= t_max)) {
|
if (minor_per_major > 1 && (t_min <= t2 && t1 <= t_max)) {
|
||||||
|
@ -987,7 +987,7 @@ void AddTicksTime(const ImPlotRange& range, float plot_width, ImPlotTickCollecti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t12 = AddTime(t12, unit0, step);
|
t12 = AddTime(t12, unit0, step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t1 = t2;
|
t1 = t2;
|
||||||
}
|
}
|
||||||
|
@ -1033,8 +1033,8 @@ void UpdateAxisColors(int axis_flag, ImPlotAxisColor* col) {
|
||||||
// BeginPlot()
|
// BeginPlot()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BeginPlot(const char* title, const char* x_label, const char* y_label, const ImVec2& size,
|
bool BeginPlot(const char* title, const char* x_label, const char* y_label, const ImVec2& size,
|
||||||
ImPlotFlags flags, ImPlotAxisFlags x_flags, ImPlotAxisFlags y_flags, ImPlotAxisFlags y2_flags, ImPlotAxisFlags y3_flags)
|
ImPlotFlags flags, ImPlotAxisFlags x_flags, ImPlotAxisFlags y_flags, ImPlotAxisFlags y2_flags, ImPlotAxisFlags y3_flags)
|
||||||
{
|
{
|
||||||
IM_ASSERT_USER_ERROR(GImPlot != NULL, "No current context. Did you call ImPlot::CreateContext() or ImPlot::SetCurrentContext()?");
|
IM_ASSERT_USER_ERROR(GImPlot != NULL, "No current context. Did you call ImPlot::CreateContext() or ImPlot::SetCurrentContext()?");
|
||||||
ImPlotContext& gp = *GImPlot;
|
ImPlotContext& gp = *GImPlot;
|
||||||
|
@ -1115,14 +1115,14 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gp.NextPlotData.HasXRange) {
|
if (gp.NextPlotData.HasXRange) {
|
||||||
if (just_created || gp.NextPlotData.XRangeCond == ImGuiCond_Always)
|
if (just_created || gp.NextPlotData.XRangeCond == ImGuiCond_Always)
|
||||||
plot.XAxis.SetRange(gp.NextPlotData.X);
|
plot.XAxis.SetRange(gp.NextPlotData.X);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < IMPLOT_Y_AXES; i++) {
|
for (int i = 0; i < IMPLOT_Y_AXES; i++) {
|
||||||
if (gp.NextPlotData.HasYRange[i]) {
|
if (gp.NextPlotData.HasYRange[i]) {
|
||||||
if (just_created || gp.NextPlotData.YRangeCond[i] == ImGuiCond_Always)
|
if (just_created || gp.NextPlotData.YRangeCond[i] == ImGuiCond_Always)
|
||||||
plot.YAxis[i].SetRange(gp.NextPlotData.Y[i]);
|
plot.YAxis[i].SetRange(gp.NextPlotData.Y[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,8 +1195,8 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
|
||||||
const float txt_height = ImGui::GetTextLineHeight();
|
const float txt_height = ImGui::GetTextLineHeight();
|
||||||
|
|
||||||
const float pad_top = title_size.x > 0.0f ? txt_height + gp.Style.LabelPadding.y : 0;
|
const float pad_top = title_size.x > 0.0f ? txt_height + gp.Style.LabelPadding.y : 0;
|
||||||
const float pad_bot = (gp.X.HasLabels ? txt_height + gp.Style.LabelPadding.y + (gp.X.IsTime ? txt_height + gp.Style.LabelPadding.y : 0) : 0)
|
const float pad_bot = (gp.X.HasLabels ? txt_height + gp.Style.LabelPadding.y + (gp.X.IsTime ? txt_height + gp.Style.LabelPadding.y : 0) : 0)
|
||||||
+ (x_label ? txt_height + gp.Style.LabelPadding.y : 0);
|
+ (x_label ? txt_height + gp.Style.LabelPadding.y : 0);
|
||||||
|
|
||||||
const float plot_height = gp.BB_Canvas.GetHeight() - pad_top - pad_bot;
|
const float plot_height = gp.BB_Canvas.GetHeight() - pad_top - pad_bot;
|
||||||
|
|
||||||
|
@ -1605,7 +1605,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
|
||||||
for (int t = 0; t < gp.XTicks.Size; t++) {
|
for (int t = 0; t < gp.XTicks.Size; t++) {
|
||||||
ImPlotTick *xt = &gp.XTicks.Ticks[t];
|
ImPlotTick *xt = &gp.XTicks.Ticks[t];
|
||||||
if (xt->ShowLabel && xt->PixelPos >= gp.BB_Plot.Min.x - 1 && xt->PixelPos <= gp.BB_Plot.Max.x + 1)
|
if (xt->ShowLabel && xt->PixelPos >= gp.BB_Plot.Min.x - 1 && xt->PixelPos <= gp.BB_Plot.Max.x + 1)
|
||||||
DrawList.AddText(ImVec2(xt->PixelPos - xt->LabelSize.x * 0.5f, gp.BB_Plot.Max.y + gp.Style.LabelPadding.y + xt->Level * (txt_height + gp.Style.LabelPadding.y)),
|
DrawList.AddText(ImVec2(xt->PixelPos - xt->LabelSize.x * 0.5f, gp.BB_Plot.Max.y + gp.Style.LabelPadding.y + xt->Level * (txt_height + gp.Style.LabelPadding.y)),
|
||||||
xt->Major ? gp.Col_X.MajTxt : gp.Col_X.MinTxt, gp.XTicks.GetLabel(t));
|
xt->Major ? gp.Col_X.MajTxt : gp.Col_X.MinTxt, gp.XTicks.GetLabel(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1817,7 +1817,7 @@ void EndPlot() {
|
||||||
if (!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoTickMarks)) {
|
if (!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoTickMarks)) {
|
||||||
for (int t = 0; t < gp.XTicks.Size; t++) {
|
for (int t = 0; t < gp.XTicks.Size; t++) {
|
||||||
ImPlotTick *xt = &gp.XTicks.Ticks[t];
|
ImPlotTick *xt = &gp.XTicks.Ticks[t];
|
||||||
if (xt->Level == 0)
|
if (xt->Level == 0)
|
||||||
DrawList.AddLine(ImVec2(xt->PixelPos, gp.BB_Plot.Max.y),
|
DrawList.AddLine(ImVec2(xt->PixelPos, gp.BB_Plot.Max.y),
|
||||||
ImVec2(xt->PixelPos, gp.BB_Plot.Max.y - (xt->Major ? gp.Style.MajorTickLen.x : gp.Style.MinorTickLen.x)),
|
ImVec2(xt->PixelPos, gp.BB_Plot.Max.y - (xt->Major ? gp.Style.MajorTickLen.x : gp.Style.MinorTickLen.x)),
|
||||||
gp.Col_X.Major,
|
gp.Col_X.Major,
|
||||||
|
|
|
@ -619,7 +619,7 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
"UNIX timestamps in seconds and axis labels are formated as date/time.");
|
"UNIX timestamps in seconds and axis labels are formated as date/time.");
|
||||||
ImGui::BulletText("By default, labels are in UTC time but can be set to use local time instead.");
|
ImGui::BulletText("By default, labels are in UTC time but can be set to use local time instead.");
|
||||||
|
|
||||||
ImGui::Checkbox("Use Local Time",&ImPlot::GetStyle().UseLocalTime);
|
ImGui::Checkbox("Use Local Time",&ImPlot::GetStyle().UseLocalTime);
|
||||||
|
|
||||||
static HugeTimeData* data = NULL;
|
static HugeTimeData* data = NULL;
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
|
@ -632,9 +632,9 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
|
|
||||||
ImPlot::SetNextPlotLimits(t_min,t_max,0,1);
|
ImPlot::SetNextPlotLimits(t_min,t_max,0,1);
|
||||||
if (ImPlot::BeginPlot("##Time", "Time", "Value", ImVec2(-1,0), 0, ImPlotAxisFlags_Time)) {
|
if (ImPlot::BeginPlot("##Time", "Time", "Value", ImVec2(-1,0), 0, ImPlotAxisFlags_Time)) {
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
// downsample our data
|
// downsample our data
|
||||||
int downsample = (int)ImPlot::GetPlotLimits().X.Size() / 1000 + 1;
|
int downsample = (int)ImPlot::GetPlotLimits().X.Size() / 1000 + 1;
|
||||||
int start = (int)(ImPlot::GetPlotLimits().X.Min - t_min);
|
int start = (int)(ImPlot::GetPlotLimits().X.Min - t_min);
|
||||||
start = start < 0 ? 0 : start > HugeTimeData::Size - 1 ? HugeTimeData::Size - 1 : start;
|
start = start < 0 ? 0 : start > HugeTimeData::Size - 1 ? HugeTimeData::Size - 1 : start;
|
||||||
int end = (int)(ImPlot::GetPlotLimits().X.Max - t_min) + 1000;
|
int end = (int)(ImPlot::GetPlotLimits().X.Max - t_min) + 1000;
|
||||||
|
@ -701,14 +701,14 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Checkbox("Link Y", &linky);
|
ImGui::Checkbox("Link Y", &linky);
|
||||||
ImPlot::LinkNextPlotLimits(linkx ? &xmin : NULL , linkx ? &xmax : NULL, linky ? &ymin : NULL, linky ? &ymax : NULL);
|
ImPlot::LinkNextPlotLimits(linkx ? &xmin : NULL , linkx ? &xmax : NULL, linky ? &ymin : NULL, linky ? &ymax : NULL);
|
||||||
if (ImPlot::BeginPlot("Plot A")) {
|
if (ImPlot::BeginPlot("Plot A")) {
|
||||||
ImPlot::PlotLine("Line",data,2);
|
ImPlot::PlotLine("Line",data,2);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
ImPlot::LinkNextPlotLimits(linkx ? &xmin : NULL , linkx ? &xmax : NULL, linky ? &ymin : NULL, linky ? &ymax : NULL);
|
ImPlot::LinkNextPlotLimits(linkx ? &xmin : NULL , linkx ? &xmax : NULL, linky ? &ymin : NULL, linky ? &ymax : NULL);
|
||||||
if (ImPlot::BeginPlot("Plot B")) {
|
if (ImPlot::BeginPlot("Plot B")) {
|
||||||
ImPlot::PlotLine("Line",data,2);
|
ImPlot::PlotLine("Line",data,2);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -1339,7 +1339,7 @@ int BinarySearch(const T* arr, int l, int r, T x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlotCandlestick(const char* label_id, const double* xs, const double* opens, const double* closes, const double* lows, const double* highs, int count, bool tooltip, float width_percent, ImVec4 bullCol, ImVec4 bearCol) {
|
void PlotCandlestick(const char* label_id, const double* xs, const double* opens, const double* closes, const double* lows, const double* highs, int count, bool tooltip, float width_percent, ImVec4 bullCol, ImVec4 bearCol) {
|
||||||
|
|
||||||
// get ImGui window DrawList
|
// get ImGui window DrawList
|
||||||
ImDrawList* draw_list = ImPlot::GetPlotDrawList();
|
ImDrawList* draw_list = ImPlot::GetPlotDrawList();
|
||||||
// calc real value width
|
// calc real value width
|
||||||
|
|
|
@ -170,15 +170,15 @@ enum ImPlotScale_ {
|
||||||
ImPlotScale_LogLog // log x, log y
|
ImPlotScale_LogLog // log x, log y
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImPlotTimeUnit_ {
|
enum ImPlotTimeUnit_ {
|
||||||
ImPlotTimeUnit_Us, // microsecond
|
ImPlotTimeUnit_Us, // microsecond
|
||||||
ImPlotTimeUnit_Ms, // millisecond
|
ImPlotTimeUnit_Ms, // millisecond
|
||||||
ImPlotTimeUnit_S, // second
|
ImPlotTimeUnit_S, // second
|
||||||
ImPlotTimeUnit_Min, // minute
|
ImPlotTimeUnit_Min, // minute
|
||||||
ImPlotTimeUnit_Hr, // hour
|
ImPlotTimeUnit_Hr, // hour
|
||||||
ImPlotTimeUnit_Day, // day
|
ImPlotTimeUnit_Day, // day
|
||||||
ImPlotTimeUnit_Mo, // month
|
ImPlotTimeUnit_Mo, // month
|
||||||
ImPlotTimeUnit_Yr, // year
|
ImPlotTimeUnit_Yr, // year
|
||||||
ImPlotTimeUnit_COUNT
|
ImPlotTimeUnit_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -308,28 +308,28 @@ struct ImPlotAxis
|
||||||
LinkedMin = LinkedMax = NULL;
|
LinkedMin = LinkedMax = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetMin(double _min) {
|
bool SetMin(double _min) {
|
||||||
_min = ImConstrainNan(ImConstrainInf(_min));
|
_min = ImConstrainNan(ImConstrainInf(_min));
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
||||||
_min = ImConstrainLog(_min);
|
_min = ImConstrainLog(_min);
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
||||||
_min = ImConstrainTime(_min);
|
_min = ImConstrainTime(_min);
|
||||||
if (_min >= Range.Max)
|
if (_min >= Range.Max)
|
||||||
return false;
|
return false;
|
||||||
Range.Min = _min;
|
Range.Min = _min;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool SetMax(double _max) {
|
bool SetMax(double _max) {
|
||||||
_max = ImConstrainNan(ImConstrainInf(_max));
|
_max = ImConstrainNan(ImConstrainInf(_max));
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
||||||
_max = ImConstrainLog(_max);
|
_max = ImConstrainLog(_max);
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
||||||
_max = ImConstrainTime(_max);
|
_max = ImConstrainTime(_max);
|
||||||
if (_max <= Range.Min)
|
if (_max <= Range.Min)
|
||||||
return false;
|
return false;
|
||||||
Range.Max = _max;
|
Range.Max = _max;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetRange(double _min, double _max) {
|
void SetRange(double _min, double _max) {
|
||||||
|
@ -597,19 +597,19 @@ struct ImPlotTime {
|
||||||
static ImPlotTime FromDouble(double t) { return ImPlotTime((time_t)t, (int)(t * 1000000 - floor(t) * 1000000)); }
|
static ImPlotTime FromDouble(double t) { return ImPlotTime((time_t)t, (int)(t * 1000000 - floor(t) * 1000000)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline ImPlotTime operator+(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
static inline ImPlotTime operator+(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||||
{ return ImPlotTime(lhs.S + rhs.S, lhs.Us + rhs.Us); }
|
{ return ImPlotTime(lhs.S + rhs.S, lhs.Us + rhs.Us); }
|
||||||
static inline ImPlotTime operator-(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
static inline ImPlotTime operator-(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||||
{ return ImPlotTime(lhs.S - rhs.S, lhs.Us - rhs.Us); }
|
{ return ImPlotTime(lhs.S - rhs.S, lhs.Us - rhs.Us); }
|
||||||
static inline bool operator==(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
static inline bool operator==(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||||
{ return lhs.S == rhs.S && lhs.Us == rhs.Us; }
|
{ return lhs.S == rhs.S && lhs.Us == rhs.Us; }
|
||||||
static inline bool operator<(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
static inline bool operator<(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||||
{ return lhs.S == rhs.S ? lhs.Us < rhs.Us : lhs.S < rhs.S; }
|
{ return lhs.S == rhs.S ? lhs.Us < rhs.Us : lhs.S < rhs.S; }
|
||||||
static inline bool operator>(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
static inline bool operator>(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||||
{ return rhs < lhs; }
|
{ return rhs < lhs; }
|
||||||
static inline bool operator<=(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
static inline bool operator<=(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||||
{ return lhs < rhs || lhs == rhs; }
|
{ return lhs < rhs || lhs == rhs; }
|
||||||
static inline bool operator>=(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
static inline bool operator>=(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||||
{ return lhs > rhs || lhs == rhs; }
|
{ return lhs > rhs || lhs == rhs; }
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -681,7 +681,7 @@ inline bool FitThisFrame() { return GImPlot->FitThisFrame; }
|
||||||
void FitPoint(const ImPlotPoint& p);
|
void FitPoint(const ImPlotPoint& p);
|
||||||
|
|
||||||
// Returns true if two ranges overlap
|
// Returns true if two ranges overlap
|
||||||
inline bool RangesOverlap(const ImPlotRange& r1, const ImPlotRange& r2)
|
inline bool RangesOverlap(const ImPlotRange& r1, const ImPlotRange& r2)
|
||||||
{ return r1.Min <= r2.Max && r2.Min <= r1.Max; }
|
{ return r1.Min <= r2.Max && r2.Min <= r1.Max; }
|
||||||
|
|
||||||
// Updates pointers for linked axes from axis internal range.
|
// Updates pointers for linked axes from axis internal range.
|
||||||
|
@ -816,7 +816,7 @@ ImPlotTime MkLocTime(struct tm *ptm);
|
||||||
// Make a tm struct from a timestamp expressed as a local time.
|
// Make a tm struct from a timestamp expressed as a local time.
|
||||||
tm* GetLocTime(const ImPlotTime& t, tm* ptm);
|
tm* GetLocTime(const ImPlotTime& t, tm* ptm);
|
||||||
|
|
||||||
// NB: These functions only work if there is a current ImPlotContext because the
|
// NB: These functions only work if there is a current ImPlotContext because the
|
||||||
// internal tm struct is owned by the context!
|
// internal tm struct is owned by the context!
|
||||||
|
|
||||||
// Adds time to a timestamp. #count must be positive!
|
// Adds time to a timestamp. #count must be positive!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user