mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 03:52:52 +01:00
c3b987abb2
* fix(editor): track edits keep the joints, the norms, the records and the saved speed together
- The cant typed in the inspector goes on into the track joined at that end, as the gizmo and the
joints tool do it; the neighbours go into the same undo step. The joint stepped before.
- A track laid on from a canted joint takes the cant off along the ramp the norms ask for at the
speed (`alignment::cant_ramp_length`), not at a fixed 1.5 mm a metre whatever the speed and the
norms: 120 mm at 100 km/h over 120 m, not 80 m.
- Deleting a track of the line under the route tool keeps the laying norms. They went back to the
defaults, and every later lay, extend and join used those.
- The gauge is a paste group of its own, off by default: pasting how a track rides or sounds no
longer changes its gauge.
- The speed of a turntable set in the editor is the one saved. The editor changed the speed the
turntable runs at, while the file keeps the limit it was loaded with.
- Deleting a set of tracks does what Del does with each: a double switch, a slip and a crossover go
whole, the records of the switches go with them, and the model and events of a turntable too. The
records stayed behind and on saving were given to another switch, which then showed a wrong type.
- Deleting a switch of a crossover takes the crossover out whole, as the connection tools do: the
outer track of a crossover on a curve comes down by its lift and the record of the connection
goes. Alone, the switch left the outer track up for good, and the connection to the next switch
given its name. A switch bent out of the shape of its record is found by its name.
Tests: a unit test of the norm ramp. The other changes are in the editor's UI, which the unit tests
don't reach.
* test(editor): self-test scripts that fail, a runner, and a case for each fix of the track editing
The editor's self-test scripts only logged: nothing made a run fail. Now:
- `expect` commands check the state and log `SELFTEST PASS` or `SELFTEST FAIL ... got X, expected Y`:
the cant at a track end, the joint at an end (gap, angle, cant step), the records of a switch and
the connections naming it, speed, gauge, a track present or removed, the laying norms' gauge,
heights and lifts against a mark, whether a track is in the line under the route tool, and the
includes of a turntable. A command no group takes counts as a failure, so a mistyped one can't
make the checks after it pass.
- At `quit` the result is logged, and a script whose expectations failed ends the editor with exit
code 2 (a failed start stays 1; the simulator's test mode is unchanged).
- The commit of the inspector's cant field is `track_cant_commit`, which the inspector and the
`trackcant` command both call; `routegauge` sets the laying norms as the route tool does, and
`tracksetdelete` deletes a set of tracks by name.
- `tests/editor/run.py` runs each script of `tests/editor/cases` on a copy of the fixture scenery
in the game folder, with a wall-time limit and a memory cap, reads the exit code and the
`SELFTEST` lines, and deletes the copy. A `#> reopen` line restarts the editor on the saved
scenery. See `tests/editor/README.md`.
- One case per fix of the track editing quick fixes (inspector cant, norms after deleting, the
gauge paste group, turntable speed saved, deleting a set, a set with a double switch, a slip
and a crossover, deleting a switch of a crossover, a bent switch). All pass; with the fixes
reverted all fail.
* feat(editor): the track tool panels keep their fields, results and buttons within the panel
- The card of the tool: after a long gesture the action goes under it, at its indent, when what is
left of the row is narrower than 8 font sizes or the longest word of the action. It was squeezed
into a sliver and broken in the middle of its words.
- A click on the title row of the card folds it to that row (icon, name, family, key, and a small
triangle marker) and opens it again. One flag for all the tools, kept with the editor settings
(`track_card_folded` in eu07_editor.ini), open by default: the card took 250-300 px at the top
of every tool and repeats the hint bar of the view.
- The grade labels of the vertical profile, on the graph and in the view, write the per mille as
the panel does (the translated "per mille", the per mille sign in Polish), not "o/oo".
- The track analysis window: the thresholds of the speed check and of the joints keep to their
widest name and a field of 10 font sizes where the window is wider than that, as docked across
the bottom (`begin_fields_fitted`). The results are tables with each column as wide as what is in
it: the speed check with its column names kept at the top as the list scrolls, the joints with
the kind, the value and the two tracks next to each other. A click on a row shows it as before.
- `same_line_if_fits` puts the next button beside the one before only when it fits in what is left
of the line, at the start of the next line otherwise. Used where the route design puts buttons
side by side, for "Forget the design" in the profile panel, which was cut off at the edge, and for
the buttons of a switch in the inspector.
- The laying options: the speed, the curve radius and the longest path are fields with the name on
the left in two columns (`begin_fields`/`field_row`), as in the inspector, the route and the
profile, the chips of the quick values under them. The segmented choices give the short names
less of the room when a long one doesn't fit in its even share, and go on in a second bar when
they don't fit side by side: "Through the clicked points" overflowed its third of the bar.
* fix(editor): a switch laid gets the speed of its diverging track, one breaking a hard rule of ST-T1-A6 isn't laid
- Every switch laid writes the speed of its diverging track (`velocity`): the switch tool on a
straight, into a curve, from a free end and linked, a double switch, the switches of a slip, a
switch given another template of the catalogue, and a switch moved along the curve it's bent
into. A switch of the catalogue had no limit before, one copied from a switch of the scenery kept
that one's, one laid without a track had the laying speed on both its tracks. The limit is for the
diverging track alone (`velocity -V`); the own limit of the track it goes into stays for both
where it's the lower. The switch tool says the speed and what gives it.
- The speed is formula 9.9 of PKP PLK ST-T1-A6 the other way round, V = sqrt((I + D) r / 11.8), with
the normal cant deficiency of the frog of table 9.7 (110 mm a fixed frog, 130 mm a movable nose),
rounded down to the steps of the speed limits and no more than table 11.2 gives the basic switch.
For the fixed frogs the formula gives table 11.2 itself (190 40, 300 50, 500 60, 760 80, 1200
100 km/h); the 2500-1:26.5 with a movable nose stays 130. A switch bent into a curve takes the
radius of its diverging track from table 11.8 (one-sided r" = (Rr - t^2)/(R + r), two-sided
(Rr + t^2)/(R - r)) and the cant of the line with its sign: leaning against the diverging track it
takes speed away, where the speed check counted it as helping. Rz 60E1-190-1:9 bent out of the
curve R 600 m with 60 mm: 30 km/h, not 40; the 60E1-500-1:12 of the review, out of R 1200 m with
60 mm: 60 km/h at its fixed frog (54 at I = 100 mm, the 0.65 m/s2 the editor took), not 107.
- A switch breaking a hard rule isn't laid, the tracks left as they were, and the switch tool says
why, with the value, the limit and the paragraph: the cant changing within it (11.4 pkt 7), a cant
ramp ending within it or nearer than 6 m (9.6 pkt 16-17; one ending right at an end of the switch
is let be, as the snapping of the start offers it), a double switch, a slip or a crossing bent
(11.4 pkt 4), the curvature of its diverging or its main track turning from one side to the other
(9.7 pkt 12, KZW II). They were warnings shown after the switch was laid, and on a straight the
cant wasn't looked at at all. The line is looked at 10 m past the ends of the curve or the
straight too, so the ramp on the straight before a curve counts. The previews show the refusals.
- A switch moved along its straight or the curve it's bent into, a double switch moved along its
straight, and a switch given another template go through the same checks; one breaking a rule
stays as it is.
- Warnings still: 1:9.403 and steeper than 1:9 bent (11.4 pkt 4c-d), a rule of the running and the
main tracks, which the editor doesn't tell from the side ones, as the warning now says; the limits
of table 11.9 and a cant over 100 mm in a bent switch (table 9.6), as before.
Tests: unit tests of tables 11.8 and 11.9 (the least main radius bends the diverging track to the
least radius the table gives), table 9.7, the speeds of table 11.2 by formula 9.9, the speed of a
bent switch with the cant with its sign (the example of the review), the cant over a switch on a
straight and a double switch bent. Editor cases `q2_1_switch_speed`, `q2_2_switch_refusals` and
`q2_3_switch_move`, with `expect status` (the status of the switch tool) and `expect steps` (the
undo steps), the fixture with a straight taking a cant on and a compound curve without cant. All
pass; with the changes of the editor reverted all three fail.
* test(editor): golden round trips of the tracks and of the //$ lines, the cant at the joints
The safety net of the track editor before its domain model changes (E0 of
editor-tracks-tests.md): what the editor reads from the scenery files and
writes back is read, written and read again in tests/unit, with no game data.
Tracks (test_track_text.cpp, data/tracks/). Entries written the way the game
writes them, read by TTrack::Load() and written by export_as_text(), come out
byte for byte the same, and read again give the same track field by field:
plain tracks with all their attributes (events, speed, isolated, overhead,
vradius, rail profile, friction cell), a curve with cant, radius, uneven,
buckle, cwr and sleeper models, a bridge, switches with trackbed, frogs,
movable nose, blades, uneven of both paths and timbers, a turntable, paths of
pieces, the speeds +40, -40, 0.5, 0 and none of tracks, switches and
turntables, a river, a tributary, a road and a crossing. What the game writes
otherwise than given is checked as it is (table as turn, mountain as
mountains, the length of the path, a switch heard from 10 m, the events in
order, names in lower case, model paths with forward slashes, the texture
length, rolls as floats, no overhead and no vradius left out).
The seam: TTrack built from text with no scene. The engine stubs of the tests
had none of it, so the tests link the few sources reading and writing a track
takes (world/Track.cpp, Segment.cpp, TrackUneven.cpp, MemCell.cpp,
scene/scenenode.cpp, utilities/Timer.cpp, rendering/geometrybank.cpp) and
track_stubs.cpp stands in for the rest: a renderer keeping the materials by
their names, and the scene, events, vehicles and the geometry of the rails,
which reading and writing never reach and which stop the test with their name
if one does. It tests the game's own Load() and export, where a parser of its
own would have meant rewriting Load(), and changes no code of the game. The
stub of basic_node::radius_() goes, scenenode.cpp brings the real one. The
rails don't buckle in the tests (TrackBuckle.cpp needs the environment), the
buckle declared is read and written either way; material names go through a
stand-in, the game's material manager isn't tested here.
The //$ lines (test_editor_records.cpp, data/records/). Their readers and
writers were members of editor_mode, srk_tool and the stores, with the scene
around them; they move as they were into editor/editorRecords.cpp, the one
place each kind is read and written, which the stores call (and which the
migration to the project file of E3 will need apart anyway). The methods of
scene::layer_context move into scene/scenelayercontext.cpp so it links alone.
Each kind, h r k p t w b s c o z, read from golden lines and written back comes
out the same, in the coordinates of the file and of a file placed at an
origin; //$e, the descriptions of the templates, read and saved by
editor_includes in a template in a scratch folder, leaves the file as it was.
Cant (test_cant.cpp). The paths an alignment lays roll by asin(cant/gauge),
signed with the turn, back to the cant of the line at every end; a curve the
other way rolls the other way. At a joint editor_track::match_rolls() gives
the joined track the roll for the travel across it, turned where the paths
face or stand back to back, and the track written keeps it. The inspector's
own conversion on 1500 mm stays in its lambdas here; named, as
editor_mode::cant_of_roll()/roll_of_cant(), it comes with the quick fixes.
Known bugs found, tests of the change each (doctest::should_fail, passing
until fixed, then reported to drop the decorator), data/tracks/known_lost.scn:
- angle1/angle2 are read and dropped: not written back.
- fouling1/fouling2 are read and dropped: not written back.
- name@circuit: the circuit is taken out of the name with the letter before
the @ ("tor1@iso1" becomes track "tor"; substr(0, i - 1)).
- the attributes of the entry (gauge, friction, texture sizes, speed...) are
written to 6 significant digits, a float has 9: more digits are lost on the
first save.
None in the //$ lines.
Unit tests: 957 cases before, 974 after, all passing.
* test(editor): a mistyped track fails the self-test, indented comments are skipped, case 7b checks the switch got bent
- A blank line or an indented `#` comment in a script is no longer a command no group takes.
- `trackcant`, `routegauge` and `tracksetdelete` with a track that isn't there count as a failed expectation.
- `expect shaped <switch> <yes|no>`: 7b checks that the gizmo drag bent the switch out of its record before deleting it.
- The ramp-length loop of test_alignment counts in an integer (Sonar S2193).
* test(editor): the entries known to be lost are checked apart from should_fail, the cant test says where the inspector conversion is tested
- A normal test checks that known_lost.scn and each of its entries are there and read, so the should_fail tests can't pass for
data gone missing.
- The comment of test_cant.cpp said the tests of cant_of_roll()/roll_of_cant() are here; they are the self-test case
1_inspector_cant.txt, as the unit tests don't link the editor.
477 lines
24 KiB
C++
477 lines
24 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 "application/editortool.h"
|
|
#include "editor/editorRecords.hpp"
|
|
#include "editor/editorStation.hpp"
|
|
#include "scene/scenelayers.h"
|
|
|
|
#include "imgui/imgui.h"
|
|
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <unordered_set>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
// the joints of the track circuits a station has by hand, as a step of the history keeps them
|
|
struct srk_hand_joints
|
|
{
|
|
TTrack const *anchor{nullptr}; // the switch the record of the station is found by
|
|
std::vector<glm::dvec3> added;
|
|
std::vector<glm::dvec3> removed;
|
|
};
|
|
|
|
// the signalling of a station (SRK): the station found from a switch of it, its schematic, its name and code. Three tools of the
|
|
// toolbar share it, each showing a part of it
|
|
class srk_tool final : public editor_tool
|
|
{
|
|
public:
|
|
enum class part
|
|
{
|
|
station, // its name, code, line and km, the numbers of the switches, the track circuits
|
|
signals, // the signals of the station placed at once, and what they lack
|
|
lines // the block of the lines out of it
|
|
};
|
|
srk_tool(editor_selection &Selection, editor_view &View, editor_history &History, editor_templates &Templates, editor_signals &Signals, editor_guide &Guide)
|
|
: m_selection{Selection}, m_view{View}, m_history{History}, m_templates{Templates}, m_signals{Signals}, m_guide{Guide}
|
|
{
|
|
}
|
|
void update() override;
|
|
void draw_overlay() const override;
|
|
void render_options() override;
|
|
void render_windows() override;
|
|
void forget(scene::basic_node const *Node) override;
|
|
editor_selftest_result selftest(std::string const &Command, std::istringstream &Words) override;
|
|
void set_open(bool const Open, part const Part)
|
|
{
|
|
m_open = Open;
|
|
if (Open)
|
|
m_part = Part;
|
|
}
|
|
// the block boundaries drawn by hand on the lines out of the open station
|
|
bool drawing() const { return m_open && m_part == part::lines && m_drawing && m_layout.has_value(); }
|
|
// what a click at the point of a track does while the block boundaries are drawn, for the label at the mouse; Valid: it does
|
|
// something
|
|
std::string boundary_hover(glm::dvec3 const &Point, bool &Valid);
|
|
void boundary_click();
|
|
// the stations described go to the files of their layers, as "//$s" lines
|
|
void store();
|
|
// what the last action of the tool came to, once, to be told by the mouse: Refused when it did nothing for want of something
|
|
bool told(std::string &Status, bool &Refused);
|
|
// the joints of the track circuits of the open station put, moved and taken away by hand in the scenery
|
|
bool editing_joints() const { return m_open && m_part == part::station && m_joint_editing && m_layout.has_value(); }
|
|
// what a click at the point does while the joints are edited, for the label at the mouse; Valid: it does something
|
|
std::string joint_hover(glm::dvec3 const &Point, bool &Valid);
|
|
void joint_click();
|
|
// the joints a station had by hand before the edit just made, for the step of the history it goes into; none once taken
|
|
std::optional<srk_hand_joints> take_joint_change();
|
|
// the joints of the station set back as the step of the history had them; the ones it had, for the opposite step
|
|
srk_hand_joints restore_joints(srk_hand_joints const &Joints);
|
|
|
|
private:
|
|
editor_selection &m_selection;
|
|
editor_view &m_view;
|
|
editor_history &m_history;
|
|
editor_templates &m_templates;
|
|
editor_signals &m_signals;
|
|
editor_guide &m_guide;
|
|
// the block of a line out of the station: semi-automatic, the automatic one of three aspects, of four, as the //$s lines keep it
|
|
using block_kind = editor_records::block_kind;
|
|
// where the block of a line out of the station comes from
|
|
enum class block_reason
|
|
{
|
|
hand, // set by hand
|
|
standing, // block signals stand along it
|
|
double_track, // the automatic one on a double-track line
|
|
single // the semi-automatic one on a single-track line
|
|
};
|
|
// a station described: found again by a switch of it
|
|
struct record
|
|
{
|
|
scene::layer_handle layer{null_handle};
|
|
std::string anchor; // the name of a switch of the station
|
|
TTrack *track{nullptr}; // the switch, once found: it stays the anchor when it gets renamed
|
|
std::string code; // the abbreviation of the station, as MMz
|
|
std::string name;
|
|
std::string line; // the number of the railway line
|
|
std::string km; // of the axis of the station along the line, empty while unknown
|
|
bool reversed{false}; // the km rise to the left of the schematic, the switches numbered from there
|
|
int braking{0}; // m, the braking distance of the line set by hand, 0: after its speed
|
|
std::map<std::string, block_kind> blocks; // of the lines by their entry signals, as set by hand
|
|
std::map<std::string, bool> ways; // the automatic block of the lines by their entry signals both ways, as set by hand
|
|
std::vector<glm::dvec3> joints_added; // the joints of the track circuits put by hand, on plain tracks
|
|
std::vector<glm::dvec3> joints_removed; // where the planned joints were taken away by hand
|
|
};
|
|
// the schematic: the chainage across, the offsets upwards, exaggerated
|
|
struct view
|
|
{
|
|
double from{0.0};
|
|
double to{1000.0};
|
|
double centre{0.0};
|
|
float exaggeration{0.0f}; // 0: fit at the next draw
|
|
};
|
|
bool m_open{false};
|
|
part m_part{part::station};
|
|
bool m_strip{true}; // the schematic shown, off for the screenshots of the self-tests
|
|
bool m_loaded{false};
|
|
bool m_changed{false};
|
|
std::vector<record> m_records;
|
|
std::optional<station::layout> m_layout;
|
|
station::drawing m_plot; // the schematic of the layout as the plot draws it
|
|
int m_record{-1}; // of the open station, -1 while it has none
|
|
TTrack *m_anchor{nullptr}; // the switch the open station was found from
|
|
bool m_reversed{false}; // the switches numbered from the right end of the schematic
|
|
std::size_t m_history_revision{0};
|
|
TTrack const *m_picked{nullptr}; // the track selected when the station was looked for
|
|
view m_view_state;
|
|
bool m_fit_lines{false}; // the schematic fits the lines out to the next stations too
|
|
int m_hover{-1}; // path of the layout under the mouse in the schematic
|
|
bool m_dragging{false};
|
|
std::vector<std::pair<std::string, std::size_t>> m_found; // the stations of the scenery: a switch and the count of them
|
|
struct circuit_mark
|
|
{
|
|
glm::dvec2 at{0.0}; // in the schematic
|
|
glm::dvec3 world{0.0};
|
|
std::string text;
|
|
ImU32 colour{0};
|
|
double length{0.0};
|
|
bool labelled{true}; // the circuits of the switches go without, named after them
|
|
glm::dvec2 drawn{0.0}; // in the plot
|
|
};
|
|
std::vector<int> m_circuit_of; // of each path of the layout, an index into m_circuits, -1 for none
|
|
std::vector<circuit_mark> m_circuits;
|
|
std::vector<glm::dvec2> m_ticks; // the joints between the circuits, in the schematic
|
|
std::vector<glm::dvec2> m_ticks_drawn; // the same in the plot
|
|
struct joint_mark
|
|
{
|
|
glm::dvec3 at{0.0};
|
|
glm::dvec3 across{0.0}; // of the track there, in the plan
|
|
};
|
|
std::vector<joint_mark> m_joints; // the same in the scenery
|
|
struct signal_mark
|
|
{
|
|
glm::dvec2 at{0.0}; // in the schematic
|
|
bool ahead{true}; // the trains it faces run along the chainage
|
|
std::string text;
|
|
glm::dvec3 head{0.0}; // above its lamps, in the scenery
|
|
bool unfit{false}; // its lights don't show what its routes need
|
|
glm::dvec2 drawn{0.0}; // on its track in the plot
|
|
float side{0.0f}; // 1: it stands to the left of the track in the plot, -1: to the right
|
|
};
|
|
std::vector<signal_mark> m_signal_marks;
|
|
bool m_signals_known{false}; // the signals standing surveyed, once their templates are found
|
|
std::vector<station::lengths> m_lengths; // of the station tracks, by their numbers
|
|
bool m_measured{false};
|
|
bool m_numbered{false}; // the station has tracks numbered by their circuits
|
|
int m_length_hover{-1}; // of the lengths, the row under the mouse
|
|
int m_length_canvas{-1}; // of the lengths, of the track under the mouse in the schematic
|
|
int m_length_shown{-1}; // of the lengths, the one drawn: of the row or the track under the mouse, else of the track selected
|
|
// how the SHP track resonator of a signal stands
|
|
enum class shp_state
|
|
{
|
|
needless, // the signal needs none
|
|
missing,
|
|
beyond, // missing, the tracks before the signal end short of its place
|
|
off, // farther from its place than allowed
|
|
placed
|
|
};
|
|
// a signal of the station or of its lines, its lights as the routes of its trains need them: Ie-1, Ie-4 § 8
|
|
struct head_check
|
|
{
|
|
scene::instance_handle instance{0};
|
|
std::string name; // shown, without the code of the station
|
|
std::string kind;
|
|
glm::dvec3 position{0.0};
|
|
glm::dvec2 travel{0.0, 1.0};
|
|
std::string file; // of its template
|
|
std::string lamps;
|
|
int arms{0}; // of a semaphore described with its arms: its aspects checked by name, not by lights
|
|
std::vector<std::string> aspect_names; // of its template, from its description
|
|
std::vector<int> own; // the speeds of its template
|
|
bool station{false}; // stands by the station, not out on a line
|
|
std::vector<station::route> routes;
|
|
std::vector<std::string> nexts; // of the routes, the signals they end at, shown
|
|
std::vector<int> speeds; // km/h, the lower ones it must show: 40, 60, 100
|
|
bool informs{false}; // it must tell the next signal shows stop
|
|
bool white{false}; // it must give the substitute signal
|
|
int shortened{0}; // km/h, it slows the trains to, the next signal nearer than the braking distance: Ie-4 § 8 ust. 5
|
|
bool indicator{false}; // a W21 "14" beside it, for 140 km/h so
|
|
bool told{false}; // a shaped warning disc before a semaphore described: the events it repeats checked
|
|
bool unsaid{false}; // of those, its template doesn't say what it repeats: the one described offered, the fitting leaves it be
|
|
bool fits{true}; // its template shows all of it
|
|
bool more{false}; // its template has more than it needs
|
|
std::string fit; // the template that fits best, empty for none
|
|
std::vector<std::string> problems; // of its place
|
|
// m before it the SHP track resonator belongs, -1 for none: 200 m before an entry signal, a block signal and a warning disc,
|
|
// at an exit signal onto a line of the automatic block
|
|
double shp{-1.0};
|
|
double shp_found{-1.0}; // m before it the trains run into the event of the SHP resonator standing, -1 for none
|
|
bool shp_short{false}; // the tracks before it end short of the place of its resonator
|
|
shp_state shp_of() const;
|
|
};
|
|
std::vector<head_check> m_heads;
|
|
bool m_heads_known{false}; // the templates found
|
|
int m_head_hover{-1}; // of the heads, the row under the mouse
|
|
// a line out of the open station, from an entry signal of it
|
|
struct line_row
|
|
{
|
|
std::string entry; // the entry signal, shown
|
|
glm::dvec3 position{0.0}; // of the entry signal
|
|
glm::dvec2 travel{0.0, 1.0}; // the trains it faces run, in the plan
|
|
int number{0}; // of the track of a double-track line, 0 on a single-track one
|
|
bool inbound{true}; // its trains run towards the station
|
|
int partner{-1}; // the other track of a double-track line, of the lines
|
|
double length{0.0}; // to the entry signal of the next station, or to the end of the tracks
|
|
std::string next; // the entry signal of the next station facing out along it, shown; empty for none
|
|
bool station{false}; // ends at the next station rather than at the end of the tracks
|
|
std::size_t blocks{0}; // the block signals standing along it
|
|
// the block boundaries of the same facing its trains, the joints they turn them to stop at, out along it, with the signal shown
|
|
std::vector<std::pair<double, std::string>> stops;
|
|
std::vector<std::pair<double, std::string>> wrong; // the block signals facing its wrong-track trains, out along it, shown
|
|
block_kind block{block_kind::semi};
|
|
block_reason why{block_reason::single}; // the block it has, so
|
|
block_kind own{block_kind::semi}; // the block it has by itself, unless set by hand
|
|
block_reason own_why{block_reason::single};
|
|
// the automatic block both ways: at each block boundary a block signal of each track either way, the wrong-track one with N
|
|
bool both{false};
|
|
bool both_hand{false}; // so set by hand
|
|
bool own_both{false}; // so by itself
|
|
// block signals stand along it, none switched by block sections of the editor: it keeps the block of the scenery as it stands
|
|
bool legacy{false};
|
|
double braking{0.0}; // m, the braking distance on it
|
|
std::string km_number; // the line of the kilometrage it runs along
|
|
bool rising{true}; // its trains run towards the higher km
|
|
bool km_known{false}; // the km out along it are known
|
|
// in the schematic, straightened: the chainage of the entry signal, 1 or -1 the way out along the chainage, the offset of the
|
|
// track there
|
|
double chainage{0.0};
|
|
double outward{1.0};
|
|
double offset{0.0};
|
|
struct run
|
|
{
|
|
double from{0.0}; // out along the line
|
|
double to{0.0};
|
|
std::string name;
|
|
double km_from{0.0};
|
|
double km_to{0.0};
|
|
};
|
|
std::vector<run> sections; // the track circuits along it, out from the station
|
|
std::vector<std::pair<double, double>> bare; // out along it, tracks between its block sections in none, of the automatic block
|
|
struct post
|
|
{
|
|
double distance{0.0}; // out along the line
|
|
std::string name; // shown
|
|
bool wrong{false}; // facing the wrong-track trains
|
|
double km{0.0};
|
|
};
|
|
std::vector<post> posts; // the block signals along it
|
|
// the signals of the other block standing along it: warning discs on a line of the automatic block, block signals on one of the
|
|
// semi-automatic one, the first of them
|
|
std::size_t leftovers{0};
|
|
glm::dvec3 leftover{0.0};
|
|
glm::dvec2 leftover_travel{0.0, 1.0};
|
|
};
|
|
std::vector<line_row> m_lines;
|
|
std::vector<station::line> m_line_ways; // of the lines listed
|
|
std::unordered_set<std::string> m_signal_names; // of the signals of the scenery, lowercase: a block signal drawn on one's number takes a letter
|
|
std::string m_lines_problem; // why the station has no lines listed
|
|
// what the check of the open station finds wrong: signals no track reads, lines broken off, tracks between the block sections of
|
|
// a line in none, block sections without a track
|
|
struct problem
|
|
{
|
|
std::string text;
|
|
glm::dvec3 at{0.0};
|
|
scene::instance_handle signal{0}; // Repair has a track read it again
|
|
bool lines{false}; // Repair sets the line signals again
|
|
};
|
|
std::vector<problem> m_problems;
|
|
bool m_drawing{false}; // the block boundaries drawn by hand
|
|
// a block boundary under the mouse while they are drawn: block signals across the line there, or the ones standing taken away
|
|
struct boundary
|
|
{
|
|
bool valid{false};
|
|
bool remove{false};
|
|
std::string entry; // of the line under the mouse, its entry signal shown
|
|
glm::dvec3 point{0.0}; // the joint, on its axis
|
|
std::vector<std::pair<glm::dvec3, glm::dvec3>> joints; // of each track, on its axis, the way out along it
|
|
struct post
|
|
{
|
|
glm::dvec3 point{0.0}; // on the axis
|
|
glm::dvec3 side{1.0, 0.0, 0.0}; // the signal stands off the axis so
|
|
std::string name;
|
|
};
|
|
std::vector<post> posts; // of the block signals
|
|
};
|
|
boundary m_boundary;
|
|
// a block boundary drawn on a line of the automatic block of the open station
|
|
struct block_edit
|
|
{
|
|
std::string entry; // of the line, its entry signal shown
|
|
glm::dvec3 point{0.0}; // on its axis
|
|
bool remove{false}; // the block signals standing there taken away, else placed
|
|
};
|
|
std::string m_status;
|
|
bool m_joint_editing{false}; // the joints of the track circuits edited by hand
|
|
std::optional<glm::dvec3> m_joint_held; // a joint picked up, to be put elsewhere or taken away
|
|
// what a click does while the joints are edited
|
|
struct joint_target
|
|
{
|
|
enum class kind
|
|
{
|
|
none,
|
|
add, // a new joint at the point
|
|
pick, // the joint there picked up
|
|
move, // the joint held put at the point
|
|
remove, // the joint held taken away
|
|
drop // the joint held let go, left as it stands
|
|
};
|
|
kind what{kind::none};
|
|
glm::dvec3 point{0.0};
|
|
};
|
|
joint_target m_joint_target;
|
|
std::optional<srk_hand_joints> m_joint_change;
|
|
// a joint of the track circuits put by hand near the point: on the plain station track nearest, none with Why
|
|
std::optional<station::joint> hand_joint(glm::dvec3 const &Point, std::string &Why) const;
|
|
// the joint of the circuits standing nearest the point, within reach
|
|
std::optional<glm::dvec3> joint_near(glm::dvec3 const &Point) const;
|
|
// the joint parts the station from a line out of it: it stays
|
|
bool joint_outer(glm::dvec3 const &Joint) const;
|
|
// the joints of the open station changed by hand, the circuits set again so; one step of the history
|
|
void change_joints(std::optional<glm::dvec3> const &Remove, std::optional<glm::dvec3> const &Add);
|
|
// the hand joints of the open station changed from Before: the circuits set again, the change one step of the history with them
|
|
// Forget: they were all forgotten, and the ones that changed nothing go too
|
|
void joints_changed(srk_hand_joints const &Before, bool const Forget = false);
|
|
// the track circuits of the open station set, known again after each change and for its code
|
|
bool circuits_set();
|
|
std::size_t m_circuits_revision{static_cast<std::size_t>(-1)};
|
|
std::string m_circuits_stem;
|
|
bool m_circuits_known{false};
|
|
bool m_status_refused{false}; // the status tells why an action did nothing
|
|
std::size_t m_status_count{0}; // of the actions begun, so the same status of the next one is told again
|
|
std::size_t m_told_count{0};
|
|
std::string m_told;
|
|
// an action begun: its status in place of the last one
|
|
void begin_status()
|
|
{
|
|
m_status.clear();
|
|
m_status_refused = false;
|
|
++m_status_count;
|
|
}
|
|
// the action does nothing: why
|
|
void refuse(std::string const &Why)
|
|
{
|
|
m_status = Why;
|
|
m_status_refused = true;
|
|
}
|
|
// the renames Number the switches was clicked for while events aim at the switches by their old names: a second click with
|
|
// the same ones renames anyway
|
|
std::string m_numbering_confirm;
|
|
|
|
void load();
|
|
void open(TTrack &Track);
|
|
void refresh();
|
|
record &record_of_open();
|
|
std::string title() const;
|
|
void render_found();
|
|
// the station as the Station tool set it, for the other tools; Line: the line and the km needed
|
|
void render_summary(bool const Line);
|
|
void render_station();
|
|
void render_switches();
|
|
void render_station_signals();
|
|
void render_line_block();
|
|
void render_check();
|
|
void render_canvas(float const Height);
|
|
void fit_view(float const Width, float const Height);
|
|
void find_all();
|
|
// the switches numbered along the station and named after its code; one step of the history
|
|
void number_switches();
|
|
// the station cut at the joints of its track circuits and the circuits named; one step of the history
|
|
void set_circuits();
|
|
// the track circuits as the tracks have them, for the schematic
|
|
void survey();
|
|
// the signals placed where the station has none and the standing ones named, the circuits before the entry signals set too; one
|
|
// step of the history
|
|
void set_signals();
|
|
// the signals standing by the station, for the schematic
|
|
void survey_signals();
|
|
// the lengths of the station tracks, the signals given by them
|
|
void measure(std::vector<station::signal> const &Signals);
|
|
// km/h, the highest of the speeds the tracks of the open station are set to, 0 while none is
|
|
double set_speed_of_open() const;
|
|
// km/h, the trains run the station at: the highest set on its tracks, else after the braking distance set by hand, else 160
|
|
double speed_of_open() const;
|
|
// m, the braking distance of the line of the open station: set by hand, else after its speed, as Ie-4 § 8 gives it
|
|
double braking_of_open() const;
|
|
// the lights of the signals checked against the routes of their trains and the places of the signals they tell of
|
|
void check_heads(std::vector<standing_signal> const &Standing);
|
|
void render_heads();
|
|
// of a signal in the list: in its tooltip how its template fits, in its row its aspects or its lights
|
|
static void render_head_fit(head_check const &Head);
|
|
static void render_head_aspects(head_check const &Head);
|
|
// the signals given the templates whose lights fit their routes; one step of the history
|
|
void fit_heads();
|
|
// the lengths of the station tracks as the list of the tracks gives them, the useful ones each way
|
|
void render_lengths();
|
|
// the lengths as a table to paste into a spreadsheet, a line a track, the columns parted by tabs
|
|
std::string lengths_table() const;
|
|
// of the lengths, the one of the station track the track is a part of, -1 for none
|
|
int length_of(TTrack const *Track) const;
|
|
// the signals of the lines out of the station: on a double-track line the block signals to the next station and the block
|
|
// sections between them, on a single-track one a warning disc before the entry signal; one step of the history
|
|
void set_lines(block_edit const *Edit = nullptr);
|
|
// the lines out of the open station from its entry signals standing, Entries: the signals of the plan they begin at, Owners:
|
|
// the standing ones; false with the reason while it has none
|
|
bool lines_of_open(std::vector<standing_signal> const &Standing, std::vector<station::line> &Lines, std::vector<station::signal> &Entries, std::vector<std::size_t> &Owners, std::string &Problem) const;
|
|
// the block of the line: as set by hand for its entry signal, else the automatic one where block signals stand along it, of four
|
|
// aspects where one of them has, else on a double-track line, of the aspects of the block signal chosen in Signals, else
|
|
// the semi-automatic one; Own: the block it has by itself
|
|
block_kind block_of(station::line const &Line, std::string const &Entry, std::vector<standing_signal> const &Standing, std::vector<signal_head> const &Heads, block_reason &Why, block_kind &Own, block_reason &Own_why, std::size_t &Blocks) const;
|
|
// the automatic block of the double-track line both ways: as set by hand for its entry signal, else where block signals stand
|
|
// along it, when some of them face its wrong-track trains, else on a new line; Own: so by itself
|
|
bool both_ways(std::vector<station::line> const &Lines, std::size_t Index, std::string const &Entry, std::vector<standing_signal> const &Standing, bool &Hand, bool &Own) const;
|
|
// the line of the kilometrage a line out of the open station runs along: of the station, at a junction another one
|
|
std::string km_line(station::line const &Line) const;
|
|
// the km out along the line, Number: of the line of its kilometrage
|
|
double km_along(station::line const &Line, std::string const &Number, double const Distance) const;
|
|
// the trains of the line run towards the higher km
|
|
bool km_rising(station::line const &Line, std::string const &Number) const;
|
|
// m, the braking distance at the highest speed out along the line, at 160 km/h while its tracks have none, unless set by hand
|
|
double line_braking(station::line const &Line) const;
|
|
// the lines out of the open station, for the panel
|
|
void survey_lines(std::vector<standing_signal> const &Standing);
|
|
void render_lines();
|
|
void survey_problems(std::vector<standing_signal> const &Standing);
|
|
void render_problems();
|
|
// the signals no track reads read by the tracks they stand by, the lines with tracks in no block section set again; a step of
|
|
// the history each
|
|
void fix_problems();
|
|
// the SHP track resonators placed where the signals checked need them and have none: 200 m before an entry signal, a block
|
|
// signal and a warning disc, at an exit signal onto a line of the automatic block, the track cut where none of its joints lies
|
|
// within 5 m, its event put on the track the trains run into there; one step of the history
|
|
void set_shp();
|
|
// the names of the switches and the circuits of the open station begin with it, empty while it has no code
|
|
std::string stem_of_open() const;
|
|
// the km at the chainage of the open station: of the kilometrage of its line, else of its record, else of its switches; false
|
|
// while unknown
|
|
bool km_of_open(double const Chainage, double &Km) const;
|
|
// the km at the chainage of the open station, as the Kilometrage tool sets them for its line; false where it doesn't
|
|
bool km_of_line(double const Chainage, double &Km) const;
|
|
// the line of the open station: of its record, else the one the Kilometrage tool sets the km of through it; empty for none
|
|
std::string line_of_open() const;
|
|
// the station tracks by their numbers with their circuits as the tracks have them, Inside: the tracks of the circuits; false
|
|
// while it has none
|
|
bool station_tracks(std::vector<station::numbered> &Tracks, std::unordered_set<TTrack const *> &Inside) const;
|
|
// the circuits of the station track of the track renamed after another number; one step of the history
|
|
void renumber_track(TTrack const &Track, std::string const &Number);
|
|
};
|