Skip to main content

acadrust/tables/
vx.rs

1use crate::tables::TableEntry;
2use crate::types::Handle;
3
4/// Legacy viewport-entity table record (VX_TABLE_RECORD / VPENT_HDR).
5///
6/// ACAD persisted this table from R13 through R2000.  Each record links a
7/// viewport entity to the previous viewport-entry record in the chain.
8#[derive(Debug, Clone, PartialEq)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10pub struct VxTableRecord {
11    pub handle: Handle,
12    pub name: String,
13    pub is_xref_reference: bool,
14    pub is_xref_resolved: bool,
15    pub is_xref_dependent: bool,
16    pub xref_handle: Handle,
17    pub is_on: bool,
18    pub viewport: Handle,
19    pub previous_entry: Handle,
20    /// R11 object address. Not present in the R13+ formats supported here.
21    pub legacy_viewport_entity_address: u16,
22    /// R11 viewport table index. Not present in the R13+ formats supported here.
23    pub legacy_viewport_index: i16,
24    /// R11 previous-entry index. Not present in the R13+ formats supported here.
25    pub legacy_previous_entry_index: i16,
26}
27
28impl VxTableRecord {
29    pub fn new(name: impl Into<String>) -> Self {
30        Self {
31            handle: Handle::NULL,
32            name: name.into(),
33            is_xref_reference: false,
34            is_xref_resolved: false,
35            is_xref_dependent: false,
36            xref_handle: Handle::NULL,
37            is_on: false,
38            viewport: Handle::NULL,
39            previous_entry: Handle::NULL,
40            legacy_viewport_entity_address: 0,
41            legacy_viewport_index: 0,
42            legacy_previous_entry_index: 0,
43        }
44    }
45}
46
47impl Default for VxTableRecord {
48    fn default() -> Self {
49        Self::new("")
50    }
51}
52
53impl TableEntry for VxTableRecord {
54    fn handle(&self) -> Handle {
55        self.handle
56    }
57
58    fn set_handle(&mut self, handle: Handle) {
59        self.handle = handle;
60    }
61
62    fn name(&self) -> &str {
63        &self.name
64    }
65
66    fn set_name(&mut self, name: String) {
67        self.name = name;
68    }
69}