bf94893032
Cuando una funcion del registry parte su .cpp en varios TUs por testabilidad o separacion ImGui-vs-puro, cada TU adicional se registra como entrada propia con su .md en lugar de extender file_path para listar varios archivos. Aplicado a: - graph_labels_select_cpp_viz: helpers puros (compute_degrees + labels_select). - graph_viewport_selection_cpp_viz: clear/add/toggle/is_selected puros. - graph_types_cpp_viz: TU de update_bounds + find_node_by_user_data. graph_labels y graph_viewport actualizados para declarar las nuevas entradas en uses_functions. Razon detallada en docs/adr/0003 + regla actualizada en .claude/rules/uses_functions.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.5 KiB
3.5 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path, framework, params, output, notes
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | tested | tests | test_file_path | file_path | framework | params | output | notes | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| graph_viewport_selection | function | cpp | viz | 1.0.0 | pure | void graph_viewport_clear_selection(GraphData& graph, GraphViewportState& state); bool graph_viewport_is_selected(const GraphViewportState& state, int node_idx); void graph_viewport_add_to_selection(GraphData& graph, GraphViewportState& state, int node_idx); void graph_viewport_toggle_selection(GraphData& graph, GraphViewportState& state, int node_idx) | Helpers puros (sin ImGui ni OpenGL) para gestionar la multi-seleccion del viewport: clear, add, toggle, is_selected. Mantienen sincronizados state.selection (vector de indices) y nodes[i].flags (NF_SELECTED bit), ademas de state.selected_node como ultimo focus. |
|
|
false | true |
|
cpp/tests/test_graph_viewport.cpp | cpp/functions/viz/graph_viewport_selection.cpp | imgui |
|
graph_viewport_is_selected: bool (true si el indice esta en state.selection). El resto: void. selected_node se actualiza al ultimo indice añadido, o al ultimo de la lista al togglear, o -1 si la lista queda vacia. | Issue 0049i. TU separado de graph_viewport.cpp para que los tests unitarios cubran la maquinaria de seleccion sin abrir ventana ImGui. Operaciones idempotentes: añadir un indice ya seleccionado es no-op; togglear lo elimina. Las apps que necesiten seleccion programatica (ej: 'select all of type X') deben usar estas funciones en lugar de tocar state.selection a mano. |
graph_viewport_selection
Helpers puros para multi-seleccion en graph_viewport. Viven en su propio TU
para que los tests unitarios puedan verificar invariantes (clear deja todo a
NF_SELECTED=0, toggle es involutivo, etc.) sin abrir ventana ImGui.
API
void graph_viewport_clear_selection (GraphData& graph, GraphViewportState& state);
bool graph_viewport_is_selected (const GraphViewportState& state, int node_idx);
void graph_viewport_add_to_selection(GraphData& graph, GraphViewportState& state, int node_idx);
void graph_viewport_toggle_selection(GraphData& graph, GraphViewportState& state, int node_idx);
Invariantes
state.selectionynodes[i].flags & NF_SELECTEDsiempre coherentes — no modificar uno sin el otro. Estas funciones lo garantizan.state.selected_nodees el "ultimo focus": el ultimo añadido o, al togglear fuera, el ultimo de la lista;-1si la lista esta vacia.- Indices fuera de rango son no-op (no escriben memoria, no añaden basura).
Composabilidad
graph_viewport los usa internamente al click/Ctrl+click/Esc. Apps externas
los usan para seleccion programatica:
// Seleccionar todos los nodos de tipo Person
graph_viewport_clear_selection(g, state);
for (int i = 0; i < g.node_count; ++i) {
if (g.nodes[i].type_id == person_type_id) {
graph_viewport_add_to_selection(g, state, i);
}
}
Tests
Cubiertos en cpp/tests/test_graph_viewport.cpp — cubren add/clear/toggle/
is_selected y out-of-range.