mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 21:07:06 +01:00
38f90387c4
The second half of E1: what the tracks of a scenery are against a profile of the norms, listed. Nothing of the tracks is changed. - editor/editorNormsReport: a line of paths sampled a metre apart, two samples at each joint, into what the norms read a line from: the plan, the curvature signed by the turn, the cant on the base of 1500 mm (as the simulator takes the rolls) signed by the side it leans to as the line runs, the grade, the speed of each path (a switch's for its diverging track alone too), and what the path is a part of (a switch, its diverging track, a curved switch, a movable frog, a crossing). The line described, checked, and each finding set back on its path with a point of it; its message, "cant ramp 3.00 mm/m, PLK allows at most 2.50 mm/m (tab. 9.12)", "break of the grade with no vertical curve, PLK asks for a radius of at least 2500 m (tab. 10.2)", through STR_C; the text of the report: the class, the elements, the cant, the grade line and the findings of each line. - The Norms tab of the track window, under More beside Speed and Joints, no key; its window is ###trackanalysis, as theirs. The line through the selected path (run_route, as the speed check walks it) or the whole scenery: the lines through the plain tracks, then each path of a switch none of them ran along, checked with the line it lies in and its own findings kept, a place two lines run through listed once. The profile (PLK by default) and the class of the line folded under a line saying it: the line speed for the tracks with none of their own (on by default: the speed of each track), the slow trains (tab. 8.1 by default), the traffic, main track or siding, the load, at a platform. The results in the table of the speed check and the joints, the worst first, coloured by the tier, the values above the recommended ones on a tick; a click on a row shows the place, the hard limits and the warnings are marked in the view. The icon is drawn into its own cell of editor_icons.png only (the generator has it): the sheet drawn again with this Pillow differs in other cells. - Self-test: normsreport <file> [scope] [plk|tsi|en|ch] [km/h] writes the report to the file; expect findings <tier> <least> <most>; the case e1_norms_report checks the curves k0..k3 of the fixture at 60 km/h against PLK and the whole scenery against the TSI. - Golden: data/norms/line.scn, a line of 14 tracks written by make_line.py there (curves with and without transitions, cant on and off a curve and along a straight, reverse curves 10 m apart, short straights, a grade with breaks), and its report against the four profiles in data/norms/line_report.txt; EU07_UNIT_TESTS_UPDATE_GOLDEN=1 writes it anew. A test lays a canted corner with the alignment of the editor and finds the samples leaning into it, both turns and run both ways, I = Deq - D. alignment::limits stays as the laying tools use it. Where its values differ from PLK P0: - unbalanced 0.6 m/s2 is I 92 mm on the 1500 mm base; P0 110 mm (P1 130) on the running lines, 80 on the sidings; - ramp_factor 10, a ramp of 1:(10 V), 1 mm/m at 100 km/h and 2.5 mm/m at 40 km/h, has no counterpart: P0 1.6 mm/m at any speed; - jerk 0.3 m/s3 is dI/dt 46 mm/s; P0 55 mm/s; - vertical_factor 0.4 V^2 and vertical_min 2000 m; P0 max(0.77 V^2, 5000 m) (P1 max(0.35 V^2, 5000), P2 max(0.25 V^2, 2000)); - arc_min 20 m and arc_min_factor 0.4 V; P0 max(0.35 V, 30 m) up to 120 km/h, 0.40 V up to 200 km/h, also for the straights, where tangent_min_time is 0; - the same: cant_max 150 mm (P0 = P1 = P2 on ballast), cant_rate 35 mm/s (P0 of tab. 9.13), the base of 1500 mm.
298 lines
11 KiB
C++
298 lines
11 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <map>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
#include "editor/editorTrack.hpp"
|
|
#include "utilities/Classes.h"
|
|
|
|
class TTrack;
|
|
class editor_nmt;
|
|
|
|
enum class editor_selftest_result
|
|
{
|
|
unhandled,
|
|
handled,
|
|
pause,
|
|
again
|
|
};
|
|
|
|
enum class editor_first_step { tracks, lay, laid, wheel, join, turnout, undo, save, drive, look, top, select, shape, profile, profile_point, profile_apply, terrain, nmt, plan, plan_band, plan_apply, signal, posts, bend, trace, gizmo, vector, template_open, template_clicked, ride, count };
|
|
|
|
enum class editor_track_tab { straights, route, path, turnout, profile, speed, joints, infra, lay, lineside, turntable, parallel, signals, station, station_signals, line_block, kilometrage, norms };
|
|
|
|
struct track_hover
|
|
{
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
glm::dvec3 point{0.0};
|
|
double since{0.0};
|
|
};
|
|
|
|
struct tool_tab
|
|
{
|
|
bool open{false};
|
|
bool expand{false};
|
|
};
|
|
|
|
// scenery templates standing by the track, placed and checked by the editor
|
|
struct template_item
|
|
{
|
|
std::string file;
|
|
glm::dvec3 location{0.0}; // world space
|
|
double yaw{0.0};
|
|
std::vector<std::string> rest; // parameters after the rotation
|
|
bool described{false};
|
|
std::string track;
|
|
glm::dvec2 tilt{0.0}; // rot.x and rot.z of a described template, degrees
|
|
std::map<std::string, std::string> values;
|
|
};
|
|
struct standing_template
|
|
{
|
|
scene::instance_handle instance{0};
|
|
std::string file; // lower case, forward slashes
|
|
glm::dvec3 location{0.0};
|
|
double yaw{0.0};
|
|
std::vector<std::string> values;
|
|
};
|
|
|
|
// a signal to stand by a track, of the kind of the signal templates: main, shunt...
|
|
struct signal_order
|
|
{
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
glm::dvec3 point{0.0}; // on the axis
|
|
int facing{1}; // the trains it faces run 1: towards the end of the path, -1: towards its start
|
|
int side{1}; // 1: on the right of the path, -1: on the left
|
|
std::string kind;
|
|
std::string name;
|
|
std::string plate; // the name on the plate under the head, when the template has one
|
|
std::string linked{"none"}; // the signal before it, when the template takes one: a block signal shows its aspects by it
|
|
std::string file; // the template, of its kind; empty for the one chosen for the kind
|
|
};
|
|
struct signal_rename
|
|
{
|
|
scene::instance_handle instance{0};
|
|
std::string name;
|
|
std::string plate;
|
|
std::string linked; // the same, empty to keep the one it has
|
|
};
|
|
struct standing_signal
|
|
{
|
|
scene::instance_handle instance{0};
|
|
std::string name;
|
|
std::string kind;
|
|
glm::dvec3 position{0.0};
|
|
double yaw{0.0};
|
|
std::string linked; // of a template that takes one, else empty
|
|
std::string file; // of its template
|
|
TTrack *track{nullptr}; // the trains read it on, nullptr while none does
|
|
int facing{0}; // the trains it faces run 1: towards the end of the path of the track, -1: towards its start, 0 unknown
|
|
std::string read; // its event the trains read, empty for a template without one
|
|
};
|
|
// a signal template as the signalling picks one: the lights it has and the speeds its events show
|
|
struct signal_head
|
|
{
|
|
std::string file;
|
|
std::string name;
|
|
std::string kind;
|
|
std::string mount;
|
|
std::string lamps; // its chambers from the top: z green, c red, p orange, b white, n blue, x blind
|
|
std::vector<int> speeds; // of the signal itself, km/h: -1 the highest allowed, 20 the substitute signal
|
|
bool chosen{false}; // chosen for its kind among the templates of the signals, placed by hand and with the signalling
|
|
int aspects{0}; // of a block signal: 3, or 4 with the warning two signals ahead
|
|
std::string lean; // its head leans towards the track: left, standing on the right of it, right, or none
|
|
int arms{0}; // of a semaphore, 1 or 2: its aspects are the names below, not its lights
|
|
std::vector<std::string> aspect_names; // the aspects its description lists: Sr1, Sr2, Sr3, Sz...; empty where it lists none
|
|
// of a warning disc: its event for each speed class of the signal after it, stop, vmax, 100, 60, 40
|
|
std::vector<std::pair<std::string, std::string>> repeats;
|
|
};
|
|
// one step of the history of the signalling: signals placed, standing ones renamed, other templates placed with them, the values
|
|
// of standing ones replaced
|
|
struct signal_changes
|
|
{
|
|
std::vector<signal_order> placed;
|
|
std::vector<signal_rename> renamed;
|
|
std::vector<template_item> others;
|
|
std::vector<std::pair<scene::instance_handle, std::vector<std::string>>> values;
|
|
std::vector<std::pair<scene::instance_handle, std::string>> files; // standing signals given another template, of the same kind, their values kept
|
|
std::vector<scene::instance_handle> removed; // includes taken away, the signals among them with their read events
|
|
};
|
|
|
|
struct nmt_place
|
|
{
|
|
glm::dvec3 position{0.0}; // on the axis of the path
|
|
double formation{0.0}; // the height of the formation under it, the foot of the ballast
|
|
double crown{0.0}; // the height of the top of the ballast under the rails: what the terrain model measures on a track
|
|
double half_width{3.0}; // from the axis to the foot of the ballast
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
bool shapes{true}; // not a bridge nor a tunnel
|
|
};
|
|
|
|
inline std::map<std::string, std::string> selftest_values(std::istringstream &Words)
|
|
{
|
|
std::map<std::string, std::string> values;
|
|
std::string pair;
|
|
while (Words >> pair)
|
|
{
|
|
auto const equals{pair.find('=')};
|
|
if (equals != std::string::npos)
|
|
values[pair.substr(0, equals)] = pair.substr(equals + 1);
|
|
}
|
|
return values;
|
|
}
|
|
|
|
class editor_selection
|
|
{
|
|
public:
|
|
virtual TTrack *selected_track() const = 0;
|
|
virtual std::vector<TTrack *> const &track_set() const = 0;
|
|
virtual track_hover const &hovered_track() const = 0;
|
|
virtual void set_current_node(scene::basic_node *Node) = 0;
|
|
virtual void clear_track_point() = 0;
|
|
|
|
protected:
|
|
~editor_selection() = default;
|
|
};
|
|
|
|
class editor_view
|
|
{
|
|
public:
|
|
virtual glm::dvec3 camera_position() const = 0;
|
|
virtual void fly_to(glm::dvec3 const &Target, glm::dvec3 const &Look, double const Distance, double const Duration = 0.6) = 0;
|
|
virtual void focus_track(TTrack &Track, int const Path, glm::dvec3 const &Point) = 0;
|
|
virtual editor_track_tab current_track_tab() const = 0;
|
|
virtual void show_track_tab(editor_track_tab const Wanted) = 0;
|
|
|
|
protected:
|
|
~editor_view() = default;
|
|
};
|
|
|
|
class editor_history
|
|
{
|
|
public:
|
|
// changes with each step of the history taken, undone or redone, also once the oldest steps are dropped
|
|
virtual std::size_t history_revision() const = 0;
|
|
virtual void push_track_snapshot(std::vector<std::pair<TTrack *, editor_track::state>> States, std::vector<TTrack *> Created = {}, std::vector<TTrack *> Removed = {}) = 0;
|
|
// the changes of the kilometrage made since the last step: one step of the history
|
|
virtual void push_kilometrage_snapshot() = 0;
|
|
|
|
protected:
|
|
~editor_history() = default;
|
|
};
|
|
|
|
class editor_templates
|
|
{
|
|
public:
|
|
virtual std::vector<standing_template> standing_templates(std::function<bool(std::string const &)> const &Accept) const = 0;
|
|
// the layer a tool keeps what it makes in, "<scenery>_<Part>.scm", or the one made for the part of the scenery a copy was saved
|
|
// from, told by its first line; made when the scenery has none yet. returns: null_handle if there can't be one
|
|
virtual scene::layer_handle output_layer(std::string const &Part) = 0;
|
|
// in the active layer unless given another
|
|
virtual std::size_t place_templates(std::vector<template_item> const &Items, std::string &Error, scene::layer_handle Layer = scene::layer_handle{}) = 0;
|
|
virtual std::size_t move_templates(std::vector<std::pair<standing_template, template_item>> const &Moves) = 0;
|
|
virtual std::size_t remove_templates(std::vector<scene::instance_handle> const &Instances) = 0;
|
|
|
|
protected:
|
|
~editor_templates() = default;
|
|
};
|
|
|
|
class editor_signals
|
|
{
|
|
public:
|
|
// false while the signal templates are still being looked for
|
|
virtual bool standing_signals(std::vector<standing_signal> &Signals, bool const Wait) = 0;
|
|
// the signals placed by the templates chosen for their kinds and the rest of the changes, with the tracks changed before: one
|
|
// step of the history. returns: how many signals were placed
|
|
virtual std::size_t signal_batch(signal_changes const &Changes, std::vector<std::pair<TTrack *, editor_track::state>> States, std::vector<TTrack *> Created, std::string &Error) = 0;
|
|
// the error signal_batch would stop with for the signals given, a kind with no template, so a step finds it before it cuts any
|
|
// track for them. returns: empty if each one has its template
|
|
virtual std::string signal_templates_missing(std::vector<signal_order> const &Orders) = 0;
|
|
// the signal templates with lights, false while they are still being looked for
|
|
virtual bool signal_heads(std::vector<signal_head> &Heads, bool const Wait) = 0;
|
|
// the mount of the signal template given, with none of the one chosen for the kind; empty for none
|
|
virtual std::string signal_mount(std::string const &Kind, std::string const &File) = 0;
|
|
// the signals given which no track reads, read again by the track they stand by: one step of the history. returns: how many
|
|
virtual std::size_t signal_reattach(std::vector<scene::instance_handle> const &Instances) = 0;
|
|
// the signal picked, its card at the top of the panel
|
|
virtual void select_signal(scene::instance_handle const Instance) = 0;
|
|
// the template chosen for each of the kinds given, which the signalling of a station places: the one the Signals tool places too
|
|
virtual void render_signal_templates(std::vector<std::string> const &Kinds) = 0;
|
|
|
|
protected:
|
|
~editor_signals() = default;
|
|
};
|
|
|
|
class editor_ground
|
|
{
|
|
public:
|
|
virtual glm::dvec3 placement_on_ground(glm::dvec3 Location) = 0;
|
|
virtual void nmt_locate() = 0;
|
|
virtual std::vector<nmt_place> nmt_track_places(double const Step) const = 0;
|
|
virtual editor_nmt &terrain_model() = 0;
|
|
virtual double terrain_model_offset() const = 0;
|
|
virtual bool terrain_model_fitted() const = 0;
|
|
|
|
protected:
|
|
~editor_ground() = default;
|
|
};
|
|
|
|
class editor_track_design
|
|
{
|
|
public:
|
|
virtual bool track_editing() const = 0;
|
|
virtual alignment::limits const &route_norms() const = 0;
|
|
virtual bool digitize_drawn(std::vector<TTrack *> const &Created, bool const Alone = true) = 0;
|
|
virtual void straight_refresh() = 0;
|
|
|
|
protected:
|
|
~editor_track_design() = default;
|
|
};
|
|
|
|
class editor_guide
|
|
{
|
|
public:
|
|
virtual void first_step_done(editor_first_step const Step) = 0;
|
|
// the Kilometrage tool opened, from a panel which needs the km of a line
|
|
virtual void open_kilometrage() = 0;
|
|
|
|
protected:
|
|
~editor_guide() = default;
|
|
};
|
|
|
|
class editor_services : public editor_selection, public editor_view, public editor_history, public editor_templates, public editor_signals, public editor_ground, public editor_track_design, public editor_guide
|
|
{
|
|
protected:
|
|
~editor_services() = default;
|
|
};
|
|
|
|
class editor_tool
|
|
{
|
|
public:
|
|
virtual ~editor_tool() = default;
|
|
virtual void update() {}
|
|
virtual void draw_overlay() const {}
|
|
virtual void render_options() {}
|
|
virtual void render_windows() {}
|
|
virtual void forget(scene::basic_node const *Node) {}
|
|
virtual editor_selftest_result selftest(std::string const &Command, std::istringstream &Words) { return editor_selftest_result::unhandled; }
|
|
};
|