forked from 1b-agent/opencadstudio-upstream
feat(plugin): add layer creation and modification host API
- Add LayerConfig struct and add_layer / modify_layer methods to HostApi trait - Implement IPC request/response serialization for AddLayer and ModifyLayer - Implement HostSession methods with CAD property defaults and selective modification - Refresh layer panel UI and invalidate scene layer dependencies upon layer changes - Add unit tests for add_layer with defaults and partial modify_layer
This commit is contained in:
1 parent
28e530470f
commit
929f185ba5
6 files changed
+298
No files matched your search
@@ -416,6 +416,34 @@ impl HostApi for PluginHostApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
Reference in new issue
Block a user