mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-29 05:16:49 -06:00
This commit is contained in:
@@ -142,12 +142,14 @@ impl Drawing {
|
||||
d.header = Header::imperial();
|
||||
d
|
||||
}
|
||||
/// An empty metric drawing (millimetres, ISO-25 dimensions).
|
||||
/// An empty metric drawing (millimetres, ISO-25 dimensions, multileaders and tables to match).
|
||||
pub fn new_metric() -> Self {
|
||||
let mut d = Drawing::bare();
|
||||
d.header = Header::metric();
|
||||
d.scales = metric_scales();
|
||||
d.dim_styles.push(DimStyle::iso25());
|
||||
d.mleader_styles = vec![MLeaderStyle::metric()];
|
||||
d.table_styles = vec![TableStyle::metric()];
|
||||
d.header.set_str("DIMSTYLE", "ISO-25");
|
||||
d
|
||||
}
|
||||
|
||||
@@ -616,6 +616,13 @@ impl Default for MLeaderStyle {
|
||||
}
|
||||
}
|
||||
|
||||
impl MLeaderStyle {
|
||||
/// The Standard style for metric drawings: text and arrows as high as ISO-25's.
|
||||
pub fn metric() -> Self {
|
||||
MLeaderStyle { arrow_size: 2.5, text_height: 2.5, landing_gap: 0.625, dogleg: 5.0, ..Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
pub struct TableStyle {
|
||||
@@ -636,6 +643,13 @@ impl Default for TableStyle {
|
||||
}
|
||||
}
|
||||
|
||||
impl TableStyle {
|
||||
/// The Standard style for metric drawings: text as high as ISO-25's.
|
||||
pub fn metric() -> Self {
|
||||
TableStyle { text_height: 2.5, margin: 1.0, ..Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
mod cellstyle;
|
||||
mod tablebreak;
|
||||
pub use cellstyle::*;
|
||||
|
||||
@@ -16,6 +16,23 @@ fn new_drawing_has_standard_tables() {
|
||||
assert!(m.dim_style("ISO-25").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_metric_drawing_has_metric_multileader_and_table_styles() {
|
||||
let m = Drawing::new_metric();
|
||||
let iso = m.dim_style("ISO-25").unwrap();
|
||||
let ml = m.mleader_styles.iter().find(|s| s.name == "Standard").unwrap();
|
||||
assert_eq!((ml.text_height, ml.arrow_size), (iso.text_height, iso.arrow_size));
|
||||
assert_eq!(ml.dogleg, 5.0);
|
||||
let ts = m.table_styles.iter().find(|s| s.name == "Standard").unwrap();
|
||||
assert_eq!(ts.text_height, iso.text_height);
|
||||
assert_eq!(iso.text_height, 2.5);
|
||||
|
||||
let i = Drawing::new_imperial();
|
||||
assert_eq!(i.mleader_styles, vec![MLeaderStyle::default()]);
|
||||
assert_eq!(i.table_styles, vec![TableStyle::default()]);
|
||||
assert_eq!((i.mleader_styles[0].text_height, i.table_styles[0].text_height), (0.18, 0.18));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_and_extents() {
|
||||
let mut d = Drawing::new_imperial();
|
||||
|
||||
Reference in New Issue
Block a user