From 825c91705d603d27959a815d68f6b959060fbadf Mon Sep 17 00:00:00 2001 From: maj00r Date: Wed, 21 Oct 2026 11:47:25 +0200 Subject: [PATCH] fix(editor): the free design gets no transition curves from the Plan tools Dragging an end of a straight refits the curve next to it with the cant and the transition curves recommended for the speed, keeping the curve's own only where it had some; a plain arc laid freely came out with transitions. Break and S-curve took the recommended transitions too. The recommendation of a design not checked against the norms is a plain arc now, the tools take the norms in effect rather than the ones the design was last computed with, and the Plan panel calls the automatic choice "None" in the free design. Self-test: norms free|plk. --- application/editormode.h | 1 + application/editormodelay.cpp | 13 +++++++++---- application/editormoderoute.cpp | 2 +- application/editormodeselftestjoin.cpp | 8 ++++++++ application/editormodestraights.cpp | 7 ++++--- editor/editorAlignment.cpp | 2 ++ lang/editor_pl.po | 3 +++ 7 files changed, 28 insertions(+), 8 deletions(-) diff --git a/application/editormode.h b/application/editormode.h index 974111b1..69c0bfa5 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -1294,6 +1294,7 @@ class editor_mode : public application_mode, private editor_track::observer, pri bool m_norms_free{true}; alignment::limits laying_norms() const; bool render_norms_choice(); + void set_norms_free(bool const Free); glm::dvec3 lay_angle_snap(glm::dvec3 const &Mouse, std::string &Label) const; // the straight track Alt turns the laid straight to: the nearest one the straight from From to To crosses, or one along From TTrack const *skew_reference(glm::dvec3 const &From, glm::dvec3 const &To, double const Reach) const; diff --git a/application/editormodelay.cpp b/application/editormodelay.cpp index 56cae9f1..8dd852d2 100644 --- a/application/editormodelay.cpp +++ b/application/editormodelay.cpp @@ -1344,17 +1344,22 @@ bool editor_mode::render_norms_choice() : "Transition curves and cant for the design speed, warnings when the radius, the cant or the transitions don't meet the norms"); if (clicked && false == chosen) { - m_norms_free = i == 0; - m_lay.transitions = false == m_norms_free; + set_norms_free(i == 0); changed = true; } } ImGui::PopID(); - if (changed && false == m_route.chain.tracks.empty()) - route_update(); return changed; } +void editor_mode::set_norms_free(bool const Free) +{ + m_norms_free = Free; + m_lay.transitions = false == m_norms_free; + if (false == m_route.chain.tracks.empty()) + route_update(); +} + void editor_mode::render_lay_ui() { auto &tool{m_lay}; diff --git a/application/editormoderoute.cpp b/application/editormoderoute.cpp index de674d14..f6d7de55 100644 --- a/application/editormoderoute.cpp +++ b/application/editormoderoute.cpp @@ -52,7 +52,7 @@ bool editor_mode::route_active() const void editor_mode::route_recommend(alignment::vertex &Vertex) const { - auto const recommended{alignment::recommend(m_route.design.speed, Vertex.radius, m_route.design.norms)}; + auto const recommended{alignment::recommend(m_route.design.speed, Vertex.radius, laying_norms())}; Vertex.cant = recommended.cant; Vertex.transition_in = recommended.transition; Vertex.transition_out = recommended.transition; diff --git a/application/editormodeselftestjoin.cpp b/application/editormodeselftestjoin.cpp index f5ac36d8..f645c522 100644 --- a/application/editormodeselftestjoin.cpp +++ b/application/editormodeselftestjoin.cpp @@ -122,6 +122,14 @@ editor_mode::selftest_result editor_mode::selftest_join(std::string const &comma WriteLog(format("SELFTEST %s end: %.3f m from the target", command.c_str(), geometry::plan_distance(previous, b))); return selftest_result::handled; } + if (command == "norms") + { + std::string which; + words >> which; + set_norms_free(which != "plk"); + WriteLog(std::string{"SELFTEST norms: "} + (m_norms_free ? "free" : "plk")); + return selftest_result::handled; + } if (command == "tracktab") { std::string key; diff --git a/application/editormodestraights.cpp b/application/editormodestraights.cpp index 6c9fcdab..13a43cc9 100644 --- a/application/editormodestraights.cpp +++ b/application/editormodestraights.cpp @@ -442,7 +442,8 @@ void editor_mode::render_straight_ui() ImGui::TextDisabled("%s", STR_C("Transition curves")); int transitions{state.auto_transitions ? 0 : 1}; if (segmented("straighttransitions", transitions, - {{0, STR_C("From the line speed"), "Lengths of the transition curves from the speed of the paths and the limits of the curve design"}, + {m_norms_free ? segment_option{0, STR_C("None"), "Plain arcs: the free design has no transition curves, the PKP PLK norms work them out from the speed of the line"} + : segment_option{0, STR_C("From the line speed"), "Lengths of the transition curves from the speed of the paths and the limits of the curve design"}, {1, STR_C("Given length"), "The same length of the transition curves at every curve"}})) state.auto_transitions = transitions == 0; if (false == state.auto_transitions) @@ -1054,7 +1055,7 @@ void editor_mode::apply_straight_tool() double speed{-1.0}; for (auto const *track : line.tracks) speed = std::max(speed, editor_track::velocity(*track)); - auto const transition{state.auto_transitions ? alignment::recommend(speed > 0.0 ? speed : 100.0, radius, m_route.design.norms).transition : state.transition}; + auto const transition{state.auto_transitions ? alignment::recommend(speed > 0.0 ? speed : 100.0, radius, laying_norms()).transition : state.transition}; auto const reach{radius * std::tan(std::min(std::abs(angle), 3.0) * 0.5) + transition * 0.5 + 10.0}; straight_reshape(line, state.tool_at - reach, state.tool_at + reach, [pivot, angle](glm::dvec3 const &Point) { @@ -1182,7 +1183,7 @@ void editor_mode::apply_detour() double speed{-1.0}; for (auto const *track : line.tracks) speed = std::max(speed, editor_track::velocity(*track)); - auto const transition{state.auto_transitions ? alignment::recommend(speed > 0.0 ? speed : 100.0, radius, m_route.design.norms).transition : state.transition}; + auto const transition{state.auto_transitions ? alignment::recommend(speed > 0.0 ? speed : 100.0, radius, laying_norms()).transition : state.transition}; auto const reach{radius * std::tan(slope * 0.5) + transition * 0.5 + 5.0}; auto const from{std::max(0.0, stations[0] - reach)}; auto const to{std::min(line.length, stations[3] + reach)}; diff --git a/editor/editorAlignment.cpp b/editor/editorAlignment.cpp index 2b0d9d59..232bb9f4 100644 --- a/editor/editorAlignment.cpp +++ b/editor/editorAlignment.cpp @@ -275,6 +275,8 @@ recommendation recommend(double const Speed, double const Radius, limits const & return result; result.cant_equilibrium = factor * Speed * Speed / Radius; result.cant_min = std::max(0.0, result.cant_equilibrium - allowance); + if (false == Limits.checked) + return result; result.cant = std::min(Limits.cant_max, ceil_to(std::max(result.cant_min, result.cant_equilibrium * 2.0 / 3.0), 5.0)); result.transition = std::min(5000.0, transition_length(Speed, Radius, result.cant, Limits)); return result; diff --git a/lang/editor_pl.po b/lang/editor_pl.po index 8d7a78fa..101e467a 100644 --- a/lang/editor_pl.po +++ b/lang/editor_pl.po @@ -9997,3 +9997,6 @@ msgstr "Przechyłka (mm)" msgid "Cant at the start and at the end: how much higher one rail is, + raises the left rail looking along the path" msgstr "Przechyłka na początku i na końcu: o ile jedna szyna jest wyżej, + podnosi lewą szynę patrząc wzdłuż toru" + +msgid "Plain arcs: the free design has no transition curves, the PKP PLK norms work them out from the speed of the line" +msgstr "Zwykłe łuki: projekt wolny nie ma krzywych przejściowych, normy PKP PLK liczą je z prędkości linii"