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

Function PlotBarGroups

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

Source from the content-addressed store, hash-verified

2451
2452template <typename T>
2453void PlotBarGroups(const char* const label_ids[], const T* values, int item_count, int group_count, double group_size, double shift, const ImPlotSpec& spec) {
2454 IndexerIdx<T> indexer(values,item_count*group_count,spec.Offset,Stride<T>(spec));
2455 const bool horz = ImHasFlag(spec.Flags, ImPlotBarGroupsFlags_Horizontal);
2456 const bool stack = ImHasFlag(spec.Flags, ImPlotBarGroupsFlags_Stacked);
2457 ImPlotSpec spec_bars = spec;
2458 spec_bars.Flags = 0;
2459 if (stack) {
2460 SetupLock();
2461 ImPlotContext& gp = *GImPlot;
2462 gp.TempDouble1.resize(4*group_count);
2463 double* temp = gp.TempDouble1.Data;
2464 double* neg = &temp[0];
2465 double* pos = &temp[group_count];
2466 double* curr_min = &temp[group_count*2];
2467 double* curr_max = &temp[group_count*3];
2468 for (int g = 0; g < group_count*2; ++g)
2469 temp[g] = 0;
2470 if (horz) {
2471 for (int i = 0; i < item_count; ++i) {
2472 if (!IsItemHidden(label_ids[i])) {
2473 for (int g = 0; g < group_count; ++g) {
2474 double v = indexer[i*group_count+g];
2475 if (v > 0) {
2476 curr_min[g] = pos[g];
2477 curr_max[g] = curr_min[g] + v;
2478 pos[g] += v;
2479 }
2480 else {
2481 curr_max[g] = neg[g];
2482 curr_min[g] = curr_max[g] + v;
2483 neg[g] += v;
2484 }
2485 }
2486 }
2487 GetterXY<IndexerIdx<double>,IndexerLin> getter1(IndexerIdx<double>(curr_min,group_count),IndexerLin(1.0,shift),group_count);
2488 GetterXY<IndexerIdx<double>,IndexerLin> getter2(IndexerIdx<double>(curr_max,group_count),IndexerLin(1.0,shift),group_count);
2489 PlotBarsHEx(label_ids[i],getter1,getter2,group_size,spec_bars);
2490 }
2491 }
2492 else {
2493 for (int i = 0; i < item_count; ++i) {
2494 if (!IsItemHidden(label_ids[i])) {
2495 for (int g = 0; g < group_count; ++g) {
2496 double v = indexer[i*group_count+g];
2497 if (v > 0) {
2498 curr_min[g] = pos[g];
2499 curr_max[g] = curr_min[g] + v;
2500 pos[g] += v;
2501 }
2502 else {
2503 curr_max[g] = neg[g];
2504 curr_min[g] = curr_max[g] + v;
2505 neg[g] += v;
2506 }
2507 }
2508 }
2509 GetterXY<IndexerLin,IndexerIdx<double>> getter1(IndexerLin(1.0,shift),IndexerIdx<double>(curr_min,group_count),group_count);
2510 GetterXY<IndexerLin,IndexerIdx<double>> getter2(IndexerLin(1.0,shift),IndexerIdx<double>(curr_max,group_count),group_count);

Callers 2

Demo_BarGroupsFunction · 0.85
Demo_BarStacksFunction · 0.85

Calls 8

ImHasFlagFunction · 0.85
SetupLockFunction · 0.85
IsItemHiddenFunction · 0.85
IndexerLinClass · 0.85
PlotBarsHExFunction · 0.85
PlotBarsVExFunction · 0.85
PlotBarsFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected