mirror of
https://github.com/storytold/cadcraft.git
synced 2026-11-09 12:00:50 -06:00
* chore(clippy): enforce workspace Rust quality gates * refactor(doc): use explicit entity imports * refactor(constraints): split residual evaluation * refactor(fonts): split mtext layout * refactor(render): use explicit entity imports * fix(fonts): retain height for empty paragraphs * fix(doc): repair dimension and dynamic block links * refactor(render): split entity drawing helpers * docs: document workspace lint inheritance * refactor(render): isolate dimension geometry * refactor(engine): use explicit imports * refactor(engine): split complex edit paths into helpers * refactor(io): split DXF read and write helpers * refactor(ui): split canvas interaction and drawing * refactor(ui): split command and drawing helpers * test(i18n): split locale preference checks * fix(ui): use current egui scope id API * fix(dim): preserve text offset and ellipse grip behavior
41 lines
1.3 KiB
Rust
41 lines
1.3 KiB
Rust
use super::{Deserialize, Serialize, Vec2};
|
|
|
|
/// A 2D view of a space: world centre and visible height in drawing units.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct View {
|
|
pub center: Vec2,
|
|
pub height: f64,
|
|
}
|
|
|
|
impl Default for View {
|
|
fn default() -> Self {
|
|
View { center: Vec2::new(6.0, 4.5), height: 10.0 }
|
|
}
|
|
}
|
|
|
|
pub(crate) fn usable_view(v: &View) -> bool {
|
|
v.center.is_finite() && v.height.is_finite() && v.height > 1e-12
|
|
}
|
|
|
|
/// Tiled model viewports (VPORTS): the session side of the drawing's `*Active` configuration.
|
|
#[derive(Clone, Debug, Default, PartialEq)]
|
|
pub struct ModelTiles {
|
|
/// The tile corners these views belong to (when the drawing's tiles change, by VPORTS or
|
|
/// undo, its views take over).
|
|
pub rects: Vec<(Vec2, Vec2)>,
|
|
/// Each tile's view; the current tile shows the model space view itself.
|
|
pub views: Vec<View>,
|
|
/// The current tile.
|
|
pub active: usize,
|
|
}
|
|
|
|
/// One tile of the model space drawing area, for the UI ([`Session::model_tiles`]): its corners
|
|
/// as fractions of the drawing area (0,0 lower left) and its view.
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
pub struct ModelTile {
|
|
pub min: Vec2,
|
|
pub max: Vec2,
|
|
pub view: View,
|
|
pub active: bool,
|
|
}
|