forked from 1b-agent/opencadstudio-upstream
A SOLID's filled quad and a dimension/MultiLeader text background are flat 2-D overlays that should draw in wireframe and shaded alike, but face3d_gpu classified fills by `!fill_tris_low.is_empty()` — and a 2-D fill at UTM scale carries a double-single low residual for precision just like a real 3-D mesh face. So the arrowhead fill and the "5;8" cyan text background were routed to the 3-D buffer and only appeared in shaded mode, vanishing back to nothing on return to wireframe. WireModel now carries an explicit `fill_is_3d`: true only for a real surface (PolyfaceMesh / PolygonMesh face, set in the tessellator), false for every flat overlay fill. face3d_gpu classifies on the flag, so 2-D fills stay in the always-visible buffer while keeping their low residual (and UTM precision). Verified on budweiser: the `_BoxFilled` arrow SOLID and the dim '5;8' MTEXT background both tessellate with fill_is_3d = false. Co-Authored-By: Claude Opus 4.8 <[email protected]>
90 lines
2.6 KiB
Rust
90 lines
2.6 KiB
Rust
// PLOTWINDOW command — pick two corners to define the plot window area.
|
|
//
|
|
// In paper space it writes the layout's PlotSettings (PlotType::Window); in
|
|
// model space the host stores the window for the plot dialog.
|
|
|
|
use crate::command::{CadCommand, CmdResult};
|
|
use crate::scene::model::wire_model::WireModel;
|
|
use glam::DVec3;
|
|
|
|
pub struct PlotWindowCommand {
|
|
p1: Option<DVec3>,
|
|
}
|
|
|
|
impl PlotWindowCommand {
|
|
pub fn new() -> Self {
|
|
Self { p1: None }
|
|
}
|
|
}
|
|
|
|
impl CadCommand for PlotWindowCommand {
|
|
fn name(&self) -> &'static str {
|
|
"PLOTWINDOW"
|
|
}
|
|
|
|
fn prompt(&self) -> String {
|
|
if self.p1.is_none() {
|
|
"PLOTWINDOW Specify first corner of plot window:".into()
|
|
} else {
|
|
"PLOTWINDOW Specify opposite corner:".into()
|
|
}
|
|
}
|
|
|
|
fn on_point(&mut self, pt: DVec3) -> CmdResult {
|
|
match self.p1 {
|
|
None => {
|
|
self.p1 = Some(pt);
|
|
CmdResult::NeedPoint
|
|
}
|
|
Some(p1) => CmdResult::SetPlotWindow { p1, p2: pt },
|
|
}
|
|
}
|
|
|
|
fn on_enter(&mut self) -> CmdResult {
|
|
CmdResult::Cancel
|
|
}
|
|
|
|
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
|
|
let p1 = self.p1?.as_vec3();
|
|
// Draw the selection rectangle.
|
|
Some(WireModel {
|
|
fill_is_3d: false,
|
|
pick_tris: Vec::new(),
|
|
pick_tris_low: Vec::new(),
|
|
dash_from_start: false,
|
|
dash_align_end: None,
|
|
text_verts: Vec::new(),
|
|
name: "plotwindow_preview".into(),
|
|
points: vec![
|
|
[p1.x, p1.y, p1.z],
|
|
[pt.x, p1.y, p1.z],
|
|
[pt.x, p1.y, p1.z],
|
|
[pt.x, pt.y, pt.z],
|
|
[pt.x, pt.y, pt.z],
|
|
[p1.x, pt.y, pt.z],
|
|
[p1.x, pt.y, pt.z],
|
|
[p1.x, p1.y, p1.z],
|
|
],
|
|
points_low: Vec::new(),
|
|
color: WireModel::CYAN,
|
|
selected: false,
|
|
pattern_length: 0.0,
|
|
pattern: [0.0; 8],
|
|
line_weight_px: 1.0,
|
|
snap_pts: vec![],
|
|
tangent_geoms: vec![],
|
|
aci: 0,
|
|
key_vertices: vec![],
|
|
aabb: WireModel::UNBOUNDED_AABB,
|
|
plinegen: true,
|
|
vp_scissor: None,
|
|
fill_tris: vec![],
|
|
fill_tris_low: Vec::new(),
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
// ── Autocomplete registry ─────────────────────────────────
|
|
inventory::submit!(crate::command::CommandRegistration { names: &["PLOTWINDOW"] }); // PlotWindowCommand
|