signals: label plots by row and cell, drop onto a cell

This commit is contained in:
Martino Ferrari committed 2026-11-03 18:04:58 +01:00
1 parent 645cb6f4fa
commit 9f3e3597af
4 files changed
+83 -7

No files matched your search

+65
View File
@@ -4259,8 +4259,73 @@ gboolean split_probe_step(gpointer user) {
cell_plus_sensitive, row_plus_sensitive, rs.row_count());
// Close editor.
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(a->layout_toggle), false);
split_probe_next(*a);
break;
}
// --- Steps 16..17: signals page and drop onto a cell (task 6) ---
case 16: {
// Two split rows (plots 0,1 on row 1; plots 2,3 on row 2), all empty; the next step reads a frame
// that was laid out with them.
rs.set_cells_per_row({2, 2});
split_probe_clear_all(*a);
split_probe_restructured(*a);
split_probe_next(*a);
break;
}
case 17: {
split_probe_report(*a, "two-split-rows");
// Which plot the pointer resolves to at the centre of every cell, through the app's own wrapper
// (`row_at(app, x, y)`), in the area's logical coordinates: the cell rects are device pixels.
const plot::FigureLayout& fl = rs.figure().layout();
const double scale = (a->area != nullptr && a->area->device_scale() > 0.0f)
? static_cast<double>(a->area->device_scale()) : 1.0;
std::string rowat;
int rowat_ok = fl.cells.size() == static_cast<std::size_t>(rs.row_count()) ? 1 : 0;
for (std::size_t i = 0; i < fl.cells.size() && rowat_ok; ++i) {
const plot::Rect& c = fl.cells[i];
const int got = row_at(*a, (static_cast<double>(c.x) + c.w * 0.5) / scale,
(static_cast<double>(c.y) + c.h * 0.5) / scale);
rowat += (i == 0 ? "" : ",") + rs.plot_label(static_cast<int>(i)) + "=" + std::to_string(got);
if (got != static_cast<int>(i)) rowat_ok = 0;
}
std::fprintf(stderr, "[split-probe] drop-rowat ok=%d rowat=[%s] (label=plot index at each cell's centre)\n",
rowat_ok, rowat.c_str());
// The signals page's "Plot on" buttons for signal 1: label and tooltip of each, read off the widgets.
const std::string sig0 = a->model->signals()[1].name;
signal_page_ensure(*a, sig0);
signal_pages_sync(*a);
std::string buttons;
const auto page_it = a->signal_pages.find(sig0);
GtkWidget* box = page_it == a->signal_pages.end() ? nullptr
: find_named(page_it->second, "udpscope-plot-on");
for (GtkWidget* b = box != nullptr ? gtk_widget_get_first_child(box) : nullptr; b != nullptr;
b = gtk_widget_get_next_sibling(b)) {
const char* tip = gtk_widget_get_tooltip_text(b);
buttons += std::string(buttons.empty() ? "" : "|") + gtk_button_get_label(GTK_BUTTON(b)) + ":" +
(tip != nullptr ? tip : "-");
}
std::fprintf(stderr, "[split-probe] plot-on-buttons [%s]\n", buttons.c_str());
// The "Plot on 1b" path: the button's own function, onto plot 1 (the right cell of row 1).
const bool assigned = assign_signal_to_row(*a, 1, 1);
std::fprintf(stderr, "[split-probe] assign-1b assigned=%d notice='%s'\n", assigned ? 1 : 0,
a->notice.c_str());
// And the drop handler itself, at the centre of cell 3 ("2b"), with signal 2's index as the payload.
GValue payload = G_VALUE_INIT;
g_value_init(&payload, G_TYPE_STRING);
g_value_set_string(&payload, "2");
const plot::Rect& c3 = fl.cells[3];
const gboolean dropped = on_drop_channel(nullptr, &payload, (static_cast<double>(c3.x) + c3.w * 0.5) / scale,
(static_cast<double>(c3.y) + c3.h * 0.5) / scale, a);
g_value_unset(&payload);
std::fprintf(stderr, "[split-probe] drop-2b dropped=%d notice='%s'\n", dropped ? 1 : 0,
a->notice.c_str());
split_probe_restructured(*a);
split_probe_next(*a);
break;
}
case 18:
split_probe_report(*a, "after-assign");
break;
default:
break;
}