forked from 1b-agent/opencadstudio-upstream
refactor(scene): reference-only designation becomes a scene-scoped set (API v9)
Per the upstream review of the XDATA-based storage: the host no longer writes its own state into the saved file. The marker record under the host-owned OCS APPID, the on-first-use APPID registration and the verbatim-EED rewrite handling are removed; the single source of truth is a scene-scoped in-memory set of entity handles (Scene::reference_only) that dies with the drawing tab, so a reopened file starts undesignated and the owning plugin re-marks on the document-opened notification. All behaviour sites are unchanged, driven by the set: the wire stamp moves from an XDATA read to a set lookup threaded through the tessellation pipelines (tessellate_entity and the dimension text path take the handle set as a plain parameter), and the pick filters, selection retains and update/erase refusals read Scene::is_reference_only. Undo keeps the entity-write contract: set mutations are recorded as explicit first-touch before/after values on each history delta (the parametric- constraints channel pattern). A designation inside a plugin push_undo scope joins it, a scope-less change is one step of its own, an idempotent re-mark records nothing, erasing a designated entity drops the set entry with the entity, and undo/redo restores entity and designation together. The round-trip test is inverted: reference_only_designation_is_not_written_ to_dwg_or_dxf now asserts the marker appears in neither format's bytes, that no OCS APPID or marker record survives a reload, and that the designation stays live in memory.
This commit is contained in:
1 parent
06ee0798a8
commit
50db12b169
17 files changed
+623
-232
No files matched your search
@@ -766,6 +766,7 @@ impl HistorySnapshot {
|
||||
.saturating_add(d.named_parameters.as_ref().map_or(0, |(before, after)| {
|
||||
before.len().saturating_add(after.len()).saturating_mul(128)
|
||||
}))
|
||||
.saturating_add(d.reference_designations.len().saturating_mul(16))
|
||||
.saturating_add(d.label.len()),
|
||||
HistorySnapshot::ObjectVisibility(v) => v
|
||||
.before
|
||||
@@ -818,6 +819,12 @@ pub(super) struct DeltaSnapshot {
|
||||
/// `document.objects`, so it needs its own channel here rather than
|
||||
/// riding along with `entities`/`structure`. Almost always empty.
|
||||
pub(super) parametric_constraints: Vec<ParametricConstraintsEntryDelta>,
|
||||
/// Reference-only designations (API v9) this same command changed — set
|
||||
/// state on `Scene` (see `scene::reference_only`), recorded as explicit
|
||||
/// first-touch before/afters so undo/redo restores the designation with
|
||||
/// the entity it belongs to (e.g. a plugin scope that both erases and
|
||||
/// re-designates). Almost always empty.
|
||||
pub(super) reference_designations: Vec<ReferenceDesignationDelta>,
|
||||
/// Drawing-wide parameter table changed by this transaction.
|
||||
pub(super) named_parameters: Option<(
|
||||
crate::scene::named_parameters::ParameterTable,
|
||||
@@ -892,6 +899,17 @@ pub(super) struct ParametricConstraintsEntryDelta {
|
||||
pub(super) after: crate::scene::parametric_constraints::ParametricConstraintSet,
|
||||
}
|
||||
|
||||
/// One reference-only designation's before/after value within an entity delta
|
||||
/// (API v9). The designation set lives on `Scene`, not in the document, so
|
||||
/// the value rides its own channel — symmetric like every other delta field,
|
||||
/// undo applies the before value, redo the after value.
|
||||
#[derive(Clone)]
|
||||
pub(super) struct ReferenceDesignationDelta {
|
||||
pub(super) handle: Handle,
|
||||
pub(super) before: bool,
|
||||
pub(super) after: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct HistoryState {
|
||||
pub(super) undo_stack: Vec<HistorySnapshot>,
|
||||
@@ -907,6 +925,12 @@ pub(super) struct PendingHistorySnapshot {
|
||||
pub(super) dirty_before: bool,
|
||||
pub(super) structure_before: CadDocument,
|
||||
pub(super) recorder: Arc<codec::document::EntityChangeRecorder>,
|
||||
/// First-touch before-values of reference-only designations (API v9)
|
||||
/// mutated inside this plugin scope (see `scene::reference_only`). Set
|
||||
/// mutations are not document writes, so the scope closes by reading the
|
||||
/// set's current state as the after-image and keeping entries whose value
|
||||
/// actually flipped.
|
||||
pub(super) reference_designations_before: Vec<(Handle, bool)>,
|
||||
/// Kept as an undo step even when nothing changed.
|
||||
pub(super) keep_empty: bool,
|
||||
}
|
||||
Reference in new issue
Block a user