forked from 1b-agent/opencadstudio-upstream
The codec and kernel repositories and crates are renamed opencadcodec and opencadkernel. Inside OCS they are depended on under short keys, so code reads `codec::`, `kernel::` and the new `graph::` (opencadgraph, the node graph engine). File-format and protocol spellings stay as they were: the ACIS product id `acadrust`, the ACADRUST_* switches and the plugin version keys `acadrust_version` / `acadrust_source`. A button left of MCP on the command line opens a translucent node graph over the viewport, with a palette of object, input, math, logic, list, text and geometry nodes added by click or drag. An object node owns drawing entities and its rows are the Properties panel's own rows for them: the single-object page is extracted from refresh_properties as entity_property_sections, values use the control protocol's property_json, and writes go through set_property_value with a property target override, so the panel, MCP and the graph share one read/write path. A list reaching an object row makes one entity per element. Each graph action is one undo step; the canvas pans and zooms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.0 KiB
Rust
67 lines
2.0 KiB
Rust
// ATTEDIT command — pick a block reference with attributes, then open the
|
|
// attribute editor dialog on it.
|
|
//
|
|
// This command only performs the entity pick. Once a block is chosen it
|
|
// reports the handle through `attedit_pending_handle`; the command host
|
|
// (`command_driver`) ends the command and opens the editor dialog. When a
|
|
// suitable block is already selected, the ATTEDIT dispatch opens the dialog
|
|
// directly and never starts this command (see `app::commands::inquiry`).
|
|
|
|
use glam::DVec3;
|
|
use crate::t;
|
|
|
|
use crate::command::{CadCommand, CmdResult};
|
|
use crate::scene::model::wire_model::WireModel;
|
|
|
|
pub struct AtteditCommand {
|
|
/// The picked block reference, once the user clicks one.
|
|
picked: Option<codec::Handle>,
|
|
}
|
|
|
|
impl AtteditCommand {
|
|
pub fn new() -> Self {
|
|
Self { picked: None }
|
|
}
|
|
}
|
|
|
|
impl CadCommand for AtteditCommand {
|
|
fn name(&self) -> &'static str {
|
|
"ATTEDIT"
|
|
}
|
|
|
|
fn prompt(&self) -> String {
|
|
t!("ATTEDIT Select block with attributes:").into_owned()
|
|
}
|
|
|
|
fn needs_entity_pick(&self) -> bool {
|
|
self.picked.is_none()
|
|
}
|
|
|
|
fn on_entity_pick(&mut self, handle: codec::Handle, _pt: DVec3) -> CmdResult {
|
|
if handle.is_null() {
|
|
return CmdResult::NeedPoint;
|
|
}
|
|
// Record the pick and yield: the host reads `attedit_pending_handle`
|
|
// and opens the editor dialog for this block.
|
|
self.picked = Some(handle);
|
|
CmdResult::NeedPoint
|
|
}
|
|
|
|
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
|
|
CmdResult::NeedPoint
|
|
}
|
|
fn on_enter(&mut self) -> CmdResult {
|
|
CmdResult::Cancel
|
|
}
|
|
fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
|
|
vec![]
|
|
}
|
|
|
|
fn attedit_pending_handle(&self) -> Option<codec::Handle> {
|
|
self.picked
|
|
}
|
|
}
|
|
|
|
// ── Autocomplete registry ─────────────────────────────────
|
|
inventory::submit!(crate::command::CommandRegistration { names: &["ATTEDIT"] });
|