17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 09:12:08 +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

@@ -3159,6 +3159,33 @@ TTrack *editor_track::create_switch(switch_template const &Template, std::vector
return track;
}
TTrack *editor_track::create_switch(switch_template const &Template, std::vector<segment_data> const &Paths, path_style const &Style, std::string const &Name)
{
if (Paths.size() < 2)
return nullptr;
if (Template.source != nullptr)
return create_switch(Template, Paths, *Template.source, Name);
std::ostringstream text;
text.precision(std::numeric_limits<double>::digits10);
// the rails of the style on both paths, its ballast under the switch
text << "switch " << Template.length << " 1.435 0.15 10 20 0 flat vis " << Style.rail << " 6 " << Style.rail << " 0.2 0.5 1.1 ";
write_points(text, Paths[0]);
write_points(text, Paths[1]);
text << "trackbed " << Style.ballast << ' ';
if (Style.velocity > 0.0)
text << "velocity " << Style.velocity << ' ';
if (false == Style.rail_profile.empty())
text << "railprofile " << Style.rail_profile << ' ';
text << "endtrack\n";
auto *track{load_text(text.str(), nullptr, Name)};
track->SwitchExtension->m_frogs = true;
track->SwitchExtension->m_movablenose = Template.movable;
track->SwitchExtension->m_bladeheel = Template.heel;
track->SwitchExtension->m_bladethrow = Template.bladethrow;
track->m_paths.assign(Paths.begin(), Paths.begin() + 2);
return track;
}
bool editor_track::touches(TTrack const &Track, glm::dvec3 const &Point)
{
for (auto const &path : Track.m_paths)

View File

@@ -512,6 +512,8 @@ class editor_track
static glm::dvec3 point_at(TTrack const &Track, double const T);
static std::vector<segment_data> place_switch(switch_template const &Template, glm::dvec3 const &Origin, glm::dvec2 const &Direction, int const Side, double const Grade);
static TTrack *create_switch(switch_template const &Template, std::vector<segment_data> const &Paths, TTrack const &Style, std::string const &Name = {});
// one laid where there's no track to copy, styled as the lay tool lays its tracks
static TTrack *create_switch(switch_template const &Template, std::vector<segment_data> const &Paths, path_style const &Style, std::string const &Name = {});
static TTrack *create_turntable(segment_data const &Path, TTrack const *Style, std::string const &Name);
static void move_straights(std::vector<straight> const &Lines, std::vector<std::pair<glm::dvec3, glm::dvec3>> const &Ends);
// Intervals: the path of the chain each piece takes the place of, else they're handed out in turn