feat(examples): drive a region through the glfw demo and verify its geometry
This commit is contained in:
1 parent
4e0e0ae0b3
commit
4681d7015b
1 file changed
+18
-14
+18
-14
@@ -512,15 +512,6 @@ int main() {
|
|||||||
p.set_cursor_snap(cursor_b, plot::SnapMode::NearestSample);
|
p.set_cursor_snap(cursor_b, plot::SnapMode::NearestSample);
|
||||||
const u32 measure = p.add_measure(cursor_a, cursor_b, trace);
|
const u32 measure = p.add_measure(cursor_a, cursor_b, trace);
|
||||||
|
|
||||||
// The region the direct-manipulation script drags and the pixels are counted from. Its
|
|
||||||
// bounds are placed by the script, once the view it is measured against has been frozen.
|
|
||||||
plot::Region region_desc;
|
|
||||||
region_desc.snap = plot::RegionSnap::Free;
|
|
||||||
region_desc.fill = kRegionFill;
|
|
||||||
region_desc.edge = kRegionEdge;
|
|
||||||
region_desc.label = "roi";
|
|
||||||
const u32 region = p.add_region(region_desc);
|
|
||||||
|
|
||||||
Meter meter;
|
Meter meter;
|
||||||
/// The scripted live-follow verification, off unless `PLOT_DEMO_FOLLOW` asks for
|
/// The scripted live-follow verification, off unless `PLOT_DEMO_FOLLOW` asks for
|
||||||
/// it. It is the same shape as the headless smoke mode above: a driven run whose
|
/// it. It is the same shape as the headless smoke mode above: a driven run whose
|
||||||
@@ -529,6 +520,17 @@ int main() {
|
|||||||
/// The scripted region sequence, off unless `PLOT_DEMO_REGIONS` asks for it. Same shape
|
/// The scripted region sequence, off unless `PLOT_DEMO_REGIONS` asks for it. Same shape
|
||||||
/// as the follow script: a driven run whose verdict is carried out in its `failed`.
|
/// as the follow script: a driven run whose verdict is carried out in its `failed`.
|
||||||
RegionScript region_script = RegionScript::from_env();
|
RegionScript region_script = RegionScript::from_env();
|
||||||
|
|
||||||
|
// The region that script drags, and the element the pixel counts are of. It exists only
|
||||||
|
// while the script is armed: the default run is the frame the four adapters copy, and an
|
||||||
|
// element nothing drives would be a change to it rather than a demonstration. The script
|
||||||
|
// places its bounds once the view it is measured against has been frozen.
|
||||||
|
plot::Region region_desc;
|
||||||
|
region_desc.snap = plot::RegionSnap::Free;
|
||||||
|
region_desc.fill = kRegionFill;
|
||||||
|
region_desc.edge = kRegionEdge;
|
||||||
|
region_desc.label = "roi";
|
||||||
|
const u32 region = region_script.enabled ? p.add_region(region_desc) : 0u;
|
||||||
// The cursors ride the live window until the user takes over: the first
|
// The cursors ride the live window until the user takes over: the first
|
||||||
// ctrl+drag on a cursor, or a pan/zoom that clears the x axis' auto scale,
|
// ctrl+drag on a cursor, or a pan/zoom that clears the x axis' auto scale,
|
||||||
// stops them where the user put them. Under `Live` the follow path owns the x
|
// stops them where the user put them. Under `Live` the follow path owns the x
|
||||||
@@ -688,14 +690,15 @@ int main() {
|
|||||||
stats.draw_calls, stats.lod_traces, stats.raw_traces);
|
stats.draw_calls, stats.lod_traces, stats.raw_traces);
|
||||||
std::printf("[glfw_demo] measurement %s dx %g s dy %g rms %g mean %g\n",
|
std::printf("[glfw_demo] measurement %s dx %g s dy %g rms %g mean %g\n",
|
||||||
m.valid ? "valid:" : "INVALID", m.dx, m.dy, m.rms, m.mean);
|
m.valid ? "valid:" : "INVALID", m.dx, m.dy, m.rms, m.mean);
|
||||||
std::printf("[glfw_demo] region x [%g, %g] s, snap %s, %s; checks %s\n",
|
if (region_script.enabled) {
|
||||||
|
std::printf("[glfw_demo] region %u: x [%g, %g] s, snap %s, %s; checks %s\n", region,
|
||||||
p.region(region).x0, p.region(region).x1,
|
p.region(region).x0, p.region(region).x1,
|
||||||
p.region(region).snap == plot::RegionSnap::Free ? "free" : "nearest sample",
|
p.region(region).snap == plot::RegionSnap::Free ? "free" : "nearest sample",
|
||||||
region_script.enabled ? (region_script.hover ? "bound hovered at exit" : "pointer off the data area at exit") : "not driven",
|
region_script.hover ? "bound hovered at exit" : "pointer off the data area at exit",
|
||||||
region_script.enabled ? (region_script.failed ? "FAILED" : "passed") : "-");
|
region_script.failed ? "FAILED" : "passed");
|
||||||
if (const plot::RegionLayout* rl = region_layout(p, region); rl != nullptr) {
|
if (const plot::RegionLayout* rl = region_layout(p, region); rl != nullptr) {
|
||||||
// The last frame's geometry, as the layout measured it: the rects the fills, bounds
|
// The last frame's geometry, as the layout measured it: the rect the fill, the bound
|
||||||
// and pixel counts all have to agree with.
|
// strokes and the pixel counts all have to agree with.
|
||||||
std::printf("[glfw_demo] region fill x %.1f y %.1f w %.1f h %.1f, bounds at %.1f and"
|
std::printf("[glfw_demo] region fill x %.1f y %.1f w %.1f h %.1f, bounds at %.1f and"
|
||||||
" %.1f, tab w %.1f, label w %.1f\n",
|
" %.1f, tab w %.1f, label w %.1f\n",
|
||||||
rl->fill.x, rl->fill.y, rl->fill.w, rl->fill.h,
|
rl->fill.x, rl->fill.y, rl->fill.w, rl->fill.h,
|
||||||
@@ -703,6 +706,7 @@ int main() {
|
|||||||
static_cast<plot::f64>(plot::handle_column(rl->right_handle)),
|
static_cast<plot::f64>(plot::handle_column(rl->right_handle)),
|
||||||
rl->left_handle.w, rl->label.w);
|
rl->left_handle.w, rl->label.w);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
std::printf("[glfw_demo] upload path %s, gl error on the last frame %d\n",
|
std::printf("[glfw_demo] upload path %s, gl error on the last frame %d\n",
|
||||||
r != nullptr && r->using_persistent_upload() ? "persistent-mapped ring" : "orphan",
|
r != nullptr && r->using_persistent_upload() ? "persistent-mapped ring" : "orphan",
|
||||||
r != nullptr && r->last_frame_had_gl_error() ? 1 : 0);
|
r != nullptr && r->last_frame_had_gl_error() ? 1 : 0);
|
||||||
|
|||||||
Reference in new issue
Block a user