use crate::types::{Handle, Vector2, Vector3};
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ObjectContextData {
pub handle: Handle,
pub owner_handle: Handle,
pub reactors: Vec<Handle>,
pub xdictionary_handle: Option<Handle>,
pub class_version: i16,
pub has_file_to_extension_dictionary: bool,
#[cfg_attr(feature = "serde", serde(default))]
pub uses_legacy_mleader_context_base: bool,
pub is_default: bool,
pub scale: Handle,
pub kind: ObjectContextKind,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ObjectContextKind {
AnnotScale,
BlkRef {
rotation: f64,
insertion: Vector3,
scale_factor: Vector3,
},
Text {
horizontal_mode: i16,
rotation: f64,
insertion: Vector2,
alignment: Vector2,
},
MText(MTextContext),
Dim(DimContext),
MLeader(crate::entities::multileader::MultiLeaderAnnotContext),
MTextAttribute(MTextAttributeContext),
Leader(LeaderContext),
Fcf {
location: Vector3,
horizontal_direction: Vector3,
},
HatchScale(HatchScaleContext),
HatchView(HatchViewContext),
Opaque,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct HatchScaleContext {
pub pattern_lines: Vec<crate::entities::HatchPatternLine>,
pub pattern_scale: f64,
pub pattern_base: Vector3,
pub loops: Vec<HatchLoopContext>,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct HatchLoopContext {
pub loop_type: i32,
pub supports_context: bool,
pub boundary: Option<crate::entities::BoundaryPath>,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct HatchViewContext {
pub hatch: HatchScaleContext,
pub view: Handle,
pub view_normal: Vector3,
pub view_rotation: f64,
pub evaluate_hatch: bool,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MTextContext {
pub attachment: i32,
pub x_axis_dir: Vector3,
pub insertion: Vector3,
pub rect_width: f64,
pub rect_height: f64,
pub extents_width: f64,
pub extents_height: f64,
pub column_type: i32,
pub columns: Option<MTextColumns>,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MTextAttributeContext {
pub horizontal_mode: i16,
pub rotation: f64,
pub insertion: Vector2,
pub alignment: Vector2,
pub enable_context: bool,
pub context: Option<EmbeddedMTextContext>,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct EmbeddedMTextContext {
pub owner_handle: Handle,
pub reactors: Vec<Handle>,
pub xdictionary_handle: Option<Handle>,
pub has_binary_data: bool,
pub class_version: i16,
pub has_file_to_extension_dictionary: bool,
pub is_default: bool,
pub scale: Handle,
pub mtext: MTextContext,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LeaderContext {
pub points: Vec<Vector3>,
pub x_direction: Vector3,
pub annotation_enabled: bool,
pub insertion_offset: Vector3,
pub endpoint_projection: Vector3,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimContext {
pub def_pt: Vector2,
pub is_def_textloc: bool,
pub text_rotation: f64,
pub block: Handle,
pub b293: bool,
pub dimtofl: bool,
pub dimosxd: bool,
pub dimatfit: bool,
pub dimtix: bool,
pub dimtmove: bool,
pub override_code: u8,
pub has_arrow2: bool,
pub flip_arrow2: bool,
pub flip_arrow1: bool,
pub subtype: DimSubtype,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum DimSubtype {
Aligned { dimline_pt: Vector3 },
Angular { arc_pt: Vector3 },
Diametric {
first_arc_pt: Vector3,
def_pt: Vector3,
},
Radial { first_arc_pt: Vector3 },
RadialLarge {
ovr_center: Vector3,
jog_point: Vector3,
},
Ordinate {
feature_location_pt: Vector3,
leader_endpt: Vector3,
},
}
impl DimSubtype {
pub fn class_name(&self) -> &'static str {
match self {
DimSubtype::Aligned { .. } => "ACDB_ALDIMOBJECTCONTEXTDATA_CLASS",
DimSubtype::Angular { .. } => "ACDB_ANGDIMOBJECTCONTEXTDATA_CLASS",
DimSubtype::Diametric { .. } => "ACDB_DMDIMOBJECTCONTEXTDATA_CLASS",
DimSubtype::Radial { .. } => "ACDB_RADIMOBJECTCONTEXTDATA_CLASS",
DimSubtype::RadialLarge { .. } => "ACDB_RADIMLGOBJECTCONTEXTDATA_CLASS",
DimSubtype::Ordinate { .. } => "ACDB_ORDDIMOBJECTCONTEXTDATA_CLASS",
}
}
pub fn subclass_marker(&self) -> &'static str {
match self {
DimSubtype::Aligned { .. } => "AcDbAlignedDimensionObjectContextData",
DimSubtype::Angular { .. } => "AcDbAngularDimensionObjectContextData",
DimSubtype::Diametric { .. } => "AcDbDiametricDimensionObjectContextData",
DimSubtype::Radial { .. } => "AcDbRadialDimensionObjectContextData",
DimSubtype::RadialLarge { .. } => "AcDbRadialDimensionLargeObjectContextData",
DimSubtype::Ordinate { .. } => "AcDbOrdinateDimensionObjectContextData",
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MTextColumns {
pub num_heights: i32,
pub width: f64,
pub gutter: f64,
pub auto_height: bool,
pub flow_reversed: bool,
pub heights: Vec<f64>,
}
impl ObjectContextData {
pub fn class_name(&self) -> &'static str {
match &self.kind {
ObjectContextKind::AnnotScale => "ACDB_ANNOTSCALEOBJECTCONTEXTDATA_CLASS",
ObjectContextKind::BlkRef { .. } => "ACDB_BLKREFOBJECTCONTEXTDATA_CLASS",
ObjectContextKind::Text { .. } => "ACDB_TEXTOBJECTCONTEXTDATA_CLASS",
ObjectContextKind::MText(_) => "ACDB_MTEXTOBJECTCONTEXTDATA_CLASS",
ObjectContextKind::Dim(d) => d.subtype.class_name(),
ObjectContextKind::MLeader(_) => "ACDB_MLEADEROBJECTCONTEXTDATA_CLASS",
ObjectContextKind::MTextAttribute(_) => "ACDB_MTEXTATTRIBUTEOBJECTCONTEXTDATA_CLASS",
ObjectContextKind::Leader(_) => "ACDB_LEADEROBJECTCONTEXTDATA_CLASS",
ObjectContextKind::Fcf { .. } => "ACDB_FCFOBJECTCONTEXTDATA_CLASS",
ObjectContextKind::HatchScale(_) => "ACDB_HATCHSCALECONTEXTDATA_CLASS",
ObjectContextKind::HatchView(_) => "ACDB_HATCHVIEWCONTEXTDATA_CLASS",
ObjectContextKind::Opaque => "ACDB_OBJECTCONTEXTDATA_CLASS",
}
}
}