forked from 1b-agent/opencadstudio-upstream
feat(plot): QUICKPRINT/QP — plot a selection's bounding box to PDF (#325)
Run QUICKPRINT (or QP), select objects, then Enter: the selection's bounding box becomes the plot window and a PDF is written next to the drawing (<name>_<timestamp>.pdf) using the active page setup, with no dialog. Model space. Implemented as a selection-gathering CadCommand (src/modules/view/ quick_print.rs) returning CmdResult::QuickPrint(handles); the host (on_quick_print_handles) unions the picked entities' AABBs, sets the plot window, and reuses the tested clipped window-export path. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
a1ee4d9269
commit
c45fe0267c
7 files changed
+165
No files matched your search
@@ -9,6 +9,7 @@ mod ortho;
|
||||
mod pan;
|
||||
mod persp;
|
||||
pub mod plot_window;
|
||||
pub mod quick_print;
|
||||
mod properties_palette;
|
||||
mod sheetset;
|
||||
mod solid;
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// QUICKPRINT / QP — run the command, select objects, then Enter to plot the
|
||||
// selection's bounding box to a PDF (handled by the host). No dialog. (#325)
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
use acadrust::Handle;
|
||||
use glam::DVec3;
|
||||
|
||||
pub struct QuickPrintCommand {
|
||||
/// Latest selection set, refreshed on every selection action.
|
||||
handles: Vec<Handle>,
|
||||
}
|
||||
|
||||
impl QuickPrintCommand {
|
||||
pub fn new() -> Self {
|
||||
Self { handles: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl CadCommand for QuickPrintCommand {
|
||||
fn name(&self) -> &'static str {
|
||||
"QUICKPRINT"
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
if self.handles.is_empty() {
|
||||
"QUICKPRINT Select objects to quick-print:".into()
|
||||
} else {
|
||||
format!(
|
||||
"QUICKPRINT {} selected — Enter to plot, or keep selecting:",
|
||||
self.handles.len()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_selection_gathering(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn on_selection_complete(&mut self, handles: Vec<Handle>) -> CmdResult {
|
||||
self.handles = handles;
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
|
||||
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
if self.handles.is_empty() {
|
||||
CmdResult::Cancel
|
||||
} else {
|
||||
CmdResult::QuickPrint(std::mem::take(&mut self.handles))
|
||||
}
|
||||
}
|
||||
|
||||
fn on_escape(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
}
|
||||
|
||||
inventory::submit!(crate::command::CommandRegistration {
|
||||
names: &["QUICKPRINT", "QP"]
|
||||
}); // QuickPrintCommand
|
||||
Reference in new issue
Block a user