use super::TableEntry;
use crate::types::{Handle, Vector2, Vector3};
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct VPort {
pub handle: Handle,
pub name: String,
pub lower_left: Vector2,
pub upper_right: Vector2,
pub view_center: Vector2,
pub snap_base: Vector2,
pub snap_spacing: Vector2,
pub grid_spacing: Vector2,
pub view_direction: Vector3,
pub view_target: Vector3,
pub view_height: f64,
pub aspect_ratio: f64,
pub lens_length: f64,
pub view_twist: f64,
pub front_clip: f64,
pub back_clip: f64,
pub ucsfollow: bool,
pub circle_zoom: i16,
pub fast_zoom: bool,
pub grid_on: bool,
pub snap_on: bool,
pub snap_style: bool,
pub snap_isopair: i16,
pub snap_rotation: f64,
}
impl VPort {
pub fn new(name: impl Into<String>) -> Self {
VPort {
handle: Handle::NULL,
name: name.into(),
lower_left: Vector2::ZERO,
upper_right: Vector2::new(1.0, 1.0),
view_center: Vector2::ZERO,
snap_base: Vector2::ZERO,
snap_spacing: Vector2::new(0.5, 0.5),
grid_spacing: Vector2::new(10.0, 10.0),
view_direction: Vector3::UNIT_Z,
view_target: Vector3::ZERO,
view_height: 10.0,
aspect_ratio: 1.0,
lens_length: 50.0,
view_twist: 0.0,
front_clip: 0.0,
back_clip: 0.0,
ucsfollow: false,
circle_zoom: 100,
fast_zoom: true,
grid_on: false,
snap_on: false,
snap_style: false,
snap_isopair: 0,
snap_rotation: 0.0,
}
}
pub fn active() -> Self {
Self::new("*Active")
}
}
impl TableEntry for VPort {
fn handle(&self) -> Handle {
self.handle
}
fn set_handle(&mut self, handle: Handle) {
self.handle = handle;
}
fn name(&self) -> &str {
&self.name
}
fn set_name(&mut self, name: String) {
self.name = name;
}
fn is_standard(&self) -> bool {
self.name == "*Active"
}
}