fix(viz): forzar circulo a todos los nodos salvo Table; tapar energia inicial

- types_registry.cpp::apply_types_yaml: tras aplicar el yaml, sobreescribe
  shape de cada tipo: 'Table' → SHAPE_SQUARE, todo lo demas → SHAPE_CIRCLE.
  Convencion fija — ediciones futuras del Type Editor (issue 0007) o del
  yaml no rompen la regla.
- examples/types.yaml + project_manager.cpp seed: quitar campo `shape`,
  añadir tipo Table (cuadrado) y relacion CONTAINS_ROW (preview de 0010).
- main.cpp run_force_step: damping=0.7, max_velocity=8 explicitos para
  evitar que el grafo "explote" al cargar grafos pequenos.
- AppState repulsion: 1500 → 800 (lo mismo, aplicado al force layout).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-30 23:53:21 +02:00
parent 58e835cea6
commit f0148ac368
5 changed files with 50 additions and 25 deletions
+14 -11
View File
@@ -1,60 +1,58 @@
# Ejemplo OSINT — tipos comunes en investigacion de entidades. # Ejemplo OSINT — tipos comunes en investigacion de entidades.
# Color como "#RRGGBB" (con o sin alpha "#RRGGBBAA"). # Color como "#RRGGBB" (con o sin alpha "#RRGGBBAA").
# Shapes: circle | square | diamond | hex | triangle | rounded_square # Shapes: el campo `shape` se ignora — todos los nodos son circulo, salvo
# el tipo "Table" que es cuadrado (regla de forma aplicada en
# types_registry.cpp::apply_types_yaml).
# Iconos: nombres ti-* mapeados en types_registry.cpp::tabler_codepoint_by_name # Iconos: nombres ti-* mapeados en types_registry.cpp::tabler_codepoint_by_name
# Estilos de relacion: solid | dashed | dotted # Estilos de relacion: solid | dashed | dotted
entities: entities:
- name: Person - name: Person
color: "#5B8DEF" color: "#5B8DEF"
shape: circle
icon: ti-user icon: ti-user
- name: Email - name: Email
color: "#58CA8C" color: "#58CA8C"
shape: square
icon: ti-mail icon: ti-mail
- name: Domain - name: Domain
color: "#F4B860" color: "#F4B860"
shape: diamond
icon: ti-world icon: ti-world
- name: Phone - name: Phone
color: "#E36AC0" color: "#E36AC0"
shape: hex
icon: ti-phone icon: ti-phone
- name: Org - name: Org
color: "#C780E8" color: "#C780E8"
shape: triangle
icon: ti-building icon: ti-building
- name: IBAN - name: IBAN
color: "#52CDF2" color: "#52CDF2"
shape: rounded_square
icon: ti-building-bank icon: ti-building-bank
- name: Account - name: Account
color: "#7FD3A0" color: "#7FD3A0"
shape: rounded_square
icon: ti-id icon: ti-id
- name: Document - name: Document
color: "#C9C9C9" color: "#C9C9C9"
shape: square
icon: ti-file icon: ti-file
- name: Address - name: Address
color: "#FFB870" color: "#FFB870"
shape: diamond
icon: ti-map-pin icon: ti-map-pin
- name: Url - name: Url
color: "#89E0FC" color: "#89E0FC"
shape: hex
icon: ti-link icon: ti-link
# Nodo tabla — cuadrado (regla de forma). Issue 0010: contenedor con
# filas que son nodos del grafo.
- name: Table
color: "#0EA5E9"
icon: ti-database
relations: relations:
- name: owns - name: owns
color: "#888888" color: "#888888"
@@ -75,3 +73,8 @@ relations:
- name: member_of - name: member_of
color: "#C780E8" color: "#C780E8"
style: dashed style: dashed
# Pertenencia de fila a tabla (issue 0010).
- name: CONTAINS_ROW
color: "#0EA5E9"
style: dotted
+10 -4
View File
@@ -251,10 +251,16 @@ static void run_force_step() {
if (g_app.layout_mode != 0) return; // force solo en mode 0 if (g_app.layout_mode != 0) return; // force solo en mode 0
ForceLayoutConfig cfg; ForceLayoutConfig cfg;
cfg.repulsion = g_app.repulsion; cfg.repulsion = g_app.repulsion;
cfg.attraction = g_app.attraction; cfg.attraction = g_app.attraction;
cfg.gravity = g_app.gravity; cfg.gravity = g_app.gravity;
cfg.iterations = 1; cfg.iterations = 1;
// Tapa de energia: damping mas agresivo + max_velocity bajo evita que el
// grafo "explote" al cargar (nodos que arrancan cerca del origen y se
// dispersan con repulsion alta). Valores tuneados para sentir movimiento
// suave sin saltos visibles entre frames.
cfg.damping = 0.7f;
cfg.max_velocity = 8.0f;
if (g_app.use_gpu) { if (g_app.use_gpu) {
if (!g_gpu_ctx) { if (!g_gpu_ctx) {
+10 -8
View File
@@ -125,42 +125,40 @@ CREATE TABLE IF NOT EXISTS logs (
// Semilla types.yaml minima si examples/types.yaml no se encuentra. // Semilla types.yaml minima si examples/types.yaml no se encuentra.
static const char* k_seed_types_yaml = R"YAML(# types.yaml — generado al crear el proyecto. Editable desde el Type Editor. static const char* k_seed_types_yaml = R"YAML(# types.yaml — generado al crear el proyecto. Editable desde el Type Editor.
# Color como "#RRGGBB" (con o sin alpha "#RRGGBBAA"). # Todos los nodos son circulo, salvo "Table" que es cuadrado.
# Shapes: circle | square | diamond | hex | triangle | rounded_square
# Iconos: nombres ti-* mapeados en types_registry.cpp # Iconos: nombres ti-* mapeados en types_registry.cpp
# Estilos de relacion: solid | dashed | dotted # Estilos de relacion: solid | dashed | dotted
entities: entities:
- name: Person - name: Person
color: "#5B8DEF" color: "#5B8DEF"
shape: circle
icon: ti-user icon: ti-user
- name: Email - name: Email
color: "#58CA8C" color: "#58CA8C"
shape: square
icon: ti-mail icon: ti-mail
- name: Domain - name: Domain
color: "#F4B860" color: "#F4B860"
shape: diamond
icon: ti-world icon: ti-world
- name: Phone - name: Phone
color: "#E36AC0" color: "#E36AC0"
shape: hex
icon: ti-phone icon: ti-phone
- name: Org - name: Org
color: "#C780E8" color: "#C780E8"
shape: triangle
icon: ti-building icon: ti-building
- name: Document - name: Document
color: "#C9C9C9" color: "#C9C9C9"
shape: square
icon: ti-file icon: ti-file
# Nodo tabla — cuadrado (issue 0010).
- name: Table
color: "#0EA5E9"
icon: ti-database
relations: relations:
- name: owns - name: owns
color: "#888888" color: "#888888"
@@ -173,6 +171,10 @@ relations:
- name: located_in - name: located_in
color: "#FFB870" color: "#FFB870"
style: dashed style: dashed
- name: CONTAINS_ROW
color: "#0EA5E9"
style: dotted
)YAML"; )YAML";
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
+11
View File
@@ -320,6 +320,17 @@ std::vector<uint16_t> apply_types_yaml(GraphData& graph, const ParsedTypes& type
} }
} }
// Regla de forma: todo nodo es circulo EXCEPTO el tipo "Table" (issue
// 0010 — nodo tabla rectangular contenedor). Sobreescribe lo que diga el
// yaml: se aplica en cada reload, por lo que ediciones futuras desde el
// Type Editor no rompen la convencion.
for (int i = 0; i < graph.type_count; ++i) {
EntityType& et = graph.types[i];
bool is_table = et.name && (eq_ci(et.name, std::string("Table"))
|| eq_ci(et.name, std::string("table")));
et.shape = is_table ? SHAPE_SQUARE : SHAPE_CIRCLE;
}
for (int i = 0; i < graph.rel_type_count; ++i) { for (int i = 0; i < graph.rel_type_count; ++i) {
RelationType& rt = graph.rel_types[i]; RelationType& rt = graph.rel_types[i];
for (const auto& spec : types.relations) { for (const auto& spec : types.relations) {
+5 -2
View File
@@ -21,8 +21,11 @@ struct AppState {
int apply_layout_tick = 0; // se incrementa cuando hay que reaplicar layout int apply_layout_tick = 0; // se incrementa cuando hay que reaplicar layout
bool want_unpin_all = false; // Reset layout: limpia NF_PINNED y reaplica bool want_unpin_all = false; // Reset layout: limpia NF_PINNED y reaplica
// Force layout — config + GPU toggle // Force layout — config + GPU toggle. Repulsion bajada de 1500→800
float repulsion = 1500.0f; // (issue 0006 follow-up) para evitar movimiento excesivo al cargar
// grafos pequenos. Combinado con damping=0.7 y max_velocity=8 en
// run_force_step.
float repulsion = 800.0f;
float attraction = 0.04f; float attraction = 0.04f;
float gravity = 0.005f; float gravity = 0.005f;
bool use_gpu = false; bool use_gpu = false;