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 let bend = self
.layout .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| { .map_err(|err| {
self.layout.remove(bend_to.into()); self.layout.remove(bend_to.into());
self.undo_seg(head, seg); self.undo_seg(head, seg);

View File

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

View File

@ -267,7 +267,7 @@ impl<'a> MakeShape for HalfLooseSeg<'a> {
Shape::Seg(SegShape { Shape::Seg(SegShape {
from: self.primitive(ends.0).weight().circle.pos, from: self.primitive(ends.0).weight().circle.pos,
to: self.primitive(ends.1).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 { Shape::Seg(SegShape {
from: self.primitive(ends.0).weight().circle.pos, from: self.primitive(ends.0).weight().circle.pos,
to: self.primitive(ends.1).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,
}) })
} }
} }