17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-29 13:57:28 +01:00

feat(editor,track): a cant ramp of its own, off the transition curve: each end of a curve may have its ramp moved and of a length of its own (ST-T1-A6 9.6 pkt 5 and 11), on the straight before the curve or on the arc, the transition keeping the full cant all along, as a switch laid on it wants it; set in the plan under "Cant ramps", stored with the vertex as "ramps", reversed with the curve, marked across the track in the view. The cant of a line is a profile along it now, the paths cut where a ramp of its own starts and ends, their rolls following it, warnings where a ramp is shorter than its cant asks for or reaches into the curve before, past the line or over the other ramp. A switch on a cant ramp is drawn following it: its rails, blades, frogs and bed made at the mean of its rolls, as before, are turned along each path to the roll of the path there, so it no longer steps at its ends against the tracks either side. The checks of a switch laid into a curve warn of the values of table 11.9 in brackets as of the others, with no word of a consent. Unit test of a ramp moved onto the straight

This commit is contained in:
maj00r
2026-10-25 00:54:50 +02:00
parent ece61056ff
commit e43863932d
12 changed files with 384 additions and 33 deletions

View File

@@ -1227,6 +1227,22 @@ void editor_mode::draw_route_overlay() const
previous = next;
}
}
// the cant ramps: their ends across the track, the ones moved off the transitions brighter, with how the cant goes along them
for (auto const &ramp : result.ramps)
{
if (ramp.cant < 0.5)
continue;
auto const colour{ramp.own ? IM_COL32(255, 170, 40, 255) : IM_COL32(255, 170, 40, 120)};
for (auto const end : {ramp.from, ramp.to})
{
auto const station{alignment::evaluate(result, end)};
glm::dvec3 const across{-station.direction.z * 2.0, 0.0, station.direction.x * 2.0};
projection.line(drawlist, station.position - across, station.position + across, colour, 3.0f);
}
ImVec2 screen;
if (ramp.own && projection.project(alignment::evaluate(result, (ramp.from + ramp.to) * 0.5).position, screen))
drawlist->AddText({screen.x + 8.0f, screen.y + 6.0f}, colour, format(STR_C("ramp %.0f m, %.0f mm"), ramp.to - ramp.from, ramp.cant).c_str());
}
// the part of the curve whose fields are pointed at or edited in the panel, lit up and named
if (auto const focused{route_focused()}; false == focused.empty())
{
@@ -2161,6 +2177,47 @@ bool editor_mode::render_route_vertex(int const Index)
mark(part::whole, 0);
}
}
// the cant ramps at the ends of the curve: along its transitions, or where they're put, off a switch laid on a transition say
if (false == vertex.spirals && ImGui::TreeNode(STR_C("Cant ramps")))
{
std::vector<alignment::result::cant_ramp> ramps;
for (auto const &ramp : route.result.ramps)
if (ramp.vertex == Index)
ramps.push_back(ramp);
auto const ramp = [&](char const *Id, char const *Label, double &Offset, double &Length, std::size_t const Which, part const What) {
ImGui::PushID(Id);
auto along{Length < 0.0};
if (ImGui::Checkbox(Label, &along))
{
// let go of the transition where it lay along it, to be moved from there
Length = along ? -1.0 : Which < ramps.size() ? ramps[Which].to - ramps[Which].from : 0.0;
Offset = 0.0;
changed = true;
}
mark(What, 0);
item_tooltip("The norms recommend the cant ramp along the transition curve; off it, it may lie on the straight before the curve or on the arc, a switch on the transition keeping the same cant all along");
if (false == along)
{
ImGui::SetNextItemWidth(half);
changed |= ImGui::DragScalar("##offset", ImGuiDataType_Double, &Offset, 0.5f, nullptr, nullptr, STR_C("into the curve %.1f m"));
mark(What, 0);
item_tooltip("How far the outer end of the ramp lies into the curve from its end, below 0 out along the straight before it");
ImGui::SameLine();
ImGui::SetNextItemWidth(half);
changed |= ImGui::DragScalar("##length", ImGuiDataType_Double, &Length, 0.5f, nullptr, nullptr, STR_C("length %.1f m"));
mark(What, 0);
item_tooltip("The length of the ramp, the cant rising evenly along it");
Length = std::max(0.0, Length);
}
if (Which < ramps.size() && ramps[Which].to > ramps[Which].from)
ImGui::TextDisabled(STR_C("km %s - %s, %.2f mm/m"), profile::format_chainage(route.origin + ramps[Which].from).c_str(), profile::format_chainage(route.origin + ramps[Which].to).c_str(),
ramps[Which].cant / (ramps[Which].to - ramps[Which].from));
ImGui::PopID();
};
ramp("in", STR_C("Ramp in along the transition curve"), vertex.ramp_in_offset, vertex.ramp_in_length, 0, part::entry);
ramp("out", STR_C("Ramp out along the transition curve"), vertex.ramp_out_offset, vertex.ramp_out_length, 1, part::exit);
ImGui::TreePop();
}
if (ImGui::TreeNode(STR_C("Details")))
{
for (auto const &curve : route.result.curves)

View File

@@ -1480,8 +1480,6 @@ void editor_mode::insert_curved_switch(int const Direction, int const Side)
if (made.size() == 1)
tool.status = format(STR_C("Switch %s inserted into the curve, Ctrl+Z takes it back"), made.front()->name().c_str());
// what the norms say of it stays in the status
if (report.transition)
tool.status += "\n" + report.notes.front();
for (auto const &warning : report.warnings)
tool.status += "\n" + warning;
auto const placed{created};