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 <[email protected]>
71 lines
1.9 KiB
Rust
71 lines
1.9 KiB
Rust
// DDEDIT — edit the text content of a text-bearing entity in-place.
|
|
//
|
|
// Workflow:
|
|
// 1. Pick a text entity (or fire from double-click / a current selection).
|
|
// 2. The picked entity opens its in-place editor: a plain text box for
|
|
// single-line text (Text, attributes, dimension override, tolerance) or
|
|
// the rich MText editor for MText / MultiLeader. A Leader resolves to the
|
|
// entity it annotates.
|
|
|
|
use codec::Handle;
|
|
use glam::DVec3;
|
|
|
|
use crate::command::{CadCommand, CmdResult};
|
|
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
|
use crate::t;
|
|
|
|
pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/ddedit.svg"));
|
|
|
|
pub fn tool() -> ToolDef {
|
|
ToolDef {
|
|
id: "DDEDIT",
|
|
label: "Edit Text",
|
|
icon: ICON,
|
|
event: ModuleEvent::Command("DDEDIT".to_string()),
|
|
}
|
|
}
|
|
|
|
pub struct DdeditCommand;
|
|
|
|
impl DdeditCommand {
|
|
pub fn new() -> Self {
|
|
Self
|
|
}
|
|
}
|
|
|
|
impl CadCommand for DdeditCommand {
|
|
fn name(&self) -> &'static str {
|
|
"DDEDIT"
|
|
}
|
|
|
|
fn prompt(&self) -> String {
|
|
t!("DDEDIT Select text entity:").into_owned()
|
|
}
|
|
|
|
fn needs_entity_pick(&self) -> bool {
|
|
true
|
|
}
|
|
|
|
fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
|
|
if handle.is_null() {
|
|
return CmdResult::NeedPoint;
|
|
}
|
|
// Hand the picked entity to the in-place editor (plain box or rich
|
|
// MText editor, chosen by the entity's type).
|
|
CmdResult::EditTextEntity { handle }
|
|
}
|
|
|
|
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
|
|
CmdResult::NeedPoint
|
|
}
|
|
fn on_enter(&mut self) -> CmdResult {
|
|
CmdResult::Cancel
|
|
}
|
|
fn on_escape(&mut self) -> CmdResult {
|
|
CmdResult::Cancel
|
|
}
|
|
}
|
|
|
|
// ── Autocomplete registry ─────────────────────────────────
|
|
inventory::submit!(crate::command::CommandRegistration { names: &["DDEDIT"] });
|