forked from 1b-agent/opencadstudio-upstream
feat(block-editor): add native Point parameter placement
Enable Point in Authoring Palettes and BPARAMETER. Pick parameter and label positions, then create the native Point, XY grip and position expressions in one undo transaction. Draw editor-only markers and clear placement previews. Share graph append construction with Visibility so both types coexist in either order. Allocate node, expression and edge IDs independently; preserve existing objects, nodes and relationships and reject malformed/opaque graphs. Reframe parameter, label and grip with the edited definition. Include authoring positions in editor framing while keeping reference geometry extents unchanged. Retain save/discard and parent saved-edit undo. Action association/evaluation and parameter property editing remain separate milestones. Validation: 10 targeted, 286 block and 60 dock checks passed (overlapping filters). Appending a Point to an existing native graph passed DWG/DXF roundtrips in all 17 local fixtures; old objects and original checksums stayed unchanged. Real-view palette interaction and rendered marker/label verified.
This commit is contained in:
1 parent
daa26007f9
commit
cdfb4ed632
19 files changed
+1457
-303
No files matched your search
@@ -6,6 +6,7 @@ use crate::modules::parametric::ParametricModule;
|
||||
use crate::modules::{CadModule, IconKind, ModuleEvent, RibbonGroup, RibbonItem, ToolDef};
|
||||
|
||||
pub mod visibility_parameter;
|
||||
pub mod point_parameter;
|
||||
|
||||
pub struct BlockEditorModule;
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
//! Two-point authoring gesture: parameter position followed by label position.
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
use crate::scene::WireModel;
|
||||
use codec::Handle;
|
||||
use glam::DVec3;
|
||||
|
||||
pub struct PointParameterCommand {
|
||||
document_id: u64,
|
||||
definition: Handle,
|
||||
location: Option<DVec3>,
|
||||
}
|
||||
|
||||
impl PointParameterCommand {
|
||||
pub fn new(document_id: u64, definition: Handle) -> Self {
|
||||
Self {
|
||||
document_id,
|
||||
definition,
|
||||
location: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CadCommand for PointParameterCommand {
|
||||
fn name(&self) -> &'static str {
|
||||
"BPARAMETER"
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
crate::t!(if self.location.is_some() {
|
||||
"BPARAMETER Specify point parameter label location:"
|
||||
} else {
|
||||
"BPARAMETER Specify point parameter location:"
|
||||
})
|
||||
.into_owned()
|
||||
}
|
||||
|
||||
fn on_point(&mut self, point: DVec3) -> CmdResult {
|
||||
if !point.is_finite() {
|
||||
return CmdResult::ReportError(
|
||||
crate::t!("Specify a finite parameter location.").into_owned(),
|
||||
);
|
||||
}
|
||||
if let Some(location) = self.location {
|
||||
CmdResult::PlaceBlockPointParameter {
|
||||
document_id: self.document_id,
|
||||
definition: self.definition,
|
||||
location,
|
||||
label: point,
|
||||
}
|
||||
} else {
|
||||
self.location = Some(point);
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
}
|
||||
|
||||
fn on_preview_wires(&mut self, point: DVec3) -> Vec<WireModel> {
|
||||
self.location
|
||||
.filter(|_| point.is_finite())
|
||||
.map(|location| {
|
||||
vec![WireModel::solid_f64(
|
||||
"preview_point_parameter".into(),
|
||||
vec![location.to_array(), point.to_array()],
|
||||
WireModel::CYAN,
|
||||
false,
|
||||
)]
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,8 @@ impl CadCommand for VisibilityParameterCommand {
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
if self.choosing_type {
|
||||
crate::t!("BPARAMETER Enter parameter type [Visibility] <Visibility>:").into_owned()
|
||||
crate::t!("BPARAMETER Enter parameter type [Point/Visibility] <Visibility>:")
|
||||
.into_owned()
|
||||
} else {
|
||||
crate::t!("BPARAMETER Specify visibility parameter location:").into_owned()
|
||||
}
|
||||
@@ -35,7 +36,10 @@ impl CadCommand for VisibilityParameterCommand {
|
||||
|
||||
fn options(&self) -> Vec<CmdOption> {
|
||||
if self.choosing_type {
|
||||
vec![CmdOption::new(crate::t!("Visibility").as_ref(), "V")]
|
||||
vec![
|
||||
CmdOption::new(crate::t!("Point").as_ref(), "P"),
|
||||
CmdOption::new(crate::t!("Visibility").as_ref(), "V"),
|
||||
]
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
@@ -56,13 +60,16 @@ impl CadCommand for VisibilityParameterCommand {
|
||||
.to_ascii_uppercase()
|
||||
.as_str()
|
||||
{
|
||||
"P" | "POINT" => CmdResult::Dispatch("BPARAMETER POINT".into()),
|
||||
"" | "V" | "VISIBILITY" => {
|
||||
self.choosing_type = false;
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
_ => CmdResult::ReportError(
|
||||
crate::t!("Only Visibility parameter placement is currently supported.")
|
||||
.into_owned(),
|
||||
crate::t!(
|
||||
"Only Point and Visibility parameter placement is currently supported."
|
||||
)
|
||||
.into_owned(),
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user