feat(viz): graph_layouts (radial/hierarchical/fixed) + viewport multi-select+lasso (issue 0049i)

Phase 1 — graph_layouts:
- New module cpp/functions/viz/graph_layouts.{h,cpp,md} v1.0.0
- layout_grid, layout_circular, layout_random (migrated from graph_force_layout.cpp)
- layout_radial: BFS rings from root, hop k -> circle of radius k*ring_spacing
- layout_hierarchical: Sugiyama-style heuristic (longest-path levels + barycenter ordering)
- layout_fixed: no-op
- All respect NF_PINNED. graph_layout_circular/grid kept as deprecated wrappers.

Phase 2-3 — graph_viewport v1.2.0:
- Multi-selection via state.selection (vector<int>); NF_SELECTED kept in sync
- Lasso: Shift+Drag on empty area; AABB hit-test on release
- Drag of N-selection: all selected pinned + moved by mouse delta
- Ctrl+click toggle, Esc clears selection
- Right-click on node -> on_context_menu callback
- Double-click on node -> on_double_click callback
- Helpers exposed: graph_viewport_clear/add_to/toggle/is_selected (own TU for tests)

Phase 4 — tests:
- test_graph_layouts: 12 cases / 364 assertions covering geometry, pin, edges
- test_graph_viewport: 5 cases for selection helpers (pure logic, no GL)

Phase 5 — demo (primitives_gallery):
- Layout combo (force/grid/circular/radial/hierarchical/fixed) + Apply button
- Right-click popup with Pin/Unpin/Add-to-selection
- Status overlay shows [N selected] when selection non-empty
- Updated golden images

Issue moved to dev/issues/completed/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-29 23:42:31 +02:00
parent d09b35b533
commit 4a0750445c
24 changed files with 1187 additions and 92 deletions
+17
View File
@@ -64,6 +64,7 @@ add_fn_test(test_icon_button test_icon_button.cpp)
add_fn_test(test_graph_pack_rgba8 test_graph_pack_rgba8.cpp)
add_fn_test(test_graph_should_pause test_graph_should_pause.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_force_layout.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_layouts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_types.cpp)
# --- Issue 0049d — vertex pulling edge buffer (logica solo, sin GL) --------
@@ -80,6 +81,21 @@ add_fn_test(test_graph_sources test_graph_sources.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_types.cpp)
target_link_libraries(test_graph_sources PRIVATE SQLite::SQLite3)
# --- Issue 0049i — graph_layouts (radial / hierarchical / fixed / etc) -----
add_fn_test(test_graph_layouts test_graph_layouts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_layouts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_types.cpp)
# --- Issue 0049i — graph_viewport selection helpers (logica pura sin GL) ---
# Solo cubre graph_viewport_selection.cpp; el widget completo se prueba en
# primitives_gallery + golden image diff. graph_viewport.h incluye ImVec2,
# por eso anadimos cpp/vendor/imgui al include path.
add_fn_test(test_graph_viewport test_graph_viewport.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_viewport_selection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_types.cpp)
target_include_directories(test_graph_viewport PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../vendor/imgui)
# --- Issue 0049h — graph_force_layout_gpu (compute + spatial hash) ----------
# El test crea una ventana GLFW oculta a 4.3 core; si glfwInit/window/context
# fallan (CI sin DISPLAY, Mesa sin compute), el test SKIPea. Linkamos contra
@@ -87,6 +103,7 @@ target_link_libraries(test_graph_sources PRIVATE SQLite::SQLite3)
add_fn_test(test_graph_force_layout_gpu test_graph_force_layout_gpu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_force_layout_gpu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_force_layout.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_layouts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/viz/graph_types.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../functions/gfx/gl_loader.cpp)
if(WIN32)