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

feat(editor): switch templates by their geometry and a template editor: the diverging track is a chain of straights, arcs and transition curves from the start of the switch, with the pre-blade stretch and the angle of the blade at its tip; own templates are kept in eu07_switch_templates.txt and listed in the switch tool; double switches Rpd and Rpj are laid as two switches joined by the main track and handled as one set by sliding, replacing, flipping, the gizmo and deleting, with drives for both switches; self-test switchtemplates

This commit is contained in:
maj00r
2026-10-14 23:17:30 +02:00
parent ea341af27a
commit 52a289b15b
16 changed files with 2076 additions and 156 deletions

View File

@@ -725,6 +725,8 @@ class editor_mode : public application_mode, private editor_track::observer
void track_gizmo_take_switch_joints(TTrack &Track, bool const Controlmode);
track_gizmo_drag::switch_joint track_gizmo_link(TTrack &Track, editor_track::point_ref const &Own, std::pair<TTrack *, editor_track::point_ref> const &Connection, std::function<bool(TTrack const *)> const &Movable);
void track_gizmo_take_switches(TTrack &Track);
// the other switch of a double switch and the track between them go with the moved or turned switch as a whole
void track_gizmo_take_double(TTrack &Track);
void track_gizmo_measure_rotation(TTrack &Track, bool const Pointmode);
void track_gizmo_measure(TTrack &Track, bool const Pointmode, gizmo_operation const Operation);
void track_gizmo_begin(TTrack &Track, bool const Pointmode, gizmo_operation const Operation);
@@ -832,6 +834,19 @@ class editor_mode : public application_mode, private editor_track::observer
void route_read_stored(TTrack &Track);
void route_take_stored(int const Index);
void record_switch(TTrack &Track, editor_track::switch_template const &Shape);
void record_double(TTrack &First, TTrack &Second, editor_track::switch_template const &Shape);
// the two switches of a double switch and the plain track between them, found from any of the three
struct double_switch
{
TTrack *first{nullptr};
TTrack *link{nullptr};
TTrack *second{nullptr};
};
std::optional<double_switch> double_of(TTrack const &Track) const;
// the paths of the set in the order editor_track::place_switch gives them
static std::vector<segment_data> double_paths(double_switch const &Set);
// the switch of the template, or the two switches of a double one with the plain track between them, committed and recorded
std::vector<TTrack *> create_switch_set(editor_track::switch_template const &Shape, std::vector<segment_data> const &Paths, TTrack const &Style, std::string const &Name);
void record_slip(std::vector<TTrack *> const &Parts, std::string const &Kind, std::string const &Type, double const Radius, double const Angle, std::string const &Base);
void render_switch_record(TTrack const &Track) const;
void route_store();
@@ -978,6 +993,7 @@ class editor_mode : public application_mode, private editor_track::observer
double low{0.0};
double high{0.0};
double distance{0.0};
double length{0.0};
std::vector<double> joints;
};
slide_state slide;
@@ -987,6 +1003,9 @@ class editor_mode : public application_mode, private editor_track::observer
bool switch_room(TTrack &Track, double &Low, double &High, std::string &Reason);
bool switch_vacate(TTrack &Track, glm::dvec3 const &From, glm::dvec3 const &To, double const Shift, editor_track::straight const &Line, editor_track::edit &Edit, std::string &Status);
bool move_switch_paths(TTrack &Track, std::vector<segment_data> const &Paths, std::string &Status);
// room on the straight of the whole double switch along the axis of its first switch, and the length of the set
bool double_room(double_switch const &Set, double &Low, double &High, double &Length, std::string &Reason);
bool move_double_paths(double_switch const &Set, std::vector<segment_data> const &Paths, std::string &Status);
bool slide_switch(TTrack &Track, double const Distance);
bool switch_slides(TTrack const &Track) const;
void switch_slide_start(TTrack &Track);
@@ -1213,6 +1232,29 @@ class editor_mode : public application_mode, private editor_track::observer
int m_lineside_tab{0};
void render_lineside_ui();
void arm_switch();
// the window of the switch templates: the catalogue and the own ones, made of straights, arcs and transition curves
struct switch_designer
{
bool open{false};
bool loaded{false};
std::vector<switch_design::design> catalogue;
std::vector<switch_design::design> own;
bool from_catalogue{true};
int selected{-1};
bool dirty{false};
bool stretched{true};
double quick_radius{300.0};
double quick_ratio{9.0};
double quick_straight{0.0};
double blade_length{5.0};
double blade_gap{0.15};
std::string status;
};
switch_designer m_switch_designer;
void switch_designs_load();
// the list of the switch tool built again with the own templates, keeping the armed one or arming the one whose label starts with Arm
void switch_templates_refresh(std::string const &Arm = {});
void render_switch_designer();
bool m_track_window_open{false};
// the inspector is pinned to the right edge of the screen, the profile strip to the bottom one, both resized from the inner edge
void render_track_inspector();