Persist diagram routing with atomic edits and grouped movement

This commit is contained in:
2026-09-05 20:18:55 +03:00
parent fa096cefd3
commit 4e5a88dc4d
8 changed files with 943 additions and 3 deletions
+23
View File
@@ -1241,7 +1241,29 @@ pub struct Diagram {
pub projection: ProjectionKind,
#[serde(deserialize_with = "unique_id_map")]
pub nodes: BTreeMap<Id, NodePlacement>,
#[serde(default)]
pub routes: Vec<EdgeRoute>,
}
/// Authored presentation for one existing relation or trace in one diagram.
/// Computed endpoints and automatic routing elbows are never persisted here.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct EdgeRoute {
pub edge: Id,
#[serde(default)]
pub waypoints: Vec<Position>,
#[serde(default)]
pub label: Option<EdgeLabel>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct EdgeLabel {
/// Fraction of the computed polyline's total arc length, from source to target.
pub fraction: f32,
/// Diagram-space displacement relative to the point at `fraction`.
pub offset: Position,
}
pub const MAX_ROUTE_POINTS: usize = 128;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct NodePlacement {
@@ -1613,6 +1635,7 @@ impl Project {
layer,
projection: ProjectionKind::Overview,
nodes: BTreeMap::new(),
routes: vec![],
},
);
id