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

feat(editor): laying from the photo in two modes, Tab switching them in one row of points: the points clicked as bends of straights, eased with two transition curves meeting with no cant, of 3000 to 6000 m set in the panel, or with an arc of the norms where they don't fit; or the points along the middle of a curve seen on the photo, the last two on the straight after it, a curve, compound or two with a straight between them, fitted to them with its radii and its transitions. The points clicked are kept where they are, a curve below the norms laid with its warnings in the colour of one; the line shown as the points are clicked, laid by Enter in one step of the undo and going on from its end, Backspace taking the last point back, Esc dropping the points not laid. A bend after a free end or a curve traced goes along its straight, dashed; the curves labelled with their radii, transitions, cant and speed, the straights with their lengths, the points traced in the colour of how far the line is from them, the curves of the line listed in the panel. The Plan sets two transition curves with no arc for a vertex. Selftests laymode, layradius, laytrace, layp, layreport, layenter, layback, laycancel, laysample

This commit is contained in:
maj00r
2026-10-24 21:12:27 +02:00
parent 500f068297
commit 6bd3d4d19f
9 changed files with 1012 additions and 210 deletions

View File

@@ -1384,11 +1384,42 @@ class editor_mode : public application_mode, private editor_track::observer, pri
std::vector<TTrack *> line;
};
extend_tool m_extend;
// what a point clicked while laying is: a bend of the straights, eased with a large curve, or a point along the middle of a curve
// seen on the photo, the last two of these on the straight after it
enum class lay_mode
{
straights,
curve
};
// a curve traced on the photo as it's laid, how far the points clicked along it are from it
struct lay_trace
{
std::vector<glm::dvec3> points;
std::vector<double> offsets;
double rms{0.0};
double worst{0.0};
std::size_t curves{0};
};
// the line the points clicked make: its design, the bends among its vertices, the curves traced
struct lay_line_plan
{
alignment::design design;
alignment::result shape;
std::vector<char> corners;
std::vector<lay_trace> traces;
// the straights of a fixed direction the next bend slides along: from a free end, out of a curve traced
std::vector<std::pair<glm::dvec3, glm::dvec3>> guides;
};
// lays new track through the clicked points, with no path needed to start from
struct lay_tool
{
bool active{false};
std::vector<glm::dvec3> points;
std::vector<lay_mode> modes; // of the points, as each was clicked
lay_mode mode{lay_mode::straights};
int radii{0}; // of a curve traced: 0 as many as the points need, up to three
bool straights_between{true}; // a curve traced may be two with a straight between them
lay_line_plan plan; // of the line shown
editor_track::snap_target start; // free end the track starts from, if any
glm::dvec3 mouse{0.0};
editor_track::snap_target mouse_snap;
@@ -1424,8 +1455,20 @@ class editor_mode : public application_mode, private editor_track::observer, pri
void lay_finish(editor_track::snap_target const &End);
void lay_cancel();
void lay_enter();
std::vector<segment_data> lay_pieces(std::vector<glm::dvec3> const &Points, editor_track::snap_target const &End, double &Length, std::string &Error) const;
alignment::result lay_shape(std::vector<glm::dvec3> const &Points, glm::dvec2 const &Startdirection, glm::dvec2 const &Enddirection, alignment::design &Design) const;
// Tab: the bends of straights or the curve traced, for the points clicked from now on
void lay_switch_mode();
// the points the same in number as their modes, a point with none a bend of straights
void lay_trim();
// the track through the points clicked, each the way its mode says; End: the free end it finishes at, the last point then
std::vector<segment_data> lay_pieces(std::vector<glm::dvec3> const &Points, std::vector<lay_mode> const &Modes, editor_track::snap_target const &End, double &Length, std::string &Error,
lay_line_plan *Plan = nullptr) const;
bool lay_line(std::vector<glm::dvec3> const &Points, std::vector<lay_mode> const &Modes, editor_track::snap_target const &End, lay_line_plan &Plan, std::string &Error) const;
// the curves of a stretch traced, the ones fitted lately kept for the same points
// none while the stretch the cursor moves along is still being fitted
std::optional<alignment::trace_stretch> traced_stretch(alignment::design const &Base, std::vector<glm::dvec2> const &Points) const;
mutable std::vector<std::pair<std::vector<double>, alignment::trace_stretch>> m_stretch_cache;
// the stretch the cursor moves along is fitted on a thread, the frames drawn meanwhile with the fit done last
mutable alignment::stretch_fitter m_stretch_fitter;
void render_switch_ui();
void render_switch_timbers();
void render_rail_profile_hint(TTrack &Track);