Skip to content

Commit

Permalink
Support no-pax for abandoned lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
partim committed Nov 8, 2024
1 parent 77c9581 commit 64a880b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/railway/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ impl Railway {
self.pax.unwrap_or_default()
}

pub fn opt_pax(&self) -> Option<Pax> {
self.pax
}

pub fn gauge(&self) -> Gauge {
self.gauge.unwrap_or_default()
}
Expand Down
36 changes: 32 additions & 4 deletions src/railway/feature/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,17 @@ impl ContourShape2 {
fn pax_dash(
class: &TrackClass, outline: &Outline, style: &Style
) -> Option<DashPattern<2>> {
if !class.class.is_open() || class.class.pax().is_full() {
return None
// For historical reasons, a missing explicit pax defaults to no pax
// for open lines and full pax for closed ones.
if class.class.status().is_open() {
if class.class.pax().is_full() {
return None
}
}
else {
if class.class.opt_pax().unwrap_or(Pax::Full).is_full() {
return None
}
}

if matches!(class.class.pax(), Pax::None) {
Expand Down Expand Up @@ -348,13 +357,32 @@ impl<'a> Shape<'a> for ContourShape2 {
}
Stage::AbandonedBase => {
if !self.open {
canvas.sketch()
.apply(self.color)
canvas.sketch()
.apply(
if self.dash.is_some() {
Color::rgba(1., 1., 1., 0.8)
}
else {
self.color
}
)
.apply(LineWidth(self.width))
.apply(&self.outline)
.stroke()
}
}
Stage::AbandonedMarking => {
if !self.open {
if let Some(dash) = self.dash {
canvas.sketch()
.apply(self.color)
.apply(LineWidth(self.width))
.apply(dash)
.apply(&self.outline)
.stroke()
}
}
}
Stage::LimitedBase => {
if self.open && self.dash.is_some() {
canvas.sketch()
Expand Down

0 comments on commit 64a880b

Please sign in to comment.