Merge origin/main into plugin/host-model-api

Conflicts were additive: main's AddLayer/ModifyLayer (LayerConfig, OptHandle)
alongside this branch's v7 system-variable, transaction, selection and solid
operations. Main's variants keep their positions in the IPC enums; the v7
additions follow them. src/io/mod.rs takes main's reworded Shape-rotation note.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Felix RiestraandClaude Sonnet 5 committed 2026-09-21 15:12:58 +02:00
commit 6b8056cfeb
28 files changed
+1425 -97

No files matched your search

+30
View File
@@ -690,6 +690,36 @@ pub trait HostApi {
fn solid_operation(&mut self, _operation: SolidOperation) -> Result<Handle, String> {
Err("solid operations are not supported by this host".to_owned())
}
/// Add a layer to the active document with full initial properties.
/// If an optional property in `config` is `None`, standard CAD defaults are applied.
/// Returns `None` if the layer already exists or `config.name` is invalid.
fn add_layer(&mut self, config: LayerConfig) -> Option<Handle> {
let _ = config;
None
}
/// Modify specified properties of an existing layer in the active document.
/// Properties that are `None` in `config` are left untouched as-is.
/// Returns `false` if the layer does not exist or `config.name` is invalid.
fn modify_layer(&mut self, config: LayerConfig) -> bool {
let _ = config;
false
}
}
/// Configuration properties for creating or modifying a layer.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct LayerConfig {
pub name: String,
pub color: Option<acadrust::types::Color>,
pub linetype: Option<String>,
pub lineweight: Option<acadrust::types::LineWeight>,
pub off: Option<bool>,
pub frozen: Option<bool>,
pub locked: Option<bool>,
pub plottable: Option<bool>,
pub transparency: Option<acadrust::types::Transparency>,
pub description: Option<String>,
}
/// Simplified, read-only entity kind exposed by [`DocumentReader`].
+28
View File
@@ -490,6 +490,34 @@ impl HostApi for PluginHostApi {
Err(error) => Err(error.to_string()),
}
}
fn add_layer(&mut self, config: crate::host::LayerConfig) -> Option<Handle> {
match self.client.request(PluginRequest::AddLayer(config)) {
Ok(PluginResponse::OptHandle(h)) => h,
Ok(other) => {
eprintln!("[plugin] unexpected AddLayer response: {other:?}");
None
}
Err(e) => {
eprintln!("[plugin] AddLayer request failed: {e}");
None
}
}
}
fn modify_layer(&mut self, config: crate::host::LayerConfig) -> bool {
match self.client.request(PluginRequest::ModifyLayer(config)) {
Ok(PluginResponse::Bool(b)) => b,
Ok(other) => {
eprintln!("[plugin] unexpected ModifyLayer response: {other:?}");
false
}
Err(e) => {
eprintln!("[plugin] ModifyLayer request failed: {e}");
false
}
}
}
}
/// Sentinel reader used when the shared-memory view could not be initialized.
@@ -140,6 +140,10 @@ pub enum PluginRequest {
GetTabId,
/// V5: ask the host for the filesystem path of the document in `tab_id`.
DocumentPath { tab_id: u64 },
/// Add a layer to the active document with full initial properties.
AddLayer(crate::host::LayerConfig),
/// Modify specified properties of an existing layer in the active document.
ModifyLayer(crate::host::LayerConfig),
/// Read a host-managed setting without nested command dispatch.
GetSystemVariable { name: String },
/// Change a host-managed setting without nested command dispatch.
@@ -177,6 +181,8 @@ pub enum PluginResponse {
TabId(u64),
/// V5: filesystem path of the document in the requested tab, if any.
DocumentPath(Option<std::ffi::OsString>),
/// Optional entity handle (e.g. from AddLayer).
OptHandle(Option<Handle>),
SystemVariable(Option<HostSettingValue>),
SystemVariableResult(Result<HostSettingValue, String>),
EntityTransactionResult(Result<(), String>),
+2
View File
@@ -98,6 +98,8 @@ pub fn handle_plugin_request(
DocumentPath { tab_id } => PluginResponse::DocumentPath(
host.document_path(tab_id).map(|path| path.into_os_string()),
),
AddLayer(config) => PluginResponse::OptHandle(host.add_layer(config)),
ModifyLayer(config) => PluginResponse::Bool(host.modify_layer(config)),
GetSystemVariable { name } => PluginResponse::SystemVariable(host.system_variable(&name)),
SetSystemVariable { name, value } => {
PluginResponse::SystemVariableResult(host.set_system_variable(&name, value))
@@ -804,6 +804,34 @@ impl HostApi for V4PluginHostApi {
Err(error) => Err(error.to_string()),
}
}
fn add_layer(&mut self, config: crate::host::LayerConfig) -> Option<Handle> {
match self.request(PluginRequest::AddLayer(config)) {
Ok(PluginResponse::OptHandle(h)) => h,
Ok(other) => {
eprintln!("[plugin] unexpected AddLayer response: {other:?}");
None
}
Err(e) => {
eprintln!("[plugin] AddLayer request failed: {e}");
None
}
}
}
fn modify_layer(&mut self, config: crate::host::LayerConfig) -> bool {
match self.request(PluginRequest::ModifyLayer(config)) {
Ok(PluginResponse::Bool(b)) => b,
Ok(other) => {
eprintln!("[plugin] unexpected ModifyLayer response: {other:?}");
false
}
Err(e) => {
eprintln!("[plugin] ModifyLayer request failed: {e}");
false
}
}
}
}
#[cfg(test)]