refactor(geometry): merge GetPos and SetPos

This commit is contained in:
Alain Emilia Anna Zscheile 2025-01-03 01:04:18 +01:00 committed by mikolaj
parent babe531f73
commit 699bd58949
4 changed files with 8 additions and 16 deletions

View File

@ -14,7 +14,7 @@ use crate::{
rules::AccessRules,
Drawing,
},
geometry::{AccessDotWeight, GetPos, GetWidth, SetPos},
geometry::{AccessDotWeight, GetSetPos, GetWidth},
graph::{GenericIndex, GetPetgraphIndex},
math::Circle,
};
@ -47,7 +47,7 @@ impl TryFrom<PrimitiveIndex> for DotIndex {
}
}
#[enum_dispatch(GetPos, SetPos, GetWidth, GetLayer)]
#[enum_dispatch(GetSetPos, GetWidth, GetLayer)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DotWeight {
Fixed(FixedDotWeight),
@ -87,13 +87,11 @@ pub struct FixedDotWeight {
impl_fixed_weight!(FixedDotWeight, FixedDot, FixedDotIndex);
impl AccessDotWeight<PrimitiveWeight> for FixedDotWeight {}
impl GetPos for FixedDotWeight {
impl GetSetPos for FixedDotWeight {
fn pos(&self) -> Point {
self.circle.pos
}
}
impl SetPos for FixedDotWeight {
fn set_pos(&mut self, pos: Point) {
self.circle.pos = pos
}
@ -115,13 +113,11 @@ pub struct LooseDotWeight {
impl_loose_weight!(LooseDotWeight, LooseDot, LooseDotIndex);
impl AccessDotWeight<PrimitiveWeight> for LooseDotWeight {}
impl GetPos for LooseDotWeight {
impl GetSetPos for LooseDotWeight {
fn pos(&self) -> Point {
self.circle.pos
}
}
impl SetPos for LooseDotWeight {
fn set_pos(&mut self, pos: Point) {
self.circle.pos = pos
}

View File

@ -16,7 +16,7 @@ use crate::geometry::{
recording_with_rtree::RecordingGeometryWithRtree,
with_rtree::BboxedIndex,
AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel,
GetOffset, GetPos, GetWidth,
GetOffset, GetSetPos, GetWidth,
};
use crate::graph::{GenericIndex, GetPetgraphIndex};
use crate::math::NoTangents;

View File

@ -32,12 +32,8 @@ use crate::{
};
#[enum_dispatch]
pub trait GetPos {
pub trait GetSetPos {
fn pos(&self) -> Point;
}
#[enum_dispatch]
pub trait SetPos {
fn set_pos(&mut self, pos: Point);
}
@ -70,7 +66,7 @@ pub enum GenericNode<P, C> {
Compound(C),
}
pub trait AccessDotWeight<PW>: GetPos + SetPos + GetWidth + Into<PW> + Copy {}
pub trait AccessDotWeight<PW>: GetSetPos + GetWidth + Into<PW> + Copy {}
pub trait AccessSegWeight<PW>: GetWidth + Into<PW> + Copy {}
pub trait AccessBendWeight<PW>: GetOffset + SetOffset + GetWidth + Into<PW> + Copy {}

View File

@ -17,7 +17,7 @@ use crate::{
seg::SegIndex,
Drawing,
},
geometry::GetPos,
geometry::GetSetPos,
graph::{GenericIndex, GetPetgraphIndex},
layout::CompoundWeight,
};