Skip to content

Commit 77c8748

Browse files
committed
DPL: make input slots display in DebugGUI scrollable
1 parent 0cdfe91 commit 77c8748

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#include "Framework/DataProcessingStates.h"
1818
#include "InspectorHelpers.h"
1919
#include "PaletteHelpers.h"
20-
#include "Framework/Logger.h"
21-
#include <iostream>
20+
#include "FrameworkGUIDataRelayerUsage.h"
2221
#include <cstring>
2322
#include <cmath>
2423

@@ -27,11 +26,11 @@ static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return Im
2726

2827
namespace o2::framework::gui
2928
{
30-
3129
// This is to display the information in the data relayer
3230
struct HeatMapHelper {
3331
template <typename RECORD, typename ITEM>
34-
static void draw(const char* name,
32+
static void draw(const char* /*name*/,
33+
int& v,
3534
ImVec2 const& sizeHint,
3635
std::function<size_t()> const& getNumInputs,
3736
std::function<size_t()> const& getNumRecords,
@@ -49,14 +48,14 @@ struct HeatMapHelper {
4948
constexpr float MAX_BOX_Y_SIZE = 16.f;
5049
ImDrawList* drawList = ImGui::GetWindowDrawList();
5150
ImVec2 winPos = ImGui::GetCursorScreenPos() + ImVec2{0, 7};
52-
auto records = getNumRecords();
53-
auto boxSizeX = std::min(size.x / records, MAX_BOX_X_SIZE);
51+
size_t recordsWindow = v + WND;
52+
auto boxSizeX = std::min(size.x / WND, MAX_BOX_X_SIZE);
5453
auto numInputs = getNumInputs();
5554

5655
ImGui::InvisibleButton("sensible area", ImVec2(size.x, size.y));
5756
if (ImGui::IsItemHovered()) {
5857
auto pos = ImGui::GetMousePos() - winPos;
59-
auto slot = std::lround(std::trunc(pos.x / size.x * records));
58+
auto slot = v + std::lround(std::trunc(pos.x / size.x * WND));
6059
auto row = std::lround(std::trunc(pos.y / size.y * numInputs));
6160
describeCell(row, slot);
6261
}
@@ -72,18 +71,19 @@ struct HeatMapHelper {
7271
float padding = 1;
7372

7473
size_t totalRects = 0;
75-
for (size_t ri = 0, re = getNumRecords(); ri < re; ri++) {
74+
for (size_t ri = v; ri < recordsWindow; ri++) {
7675
auto record = getRecord(ri);
7776
totalRects += getNumItems(record);
7877
}
7978

8079
drawList->PrimReserve(totalRects * 6, totalRects * 4);
81-
for (size_t ri = 0, re = getNumRecords(); ri < re; ri++) {
80+
for (size_t ri = v; ri < recordsWindow; ri++) {
8281
auto record = getRecord(ri);
83-
ImVec2 xOffset{(ri * boxSizeX) + padding, 0};
82+
ImVec2 xOffset{((ri - v) * boxSizeX) + padding, 0};
8483
ImVec2 xSize{boxSizeX - 2 * padding, 0};
85-
auto boxSizeY = std::min(size.y / getNumItems(record), MAX_BOX_Y_SIZE);
86-
for (size_t mi = 0, me = getNumItems(record); mi < me; mi++) {
84+
auto me = getNumItems(record);
85+
auto boxSizeY = std::min(size.y / me, MAX_BOX_Y_SIZE);
86+
for (size_t mi = 0; mi < me; mi++) {
8787
ImVec2 yOffSet{0, (mi * boxSizeY) + padding};
8888
ImVec2 ySize{0, boxSizeY - 2 * padding};
8989

@@ -98,11 +98,12 @@ struct HeatMapHelper {
9898
}
9999
};
100100

101-
void displayDataRelayer(DeviceMetricsInfo const& metrics,
102-
DeviceInfo const& info,
101+
void displayDataRelayer(DeviceMetricsInfo const& /*metrics*/,
102+
DeviceInfo const& /*info*/,
103103
DeviceSpec const& spec,
104104
DataProcessingStates const& states,
105-
ImVec2 const& size)
105+
ImVec2 const& size,
106+
int& v)
106107
{
107108
auto getNumInputs = [&states]() -> size_t {
108109
auto& inputsView = states.statesViews[(int)ProcessingStateId::DATA_QUERIES];
@@ -146,7 +147,7 @@ void displayDataRelayer(DeviceMetricsInfo const& metrics,
146147
}
147148
char const* const beginData = strchr(buffer + view.first, ' ') + 1;
148149
// Protect against buffer overflows
149-
if (view.size <= beginData - buffer + i - view.first) {
150+
if ((size_t)view.size <= beginData - buffer + i - view.first) {
150151
return &error;
151152
}
152153
return (int8_t const*)beginData + i; };
@@ -184,7 +185,7 @@ void displayDataRelayer(DeviceMetricsInfo const& metrics,
184185
if ((end - input) == 0) {
185186
continue;
186187
}
187-
if (i == row) {
188+
if (i == (size_t)row) {
188189
ImGui::Text("%d %.*s (%s)", row, int(end - input), input, InspectorHelpers::getLifeTimeStr(spec.inputs[i].matcher.lifetime).c_str());
189190
break;
190191
}
@@ -226,6 +227,7 @@ void displayDataRelayer(DeviceMetricsInfo const& metrics,
226227

227228
if (getNumRecords()) {
228229
HeatMapHelper::draw<int, int8_t>("DataRelayer",
230+
v,
229231
size,
230232
getNumInputs,
231233
getNumRecords,

Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12+
#include "Framework/DeviceSpec.h"
1213
class ImVec2;
1314

1415
namespace o2::framework
@@ -19,9 +20,9 @@ class DataProcessingStates;
1920

2021
namespace gui
2122
{
22-
23+
static constexpr int WND = 16;
2324
/// View of the DataRelayer metrics for a given DeviceInfo
24-
void displayDataRelayer(DeviceMetricsInfo const& metrics, DeviceInfo const& info, DeviceSpec const& spec, DataProcessingStates const&, ImVec2 const& size);
25+
void displayDataRelayer(DeviceMetricsInfo const& metrics, DeviceInfo const& info, DeviceSpec const& spec, DataProcessingStates const&, ImVec2 const& size, int& v);
2526

2627
} // namespace gui
2728
} // namespace o2::framework

Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,21 @@ void showTopologyNodeGraph(WorkspaceGUIState& state,
713713
default:
714714
break;
715715
}
716-
gui::displayDataRelayer(metricsInfos[node->ID], infos[node->ID], specs[node->ID], allStates[node->ID], ImVec2(140., 90.));
716+
static int v = 0;
717+
auto records = [states = allStates[node->ID]]() -> size_t {
718+
auto& view = states.statesViews[(int)ProcessingStateId::DATA_RELAYER_BASE];
719+
if (view.size == 0) {
720+
return 0;
721+
}
722+
// The first number is the size of the pipeline
723+
int numRecords = strtoul(states.statesBuffer.data() + view.first, nullptr, 10);
724+
return numRecords;
725+
}();
726+
if (records > 0) {
727+
ImGui::PushItemWidth(140);
728+
ImGui::SliderInt("##window", &v, 0, records - gui::WND, "start: %d", ImGuiSliderFlags_AlwaysClamp);
729+
}
730+
gui::displayDataRelayer(metricsInfos[node->ID], infos[node->ID], specs[node->ID], allStates[node->ID], ImVec2(140., 90.), v);
717731
ImGui::EndGroup();
718732

719733
// Save the size of what we have emitted and whether any of the widgets are being used

0 commit comments

Comments
 (0)