feat(tahuantinsuyu): fase 10 — Sinastría como overlay (bi-wheel con carta hermana)
Quinto módulo overlay. Cuando hay otra carta hermana del mismo
contacto, la sinastría pone las posiciones del partner en el outer
ring + dibuja cross aspects entre las dos personas. Mismo molde que
los overlays anteriores; única novedad: el PipelineRequest transporta
una `Chart` completa porque el partner no es derivable de la natal.
- engine: PipelineRequest::Synastry { partner_chart: Box<Chart> }.
build_synastry_overlay(natal, partner_chart, render) llama
compute_natal_chart sobre el partner y find_synastry_aspects entre
los dos NatalCharts (sólo majors). Layers con module_id="synastry"
y z=10/11. Reusa la helper compute_natal_chart de fase 5.
- modules: synastry::SynastryModule (id "synastry", toggle "Activar"
sin hotkey por ahora). Registry agrega el quinto built-in. Test
pasó a 5 módulos aplicables a ChartKind::Natal.
- shell: build_requests detecta synastry.enabled y llama
find_synastry_partner — busca la primera carta hermana del contacto
actual (mismo contact_id, distinto chart_id). Si no hay hermana,
skip silencioso. Mutual exclusion: al prender transit o synastry
se apaga el otro automáticamente (comparten outer ring) — sincroniza
el toggle del panel + el layer_visibility del canvas.
- canvas: Radii::aspect_endpoints("synastry") devuelve (bodies,
transits) — same slot que transit. Loops del outer ring aceptan
module_id "transit" OR "synastry" (paint_wheel + glyph overlay).
Sin radii nuevo — visualmente comparten el ring 0.82 con transit.
Para probarlo: creá dos cartas en el mismo contacto (ej. el sujeto +
su pareja). Abrí la primera y activá "Sinastría" en el panel. Verás
los planetas del partner en el outer ring + líneas que cruzan al
centro mostrando los aspectos entre las dos personas. Si tenés
transit prendido cuando lo activás, se apaga; al revés también.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -206,9 +206,25 @@ impl Shell {
|
||||
target_age_years: age,
|
||||
});
|
||||
}
|
||||
if module_enabled(&self.module_configs, "synastry") {
|
||||
if let Some(partner) = self.find_synastry_partner() {
|
||||
requests.push(PipelineRequest::Synastry {
|
||||
partner_chart: Box::new(partner),
|
||||
});
|
||||
}
|
||||
}
|
||||
requests
|
||||
}
|
||||
|
||||
/// Encuentra una carta hermana del contacto actual (cualquier otra
|
||||
/// carta con el mismo `contact_id` ≠ self). `None` si no hay
|
||||
/// hermana — el shell salta el request silenciosamente.
|
||||
fn find_synastry_partner(&self) -> Option<Chart> {
|
||||
let current = self.current_chart.as_ref()?;
|
||||
let siblings = self.store.list_charts(current.contact_id).ok()?;
|
||||
siblings.into_iter().find(|c| c.id != current.id)
|
||||
}
|
||||
|
||||
/// Lee `target_age_years` del módulo o cae a la edad actual del
|
||||
/// sujeto (calculada desde la fecha de nacimiento y el reloj).
|
||||
fn module_age_or_current(&self, module_id: &str) -> f64 {
|
||||
@@ -321,9 +337,29 @@ impl Shell {
|
||||
if let serde_json::Value::Object(map) = entry {
|
||||
map.insert(key.clone(), value.clone());
|
||||
}
|
||||
// Transit y Synastry comparten el outer ring del
|
||||
// canvas — son mutuamente excluyentes. Al prender
|
||||
// uno, apagamos el otro y sincronizamos el panel.
|
||||
if key == "enabled" && bool_val {
|
||||
let conflicting = match module_id.as_str() {
|
||||
"transit" => Some("synastry"),
|
||||
"synastry" => Some("transit"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(other) = conflicting {
|
||||
if module_enabled(&self.module_configs, other) {
|
||||
set_module_enabled(&mut self.module_configs, other, false);
|
||||
let other_str = other.to_string();
|
||||
self.panel.update(cx, |p, cx| {
|
||||
p.set_toggle(&other_str, "enabled", false, cx)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sincronizar visualmente el toggle [T] del canvas
|
||||
// cuando el cambio fue al "enabled" del transit.
|
||||
if module_id == "transit" && key == "enabled" {
|
||||
// cuando el cambio afecta el outer ring (transit o
|
||||
// synastry — ambos lo usan).
|
||||
if (module_id == "transit" || module_id == "synastry") && key == "enabled" {
|
||||
self.canvas.update(cx, |c, cx| {
|
||||
c.set_layer_visible(LayerKind::Outer, bool_val, cx)
|
||||
});
|
||||
|
||||
@@ -567,10 +567,13 @@ fn render_wheel(
|
||||
}
|
||||
}
|
||||
|
||||
// Planet glyphs (transit ring) — solo si la capa Outer está activa.
|
||||
// Planet glyphs en el outer ring — transit o synastry, los dos
|
||||
// comparten ese slot (mutuamente excluyentes a nivel de Shell).
|
||||
if visible.get(&LayerKind::Outer).copied().unwrap_or(true) {
|
||||
for layer in &render.layers {
|
||||
if matches!(layer.kind, LayerKind::Outer) && layer.module_id == "transit" {
|
||||
if matches!(layer.kind, LayerKind::Outer)
|
||||
&& (layer.module_id == "transit" || layer.module_id == "synastry")
|
||||
{
|
||||
for g in &layer.glyphs {
|
||||
let (x, y) = polar_to_screen(g.deg, asc, rot_offset, radii.transits);
|
||||
let color = with_alpha(planet_color(palette, &g.symbol), 0.9);
|
||||
@@ -724,10 +727,12 @@ impl Radii {
|
||||
|
||||
/// Resuelve qué radios corresponden a una capa de aspectos según el
|
||||
/// `module_id`: natal-natal en `aspects`, cross con cada overlay
|
||||
/// desde `bodies` (extremo natal) al ring del módulo.
|
||||
/// desde `bodies` (extremo natal) al ring del módulo. Synastry
|
||||
/// comparte el outer ring de tránsito (son mutuamente excluyentes
|
||||
/// a nivel de Shell).
|
||||
fn aspect_endpoints(&self, module_id: &str) -> (f32, f32) {
|
||||
match module_id {
|
||||
"transit" => (self.bodies, self.transits),
|
||||
"transit" | "synastry" => (self.bodies, self.transits),
|
||||
"progression" => (self.bodies, self.progression),
|
||||
"solar_arc" => (self.bodies, self.solar_arc),
|
||||
_ => (self.aspects, self.aspects),
|
||||
@@ -935,12 +940,14 @@ fn paint_wheel(
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Outer ring (transit overlay): anillo guía + dots de transit.
|
||||
let transit_active = layers
|
||||
.iter()
|
||||
.any(|l| matches!(l.kind, LayerKind::Outer) && l.module_id == "transit");
|
||||
if transit_active && show(LayerKind::Outer) {
|
||||
// Anillos guía para delimitar el slot.
|
||||
// 5. Outer ring (transit o synastry overlay): anillo guía + dots
|
||||
// de la capa activa. Son mutuamente excluyentes a nivel de Shell;
|
||||
// si alguno de los dos está prendido, pintamos el slot.
|
||||
let outer_active = layers.iter().any(|l| {
|
||||
matches!(l.kind, LayerKind::Outer)
|
||||
&& (l.module_id == "transit" || l.module_id == "synastry")
|
||||
});
|
||||
if outer_active && show(LayerKind::Outer) {
|
||||
stroke_circle(
|
||||
window,
|
||||
cx,
|
||||
@@ -960,7 +967,9 @@ fn paint_wheel(
|
||||
|
||||
let dot_r = (radii.sign_outer * 0.017).max(2.0);
|
||||
for layer in layers {
|
||||
if matches!(layer.kind, LayerKind::Outer) && layer.module_id == "transit" {
|
||||
if matches!(layer.kind, LayerKind::Outer)
|
||||
&& (layer.module_id == "transit" || layer.module_id == "synastry")
|
||||
{
|
||||
for g in &layer.glyphs {
|
||||
let color = with_alpha(planet_color(palette, &g.symbol), 0.85);
|
||||
let (x, y) =
|
||||
|
||||
@@ -261,6 +261,9 @@ pub fn compose(
|
||||
crate::PipelineRequest::SolarArc { target_age_years } => {
|
||||
build_solar_arc_overlay(&natal, *target_age_years, &mut render)?;
|
||||
}
|
||||
crate::PipelineRequest::Synastry { partner_chart } => {
|
||||
build_synastry_overlay(&natal, partner_chart, &mut render)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,6 +469,68 @@ fn build_solar_arc_overlay(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Helper: agrega al `RenderModel` las capas del overlay de sinastría
|
||||
/// con otra carta natal completa. La carta partner se computa con su
|
||||
/// propio observer/config (no comparte con la natal). El outer ring
|
||||
/// se comparte con Transit — mutuamente excluyentes a nivel de Shell.
|
||||
fn build_synastry_overlay(
|
||||
natal: &NatalChart,
|
||||
partner_chart: &Chart,
|
||||
render: &mut RenderModel,
|
||||
) -> Result<(), EngineError> {
|
||||
let (partner, _config, _observer) = compute_natal_chart(partner_chart, 0)?;
|
||||
|
||||
let glyphs: Vec<Glyph> = partner
|
||||
.placements
|
||||
.iter()
|
||||
.map(|p| Glyph {
|
||||
deg: p.longitude.longitude_deg() as f32,
|
||||
symbol: body_symbol(p.body).into(),
|
||||
annotation: Some(format!("{:.1}°", p.longitude.degree_in_sign_decimal())),
|
||||
retrograde: p.longitude_rate_rad_per_day < 0.0,
|
||||
house: Some(p.house_number),
|
||||
})
|
||||
.collect();
|
||||
render.layers.push(Layer {
|
||||
module_id: "synastry".into(),
|
||||
kind: LayerKind::Outer,
|
||||
ring: 0.82,
|
||||
z: 10,
|
||||
geometry: Geometry::GlyphsOnly,
|
||||
glyphs,
|
||||
});
|
||||
|
||||
let cross = find_synastry_aspects(
|
||||
natal,
|
||||
&partner,
|
||||
&OrbTable::modern_western(),
|
||||
EAspectKind::MAJORS,
|
||||
);
|
||||
let cross_lines: Vec<LineSeg> = cross
|
||||
.iter()
|
||||
.filter_map(|a| {
|
||||
let natal_p = natal.placement(a.person_a_body)?;
|
||||
let partner_p = partner.placement(a.person_b_body)?;
|
||||
let opacity = orb_to_opacity(a.orb_abs_deg(), a.kind);
|
||||
Some(LineSeg {
|
||||
from_deg: natal_p.longitude.longitude_deg() as f32,
|
||||
to_deg: partner_p.longitude.longitude_deg() as f32,
|
||||
kind: aspect_kind_id(a.kind).into(),
|
||||
opacity: opacity * 0.85,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
render.layers.push(Layer {
|
||||
module_id: "synastry".into(),
|
||||
kind: LayerKind::Aspects,
|
||||
ring: 0.0,
|
||||
z: 11,
|
||||
geometry: Geometry::Lines(cross_lines),
|
||||
glyphs: Vec::new(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// NatalChart → RenderModel
|
||||
// =====================================================================
|
||||
|
||||
@@ -30,6 +30,10 @@ use thiserror::Error;
|
||||
|
||||
pub use tahuantinsuyu_model::{Chart, ChartId, ChartKind};
|
||||
|
||||
// `Chart` reexportado arriba es lo que `PipelineRequest::Synastry`
|
||||
// transporta — el caller (shell) lee del Store y pasa el Chart entero
|
||||
// para que el bridge construya su NatalChart en eternal.
|
||||
|
||||
#[cfg(feature = "eternal-bridge")]
|
||||
mod bridge;
|
||||
|
||||
@@ -180,8 +184,13 @@ pub enum PipelineRequest {
|
||||
SolarArc {
|
||||
target_age_years: f64,
|
||||
},
|
||||
// ── Fase 10 ─────────────────────────────────────────────────────
|
||||
// Synastry { partner: tahuantinsuyu_model::ChartId },
|
||||
/// `module_id = "synastry"` — bi-wheel: la natal en el centro, la
|
||||
/// carta del partner en el anillo externo (compartido con Transit
|
||||
/// — mutuamente excluyentes), cross aspects natal × partner.
|
||||
/// El partner viene como `Chart` completo del shell.
|
||||
Synastry {
|
||||
partner_chart: Box<Chart>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Composición canónica: carta natal + todos los overlays pedidos.
|
||||
|
||||
@@ -126,6 +126,7 @@ impl Registry {
|
||||
r.register(Box::new(transit::TransitModule));
|
||||
r.register(Box::new(progression::ProgressionModule));
|
||||
r.register(Box::new(solar_arc::SolarArcModule));
|
||||
r.register(Box::new(synastry::SynastryModule));
|
||||
r
|
||||
}
|
||||
|
||||
@@ -333,6 +334,50 @@ pub mod progression {
|
||||
}
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// SynastryModule — bi-wheel con otra carta hermana del contacto actual
|
||||
// =====================================================================
|
||||
|
||||
pub mod synastry {
|
||||
use super::*;
|
||||
|
||||
/// Pone la carta del partner en el anillo externo (compartido con
|
||||
/// Transit — mutuamente excluyentes) y dibuja las cross aspects
|
||||
/// natal × partner. El shell elige el partner: la primera carta
|
||||
/// hermana del mismo contacto. Si no hay hermana, el request se
|
||||
/// salta silenciosamente.
|
||||
pub struct SynastryModule;
|
||||
|
||||
impl Module for SynastryModule {
|
||||
fn id(&self) -> &'static str {
|
||||
"synastry"
|
||||
}
|
||||
fn label(&self) -> &'static str {
|
||||
"Sinastría"
|
||||
}
|
||||
fn description(&self) -> &'static str {
|
||||
"Bi-wheel con la primera carta hermana del contacto."
|
||||
}
|
||||
fn applies_to(&self, kind: ChartKind) -> bool {
|
||||
matches!(kind, ChartKind::Natal)
|
||||
}
|
||||
fn enabled_by_default(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn controls(&self) -> Vec<Control> {
|
||||
vec![Control::Toggle {
|
||||
key: "enabled".into(),
|
||||
label: "Activar".into(),
|
||||
default: false,
|
||||
hotkey: None,
|
||||
}]
|
||||
}
|
||||
fn compute_layers(&self, _chart: &Chart, _cfg: &serde_json::Value) -> Vec<Layer> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// SolarArcModule — Solar Arc dirigido (true progressed Sun)
|
||||
// =====================================================================
|
||||
@@ -397,8 +442,9 @@ mod tests {
|
||||
assert!(r.find("transit").is_some());
|
||||
assert!(r.find("progression").is_some());
|
||||
assert!(r.find("solar_arc").is_some());
|
||||
// Natal kind tiene 4 módulos: natal + transit + progression + solar_arc.
|
||||
assert_eq!(r.for_kind(ChartKind::Natal).len(), 4);
|
||||
assert!(r.find("synastry").is_some());
|
||||
// Natal kind tiene 5 módulos aplicables.
|
||||
assert_eq!(r.for_kind(ChartKind::Natal).len(), 5);
|
||||
assert!(r.for_kind(ChartKind::Synastry).is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user