forked from 1b-agent/opencadstudio-upstream
Feat: viewport display lock, extended properties, VPLAYER and VPORTS commands
- Enforce status.locked in pan_active_viewport and zoom_active_viewport: locked viewports now reject pan/zoom inputs entirely - Add perspective, render_mode, shade_plot_mode, hide_plot, ucs_icon_visible fields to the viewport property panel with appropriate pickers/toggles - Add VPORTS command: lists all user viewports in the current layout (id, size, position, scale, on/locked state) in the command line - Add VPLAYER command: per-viewport layer freeze/thaw from the command line (F <layer> to freeze, T <layer> to thaw, Enter to exit) - Add CmdResult::VpLayerUpdate variant and its handler in apply_cmd_result Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
b013619c25
commit
73b224c191
7 files changed
+311
-1
No files matched your search
@@ -2,6 +2,7 @@
|
||||
// This tab is only shown when the active layout is not "Model".
|
||||
|
||||
pub mod mview;
|
||||
pub mod vplayer;
|
||||
|
||||
use crate::modules::{CadModule, IconKind, ModuleEvent, RibbonGroup, ToolDef};
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// VPLAYER — per-viewport layer freeze/thaw command.
|
||||
//
|
||||
// Usage (command line):
|
||||
// VPLAYER
|
||||
// > F <layer_name> → freeze layer in active viewport
|
||||
// > T <layer_name> → thaw layer in active viewport
|
||||
// > Enter → exit
|
||||
//
|
||||
// Layer names are case-insensitive. Multiple space-separated names are accepted.
|
||||
|
||||
use acadrust::Handle;
|
||||
use glam::Vec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
use crate::scene::wire_model::WireModel;
|
||||
|
||||
pub struct VplayerCommand {
|
||||
vp_handle: Handle,
|
||||
}
|
||||
|
||||
impl VplayerCommand {
|
||||
pub fn new(vp_handle: Handle) -> Self {
|
||||
Self { vp_handle }
|
||||
}
|
||||
}
|
||||
|
||||
impl CadCommand for VplayerCommand {
|
||||
fn name(&self) -> &'static str {
|
||||
"VPLAYER"
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
"VPLAYER F <layer> = Freeze | T <layer> = Thaw | Enter = Exit".to_string()
|
||||
}
|
||||
|
||||
fn wants_text_input(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
||||
let text = text.trim();
|
||||
if text.is_empty() {
|
||||
return Some(CmdResult::Cancel);
|
||||
}
|
||||
|
||||
let mut parts = text.splitn(2, char::is_whitespace);
|
||||
let op = parts.next().unwrap_or("").to_uppercase();
|
||||
let rest = parts.next().unwrap_or("").trim();
|
||||
|
||||
let layer_names: Vec<String> = rest
|
||||
.split_whitespace()
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
|
||||
if layer_names.is_empty() {
|
||||
return None; // no layer name given — ignore and re-prompt
|
||||
}
|
||||
|
||||
match op.as_str() {
|
||||
"F" | "FREEZE" => Some(CmdResult::VpLayerUpdate {
|
||||
vp_handle: self.vp_handle,
|
||||
freeze: layer_names,
|
||||
thaw: vec![],
|
||||
}),
|
||||
"T" | "THAW" => Some(CmdResult::VpLayerUpdate {
|
||||
vp_handle: self.vp_handle,
|
||||
freeze: vec![],
|
||||
thaw: layer_names,
|
||||
}),
|
||||
_ => None, // unknown op — ignore
|
||||
}
|
||||
}
|
||||
|
||||
fn on_point(&mut self, _pt: Vec3) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
|
||||
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> {
|
||||
None
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user