17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-02 23:16:22 +01:00

feat(editor): a switch laid with no track there, and no switch laid by a click: a press on the ground with a switch armed lays the switch there, its start where it was pressed, the direction of its main track taken from the drag once it's 4 m long and held, the drag sideways then giving the side of the diverging track, back by the start the direction free again; pressed by a free end within 5 m it goes on from that end in its direction and grade, joined to it. Its ends are left free to lay on from, styled after the track it goes on from or as the lay tool lays its tracks (editor_track::create_switch with a path_style). A press let go within 10 pixels places no switch, a slip at a crossing included, which was laid at once on the press: it's laid once dragged, its straights shown meanwhile. The hints and the panel tell of both. Selftest switchfree: Rz 60E1-300-1:9 on the ground with its four ends free, from the free end of a straight joined and walked through; a click on a straight laid none, a drag laid z1

This commit is contained in:
maj00r
2026-10-27 19:33:23 +01:00
parent 1340017be3
commit f8a12107a0
12 changed files with 342 additions and 15 deletions

View File

@@ -481,6 +481,49 @@ editor_mode::selftest_result editor_mode::selftest_switch(std::string const &com
model->location().x, model->location().y, model->location().z, path.points[segment_data::point::start].y));
return selftest_result::handled;
}
if (command == "switchfree")
{
// a switch with no track: pressed at the point, the direction of its main track toward the second one (none at a free end), let
// go at the third one, whose side it takes
std::string label;
glm::dvec3 press{0.0};
glm::dvec3 heading{0.0};
glm::dvec3 release{0.0};
words >> label >> press.x >> press.z >> heading.x >> heading.z >> release.x >> release.z;
std::replace(label.begin(), label.end(), '_', ' ');
auto &tool{m_switch};
show_track_tab(track_tab::turnout);
tool.templates = editor_track::standard_switch_templates();
tool.collected = true;
tool.connection = -1;
tool.armed = -1;
for (int i = 0; i < static_cast<int>(tool.templates.size()); ++i)
if (tool.templates[i].label.rfind(label, 0) == 0)
{
tool.armed = i;
break;
}
start_free_switch(press);
if (false == tool.placing)
{
WriteLog("SELFTEST switchfree: not started, no template " + label);
return selftest_result::handled;
}
if (tool.free_end.track == nullptr)
tool.free_heading = glm::normalize(geometry::plan_of(heading - tool.point));
tool.mouse = glm::dvec3{release.x, tool.point.y, release.z};
tool.placing = false;
finish_switch_placement();
WriteLog("SELFTEST switchfree" + (tool.free_end.track != nullptr ? " from " + tool.free_end.track->name() : std::string{}) + ": " + tool.status);
if (auto const *track{selected_track()}; track != nullptr && track->eType == tt_Switch)
for (std::size_t i = 0; i < track->m_paths.size(); ++i)
{
auto const &a{track->m_paths[i].points[segment_data::point::start]};
auto const &b{track->m_paths[i].points[segment_data::point::end]};
WriteLog(format("SELFTEST switchfree path %s/%zu: %.3f %.3f %.3f -> %.3f %.3f %.3f", track->name().c_str(), i, a.x, a.y, a.z, b.x, b.y, b.z));
}
return selftest_result::handled;
}
if (command == "switchplace" || command == "switchcurve" || command == "slipplace")
{
std::string label;