Files
Martino Ferrari 942f88c568 feat(examples): a three-row synced Figure demo, on a GLFW host that draws one
The multi-plot example the phase exists for: three plots stacked in one
Figure, sharing one x link with following armed, each row carrying its own
named signals and its own legend, driven by six StreamSeries at 500 kS/s.
Two cursors and a region with an exact statistics readout reach the direct
manipulation of spec §5 in the same frame, and PLOT_DEMO_SYNC=1 is a
self-checking mode that exits non-zero unless all three rows hold one range
and the shared right edge keeps tracking the newest sample through a zoom, a
pan on another row and more arriving data.

The GLFW host gains the figure mode the demo needs: set_figure() makes the
run loop draw the Figure instead of its own plot and route each pointer,
wheel and key event to the row it lands in, through one Controller per row
(row_controller()). All of it is opt-in; the single-plot path is untouched.
2026-09-28 15:24:22 +02:00

52 lines
2.2 KiB
CMake

# The example programs. Each one is guarded by the adapter it needs, so
# -DPLOT_BUILD_EXAMPLES=ON without -DPLOT_BUILD_GLFW=ON is a no-op rather than a
# configure error.
find_package(Threads REQUIRED) # the GLFW demo's producer thread
if(TARGET plot::glfw)
add_executable(plot_glfw_demo glfw_demo.cpp)
target_link_libraries(plot_glfw_demo PRIVATE plot::glfw Threads::Threads)
plot_apply_warnings(plot_glfw_demo)
endif()
if(TARGET plot::glfw)
# The multi-plot example: a three-row `Figure` sharing one x axis. It needs the GLFW
# host's figure mode (the host draws the figure and routes each row's gestures), so it
# is guarded by the same target as the single-plot demo above; its producer thread is
# the only extra dependency.
add_executable(plot_multiplot_demo multiplot_demo.cpp)
target_link_libraries(plot_multiplot_demo PRIVATE plot::glfw Threads::Threads)
plot_apply_warnings(plot_multiplot_demo)
endif()
if(TARGET plot::imgui)
# The demo owns the window, the ImGui context and the frame loop itself, so it
# links the toolkit and its backends directly; the adapter is only the widget.
plot_find_glfw(plot_imgui_demo_glfw_dep)
add_executable(plot_imgui_demo imgui_demo.cpp)
target_link_libraries(plot_imgui_demo PRIVATE
plot::imgui
imgui
${plot_imgui_demo_glfw_dep}
Threads::Threads)
plot_apply_warnings(plot_imgui_demo)
endif()
if(TARGET plot::qt6)
# The demo owns the QApplication, the QMainWindow and the toolbar; the adapter is
# only the widget, which the window adopts as its central widget. No macro
# processing is needed here: the demo declares no Qt class of its own.
add_executable(plot_qt_demo qt_demo.cpp)
target_link_libraries(plot_qt_demo PRIVATE plot::qt6 Threads::Threads)
plot_apply_warnings(plot_qt_demo)
endif()
if(TARGET plot::gtk4)
# The demo owns the GtkApplication, the window and the header bar; the adapter is
# only the plot area, which the window adopts as its content. GTK's include
# directories come with plot::gtk4 (see the adapter's CMakeLists).
add_executable(plot_gtk_demo gtk_demo.cpp)
target_link_libraries(plot_gtk_demo PRIVATE plot::gtk4 Threads::Threads)
plot_apply_warnings(plot_gtk_demo)
endif()