graph: Remove width from loose seg weights, add it to fixed bend weights

This commit is contained in:
Mikolaj Wielgus 2023-10-27 08:41:03 +00:00
parent 3619c5eab4
commit fae2ada334
3 changed files with 9 additions and 5 deletions

View File

@ -262,7 +262,12 @@ impl<'a> Draw<'a> {
let bend = self
.layout
.add_fixed_bend(head.dot, bend_to, around, FixedBendWeight { net, cw })
.add_fixed_bend(
head.dot,
bend_to,
around,
FixedBendWeight { net, width, cw },
)
.map_err(|err| {
self.layout.remove(bend_to.into());
self.undo_seg(head, seg);

View File

@ -171,7 +171,6 @@ impl SegWeight for FixedSegWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct HalfLooseSegWeight {
pub net: i64,
pub width: f64,
}
impl_type!(HalfLooseSegWeight, HalfLooseSeg, HalfLooseSegIndex);
@ -180,7 +179,6 @@ impl SegWeight for HalfLooseSegWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FullyLooseSegWeight {
pub net: i64,
pub width: f64,
}
impl_type!(FullyLooseSegWeight, FullyLooseSeg, FullyLooseSegIndex);
@ -191,6 +189,7 @@ pub trait BendWeight: GetNet + Into<Weight> + Copy {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedBendWeight {
pub net: i64,
pub width: f64,
pub cw: bool,
}

View File

@ -267,7 +267,7 @@ impl<'a> MakeShape for HalfLooseSeg<'a> {
Shape::Seg(SegShape {
from: self.primitive(ends.0).weight().circle.pos,
to: self.primitive(ends.1).weight().circle.pos,
width: self.weight().width,
width: self.primitive(ends.1).weight().circle.r * 2.0,
})
}
}
@ -293,7 +293,7 @@ impl<'a> MakeShape for FullyLooseSeg<'a> {
Shape::Seg(SegShape {
from: self.primitive(ends.0).weight().circle.pos,
to: self.primitive(ends.1).weight().circle.pos,
width: self.weight().width,
width: self.primitive(ends.1).weight().circle.r * 2.0,
})
}
}