18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 05:02:45 +01:00

fix(editor): track edits keep the joints, the norms, the records and the saved speed together

- The cant typed in the inspector goes on into the track joined at that end, as the gizmo and the
  joints tool do it; the neighbours go into the same undo step. The joint stepped before.
- A track laid on from a canted joint takes the cant off along the ramp the norms ask for at the
  speed (`alignment::cant_ramp_length`), not at a fixed 1.5 mm a metre whatever the speed and the
  norms: 120 mm at 100 km/h over 120 m, not 80 m.
- Deleting a track of the line under the route tool keeps the laying norms. They went back to the
  defaults, and every later lay, extend and join used those.
- The gauge is a paste group of its own, off by default: pasting how a track rides or sounds no
  longer changes its gauge.
- The speed of a turntable set in the editor is the one saved. The editor changed the speed the
  turntable runs at, while the file keeps the limit it was loaded with.
- Deleting a set of tracks does what Del does with each: a double switch, a slip and a crossover go
  whole, the records of the switches go with them, and the model and events of a turntable too. The
  records stayed behind and on saving were given to another switch, which then showed a wrong type.
- Deleting a switch of a crossover takes the crossover out whole, as the connection tools do: the
  outer track of a crossover on a curve comes down by its lift and the record of the connection
  goes. Alone, the switch left the outer track up for good, and the connection to the next switch
  given its name. A switch bent out of the shape of its record is found by its name.

Tests: a unit test of the norm ramp. The other changes are in the editor's UI, which the unit tests
don't reach.
This commit is contained in:
maj00r
2026-11-23 01:31:37 +01:00
parent f15ea40575
commit c813c03865
9 changed files with 211 additions and 22 deletions
+24
View File
@@ -1162,3 +1162,27 @@ TEST_CASE("alignment: a curve traced on from a switch goes on at its radius, not
CHECK(two.vertices.front().arcs.front().radius == doctest::Approx(600.0).epsilon(0.1));
CHECK(two.rms < 0.1);
}
TEST_CASE("alignment: the cant ramp the norms ask for, which a track laid on from a canted joint takes its cant off along") {
alignment::limits const norms;
// no change, no ramp
CHECK(alignment::cant_ramp_length(100.0, 0.0, norms) == doctest::Approx(0.0));
// 120 mm at 100 km/h: along the track 0.12 * 10 * 100 = 120 m, longer than in time (100 * 120 / (3.6 * 35) = 95.2 m). The lay tool
// used to take any cant off at a fixed 1.5 mm a metre, over 80 m here, whatever the speed and the norms
CHECK(alignment::cant_ramp_length(100.0, 120.0, norms) == doctest::Approx(120.0));
// the cant taken off or put on alike
CHECK(alignment::cant_ramp_length(100.0, -120.0, norms) == doctest::Approx(120.0));
// slower, shorter: 0.12 * 10 * 40 = 48 m, to whole 5 m
CHECK(alignment::cant_ramp_length(40.0, 120.0, norms) == doctest::Approx(50.0));
// the norms of the route tool count: a gentler factor leaves the time the longer, 95.2 m to 100 m
auto gentle{norms};
gentle.ramp_factor = 5.0;
CHECK(alignment::cant_ramp_length(100.0, 120.0, gentle) == doctest::Approx(100.0));
// the ramp is never shorter at a higher speed
double previous{0.0};
for (double speed = 20.0; speed <= 200.0; speed += 10.0) {
auto const length{alignment::cant_ramp_length(speed, 80.0, norms)};
CHECK(length >= previous);
previous = length;
}
}