MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / PlotDigitalEx

Function PlotDigitalEx

Source/3rdParty/implot/implot_items.cpp:3364–3420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3362
3363template <typename Getter>
3364void PlotDigitalEx(const char* label_id, Getter getter, const ImPlotSpec& spec) {
3365 if (BeginItem(label_id, spec, spec.FillColor)) {
3366 ImPlotContext& gp = *GImPlot;
3367 ImDrawList& draw_list = *GetPlotDrawList();
3368 const ImPlotNextItemData& s = GetItemData();
3369 if (getter.Count > 1 && s.RenderFill) {
3370 ImPlotPlot& plot = *gp.CurrentPlot;
3371 ImPlotAxis& x_axis = plot.Axes[plot.CurrentX];
3372 ImPlotAxis& y_axis = plot.Axes[plot.CurrentY];
3373
3374 int pixYMax = 0;
3375 ImPlotPoint itemData1 = getter[0];
3376 for (int i = 0; i < getter.Count; ++i) {
3377 ImPlotPoint itemData2 = getter[i];
3378 if (ImNanOrInf(itemData1.y)) {
3379 itemData1 = itemData2;
3380 continue;
3381 }
3382 if (ImNanOrInf(itemData2.y)) {
3383 itemData2.y = ImConstrainNan(ImConstrainInf(itemData2.y));
3384 }
3385 int pixY_0 = (int)(s.Spec.LineWeight);
3386 itemData1.y = ImMax(0.0, itemData1.y);
3387 const float pixY_1 = s.Spec.Size * (float)itemData1.y;
3388 const int pixY_chPosOffset = (int)(ImMax(s.Spec.Size, pixY_1) + gp.Style.DigitalSpacing);
3389 pixYMax = ImMax(pixYMax, pixY_chPosOffset);
3390 ImVec2 pMin = PlotToPixels(itemData1,IMPLOT_AUTO,IMPLOT_AUTO);
3391 ImVec2 pMax = PlotToPixels(itemData2,IMPLOT_AUTO,IMPLOT_AUTO);
3392 const int pixY_Offset = (int)gp.Style.DigitalPadding;
3393 const float y_ref = y_axis.IsInverted() ? y_axis.PixelMax : y_axis.PixelMin;
3394 pMin.y = y_ref - (gp.DigitalPlotOffset + pixY_Offset);
3395 pMax.y = y_ref - (gp.DigitalPlotOffset + pixY_0 + (int)pixY_1 + pixY_Offset);
3396 //plot only one rectangle for same digital state
3397 while (((i+2) < getter.Count) && (itemData1.y == itemData2.y)) {
3398 const int in = (i + 1);
3399 itemData2 = getter[in];
3400 if (ImNanOrInf(itemData2.y)) break;
3401 pMax.x = PlotToPixels(itemData2,IMPLOT_AUTO,IMPLOT_AUTO).x;
3402 i++;
3403 }
3404 // do not extend plot outside plot range
3405 pMin.x = ImClamp(pMin.x, !x_axis.IsInverted() ? x_axis.PixelMin : x_axis.PixelMax, !x_axis.IsInverted() ? x_axis.PixelMax - 1 : x_axis.PixelMin - 1);
3406 pMax.x = ImClamp(pMax.x, !x_axis.IsInverted() ? x_axis.PixelMin : x_axis.PixelMax, !x_axis.IsInverted() ? x_axis.PixelMax - 1 : x_axis.PixelMin - 1);
3407 //plot a rectangle that extends up to x2 with y1 height
3408 if ((gp.CurrentPlot->PlotRect.Contains(pMin) || gp.CurrentPlot->PlotRect.Contains(pMax))) {
3409 // ImVec4 colAlpha = item->Color;
3410 // colAlpha.w = item->Highlight ? 1.0f : 0.9f;
3411 draw_list.AddRectFilled(pMin, pMax, ImGui::GetColorU32(s.Spec.FillColor));
3412 }
3413 itemData1 = itemData2;
3414 }
3415 gp.DigitalPlotItemCnt++;
3416 gp.DigitalPlotOffset += pixYMax;
3417 }
3418 EndItem();
3419 }
3420}
3421

Callers 2

PlotDigitalFunction · 0.85
PlotDigitalGFunction · 0.85

Calls 12

BeginItemFunction · 0.85
GetPlotDrawListFunction · 0.85
ImNanOrInfFunction · 0.85
ImConstrainNanFunction · 0.85
ImConstrainInfFunction · 0.85
ImMaxFunction · 0.85
PlotToPixelsFunction · 0.85
ImClampFunction · 0.85
EndItemFunction · 0.85
IsInvertedMethod · 0.80
AddRectFilledMethod · 0.80
ContainsMethod · 0.45

Tested by

no test coverage detected