forked from 1b-agent/opencadstudio-upstream
fix(dyn-input): correct Y coordinate, label by prompt type — #27
DYN overlay artık ekran-yukarı için world Y'yi (w.y) gösteriyor; eskiden w.z kullanıldığı için Z-up sahnede top/3D görünümde Y hep 0 görünüyordu (#27). Ayrıca overlay etiketi aktif komutun o anki sorusuna göre biçimleniyor: yeni DynField (Point / Distance / Angle) trait metodu eklendi. CIRCLE yarıçap adımında 'd=...', ROTATE açı adımında '<...°', diğer nokta adımlarında koordinat / polar (d + açı) gösteriliyor. Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
1 parent
874226bd43
commit
1fc73ba8b0
4 files changed
+72
-11
No files matched your search
+32
-9
@@ -2,6 +2,7 @@ use super::document::DocumentTab;
|
||||
use super::helpers::grid_plane_from_camera;
|
||||
use super::history::history_dropdown_labels;
|
||||
use super::{Message, OpenCADStudio};
|
||||
use crate::command::DynField;
|
||||
use crate::scene::grip::{grips_to_screen, grips_to_screen_paper};
|
||||
use crate::scene::paper_canvas::PaperCanvas;
|
||||
use crate::scene::viewport_pane::{PaperViewportPane, ViewportPane};
|
||||
@@ -463,18 +464,40 @@ impl OpenCADStudio {
|
||||
};
|
||||
|
||||
// Dynamic input overlay — shown when a command is active and DYN is on.
|
||||
// The label adapts to what the command is currently asking for:
|
||||
// a point shows coordinates (or polar distance+angle once a base
|
||||
// point exists); a radius/length prompt shows a single distance;
|
||||
// an angle prompt shows degrees.
|
||||
let dyn_input_overlay: Option<Element<'_, Message>> =
|
||||
if self.dyn_input && tab.active_cmd.is_some() {
|
||||
let w = tab.last_cursor_world;
|
||||
let label = if let Some(base) = self.last_point {
|
||||
// Show relative distance + angle when we have a base point.
|
||||
let dx = (w.x - base.x) as f64;
|
||||
let dy = (w.z - base.z) as f64;
|
||||
let dist = (dx * dx + dy * dy).sqrt();
|
||||
let ang = dy.atan2(dx).to_degrees();
|
||||
format!("d={:.3} <{:.1}°", dist, ang)
|
||||
} else {
|
||||
format!("X:{:.3} Y:{:.3}", w.x, w.z)
|
||||
let field = tab
|
||||
.active_cmd
|
||||
.as_ref()
|
||||
.map(|c| c.dyn_field())
|
||||
.unwrap_or(DynField::Point);
|
||||
// World is Z-up: the drawing plane is X/Y, so screen "up"
|
||||
// maps to world Y — use w.y, not w.z (issue #27).
|
||||
let label = match (field, self.last_point) {
|
||||
(DynField::Distance, Some(base)) => {
|
||||
let dx = (w.x - base.x) as f64;
|
||||
let dy = (w.y - base.y) as f64;
|
||||
format!("d={:.3}", (dx * dx + dy * dy).sqrt())
|
||||
}
|
||||
(DynField::Angle, Some(base)) => {
|
||||
let dx = (w.x - base.x) as f64;
|
||||
let dy = (w.y - base.y) as f64;
|
||||
format!("<{:.1}°", dy.atan2(dx).to_degrees().rem_euclid(360.0))
|
||||
}
|
||||
(_, Some(base)) => {
|
||||
// Point with a base: polar distance + angle.
|
||||
let dx = (w.x - base.x) as f64;
|
||||
let dy = (w.y - base.y) as f64;
|
||||
let dist = (dx * dx + dy * dy).sqrt();
|
||||
let ang = dy.atan2(dx).to_degrees().rem_euclid(360.0);
|
||||
format!("d={:.3} <{:.1}°", dist, ang)
|
||||
}
|
||||
(_, None) => format!("X:{:.3} Y:{:.3}", w.x, w.y),
|
||||
};
|
||||
Some(overlay::dynamic_input_overlay(
|
||||
tab.last_cursor_screen,
|
||||
|
||||
Reference in new issue
Block a user