forked from 1b-agent/opencadstudio-upstream
ocs_doc_api: Phase 2b-c (linear Dimension) — Phase 2 complete
- CreateDimensionLinear(DimensionSpec) op + GetDimensionMeasurement query (append-only). - backend add_dimension_linear (Dimension::Linear via DimensionLinear::new) + dimension_measurement (linear/radius/diameter distance). - Dimension bounds from measured + definition points; Dimension handle + measurement(). - spec Dimension family; api_reference + binding_schema regenerated; mocks + baseline. - Test phase2c_dimension_linear_create_measurement_bounds -> 607 host lib + 8 crate + 3 consistency green. Phase 2 (full 2D + annotations) is now complete.
This commit is contained in:
1 parent
ba8e5ed0cd
commit
2dba0158ca
16 files changed
+209
-3
No files matched your search
@@ -269,6 +269,18 @@ handle!(Ray);
|
||||
handle!(XLine);
|
||||
handle!(Text);
|
||||
handle!(MText);
|
||||
handle!(Dimension);
|
||||
|
||||
impl Dimension {
|
||||
/// The measured value of this dimension (distance for linear/radius, degrees
|
||||
/// for angular).
|
||||
pub fn measurement(&self) -> ApiResult<f64> {
|
||||
match self.session.one_query(Query::GetDimensionMeasurement { id: self.id })? {
|
||||
QueryResult::DimensionMeasurement(v) => Ok(v),
|
||||
_ => Err(ApiError::Transport("unexpected measurement result".into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Entity {
|
||||
pub fn view(&self) -> ApiResult<EntityView> {
|
||||
@@ -475,6 +487,16 @@ impl CurveCollection {
|
||||
Ok(Entity::new(self.session.clone(), id))
|
||||
}
|
||||
|
||||
/// A linear DIMENSION between `first_point` and `second_point`, with the
|
||||
/// dimension line placed at `definition_point`. `measurement()` reads the value.
|
||||
pub fn create_dimension_linear(&self, first_point: [f64; 3], second_point: [f64; 3], definition_point: [f64; 3]) -> ApiResult<Dimension> {
|
||||
let receipt = self.session.apply_op(Operation::CreateDimensionLinear(crate::ops::DimensionSpec {
|
||||
first_point, second_point, definition_point,
|
||||
}))?;
|
||||
let id = receipt.outcome.and_then(|o| o.new_id()).ok_or_else(|| ApiError::Transport("create_dimension returned no id".into()))?;
|
||||
Ok(Dimension::new(self.session.clone(), id))
|
||||
}
|
||||
|
||||
/// Single-line TEXT annotation.
|
||||
pub fn create_text(&self, value: &str, insertion_point: [f64; 3], height: f64, rotation: f64) -> ApiResult<Text> {
|
||||
let receipt = self.session.apply_op(Operation::CreateText(crate::ops::TextSpec {
|
||||
|
||||
Reference in new issue
Block a user