forked from 1b-agent/opencadstudio-upstream
Merge PR #1028: add document API with atomic edits
Add the typed document facade and plugin IPC adapter. Prepare bulk edits before mutation, preserve undo and dirty state, keep profile elevations, validate numeric inputs and session bindings, and generate Python constructors with typed results. Reuse existing entity transforms and profile conversion. Compute mass properties and closed-surface bounds in cadkernel; pin its main revision 6a5e6fc2822f6af6b2611cd605b44437b35158f0. Keep plugin API metadata at version 6. Validation: 646 native application tests, 597 kernel tests, 12 document API tests, 91 plugin API tests, 3 Python tests, default/IPC feature builds and wasm32 check passed.
This commit is contained in:
commit
3385160493
50 files changed
+11481
-6
No files matched your search
@@ -0,0 +1,102 @@
|
||||
// HAND-MAINTAINED wire vocabulary (the Operation enum). This file is NOT derived
|
||||
// from spec/entities.toml by build.rs — the enum is the canonical append-only
|
||||
// wire vocabulary; the spec's `op` names must each map to a variant here
|
||||
// (enforced by a test). Append new variants at the END only (bincode discriminant
|
||||
// stability). Do NOT reorder or remove variants.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::id::ObjectId;
|
||||
use crate::ops::{
|
||||
AttributeDefinitionSpec, BoolOp, Curve2Spec, DimensionAngularSpec, DimensionRadialSpec,
|
||||
DimensionSpec, EntitySpec, HatchSpec, InsertSpec, MTextSpec, PlacementSpec, RasterImageSpec,
|
||||
SolidPrimitive, TableSpec, TextSpec, ViewportSpec,
|
||||
};
|
||||
|
||||
/// A typed write operation. Each variant is ONE atomic host call = one
|
||||
/// undo step. Append new variants at the END only.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[non_exhaustive]
|
||||
pub enum Operation {
|
||||
// construction
|
||||
CreateSolid(SolidPrimitive),
|
||||
CreateCurve(Curve2Spec),
|
||||
Extrude {
|
||||
profile: ObjectId,
|
||||
direction: [f64; 3],
|
||||
},
|
||||
Revolve {
|
||||
profile: ObjectId,
|
||||
axis: ([f64; 3], [f64; 3]),
|
||||
angle: f64,
|
||||
},
|
||||
// modification
|
||||
Transform {
|
||||
id: ObjectId,
|
||||
placement: PlacementSpec,
|
||||
},
|
||||
SolidBoolean {
|
||||
op: BoolOp,
|
||||
a: ObjectId,
|
||||
b: ObjectId,
|
||||
erase_sources: bool,
|
||||
},
|
||||
AddVertex {
|
||||
id: ObjectId,
|
||||
at: usize,
|
||||
point: [f64; 3],
|
||||
},
|
||||
Delete {
|
||||
id: ObjectId,
|
||||
},
|
||||
// Bulk ops (single op, upfront-validation all-or-nothing — NOT a transaction, §5.3)
|
||||
CreateMany(Vec<EntitySpec>),
|
||||
TransformMany {
|
||||
ids: Vec<ObjectId>,
|
||||
placement: PlacementSpec,
|
||||
},
|
||||
DeleteMany(Vec<ObjectId>),
|
||||
// containers
|
||||
CreateInsert(InsertSpec),
|
||||
// paper-space
|
||||
CreateViewport(ViewportSpec),
|
||||
// annotations
|
||||
CreateText(TextSpec),
|
||||
CreateMText(MTextSpec),
|
||||
SetTextContent {
|
||||
id: ObjectId,
|
||||
value: String,
|
||||
},
|
||||
// hatch
|
||||
CreateHatch(HatchSpec),
|
||||
// dimensions
|
||||
CreateDimensionLinear(DimensionSpec),
|
||||
// attributes
|
||||
SetAttribute {
|
||||
id: ObjectId,
|
||||
tag: String,
|
||||
value: String,
|
||||
},
|
||||
// viewport view
|
||||
SetViewportView {
|
||||
id: ObjectId,
|
||||
view_target: [f64; 3],
|
||||
view_height: f64,
|
||||
},
|
||||
// media
|
||||
CreateRasterImage(RasterImageSpec),
|
||||
// multi-profile solid
|
||||
Loft {
|
||||
profiles: Vec<ObjectId>,
|
||||
},
|
||||
// dimension sub-types
|
||||
CreateDimensionRadius(DimensionRadialSpec),
|
||||
CreateDimensionDiameter(DimensionRadialSpec),
|
||||
CreateDimensionAngular(DimensionAngularSpec),
|
||||
// attribute definitions
|
||||
CreateAttributeDefinition(AttributeDefinitionSpec),
|
||||
// tables
|
||||
CreateTable(TableSpec),
|
||||
// dimension sub-types (2-line angular)
|
||||
CreateDimensionAngular2Ln(DimensionAngularSpec),
|
||||
}
|
||||
Reference in new issue
Block a user