17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-30 09:40:29 +01:00

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.
This commit is contained in:
maj00r
2026-10-21 11:47:25 +02:00
parent 19b7364bca
commit 825c91705d
7 changed files with 28 additions and 8 deletions

View File

@@ -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;

View File

@@ -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};

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)};

View File

@@ -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;

View File

@@ -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"