mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-05 16:55:32 +01:00
9b431e8bf3
* 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.
* feat(editor): the norms of the track geometry, a module of their own: the profiles as tables, one engine
Stage E1 of editor-tracks-domain.md (§3, §6): the norms stand on their own in editor/norms, with no scene, no tracks and no user
interface, so they are tested whole in tests/unit. Nothing of the editor uses them yet but the report of the next commit;
alignment::limits stays as the laying tools use it.
- The profiles are tables of rows (normsTables.cpp). A row holds the limits of PREFER / WARN / BLOCK of one parameter where its
conditions hold (a band of the speed, of the radius or of the load, main or side track, the traffic, a switch and its frog, a
crossing, an expansion device, a platform, a station track, ballastless track, crest or sag), with the table or the paragraph of
its document. Where several rows hold the strictest limit of each tier counts. A cell can be unconfirmed: it warns, never blocks.
- PLK, ST-T1-A6 v1.0: P0 PREFER, P1 WARN, P2 BLOCK; tab. 8.1, 9.1, 9.2, 9.6 - 9.8, 9.10, 9.12 - 9.16, 10.1, 10.2, formula 9.8.
- TSI only, Reg. 1299/2014 consolidated 28.9.2023: BLOCK; 4.2.3.3 - 4.2.3.5, 4.2.4.2 - 4.2.4.4.
- EN 13803-1:2010 5.2.1 - 5.2.5: normal WARN, exceptional BLOCK.
- CH, AB-EBV AB 17 (Normalspur, 1.7.2024): Grenzwert im Normalfall WARN, maximaler Grenzwert BLOCK.
- In every profile the global hard limits of §6.3: the TSI rows and the cant gradient of 2.5 mm/m (EN 13803-1 5.2.5, the twist).
- The line class: Vmax, Vmin of the slow trains (by tab. 8.1 when not given), passenger / mixed / freight, main or side track,
the load, and what holds along the line (platform, station, ballastless, suburban, tilting).
- One engine (normsEngine.cpp) over a line of elements (straights, transitions, arcs, the curvature changing evenly along each),
its cant (points, a step being two at one chainage) and its grade line: I at Vmax and E at Vmin; dI/dt along the transitions
and the ramps; ΔI at every jump of the curvature or of the cant, the jumps closer than the intermediate length of the profile
(tab. 9.16) taken together while the deficiency keeps changing one way (9.11 pkt 8 - 13); dD/ds and dD/dt along the ramps, a
step of the cant as its twist on the 5 m base; the lengths of the straights, arcs and transitions and the shift of the arc; R;
D with (R - 50) / 1.5 and the least cant; Rv and the breaks of the grade over 2 per mille; the held grades. A finding names the
parameter, the value, the limit, the tier, the profile, the source, confirmed or not, hard or not, and the chainage. The module
makes no text, its users write the messages.
- Areas (§6.4): the default profile of the scenery, areas outlined in the plan, lines by name (a line's own wins). An element with
its ends under two profiles is checked against both, the worse kept (the stricter one); an arc across a boundary is a warning.
- describe() reads a line from samples along it (the curvature, the cant and the grade simplified by Douglas and Peucker), with a
precision of 0.2 % for the values measured on it.
- The formulas of ST-T1-A6 9.1 - 9.10: Deq, Dreg, I, E, Dmin, Dmax, Rmin, V.
The sources, and what they gave:
- The cells of ST-T1-A6 spanning two or three columns (tab. 9.1, 9.6, 9.7, 9.13 - 9.15, 10.1, 10.2; §6.5 pkt 4) were read on the
pages of the PDF. Tab. 9.15 has for the connections of tracks P0 = P1 = 80 mm at 100 < V <= 160 and 60 mm at 160 < V <= 200,
P2 160 - 0.35 V; the table of §6.2 has P1 = 160 - 0.35 V there. Tab. 9.1 has P1 = P0 (one cell), not "-".
- TSI tab. 8 (§6.5 pkt 3): the 153 mm spans both columns up to 300 km/h, 100 mm only above 300 km/h.
- Unconfirmed, warning only: tab. 9.8, 5 < q <= 10, P0 95 mm, and tab. 9.7, movable frog 230 < V <= 250, P2 110 mm (as printed,
out of line with the rows around them); EN 13803-2:2006+A1:2009 7.1.3, ΔI of the plain line 50 / 40 / 30 mm, read from a garbled
preview.
- Not there: ST-T1-A6 tab. 9.4 (a picture); EN 13803-1 dD/dt, dI/dt, ΔI in S&C, element lengths, Rv and grades (beyond the part of
the standard published as its preview); AB-EBV a limit of the grade of a line, the least cant, the table of the buffer locking of
5.4.2; the TSI has no dD/ds, dD/dt nor dI/dt. DB (Ril 800.0110) is left out: it isn't published, its values are known from
secondary sources only.
- Simplified: the (R - 50) / 1.5 of the TSI holds for every R < 305 m of mixed and freight traffic, leaving out its condition of
a ramp steeper than 1 mm/m; the intermediate element of tab. 9.16 between transitions is the one of tab. 9.1 at P2 (tab. 9.10 at
P2 would do there); a switch has a fixed frog unless the track says it moves; the track is ballasted unless the class says not.
Tests: test_norms_tables.cpp, every value of the PLK tables and of the TSI with its table in the name of the test, the edges of the
bands (a speed on the boundary, R 300, 250 and 200 m), some of EN and AB-EBV; test_norms_engine.cpp, the examples of ST-T1-A6
(Z1-1, Z1-2, załącznik 2, the ramps of Z3-2 and Z3-3), I at Vmax and E at Vmin, ΔI of arcs turning alike and the other way, taken
together over a short straight or not, dD/ds, dD/dt, a step of the cant, dI/dt, the lengths, the vertical curves, the areas and the
boundary, describe().
* feat(editor): the norms checked on the tracks laid, read only: a Norms tab of the track analysis and its report
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.
* feat(editor): the elements and the line of the track geometry, a module of their own
The first part of E2 (editor-tracks-domain.md §2 - §4): the geometry of a line computed in one place, editor/layout, standing on its
own with no scene, no tracks and no user interface. Nothing of the editor uses it yet; the route design keeps its own solver.
- layoutElements: the elements of a line, the straight, the arc, the clothoid (the curvature changing evenly, from any curvature to
any other), the Bloss curve (3t^2 - 2t^3) and the cubic parabola (y = x^3 / 6RL by the abscissa, the length along it its own):
the length, the curvature along, the point and the heading at a distance, a point offset from the axis, the shift of the arc. The
local forms of the clothoid and the cubic parabola and the blossom of a Bezier curve are the ones of editorAlignment.cpp, moved
here word for word; the alignment calls them, so the two agree to the bit and its tests run as before.
- layoutLine: the line as a tangent polygon between the points of its two end nodes (it has no coordinates of its own there), its
vertices with the radius, the transitions in and out and the cant, a grade line of breaks with their vertical curves, the shape of
the transitions and of the cant ramps (linear or Bloss). solve() lays it: each curve fitted in the frame of its tangent point
from its deflection (the arc what the transitions leave of it), the straights what the tangents leave of the sides, every element
placed from the polygon so nothing drifts; the cant held along the arcs, ramped along the transitions, a step refused; the heights
and the grades by the breaks. An end can go on from the curvature and the cant its node holds (a line split inside a curve):
its curve begins right at the node. What can't be laid is an error with the vertex and the metres: curves overlapping, a curve
starting before the start, transitions turning more than the tangents, a cant step, a vertical curve past the end.
- described(): the line as the norms module reads it (elements, cant points, grade elements), a Bloss ramp seen by eight points
so its steeper middle counts. preferred_curve(): the cant and the transition length the profile prefers for a radius at the line
class, the deficiency, the excess and the greatest cant of PREFER, else of WARN, the transitions long enough for dD/ds, dD/dt
and dI/dt.
- norms::line_class compares by its values (operator==), the line keeping it compares whole.
Tests (U): the clothoid, the cubic parabola, the Bloss curve and the arc against the series of the textbooks (the end point, the
length of the parabola, the shift: L^2/24R and L^2/40R), the point as the integral of the heading, the circles alongside an arc, the
curve of a vertex by its tangent length (R + p) tan(a/2) + x_m.
* feat(editor): the nodes of the track geometry and the commands editing the lines, kept whole or refused, one step to undo
Continues E2 (editor-tracks-domain.md §4 "Edycja = polecenie", §8): the lines meet at nodes, and every edit is a command which
proposes a new state, has what depends on it laid again, is checked and kept, or refused with its reasons and nothing changed.
- layoutNetwork: the node, its place (the only coordinates of the ends of the lines), the heading, the curvature, the cant and the
grade, and the ends of the lines meeting there, each with its sense along the heading; the network of the nodes and the lines
with the profiles of the norms by place and the identifiers handed out once, never again (an undone line made again is a new one).
A transaction keeps each line and node the first time it touches it, so a change is rolled back whole or recorded.
- settle(): the lines touched laid again; the nodes take the values of their ends (a free end follows its line, a node keeps the
curvature and the cant a line going on from it reads), a line going on from a node whose curve changed is laid again.
- check(): the invariants of the touched lines and nodes: laid, at their nodes, two ends at most on the two sides of a node (more
is a turnout, E5), the heading the same within 1e-9 rad, the cant within 0.5 mm, the grade within the 2 per mille that needs no
rounding; and the norms along the chains through the touched lines (the lines running on through the nodes as one line, the
elements running on alike across a node as one, a jump of the curvature at a node a step of the deficiency the profile judges):
BLOCK refuses, WARN and PREFER are told as notices.
- layoutCommands: create a line between two new nodes; move a vertex; set its radius, transitions or cant; split a line at a
chainage (the track kept as it was: on a straight, in an arc, in a clothoid with a straight ramp, the parts going on from the new
node at its curvature and cant; refused inside a vertical curve and inside a Bloss or cubic parabola transition); join two free
ends with a line solved between them (a straight, a curve where the tangents meet, or two curves, the largest radius which fits
with the cant and the transitions the norms prefer, a grade line meeting the grades of the ends); delete a line (a node left with
no end goes). The model keeps the network and the steps: undo and redo restore the snapshots of the lines and nodes a command
touched, one step a command.
Tests: the cases of each command, a refusal (a radius under the least, a cant over the greatest, curves overlapping, transitions
too long) leaving the state as it was, a WARN radius kept with its notice, undo and redo, the track the same along a line split on a
straight, in an arc and in a clothoid, a middle part deleted and joined again both ways round, a straight joining two ends on one
straight. P: 300 random edits each with the seeds 20261123, 7 and 450 (moved vertices, new radii, transitions and cants, splits,
joins, deletions, undo, redo): after each the invariants checked on their own (each element running on from the last, the cant
running on, the ends of the lines at their nodes to the bit, the heading, the cant and the grade running on through the nodes) and
no BLOCK along any chain; a refused command leaves the state as it was, an undo gives the state before the command.
* feat(editor): the tracks of the simulator made of the lines of the track geometry, within half a millimetre
The last part of E2a (editor-tracks-domain.md §3 and §5): the generator, the layer between the domain and the simulator. A line is
cut into cubic Bezier pieces, each one a track entry of the text TTrack::Load reads. Nothing of the editor writes them yet.
- The pieces end at the elements, at the ends of the vertical curves and of the cant ramps; each one halved until the curve as the
simulator draws it lies within 0.5 mm of the line, in the plan and in the height, and its cant within 2 mm of the line where the
simulator turns the roll evenly; none longer than a track may be (400 m), none shorter than 10 cm. The handles of an arc are its
own, 4/3 tan(turn / 4) R; a transition takes the handles which give the curve the curvatures of the line at its ends (G2 Hermite,
by Newton's method, those of an arc where it finds none near them); a cubic parabola is the cubic Bezier curve it is, cut by its
blossom; a straight of an even grade has no control vectors, as the simulator draws it. A piece TTrack would take for a straight
(its 2 cm check of the control vector) is one, close enough or halved.
- The rolls and the heights come from the functions of the line, the radius from the element: an arc's own, the sharpest over a
transition, 0 on a straight. A piece ends at a node with the numbers of the node, its place, its heading and its cant, so the
tracks on both sides of it have the same numbers to the bit; the numbers are written in the shortest form which reads back to the
same double.
- The names come from the identifiers: <prefix><line>_<element><piece>, the element the straight leading to a vertex (s7, se to
the end) or the transition in, the arc or the transition out of a vertex (v7i, v7a, v7o); a change of a curve leaves the names of
the pieces of the others.
- The joints of old tracks as hard points of the pieces, keeping their names and events, are E6 (§10): generator_options has their
place, a line given any is refused rather than made without them.
Tests: the pieces of lines of clothoids, Bloss curves and cubic parabolas, of R 190 m and of 5 km with vertical curves, each
measured both ways (the points of the curve set square onto the line, and the points of the line against the nearest of the curve,
searched on its own): within 1 mm, the farthest 0.35 mm (0.45 mm with Bloss curves). G: a line split on a straight and in an arc,
its tracks written and read back by TTrack::Load (the E0 seam): the ends at the nodes and between the pieces the same to the bit on
both sides, the rolls and the headings of the control vectors too, the curve within 1 mm of the line, the radius of the element;
a line laid the other way through its nodes; the names unique and kept by a change of another curve; the E6 hook refusing.
* lang(editor): Polish for the strings of the switch rules and the norms of the track geometry
62 entries the stages of the track editing added without a translation: the crossover taken out whole (#450), the refusals and the speed of the switches (#454), the Norms tab and its report (#456), in the terms of ST-T1-A6 (niedomiar, nadmiar przechyłki). Also "Other switches of a connection##connectionsecond": field_row looks the label up with its id, which the file had only without it.
* feat(editor): the first steps in the inspector, one way to start, the line laid summed up
The first steps of the editor, after the first-run pass at 1920x1080 and 1366x768 (P1 of the plan of the
editor's interface):
- The tutorial no longer opens by itself as a window over the middle of the view (at 1366x768 over all
of it, its close button under the tool row). With nothing selected, the inspector shows a compact
"First steps" card: the lesson of the tool in use, its steps to try ticked as they're reached, the
links "Show the lesson", "The camera" (the first lesson) and "Hide" (the setting first_steps, which
the checkbox of the window now names "Show the first steps in the inspector"). Opened, the window of
the lesson goes into the corner of the view by the inspector, below the rows of the menu and the
tools; moved, it stays between them and the status line, as high as that room at most, the lesson
scrolled inside. Its close button is always within reach.
- The lesson follows the tool: the select tool of Tracks opens "Laying track" until its steps are done,
so a new scenery opened in Tracks starts there, not with the camera, which stays the first page and a
link of the card.
- An empty scenery in Tracks with nothing selected: "The scenery has no tracks yet" and one highlighted
button, "Lay the first track (L)"; the tutorial is the card under it, a "Tutorial" link when the card
is hidden. With tracks, the select tool keeps its hints and a plain "Lay a track (L)".
- "Without terrain", the answer to the question of the terrain at the first L, turns off the terrain
made of the terrain model by itself: under the tracks as they're laid (the checkbox of the layers) and
around the camera within the download area (the checkbox of the terrain panel), stops putting the
squares of the area into the cache, a square on its way giving way at once, and drops the squares
waiting. Kept on, the model went on being asked for, and offline the log filled with "NMT square ...
not fetched: WinHTTP error"; now nothing is asked for after the answer.
"Load the terrain" turns both on again. The squares of the area go to the cache, and the aerial photos
ask for the model to lie on, only while some terrain is made of the model by itself. The question
stands in the middle of the view, the window of the lesson waiting meanwhile. The warning of no ground
under the mouse shows only while the pointer is over the view and the terrain is to be there.
- The tooltip of the line being laid names the panel the rest of its warnings are in ("listed in the
tool options"): the translation of the text before said "in the panel on the right", the panel is on
the left.
- While the pointer is over a panel, the line being laid stays as it was: the point of the cursor, the
free end it snaps to and its height aren't taken from where the pointer is under the panel, which
added a leg there with curves and warnings of its own. A drag begun in the view goes on over a panel.
- After Enter the inspector sums up the line laid: its tracks, length and curves, those below the norms
in orange, and what comes next, "A switch (T)" and "Save (Ctrl+S)". It stays while the last track is
the selection the laying left; a click on a track shows the sheet of that track. The switch tool with
nothing clicked shows the same, not the sheet of the last track laid.
- A switch the switch tool refuses is told in its panel and by the cursor, no longer in the status line
and the layers window as well, where it stayed after the next switch was laid. Why a branch couldn't
lead into a free end goes into the panel with the rest; a switch laid takes the note by the cursor
away.
- The panel of the lay tool fits one screen at 1366x768: what the tool is for is the tooltip of the
title of its card, the paragraph of the radius at the bends the tooltip of its "?" (which still opens
the lesson), "This speed also on from a track with a speed of its own" is under More settings; the
mode, the speed and the height stay up front.
- The layout made on the first start: the side columns 22% of the width, at least 300 px, at most the
400 and 460 px they had and 30%; at 1366 px the view has about 766 px instead of 557. The tool options
take 60% of the left column, and in a window under 800 px high the layers are a tab beside them, the
tool options shown, so the panel of a tool has the whole column. The line of the keys of the
surroundings goes on under itself at the edge of the panel. Layouts kept in imgui.ini are left as they
are.
- The names of the period of the day, the season and the weather in Weather and time, and the type of a
node in the inspector of the surroundings, go through the translations ("(day)", "(autumn)",
"(scattered)", "Typ: track" before). The degree sign of the air temperature is written as its UTF-8
bytes: CMakeLists.txt sets COMPILE_OPTIONS of eu07 and eu07_core after add_compile_options("/utf-8"),
which drops /utf-8, so MSVC writes the "°" of a literal as the single byte 0xB0 of the ANSI code page,
not UTF-8, and ImGui drew '?'.
- Self-tests: the expectations statuslacks, refusal, statusline, laycursor and terrain, the command
nmtquestion, and the cases fs_1_preview_over_panel, fs_2_switch_refusal_cleared and
fs_3_without_terrain.
lang/editor_pl.po: the Polish of the new texts (the card of the first steps, the summary of the line laid,
"Lay the first track", the names of the periods, seasons and weathers and of the node types), the entries
of the texts replaced given their new English ("Show the first steps in the inspector", "and %zu more,
listed in the tool options", "Lay the first track (L)" in place of "Or start with:"), and "(do
transmisji)" in place of the English "(stream)" of the drawn cursor.
* feat(editor): the speed of the diverging track of a switch, one rule for the editor and the domain model
The formula Q2 gave the editor (editor_mode::branch_speed_of) taken out into a pure function of the switch curve module, which the
domain model of the track geometry (editor/layout, E2b) calls for its turnouts too, so the two write the same speed.
- switch_curve::branch_speed(): of the basic switch of R and 1:n, its main track bent by table 11.8, the cant with its sign toward
the side the diverging track leaves to: formula 9.9 with the normal deficiency of the frog (table 9.7), rounded down to the steps of
the speed limits, no more than table 11.2 gives the basic switch. It reports the radius, the cant into the turn, the deficiency, the
formula, the rounded speed and the table, which the editor's message tells.
- switch_curve::basic_speed(): table 11.2, moved from editor_track::diverging_speed(), which now returns it.
- switch_curve::written_velocity(): the one velocity a switch keeps, the main limit for both where it's the lower, else the
diverging one below 0; write_switch_speed() calls it.
- speed_check::suggested() inline in editorSpeed.hpp, so the switch curve module takes it in the unit tests, which don't build the
checks of the speed.
The editor computes the same numbers the same way: the basic radius and the bent main radius as before (bent only where the type is
known), the cant toward the diverging side the same product, its sign flipped by the bent radius as before (a multiplication by -1,
exact), then the same calls in the same order. tests/unit/test_switch_curve.cpp unchanged and passing.
Tests (U): the examples of Q2 through branch_speed (Rz 60E1-500-1:12 outward in R 1200 m with 60 mm 60 km/h, inward 60 by the table;
Rz 60E1-190-1:9 in R 600 m with 60 mm 30 and 40 km/h), the table of the basic switches, a movable nose kept to 130 km/h, a diverging
track bent straight, the editor's table the same, the velocity written.
* feat(editor): the turnouts of the track geometry, laid into a line, moved, changed and taken out, their legs nodes
E2b (editor-tracks-domain.md §2, §4 "Rozjazd", §7, §8): a turnout is an aggregate of the domain model, laid from the catalogue the
editor lays its switches from, its rules invariants which refuse.
- layoutTurnout: the type of the catalogue (switch_design::catalogue(), Id-4) as the model lays it: R, 1:n, a, b, the main length,
the lead and the parts of the diverging track, the movable nose, the blades; the ordinary switches whose diverging track leaves
tangentially, the double, symmetric and secant ones refused with the reason (E5). The diverging track laid off the start along the
turnout: on a straight the curve of the type; bent with the main track the curve of the basic switch of the radius of table 11.8
(switch_curve::bent_radius), over the length which keeps its turn off the main track, so the angle of the frog stays 1:n, the lead
and the straight through the frog bent along with the main track; the cant of the main track all along it, the grade of its start.
The speeds: the diverging one by switch_curve::branch_speed (the rule the editor writes), the main one the line's, bent no faster
than the deficiency of the frog lets it; the velocity written by the same rule as the editor's.
- The turnout: its type, hand, direction along the line, its start, the ends of its two tracks (nodes), its main and diverging track
(lines it owns), derived: the kilometrage of its start, the bending, the cant, the speeds. The network keeps the turnouts with the
lines and the nodes, in the snapshots of undo and in the transactions; settle() has a turnout whose main track or start changed
lay its diverging track again, move the node at its end and lay again the lines going on from there.
- The nodes: three ends at the start of a turnout, its two tracks on one side of it; the start of a diverging track tells its node
nothing (the node keeps the curvature of the main track) and runs on into no line, the end of one sets its node.
- check(): the turnouts whose tracks or legs are touched, their invariants (the legs, the tracks, the main track as long as the type)
and the rules of Q2 and 11.4 through switch_curve::check (the curvature of each track of one sign, KZW II refused; the cant the same
over it; the ends of the ramps at its ends or 6 m off it), a switch of 1:9.403 or steeper than 1:9 bent in a main track refused (the
model knows a main track from a side one, where the editor only warns), table 11.9 and a transition under it as warnings. The norms
of the E1 module with the switch context: the elements of a turnout track are a connection of tracks of their frog (fixed or movable
nose: the deficiency of tab. 9.7), bent or not (the cant of tab. 9.6), at its speeds; the chain of the line runs through the main
track, the element cut by a turnout open. BLOCK findings are kept apart from the broken invariants (verdict::blocks).
- The commands: insert a turnout at a chainage of a line (cut at its legs, the part between them its main track), move it along its
line (the lines on both sides and its main track one line again, cut anew, the ids kept, a line going on from the end of its
diverging track carried with it), change its type or hand, remove it (the line one again where it can be: the merge laid and kept
only where it's the same track within a micrometre). The tracks of a turnout aren't split, deleted or edited as lines; a line is joined
to the free side of a turnout's start, or to the end of its diverging track from a straight (the curvature stepping there).
Tests: U: the types laid and refused; the legs on a straight against the catalogue for four types both hands both ways (the main
track a + b, the tangent of the diverging end meeting the main track at R tan(a/2), Id-4's a within half a millimetre, the angle 1:n,
the speeds of table 11.2); Rz 60E1-500-1:12 bent outward and inward into R 1200 m with 60 mm (r" 857.8 m and 352.7 m, 60 km/h, the
angle of the frog kept, the cant over it); refusals: KZW II, a ramp under it and 3 m off it, a 1:7.5 bent in a main track (laid in a
side track), no type, no hand, no room; moved, changed, turned, taken out with the line laid again within a micrometre, each a step
to undo; a line from the diverging end carried along. P: 250 random edits with turnouts each, seeds 20261124, 31 and 977 (laid,
moved, changed, taken out, with vertices moved and set, splits, joins, deletions, undo, redo): the invariants after each (the legs
and the nodes whole, three ends only at a start, the velocity by the rule), no BLOCK, a refusal changing nothing, an undo exact.
* feat(editor): the edits E2a left: vertices, the grade line, the class and the profile of a line, a join from a curve, no new BLOCK
The rest of the list E2a left for E2b (editor-tracks-domain.md §8), commands of the domain model of the track geometry like the others:
kept whole or refused with the reasons, one step to undo.
- insert_vertex (after a vertex, or after the start, with its radius, transitions and cant, its id given) and remove_vertex.
- set_grades: the breaks of the grade line with their heights and vertical radii; checked by the solver (overlapping vertical curves)
and the norms.
- set_line_class and set_line_profile: the class of a line (its speed, traffic, main or side track) and a profile of the norms of its
own (the line's own wins over the areas, as norms::area_map has it); a chain of the norms doesn't run on into a line of another
profile of its own. The tracks of a turnout take a class too, their speeds derived again.
- join_ends from a free end in a curve (a line cut inside one): one curve where the tangents meet, going on from the curve at the end,
its arc of the radius there with no transition (or, where that doesn't fit, a radius the norms prefer and a transition from the
curvature of the end), the transition at the straight end as long as makes the curve begin right at the curved end (bisected to the
bit), refused where both ends lie in curves or the curve would turn the other way. The original join and this one lay the new line
the same way (add_joined).
- edit_policy::no_new_block for old tracks (stage E6): an edit is refused by a BLOCK finding only where it adds one; one there before,
of the same parameter on the same stretch (the elements within 1.5 m, the findings carry their element as points of the plan) and no
worse, doesn't refuse; the same rule of the same turnout neither. The invariants refuse in any case. model(network) takes a network
over as it is, the norms not asked.
Tests: U: a vertex put in and another after it, both taken out, the line as it was; a grade break and its vertical curve, two
overlapping and one of no radius refused; a class of 200 km/h refused on curves fine at 80, one of 60 kept; R 280 m at 80 km/h warned
by PLK, not by the TSI as the line's own profile; a line joined to a free end in an arc going on from it with the transition the part
taken away had, the track the same within a micrometre; both ends in curves refused; R 170 m laid by the TSI and judged by PLK: an
edit refused when any BLOCK refuses, kept with no_new_block, a sharper curve and a cant past (R - 50) / 1.5 refused, a wider curve
kept. P: 250 random edits of an old track breaking the norms (curves laid for 80 km/h judged at 120), seed 4242, with no_new_block: no
BLOCK finding over all the network which wasn't there before, a refusal changing nothing, an undo exact; the random edits with
turnouts put vertices into straight lines and take them out.
* feat(editor): the switch tracks of the simulator made of the turnouts of the track geometry, the legs at their nodes to the bit
The generator (editor-tracks-domain.md §5, "Rozjazdy") makes a turnout one switch track entry TTrack::Load reads: the paths of its main
and its diverging track, each from the start of the turnout.
- Each path the pieces of its line as the generator cuts any line (within 0.5 mm of the elements, the rolls and the heights from the
line), turned round where the main track runs against the turnout, written as pieces1/pieces2; the path itself the curve between
their ends and headings for the versions which know only the path, or the one piece where one makes it. The ends of both paths are
the numbers of the nodes of the legs, so the tracks on the other side of them meet them to the bit.
- velocity as the speed rule gives it (the main limit for both where it's the lower, else the diverging one below 0), frogs, the
movable nose and the blades of the type where it has them; the name <turnout_prefix><turnout>, t by default.
- A track of a turnout isn't made as a line of its own; generate_all() makes the lines, then the turnouts.
Tests (G): turnouts on a straight with a grade (a 1:12 to the left along the line, a 1:9 to the right against it, a 1:26.5 with a
movable nose) and one bent outward into R 1200 m with 60 mm, written and read back: both paths from the start node, the main one to
the end of the main track, the diverging one to its end, to the bit; the pieces as written, joined to the bit, each within 0.5 mm of
its line both ways (the farthest 6e-6 mm: short arcs of one Bezier curve each); the radius of the bent diverging curve; the velocity,
the movable nose and the frogs read back; the tracks of the lines on the other side of the legs ending there with the same numbers and
rolls (of the other sign where they meet head on). The diverging track of Rz 60E1-2500-1:26,5 as the simulator draws it within the chord
offsets of Id-4 (30 m chords, 41 to 49 mm in the middle): 45.0 mm all along, 130 km/h on it.
Left for E5: the catalogue as a data file (now switch_design::catalogue() in code), the double, symmetric and secant switches, the bending
exact everywhere (now table 11.8 for the curve of the basic switch, the rest of the diverging track bent with the main one, a main track
on a transition taken at its mean curvature), the connection solver (crossovers, the spacing measured along).
* feat(editor): the project file of the track geometry, one per map, of a schema of its own
The first part of E3 (editor-tracks-domain.md §9): the domain of the editor written next to the scenery, the .scn and .scm files
staying what the simulator reads. editor/project/projectFile reads and writes it, nothing else does; nothing of the editor uses it yet.
- <map>.eu07proj next to the file of the map, shared by the scenarios of the map; plain text, a line a record, the version of the
schema on the first line. Version 1:
eu07proj 1
next node 9 line 8 vertex 1 turnout 3
norms plk
area granica ch 4 -500 0 -100 0 -100 400 -500 400
lineprofile 91 en13803
class 1 vmax 80 vmin 0 traffic mixed track main load 5 features 0
node 3 at 300 101.2 0 heading 1 0 curvature 0 cant 0 grade 0.004 ends 3 1 end 1 2 start 1 4 start 1
line 1 from 1 to 3 class 1 chainage 0 transition clothoid ramp linear continues 0 0 turnout 0 profile tsi
vertex 2 at 0 800 radius 300 in 60 out 60 cant 40
grade 200 101.5 5000
end
turnouts
turnout 1 type Rz%2060E1-500-1:12 hand 1 direction 1 start 3 main 2 4 diverging 4 5 chainage 300 radii 0 500 cant 0
speeds 80 60 velocity -60 movable 0
end
anchors ... end kept for E6 as read, empty in version 1
generated ... end the tracks the generator wrote (the next commit)
legacy h trasa/tory.scm line 1 [why ...] / | <the //$ line> / end the //$ lines read when the map was first opened
The profile of the scenery, the areas and the lines by name; the classes of the lines, each one once, the lines naming theirs; the
nodes with all they hold, the ends in their order; the lines with their vertices, grade breaks, shapes, chainage, turnout and
profile of their own; the turnouts of E2b with their legs, their tracks and what they derive. Numbers in the shortest form which
reads back to the same double, names and files with %20 for a blank.
- Read: the lines laid between their nodes as read, then the diverging tracks laid by their turnouts off the main tracks, the nodes
and the turnouts as written; what refers to what checked (a line's ends held once by its nodes, the classes there, the turnouts and
their tracks each of the other); a file of a newer schema refused before anything of it is read, with the reason, as is one which
isn't a project file, has a record not of its version or a section not ended. Saved through a file next to it put in its place.
- The identifiers handed out are kept (next), so none is handed out again after a load, whatever was deleted before the save:
layout::network gets handed() and hand_out(), the turnouts' counter with them; nothing else of editor/layout changes.
Tests: G: a network edited by the model (a line deleted between two) written, read and written again: the same text, the lines laid
again the same to the bit as the model laid them; two turnouts, one against the line, and a line of a profile of its own: the same to
the bit, the diverging tracks too (the network as settle() leaves it: the model lays the diverging track of a turnout against the line
before the node at its start takes the grade of the line beyond it, 1e-16 off); the golden file of data/project/ read and written back
the same, with the line ends of windows too; the anchors kept as read. A newer schema, an empty file, not a project file, broken
records (a turnout whose track isn't its among them) refused cleanly. U: the identifiers after the last line is deleted, a save and
a load: the next line, its nodes and its vertices numbered past them.
* feat(editor): the tracks the generator wrote kept by their checksums, a track changed by hand marking its line
Continues E3 (editor-tracks-domain.md §9, "Ręczna zmiana wygenerowanego węzła ... wykrywana po sumie kontrolnej"): the generated
section of the project file and what the scenery files hold of it now. Nothing of the editor writes the tracks yet (E4).
- generated: a record a track the generator wrote, its name, its line, the file it's written into and the FNV-1a checksum (64 bits)
of its text as the simulator reads it: the words joined by one blank, the comments left out, so the line ends and the blanks
another tool writes aren't a change; the switch track of a turnout kept by the main track of the turnout.
track l1_s11 line 1 file trasa/tory.scm sum 0123456789abcdef
switch t1 line 2 file trasa/tory.scm sum 00000000000000ff
hand 3
record_generated() puts the pieces of a line, or the switch track of a turnout, in the place of the ones the project had of it;
find_hand_changes() looks the names up in the text of the files now: a text of another checksum, or a track gone, or a file which
can't be read; mark_hand_changes() marks their lines changed by hand (hand <line>, kept by the file), may_overwrite() tells the
editor to leave them, until the line is written again by the editor (the author decided).
- editor/project/sceneryText: the text of the scenery files read as cParser and state_serializer read it, with no scene: the words
(blanks and semicolons between them, // and /* */ comments, the quotes), the node of a name and its words up to the end word of its
type, and the statements of a scenery with its includes followed relative to the scenery folder (the words of each file taken as
they're needed, the includes no deeper than 32), the parameters of a template in place of (p1)..., the placement of origin, rotate
and scale at each include, the terrain files passed over for a binary terrain. The scenario index and the migration read the files
with it.
Tests: U: two lines generated into one file among other nodes: as written nothing is changed, through the project file too; the speed
of a track of the second line edited: that line and that track told, marked changed by hand once, kept by the file, the first line
not; written again, not marked. The switch track of a turnout: its speed edited marks its main track. Blanks doubled, the line ends of
windows and comments inside a track aren't a change; a track taken away, a file which can't be read are. The node of a name found by
the words.
* feat(editor): the //$ lines of an old scenery taken into the project file when its map is first opened
Continues E3 (editor-tracks-domain.md §9 "Migracja", §10): what the //$ lines describe of the track geometry becomes the lines and the
nodes of the domain where the domain lays it as the editor laid it; the rest is kept in the project file as it was written. The lines
stay in the scenery files, untouched; the scenery files aren't written.
- //$h, an alignment: a line between two nodes at its ends, its vertices where the design puts them (from the tangents of the ends
for one, by the offsets for the first and the last of more), their radii, transitions and cants, the shape of the transitions,
the origin as the chainage of the start, the speed as the highest of the class; a curve going on from the adjoining track as an end
going on from the curvature and the cant of its node. Not a compound curve, two transitions with no arc between them, cant ramps
of its own, a curve turning the longer way, a curve going on from a switch, a design kept for a part of its line, nor one the domain
lays to a length 5 mm off the old one: kept as it was, with why. The free ends of two lines within 0.5 mm, running on from one
another, join at a node (a turn of the headings over 1e-9 rad told). The record is kept whole in the project with the line it
became: the points clicked, the old norms, the pieces and the fit have no place in the domain yet.
- //$p, a grade line along such a line (its ends and length within 5 cm, either way): its breaks with their vertical curves as the
breaks of the line, the heights of its ends as those of the nodes; not one with a break of no vertical curve, or along no line, or
one the line can't be laid with. Kept whole too.
- //$r switches (E5), //$k the kilometrage of the railway lines (the line's own chainage is the //$h origin), //$t the tracks fitted,
//$w the tracks sharing a grade line, //$b the objects bound to the tracks (E6, the anchors), //$s the stations (E7): no place in
the domain yet, kept as they were, a block a kind a file. //$c, //$o, //$z, what the editor keeps of itself, aren't taken.
- The lines read as the editor reads them: the old letters of the marks under the new ones, the lines other tools put after the same
marks (Rainsted's includes after //$r) left out. marked_files() finds the files of the map with their includes followed and the
placement in effect at each; open_project() reads the project of the map, or makes it of the //$ lines and writes it where there's
none.
Tests: G: the sceneries of data/records/ made into a project: the alignment of clothoids a line within a millimetre of the old design
along all of it, the one kept for a part of its line and the grade line along nothing kept with why, each other kind kept as the file
has it and read back by editor_records as from the scenery, the camera, the orthophoto and the area left; written and read back the
same. A map of data/project/migration (its tracks included at an origin) opened the first time: two alignments joined at a node in the
world, the grade line of the second one its break and the heights of its ends, the one along the first refused for a break of no
vertical curve, the compound curve kept; the scenery files byte for byte as they were; opened again, the file read and not made again.
* feat(editor): the scenarios using a map and the tracks, events and memory cells they name in it
The last part of E3 (editor-tracks-domain.md §0 pkt 7, §3 "Indeks scenariuszy"): a change of the map mustn't take away what a
scenario relies on. Read only, from the text of the files as the simulator reads it; nothing of the editor asks it yet (E4, E7).
- The scenarios are the *.scn files of the scenery folder. A quick look at the include words of the files, each file once for all
of them, tells which may reach the file of the map; those are read whole (sceneryText), their includes followed with the
parameters of the templates, the terrain passed over where the scenario has its binary terrain. A scenario uses the map where the
file of the map is among its files.
- What the map defines: the tracks, the events and the memory cells of the statements of its files. What a scenario names in it: of
the statements outside the files of the map, the tracks the trainsets start on (anywhere, a scenario being its own map too) and
the vehicles standing on their own; the events called by multiple events, by event launchers and by the tracks of the scenario;
the cells and tracks acted on by the events (updatevalues, getvalues, copyvalues and its source, whois, logvalues; switch,
trackvel, trackbuckle), checked by their conditions (memcompare, trackoccupied, trackfree) and by the launchers; the tracks of the
scenario's cells and isolated circuits; the events named after a track of the map, <track>:event1..., which the track calls. Each
with what names it, the file and the line. The names as the parser makes them, A to Z small.
- Not seen: the names the simulator makes (the tracks of the roads, the turntables), the scripts, the timetables, the commands the
cells give the drivers, the random includes.
Tests: U: data/project/index, a map of tracks, events and memory cells, some from a template included with parameters at an origin,
and three scenarios: two using it (one through a file of its own) with their trainsets, vehicles, events, launchers, cells and
isolated circuits, listed in full; the trainset on a track of the scenario, the names in comments, an event of none_ and a name of
nothing left out; the scenario of another map with tracks of the same names not among them. The include tree read with the
parameters and the placements; the words split as the parser splits them.
* feat(editor): one card for the tools, one layout of the fields, windows of their own, one name for each thing
The consistency pass of the editor's interface after its first steps (P2 of the plan of the editor's interface):
- One card for the tool in use in every field of work. The card of the track tools (its icon, name, family and key, what
the tool is for, the mouse and the keys drawing its gestures, the link to all the shortcuts) is a component of its own,
render_tool_card, fed by the tracks as before and now by the surroundings, the roads and the terrain: their tools, kept in
one table each with their icons, keys, tooltips and gestures for the toolbar and the card, had a plain heading and a line
of keys or a few rows of gestures there. The tool options of the surroundings are headed by the field of work as the
others are. The card is folded to its title row unless the user opened it, for all the tools: what the tool is for shows
over the title, a click opens the gestures, which are in the strip under the view of the tracks as well. Kept with the
settings of the editor under the key tool_card_folded, so the open card the tracks had by default before stays behind.
- One layout of the fields: the name on the left, the field on the right (begin_fields and field_row, as in the inspector of
the tracks) in the inspector of the surroundings (the name, the position, the rotation, the scale), Weather and time,
Change history, the settings of the orthophoto and the settings of the editor. The square buttons of the download area go
on to the next line at the edge, the last one was cut off.
- Windows of their own, which don't hide the inspector: Editor settings, Weather and time and the orthophoto settings float
over the view, opened in its top left corner below the rows of the tools and kept between them and the status line, as
the window of a lesson is. They were tabs over the inspector, and the orthophoto settings unfolded inside the layers; Map >
Orthophoto settings..., the button of the terrain tools and the button in the layers open the window now.
- One list of the objects of the scenery: Windows > Scene Hierarchy, a plain list of the same nodes, is gone; Windows >
Scene opens the Scene tab (by layer and group, with the filter) and brings it forward when it lies behind the layers.
- One name for each thing, in the menus, the toolbar, the panels, the tutorial and F1: the orthophoto ("Ortofotomapa
(zdjęcia lotnicze z geoportal.gov.pl)" where it's introduced, "ortofotomapa" in the rest, for "zdjęcia lotnicze",
"ortofoto" and "zdjęcie"), the terrain model ("Teren z map (NMT)" for "Prawdziwy teren z map", "model terenu", "prawdziwy
teren", "Teren z NMT"), the plan tool ("Plan", the lesson "Correcting a curve" and the section of F1 "Plan of a curve"
before), the area fill (the terrain's "Fill" is "Area fill" as in the surroundings, with the icon of it, Water without).
The texts of the laying, whose panel is to be redone, are left as they are.
- The node bank: a model clicked with the select tool of the surroundings arms the insert tool with it (the click did
nothing before), the random model of a set is left off then. A model inserted where there's no ground under the cursor
stands at the height 0 where the cursor points, or in front of the camera when it points above the horizon, and the
status says where; it stood at the point the renderer last had under the cursor, out of sight. The search field of the
bank has no name beside it, which was cut to its first letter.
- The settings in one place: Editor settings holds the movement and the speed of the camera (as View > Camera speed), the
gizmo and the colours, the terrain made of the terrain model by itself (as in the layers and the download area) and the
maximum placement distance (as in Change history).
- F1 and the menus: Esc closes the window of the shortcuts, before anything else; the window stays in the work area as the
window of a lesson; the menus are opaque, the windows under them showed through.
- What the first steps left: with an empty scenery the panel in the middle of the view gives way to the inspector, which
says the same with the button of the lay tool and the first steps; it's drawn only while the inspector isn't seen. A
switch whose speed limits its diverging track alone shows that speed under its empty speed field ("The diverging track
40 km/h, the main one no limit"), read only; the field alone said no limit.
- Self-tests: the command bankpick, the expectations tool, window and selected, the cases c_1_bank_card_arms_insert and
c_2_esc_closes_shortcuts.
lang/editor_pl.po: the Polish of the new texts (the cards of the tools, the windows, the fields, the notices), the entries of
the texts renamed given their new English, those no longer used taken out, and the names unified in the Polish of the
orthophoto and of the terrain model.
* feat(editor): the lay tool a step at a time, its settings folded while the points are clicked
While the points of a line were clicked, the same things were told in four places at once: the card of the
tool with seven gestures, the panel (the points not laid, the buttons, the modes with their explanation,
the speed with its chips, the height, the curves with their legend), six lines by the cursor with the full
texts of the norms, and the gestures again in the bar under the view. The panel of the lay tool now goes by
states, each with one line of what to do now at its top (editor-lay-flow.md):
- Ready, nothing clicked: "Click on the ground or at a free end of a track" (with a curve traced: "Click
points along the curve on the photo"), and the three settings: the shape [Straights | Curve], with what it
makes of the points under the "?" beside it (a click opens its lesson), the radii of a curve traced in the
same place, the speed (the field and its chips), the height [Fitted | Point to point | Flat]. The rest
under More settings, the pieces added at the free end of the selected track there too.
- Clicking, a point or more: "Click the next bends" and the keys "Enter lays, Backspace takes back a point,
Esc drops". The line in one line, "Length 300 m, 2 curves, slowest 35 km/h", and a badge, green "meets the
norms" or orange "2 curves below the norms for 100 km/h"; "details" (or the badge) opens the curves one by
one, the breaches of the norms in their words, how the curves go on from those of the tracks joined, the
speed designed for, the grades and what the norms say where the line goes on from a switch. The legend of
the labels is by the cursor over a curve. [Lay (Enter)] as the main button and [Drop]. The settings
folded to one line, "Straights, 100 km/h, through the points" (a curve traced with its radii), a pencil at
its end opening them. The details open under it all, so the buttons stay where they are.
- Laid: back to ready, with one line over the settings, "Laid 214 m (14 tracks), Ctrl+Z undoes" in green,
the rest of what the laying told under "notes" beside it. It goes as the history moves on or back.
- Dragged out of a free end: "Drag to lay from the end; let go to lay it", the line of its length and
radius with the badge, the settings as the line of their summary. The drag tells the line laid as Enter
does.
- By the cursor, the leg drawn to it in a line or two: "straight 40 m", "curve R 76 m, up to 35 km/h" with
the sign of a warning (drawn, the font has no glyph of it) and the line in orange where it's below the
norms; joining a free end, the shape of the join, a line that can't be laid, Alt, the first Esc and what
Tab switched to. The texts of the norms are in the details only.
- The labels in the view short: "R 198, up to 60 km/h", orange below the norms; the straights as before.
- The bar under the view shows the three gestures of the state: ready "LMB the first point, LMB on a free
end from the end, Tab a curve from the photo"; clicking "LMB the next bend, Enter lay, Backspace take
back". The rest of them in the card unfolded and in F1, Ctrl+Shift+wheel (the speed) added there; the
length typed after the three.
Nothing is taken away: what the panel showed is behind a fold, the pencil, the "?" or F1. The messages the
lay tool logs for the self-tests keep their words, the line laid told as "Laid 214 m (14 tracks)" now.
The flow: application/editorflow.h, the step line, the summary line with its pencil, the badge with its
details, the message of one line with the rest in its tooltip, for the panels of other tools as well.
Self-test: expect laypanel <ready|clicking|laid|extending> <shown|folded>, and the case lf_1_lay_panel_states
through the states, in straights and in a curve traced.
lang/editor_pl.po: the Polish of the new texts as the spec words them; the laying texts of "the photo"
named the orthophoto as the rest of the editor ("na ortofotomapie", "z ortofotomapy").
* feat(editor): the switch tool a step at a time, the template chosen as a line
The panel of the switch tool goes by states as the lay tool's does, each with its step at the top
(editor-lay-flow.md, second part):
- Ready: "Press on a straight and drag along it and to the side" (a slip, a crossing and a connection with
steps of their own). What to place as one bar, [Switch | Slip | Crossing], in place of the tiles in two
rows. The rail of the track, or the rails [60E1 49E1 S42] where it doesn't tell its rail, and the speed on
the diverging track as chips beside "Diverging speed (km/h)"; the template they pick as one line,
"Rz 60E1-300-1:9, 50 km/h", its tooltip the lengths and the rest of its label, a pencil at its end opening
the list of the templates and All templates under it. The gestures of placing are in the card and in the
bar under the view, no longer rows in the panel; the template editor among More settings.
- Dragging: "Let go to insert" and one line, "27.1 m, left, 40 km/h"; what keeps the switch from being laid
(the rules a switch bent into a curve or laid on from a free end breaks) in one line in red, the switch
moved back onto its straight or into its curve and the branch that doesn't fit into a track in orange.
- Placed: "Switch z1 inserted, Ctrl+Z undoes" while the switch is the one the last step of the history laid,
else "Switch z1: drag it along its track to move it". The sketch, its length and side in its tooltip; the
speed chips and the template as the line with the pencil, as when placing; Flip the side. A switch with no
drive says so with what puts one there; the name, the record, the angle, the drive, the frog and the check
rails, the slide along its track and the note of the inspector are under Details, folded. What the tool
told of it besides the step under it all.
- Refused: the reason in red right under the step, the rest of a long one in its tooltip.
The drive of the switch is drawn by a function of its own (render_switch_drive), no longer a lambda of the
panel. The status of the switch tool is told in red while it's the refusal last told
(m_switch.refusal), the expectations of the self-tests read it as before. The bar under the view keeps
the gestures of the view first, "List in the panel" after them.
Self-test: expect switchpanel <ready|dragging|placed|selected>, and the case lf_2_switch_panel_states:
ready after a switch refused, placed after one laid, selected after another one laid since.
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): the catalogue of the turnouts a data file, the switch tool and the domain model reading it
The first part of E5 (editor-tracks-domain.md §7, "Katalog jako dane"): the types the editor lays its switches from were a table in
switch_design::catalogue() and two in editor_track::standard_switch_templates(); now they are editor/data/turnouts.txt, one type a
line, built into the executable as its text (CMakeLists.txt writes it out as editor_turnouts_txt.inc, as it does the icons), so the
game data doesn't need it, and read once when first needed.
- The format, which the templates of the user (eu07_switch_templates.txt) share: switch <name> <key> <value>... source <the rest>.
A type of the catalogue gives its geometry as the instruction does (type, rail, radius, ratio, a, b, diverging, the blades tangent or
secant, the cut tip of the blade; stagger and the keys of the second switch of a double one; middle and the half length of a slip;
fit for the three fitted to measured tangents), the parts made of it as before; a template of the user gives its parts. What §7 asks
besides the geometry, - where the source has nothing: the frog (fixed or movable), the locks (Id-4 tab. 14-3), the drive, the speed of
the diverging track (ST-T1-A6 tab. 11.2), the bending (tab. 11.9), the least spacing for a crossover (tab. 11.2) and the source of the
values, unconfirmed ones said so: the cut tips of SKMd-4 (190, 300, 500, 1200 m; 760 m the editor's own), the secant blades of S42 at
25' and the one fitted for S42-140-1:7, the a and b of 2500-1:26,5, the slips' blades (not found), the tip of a blade with no data by the
rule sqrt(2R 0.005) - 0.125.
- read_designs() reads the format, a line which isn't one left out with why; catalogue() the switches as before, in the same order, slips()
the slips and the crossings, catalogue_entries() all of them, read once (secant_blade() no longer builds the catalogue at each call).
- The slip curve and slip_of() moved from editor_track to switch_design, which the domain model lays its slips with (E5); editor_track
keeps the names.
- A template of the user with a movable nose writes frog movable, which it lost before; without one the line is what the builds before
wrote (they leave out a template with a key they don't know). The lines they wrote read as they did.
Tests: U: every switch of the data file the same to the bit as the catalogue of the code (kept in the test as it was), the slips and the
crossings as the switch tool had them; every line read, with its source; each switch against Id-4 and ST-T1-A6: R, 1:n, a, the main
track a + b, the pre-blade stretch, the blades (the tip lead + cut where the sheets give it, about sqrt(2R 0.005) - 0.125 where they
don't; secant at 25'), the speed of tab. 11.2, the bending of tab. 11.9, the spacing of tab. 11.2; the rule of the tip against the sheets
(190 m +3 mm, 300 m +105 mm, 500 m -56 mm, 1200 m +3 mm; the 4.5 mm rule +60, +143, -44, -49 mm); a template keeping its movable nose,
an old line read as before; lines left out with why. Unit tests 1070 -> 1077.
* feat(editor): the double, symmetric and secant switches, the slips and the crossings of the catalogue in the domain model
E5 (editor-tracks-domain.md §4 "Rozjazd", §7): every type of the catalogue is a turnout the model lays, its tracks lines it owns and its
legs nodes, kept whole or refused like the ordinary switches E2b laid. E2b refused the rest with "stage E5".
- Secant blades (S42): the diverging track runs along the main one for the pre-blade stretch and turns off it by the angle of the blades
at their tips, the rest of 1:n on its arc; a turn inside the track, the node at the start keeping the heading of the main track. The
generator ends a piece there with the heading of the element before it (unchanged where a line runs on in its heading).
- Double switches (Rpd, Rpj, Rps): the main track cut at the start of the second switch, its node holding the main track, the main track
of the second switch (main2) and its diverging track, to the other side or the same one, as switch_design::build() lays it. Written as
the switch tool writes them: the first switch, a plain track of a metre before the second one (the simulation joins a switch to plain
tracks only), the second switch.
- Symmetric switches (Rls): both tracks turning off by half of the angle, to both sides, laid at a free end of a line, which they end (the
line beyond it would have to turn at the node); not moved along the line.
- Slips (Rkp, Rkpd) and diamond crossings (Skrz): the main track a part of the line, the crossing track across its middle at the angle of
the slip between two nodes of its own, the slip curves from the start to the end of the crossing track and, of a double slip, from its
start to the end of the main track; slip_of() lays the curves with the blades of the ordinary switch of the rail, radius and angle (no
data of the slips' own blades was found), passing the crossing as near as the rails of the simulator's profile let them. The three with
the blades outside of the diamond whose curves then reach past the half length of Id-4 (49E1 190-1:6,6, 300-1:9, 500-1:9, by up to 0.3 m)
are laid as long as their curves. Written as the switch tool writes them: a switch at each leg a slip curve leaves, the tracks crossing
and the middles of the slip curves plain tracks, the joints inside it the same numbers on both sides.
- The rules: a double switch, a slip, a crossing (11.4 pkt 4 a, b) and a symmetric switch (no rule of table 11.8 for it) lie on straights
only; an invariant, refused with the reason before anything is laid. The norms judge the tracks crossing at a slip or a crossing as
crossings (no cant, tab. 9.6), its slip curves as diverging tracks.
- The ends of the tracks of a turnout which carry no line through their node (the starts of the diverging tracks, the ends of the slip
curves) are branch_end(); a node holds such an end beside a track of the same turnout on its side. settle() lays all the tracks a turnout
lays itself (lay_tracks()), the nodes of its own where they end; lifting, moving, changing (to another kind too) and removing a turnout
take all of them along.
- The project file: the turnout record gets "second <node> <main2> <diverging2> <node>" and "crossing <line> <node> <node> slip <line>"
where the turnout has them (diverging 0 0 for a crossing); version 1, unreleased, read as before without them. The generated section
keeps each track a turnout is made of.
- TSI INF 4.2.3.4(1), 150 m at least, judges the plain line, not the curves of switches (4.2.5): its hard row leaves out the tracks of the
turnouts, so the industrial S42 switches of R 70 and 140 m are laid.
Tests: U: every type of the catalogue laid (41 ordinary, 3 symmetric, 15 double, 18 slips, 20 crossings) on a straight to both sides
along the line and against it, its legs where the catalogue puts them (the main track a + b, 1:n at the ends, the second switch at the
stagger, the crossing track at the angle of the slip, half its length from the crossing), moved and taken out, the line one again, each a
step to undo; the turn of the secant blades of S42-190-1:7 at the end of the pre-blade stretch; a double switch, two slips and a crossing
refused in a curve, a secant S42 bent in a side track, a symmetric switch refused at the end of a curve. The three fitted to the tangents
of S42-140-1:6,6 16/12 measured are refused by the norms (tab. 9.14) where the transition one is. P: 200 random edits with every type along
arcs and transitions, seeds 5150, 2718 and 1618: the invariants after each, a refusal changing nothing, undone back to the start exactly.
G: every type made into the tracks of the simulator and read back by TTrack::Load, the ends of the paths at the legs or at each other to
the bit, the velocity and the frog; a double switch, a double slip and a crossing written to the project file and read back, their tracks
laid again the same to the bit. The E2b case of the types refused now checks that they're laid. Unit tests 1077 -> 1086.
* feat(editor): the bending of the turnouts exact: table 11.8 for the whole diverging track, the main track on a transition as it is
E5 (editor-tracks-domain.md §4 "Rozjazd", §7 "Na łuku — łukowanie z dokładnym wzorem (tab. 11.8)"), what E2b left: table 11.8 for the curve
of the basic switch only, the rest of the diverging track bent with the main track by the sum of the curvatures, a main track on a transition
taken at its mean curvature, the sign of the curvature of the diverging track judged from headings sampled every half metre.
- Table 11.8 written for the curvatures, r" = (R r -+ t^2) / (R +- r) as k" = (k + K) / (1 - k K t^2) with the tangent t of the basic switch,
bends every curve of the diverging track and the ends of its transitions, each as long as keeps its turn off the main track (the angle of
the frog); the curve of the basic switch keeps switch_curve::bent_radius(), the same numbers as before; a straight goes with the main
track as before (the formula gives K for k = 0). On a straight nothing changes.
- The frame of a turnout knows its main track: where its curvature changes under the turnout (a transition curve, or the end of one) the
diverging track is laid in steps of 2 m at most, each one's curvature at its ends by the table with the curvature of the main track at the
station it runs by (along the main track, its heading off the main one taken in), the turn of each part kept; the straights and the lead
with the main track step by step too.
- The curvature of a diverging track of one sign all along it, from its elements (9.7 pkt 12, 11.4 pkt 6): a BLOCK rule of the turnout in
place of the sampled check of switch_curve (KZW II), which a short straight through the frog going the other way could slip through.
Tests: U: a diverging track of a curve of 800 m, the curve of the basic switch of 500 m and a transition off it, bent with main tracks of
1200 m both ways and of 3000 m: each by the table with the tangent of the basic switch, the basic one the same as bent_radius(), each turning
off as far as in the basic switch, on a straight to the bit as it was; Rz 60E1-500-1:12 60 m into a transition of 200 m to R 1200 m: laid in
steps, its curvature at the start by the table with the main track's there, growing along it, the frog against the main track where it ends
beside it at 1:12.0004 (1:11.9966 by the mean curvature, the end 27 mm apart), moved and back the same; Rz 60E1-190-1:9 bent two-sided
refused, its curve turning off to its side and the straight through its frog the other way (KZW II), one-sided not. Unit tests 1086 -> 1089.
* feat(editor): the solver of the connections of the tracks: a crossover between two lines, the norms of the straight and the spacing
E5 (editor-tracks-domain.md §7 "Połącz tory", §8 "Połącz dwa końce ... odmowa ... z najlepszą propozycją"): editor/layout/layoutConnection
plans a crossover between two lines running alongside, straight or curved, and the command connect_tracks lays it, one step to undo.
- The first turnout where it's asked for, toward the other line; the second one on the other line running back, its diverging track facing
the first one's, where the line between their ends turns by as much at both of them: on one straight between straights alongside (the
headings of the ends within 1e-13 rad), one curve between curved lines. Found by the secant along the other line, each try the turnout
laid in a copy of the network, so it's put as the command will put it.
- The spacing of the lines measured along the whole crossover, a point every metre, not where it starts; the least of it against the
least spacing of the type: of ST-T1-A6 tab. 11.2 where the catalogue gives it, or what its geometry needs with the least straight
between its turnouts (crossover_spacing()), the larger.
- The least straight between the turnouts from the norms: a new parameter of the E1 module, switch_straight, at the speed through them:
max(0.15 V; 6) m in the running and the main tracks (11.3 pkt 7d, WARN), 30 m on a line of 160 km/h or more (pkt 7e, BLOCK; the new
feature fast_line), 6 m recommended in the side tracks (pkt 7c). The solver asks for the normal limit.
- Where they can't be met: refused with the reasons and the best which fits the spacing measured, a type of the catalogue of the rail of
the one asked for before the others, the fastest; or that none fits, and the spacing the type asked for needs.
- The line between the turnouts runs at the speed of their diverging tracks and is a part of the connection of the tracks for the norms
(the feature switch_track of its class, which describe_chain() puts on its elements): an arc with no transitions nor cant where it isn't a
straight, and the steps of the cant deficiency and the elements between them judged as in the tracks of turnouts (tab. 9.15, 9.16).
Tests: U: crossovers of Rz 60E1-500-1:12 between straights 4.75 m apart, both ways to both sides: the spacing 4.75 m all along, the
straight between the ends (4.75 m less twice the offset of an end) / sin(1:12), the norms' 9 m at 60 km/h, the ends facing each other on
one straight, one step to undo; a line closing in on the other refused for its spacing along the crossover though wide enough at its
start; 0.15 m short of the spacing for the 9 m straight refused with "11.3 pkt 7" and a type proposed, which then is laid; 30 m on a
line of 160 km/h; Rz 60E1-760-1:14 refused at 4.74 m by tab. 11.2 though its geometry fits; between two curves of R 1200 and 1195.5 m
4.5 m apart (4.50086 to 4.50087 m along it), both turnouts bent, one curve turning by 0.6 degree between their ends; a slip, a line to
itself, a line across and a type of none refused; the rows of switch_straight. Unit tests 1089 -> 1096.
* feat(editor): the //$r switches of an old scenery on the lines of its alignments made turnouts of its project
E5, what E3 left (editor-tracks-domain.md §9 "Migracja"): the //$r records were kept in the project file as a block a file; the switches
among them which the domain can lay now become its turnouts when the map is first opened.
- A switch or a double switch of the editor becomes a turnout where its record names a type of the catalogue (its type, rail, radius, ratio
and a, b of an ordinary or a symmetric one; the first of the catalogue's order where a movable nose is the only difference, which the
record doesn't keep), its start lies on a line made of an alignment within a centimetre and its direction along the line or against it,
and its main track is bent as the record says the line is there (straight, or the radius within 5 %). It's laid into the line by the
command insert_turnout, the hand of the record, with edit_policy::no_new_block: the old line may break the norms where nobody touched
it, the turnout may add no BLOCK finding to it.
- Its record goes on its own into the project with the main track of the turnout (as an //$h record keeps the line it became); the rest of
the block stays as written, the comments with it, why each switch didn't become a turnout with it: a slip or a crossing (their records
don't tell the side of the crossing track), a connection (the solver of the connections lays it anew), a lifted outer track, no type of
the catalogue, no line under it, a bending other than the line's, or the reasons the command refused it for. A block none of whose
switches became one is kept as before, with the reasons.
Tests: U: an alignment of data/records with five //$r lines: two switches on its straight, along it and against it, to the left and to
the right, made turnouts of their types at their starts (the structure whole, no reason); one beside the line, one of no type of the
catalogue and a connection kept in the block with the comment, each with why; the two records each with the main track of its turnout;
the project written and read back the same. The records of data/records and of the map of data/project/migration (no switch on a line)
kept whole as before. Unit tests 1096 -> 1097.
* feat(editor): the project of the map opened with the scenery and written with it, behind a setting of the editing on the model
The first part of E4a (editor-tracks-domain.md §3, §9, §14): the domain model of E2 and the project file of E3 brought into the
running editor, behind a setting, "Editing on the model (trial)" in the settings of the editor, off by default. Off, nothing of it
runs and the editor is as it was.
- editor/project/projectSession: the project of the map open in the editor, no scene. open() reads the project file of the map, or
makes it of the //$ lines the first time (open_project of E3), and compares the tracks the generator wrote with the files as they
are now: a track changed or gone outside the editor marks its line changed by hand. trial() tries a command on a copy of the network
and tells the lines it lays anew or takes away (differences()), nothing changed; execute() carries it out, the lines of Overwrite
no longer taken for changed by hand with it. A command kept is a step of the model's history with a token, which the editor's step of
it takes back and brings again (undo(Token), redo(Token)): only the latest step kept, or taken back, can be, so the two histories
can't go out of step; the marks of a change by hand go with the step. record_written() records the tracks of a line as the scenery
save wrote them, save() writes the project with the network as it is, the records of the lines gone taken out.
- The setting on, the project of the map (the file of the scenery opened, <map>.eu07proj next to it) is opened with the scenery and
written with it. The scenery save asks for the text of each track it writes (scene::node_layers::path_writer): a track the generator
made, as long as nothing else changed it, is written as the generator made it (the numbers in the shortest form which reads back to
the same double, not the 15 digits of the export), and its checksum recorded; one changed by the other tools is written by its own
export and its line marked changed by hand. The tracks of the lines of the project are found in the scene by their names, with the
text the file has for each (scene::node_layers::source() tells the file and the placement of a node).
Tests: U: a map opened gets its project file; a command refused, tried or carried out, changes nothing and isn't a step; a command
tried changes nothing, carried out tells its lines (new, split, a curve changed, deleted); the steps taken back and brought again by
their tokens in the order of the history, another token refused, a command after an undo dropping the step taken back, the
identifiers not given again; the tracks of two lines written and recorded, a reopen finding nothing changed and the line the same to
the bit as the model laid it, a speed edited in the file marking its line alone, deleting it writing over it too, the mark taken off by
a command writing over it and back with its undo, the records of a line deleted gone with it at the save.
Self-test: modelediting <0|1> (the setting for the run, not kept), expect modellines, expect projectfile <present|absent|lines n>.
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): a line laid in the straights, or the route design applied to old tracks, a line of the model, its tracks the generator's
Continues E4a (editor-tracks-domain.md §3, the generator as the layer between the domain and the simulator; §4, §10): with the editing
on the model on, the lines laid in the editor are lines of the model and their tracks its tracks; the old tracks stay as they are, the
old tools edit them.
- The lay tool in the straights: Enter lays the line its preview shows as a create_line command of the model, its vertices where the
preview has them with their radii, transitions and cants, an even grade from end to end (the grade line through the model is E4b),
the speed designed for as the class of the line. Refused, the panel tells why with the value, the limit and the paragraph, nothing
is laid and the points are kept to be put right; kept, the generator makes its tracks, named after the line and its elements
(l1_s11, l1_v1a1...), of the style of the track it goes on from or the lay tool's, one step of the history; what the norms warn of
is told under it. A curve traced, a curve going on from the curve of a free end, a compound curve or one with cant ramps of its own
are laid the old way, told why.
- The route design applied to old tracks makes them a line of the model in their place, one step: not through switches, nor tracks
with events or in isolated circuits (their events would be lost until E6), nor a line with a grade line of its own; those are laid
the old way, told why.
- A track the model made is marked as its line's: the inspector shows "Line L1 (managed)". Ctrl+Z takes the command back with its
tracks, Ctrl+Y brings it again: the editor's step keeps the token of the model's step (EditorSnapshot::model_token).
- editor_track::load_entry: a track of the entry the generator wrote, its numbers as written.
Self-test: a track named @<line>.<index>, modeltracks, expect managed, expect modelends (the tracks of each line from end to end at the
numbers of its nodes and at each other, to the bit), expect hand. The cases m_0_setting_off (the setting off: no project, old tracks),
m_1_lay_managed (a line laid is a line of the model, the project file written next to the copy of the scenery, the ends to the bit
before and after a reopen, nothing changed by hand), m_7_plan_converts (the route design applied to a1..a3 makes them a line, Ctrl+Z
brings them back).
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): the curves of a line of the model changed in the route design as its commands, refused with the reasons; split, join, delete
Continues E4a (editor-tracks-domain.md §4 "Edycja = polecenie", §8): a line of the model is edited through its commands, each kept
whole or refused with the reasons, one step of the history.
- The route design opened on a track of a line of the model shows the line as the model has it, its curves with their radii,
transitions and cants. The preview is the route design's as before; applied, each change is a command of the model: a vertex moved
(move_vertex), its radius, transitions or cant typed (set_vertex). A command refused changes nothing and the panel tells why, with
the value, the limit and the paragraph ("cant 200, the limit 150 (ST-T1-A6 tab. 9.6)"); one kept is laid, one step, and what the
norms warn of, or would prefer, is the quality line of the panel. Curves added or taken out aren't applied to a line of the model yet.
- Under the line in the panel: split it at a distance from its start, join its free end to the free end of the nearest other line of
the model (a new line solved between them), delete it; Del on one of its tracks deletes the line too.
- A command which lays anew, or takes away, a line whose tracks were changed by hand (found so in the files when the map was opened,
or changed in the editor by the other tools since the model made them) asks first, in a window naming the line: keep the change by
hand, and nothing is done; or overwrite it, the line laid anew and no longer taken for changed by hand.
Self-test: modelplan <track>, routeradius|routecant <vertex> <value>, routemove, modelsplit, modeljoin, modeldelete, modelselect,
modeldel, modelanswer <yes|no>, modelmark; expect modelrefused, modelmessage, modelvertex, modelsame, question. The cases
m_2_plan_refusal (a cant of 200 mm refused with its reason, nothing changed; a wider curve laid in one step), m_3_model_undo (a command
taken back and brought again with its tracks, a split taken back, the project saved after an undo read back as it was),
m_4_hand_change (a track's speed changed in the inspector: kept, nothing changes; overwritten, laid anew; a change by hand saved found
after a reopen), m_6_split_join (two lines joined, the new one split and deleted, each a step).
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): the scenarios naming a track looked through before it goes, the index of the map built in the background and kept
The last part of E4a (editor-tracks-domain.md §0 pkt 7; §8, deleting a line): with the editing on the model on, a track a scenario of
the map names goes, or is renamed, only when the user says so.
- editor/project/scenarioIndexCache: the scenario index of E3 built on a thread of its own as the map is opened, and kept: in memory,
and in a file of the cache of the user between the sessions (scenario_index/<map>.txt; not for the self-tests), for as long as the
*.scn files of the folder are the ones it was built of (their names, sizes and times); on a big map it takes minutes, once. The
editor doesn't wait for it to close. users_of() tells the scenarios naming the tracks, with what names them and where.
- Del on an old track with a name, on a set of them, or on a track of a line of the model (its line goes), the route design applied
to old tracks, and a track renamed in the inspector (editor_mode::track_rename) wait for the index ("Checking the scenarios":
cancel, or go on without checking), then go at once where no scenario names the tracks, or ask: "Track used by 2 scenarios", each
scenario with the trainsets, events and the rest naming the track, the file and the line; delete (rename) anyway, or cancel and
nothing changes.
- The self-tests: the scenarios of the map of the fixture, tests/editor/scenery/autotest_editor.<part>.scn, copied by run.py next to
the copy of the fixture as autotest_editor_<case>_<part>.scn, naming that copy (autotest_editor.uses.scn: a trainset on s1, an event
on d2). The index of the fixture's map over the scenarios of the game's folder takes about 80 s.
Tests: U: the index written and read back with its fingerprint, other versions refused; the users of a track by its name as the
simulator compares it; built once in the background, given again for the scenarios as they are, built again when one changed, read
from the file of the cache in the next session, built for another map. Self-test: modelwait, modelrename, expect question
<waiting|scenarios> [n]; the case m_5_index_delete (Del on s1 asks: cancelled it stays, confirmed it goes; d2 renamed the same; a3 and
a line of the model go at once); m_6 and m_7 wait for the index.
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): the old tracks recognized as lines of the domain: the curves read off the curvature, fitted by least squares, the deviation measured
The first part of E6 (editor-tracks-domain.md §10 "Automatyczne przejęcie odcinka", editor-tracks-tests.md §4 "E6"): a chain of the
paths of an old scenery, Bezier curves drawn by hand or by older tools, made a line of the domain (editor/layout/layoutRecognition).
Model only, nothing of the editor asks it yet.
- The chain sampled along its arc length in the plan, every metre for the fit and every half metre for the deviation, each joint with
the turn of the heading there: the point, the heading and the curvature of the Bezier curve as the simulator draws it, the cant of the
roll turned evenly with the parameter as the simulator turns it (1500 mm sin roll, of the other sign where a path runs against the
chain).
- The curves found where the curvature changes: the heading differenced over 30 m (the noise of the ends of the old paths, written to the
millimetre, and the ripple of the Bezier curves evened out), runs of one sign past 1/5000 m; a run whose curvature falls to a third of
what it is on both sides cut in two; the arc of each where the curvature is half of it or more (the area over that width is the turn),
its transitions where it rises from a tenth to nine tenths, the window taken off; a turn of more than a quarter of a circle laid as
curves of a quarter at most. A turn of more than 5 mrad at one joint making up a curve is a kink (told, laid as the shortest curve
which fits); an arc whose halves differ by a quarter is a compound curve (told, laid as one).
- Each curve a vertex of the domain, clothoid - arc - clothoid, its point where the straights fitted around it cross; then the points,
the radii and the transitions of all of them fitted by least squares to the offsets of the points of the chain from the line the domain
lays (Levenberg-Marquardt, the Jacobian by differences over the points each parameter moves; the transitions by their squares, since
what a transition moves the curve by grows with its square; the points and the radii first, then all of it). An end held by what stays
beyond it (a switch, an old track not taken over) keeps the first or the last vertex on its heading. The curves the curvature doesn't
show (a radius over 5 km, a turn spread over the joints) are added where the line keeps off the points by the tolerance, six at most;
the small turns of old tracks laid jagged, joint by joint, are left out where the line keeps nearer without them; where it keeps more
than a metre off, the plan of the added curves alone is tried; a vertex whose tangents cross behind the curve tells nothing of it, and
a vertex no radius lays is taken out.
- The cant of each vertex fitted to the rolls along its arc and its transitions; a cant the rolls ramp up with no transition under it is
fitted again with transitions as long as the ramps, kept where the line keeps nearer so. The grade line: the heights as straight grades
within 1 cm (Douglas and Peucker), the heights of the breaks by least squares, each vertical curve the largest of the usual radii which
keeps within it.
- The deviation measured densely: each point of the chain every half metre set square onto the line, the farthest and the root mean
square of the distance in the plan, of the height and of the cant, where the farthest is. The tolerance of a takeover with no question
(takeover_tolerance): 20 mm in the plan and in the height, as the simulator itself joins the ends of the tracks within 2 cm, so the
tracks made again lie where the simulator takes the old ones to be; 10 mm of the cant, 0.4 degree of the roll, under the half degree
many old files round the rolls to. The norms aren't asked here.
Tests: U: three curves (R 800 m with clothoids of 80 m and 60 mm, R 600 m with 60 and 70 m and 90 mm, R 1500 m with none) and a grade line
with two breaks, cut at random places 8 to 25 m apart, each piece a Bezier curve, the joints shaken by up to 4 mm across and in height,
the rolls rounded to the tenth of a degree, seeds 1101, 2202 and 3303: the radii within 1 %, the transitions within 3 m or moving the arc
within 5 mm of where the laid ones move it, the cants within 3 mm, the deviation within the tolerance; the same walked the other way
round, the transitions swapped. A kink of 0.6 degree at a joint told and laid within the tolerance; an arc of 11 km found where the
curvature shows none; an end held in a heading 2 mrad off the chain kept to 1e-9 rad. Unit tests 1101 -> 1103.
* feat(editor): the joints of old tracks as hard points of the pieces, the names, events and circuits of the old tracks kept by the lines
E6 (editor-tracks-domain.md §5 "Podział na kawałki zachowuje miejsca...", §10 "Stare złącza jako twarde punkty podziału"), the hook of the
generator E2a left (generator_options::hard_splits, a line given any refused).
- A line keeps the old tracks it was taken over from (line::hard_splits): where along it the stretch of each begins, its name, the words of
its entry before the path (the width, the friction, ... the visibility and the materials) and after it (the speed, the events, the
isolated circuits and the rest), whether it ran against the line. In the line rather than in the options of the generator, so a command
which cuts or joins lines carries them and an undo puts them back: a line cut (split_line, a turnout laid into it) gives those past the
cut to the part after it, and the old track cut in two keeps its name and its events on the part it ran into first, the other part a
stretch of it the generator names (continued); two lines joined, the second one's after the first one's.
- The generator ends the pieces at each joint inside the line (a joint stays, a break of the elements next to it gives way) and writes the
pieces of a stretch as the old track was: its name on the piece it ran into first with all its attributes, <name>_2, <name>_3... on the
others with them but its events (an event of a track is called once), its surface, the path written the way it ran (event1 and event2,
the sign of the rolls); an old track of no name named by the generator, its events kept. A line with none is made as before.
- The project file: "old <chainage> <name> reversed <0|1> continued <0|1> surface <words> attributes <words>" in the block of a line;
version 1, unreleased, read as before without them.
Tests: G: a line of three curves given three old tracks (one named with its events and its circuit, one of no name, one which ran against
the line): the pieces end at the joints, each name once, the attributes of the first on its first piece and without its event on the
others, the event of the unnamed one once, the one which ran against the line written from the end of the line; written into the project
file and read back the same. It takes the place of the E2a case of the hook refusing. Unit tests 1103 -> 1103.
* feat(editor): the old tracks of a scenery chained and taken over as lines by one command of the model, the norms told, not refusing
E6 (editor-tracks-domain.md §10): a set of old tracks made lines of the domain in one step to undo (editor/layout/layoutLegacy and the
command take_over). Model only: the question with a preview before and after is the editor's, after E4a.
- legacy_track: an old track as its entry has it, in the world, with no scene: its name, its paths, the words before and after them.
walk_chains(): the plain tracks of the set chained the way a train runs them (the chain walking of the old digitization, kept): a track
joined at an end to exactly one other plain track of the set, within the 2 cm the simulator joins them within, goes on into it; a
switch, a track not taken over, a fork or a free end ends the chain, held in the heading of the main path of the switch or of the track
holding it, which the line runs on from. Each chain runs from its end the smaller in x, then in z, whichever track it was found from.
- plan_takeover(): each chain recognized (layoutRecognition), its held ends kept, the old tracks along it as its hard splits (a track named
none of no name), the class of its line of the highest speed of its tracks; the deviation of each line and the worst of all; silent where
each line keeps within the tolerance. Nothing is laid.
- take_over, a command of the model: the lines between new nodes at the ends of their old tracks, their vertices, grade lines and old
tracks as recognized. The invariants refuse it as they refuse any command; the norms don't: the BLOCK limits the old tracks pass are told
in outcome::broken (an old track may break the norms where nobody touched it, improving it is a separate decision; edits of the lines
after it are judged by edit_policy::no_new_block). take_over_tracks() executes it and returns the deviation of each line and whether
the takeover is silent, for the question.
- A switch stays an old track, a fixed constraint: the lines end at its legs in its headings. Its type recognized in the catalogue and the
switch laid into the line as a turnout, so the line runs on through it, is left for later.
Tests: U: the line of three curves cut into old tracks, each written the way it was: the tracks in three random orders, seeds 4401, 5502 and
6603, the walk starting from another one of them each time: the same line, its vertices to 1e-6 m and its radii and transitions to 1e-9,
the same old tracks at the same chainages. Unit tests 1103 -> 1104.
* feat(editor): an old scenery read with no scene, its lineside objects anchored to the lines with a confidence, the anchors in the project file
The rest of E6a (editor-tracks-domain.md §2 "Kotwica", §3 "Otoczenie", §9, §10 "Powiązania otoczenia ... z oceną pewności; wątpliwe
pokazane do przejrzenia; przewody wiązane ze słupami").
- editor/project/legacyScenery: the tracks of the railway (normal and switch) and the lineside objects (models, wires, memory cells, event
launchers) of a scenery read from the text of its files with their includes, as the simulator places them: the tracks and the wires
moved by the origin only, the rest by the origin, the rotation and the scale (sceneryText now tells the placement in effect at each
statement). The tracks naming an object: a memory cell's own, and those whose events (event0 to eventall2 of their entries, the events
<track>:eventN) act on it, multiple events followed four deep. The kind of an object by its file and name, as the binding of the editor
tells it (infra::classify).
- editor/layout/layoutAnchors: an anchor puts an object along a line: its chainage, the offset to the left of the line (below 0 to the
right), the height above it, its turn against the heading there; a wire by its four points, bound to the poles its ends hang on (a pole,
or a model the names take for a part of the catenary, within 8 m of each end, along the same line). infer_anchors() anchors every
object within 30 m of a line to the nearest one, with a confidence from 0 to 1 and the reasons for it: named by a track of a line, 0.95
at least (0.85 where another line is nearer, half of the fit where the line named isn't near); else how its distance fits its kind (a signal 0 to 6 m, a
sign or a pole 1.5 to 8 m, a wire 0 to 1.5 m, equipment 0 to 3 m, logic and the rest 0 to 15 m, the environment at half), a third past
the end of a line or 15 m above or below it, half where another line is as near within a metre, 0.8 for a sign, a signal or a pole turned
more than 10 degree off square to the track; a wire on poles at both ends 0.9 at least, on none 0.7 of what it had. Below 0.6 doubtful,
to be looked over. place() puts the object where it stands along its line now; follow() after a change of the network: an anchor whose
line is there keeps its chainage, one whose line is gone (cut, joined, taken by a turnout) is anchored again where it stood, to the line
there now; the anchors whose objects move, with where to. Moving the nodes of the scene, and taking the anchors back with an undo, is
the editor's.
- take_over_tracks() given the objects of the scenery anchors them to the lines it laid, the old tracks naming them by the lines they
became, and lists the doubtful ones, with the deviations, for the question.
- The project file: the anchors section, reserved and empty in version 1 so far, holds the anchors: "anchor <id> <kind> <name> <key>
group <n> at <x y z> yaw <deg> line <id> chainage <m> offset <m> height <m> turn <deg> confidence <c> points <n> ... poles <n> ...
[why <reasons>]". The schema stays 1: it's unreleased and the section was empty.
- The //$b bindings of the old editor (the same mechanism along the paths of the tracks) aren't made anchors yet.
Tests: G: data/takeover/old.scn, written by make_old.py (a line of 26 tracks with a curve of R 500 m, clothoids of 60 m and 80 mm, a break
of the grade with no vertical curve, tracks of no name and written backwards, events and an isolated circuit; a switch at its end and a
line on from each of its legs; a signal named by the events of a track and its memory cell, a pole every 50 m and the wires between them,
hectometre posts, a tree 25 m off, a cabinet between two lines): read with no scene; its plain tracks taken over as three lines with no
question, R 500 m, the clothoids and the cant read back within 1 and 5 %, the lines held at the legs of the switch in its headings, one
step undone and done again the same; the tracks made again ending at the old joints, each old name once, the events and the circuit on
their pieces, also after the curve was made 20 m wider; written into the project file and read back. The signal and its memory cell
anchored with 0.9 or more, the poles with 1, every wire bound to its two poles, the tree and the cabinet doubtful; the curve made wider: the
objects along it follow at their chainages and offsets, the signal on the straight before it stays; the anchors written into the project
file and read back. The case of the project file which kept the section of the anchors as text reads and writes two anchors now. Unit
tests 1104 -> 1108.
* test(editor): the recognition of old tracks measured on sceneries of the game, read only, skipped unless asked for
editor-tracks-tests.md §4 "E6", the measure: tests/unit/test_takeover_measure.cpp, a case skipped by default (it needs the data of the game,
so it isn't a test of the build), run as
EU07_TAKEOVER_MEASURE="<scenery folder>;<file>;..." eu07_unit_tests --no-skip --test-case="takeover measure*"
It reads the tracks of each file with its includes, takes all the plain ones over in a plan (nothing laid, nothing written) and prints the
lines made, how far they keep off their old tracks in the plan, the height and the cant, how many would be taken over with no question and
why the others ask it, what the domain lays otherwise (kinks, compound curves, cants with no transition), the worst lines;
EU07_TAKEOVER_TRACK=<name> prints the curves found and the vertices of the line of a track.
Measured on the game data, read only (baltyk/baltyk_torowisko.scm, l02/l02_tory.scm, linia61/l61_tory.scm, lk197/lk197_tory_uniwersalne.scm,
drawinowo/tory.scm, calkowo_v2/v2_tory.scm): 31 411 tracks (2 111 switches), 3 594 lines of 30 297 tracks, 1 477 km, 2 chains not laid,
8 minutes. With no question 3 112 lines (87 %) but 591 km (40 %): the short tracks of the stations fit within 5 mm, the long lines drawn by
hand ask. The farthest in the plan: up to 5 mm 2 890 lines, 10 mm 195, 20 mm 113, 50 mm 134, 100 mm 97, 500 mm 99, more 66 (bulging
Bezier curves, compound curves of stations, a few tracks of no sense). The question for 482: the plan 297, the height 74 (buffer stops of
tracks climbing a metre), the cant 12, more than one 99.
* feat(editor): the messages of the model of the track geometry and of its norms told in the language of the editor
The first part of E4b (editor-tracks-domain.md §8; E4a left the messages of the model in English): what the model refuses a command for,
and what the norms warn of, reach the user through the catalogue of the editor, the model staying as it is, English and pure.
- The editor layer formats them: a message of the model is matched against the forms it's made by (a BLOCK limit along a line, a finding
of the norms with its value, limit and paragraph, a rule of a turnout, a line or a vertex which can't be laid, the solver of the
connections and its proposal...), the form of the catalogue (STR) filled with its numbers and names, the parts which are messages
of their own (the name of a parameter of the norms, what a line or a turnout is refused for) shown so in turn; a whole message the
catalogue has, as it is. One with no form stays English.
- The editing on the model keeps both: what the model told, English, for the log and the self-tests, and what the user reads, in the
route design, the lay tool and the panels of E4b. The window of the application is split off editormodemodel.cpp into
editormodemodel.h, shared by the files of E4b.
Self-test: expect modelmessage holds or lacks the text in either of them, so the cases run in any language.
lang/editor_pl.po: the Polish of the forms and of the names of the parameters of the norms the editor hadn't yet.
* feat(editor): the switches of the switch tool on the lines of the model its turnouts, inserted, moved, changed and taken out by its commands
Continues E4a (editor-tracks-domain.md §7, §8; stage E4b): with the editing on the model on, a switch dragged on a track of a line of
the model is a turnout of the catalogue of the model, and so on, each a command, refused with the reasons or one step of the history.
The switches of the old tracks are laid the old way.
- The drag of the switch tool, let go on a line of the model (on a straight or along a curve), is insert_turnout: the type of the
catalogue the template is of (a template of the user's own isn't), its start where it was pressed, its chainage on the line
(layout::chainage_of), the side of the drag its hand, the way it was dragged its direction. While it's dragged the panel tells in its
red line why the model would refuse it, tried on a copy; let go, a refusal is told there with the value, the limit and the paragraph
("(9.6 pkt 16)"), nothing changed. Laid: its switch track made by the generator (t<n>), selected, the panel placed, its speed told.
- A turnout of the model selected: the inspector shows its type, side, speeds and bending, the templates of its kind of the catalogue
(change_turnout), the other side (change_turnout of the hand), moved by a distance (move_turnout), taken out (remove_turnout). The
slide of the switch tool moves it, another template changes it, Del takes it out (after the scenarios are looked through), each a
command. Plan on a track of a turnout doesn't open: the turnout is edited through itself.
- A crossover dragged between two lines of the model is connect_tracks of the solver of the connections; refused, the solver's best
proposal is told with the reasons ("Proposal: Rz 60E1-300-1:9 needs them 4.498 m apart").
- The tracks after a command: of a turnout one of whose tracks changed, its tracks of the simulator made again whole, kept by its main
track (kind switch, the plain tracks of a double switch, a slip or a crossing with them); written with the scenery as the generator
made them, recorded in the project with their kind and the file each went into (session::record_written of pieces of several files),
found again when the map is opened, nothing taken for changed by hand. project::session::generate(turnout_id).
Self-test: modelturnoutside <track>; expect modelproposal <holds|lacks> <text>, expect handlines <count>; expect modelends checks the
paths of the switch tracks at the numbers of the nodes; a crossover of the connection command between two lines of the model goes to
the solver of the model. The cases m_8_turnout (a turnout dragged on, taken back and brought again, moved, given another type and side,
taken out by Del; one 2 m off the end of a cant ramp refused, nothing changed; saved and found after a reopen) and m_9_crossover (a
crossover between lines 4.75 m apart, one between lines 4 m apart refused with the proposal).
Tests: U: the chainage of a point on a line and its distance; the switch track of a turnout made by the session, the tracks of a line
written into two files recorded.
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): the grade line of a line of the model drawn in the profile tool, its command
Continues E4b (editor-tracks-domain.md §8, "Zmień załom lub Rv niwelety"): with the editing on the model on, the profile tool opened on a
track of a line of the model is the profile of the whole line, its points the breaks of the grade line as the model has them with their
vertical radii, the heights of the ends its nodes'.
- Applied, the points between the ends are set_grades of the line (chainages along it, the route run along it or against it), a break
with no radius given the one the line needs; the model is the judge of it, before the checks of the profile tool: refused, nothing
changes and the profile tells why in red; kept, one step, the tracks made anew, the profile read again from the model, what the norms
warn of under it. The heights of the ends aren't changed here: a line of the model keeps the heights of its nodes.
Self-test: modelgrade <track> <m> <height> <vertical radius> (a break put into the grade line of the profile opened on the line, applied),
expect modelgrades <line> <count>. The case m_10_grade_curves (a break 1 m up taken back and brought again; one too near the end to be
rounded refused, nothing changed).
lang/editor_pl.po: the Polish of the new text.
* feat(editor): the vertices of a line of the model dragged on the map, the line as the model would lay it shown before they're let go
Continues E4b (editor-tracks-domain.md §0 pkt 2, §8 "Przesuń wierzchołek", "Zmień R / L / D wierzchołka"): the route design opened on a
line of the model has its handles on the map, a vertex and the grip of the radius of each curve.
- While a handle is dragged the change is tried on a copy of the network as it goes: the line as the model would lay it drawn over the
map, green, or red where it's refused, and by the mouse and in the panel why it's refused or what the norms say of it ("The norms:
2 notes"). Let go, it's one command of the model: move_vertex for a vertex moved, set_vertex for a radius dragged; a vertex moved and
its curve changed at once one set_vertex with its place (layout::set_vertex::point), one step. The first and the last vertex of a
line of two or more go along the tangents of its ends, as the route design drags them.
- No gizmo on the tracks of a line of the model, nor the points of their paths dragged by hand: the line is edited through the route
design. The gizmo stays for the old tracks and the models.
Self-test: modelplan opens the route design in the field of the tracks; expect modelvertexat <line> <index> <x> <z> <tolerance>, expect
modelpreview <shown|none>. The case m_11_vertex_drag (the vertex dragged with the mouse, the preview told while it's held, one step).
Tests: U: a vertex moved and its curve changed by one set_vertex, one step, taken back.
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): curves added to a line of the model and taken out, a line laid on from its free end sharing the node there
Continues E4b (editor-tracks-domain.md §4, §8): two edits E4a left.
- The route design of a line of the model adds a curve at a distance from its start (insert_vertex: a vertex on the leg of the tangents
there, no curve until it's dragged off the line, then of the radius of the lay tool) and takes the curve of a vertex out
(remove_vertex), a command each, the design read again from the model; a handle dragged told above them.
- The lay tool laying from the free end of a line of the model, or to one, makes the new line go on from the node of that end, shared,
not a free node of its own beside it: create_line given the node (layout::create_line::start_node, end_node: a free end of a line of
its own, the line leaving it along its heading or against it as its first leg does), its leg there put onto the tangent of the node, so
the line goes on with no kink. Its tracks and the other line's end at the numbers of the node, to the bit, also after a save and a
reopen.
Self-test: modelvertexadd <m>, modelvertexdel <index>; expect modelvertices <line> <count>, expect modelnodes <count>. The cases
m_10_grade_curves (a curve added, bent, taken out, a step each) and m_12_lay_from_end (a line laid on from a free end shares its node, the
ends to the bit after a reopen).
Tests: U: a line laid on from the free end of another one and back from its start share the nodes, a node of two ends no free end, a kink
refused, undone the node free again.
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): the parallel tool beside a line of the model lays a line of the model, its arcs concentric
Continues E4b (editor-tracks-domain.md §8, "Odsuń tor równoległy"): with the editing on the model on, the parallel tool beside a track of
a line of the model lays a new line of the model at the spacing, one create_line, checked by the norms.
- editor/layout/layoutParallel: the line alongside a line, pure: the legs of the tangents offset, the vertices where the offset legs
meet, the arcs concentric with the line's, the radius less on the inside of a curve and more on the outside, the transitions recomputed
from the shift of the arc so the centre stays the line's; the cant and the class of the line, its grade breaks at the same share of
the length. In a curve the spacing is widened by the widening of the gauge of both tracks on the sides facing each other (PLK tom II
annex 1, gauge::curve_widening, under R 250 m), where the transitions of the curve can take it; where they can't, told so. The norms
of the track geometry have no spacing of their own yet.
- The tool tells the line laid, the spacing in each curve widened, what the norms warn of; refused, why, nothing changed.
Self-test: expect modelspacing <line> <other> <m> <low> <high>. The case m_13_parallel (a line laid on the inside of the curve of a line
of the model, 4.5 m on the straight and in the arc, one step).
Tests: U: the line alongside a straight and alongside three curves on both sides, laid, the arcs concentric within 2 mm; alongside a
curve of R 200 m the spacing widened by the gauges, the transitions longer on the inside and shorter on the outside; not widened where a
curve has no transitions, told why.
lang/editor_pl.po: the Polish of the new texts.
* fix(editor): the tracks of a line of the model saved into a file under an origin aren't taken for changed by hand
The last part of E4b (E4a left it): a track the generator made, written into a layer of another placement than the one its entry was
made for (a file under an origin), went by its own export, recorded by none, and the scenery opened again took its line for changed by
hand.
- project::moved_entry: the entry of a track of the generator, a plain track or a switch track, as written into a file of another
placement: the points of its paths moved by the difference of the origins, in the shortest form of the generator, the control vectors
as they are. The save writes it so and records it, the track keeps it as its text for the next save; reopened, the checksums of the
file are the ones recorded.
Self-test: tests/editor/run.py takes a line `#> append <text>` of a case, added at the end of the copy of the fixture. The case
m_14_layer_origin (a line of the model laid under origin 2000 0 0, saved, reopened, saved again and reopened: nothing changed by hand).
Tests: U: the entry of a track moved for a file under an origin, its control vectors as they were; not moved, the checksum the same.
* feat(editor): the assumptions of the project asked for at the start, what's drawn, kept with the map
editor-project-setup.md: a new user drew with no word of what: the norms, the speed, the gauge and the rail lay about the panels, set
on the way. Now one short step, "What do you draw?" (Co rysujesz?), one screen of defaults and one button:
- The fields: the norms (PLK ST-T1-A6, TSI alone, EN 13803, CH; PLK by default, no "none": a fictional scenery has a profile too), the
speed of the line (chips 40..200, 100 km/h), the traffic, a main or a side track, the gauge (1435 / 1520 / 1000 / 750 / 600 mm),
the rail (60E1 / 49E1 / S42), the look of the tracks under More (the rails and the trackbed as now where left empty).
application/editorsetupui.* draws them for all three places below.
- Asked for as the last step of the wizard of a new scenery (4., or 2. for a fictional one; its button Start: create and open in the
editor), which writes them into the new scenery; and in a scenery with none, as a card in the inspector of the tracks in place of the
first steps, until its Start. Changed later in their window, Assumptions of the project, from the editor settings or the line of
them under the first steps in Tracks; a change checks the lines laid before against them, the report in the window of the norms,
nothing laid changed by it.
- Kept with the map (editor/editorProjectSetup.*, one record "setup norms plk speed 100 traffic mixed track main gauge 1435 rail 60E1"):
in its project file where it has one (a record of its own; the profile of the scenery the model judges by set with it), else in the
scenery as //$u lines, which the simulator skips and the scene layers keep as a mark of the editor. Read when the map is opened, the
project file first. A scenery saved without them holds nothing new.
- The defaults of the tools from them: the speed of the laying and of the route design, the gauge and the rails and the trackbed of the
tracks laid, the norms checked against, the rail of the switch tool and the usual switch of the rail for the speed on its diverging
track (the closest speed, the ratio usual for it). A route with no speed of its own takes the speed of the assumptions.
Self-test: setup [<key> <value>]..., setupwindow [close]; expect setup none|<key> <value>, expect setupmark <present|absent>, expect layspeed <km/h>. The cases
ps_1_setup_saved (set, saved into the scenery, read back after a reopen) and ps_2_setup_project (into the project file with the
editing on the model, read from there after a reopen with it off).
Tests: U: the record written and read back, the defaults, what it can't read, the class of the line, kept in the project file.
lang/editor_pl.po: the Polish of the new texts.
* feat(editor): the aerial photo turned on or off kept per scenery, //$g of the scenery first for its origin
The photo on or off is the scenery's now, as the user left it in it: a global off kept by the editor no longer hides the photo
of a scenery the wizard made with //$o on 1, and the old global choice is left behind. With nothing chosen in the scenery it's
as the scenery keeps it, else off, and the terrain model turns it on where the scenery lies on the map.
The origin of the scenery is taken from //$g of its file before the one the editor remembered for a scenery of that name, or
wrote into //$o with it; where they're apart by more than a metre the status line says so, and the settings of the
orthophoto tell that an origin typed there is for the session.
The rules the photo goes by stand on their own (editorPhotoRules), with their unit tests; the settings of the editor are read
and written through a stream, so they're tested without the user's file.
* feat(editor): the downloads of the aerial photo look after themselves: the area grown at its edge, the failures told and tried again, 4K zoomed in
The download area grows by itself where the camera or the laying comes within a tile of its edge: the tiles of 5 x 5 around
them added to its tiles, as one outline along the grid with its holes filled, now and then (5 s apart at least) and not past
1600 tiles; the status line tells it, and the limit once. The area is saved with the scenery as before.
A tile which failed is tried again later and later, up to 5 min apart, and never given up for good, around the camera and in the
area alike. The ones failed are outlined red in the view, and the status bar tells how many with the reason in plain words
(no connection, the server didn't answer, ...) in place of the code of WinHTTP, and Retry (Ponów) at once.
The 4K photos (6 cm/px) of the tiles next to the camera come by themselves with the view zoomed in to 15 cm a pixel, and go
again past 25 cm, within the limits on the 4K downloads as they were; the area is put into the cache in the products of the
setting alone.
* feat(editor): the tracks laid drawn over the aerial photo in the top view zoomed in as well
The photo is drawn over the view, the 3d tracks under it: zoomed in under 0.5 m a pixel they were left to the 3d tracks and
the photo dimmed them. With the photo shown over the view the tracks are drawn over it there too, as their two rails in the
colour of the rails of the top view where they're apart on the screen, so the tracks laid and the ones of the photo are seen
together; the tracks being laid are drawn after them, on top. How many were drawn in the last frame is kept for the self-test.
* feat(editor): no question of the terrain at the first L, it loads in the background and the photo doesn't wait for it
The first L in a new scenery with no tracks nor terrain asked in a window whether to load the terrain. Now nothing is asked:
where the scenery lies on the map the terrain model loads in the background around it, as the answer Load the terrain did, and
a line in the panel of the laying says "Terrain: loading..." with Without terrain, which stops it as that answer did; it goes
once the terrain is in. A scenery not placed on the map has Place it... there, to Terrain (F5). Whether a new scenery gets its
terrain by itself is a checkbox of the settings of the terrain loading, where the window had it. A download of the model that
failed is told there, and in the banner of the loading and the terrain panel, in plain words as the photo tells its own, not
as the code of WinHTTP (which stays in the log).
A tile of the photo no longer waits for the chunks of the terrain still to come under it: it lies flat at the height of the
ground found last (of the layer before any was) and goes onto the ground as it comes. The window and its strings are gone.
* feat(editor): the aerial photo in the toolbar of the tracks with its opacity, ~ the scenery's choice and in F1
The toolbar of the tracks has the photo: its button shows or hides it for the scenery, as the user's choice, and while it's
shown over the view a slider of its opacity is beside it, kept with the editor. ~ (and Ctrl+~, which turns it on to hurry the
view's tiles) count as the user's choice now: turned off with ~, the terrain model made afterwards no longer turned it on
again behind the user. ~ and Ctrl+~ are listed in F1 with the camera.
* feat(editor): the aerial photos on the map of the wizard, from the service the photo under the scenery comes from
The map the centre of a new scenery is clicked on (and the one of the terrain panel) showed the base map of OpenStreetMap
alone. Zoomed in to 40 m a pixel or finer it shows the orthophoto of GUGiK now, the same WMS as the photo under the scenery in
the editor; further out the map, with "Zoom in for the photos" while the photos are chosen. Map | Photos in its corner
switches between them, the photos chosen at first. Whose the picture is, is told by the line under the steps of the wizard
and, for the photos, in the corner of the map: GUGiK, geoportal.gov.pl, or OpenStreetMap for the map.
* test(editor): the cases of the aerial photo with no fuss, and fs_3 with the line in place of the question
ph_1: the photo turned off with the button of the toolbar stays off over the wizard's //$o on 1 when the scenery is opened
again, on again after the next. ph_2: the first L in a scenery placed on the map asks nothing, the terrain loads in the
background with its line in the panel of the laying, Without terrain stops it. ph_3: the tracks drawn over the photo in the top
view zoomed in under 0.5 m a pixel, not without the photo. ph_4: the button and ~ are the user's choice, the terrain of the model
made afterwards doesn't turn the photo on again, F1 opens.
fs_3 still checks the answer Without terrain, now the button of the line which took the place of the question in a window, and
that no window asks. New for the scripts: expect photo <on|chosen|zoom4k|tracksover>, expect terrain <loading|question>,
toolbar <key|name>, orthophoto forget, and the key grave (~) for tap.
* fix(editor): the panels of the editor opaque, the 3d scene doesn't show through the docks around the view
The 3d scene is drawn under the whole window and the windows took the opacity of the simulator's interface (ui.bg.opacity,
0.65 in the ini of the game): the tracks and the models beside the view showed through the docks around it. The editor's
windows are opaque now; the ones over the view meant to be seen through set their own alpha as before. The simulator keeps
ui.bg.opacity for its own interface.
* 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.
* fix(editor): TSI and EN take close jumps of the cant deficiency together, the norms queue keeps its own span after a delete
- TSI INF and EN 13803 limit an abrupt change of the cant deficiency but give no intermediate length, so two jumps a few metres
apart were each checked alone: at km 478 of the golden line CH reported 191 mm over the TSI limit, TSI itself nothing. With
no intermediate length in the profiles of the element, the longest any profile asks for is taken. The golden report changes
that way: TSI gets the 191 mm hard limit at km 478, EN reports it instead of 106 and 85 mm one by one.
- forget() moves the span whose findings alone are kept (a diverging track) down by the spans removed before it, and drops a
queued line whose own span was removed, instead of leaving the index on another span.
- The report test of R 400 / 80 mm runs at 90 km/h and requires the finding: at 80 km/h there was none and the check never ran.
* fix(editor): the norms see a Bloss transition as it is, a line splits at the tangent point of an arc with no transitions
- A Bloss transition went to the norms as an even one: 60 m into R 600 m at 100 km/h showed 63 mm/s of deficiency change,
where its middle reaches 109 mm/s, past the hard limit of 80 mm/s, so the edit wasn't blocked. norms::element::bloss makes the
engine follow 3t^2 - 2t^3 of the curvature, look at the transition in eight pieces, and take the shift as L^2 / 40R instead
of L^2 / 24R. Two Bloss halves no longer run on into one element of the chain.
- split_line right at the tangent point of an arc without transitions was refused ("the tangent there doesn't cross the
tangents of the curve"): the curvature there is already the arc's, so it now takes the start or the end of the curve.
- Sonar: the chain walk, describe_chain and check_norms check the lines they look up (S2259), join_ends returns when an end
isn't found rather than when a reason was given (S836), the test loops count in integers (S2193), the seeded generator
of the random edits is marked (S2245).
* fix(editor): the answer Without terrain keeps to the scenery open, the settings stay as they were
nmt_decline_offer() turned off terrain_while_laying and terrain_model().area in the settings of the editor and saved them, so
one Without terrain for a scratch scenery left the terrain off for every scenery opened later. The answer now holds for the
scenery open only (nmt_state::declined, read through nmt_area()); the checkbox of the terrain panel shows it and, ticked, turns
the terrain on again and keeps it in the settings. The nmtquestion self-test no longer writes the tester's settings, and fails
the run if the answer changed them.
* fix(editor): no diverging track is laid from a main track that isn't laid, a switch track with no pieces isn't written
- lay_diverging() didn't look at turnout_frame::valid: with the main track unsolved the diverging track was laid from the origin
and settle moved its end node there. Edits were rolled back by the check, but nothing refused it at its source. It now
returns an error, for every caller.
- whole_path() took Pieces.front() of a track the cutter gave no pieces of; the switch track is refused with the reason.
- Sonar: the turnout lookups of the node and network checks are guarded (S2259), the search of the free transition and the
test loops count in integers (S2193; 2 m steps, the same values as their sum), the seeded generator of the turnout edits
is marked (S2245).
* fix(editor): file names outside the code page don't crash the project, includes are found in any case, a project file cut short isn't put in place
- The scenario index made a string of the name of every file in the folder, which throws on Windows for a name the ANSI code
page can't hold (the class of GE#560). It looks at the extension first and leaves out a .scn the game couldn't open by its
name either; the messages of the project file show paths as UTF-8.
- The includes are read with the FileCased() fallback of the game (scenery_text::file_text), so on Linux an include written in
another case no longer drops the scenario from the index, skips the migration of its file or marks its tracks as changed by
hand.
- save() closes the file before looking at it: a failed last flush no longer renames a truncated .new over the project.
- "next node 0" is refused instead of wrapping to 0xffffffff.
- open_project() writes no .eu07proj when there were no //$ lines to migrate, and asks exists() without throwing.
* fix(editor): the checkbox of the terrain around the camera in the layers shows the answer Without terrain of the scenery open
* fix(editor): the lay panel says "Laid" only while the step it was laid with is on top of the history
lay_panel_state() told the line laid from laid_step == m_history.size(). Lay, Ctrl+Z, then any one-step edit made the size the
same again, and the panel said "Laid … Ctrl+Z undoes" for a line that was gone; at the cap of 200 steps it stayed "laid" for
good. The panel now compares the serial of the step on top of the history (EditorSnapshot::serial), which each step made has
of its own.
* fix(editor): migrated switches leave to the side their records say, bent ones migrate, a record fitting two types isn't guessed
- The migration mapped L to hand 1, but switch_store::classify() writes R where the diverging end lies to the positive cross of
the direction, which is the side of hand 1 of the domain (its curvature above 0 turns that way). Every migrated switch came
out mirrored, and the test checked hand == 1 for an L record without looking at where the diverging end lies. R is hand 1
now, and the test checks the side of the diverging end.
- classify() writes a switch bent into a curve as Rlj or Rld with the radius of the ordinary switch it's bent from; the
catalogue has it as an Rz, so no bent switch could migrate. They're looked up as Rz.
- catalogue_type() took the first loose match. A movable nose isn't in the record, so the ordinary frog is taken where the
catalogue has both; a record fitting two other types (the variants of an Rpd) is kept as it was, why with it.
- Slips and crossings are kept as they were, as the header of the migration says.
- Smaller: the type looked up is checked before its length is read; new diverging, slip and crossing tracks get the
chainage of the turnout as a diverging track had before; the walk of a bent transition stops on a step that turned nothing
instead of dividing by it.
- Sonar: the leg check skips an end whose turnout isn't found (S2259), the spacing of a crossover is measured in whole steps
counted in an integer (S2193), the seeded generator of the turnout kinds test is marked (S2245).
* fix(editor): a save writing some tracks of a line keeps the records of the others, a plan edit refused in part changes nothing
- record_written() erased every record of the line and added only the pieces written in this save, while the scenery writes
only the tracks changed since. After a gizmo move and Ctrl+Z on one track of a line, the next save kept a record of that
track alone: on reopening the line owned one track, and the next Plan edit left the others as duplicates. The records of
the tracks the line still has and this save didn't write now stay.
- model_run() kept each command before trying the next: with the radius of one vertex carried out and the cant of the next
refused, the first stayed changed under "Refused, nothing changed". Several commands are now all tried on a copy first.
- The fingerprint of the scenario index made a string of every file name before its .scn filter, which throws on Windows
outside of the code page, on a detached thread (the class of GE#560). The extension is looked at first, as in the index
itself; scenery_text::name_of() and has_extension() are shared by both.
- A Del deferred by the check of the scenarios reads Shift as it was at the key press, not at the click on "go on".
- open_project() writes no project file for a map with nothing to migrate (#461): the session test expects that.
* fix(editor): the pieces of a cut old track get its events as the simulator fires them, its joints follow a line laid anew
- keep_old_tracks() kept all the events on the first piece of an old track. The simulator fires event1 as a vehicle enters a
track at its Point2, event2 at its Point1 and event0 while it stands on it (TrkFoll.cpp), so with a 120 m track cut into 40
and 80 m a train running towards Point1 got event1 about 80 m late, and one standing on the second piece no event0. Now each
piece gets event0/eventall0, the piece at Point1 event2/eventall2 and the piece at Point2 event1/eventall1. The keywords are
compared in any case, as the simulator lowers its tokens.
- The joints of the old tracks kept their chainages through move_vertex, set_vertex, insert_vertex and remove_vertex: widening
a 90° curve by 20 m shortens the line by about 8.6 m, and a joint past the new end was dropped, a short buffer-stop or signal
track there with its name, events and circuit. Each joint now goes to the point of the new line nearest to where it was.
solved_line::nearest() is shared with the crossover planner.
- Sonar: the seeded generators of the takeover tests are marked (S2245), two dereferences after a REQUIRE too (S2259).
* fix(editor): the plan preview follows a drag of the first or last vertex, "This path" lays beside the path alone, Esc clears the preview
- model_plan_preview() keyed on vertex.position, which a drag of the first or the last vertex of a line with two or more
curves doesn't change (it moves vertex.offset along the tangent of the end): the green or red line and the text of the norms
froze after the first frame, and the release could be refused where the preview showed it within the norms. The key has the
offset now.
- parallel_build() laid the whole line with model_parallel beside a managed line whatever the scope, so "This path" on a 50 m
track of a 2 km line previewed 50 m and laid 2 km. The model's parallel line is laid for the scope of the whole line only.
- Esc during a handle drag restored the design but left the preview of the model on screen.
* fix(editor): the assumptions of the project aren't lost with a project not saved, a texture field cleared is the lay tool's own again
- With the editing on the model, setup_store() took the //$u lines out of the scenery and left the assumptions to the project
of the model, which is written after the scenery and may fail to be: then they were in neither. The scenery keeps the line
as well; the project's is read first, as before.
- A texture typed into the assumptions and cleared again left the lay tool with the one typed: empty is the tool's own.
* fix(editor): a photo origin aligned by hand isn't overridden by //$g, the 4K photos of the zoom take the tile under the camera alone
- //$g of the scenery file went before the origin of //$o, also where the user had aligned the photo by hand in the editor: the
alignment was gone on the next opening. An origin typed in the editor is written into //$o with the word "aligned", and such
an origin goes before //$g. The word is optional: a release before it passes it over and reads the origin as before, and an
//$o without it is read as before. "Use it" (the origin of //$g) takes the word off.
- The zoom turned the 4K photos on for the 3 x 3 tiles around the camera, as the setting for them does: up to about 0.75 GB of
the memory of the graphics card, unasked. By the zoom alone the 4K photo is the tile under the camera (about 85 MB); the
setting keeps the 3 x 3.
* fix(editor): a map opened on the model gets its project file also with nothing to migrate
open_project() writes no project file when there are no //$ lines to migrate (#461), but the editing on the model relies on
the map having its project file from the start: the self-test cases m_1_lay_managed and ps_2_setup_project failed with it
absent. session::open() writes it when it isn't there.
* fix(editor): the assumptions go into the project of the model, and back into the scenery only while it isn't saved
The earlier fix kept the //$u line in the scenery whenever the editing is on the model, so ps_2_setup_project found the
assumptions in the scenery where the project should hold them alone. They are taken out of the scenery again as before; when
the scenery or the project of the model then fails to be saved, they go back into the scenery with its next save and stay
there until the project is saved.
* test(editor): nmtsettings grow sets the terrain while laying for the run only, the tester's eu07_editor.ini left as it was, as area does
* fix(editor): the anchors section keeps its blank lines and comments, a reason keeps its blanks, a scenery including itself is told
- The section kept for the anchors is written back as it was read: its blank lines and its # comments were dropped before the section
was looked at.
- The reason of a legacy record is the rest of the line as written, its blanks kept: joined with one blank, a reason of two blanks
came back changed after a save and a load.
- A file of a scenery including itself, on its own or through others, is told and not read again; before, only the depth of 32
stopped it.
* test(editor): lf_1 opens the settings of the lay tool from the line of their summary and folds them again, through a new laysettings command
* test(editor): the migration takes a bent switch (Rlj) for the Rz it's bent from, and keeps an Rpd record two types of the catalogue fit with why
* fix(editor): a Plan apply is one step to undo, the setting of the model is taken when the scenery is opened, tracks taken away by hand are a change by hand
- The commands of one Plan apply after the first are joined to it: one Ctrl+Z takes back the whole apply, none leaves the line half
edited.
- The setting "Editing on the model" is taken when the scenery is opened and kept for the session; changed meanwhile, the panel says it
takes effect with the next scenery. Turned on later, an edit made the old way before was written back as the file had it; turned off
before a save, the scenery was saved without its project.
- A line of the model some of whose tracks another tool took away (a switch put in) counts as changed by hand, as it does after a
reopen: each track knows how many tracks its line was made of.
- A self-test which doesn't set the model leaves it off, whatever the tester's own eu07_editor.ini has.
- What the generator can't make as the line has it is told with the notices of the command, not only logged.
* fix(editor): an object past a split goes onto the part beyond it, the joints follow every line laid again, the old tracks read in any case and named apart
- follow() anchors an object again also where its line now ends before it: a split keeps the id for the part before it, so an object
past the split was clamped onto the end of that part.
- The joints of the old tracks follow every line settle() lays again with a reshaping command, not only the line the command names: a
taken-over line going on from a turnout of the line edited kept its joints at their old chainages.
- velocity and none of an old track are read in any case, as the simulator lowers its tokens.
- A line merged with one with no old tracks where it starts keeps that part out of the old tracks, rather than giving it the name and
the circuit of the last old track of the first line.
- <name>_2... of the pieces of an old track pass over the names other old tracks of the line have.
- The old records of a line are refused on read where they aren't on the line or not in their order.
* fix(editor): the hand of a turnout commented as the code has it, an Apply with no edit adds no step, a profile opened drops the error of the one before, tests of the side
- The comments of layoutCommands.hpp and layoutNetwork.hpp give hand 1 as right and -1 as left, as the migration and the inspector
have it since #464 (R of a switch record).
- The grade line of a line of the model applied with no edit: the breaks compared within a micrometre, the chainages having gone to
the route and back; compared exactly, it added a step.
- profile_open() clears the error of the route opened before.
- Self-test expectations: modelpreview current (the preview worked out for the design as it is now, m_11), modelspacing signed by
the side (m_13 to the right, -4.5 m), modelside of a switch (m_8 right, then left after the side is changed).
* fix(editor): a project of the map not saved tells to save again while the assumptions of the project are in neither file
* fix(editor): the area tiles failing offline logged once and retried on their own schedule, the terrain loads once the scenery is placed, failed tiles outlined on the ground
- A tile of the download area failing again and again is logged the first time only; each retry wrote a line, the whole area every
5 min offline.
- The queue of the area holds the tiles still to be fetched: the ones fetched go from it before a retry is added, it no longer grows
by each retry.
- A growth of the area keeps the tries of the tiles which failed, for the same photos: the ones waiting for their next try go on
waiting, not asked for again all at once with the backoff started over.
- "Place it..." in the line of the terrain: once the scenery is placed on the map, its terrain loads as the offer has it, and the line
says so; it said the scenery wasn't placed and nothing loaded.
- In the 3D view the outlines of the failed tiles lie on the ground the draped photo lies on, not at the height of the layer.
- area_grow() looks at the area every 5 s whatever comes of it; set only by a growth, it ran every frame once 5 s had passed.
* fix(editor): the outlines of the failed photo tiles don't keep the ground cache growing
With the photo draped, the 3D view and the tiles failing (offline), draw_orthophoto_failures asked ground_heights for the
corners of up to 400 tiles every frame. That gathered a 256 m ground tile per frame without end, and since every tile it
asked for was used in that frame, the eviction stopped and the ground cache grew past its limit over the download area.
The heights under the corners are now kept per failed tile. Two tiles are asked for a frame: one with a corner not found
yet each second, one found all round each 30 s, as the ground under it may have come or changed since. The entries of the
tiles no longer failing are dropped, and all of them when the photo is off or nothing fails. A corner not found yet is
drawn at the height of the layer, as before.
3978 lines
216 KiB
C++
3978 lines
216 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/applicationmode.h"
|
|
#include "application/editoruipanels.h"
|
|
#include "input/editormouseinput.h"
|
|
#include "input/editorkeyboardinput.h"
|
|
#include "vehicle/Camera.h"
|
|
#include "application/editormodegauge.h"
|
|
#include "application/editormoderide.h"
|
|
#include "application/editormodeminimap.h"
|
|
#include "application/editormodejoints.h"
|
|
#include "application/editormodelineside.h"
|
|
#include "application/editormodeparallel.h"
|
|
#include "application/editormodespeed.h"
|
|
#include "application/editormodenorms.h"
|
|
#include "application/editormodesrk.h"
|
|
#include "application/editormodekm.h"
|
|
#include "application/editormodevehicle.h"
|
|
#include "application/editortool.h"
|
|
#include "scene/sceneeditor.h"
|
|
#include "scene/scenenode.h"
|
|
#include "editor/editorTerrain.hpp"
|
|
#include "editor/editorTerrainStreamer.hpp"
|
|
#include "editor/editorOrthophoto.hpp"
|
|
#include "editor/editorNmt.hpp"
|
|
#include "editor/editorGeoMap.hpp"
|
|
#include "editor/editorTrack.hpp"
|
|
#include "editor/editorTrackTrace.hpp"
|
|
#include "editor/editorConnections.hpp"
|
|
#include "editor/editorAlignment.hpp"
|
|
#include "editor/editorAlignmentStore.hpp"
|
|
#include "editor/editorSwitchStore.hpp"
|
|
#include "editor/editorSwitchCurve.hpp"
|
|
#include "editor/editorKilometrage.hpp"
|
|
#include "editor/editorSpeed.hpp"
|
|
#include "editor/editorRoad.hpp"
|
|
#include "editor/editorProfile.hpp"
|
|
#include "editor/editorProjectSetup.hpp"
|
|
#include "editor/editorRecords.hpp"
|
|
#include "editor/editorGroundFollow.hpp"
|
|
#include "editor/editorInfra.hpp"
|
|
#include "editor/editorGauge.hpp"
|
|
#include "editor/editorClips.hpp"
|
|
#include "editor/editorIcons.hpp"
|
|
#include "editor/layout/layoutCommands.hpp"
|
|
#include "application/scriptedinput.h"
|
|
#include "world/Sweep.h"
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <tuple>
|
|
#include <chrono>
|
|
#include <functional>
|
|
#include <atomic>
|
|
#include <future>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <sstream>
|
|
#include <limits>
|
|
#include <set>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
class TAnimModel;
|
|
// a tool of a field of work of the editor, a button in the toolbar and over the 3d view
|
|
struct editor_tool_button;
|
|
class TTrack;
|
|
|
|
// the state of the editing through the model of the track geometry, editormodemodel.cpp
|
|
struct editor_model;
|
|
struct editor_model_deleter
|
|
{
|
|
void operator()(editor_model *Model) const;
|
|
};
|
|
|
|
class editor_mode : public application_mode, private editor_track::observer, private editor_services
|
|
{
|
|
|
|
public:
|
|
// constructors
|
|
editor_mode();
|
|
~editor_mode() override;
|
|
// methods
|
|
// initializes internal data structures of the mode. returns: true on success, false otherwise
|
|
bool init() override;
|
|
// mode-specific update of simulation data. returns: false on error, true otherwise
|
|
bool update() override;
|
|
// maintenance method, called when the mode is activated
|
|
void enter() override;
|
|
// maintenance method, called when the mode is deactivated
|
|
void exit() override;
|
|
// input handlers
|
|
void on_key(int Key, int Scancode, int Action, int Mods) override;
|
|
void on_cursor_pos(double Horizontal, double Vertical) override;
|
|
void on_mouse_button(int Button, int Action, int Mods) override;
|
|
void on_scroll(double const Xoffset, double const Yoffset) override;
|
|
void on_window_resize(int w, int h) override
|
|
{
|
|
;
|
|
}
|
|
void on_event_poll() override;
|
|
bool is_command_processor() const override;
|
|
// takes the last change back; changes made together (e.g. to the models of a selection) are taken back together
|
|
void undo_last();
|
|
static bool focus_active();
|
|
static void set_focus_active(bool isActive);
|
|
static TCamera& get_camera() { return Camera; }
|
|
static glm::mat4 projection_matrix(float const Aspect);
|
|
void toggle_ortho();
|
|
static bool change_history() { return m_change_history; }
|
|
static void set_change_history(bool enabled) { m_change_history = enabled; }
|
|
static bool settings_open() { return m_settings_open; }
|
|
static void set_settings_open(bool enabled) { m_settings_open = enabled; }
|
|
private:
|
|
// types
|
|
struct editormode_input
|
|
{
|
|
|
|
editormouse_input mouse;
|
|
editorkeyboard_input keyboard;
|
|
|
|
bool init();
|
|
void poll();
|
|
};
|
|
|
|
struct state_backup
|
|
{
|
|
|
|
TCamera camera;
|
|
bool freefly;
|
|
bool picking;
|
|
};
|
|
|
|
// grade lines designed in the editor, kept in the scenery files as "//$p" comment lines
|
|
using stored_profile = editor_records::grade_profile;
|
|
struct EditorSnapshot
|
|
{
|
|
enum class Action { Move, Rotate, Scale, Add, Delete, TrackEdit, Other, RoadEdit, Array, Bend, Terrain, Kilometrage };
|
|
// copy of a model an array made
|
|
struct array_copy
|
|
{
|
|
TAnimModel *model{nullptr}; // nullptr while the copy is out of the scene
|
|
UID uuid;
|
|
// what it takes to make the copy again, filled in when it's taken out of the scene
|
|
std::string serialized;
|
|
std::string name;
|
|
glm::dvec3 position{0.0};
|
|
glm::vec3 rotation{0.0f};
|
|
glm::vec3 scale{1.0f};
|
|
};
|
|
|
|
Action action{Action::Other};
|
|
std::string node_name; // node identifier (basic_node::name())
|
|
// direct pointer to node when available; used for in-memory undo/redo lookup
|
|
scene::basic_node *node_ptr{nullptr};
|
|
std::string serialized; // full text for recreate (used for Add/Delete)
|
|
glm::dvec3 position{0.0, 0.0, 0.0};
|
|
glm::vec3 rotation{0.0f, 0.0f, 0.0f};
|
|
glm::vec3 scale{1.0f, 1.0f, 1.0f};
|
|
UID uuid; // node UUID for reference, used as fallback lookup for deleted/recreated nodes
|
|
scene::layer_handle layer{null_handle}; // scenery layer of the node, so a recreated node returns to it
|
|
scene::instance_handle instance{0}; // include of a scenery template which was placed or removed, instead of a node
|
|
std::vector<scene::instance_handle> instances; // includes placed or removed together
|
|
std::vector<std::pair<scene::instance_handle, std::string>> directives; // includes changed together, with the directives to go back to
|
|
std::vector<std::pair<sweep_node *, sweep_node::state>> sweeps; // models along curves changed, with the definitions to go back to
|
|
std::vector<sweep_node *> sweeps_toggled; // models along curves made or removed: undo flips whether they're there
|
|
std::vector<std::pair<TTrack *, editor_track::state>> tracks;
|
|
std::vector<TTrack *> created;
|
|
std::vector<TTrack *> removed;
|
|
editor_road::record roads; // what a change of the roads comes to
|
|
std::vector<infra::object_state> infra; // objects which followed the paths
|
|
bool profiles{false}; // the stored grade line designs changed too, these were the ones before
|
|
std::vector<stored_profile> profile_library;
|
|
std::optional<std::vector<alignment_store::record>> alignments; // the kept horizontal alignments changed too, these were the ones before
|
|
std::optional<std::vector<switch_store::record>> switch_records; // the kept switches changed too, these were the ones before
|
|
std::optional<srk_hand_joints> hand_joints; // the joints of a station put by hand changed too, these were the ones before
|
|
std::optional<kilometrage::state> kilometrage; // the kilometrage before the change (Action::Kilometrage)
|
|
std::vector<array_copy> copies; // models an array added to the one it was made of
|
|
bool joined{false}; // undone and redone together with the change before it
|
|
std::uint64_t model_token{0}; // a command of the model of the track geometry this step is, taken back and brought again with it
|
|
std::shared_ptr<terrain_streamer::change const> terrain; // the heightmap terrain from before the change (Action::Terrain)
|
|
std::uint64_t serial{next_serial()}; // of each step made, for the revision of the history
|
|
static std::uint64_t next_serial()
|
|
{
|
|
static std::uint64_t counter{0};
|
|
return ++counter;
|
|
}
|
|
};
|
|
void push_snapshot(scene::basic_node *node, EditorSnapshot::Action Action = EditorSnapshot::Action::Move, std::string const &Serialized = std::string());
|
|
|
|
std::vector<EditorSnapshot> m_history; // history of changes to nodes, used for undo functionality
|
|
std::vector<EditorSnapshot> g_redo;
|
|
int m_track_edits{0};
|
|
// methods
|
|
void update_camera(double const Deltatime);
|
|
// the camera onto the track under the cursor, or the nearest one, to ride along it
|
|
void ride_enter();
|
|
// the way the camera looks, in the plan
|
|
glm::dvec3 camera_look() const;
|
|
|
|
editor_ui *ui() const;
|
|
void redo_last();
|
|
// a single step of the history, see undo_last()
|
|
void undo_one();
|
|
void drop_step(std::size_t const Step);
|
|
std::string refused(std::string Text);
|
|
// a switch not laid: told in the panel of the switch tool, which shows the text returned, and by the cursor
|
|
std::string switch_refused(std::string Text);
|
|
void redo_one();
|
|
// the changes of the heightmap terrain since the last step become a step of the history: a stroke of the brush,
|
|
// or what a frame did; the next change is recorded from now on
|
|
void terrain_history_step();
|
|
// puts the terrain back as the step recorded it, the step left with the state it replaced
|
|
void restore_terrain(EditorSnapshot &Snapshot);
|
|
// swaps the kilometrage with the one the snapshot keeps
|
|
void restore_kilometrage(EditorSnapshot &Snapshot);
|
|
bool m_history_busy{false}; // undo or redo under way
|
|
void handle_brush_mouse_hold(int Action, int Button);
|
|
void apply_rotation_for_new_node(scene::basic_node *node, int rotation_mode, float fixed_rotation_value);
|
|
// members
|
|
state_backup m_statebackup; // helper, cached variables to be restored on mode exit
|
|
editormode_input m_input;
|
|
static TCamera Camera;
|
|
|
|
// focus (smooth camera fly-to) state
|
|
static bool m_focus_active;
|
|
glm::dvec3 m_focus_start_pos{0.0,0.0,0.0};
|
|
glm::dvec3 m_focus_target_pos{0.0,0.0,0.0};
|
|
glm::vec3 m_focus_start_angle{0.0f}; // camera pitch/yaw/roll at focus start
|
|
glm::vec3 m_focus_target_angle{0.0f}; // camera pitch/yaw/roll facing the focused object
|
|
double m_focus_time{0.0};
|
|
double m_focus_duration{0.6};
|
|
// the last place and angles of the camera which were numbers: a camera gone to no finite place goes back there
|
|
glm::dvec3 m_camera_finite_pos{0.0, 0.0, 0.0};
|
|
glm::vec3 m_camera_finite_angle{0.0f};
|
|
bool m_camera_finite{false};
|
|
|
|
double fTime50Hz{0.0}; // bufor czasu dla komunikacji z PoKeys
|
|
scene::basic_editor m_editor;
|
|
scene::basic_node *m_node{nullptr}; // currently selected scene node
|
|
scene::instance_handle m_instance{0}; // currently selected include of a scenery template; these are handled as a whole
|
|
include_selection m_include; // parameters of the selected include, changed with the gizmo and in the node properties
|
|
bool m_include_gesture{false}; // a change of the selected include is under way, and has its undo snapshot already
|
|
std::vector<std::pair<TAnimModel *, int>> m_retired; // models replaced after changes of includes, with the frames left until they're destroyed
|
|
bool m_takesnapshot{true}; // helper, hints whether snapshot of selected node(s) should be taken before modification
|
|
bool m_dragging = false;
|
|
glm::dvec3 oldPos; // world position of the last brush placement
|
|
bool m_brush_has_last{false}; // false at the start of a brush stroke, so the first placement ignores spacing
|
|
bool m_draw_cursor{false}; // the cursor drawn into the picture (View menu), on only while the editor is
|
|
bool mouseHold{false};
|
|
float kMaxPlacementDistance = 200.0f;
|
|
static bool m_change_history;
|
|
static bool m_settings_open;
|
|
|
|
double m_ortho_pitch{0.0};
|
|
bool m_ortho_pan{false};
|
|
glm::dvec2 m_ortho_pan_cursor{0.0};
|
|
double m_pan_metres{0.0}; // of the ground to a pixel, held by the panning in the perspective view
|
|
void ortho_pan_to(double const Horizontal, double const Vertical);
|
|
void ortho_pan_stop();
|
|
// camera fly-mode (right mouse button held); used to flush motion when it's released
|
|
command_relay m_camera_relay;
|
|
bool m_camera_flying{false};
|
|
|
|
// UI/history settings
|
|
int m_max_history_size{200};
|
|
int m_selected_history_idx{-1};
|
|
glm::dvec3 clamp_mouse_offset_to_max(const glm::dvec3 &offset);
|
|
// the ground under a point the cursor landed on, for things which are to stand on the ground
|
|
glm::dvec3 placement_on_ground(glm::dvec3 Location) override;
|
|
// the ground under a point, the point itself with none there
|
|
glm::dvec3 ground_at(glm::dvec3 Location) const;
|
|
// puts every instance of the model the selected node shows on the ground under it
|
|
void drop_model_instances();
|
|
void render_object_menu();
|
|
// undo, redo and what can be done with the selection, with their keys
|
|
void render_edit_menu();
|
|
// the list of the keyboard shortcuts, opened from the help menu or by F1
|
|
void render_help_menu();
|
|
void render_shortcuts_window();
|
|
bool m_shortcuts_open{false};
|
|
using first_step = editor_first_step;
|
|
// the tutorial: a window of lessons, each with a clip or a sketch, the mouse and the keys it teaches and the steps to try
|
|
struct tutorial_lesson;
|
|
static std::vector<tutorial_lesson> const &tutorial_lessons();
|
|
// a lesson is done once all its steps are
|
|
bool tutorial_done(tutorial_lesson const &Lesson) const;
|
|
void render_first_steps();
|
|
// the first steps in the inspector with nothing selected: the lesson of the tool in use with its steps to try, the whole lesson
|
|
// in its window on request. false: hidden for good, or the window of the lesson is open
|
|
bool render_first_steps_card();
|
|
// the steps to try of a lesson, ticked as they're reached
|
|
void render_tutorial_steps(tutorial_lesson const &Lesson);
|
|
// a track laid where there's no ground lies flat at the height 0: told while the pointer is over the view where the terrain is to be
|
|
void render_ground_warning(tutorial_lesson const &Lesson);
|
|
// the steps reached by what the editor is doing now
|
|
void note_first_steps();
|
|
// the lesson of the tool in use: the first of its lessons not done yet, or none
|
|
char const *tutorial_of_tool();
|
|
// the lesson the tool in use or a button of a panel asks for opened, and the clip of the lesson open loaded
|
|
void follow_tutorial();
|
|
void render_tutorial_media(tutorial_lesson const &Lesson, float const Width);
|
|
void render_tutorial_goals(tutorial_lesson const &Lesson);
|
|
// the button under a lesson, opening the tool it's about or switching the view
|
|
void render_tutorial_trial(tutorial_lesson const &Lesson);
|
|
// the buttons to the lesson before and after, and a dot for each lesson, green when it's done
|
|
void render_tutorial_pages();
|
|
void first_step_done(first_step const Step) override;
|
|
void open_kilometrage() override;
|
|
bool m_first_steps_open{false}; // the window of the lesson
|
|
// the assumptions of the project ("Co rysujesz?"): none until they're said, the card of the inspector of the tracks asking for them;
|
|
// the defaults meanwhile. Kept with the map: in its project file where it has one, else in the scenery (//$u)
|
|
std::optional<project_setup::setup> m_setup;
|
|
project_setup::setup m_setup_edit; // the fields of the card and of the window
|
|
bool m_setup_read{false}; // read for the scenery open
|
|
bool m_setup_changed{false}; // to be written with the scenery
|
|
bool m_setup_marked{false}; // the scenery holds //$u lines
|
|
bool m_setup_moving{false}; // the assumptions given to the project of the model, which isn't saved yet
|
|
bool m_setup_unsaved{false}; // the project of the model failed to be saved with them: the scenery keeps them till it is
|
|
bool m_setup_window{false};
|
|
std::string m_setup_told; // what the change of them found among the lines laid before
|
|
bool m_setup_checking{false}; // the lines of the scenery being checked against the assumptions changed
|
|
project_setup::setup setup_now() const { return m_setup.value_or(project_setup::setup{}); }
|
|
void setup_update();
|
|
void setup_read();
|
|
// the assumptions taken: the defaults of the tools from now on; Changed: said by the user, to be written with the scenery, the lines
|
|
// laid before checked against them
|
|
void setup_apply(project_setup::setup const &Setup, bool const Changed);
|
|
// the defaults of the tools from the assumptions: the speed of the laying and of the plan, the gauge and the look of the tracks laid,
|
|
// the norms checked against, the rail and the usual switch of the switch tool
|
|
void setup_defaults(project_setup::setup const &Setup);
|
|
void setup_store();
|
|
void setup_keep_in_scenery();
|
|
// the project of the model saved, or not, after the scenery: where the assumptions are kept
|
|
void setup_project_saved(bool const Saved);
|
|
bool render_setup_card();
|
|
void render_setup_window();
|
|
void render_setup_line();
|
|
// the assumptions into the project of the map where it's open, the profile of its scenery with them; false where it isn't
|
|
bool model_setup();
|
|
editor_selftest_result selftest_setup(std::string const &command, std::istringstream &words);
|
|
int m_first_steps_shown{0}; // frames the window of the lesson was drawn since it opened, up to 3: it's placed anew as it opens
|
|
std::array<bool, static_cast<std::size_t>(first_step::count)> m_first_steps_done{};
|
|
int m_tutorial_page{0};
|
|
char const *m_tutorial_goto{nullptr}; // the lesson of this title opened by a button of a panel
|
|
std::string m_tutorial_followed; // the lesson the tool in use asked for last: it's opened when that changes
|
|
double m_tutorial_since{0.0};
|
|
editor_clips::clip m_tutorial_clip;
|
|
// deletes what's selected: a road piece or point, a signal, an include of a scenery template, a model, tracks (Del)
|
|
void delete_selected();
|
|
void delete_model(TAnimModel *Model, bool const Joined);
|
|
|
|
// more models selected at once, in the surroundings: m_node is the one the gizmo is on, the others are in m_selection.
|
|
// Shift+LMB adds a model or takes it out; a model of a group stands for the whole group
|
|
std::vector<scene::basic_node *> m_selection;
|
|
std::vector<scene::basic_node *> selected_nodes() const; // m_node first
|
|
std::vector<scene::basic_node *> selection_with_groups() const; // and the other models of their groups
|
|
void select_node(scene::basic_node *Node, bool const Additive);
|
|
void draw_selection_overlay();
|
|
// the other models of the selection follow m_node moved or turned by the gizmo
|
|
void selection_snapshots(EditorSnapshot::Action const Action);
|
|
void selection_follow(glm::dvec3 const &Moved, glm::vec3 const &Turned, glm::dvec3 const &Pivot);
|
|
// clipboard (Ctrl+C, Ctrl+V): definitions of the models, placed around the cursor as they were around the selected one
|
|
struct clipboard_entry
|
|
{
|
|
std::string definition;
|
|
glm::dvec3 offset{0.0};
|
|
glm::vec3 angles{0.0f};
|
|
glm::vec3 scale{1.0f};
|
|
int group{-1}; // models copied with their group are grouped again, each group anew
|
|
};
|
|
std::vector<clipboard_entry> m_clipboard;
|
|
void copy_selection();
|
|
void paste_clipboard(glm::dvec3 const &Location);
|
|
glm::dvec3 cursor_ground(); // the point of the ground under the cursor
|
|
// groups (Ctrl+G, Ctrl+Shift+G), written to the scenery as group ... endgroup
|
|
void group_selection();
|
|
void ungroup_selection();
|
|
void drop_selection_to_ground();
|
|
// menu at the cursor, Ctrl+RMB
|
|
bool m_contextopen{false};
|
|
glm::dvec3 m_contextpoint{0.0};
|
|
void render_context_menu();
|
|
|
|
// focus camera smoothly on specified node
|
|
void start_focus(scene::basic_node *node, double duration = 0.6);
|
|
|
|
// drops the node straight down onto the nearest surface below (terrain or another object). its group goes along with it,
|
|
// unless Alone: then the node goes by itself. Joined: undone together with the change before
|
|
void snap_to_ground(scene::basic_node *node, bool const Alone = false, bool const Joined = false);
|
|
|
|
// the heightmap terrain of the scenery (terrain/<name>/): chunks, sculpting, painting, water
|
|
void render_terrain_ui();
|
|
// the terrain as a field of work of its own: the terrain tools and the orthophoto in the tool options window
|
|
void render_terrain_tool_options();
|
|
// opens or leaves the terrain; leaving it puts the terrain tools away, so the mouse doesn't stay with them
|
|
void terrain_workspace(bool const Open);
|
|
// opens the heightmap terrain of the scenery for editing, named after the scenery, if the scenery has none yet. returns: true if it's open
|
|
bool ensure_terrain();
|
|
// adds chunks around the camera, Count along a side, at the height of the ground under each grid point where there's any
|
|
void add_chunks_around(int const Count);
|
|
// adds a chunk of the terrain shaped as the ground under it; where there's no ground, carried on level with the nearest point
|
|
// of it, or at the base height. returns: false if there's a chunk already
|
|
bool add_chunk_from_ground(heightmap::chunk_key const &Key, float const Spacing, std::uint16_t const Layer = 0);
|
|
|
|
// the terrain from the digital terrain model of GUGiK (editormodenmt.cpp)
|
|
using nmt_place = ::nmt_place;
|
|
struct nmt_state
|
|
{
|
|
double offset{0.0}; // added to the heights of the model, so they meet the tracks of the scenery
|
|
bool fitted{false};
|
|
bool fitting{false}; // waiting for the model under the places of the tracks the offset is worked out from
|
|
std::vector<nmt_place> fit;
|
|
double spread{0.0}; // how much the tracks differ from the model about the offset, m
|
|
std::size_t samples{0};
|
|
double band{300.0}; // m from the tracks the chunks made along them reach
|
|
bool shape{true}; // the formation and the slopes of the tracks as modifiers of the terrain
|
|
bool grow{true}; // while a track is laid, the terrain is made around the cursor where there's none
|
|
// the answer Without terrain for the scenery open: nothing of the model is made around the camera by itself, whatever the
|
|
// settings, which stay as they were for the other sceneries
|
|
bool declined{false};
|
|
bool laying{false}; // the tracks committed are being laid: they leave the terrain as it is
|
|
bool follow{true}; // a track with its formation edited takes it along, the formation led anew
|
|
bool grown{false}; // the chunks waiting were all asked for by growing: the formations aren't made anew after them
|
|
bool reshape{false}; // the formations of the tracks laid anew once the chunks waiting are made, as the tracks are put onto the terrain
|
|
bool unfitted{false}; // the tracks put onto the terrain are only the ones whose grade line isn't fitted yet
|
|
bool redo_hand{false}; // all anew takes the grade lines edited by hand too
|
|
std::unordered_set<TTrack const *> stayed; // the tracks this putting onto the terrain leaves as they are
|
|
double grow_time{-10.0};
|
|
double slope{1.5};
|
|
double reach{60.0};
|
|
std::vector<heightmap::chunk_key> pending; // chunks to make once their model is in
|
|
// of the chunks waiting, those there already with flat ground, made without the model: the model fills their ground
|
|
std::set<heightmap::chunk_key> refill;
|
|
std::set<heightmap::chunk_key> given_up; // chunks the growing gave up, next to terrain not from the model: not asked for again
|
|
std::size_t made{0};
|
|
std::size_t empty{0}; // chunks not made: the model has no data there
|
|
std::size_t foreign{0}; // chunks not made ahead: the terrain beside isn't of the model
|
|
std::optional<double> ahead; // how much the terrain made ahead lies over the model
|
|
std::set<TTrack *> changed; // tracks whose formations are to follow them
|
|
std::set<std::string> gone; // names of the tracks removed, whose formations go with them
|
|
double changed_time{0.0};
|
|
bool restoring{false}; // the history is taken back or forward: the terrain comes back with it
|
|
std::size_t shaped{0};
|
|
std::string status;
|
|
std::string error;
|
|
bool common{true}; // the tracks nearly parallel under 5.1 m apart lie on one grade line
|
|
static int constexpr grade_line_own{-1};
|
|
static int constexpr grade_line_steep{-2};
|
|
static int constexpr grade_line_off{-3}; // taken off a grade line by hand, stays on its own when the lines are worked out again
|
|
static int constexpr grade_line_off_number{-10}; // this and below: taken off the grade line of this number less this
|
|
std::map<std::string, int> grade_lines; // of each track the number of the grade line it shares, or one of those above
|
|
std::set<std::string> grade_lines_hand; // the tracks put on their grade line by hand: they stay on it when the lines are worked out again
|
|
bool grade_lines_loaded{false};
|
|
bool grade_lines_dirty{false}; // the edits of the tracks carried their lines on: stored once, with the next frame
|
|
std::unordered_map<TTrack const *, std::string> grade_line_keys; // of the tracks changed, the key each had last, to carry its line on to the next
|
|
std::vector<std::pair<std::string, segment_data>> grade_line_replaced; // the first paths of the tracks of a line changed since the last frame: a new track on one takes its line
|
|
std::unordered_set<TTrack const *> on_hump; // the tracks of the humps fitted to the model: no grade line shared levels them
|
|
std::size_t grade_lines_changes{0};
|
|
std::string explain; // a track whose run the next sharing of the grade lines tells of in the log, for a selftest
|
|
struct surface_place
|
|
{
|
|
TTrack const *track;
|
|
int path;
|
|
double share;
|
|
int surface;
|
|
};
|
|
std::vector<surface_place> surface_places; // what lies on the surface of each group on common timbers
|
|
bool camera_check{false}; // chunks were made: the 3d camera may be under them now
|
|
std::vector<std::string> buried; // the tracks just laid, when a part of them is hidden in the ground
|
|
double buried_length{0.0}; // m of them hidden
|
|
// the tracks of a scenery built at any height put onto the terrain model: the model offset to meet the scenery, then the grade
|
|
// line of each line of tracks fitted to the model, the longest first, then the terrain made along them
|
|
enum class automatic
|
|
{
|
|
idle,
|
|
fetching, // the model under the tracks
|
|
fitting // the grade lines, a few each frame
|
|
};
|
|
automatic stage{automatic::idle};
|
|
std::vector<nmt_place> probes; // places of the tracks whose model is waited for
|
|
std::size_t probes_kept{0}; // the last of the probes, on tracks fitted already: they tell the offset the model had
|
|
std::size_t tracks{0}; // rail tracks when the grade lines began, and the paths the grade lines split off since
|
|
std::size_t split{0};
|
|
std::vector<TTrack *> left; // tracks whose grade line is still to be fitted
|
|
std::vector<TTrack *> done; // tracks of the lines fitted already: the lines fitted later end on them and don't change them
|
|
// the rail tops of the lines fitted already, in squares of the plan: the tracks of a station lie in one plane, a line laid
|
|
// near them takes their height for its ground too, the more closely the nearer it is, and a line crossing one of them
|
|
// on its level its height on the crossing
|
|
struct laid_point
|
|
{
|
|
glm::dvec3 position{0.0};
|
|
glm::dvec2 direction{0.0, 1.0};
|
|
double grade{0.0};
|
|
double was{0.0}; // the height before the line was fitted
|
|
double rails{0.0}; // the height of the rails of the track
|
|
TTrack const *track{nullptr};
|
|
};
|
|
std::map<std::pair<int, int>, std::vector<laid_point>> laid;
|
|
// the points of all the paths as they were laid, for the crossings
|
|
std::map<std::pair<int, int>, std::vector<laid_point>> paths;
|
|
// ends which meet in the plan unlinked, laid apart in height, that the joining of the ends couldn't join as neither of
|
|
// them can be changed alone, as of two switches: each with the other one, which a line ending there takes over
|
|
std::map<std::tuple<TTrack const *, int, bool>, std::tuple<TTrack *, int, bool>> loose;
|
|
// the points of the lines over a bridge or a viaduct, the model falling away under them: no formation is laid there
|
|
std::map<std::pair<int, int>, std::vector<glm::dvec3>> bridged;
|
|
// a turntable lies level in its pit, which the model has, at the height of the tracks running up to it: it isn't put onto
|
|
// the model, and a line ending on its rim ends there level at its height, turning to the model away from it
|
|
struct turntable
|
|
{
|
|
TTrack *table{nullptr};
|
|
glm::dvec3 centre{0.0}; // at the height of its rails
|
|
double rim{0.0}; // m from the centre
|
|
std::vector<std::tuple<TTrack *, int, bool>> ends; // of the paths running up to it: track, path, at its end
|
|
};
|
|
std::vector<turntable> turntables;
|
|
std::size_t levelled{0}; // turntables moved to the height of their tracks
|
|
std::size_t lines{0}; // grade lines fitted and applied
|
|
std::size_t refused{0}; // grade lines the checks didn't let apply
|
|
std::size_t departures{0}; // grade lines parting from the terrain model by much
|
|
// what the last putting of the tracks onto the terrain found, listed in the panel to be looked at: a line the checks
|
|
// refused, a line parting from the model by much, a path which didn't take its line
|
|
struct finding
|
|
{
|
|
enum class kind
|
|
{
|
|
refused,
|
|
off,
|
|
parted
|
|
};
|
|
kind what{kind::refused};
|
|
TTrack *from{nullptr}; // the ends of the line, for its profile
|
|
TTrack *to{nullptr};
|
|
double length{0.0};
|
|
glm::dvec3 where{0.0}; // the place to look at
|
|
std::string text;
|
|
double size{0.0}; // m the line or the path is off by: of one kind the worst told first
|
|
};
|
|
std::vector<finding> findings;
|
|
bool result{false}; // the putting onto the terrain ended: what it did is told in the panel until the next one
|
|
bool run{false}; // the tracks are being put onto the terrain, the chunks after the grade lines too: the steps told
|
|
std::size_t fetch_most{0}; // the most squares of the model waited for since the loading began, for its progress
|
|
// the terrain made under the tracks as they are: the model drawn to them by the difference found at the places along them,
|
|
// fading out away from them into the offset of the whole scenery
|
|
bool under{false};
|
|
std::vector<glm::dvec3> anchors; // x, z of a place of the tracks, the formation there less the model
|
|
std::map<std::pair<int, int>, std::vector<std::size_t>> anchor_cells; // the anchors in squares of the plan
|
|
bool offered{false}; // the terrain was offered to the scenery begun without it
|
|
bool prompt{false}; // the line of the offer is shown in the panel of the laying
|
|
bool offer_loading{false}; // and the terrain of the offer is being loaded
|
|
bool moving{false}; // the place being picked again
|
|
char place[96]{}; // typed: degrees or PUWG 1992
|
|
int shown{-1}; // the frame the terrain panel showed how far the work got
|
|
};
|
|
editor_nmt m_nmt;
|
|
nmt_state m_nmt_state;
|
|
editor_map m_nmt_map;
|
|
std::vector<nmt_place> nmt_track_places(double const Step) const override;
|
|
void nmt_locate() override;
|
|
void nmt_fit();
|
|
void nmt_finish_fit();
|
|
// the terrain under the tracks, the tracks left as they are: the model drawn to each of them, its relief kept
|
|
void nmt_under_start();
|
|
void nmt_under_anchors();
|
|
// added to the height of the model at the place: the offset of the scenery, drawn to the tracks near them
|
|
double nmt_offset_at(double const X, double const Z) const;
|
|
std::vector<heightmap::chunk_key> nmt_keys_around() const;
|
|
std::vector<heightmap::chunk_key> nmt_keys_along_tracks() const;
|
|
// only the chunks there are none of yet: a chunk there is, made from the model or by hand, edited or not, is never made anew.
|
|
// Reshape: the formations of the tracks laid anew as the tracks lie now, as when they moved
|
|
void nmt_make(std::vector<heightmap::chunk_key> const &Keys, bool const Reshape = false);
|
|
enum class nmt_chunk
|
|
{
|
|
waiting, // for its squares of the model
|
|
made,
|
|
empty // the model has no data there
|
|
};
|
|
// Offset: the heights of the model go up or down by it in the whole chunk, in place of the offsets of the fit
|
|
nmt_chunk add_chunk_from_nmt(heightmap::chunk_key const &Key, std::optional<double> const Offset = std::nullopt);
|
|
// a chunk there with its ground level all over, as made where there was no ground and no model: none of the shape of the land
|
|
bool nmt_flat_chunk(heightmap::chunk_key const &Key) const;
|
|
// how much the terrain lies over the model at the points: none where there's too little terrain at them, nor where it
|
|
// doesn't follow the model (Foreign), as one made by hand
|
|
std::optional<double> nmt_terrain_offset(std::vector<glm::dvec2> const &Points, bool &Foreign) const;
|
|
// the same along the edges the chunk shares with the chunks beside it in memory
|
|
std::optional<double> nmt_seam_offset(heightmap::chunk_key const &Key, bool &Foreign) const;
|
|
// the offset a chunk made from the model where there's no terrain gets: of the terrain made from the model beside it, empty
|
|
// (the offset of the scenery) beside terrain made by hand or none
|
|
std::optional<double> nmt_chunk_offset(heightmap::chunk_key const &Key) const;
|
|
// the terrain beside the formation of the track is the one made from the model; Waiting: its squares of the model aren't in yet
|
|
// the tracks changed by hand are told to the terrain: their formations laid anew, of the tracks removed taken away, a
|
|
// track laid onto the terrain of the model given its own, once the mouse lets go; in the step of the history of the change
|
|
void nmt_track_changed(std::vector<TTrack *> const &Tracks);
|
|
void nmt_track_gone(TTrack const &Track);
|
|
void nmt_follow_tracks();
|
|
// the height the ground will have where the terrain is made ahead of the track laid and isn't there yet
|
|
bool nmt_ahead(double const X, double const Z, double &Height) const;
|
|
// the same, else the height of the model with the offset of the scenery where its square is in: the ground where there's no
|
|
// terrain made yet, as under the base map of the top view
|
|
bool nmt_ground(double const X, double const Z, double &Height) const;
|
|
// the squares of the model under the rectangle are in, none of them waiting to be asked for again
|
|
bool nmt_ready(glm::dvec2 const &Min, glm::dvec2 const &Max);
|
|
// Only: the paths of these tracks are shaped anew, the modifiers of those removed taken away; null: all of them. the number
|
|
// of the modifiers laid
|
|
std::size_t nmt_shape_tracks(std::vector<TTrack *> const *Only = nullptr);
|
|
void nmt_update();
|
|
// the terrain of the scenery made from the model around the camera within the download area, a chunk at a time while nothing
|
|
// else is done with the model and the frames are quick: edited chunks wait in memory to be saved, so not the whole area at once
|
|
void nmt_area_terrain();
|
|
void nmt_grow();
|
|
void render_nmt_ui();
|
|
// where the scenery lies: the map to click on, the place typed; true once it's placed
|
|
bool render_nmt_place(bool const Moving, bool const Button);
|
|
// the work under way: what's left of it and the button to stop it; Compact: one line, for the 3d view
|
|
void render_nmt_progress(bool const Compact);
|
|
// the formations of the tracks led into the terrain, down or up to it, or taken out of it; one step of the history each
|
|
void nmt_pull_terrain(std::vector<TTrack *> const &Tracks);
|
|
void nmt_restore_terrain(std::vector<TTrack *> const &Tracks);
|
|
// the terrain of the selected tracks in the panel of the tracks
|
|
void render_track_terrain(std::vector<TTrack *> const &Tracks);
|
|
// all the tracks of the scenery onto the terrain model, or it under them: step 2 of the terrain model (Terrain_panel), and in
|
|
// the panel of the tracks
|
|
void render_nmt_all_tracks(bool const Terrain_panel);
|
|
// what the last putting of the tracks onto the terrain did, and the places it found to be looked at, each to be shown
|
|
void render_nmt_result();
|
|
// a line from From to To being put onto the terrain kept to be looked at: the place of it to show and what's wrong there
|
|
void nmt_note(nmt_state::finding::kind const What, TTrack *From, TTrack *To, double const Length, glm::dvec3 const &Where, std::string Text, double const Size = 0.0);
|
|
// the place found shown in the 3d view with the track there selected; Profile: the profile of its line opened too
|
|
void nmt_show(nmt_state::finding const &Finding, bool const Profile);
|
|
// the chunks waiting for the terrain model and the tiles of the imagery asked for outlined where they will be, so it's seen
|
|
// what's on its way
|
|
void draw_nmt_pending() const;
|
|
// the download area: a polygon drawn on the map, the boundary of what the orthophoto and the terrain model download in the
|
|
// background, none of them asking for anything outside it (application/editormodenmt.cpp)
|
|
void area_start();
|
|
// Keep: the area drawn taken, else the one before stays
|
|
void area_finish(bool const Keep);
|
|
// a press of the left button while drawing: a point added, or the one under the cursor taken to drag, Shift: removed
|
|
void area_click(bool const Shift);
|
|
void area_update();
|
|
// a point of the area (x, z) where it's drawn: over the map of the top view, on the ground in the 3d view
|
|
glm::dvec3 area_point(glm::dvec2 const &Point) const;
|
|
void draw_download_area() const;
|
|
void render_download_area_ui(editor_orthophoto::statistics const &Stats);
|
|
// the download area a square of the side, km, around the camera
|
|
void area_square(int const Side);
|
|
// the chunk of the terrain (x, z) touches the area, or there's none
|
|
bool in_download_area(glm::dvec2 const &Low, glm::dvec2 const &High) const;
|
|
// over the 3d view while the terrain panel isn't seen
|
|
void render_nmt_banner();
|
|
// the grade lines fitted, the tracks nearly parallel under 5.1 m apart brought onto one, a track going away from them fading back onto its own
|
|
void nmt_share_grades();
|
|
void grade_lines_load();
|
|
void grade_lines_store();
|
|
bool on_route_grade_line(TTrack const &Track);
|
|
std::vector<TTrack *> const &grade_line_beside();
|
|
std::size_t grade_line_follow(std::vector<editor_track::route_sample> const &Before);
|
|
void grade_line_take_off(bool const Off);
|
|
// the grade line the route shares, by most of its paths; -1 when it shares none
|
|
int route_grade_line();
|
|
// the plain tracks from switch to switch the track is one of, a switch by itself; Alone: the track only
|
|
static std::vector<TTrack *> grade_line_run(TTrack &Track, bool const Alone);
|
|
// the run of the track clicked onto the grade line of the route by hand, or off it if it's on it; a route sharing none makes one with it
|
|
void grade_line_pick(TTrack &Track, bool const Alone);
|
|
// all the tracks of the grade line, wherever they are, for the view while they're picked
|
|
std::vector<TTrack const *> const &grade_line_members(int const Number);
|
|
void draw_grade_line_pick();
|
|
// a piece split off a track lies on the grade line the track does
|
|
void grade_line_split(TTrack const &Original, TTrack const &Created);
|
|
// a track changed keeps its grade line under the key it has after it; a new one between two tracks of a line, a switch put into one, lies on it
|
|
void grade_line_captured(TTrack const &Track);
|
|
void grade_lines_committed(std::vector<TTrack *> const &Tracks);
|
|
void grade_line_renamed(TTrack const &Track, std::string const &Old);
|
|
void render_profile_grade_line();
|
|
// the tracks laid since the step of the history hidden in the ground, told over the 3d view with the way to fit the ground to them
|
|
void nmt_check_buried(std::size_t const From);
|
|
void render_nmt_buried();
|
|
// what to do first, in the middle of the view of a scenery with no tracks nor terrain
|
|
void render_empty_scenery_hint();
|
|
// the camera outside the download area: no photos there, told at the bottom of the view with the way to the area
|
|
void render_outside_area_hint();
|
|
// the 3d camera under the ground, as after the view from above or the terrain model made under it, lifted over it
|
|
void camera_above_ground();
|
|
bool nmt_busy() const;
|
|
// the terrain made so far stays, what's waiting is dropped, the grade lines not fitted yet are left
|
|
void nmt_stop();
|
|
// a scenery begun from nothing, with no tracks nor terrain, has the terrain loaded in the background as the first track is laid,
|
|
// where it lies on the map, with no question in the way: a line of the panel of the laying tells it, with the button to go without
|
|
void nmt_offer();
|
|
void nmt_offer_start();
|
|
// the place picked in the terrain window: the terrain model and the orthophoto take it
|
|
void nmt_place_scenery(glm::dvec2 const &Point);
|
|
void nmt_accept_offer();
|
|
// the answer without terrain: the tracks lie on the plane, nothing of the terrain model is loaded by itself any more, under the
|
|
// tracks laid nor around the camera, in the scenery open; the settings stay as they are for the other sceneries
|
|
void nmt_decline_offer();
|
|
// the terrain of the download area made around the camera by itself: as the settings have it, unless declined for this scenery
|
|
bool nmt_area() const;
|
|
// the whole scenery: tracks, includes and models, moved up or down as one undo step
|
|
std::size_t nmt_join_ends();
|
|
// the turntables as they lie, each with the ends of the tracks running up to it on its rim
|
|
std::vector<nmt_state::turntable> nmt_turntables() const;
|
|
// each turntable level at the height of the tracks running up to it, its include with it, before the grade lines are fitted:
|
|
// at the height of the ones fitted already, else of the terrain model beside its rim; the number of them moved
|
|
std::size_t nmt_level_turntables();
|
|
// Unfitted: only the tracks whose grade line isn't fitted yet, the scenery left at its height
|
|
void nmt_auto_start(bool const Unfitted = false);
|
|
void nmt_auto_step();
|
|
// the grade line of the line of tracks through the track fitted to the terrain model and applied; false if it couldn't be.
|
|
// The line runs over the tracks not Fitted, the ones fitted stay as they are and the line meets them. Where the model falls
|
|
// away under the line by the abutments the tracks go over on a bridge; Laid: the tracks just laid, the formation fills it and
|
|
// they are cut only where they can't follow the line otherwise
|
|
bool nmt_fit_line(TTrack &Track, std::function<bool(TTrack const *)> const &Fitted, bool const Laid);
|
|
// the tracks laid in one go since the history step From put onto the terrain model as one line, as the tracks go onto the
|
|
// terrain: the track ending at End then the one the laying goes on from
|
|
bool nmt_fit_laid(std::size_t const From, glm::dvec3 const End);
|
|
// the tracks laid one after another on one straight or one arc, cut by the grade lines fitted before, made one again
|
|
void nmt_merge_laid(std::unordered_set<TTrack const *> &Laid);
|
|
// the points of the paths of the track about a metre apart, in squares of the plan
|
|
static void nmt_sample_paths(TTrack const &Track, std::map<std::pair<int, int>, std::vector<nmt_state::laid_point>> &Points);
|
|
// the tool of the terrain the left mouse button works
|
|
enum class terrain_tool
|
|
{
|
|
none, // picks the models, as in the surroundings
|
|
chunks, // adds a chunk, Shift: removes it
|
|
sculpt, // raises the ground, Shift: lowers it
|
|
smooth,
|
|
level, // leads the ground to the target height, Ctrl: picks the target height under the cursor
|
|
paint, // paints the chosen material, Shift: the first material of the palette
|
|
spacing, // selects chunks (Ctrl: adds or takes away one), whose point spacing is then converted
|
|
water, // outlines a body of water
|
|
restore, // takes the touch-ups over the modifiers back
|
|
fill // outlines an area filled with a material
|
|
};
|
|
terrain_tool m_terrain_tool{terrain_tool::none};
|
|
bool terrain_brush() const
|
|
{
|
|
return m_terrain_tool == terrain_tool::sculpt || m_terrain_tool == terrain_tool::smooth || m_terrain_tool == terrain_tool::level || m_terrain_tool == terrain_tool::paint ||
|
|
m_terrain_tool == terrain_tool::restore;
|
|
}
|
|
// the point of the ground of the terrain under the cursor, found along the ray through the cursor, so it's found also over
|
|
// a hole and behind the grass. returns: false if the ray meets no terrain
|
|
bool terrain_cursor(glm::dvec3 &World) const;
|
|
// the point of the ground under the cursor in this frame, for the points put on the ground (outlines, areas, brushes): along the ray
|
|
// through the cursor to the terrain; the depth read back (a frame late, and stopped by the models over the ground) only where
|
|
// there's none. false: nothing under the cursor
|
|
bool cursor_on_ground(glm::dvec3 &World);
|
|
// converts the point spacing of the selected chunks to m_terrain_convert_spacing
|
|
void convert_selected_chunks();
|
|
// the chunks selected with the spacing tool taken out of the terrain, in one step of the history
|
|
void remove_selected_chunks();
|
|
// takes the height of whatever is under the cursor (terrain, track, model) for the target of the level brush. returns: false if there's nothing
|
|
bool pick_terrain_target();
|
|
bool terrain_clicking() const { return m_terrain_tool == terrain_tool::chunks || m_terrain_tool == terrain_tool::spacing || m_terrain_tool == terrain_tool::water || m_terrain_tool == terrain_tool::fill; }
|
|
// fills the outlined area with the material of the chosen palette entry, turned by m_paint_rotation
|
|
void fill_terrain_area();
|
|
// the brush, the hovered chunk and the outlines of water drawn over the viewport
|
|
void draw_terrain_overlay();
|
|
// forgets what's known about the ground, after the terrain changed
|
|
void forget_ground();
|
|
// the ground gathered where the terrain changed in the rectangle (x, z) gathered again when asked for, the rest kept
|
|
void forget_ground_in(glm::dvec2 const &Min, glm::dvec2 const &Max);
|
|
// conversion of the ground of the terrain files of the scenery (terrain directive, .txtf/.btf) to heightmap terrain
|
|
struct ground_conversion
|
|
{
|
|
struct source
|
|
{
|
|
std::string file; // as the terrain directive names it
|
|
std::uint16_t reference{0}; // see scene::terrain_file::reference_of()
|
|
bool text{false}; // read from the text file, rather than the binary one
|
|
bool good{false};
|
|
bool chosen{true};
|
|
std::string message;
|
|
std::size_t first{0}, count{0}; // its triangles
|
|
};
|
|
bool open{false};
|
|
std::vector<source> files;
|
|
std::vector<std::array<glm::dvec3, 3>> triangles;
|
|
std::vector<std::uint16_t> materials; // of the triangles: index of the name
|
|
std::vector<std::string> names; // of the materials
|
|
std::set<std::size_t> chosen; // materials to convert
|
|
std::string status;
|
|
} m_ground_conversion;
|
|
// reads the triangles of the terrain files of the scenery for the conversion
|
|
void load_ground_files();
|
|
// the folder of the textures as a browser, in the window of the node bank while the terrain is edited: the textures and the
|
|
// materials can be dragged onto the fields which take a material
|
|
struct texture_browser
|
|
{
|
|
struct item
|
|
{
|
|
std::string name; // as the materials are named: relative to the folder of the textures, without the extension
|
|
std::string label; // the file, without the folder
|
|
bool material{false}; // there's a .mat file of the name
|
|
};
|
|
std::string folder; // relative to the folder of the textures, empty or with a trailing slash
|
|
std::vector<std::string> folders; // under the current one
|
|
std::vector<item> items;
|
|
bool listed{false};
|
|
char filter[64]{};
|
|
float size{96.f}; // of the images, pixels
|
|
std::string selected;
|
|
struct thumbnail
|
|
{
|
|
int texture{0}; // 0: none
|
|
int material{0}; // the material the texture is the first of, 0: a texture alone
|
|
double shown{0.0}; // when it was last asked for, ImGui time
|
|
};
|
|
std::map<std::string, thumbnail> thumbnails; // texture shown for the item of the name
|
|
bool refresh{false}; // all the images to be let go of and read again
|
|
int loads{0}; // textures read in the frame, a few at most so the browser doesn't stall the editor
|
|
int loadsframe{-1};
|
|
} m_textures;
|
|
void render_texture_browser();
|
|
// texture of the image of the item of the browser, 0 while there's none
|
|
std::uint64_t texture_thumbnail(texture_browser::item const &Item);
|
|
// the textures of the images out of sight for a while taken out of the memory: a picker of thousands of them scrolled
|
|
// through would keep them all, full size, until the memory ran out
|
|
void thumbnails_trim();
|
|
// takes a material dragged from the texture browser onto the item drawn last. returns: true if one was dropped, its name in Name
|
|
static bool material_drop(std::string &Name);
|
|
// the same, for a text field
|
|
static bool material_drop(char *Buffer, std::size_t Size);
|
|
// replaces the chosen triangles of the chosen terrain files with chunks of heightmap terrain of their shape, painted with
|
|
// their materials; the files lose them on save. returns: summary for the user
|
|
std::string convert_ground();
|
|
void render_ground_conversion();
|
|
// handles a click of the chunk, spacing and water tools (Shift: the other way round)
|
|
void handle_terrain_click(bool const Shift);
|
|
// writes the changes to the files of scenery opened for editing (Ctrl+S)
|
|
bool save();
|
|
// places include of specified scenery template at the cursor, in the active layer
|
|
void place_include(std::string const &File, int RotationMode, float FixedRotation);
|
|
// undo and redo of placing or removing an include: brings removed include back, or removes it
|
|
void toggle_include(scene::instance_handle Instance);
|
|
// makes specified include the selected one, 0 clears the selection
|
|
void select_include(scene::instance_handle Instance);
|
|
// writes parameter values of the selected include to its directive, and shows the outcome in the scene
|
|
void apply_include();
|
|
// replaces directive of specified include, and the models shown for it
|
|
void set_include_directive(scene::instance_handle Instance, std::string const &Directive);
|
|
// undo and redo of an include snapshot
|
|
void restore_include(EditorSnapshot &Snapshot);
|
|
// undo and redo of the includes placed, removed or changed together
|
|
void restore_includes(EditorSnapshot &Snapshot);
|
|
// gizmo for the selected include, limited to what the parameters of its template can express
|
|
void render_include_gizmo(glm::mat4 const &View, glm::mat4 const &Projection, glm::dvec3 const &Camerapos);
|
|
// exports the scenery in legacy (text) format, with layers hidden in the editor left out of the picture
|
|
void export_scenery();
|
|
// works the brush of the terrain under the cursor while the left mouse button is held
|
|
void handle_terrain_brush(double Deltatime);
|
|
// the chunk of the terrain (if any) covering the given world point
|
|
editor_terrain *terrain_at(double X, double Z);
|
|
// the chunks of the terrain held in memory
|
|
std::vector<editor_terrain *> active_terrains() const;
|
|
// samples the selected model instance's geometry into the chunks of the terrain it covers, then removes it
|
|
void capture_terrain();
|
|
bool m_terrain_open{false}; // the terrain is the field of work, chosen in the toolbar
|
|
float m_terrain_spacing{2.0f}; // point spacing of the chunks made and of the spacing tool
|
|
float m_terrain_baseheight{0.0f}; // height of chunks made where there's no ground
|
|
int m_terrain_add_count{4}; // chunks along a side added around the camera
|
|
float m_terrain_brush_radius{12.0f};
|
|
float m_terrain_brush_strength{4.0f}; // metres per second while held; for the paint, how fast it covers
|
|
// the level brush
|
|
float m_terrain_target{0.0f}; // height the ground is led to
|
|
int m_terrain_level_mode{0}; // 0: up and down, 1: only raises, 2: only lowers
|
|
bool m_terrain_target_from_stroke{false}; // the target is the height where a stroke starts
|
|
bool m_terrain_stroke{false}; // a stroke of the brush is under way
|
|
bool m_terrain_picking{false}; // the next click picks the target height
|
|
int m_terrain_layer{0}; // entry of the palette painted
|
|
char m_terrain_material[128]{"grass"}; // material added to the palette
|
|
float m_terrain_material_size{0.0f}; // metres its textures repeat at, 0: given by the material
|
|
float m_terrain_layer_size{0.0f}; // repeat of the chosen palette entry, while it's dragged
|
|
bool m_terrain_layer_size_dragged{false};
|
|
float m_terrain_layer_rotation{0.0f}; // angle of the chosen palette entry, while it's dragged
|
|
bool m_terrain_layer_rotation_dragged{false};
|
|
std::vector<glm::dvec3> m_water_points; // outline of a body of water being drawn
|
|
float m_water_level{0.0f};
|
|
bool m_water_level_edited{false}; // the level was given by hand, the points clicked don't change it
|
|
char m_water_material[128]{""};
|
|
int m_water_selected{-1};
|
|
char m_water_selected_material[128]{""}; // material of the chosen water, while it's edited
|
|
int m_water_material_of{-1}; // the water whose material is in the field above
|
|
float m_water_selected_size{0.0f}; // metres its texture repeats at, 0: given by the material
|
|
std::set<heightmap::chunk_key> m_terrain_selection; // chunks chosen with the spacing tool
|
|
float m_terrain_convert_spacing{1.0f}; // point spacing the selected chunks are converted to
|
|
bool m_terrain_convert_paint{true}; // chunks converted to 0.5 m get paint samples every 0.5 m too
|
|
std::vector<glm::dvec3> m_paint_outline; // of the area filled with a material
|
|
float m_paint_feather{0.0f}; // metres the filled material blends in over across the outline, 0: sharp
|
|
float m_paint_rotation{0.0f}; // degrees the textures of the filled material are turned by
|
|
float m_water_selected_level{0.0f}; // level of the chosen water, while it's edited
|
|
bool m_water_level_dragged{false};
|
|
std::string m_terrain_status;
|
|
|
|
// the heightmap terrain, shared with the scenery loader so it shows in every mode
|
|
terrain_streamer &m_streamer{EditorTerrain};
|
|
|
|
// geoportal orthophoto layer drawn under the other viewport overlays
|
|
void render_orthophoto_ui();
|
|
void render_map_menu();
|
|
bool m_newscenery_asked{false};
|
|
void render_new_scenery_popup();
|
|
bool restart_for_new_scenery();
|
|
bool restart_editor(std::string const &Scenery);
|
|
bool m_openscenery_asked{false};
|
|
bool m_opened_at_track{false};
|
|
bool m_turntable_included{false};
|
|
bool turntable_controls(std::vector<std::string> &Rootstatements);
|
|
bool m_nose_included{false};
|
|
bool nose_controls(std::vector<std::string> &Rootstatements);
|
|
void starter_trainset(std::vector<std::string> &Trailing);
|
|
std::optional<std::pair<glm::dvec3, glm::vec3>> m_saved_camera;
|
|
char m_openscenery_search[64]{};
|
|
std::vector<std::string> m_openscenery_list;
|
|
std::string m_openscenery_choice;
|
|
void render_open_scenery_popup();
|
|
// the window of the settings of the orthophoto open, and the frame it was last drawn open in
|
|
bool m_orthophoto_window{false};
|
|
// the user turned the orthophoto on or off, or the scenery keeps it so: the terrain model made, or the area drawn, leaves it as it
|
|
// is then, it turns it on only where nobody chose
|
|
bool m_orthophoto_chosen{false};
|
|
// the user turns the orthophoto on or off: kept with the editor, for the scenery
|
|
void choose_orthophoto(bool const On);
|
|
// the 4K photos by themselves while the view is zoomed in to 15 cm a pixel; the m a pixel of the view, the top view's or of the
|
|
// ground under the camera
|
|
void orthophoto_zoom();
|
|
double view_metres_per_pixel() const;
|
|
// the download area carried along where the camera or the laying comes near its edge, told in the status line
|
|
void area_grow();
|
|
double m_area_grow_time{-100.0};
|
|
bool m_area_grow_limited{false};
|
|
// the tiles of the photo which failed: marked red in the view, counted in the status bar with the button trying them again
|
|
void draw_orthophoto_failures() const;
|
|
// the heights of the ground under the corners of the tiles which failed, outlined on it in the 3D view. A few tiles are asked for
|
|
// each frame, and a tile whose corners were found only again once in a while, so that the outlines don't keep the tiles of the
|
|
// ground in use every frame and their cache growing past its limit
|
|
struct orthophoto_failure_ground
|
|
{
|
|
std::array<double, 4> heights{};
|
|
std::array<bool, 4> found{};
|
|
double asked{-1.0e9};
|
|
};
|
|
void ground_orthophoto_failures(std::vector<std::pair<glm::dvec2, glm::dvec2>> const &Failed) const;
|
|
mutable std::map<std::pair<double, double>, orthophoto_failure_ground> m_orthophoto_failure_ground;
|
|
void render_orthophoto_status();
|
|
// the terrain loaded in the background as the first track of a new scenery is laid, told in a line of the panel of the laying with
|
|
// the button to go without it
|
|
void render_nmt_offer_line();
|
|
int m_orthophoto_frame{-10};
|
|
bool orthophoto_settings_open() const;
|
|
// view menu: the top view, the lanes of the roads, the structure gauge, the environment
|
|
void render_view_menu();
|
|
// View > Camera speed: the speed of the free camera, the Ctrl multiplier, in the top view as fast as it's zoomed; kept in the
|
|
// settings of the editor and handed to the camera
|
|
void render_camera_settings(bool const Window);
|
|
void apply_camera_settings();
|
|
// ~ (Ctrl): the orthophoto of what the camera sees downloaded before the rest, the ones which failed tried again at once
|
|
void orthophoto_hurry();
|
|
// time of day, day of the year, visibility, clouds and air temperature, as the scenery is seen in the editor
|
|
void render_environment_window();
|
|
bool m_environment_open{false};
|
|
int m_environment_shown{0}; // frames since its window was opened, for its place
|
|
// the settings of the orthophoto in a window of their own, opened from the map menu, the terrain tools and the layers window
|
|
void render_orthophoto_window();
|
|
int m_orthophoto_shown{0};
|
|
int m_settings_shown{0};
|
|
int m_shortcuts_shown{0};
|
|
// the terrain of the terrain model made by itself, in the settings of the editor
|
|
void render_terrain_loading();
|
|
// over the 3d view: the tools of the field of work along its left edge, the modes of the gizmo at its top, the axes of the
|
|
// world and the top view in its top right corner
|
|
void render_viewport_overlays();
|
|
// the tools of the field of work, in the order of the toolbar
|
|
void work_area_tools(std::vector<editor_tool_button> &Buttons);
|
|
// the button of the toolbar of the key or the name given clicked, for the self-test; false: none such
|
|
bool press_toolbar(std::string const &Name);
|
|
// the tools of the field of work in the toolbar, as icons with their names
|
|
void render_toolbar_tools();
|
|
// what the row of the toolbar holds, written at its left end: the fields of work, the tools
|
|
static void render_toolbar_caption(char const *Text);
|
|
void render_viewport_gizmo();
|
|
void render_view_axes();
|
|
// the camera looking along an axis of the world (0: x, 1: y, 2: z) from its positive or negative side
|
|
void look_along_axis(int const Axis, bool const Positive);
|
|
// origin of the scenery in PUWG 1992 the scenery file gives in its //$g line, if it does
|
|
bool m_georeference_read{false};
|
|
bool m_georeference{false};
|
|
glm::dvec2 m_georeference_origin{0.0}; // northing, easting
|
|
std::string m_georeference_line;
|
|
// //$g and the origin remembered or the one of //$o were apart, by that many m; //$g taken. 0: they weren't
|
|
double m_georeference_differs{0.0};
|
|
void read_georeference();
|
|
void draw_orthophoto();
|
|
void draw_ortho_compass() const;
|
|
// picks up the stored settings and the origin of the current scenery, and the offset of the terrain model the scenery has
|
|
void load_orthophoto_settings();
|
|
void save_orthophoto_settings();
|
|
// the settings of the terrain model changed, kept with the editor, and the offset of the model with the scenery's
|
|
void keep_nmt_settings();
|
|
editor_orthophoto m_orthophoto;
|
|
// the WMS layers of the user's over the orthophoto, the top one first, as the settings of the editor keep them; their tiles are
|
|
// kept in memory only
|
|
std::vector<std::unique_ptr<editor_orthophoto>> m_wms;
|
|
// a WMS layer being added: the address typed, what its capabilities tell, read on a thread of its own, the layers ticked
|
|
struct wms_adding
|
|
{
|
|
std::array<char, 512> url{};
|
|
std::array<char, 64> filter{};
|
|
// the reading is given up: the editor goes. before the reading, so it outlives the future waiting for the reading to end
|
|
std::atomic<bool> closing{false};
|
|
std::future<editor_orthophoto::service_info> reading;
|
|
std::optional<editor_orthophoto::service_info> info;
|
|
std::string service; // the address the capabilities were read of
|
|
std::vector<char> ticked;
|
|
} m_wms_adding;
|
|
// the orthophoto and the WMS layers of the user's at the bottom of the layers window, with their settings
|
|
void render_base_layers();
|
|
void render_wms_adding();
|
|
// the WMS layers as the settings have them, laid out by the origin and on the ground of the orthophoto, around the camera
|
|
void update_wms_layers();
|
|
// the ground the imagery is fitted onto, the same for the orthophoto and the WMS layers
|
|
void ground_sources(editor_orthophoto &Layer);
|
|
std::size_t m_ortho_resident{0}; // chunks of the terrain in memory, as the imagery last heard of them
|
|
std::size_t m_ortho_waiting{0}; // squares of the terrain model asked for and not in yet, the same
|
|
std::string m_orthophoto_scenery; // scenery whose origin is loaded
|
|
std::string m_orthophoto_mark;
|
|
std::vector<std::string> m_orthophoto_area_mark; // the lines of the download area as the scenery keeps them
|
|
// the download area being drawn on the map: its points in the world (x, z), the one dragged
|
|
struct area_drawing
|
|
{
|
|
bool active{false};
|
|
std::vector<glm::dvec2> points;
|
|
int dragged{-1};
|
|
} m_area_drawing;
|
|
std::vector<glm::dvec2> m_nmt_prefetched; // the download area the terrain model was given
|
|
bool m_area_paused{false}; // the download of the area held by the button; out of the editor it's held anyway
|
|
// the terrain made around the camera within the area: the chunks there, nearest first, the next one looked at, when the next one
|
|
// may be made, those made (or left: the model has no data there, or the chunk is outside the region) since the scenery opened
|
|
struct area_terrain
|
|
{
|
|
std::vector<heightmap::chunk_key> keys;
|
|
std::size_t next{0};
|
|
heightmap::chunk_key centre{0, 0};
|
|
bool listed{false};
|
|
double resume{0.0};
|
|
std::size_t made{0};
|
|
std::size_t square_made{0}; // of them, in the square around the camera now
|
|
bool refit{false}; // chunks made since the photos were last laid onto the ground
|
|
double waiting{-1.0}; // since when the next chunk waits for its model; -1: it doesn't
|
|
std::string held{"-"}; // what held it last, as logged; empty: nothing
|
|
double took{0.0}; // s the chunks of the square around the camera took, all and the longest
|
|
double took_most{0.0};
|
|
std::set<heightmap::chunk_key> empty;
|
|
std::optional<bool> run_only; // the selftest turned it on or off for its run, the setting left as it is
|
|
} m_area_terrain;
|
|
int m_area_square{0}; // km, the side of the square around the camera waiting for its yes in place of the area there is
|
|
bool m_outside_area_closed{false}; // the note of the camera outside the area closed; open again once it's back inside
|
|
int m_empty_hint_frame{-10}; // the frame the panel of the empty scenery was last drawn in
|
|
int m_empty_card_frame{-10}; // the frame the inspector last said the scenery has no tracks yet
|
|
glm::dvec2 m_orthophoto_origin_edit{0.0}; // origin being typed in (northing, easting); applied when editing ends
|
|
|
|
// hierarchy management
|
|
void add_to_hierarchy(scene::basic_node *node);
|
|
void remove_from_hierarchy(scene::basic_node *node);
|
|
void erase_model(TAnimModel *model);
|
|
scene::basic_node* find_in_hierarchy(const std::string &uuid_str);
|
|
scene::basic_node* find_node_by_any(scene::basic_node *node_ptr, const std::string &uuid_str, const std::string &name);
|
|
|
|
// clear history/redo pointers that reference the given node (prevent dangling pointers)
|
|
void nullify_history_pointers(scene::basic_node *node);
|
|
void render_change_history();
|
|
void render_settings();
|
|
glm::dvec3 insert_point(std::string &Notice);
|
|
void render_placement_distance(bool const Fields);
|
|
|
|
// area fill: scatters models from a package over a polygon outlined in the viewport
|
|
void render_area_fill();
|
|
void draw_area_fill_outline() const;
|
|
void add_area_fill_point();
|
|
void run_area_fill();
|
|
void undo_last_area_fill();
|
|
std::vector<glm::dvec3> m_fill_points; // outline vertices (world space) in click order
|
|
std::vector<TAnimModel *> m_fill_last; // instances created by the most recent fill, for "Undo last fill"
|
|
std::vector<std::string> m_fill_custom; // user-assembled package of node templates
|
|
int m_fill_custom_idx{-1};
|
|
model_set_ref m_fill_source; // manual = m_fill_custom, otherwise a user set or node bank group
|
|
float m_fill_density{200.0f}; // objects per hectare
|
|
float m_fill_min_spacing{2.0f}; // minimal distance between placed objects (m)
|
|
bool m_fill_random_rotation{true}; // random yaw; otherwise the Functions panel rotation settings apply
|
|
float m_fill_scale_min{1.0f};
|
|
float m_fill_scale_max{1.0f};
|
|
bool m_fill_models_as_ground{true}; // large model instances (terrain tiles) count as ground
|
|
std::string m_fill_status; // result of the last fill, shown in the panel
|
|
|
|
// array: copies of the selected model set out in a row, after the array modifier of Blender
|
|
struct array_settings
|
|
{
|
|
int fit{0}; // 0: fixed count, 1: as many as the length takes
|
|
int count{2}; // the model itself included
|
|
float length{10.0f}; // m
|
|
bool relative{true};
|
|
glm::vec3 relative_offset{1.0f, 0.0f, 0.0f}; // of the size of the model, along its axes
|
|
bool constant{false};
|
|
glm::vec3 constant_offset{1.0f, 0.0f, 0.0f}; // m, along the axes of the model
|
|
float turn{0.0f}; // degrees around the vertical axis, each copy against the one before it
|
|
bool ground{false}; // the copies are put as high over the ground as the model is
|
|
bool operator==(array_settings const &) const = default;
|
|
};
|
|
struct array_tool
|
|
{
|
|
static constexpr int limit = 1000; // models in an array, so a slip of the finger doesn't freeze the editor
|
|
static constexpr double minimal_step = 0.001; // m, copies any closer would sit in one another
|
|
array_settings settings;
|
|
// the array made last, which follows the settings until something else is selected or changed
|
|
TAnimModel *base{nullptr}; // model it was made of, nullptr if there's none
|
|
std::size_t step{0}; // size of the undo history with the array at its top
|
|
array_settings applied; // what the copies were set out with
|
|
glm::dvec3 location{0.0}; // of the model then
|
|
glm::vec3 angles{0.0f};
|
|
glm::vec3 scale{1.0f};
|
|
// size of the model asked about last
|
|
TModel3d const *sized{nullptr};
|
|
glm::vec3 size{0.0f};
|
|
std::string status; // outcome of the last operation, shown in the panel
|
|
};
|
|
array_tool m_array;
|
|
void render_array();
|
|
// size of the model of specified instance along its axes, the scale of the instance left out
|
|
glm::vec3 array_size(TAnimModel const &Base);
|
|
// offset of each copy from the one before it, along the axes of the model
|
|
glm::dvec3 array_offset(TAnimModel const &Base);
|
|
// number of the models in the array, the one it's made of included. Step: length of the offset
|
|
int array_count(double const Step) const;
|
|
// location and angles of each copy in turn
|
|
std::vector<std::pair<glm::dvec3, glm::vec3>> array_placements(TAnimModel &Base);
|
|
// true while the array made last follows the settings
|
|
bool array_live() const;
|
|
void make_array();
|
|
// brings the copies of the array made last to what the settings ask for
|
|
void shape_array();
|
|
void update_array();
|
|
void restore_array_snapshot(EditorSnapshot Snapshot, std::vector<EditorSnapshot> &Opposite, bool const Undo);
|
|
|
|
// ImGuizmo-based transform gizmo for the selected node
|
|
enum class gizmo_operation { translate, rotate, scale };
|
|
void render_gizmo();
|
|
// gizmo settings, drawn in the toolset window
|
|
void render_gizmo_options();
|
|
// how the top view draws the tracks: as a combo with the colour of the rails, or as items of a menu
|
|
void render_top_tracks_choice(bool const Combo);
|
|
// the tools of the field of work in the toolbar under the menu
|
|
void render_toolbar();
|
|
// an edit mode of the node bank as the field of work, from the toolbar or its key (1-5)
|
|
void choose_edit_mode(nodebank_panel::edit_mode const Mode);
|
|
// fields of work of the editor, in the row above the toolbar: the models around, the tracks, the roads, the terrain
|
|
enum class work_area
|
|
{
|
|
surroundings,
|
|
tracks,
|
|
roads,
|
|
terrain
|
|
};
|
|
work_area current_work_area() const;
|
|
void choose_work_area(work_area const Area);
|
|
void render_workspaces();
|
|
bool m_gizmo_enabled{true}; // master switch for the in-viewport gizmo
|
|
bool m_track_gizmo_on{false}; // the gizmo in the tracks: off until Q, W or E, so a track isn't moved by chance
|
|
bool gizmo_shown() const; // the switch of the field of work in use
|
|
bool m_gizmo_using{false}; // tracks an ongoing drag, so a single undo snapshot is taken per drag
|
|
bool m_gizmo_local{false}; // manipulate in the object's local space instead of world space
|
|
gizmo_operation m_gizmo_op{gizmo_operation::translate}; // current transform mode (translate/rotate/scale)
|
|
float m_gizmo_snap{1.0f}; // translation snap step (metres) applied while Ctrl is held
|
|
|
|
TTrack *selected_track() const override;
|
|
bool track_editing() const override;
|
|
std::size_t history_revision() const override;
|
|
glm::dvec3 camera_position() const override;
|
|
track_hover const &hovered_track() const override;
|
|
std::vector<TTrack *> const &track_set() const override;
|
|
editor_track_tab current_track_tab() const override;
|
|
void render_path_ui();
|
|
// the cant at an end of a path [mm] from its roll [deg] and back, as the inspector shows and takes it: over 1500 mm between the
|
|
// rail axes
|
|
static float cant_of_roll(float const Roll);
|
|
static float roll_of_cant(float const Cant);
|
|
// the cant of the track changed goes on into the tracks joined at its ends, as with the gizmo and the joints tool: the joints would
|
|
// step otherwise. The track, whose state before the change is Before, and its neighbours go into one undo step
|
|
void track_cant_commit(TTrack &Track, editor_track::state const &Before);
|
|
void draw_track_overlay() const;
|
|
editor_track::point_ref track_handle_hit() const;
|
|
void select_track(scene::basic_node *Node);
|
|
void render_track_gizmo();
|
|
void commit_track_drag(bool const Force);
|
|
void cancel_track_tools();
|
|
void push_track_snapshot(std::vector<std::pair<TTrack *, editor_track::state>> States, std::vector<TTrack *> Created = {}, std::vector<TTrack *> Removed = {}) override;
|
|
void push_kilometrage_snapshot() override;
|
|
void set_current_node(scene::basic_node *Node) override;
|
|
alignment::limits const &route_norms() const override;
|
|
void clear_track_point() override;
|
|
editor_nmt &terrain_model() override;
|
|
double terrain_model_offset() const override;
|
|
bool terrain_model_fitted() const override;
|
|
// false, with the reason, when one of the paths can't be changed, its file not taking the changes back
|
|
static bool tracks_editable(std::vector<TTrack *> const &Tracks, std::string &Reason);
|
|
void trim_history();
|
|
// the serial of the step on top of the history, 0 with none
|
|
std::uint64_t history_top() const;
|
|
void restore_track_snapshot(EditorSnapshot const &Snapshot, std::vector<EditorSnapshot> &Opposite, bool const Undo);
|
|
// changes of the kept alignments and switches go into the last step of the history, made just before them
|
|
void records_to_history();
|
|
// the paths a drag of the gizmo takes, to tell after it what became of the kept alignments and switches
|
|
struct record_watch
|
|
{
|
|
bool active{false};
|
|
std::vector<TTrack *> moving;
|
|
std::vector<std::pair<glm::dvec3, glm::dvec3>> before; // ends of the first path of each moving track
|
|
std::map<int, std::vector<TTrack *>> on; // the kept alignments and the moving paths on them
|
|
std::set<int> whole; // the kept alignments all of whose paths move
|
|
} m_record_watch;
|
|
void records_watch_begin();
|
|
void records_watch_end();
|
|
editor_track::point_ref m_track_point;
|
|
std::vector<TTrack *> m_track_drag;
|
|
std::vector<std::pair<TTrack *, editor_track::point_ref>> m_track_drag_points;
|
|
std::vector<editor_track::joint> m_track_joints; // of the neighbours, following the whole track dragged
|
|
editor_track::snap_target m_track_snap;
|
|
glm::dvec3 m_track_pivot{0.0};
|
|
glm::mat4 m_track_gizmo{1.0f};
|
|
bool m_track_gizmo_using{false};
|
|
struct track_gizmo_drag
|
|
{
|
|
gizmo_operation operation{gizmo_operation::translate};
|
|
bool control{false};
|
|
double angle{0.0};
|
|
int path{-1};
|
|
bool atend{true};
|
|
std::size_t pieces{1};
|
|
std::vector<segment_data> paths;
|
|
editor_track::point_ref point;
|
|
glm::dvec3 origin{0.0};
|
|
glm::dvec3 axis{0.0};
|
|
double grabbed{0.0};
|
|
double length{0.0};
|
|
double stretch{0.0};
|
|
std::vector<std::pair<TTrack *, editor_track::point_ref>> partners;
|
|
glm::dvec3 fixed{0.0};
|
|
std::vector<std::pair<TTrack *, std::vector<int>>> held;
|
|
std::vector<TTrack *> extra;
|
|
int ring{-1};
|
|
glm::dmat3 basis{1.0};
|
|
glm::dvec3 pivot{0.0};
|
|
double grade{0.0};
|
|
double roll{0.0};
|
|
double roll0{0.0};
|
|
double pivot_chainage{0.0};
|
|
std::vector<double> chainages;
|
|
std::vector<double> lengths;
|
|
struct switch_joint
|
|
{
|
|
TTrack *track{nullptr};
|
|
editor_track::point_ref own;
|
|
editor_track::point_ref theirs;
|
|
glm::dvec3 point{0.0};
|
|
glm::dvec3 tangent{0.0};
|
|
double roll{0.0};
|
|
bool moved{false};
|
|
std::vector<std::pair<TTrack *, std::vector<segment_data>>> cluster;
|
|
std::vector<std::pair<TTrack *, std::vector<editor_track::joint>>> joints;
|
|
};
|
|
std::vector<switch_joint> switches;
|
|
};
|
|
track_gizmo_drag m_track_gizmo_drag;
|
|
gizmo_operation track_gizmo_operation(TTrack const &Track, bool const Pointmode) const;
|
|
glm::mat4 track_gizmo_frame(TTrack const &Track, bool const Pointmode, gizmo_operation const Operation) const;
|
|
void track_gizmo_hold();
|
|
void track_gizmo_settle();
|
|
void track_gizmo_stretch(TTrack &Track, double const Length);
|
|
void track_gizmo_control(TTrack &Track, glm::dvec3 Control);
|
|
void track_gizmo_point(TTrack &Track, glm::dvec3 const &Position);
|
|
void track_gizmo_switches(TTrack &Track);
|
|
void track_gizmo_conform(TTrack &Track) const;
|
|
bool track_gizmo_clustered(TTrack const *Track) const;
|
|
void track_gizmo_spill(TTrack &Track, std::size_t const Pieces);
|
|
void track_gizmo_carry(track_gizmo_drag::switch_joint &Link, glm::dvec3 const &Point, glm::dvec3 const &From, glm::dvec3 const &To, double const Grade);
|
|
void track_gizmo_roll_switch(track_gizmo_drag::switch_joint const &Link, double const Roll);
|
|
void track_gizmo_take_joints(TTrack &Track);
|
|
void track_gizmo_take_points(TTrack &Track);
|
|
void track_gizmo_take_partners(TTrack &Track);
|
|
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);
|
|
void track_gizmo_turn_direction(TTrack &Track, double const Angle);
|
|
void track_gizmo_turn_grade(TTrack &Track, double const Angle);
|
|
void track_gizmo_turn_cant(TTrack &Track, double const Angle);
|
|
void track_gizmo_turn(TTrack &Track, int const Axis, double const Angle);
|
|
void track_gizmo_rotated(TTrack &Track);
|
|
void track_gizmo_scaled(TTrack &Track);
|
|
void track_gizmo_moved_point(TTrack &Track, glm::dvec3 const &Position);
|
|
void track_gizmo_length(TTrack &Track, double Length);
|
|
void track_gizmo_end(TTrack &Track);
|
|
bool m_track_dirty{false};
|
|
bool m_track_drag_on_the_way{false}; // committed, but not as the end of the drag
|
|
std::chrono::steady_clock::time_point m_track_last_commit;
|
|
editor_track::state m_track_field_before;
|
|
// the event to add to the path, typed
|
|
TTrack const *m_track_events_for{nullptr};
|
|
std::array<char, 128> m_track_event{};
|
|
int m_track_event_list{0};
|
|
std::string m_track_events_missing;
|
|
void render_path_events(TTrack &Track);
|
|
std::string m_track_mode_notice;
|
|
struct route_design
|
|
{
|
|
TTrack *from{nullptr};
|
|
TTrack *to{nullptr};
|
|
editor_track::chain chain;
|
|
std::string error;
|
|
std::string status;
|
|
alignment::design design;
|
|
alignment::result result;
|
|
int vertex{-1};
|
|
int grip{-1};
|
|
bool single{true}; // one curve between its straights, instead of the whole line
|
|
bool relaying{false}; // the crossovers of the line were taken out, they go back once it's laid
|
|
// crossovers taken out with a line which didn't fit it laid again, tried again as the other lines are laid
|
|
struct crossover_out
|
|
{
|
|
int shape{-1};
|
|
glm::dvec3 press{0.0}, release{0.0};
|
|
std::string name;
|
|
std::vector<std::string> names; // of the switches at the press and at the release
|
|
};
|
|
std::vector<crossover_out> crossovers_out;
|
|
double origin{0.0}; // km of the start, m
|
|
int designed{0}; // vertices whose parameters came from the alignment kept in the scenery
|
|
int departed{-1}; // alignment kept in the scenery near the fragment, which its paths no longer follow
|
|
double departure{0.0};
|
|
// the band of the curvature in the panel: the element under the mouse, the point of it, and what's dragged in it
|
|
struct curvature_band
|
|
{
|
|
int hot{-1};
|
|
double at{-1.0};
|
|
int vertex{-1};
|
|
int part{0}; // 1 the radius, 2 the transition in, 3 the transition out, 4 the transition between two arcs of a compound curve
|
|
int arc{0}; // the arc of a compound curve the radius is of, 0 the first; of a transition between arcs the one after it
|
|
double value{0.0};
|
|
ImVec2 press{0.0f, 0.0f};
|
|
float metres{1.0f}; // pixels of a metre and of a unit of the curvature, kept as the drag goes
|
|
float curvature{1.0f};
|
|
} band;
|
|
// the part of a curve whose field the mouse is over in the panel, or which is being edited there, shown in the view
|
|
struct curve_focus
|
|
{
|
|
enum class part
|
|
{
|
|
whole,
|
|
entry,
|
|
exit,
|
|
arc, // of the radius `arc`, the first one 0
|
|
between // the transition leading into the arc of the radius `arc`
|
|
};
|
|
int vertex{-1};
|
|
part what{part::whole};
|
|
int arc{0};
|
|
bool held{false}; // by a field being edited, the mouse over the others doesn't move it
|
|
} focus;
|
|
// the points clicked when the fragment was laid, kept with its design: the curves keep to them as their transitions and cants
|
|
// change, while hold is on
|
|
std::vector<glm::dvec3> clicks;
|
|
bool hold{true};
|
|
struct click_state
|
|
{
|
|
double offset{0.0}; // from the line, m
|
|
int vertex{-1}; // whose curve it's a point of
|
|
bool corner{false}; // a bend of straights clicked, the vertex itself rather than a point of its curve
|
|
};
|
|
std::vector<click_state> click_states; // as the line was at the revision measured
|
|
int revision{0}; // of the result, counted as it's computed
|
|
int measured{-1};
|
|
// points clicked along the middle of the track seen on the orthophoto, the radii of the curves and their shares fitted to them after each click
|
|
struct trace_state
|
|
{
|
|
bool active{false};
|
|
int radii{0}; // 0: as many as the points need, up to three
|
|
std::vector<glm::dvec3> points;
|
|
alignment::design before; // taken back by Esc
|
|
double rms{0.0};
|
|
double worst{0.0};
|
|
} trace;
|
|
};
|
|
void render_route_ui();
|
|
// lets go of the line under the route tool, a track of it deleted; the norms set for laying stay
|
|
void route_drop();
|
|
bool render_route_band();
|
|
bool render_route_parameters();
|
|
bool render_route_vertices();
|
|
bool render_route_vertex(int const Index);
|
|
void render_route_result();
|
|
void render_route_trace();
|
|
// the camera over the stretch of the line between the chainages, a curve seen whole
|
|
void route_show_curve(double const From, double const To);
|
|
// the departures of the points clicked from the line and the curves they belong to, measured again when the line changed
|
|
void route_measure_clicks();
|
|
// the points clicked along the curve of the vertex, in the plan, the bends of straights left out
|
|
std::vector<glm::dvec2> route_clicks_of(int const Vertex) const;
|
|
// the radii of the curve of the vertex fitted again to the points clicked along it, its transitions and cants as they are
|
|
bool route_hold_clicks(int const Vertex);
|
|
// the elements of the part of the curve in focus in the panel, in their order along the line
|
|
std::vector<std::size_t> route_focused() const;
|
|
void route_trace_start();
|
|
void route_trace_fit();
|
|
void route_trace_end(bool const Keep);
|
|
int route_trace_hit() const;
|
|
glm::dvec3 route_trace_cursor() const;
|
|
void route_reset();
|
|
void route_bind_ends();
|
|
bool route_from_curve(TTrack &Track);
|
|
bool route_from_line(TTrack &Track);
|
|
// the first curve of the design and the last one going on from the curves of the tracks adjoining, where they turn their way: a
|
|
// curve cut by a switch bent into it, say. Lays the design
|
|
void route_curved_ends();
|
|
alignment::vertex route_vertex_of(editor_track::curve const &Curve) const;
|
|
bool route_load(TTrack &Track);
|
|
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;
|
|
// a slip of the scenery the track is a part of: its switches, all its tracks, the switches among them, and its ends where it joins
|
|
// the tracks around, A and B of its first track through, C and D of the other one, with the way into the slip at each
|
|
struct slip_set
|
|
{
|
|
switch_store::record record;
|
|
std::vector<TTrack *> switches;
|
|
std::vector<TTrack *> parts;
|
|
std::array<glm::dvec3, 4> ends{};
|
|
std::array<glm::dvec2, 4> into{};
|
|
};
|
|
std::optional<slip_set> slip_of(TTrack const &Track) const;
|
|
// the two tracks of the slip through it from end to end, as they cross where it's taken out
|
|
static std::array<segment_data, 2> slip_throughs(slip_set const &Slip);
|
|
// the slip taken out with its record, nothing of it put in the history yet; with Throughs its two tracks laid crossing in its
|
|
// place, given back
|
|
std::vector<TTrack *> slip_taken_out(slip_set const &Slip, bool const Throughs);
|
|
// the record of the crossing of two plain tracks the track is one of
|
|
std::optional<switch_store::record> crossing_record(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);
|
|
// with no Style, as the lay tool lays its tracks
|
|
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, double const Middle = 0.0);
|
|
void render_switch_record(TTrack const &Track) const;
|
|
void route_store();
|
|
bool digitize_drawn(std::vector<TTrack *> const &Created, bool const Alone = true) override;
|
|
bool model_parallel(TTrack &Source, double const Spacing, int const Side, std::string &Status, std::string &Error) override;
|
|
bool digitize_chain(editor_track::chain const &Chain, std::string *Reason = nullptr, TTrack **Culprit = nullptr);
|
|
int digitize_parts(editor_track::chain const &Chain, std::string *Reason, int &Skipped);
|
|
// the lines kept, the paths left out
|
|
void digitize_all(int *Kept = nullptr, int *Failed = nullptr);
|
|
// what the digitization of the scenery did, or would do
|
|
struct digitize_report
|
|
{
|
|
int lines{0};
|
|
int lines_failed{0};
|
|
int switches{0};
|
|
int known{0}; // kept in the scenery already
|
|
int designed{0}; // of a template of the catalogue
|
|
int measured{0};
|
|
int slips{0};
|
|
int unnamed{0}; // no record finds them
|
|
int odd{0};
|
|
int recorded{0};
|
|
int crossovers{0};
|
|
int crossovers_known{0};
|
|
int crossovers_recorded{0};
|
|
int crossovers_odd{0};
|
|
int found{0};
|
|
int bound{0};
|
|
std::map<std::string, int> types; // of the catalogue
|
|
std::map<std::string, int> shapes; // measured
|
|
std::vector<std::string> notes;
|
|
};
|
|
// the switches without a type kept get the one of the catalogue they are of, or the size measured from their shape
|
|
void digitize_switches(digitize_report &Report, bool const Write);
|
|
// two switches facing each other from two tracks, their diverging tracks joined by a plain one, are kept as a crossover
|
|
void digitize_crossovers(digitize_report &Report, bool const Write);
|
|
// the lines, the switches, the crossovers and the objects along the tracks at one go; without Write only counts them
|
|
std::string digitize_scenery(bool const Write);
|
|
void render_route_stored();
|
|
void route_update()
|
|
{
|
|
m_route.design.norms.checked = true;
|
|
m_route.result = alignment::compute(m_route.design);
|
|
++m_route.revision;
|
|
}
|
|
void route_apply();
|
|
void route_lay();
|
|
bool route_relay_through_switches(editor_track::chain const &Chain, std::vector<std::pair<TTrack *, editor_track::state>> &States, std::vector<TTrack *> &Created, TTrack *&Last);
|
|
void route_recommend(alignment::vertex &Vertex) const;
|
|
void draw_route_overlay() const;
|
|
void render_route_gizmo();
|
|
glm::dvec3 route_vertex_position(int const Vertex) const;
|
|
bool route_active() const;
|
|
route_design m_route;
|
|
|
|
struct straights_state
|
|
{
|
|
editor_track::straight_tolerance tolerance;
|
|
double minimum_length{50.0};
|
|
std::vector<editor_track::straight> found;
|
|
int listed{-1};
|
|
TTrack *current_for{nullptr};
|
|
editor_track::straight current;
|
|
std::vector<editor_track::straight> neighbours;
|
|
std::vector<double> spacings{3.5, 4.0, 4.5, 4.75, 5.0, 5.5, 6.0};
|
|
char filter[32]{};
|
|
int handle{-1};
|
|
bool dragging{false};
|
|
editor_track::straight drag_line;
|
|
std::vector<editor_track::straight> set;
|
|
std::vector<editor_track::straight> drag_lines;
|
|
bool fitting{false};
|
|
editor_track::curve fit_before;
|
|
editor_track::curve fit_after;
|
|
bool fit_has_before{false};
|
|
bool fit_has_after{false};
|
|
std::vector<std::pair<TTrack *, editor_track::state>> drag_states;
|
|
std::size_t drag_step{0};
|
|
glm::dvec3 preview_start{0.0};
|
|
glm::dvec3 preview_end{0.0};
|
|
glm::dvec3 edit_start{0.0};
|
|
glm::dvec3 edit_end{0.0};
|
|
double edit_length{0.0};
|
|
double edit_azimuth{0.0};
|
|
double distance{4.0};
|
|
double curve_radius{0.0};
|
|
bool auto_transitions{true};
|
|
double transition{0.0};
|
|
int tool{0};
|
|
int tool_before{0};
|
|
bool tool_mouse{false};
|
|
std::vector<glm::dvec3> detour;
|
|
editor_track::straight detour_line;
|
|
glm::dvec3 detour_mouse{0.0};
|
|
bool tool_placed{false};
|
|
double tool_at{0.0};
|
|
glm::dvec3 tool_point{0.0};
|
|
glm::dvec3 tool_handle{0.0};
|
|
editor_track::straight tool_line;
|
|
std::string status;
|
|
};
|
|
void render_straights_ui();
|
|
void draw_straights_overlay() const;
|
|
editor_track::straight const ¤t_straight();
|
|
bool straights_active();
|
|
void render_straight_gizmo();
|
|
void straight_apply(editor_track::straight const &Line, glm::dvec3 const &Start, glm::dvec3 const &End);
|
|
void straights_apply(std::vector<editor_track::straight> const &Lines, std::vector<std::pair<glm::dvec3, glm::dvec3>> const &Ends);
|
|
bool in_straight_set(editor_track::straight const &Line) const;
|
|
bool place_straight_tool();
|
|
void apply_straight_tool();
|
|
double straight_tool_radius(editor_track::straight const &Line) const;
|
|
void straight_reshape(editor_track::straight const &Line, double const From, double const To, std::function<glm::dvec3(glm::dvec3 const &)> const &Tail, double const Radius);
|
|
void straight_refresh() override;
|
|
bool start_curve_fit(editor_track::straight const &Line, int const Handle);
|
|
void update_curve_fit(glm::dvec3 const &Start, glm::dvec3 const &End);
|
|
void add_detour_point();
|
|
void apply_detour();
|
|
std::vector<glm::dvec3> detour_outline() const;
|
|
void find_neighbour_straights();
|
|
// listed spacing of a neighbouring straight the line can snap to, if it is close enough
|
|
struct parallel_offer
|
|
{
|
|
bool nearby{false};
|
|
bool snaps{false};
|
|
double spacing{0.0};
|
|
double distance{0.0};
|
|
double angle{0.0}; // deg between the two straights
|
|
double correction{0.0}; // m along the line normal to reach the spacing
|
|
editor_track::straight const *neighbour{nullptr};
|
|
};
|
|
parallel_offer straight_parallel_offer(editor_track::straight const &Line, glm::dvec3 const &Offset) const;
|
|
glm::dvec3 snap_straight_offset(editor_track::straight const &Line, glm::dvec3 const &Offset) const;
|
|
glm::dvec3 snap_straight_direction(glm::dvec3 const &Pivot, glm::dvec3 const &Moved) const;
|
|
straights_state m_straights;
|
|
|
|
struct curve_sample
|
|
{
|
|
double station{0.0};
|
|
glm::dvec3 position{0.0};
|
|
glm::dvec2 tangent{0.0, 1.0};
|
|
float roll{0.f};
|
|
float radius{0.f};
|
|
};
|
|
// the line leaving an end of a switch off its main straight, taken before the switch moves: its paths up to the end of
|
|
// the straight past the curve next to the switch. When the switch moves only the paths up to a joint on that straight
|
|
// are laid again, so the curve keeps to the end of the switch and the rest of the network stays where it is
|
|
struct switch_branch
|
|
{
|
|
std::size_t joint{0};
|
|
editor_track::chain chain;
|
|
std::size_t straight{0}; // the first path of the straight past the curve
|
|
alignment::design design; // as the paths lie
|
|
alignment::result result;
|
|
// made for the new end of the switch
|
|
editor_track::chain part; // the paths laid again
|
|
std::vector<segment_data> pieces;
|
|
alignment::design laid; // of the whole chain
|
|
double factor{1.0}; // of the radius and the transitions of the curve
|
|
};
|
|
struct switch_tool
|
|
{
|
|
std::vector<std::string> keep_names; // the names the switches laid next take, before the ones of the tool
|
|
std::string keep_slip; // the name the slip or the crossing laid next takes, of the one it's laid in place of
|
|
bool curved{false};
|
|
// a switch placed where there's no track: started on the ground, or at the free end it goes on from in its direction; the direction
|
|
// of its main track taken from the drag once it's long enough, then the drag sideways gives the side of the diverging one
|
|
bool free{false};
|
|
editor_track::snap_target free_end;
|
|
std::optional<glm::dvec2> free_heading;
|
|
// from a free end, dragged on past its end: bent, its diverging track turning the other way than the main one, the same way with
|
|
// Tab (one-sided)
|
|
bool one_sided{false};
|
|
std::vector<curve_sample> frame;
|
|
std::vector<TTrack *> frame_tracks;
|
|
std::vector<editor_track::switch_template> templates;
|
|
bool collected{false};
|
|
int armed{-1};
|
|
int last{0}; // template armed the last time
|
|
bool placing{false};
|
|
// where it was pressed on the screen: let go no farther from there, the press places nothing, a click doesn't lay a switch by chance
|
|
glm::vec2 pressed_at{0.f};
|
|
double along{0.0};
|
|
double pressed{0.0}; // along a curve: where the press was, the start of the switch drawn from it to the ends of the cant ramps
|
|
glm::dvec3 point{0.0};
|
|
glm::dvec3 mouse{0.0};
|
|
editor_track::straight line;
|
|
std::string status;
|
|
std::string refusal; // the last of the statuses which told a switch refused, told in red while it's the status
|
|
char name[64]{};
|
|
struct drive_family
|
|
{
|
|
std::string name;
|
|
std::array<std::string, 4> files;
|
|
std::array<double, 4> heights{};
|
|
bool preferred{false};
|
|
};
|
|
std::vector<drive_family> drives;
|
|
int drives_revision{-1}; // of the include bank the drives were read from
|
|
int drive{-1};
|
|
int drive_side{0};
|
|
struct slide_state
|
|
{
|
|
bool active{false};
|
|
TTrack *track{nullptr};
|
|
glm::vec2 pressed{0.f};
|
|
double grip{0.0};
|
|
double low{0.0};
|
|
double high{0.0};
|
|
double distance{0.0};
|
|
double length{0.0};
|
|
std::vector<double> joints;
|
|
// the lines leaving the switch off its straight: the joint they leave at, the path of the switch in the shown ones
|
|
struct branch_line
|
|
{
|
|
editor_track::joint joint;
|
|
std::size_t path{0};
|
|
switch_branch branch;
|
|
};
|
|
std::vector<branch_line> branches;
|
|
// a switch bent into a curve slides along it: the curve its main track and the tracks next to it make, where the switch
|
|
// starts on it; low and high the distances it may go back and on
|
|
std::vector<curve_sample> frame;
|
|
double station{0.0};
|
|
};
|
|
slide_state slide;
|
|
double slide_typed{0.0};
|
|
int connection{-1};
|
|
int connection_kind{0}; // the kind of connection chosen last, taken again when the connections are chosen
|
|
std::string rail_pick{"60E1"}; // the rail whose templates are listed first where the track doesn't tell its rail
|
|
int connection_second{-1};
|
|
double connection_radius{0.0};
|
|
double connection_gap{6.0};
|
|
bool connection_together{false};
|
|
char connection_spacings[64]{"4.75;4.75;5.0"};
|
|
double connection_stub{25.0};
|
|
// the connection a switch dragged makes, as where it's let go tells it, in connection then: let go on the other track a
|
|
// crossover, across the tracks between them a ladder; by a crossover there already turned the other way a double crossover
|
|
// with it, over it a scissors one
|
|
bool recognised{false};
|
|
TTrack *partner{nullptr}; // a switch of the crossover there already
|
|
};
|
|
switch_tool m_switch;
|
|
// what the switch tool places: a switch into a straight or a curve, a slip switch or a crossing at a crossing of two
|
|
// straights, or a connection of tracks laid whole
|
|
enum class switch_kind
|
|
{
|
|
single,
|
|
slip,
|
|
crossing,
|
|
connection
|
|
};
|
|
switch_kind current_switch_kind() const;
|
|
void choose_switch_kind(switch_kind const Kind);
|
|
bool switch_kind_offered(switch_kind const Kind) const;
|
|
bool plan_connection(connection::request &Request, connection::result &Result) const;
|
|
// what the drag of the switch being placed makes, from where the cursor is: sets connection and partner of the tool
|
|
void recognise_connection();
|
|
// the double or the scissors crossover of the partner and the crossover dragged, on the lines of their tracks
|
|
bool plan_partner_connection(connection::request &Request, connection::result &Result) const;
|
|
void insert_partner_connection();
|
|
// the switches and the inserts of the connection planned laid, one step of the history. false if they don't fit
|
|
bool lay_planned_connection(connection::request const &Request, connection::result const &Plan, TTrack *Style);
|
|
void insert_connection();
|
|
void render_connection_options();
|
|
// the name of a kind of connection of tracks, translated
|
|
static char const *connection_name(int const Kind);
|
|
// the name of a switch template for the lists: where it comes from and its name without the lengths
|
|
static std::string switch_template_label(editor_track::switch_template const &Template);
|
|
// the name of a switch template for the user: translated, with the speed on its diverging track
|
|
static std::string template_name(editor_track::switch_template const &Template);
|
|
// the template of the catalogue a record of the switches was laid of, -1 if none: Lengths compares a and b too, which the
|
|
// record of a connection keeps for its spacing; Movable: the nose of the frog, either when not given
|
|
int matching_template(switch_store::record const &Record, bool const Lengths, std::optional<bool> const Movable = std::nullopt) const;
|
|
// the template the switch was laid of, -1 if none: a switch of the scenery of its own shape, say
|
|
int switch_template_index(TTrack const &Switch) const;
|
|
// the usual switch of the rail for the speed on its diverging track, as the assumptions of the project ask for one: the closest speed,
|
|
// the skos usual for it; -1 for none
|
|
int usual_switch(std::string const &Rail, double const Speed) const;
|
|
// why the switch can't take another template here, empty when it can
|
|
std::string template_change_blocked(TTrack const &Switch) const;
|
|
// the template of the catalogue a slip or a crossing was laid of, of the rail before the others; -1 if none
|
|
int slip_template_index(switch_store::record const &Record, std::string const &Rail) const;
|
|
// the switch of the template of the index in place: its start and its side kept, the tracks it joins following; a switch of a
|
|
// crossover takes the crossover with it, laid again, a slip or a crossing is laid again where its tracks cross. One step of the
|
|
// history; the status says how it went
|
|
bool change_switch_template(TTrack &Switch, int const Index);
|
|
bool change_slip_template(TTrack &Part, int const Index);
|
|
// the switch, or the double switch it's a part of, given the shape in place, straight or bent into the curve it lies in; Flip:
|
|
// the diverging track to the other side. Notes: for the user
|
|
bool apply_switch_template(TTrack &Switch, editor_track::switch_template const &Shape, bool const Flip, std::string &Notes);
|
|
// the template to choose: the speeds on the diverging track as chips, the templates of the rail by their skos, all the others
|
|
// folded under. Fits: those of the kind wanted; Rail: of the track, empty when it doesn't tell; Popup: inside a combo, with no
|
|
// windows of its own. Gives the index picked, -1 while none is
|
|
// in the panel (not Popup) the template chosen is a line, Unlisted where it's of none of them, which opens the list
|
|
int render_template_picker(char const *Id, std::function<bool(editor_track::switch_template const &)> const &Fits, std::string const &Rail, int const Chosen, bool const Popup, std::string const &Unlisted = {});
|
|
// the template of the selected switch, slip or crossing, changed with a pick: in a combo for the inspector, else in full; nothing
|
|
// for another track
|
|
void render_switch_template(TTrack &Track, bool const Combo);
|
|
std::string connection_readout(connection::result const &Plan) const;
|
|
editor_track::straight straight_near(glm::dvec3 const &Point, std::vector<TTrack const *> const &Exclude, double const Reach) const;
|
|
editor_track::straight straight_through(glm::dvec3 const &Point, glm::dvec2 const &Direction) const;
|
|
void record_connection(connection::kind const Kind, std::vector<TTrack *> const &Switches, connection::result const &Plan, editor_track::switch_template const &Shape);
|
|
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);
|
|
std::optional<switch_branch> take_switch_branch(TTrack const &Track, editor_track::joint const &Joint, std::size_t const Index) const;
|
|
// for the path of the switch the line leaves, as it'll lie
|
|
bool plan_switch_branch(segment_data const &Path, editor_track::joint const &Joint, switch_branch &Branch) const;
|
|
void lay_switch_branch(switch_branch const &Branch, editor_track::edit &Edit);
|
|
// of the joints off the main straight of the switch, the neighbours in Skip left out
|
|
std::vector<switch_branch> switch_branches(TTrack const &Track, std::vector<editor_track::joint> const &Joints, std::vector<TTrack const *> const &Skip = {}) const;
|
|
// for the paths the switch has now; the joints of the branches which can be laid are handled, the others are left out. Gives the notes for the user
|
|
std::string plan_switch_branches(TTrack const &Track, std::vector<editor_track::joint> const &Joints, std::vector<switch_branch> &Branches, std::vector<bool> &Handled) const;
|
|
// 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;
|
|
// a slip slid along its first track: the slip and the tracks its crossing track goes on into with their ends free move whole, the
|
|
// straights of its first track before it and past it give and take the length. Low and High: how far back and on it may go
|
|
struct slip_slide
|
|
{
|
|
glm::dvec3 shift{0.0}; // along its first track, a metre of it
|
|
std::vector<TTrack *> movers;
|
|
// where it joins the tracks of its first track before it and past it: at its ends A and B, or at the joints of its template
|
|
// with the straights out to them going along; those tracks, the end of each there
|
|
std::array<glm::dvec3, 2> joints{};
|
|
std::array<std::pair<TTrack *, editor_track::point_ref>, 2> ends{};
|
|
double low{0.0};
|
|
double high{0.0};
|
|
};
|
|
bool slip_room(slip_set const &Slip, slip_slide &Slide, std::string &Reason) const;
|
|
bool slide_slip(slip_set const &Slip, double const Distance);
|
|
// a switch bent into a curve, its main track going on into a plain track at each end: the curve the three make, the two tracks,
|
|
// where the switch starts on it; false for any other
|
|
bool bent_switch_frame(TTrack const &Track, std::vector<curve_sample> &Frame, std::array<TTrack *, 2> &Sides, double &Station) const;
|
|
// the paths of the switch moved along the curve by the distance, shaped as the curve is there
|
|
std::vector<segment_data> bent_switch_paths(TTrack const &Track, std::vector<curve_sample> const &Frame, double const Station, double const Distance) const;
|
|
bool slide_bent_switch(TTrack &Track, double const Distance);
|
|
// the switch bent into a curve given the paths, along the curve of the bent_switch_frame: the tracks next to it laid along it up to
|
|
// its new ends, one taken up whole going, the curve past the diverging track following. Notes: for the user
|
|
bool lay_bent_switch(TTrack &Track, std::vector<curve_sample> const &Frame, std::array<TTrack *, 2> const &Sides, std::vector<segment_data> const &Paths, std::string &Notes);
|
|
void switch_slide_start(TTrack &Track);
|
|
void switch_slide_update();
|
|
void switch_slide_finish();
|
|
void draw_switch_slide() const;
|
|
// reads the drives from the include bank once it changes; Wait: for the templates being looked for. true if it read them
|
|
bool scan_switch_drives(bool Wait = true);
|
|
std::string switch_name_for_new() const;
|
|
bool place_switch_drive(TTrack &Switch);
|
|
bool flip_switch_drive(TTrack &Switch);
|
|
void advance_switch_name();
|
|
void join_last_steps();
|
|
bool render_switch_drive_choice();
|
|
struct turntable_template
|
|
{
|
|
std::string file;
|
|
std::string name;
|
|
double length{0.0};
|
|
int angles{0};
|
|
int positions{0};
|
|
int track{0};
|
|
int yaw{0};
|
|
std::vector<double> fixed;
|
|
};
|
|
struct turntable_fit
|
|
{
|
|
editor_track::snap_target end;
|
|
double heading{0.0};
|
|
double radius{0.0};
|
|
double length{0.0};
|
|
std::vector<segment_data> pieces;
|
|
std::string issue;
|
|
bool chosen{true};
|
|
TTrack *replaces{nullptr};
|
|
};
|
|
struct turntable_tool
|
|
{
|
|
std::vector<turntable_template> templates;
|
|
int revision{-1}; // of the include bank the templates were read from
|
|
int chosen{-1};
|
|
char name[64]{};
|
|
bool placing{false};
|
|
glm::dvec3 centre{0.0};
|
|
double yaw{0.0};
|
|
glm::vec2 pressed{0.f};
|
|
editor_track::snap_target snap;
|
|
TTrack *table{nullptr};
|
|
scene::instance_handle include{0};
|
|
int kind{-1};
|
|
double length{0.0};
|
|
double table_yaw{0.0};
|
|
std::vector<double> exits;
|
|
float reach{80.f};
|
|
float radius{150.f};
|
|
float stub{25.f};
|
|
float step{0.f};
|
|
std::vector<turntable_fit> fits;
|
|
int hovered{-1};
|
|
double heading{0.0};
|
|
double exit_length{0.0};
|
|
std::string status;
|
|
std::string error;
|
|
};
|
|
turntable_tool m_turntable;
|
|
bool scan_turntables(bool Wait = true);
|
|
std::string turntable_name_for_new() const;
|
|
bool turntable_read(TTrack *Table);
|
|
std::vector<scene::instance_handle> turntable_includes(TTrack const &Table);
|
|
glm::dvec3 turntable_centre() const;
|
|
std::vector<double> turntable_lines() const;
|
|
double turntable_snap(double const Heading) const;
|
|
void turntable_finish_placement();
|
|
void turntable_place(glm::dvec3 const &Centre, double const Yaw);
|
|
bool turntable_fit_end(editor_track::snap_target const &End, turntable_fit &Fit) const;
|
|
void turntable_find_fits();
|
|
void turntable_build(std::vector<turntable_fit const *> const &Fits);
|
|
bool turntable_exit_at(glm::dvec3 const &Ground, double &Heading, double &Length) const;
|
|
void turntable_store_exits();
|
|
void render_turntable_ui();
|
|
void draw_turntable_overlay() const;
|
|
struct extend_tool
|
|
{
|
|
bool active{false};
|
|
TTrack *track{nullptr};
|
|
glm::dvec3 point{0.0};
|
|
glm::dvec2 direction{0.0, 1.0};
|
|
double grade{0.0};
|
|
glm::dvec3 mouse{0.0};
|
|
int path{0};
|
|
bool atend{true};
|
|
editor_track::snap_target origin;
|
|
editor_track::snap_target snap;
|
|
glm::vec2 pressed{0.f};
|
|
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 curve ending at the last of these
|
|
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;
|
|
// where the grade breaks from point to point: the bends kept as such, at the heights clicked; a curve traced, or bends made
|
|
// one curve, goes at one grade from end to end
|
|
std::vector<glm::dvec3> knots;
|
|
};
|
|
// 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;
|
|
std::vector<segment_data> preview;
|
|
std::string preview_error;
|
|
double preview_length{0.0};
|
|
// the line worked out whole last, all its fits done: shown while the one of the cursor now still waits for them on the thread,
|
|
// so that the curves don't jump from one fit to the next as each comes
|
|
struct worked_out
|
|
{
|
|
std::vector<segment_data> preview;
|
|
std::string error;
|
|
double length{0.0};
|
|
lay_line_plan plan;
|
|
std::optional<alignment::lay_result> eased;
|
|
alignment::join_result join;
|
|
std::vector<glm::dvec3> points; // the ones clicked it was worked out for
|
|
};
|
|
std::optional<worked_out> shown;
|
|
// the cursor the line is being worked out for, kept till all its fits are done: what it was worked out from
|
|
struct settling_cursor
|
|
{
|
|
glm::dvec3 mouse{0.0};
|
|
editor_track::snap_target snap;
|
|
std::vector<glm::dvec3> points;
|
|
std::vector<lay_mode> modes;
|
|
lay_mode mode{lay_mode::straights};
|
|
int edits{0};
|
|
};
|
|
std::optional<settling_cursor> settling;
|
|
bool whole{true}; // false: each fit shown as it comes, as before, for a selftest to compare
|
|
double radius{500.0};
|
|
double piece_length{100.0};
|
|
bool copy_selected{false};
|
|
editor_track::path_style style;
|
|
bool own_speed{false}; // the speed of the style also where the track goes on from one with its own, the new tracks given it
|
|
std::string status;
|
|
double status_time{-100.0};
|
|
// what Tab switched to, told by the cursor a while: the step at the top of the panel says it for good
|
|
std::string hint;
|
|
double hint_time{-100.0};
|
|
std::string skew; // what Alt turned the straight to
|
|
double escape_time{-100.0}; // when Esc was pressed over points not laid: the second Esc drops them
|
|
std::size_t history{0}; // the step of the history the track laid last was begun at
|
|
// the panel: the settings opened from the line of their summary while the points are clicked, the details of the line shown, the
|
|
// notes of the line laid
|
|
bool settings_open{false};
|
|
bool details_open{false};
|
|
bool notes_open{false};
|
|
// the status tells of a line laid just now, as long as the history stays at the step it was laid with: the serial of the step on
|
|
// top then, not the size of the history, which an undo and another step make the same again
|
|
bool laid_now{false};
|
|
std::uint64_t laid_step{0};
|
|
// the line laid last, told in the inspector while the last of its tracks stays the selection the laying left
|
|
struct laid_curve
|
|
{
|
|
std::string label;
|
|
bool meets{true}; // the norms for the speed
|
|
};
|
|
struct laid_line
|
|
{
|
|
std::vector<TTrack *> tracks;
|
|
double length{0.0};
|
|
std::vector<laid_curve> curves;
|
|
};
|
|
laid_line laid;
|
|
};
|
|
lay_tool m_lay;
|
|
// the line laid last is told in the inspector in place of the sheet of its last track: that one is selected by the laying, not by
|
|
// a click
|
|
bool laid_shown() const;
|
|
void render_laid_summary();
|
|
alignment::limits laying_norms() const;
|
|
glm::dvec3 lay_angle_snap(glm::dvec3 const &Mouse, std::string &Label) const;
|
|
// the straight track Alt turns the laid straight to: the nearest one the straight from From to To crosses, or one along From
|
|
TTrack const *skew_reference(glm::dvec3 const &From, glm::dvec3 const &To, double const Reach) const;
|
|
void lay_after_history(bool const Undo);
|
|
void lay_back();
|
|
void lay_escape();
|
|
std::size_t lay_pending() const; // the points clicked and not laid yet
|
|
// the states of the panel of the lay tool, each with a step of its own: nothing clicked yet, the points being clicked, a line laid
|
|
// just now (one line over the state of nothing clicked), the shape dragged out of a free end
|
|
enum class lay_state
|
|
{
|
|
ready,
|
|
clicking,
|
|
laid,
|
|
extending
|
|
};
|
|
lay_state lay_panel_state() const;
|
|
// the states of the panels of the lay tool and of the switch tool in words, for the expectations of the self-test
|
|
std::string shown_lay_panel() const;
|
|
std::string shown_switch_panel() const;
|
|
// the line shown at a glance: its length, its curves, the speed of the slowest one and how many are below the norms for the speed
|
|
// it's designed for
|
|
struct lay_quality
|
|
{
|
|
bool valid{false};
|
|
double length{0.0};
|
|
std::size_t curves{0};
|
|
double slowest{0.0};
|
|
std::size_t below{0};
|
|
double speed{0.0};
|
|
};
|
|
lay_quality lay_quality_now() const;
|
|
std::string lay_settings_summary() const;
|
|
// what the cursor tells of the leg drawn to it, in a line or two
|
|
std::vector<std::string> lay_leg() const;
|
|
// why the line shown can't be laid, or what's told of a leg not of a design; empty where it only breaks the norms, which the details
|
|
// of the panel list
|
|
std::string lay_error() const;
|
|
std::string lay_readout() const;
|
|
// the same of the shape dragged out of a free end with the lay tool on: of Length, the sharpest arc of Radius, joined to Joined,
|
|
// Warned of by the norms where it goes on from a switch
|
|
std::string extend_leg(double const Length, double const Radius, TTrack const *Joined, bool const Warned) const;
|
|
void render_lay_ui();
|
|
void render_lay_step(lay_state const State);
|
|
void render_lay_settings();
|
|
void render_lay_quality();
|
|
void render_lay_details();
|
|
void render_lay_buttons();
|
|
void render_lay_more();
|
|
void render_lay_status(lay_state const State);
|
|
// a line laid by the lay tool, told in its panel: the length, the tracks, how to take it back
|
|
void lay_told(double const Length, std::size_t const Tracks);
|
|
void lay_click();
|
|
void lay_finish(editor_track::snap_target const &End);
|
|
void lay_cancel();
|
|
void lay_enter();
|
|
// 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;
|
|
// Adjoining: the curve next to a free end on a curve goes on from its curvature, where it turns its way; else from a straight there
|
|
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, bool const Adjoining = true) const;
|
|
// whether the points next to the start of the line, or to its end, AtEnd, a free end joined there, are clicked along a curve
|
|
static bool traced_from(std::vector<glm::dvec3> const &Points, std::vector<lay_mode> const &Modes, bool const AtEnd);
|
|
// 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; Meanwhile: the fit done last of the same points but the one
|
|
// at the cursor until then
|
|
// Exact receives whether the fit is the one of these points, not one shown meanwhile; Going: the curve going on from the curve of the
|
|
// free end Base starts at, alignment::fit_going_on
|
|
std::optional<alignment::trace_stretch> traced_stretch(alignment::design const &Base, std::vector<glm::dvec2> const &Points, int const Radii, bool const Straights, bool const Meanwhile = true,
|
|
bool *Exact = nullptr, bool const Going = false) const;
|
|
// the curve through a row of bends clicked close along one, by traced_stretch
|
|
alignment::stretch_fit bends_fit() const
|
|
{
|
|
return [this](alignment::design const &Base, std::vector<glm::dvec2> const &Points) { return traced_stretch(Base, Points, 0, false, false); };
|
|
}
|
|
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;
|
|
// a fit the line asked the thread for isn't done yet: the line is one of the fits meanwhile
|
|
mutable bool m_fits_waiting{false};
|
|
// how much more the curve at the cursor was turned last to reach it, the first one tried for the next line
|
|
mutable double m_turned_last{0.0};
|
|
void render_switch_ui();
|
|
// what the switch tool places, as a bar of its kinds
|
|
void render_switch_kinds(switch_kind const Kind);
|
|
// a switch dragged: the length of its template, the side its diverging track goes to and the speed on it, what keeps it from being
|
|
// laid; the side 1 the right
|
|
void render_switch_drag();
|
|
int switch_drag_side(std::string &Refusal) const;
|
|
// the track was made by the last step of the history, with those made together with it
|
|
bool just_laid(TTrack const *Track) const;
|
|
void render_switch_timbers();
|
|
void render_rail_profile_hint(TTrack &Track);
|
|
bool start_switch_placement();
|
|
void finish_switch_placement();
|
|
// a switch with no track under it: a press on the ground starts it at the free end of a track within reach, none with no free end near
|
|
editor_track::snap_target free_switch_end(glm::dvec3 const &Ground) const;
|
|
bool free_switch_offered() const;
|
|
void start_free_switch(glm::dvec3 const &Ground);
|
|
// the start of the switch, the way its main track goes and the side of its diverging one, as the drag gives them so far
|
|
void free_switch_pose(glm::dvec3 &Start, glm::dvec2 &Heading, int &Side, double &Grade) const;
|
|
// a switch laid on from a free end, dragged on past its end: bent, its main track turning toward the cursor
|
|
struct free_bend
|
|
{
|
|
double radius{0.0}; // of the main track
|
|
int turn{1}; // the way the main track turns, 1 to the left
|
|
int side{1}; // of the diverging track
|
|
std::vector<curve_sample> frame; // the curve the switch is bent into
|
|
std::vector<segment_data> paths;
|
|
switch_curve::switch_report report;
|
|
// a free end the cursor is at, which the main track leads into, the diverging one with Shift
|
|
editor_track::snap_target target;
|
|
bool diverging{false};
|
|
editor_track::branch_link link;
|
|
std::string problem; // why it can't lead into the target
|
|
};
|
|
// false where it isn't bent: near the switch, along the straight, or not from a free end
|
|
bool free_switch_bend(free_bend &Bend) const;
|
|
bool free_switch_bend_now(free_bend &Bend) const;
|
|
// laid on from an end of a switch: what the norms say of the change of the curvature from that switch to the tracks of this one
|
|
std::vector<std::string> free_switch_exits(std::vector<segment_data> const &Paths) const;
|
|
std::vector<segment_data> free_switch_paths() const;
|
|
void insert_free_switch();
|
|
std::vector<segment_data> switch_preview() const;
|
|
std::vector<segment_data> switch_preview_now() const;
|
|
// where a switch can't go, or doesn't go where it's dragged: what's in the way blinking in the view, each point told what's there,
|
|
// why by the cursor; while it's dragged, and a while after it's refused
|
|
struct switch_problem
|
|
{
|
|
std::string text;
|
|
std::vector<segment_data> paths;
|
|
std::vector<std::pair<glm::dvec3, std::string>> marks;
|
|
};
|
|
// what's at the end of the straight: a curve beginning, a switch, the track ending
|
|
std::string straight_end_note(editor_track::straight const &Line, bool const Far) const;
|
|
std::optional<switch_problem> switch_drag_problem() const;
|
|
std::optional<switch_problem> straight_switch_problem(editor_track::straight const &Line, double const Length, double const Along, int const Direction) const;
|
|
// the hard rules of ST-T1-A6 the switch breaks, for the status: not Laid, or kept as it is when moved or given another template
|
|
static std::string switch_refusal(std::vector<std::string> const &Refusals, bool const Laid);
|
|
// the switch lying along the straight From to To, the cant of the line under it and near it (11.4 pkt 7, 9.6 pkt 16): what it breaks,
|
|
// empty for nothing. Moving: the tracks of the switch moved along the straight, which the line is taken without
|
|
std::string straight_switch_refusal(editor_track::straight const &Line, glm::dvec3 const &From, glm::dvec3 const &To, bool const Laid, std::vector<TTrack const *> const &Moving = {}) const;
|
|
void flash_switch_problem(switch_problem Problem);
|
|
void flash_switch_problem(std::string const &Text, std::vector<segment_data> Paths, std::vector<std::pair<glm::dvec3, std::string>> Marks = {});
|
|
void draw_switch_problem(switch_problem const &Problem) const;
|
|
switch_problem m_switch_flash;
|
|
double m_switch_flash_until{-1.0};
|
|
// a preview worked out once a frame for the drawing and the readouts which all show it: the frame and the state of the tool it
|
|
// was worked out for
|
|
template <typename Result> struct frame_memo
|
|
{
|
|
int frame{-1};
|
|
std::vector<double> key;
|
|
Result result{};
|
|
bool fresh(std::vector<double> const &Key) const { return frame == ImGui::GetFrameCount() && key == Key; }
|
|
void keep(std::vector<double> Key, Result const &Value)
|
|
{
|
|
frame = ImGui::GetFrameCount();
|
|
key = std::move(Key);
|
|
result = Value;
|
|
}
|
|
};
|
|
std::vector<double> switch_memo_key() const;
|
|
mutable frame_memo<std::vector<segment_data>> m_switch_memo;
|
|
mutable frame_memo<std::pair<bool, free_bend>> m_bend_memo;
|
|
mutable frame_memo<std::vector<segment_data>> m_extend_memo;
|
|
void insert_switch(editor_track::straight const &Line, double const Along, int const Direction, int const Side);
|
|
void switch_placed(std::vector<TTrack *> const &Created);
|
|
static std::vector<curve_sample> sample_chain(editor_track::chain const &Chain);
|
|
static curve_sample sample_at(std::vector<curve_sample> const &Frame, double const Station);
|
|
// the curve a switch goes into as the norms look at it: its headings and its cant along it
|
|
std::vector<switch_curve::track_point> frame_points(std::vector<curve_sample> const &Frame) const;
|
|
// the line of the chain as the norms look at it, the first path of each track the way the chain runs, and on over the plain tracks
|
|
// joined past its ends as far as Beyond: the ends of the cant ramps near a switch; Offset: the station the chain starts at
|
|
std::vector<switch_curve::track_point> line_points(editor_track::chain const &Chain, double const Beyond, double &Offset) const;
|
|
// the tracks of the frame as a chain, each run the way the frame goes
|
|
static editor_track::chain frame_chain(std::vector<curve_sample> const &Frame, std::vector<TTrack *> const &Tracks);
|
|
// the tracks of the straight along their first paths as a chain, from its start on
|
|
static editor_track::chain straight_chain(editor_track::straight const &Line);
|
|
// the speed on the diverging track of the switch as it lies, km/h: the basic switch of Radius and 1:Ratio bent as its main track is
|
|
// (table 11.8), the cant of its line with its sign, the cant deficiency its frog takes (formula 9.9, table 9.7), no more than the
|
|
// basic switch has (table 11.2); Why receives how, for the status
|
|
double branch_speed_of(TTrack const &Switch, double const Radius, double const Ratio, std::string *Why = nullptr) const;
|
|
// that speed written into the switch for its diverging track, a lower limit of the main track kept for both; returns how, for the
|
|
// status
|
|
std::string write_switch_speed(TTrack &Switch, double const Radius, double const Ratio, double const Main);
|
|
// a switch of the scenery bent into the curve of the Frame along its Tracks, its Paths where it's moved to, as ST-T1-A6 sees it
|
|
switch_curve::switch_report bent_switch_report(TTrack const &Switch, std::vector<curve_sample> const &Frame, std::vector<TTrack *> const &Tracks, std::vector<segment_data> const &Paths) const;
|
|
// the way the switch being placed into a curve goes along it and the side its diverging track leaves to, from the drag
|
|
void curved_switch_pose(int &Direction, int &Side) const;
|
|
// the start of the switch being placed into a curve: where it was pressed, drawn to where the switch meets an end of a cant ramp or
|
|
// keeps 6 m off it; What receives which
|
|
double curved_switch_start(int const Direction, std::string *What = nullptr) const;
|
|
// the switch made of the paths, laid into the curve at the station, as ST-T1-A6 sees it; with the Tracks of the frame its cant is
|
|
// looked at on past the ends of the curve too
|
|
switch_curve::switch_report curved_switch_report(std::vector<segment_data> const &Paths, std::vector<curve_sample> const &Frame, double const Station, int const Direction, std::vector<TTrack *> const *Tracks = nullptr) const;
|
|
static double nearest_station(std::vector<curve_sample> const &Frame, glm::dvec3 const &Point);
|
|
static std::vector<segment_data> curved_switch_paths(editor_track::switch_template const &Shape, std::vector<curve_sample> const &Frame, double const Station, int const Direction, int const Side);
|
|
// the path of a switch template laid into the curve: x of the template across the main track to the Side, z along it from the
|
|
// Station on, going Direction along the curve; past Bent along it going on straight as the curve heads there. The heights and the
|
|
// cant are those of the line where the point is along it
|
|
static segment_data frame_path(segment_data const &Local, std::vector<curve_sample> const &Frame, double const Station, int const Direction, int const Side, std::optional<double> const &Bent = std::nullopt);
|
|
void insert_curved_switch(int const Direction, int const Side);
|
|
// a crossover between two tracks running side by side along a curve (editormodeconnectioncurve.cpp)
|
|
struct curve_mapping;
|
|
// Beyond: the straights past the ends of the curve go with it up to that far, and a straight track that near the curve is taken
|
|
// as its part
|
|
static bool curve_of(TTrack &Track, editor_track::straight_tolerance const &Tolerance, double const Gauge, std::vector<curve_sample> &Frame, std::vector<TTrack *> &Tracks, double const Beyond = 0.0);
|
|
static void cut_curve(std::vector<TTrack *> &Candidates, std::vector<curve_sample> const &Frame, glm::dvec3 const &First, glm::dvec3 const &Second, std::vector<std::pair<TTrack *, editor_track::state>> &States, std::vector<TTrack *> &Created, std::vector<TTrack *> &Removed);
|
|
void insert_curved_connection();
|
|
struct curved_crossover
|
|
{
|
|
switch_store::record record;
|
|
TTrack *first{nullptr};
|
|
TTrack *second{nullptr};
|
|
TTrack *insert{nullptr};
|
|
};
|
|
// the single crossover the switch is a part of, along a curve or straights
|
|
std::optional<curved_crossover> crossover_of(TTrack const &Switch) const;
|
|
bool take_out_crossover(curved_crossover const &Crossover, std::vector<std::pair<TTrack *, editor_track::state>> &States, std::vector<TTrack *> &Created, std::vector<TTrack *> &Removed, TTrack *&First, TTrack *&Second);
|
|
bool slide_curved_connection(TTrack &Switch, double const Distance, int const Shape = -1);
|
|
// the template a crossover was laid of, -1 if it's not among the templates
|
|
int crossover_template(switch_store::record const &Record);
|
|
// a crossover laid again from the press on one track to the release by the other, as by the mouse. false if it doesn't fit
|
|
// Names: of the switch at the press and of the one at the release, kept when a crossover is laid again
|
|
bool lay_crossover(int const Shape, glm::dvec3 const &Press, glm::dvec3 const &Release, double const Reach = 3.0, std::vector<std::string> const &Names = {});
|
|
// after the grade line of the open route went on its paths: the line on the other side of each crossover of the route
|
|
// takes the same change of the heights where it runs beside, and its design with it. returns: how many lines followed
|
|
std::size_t follow_crossovers(std::vector<editor_track::route_sample> const &Before);
|
|
bool place_switch_on_straight(editor_track::straight const &Line, editor_track::switch_template const &Shape, TTrack const *Style, double const Along, int const Direction, int const Side, bool const Snap, std::vector<std::pair<TTrack *, editor_track::state>> &States, std::vector<TTrack *> &Created, std::vector<TTrack *> &Removed, std::string const &Name = {});
|
|
struct crossover_plan
|
|
{
|
|
editor_track::straight target;
|
|
editor_track::switch_template shape;
|
|
double along{0.0};
|
|
int direction{1};
|
|
int side{1};
|
|
std::vector<segment_data> inserts; // a straight one, or an aligning curve between straights onto a track not parallel
|
|
std::vector<segment_data> paths;
|
|
connection::result connection; // as it's kept with the two switches
|
|
};
|
|
bool plan_crossover(crossover_plan &Plan) const;
|
|
struct switch_link
|
|
{
|
|
editor_track::snap_target target;
|
|
editor_track::branch_link link;
|
|
double along{0.0};
|
|
int forward{1};
|
|
int side{1};
|
|
double moved{0.0};
|
|
std::vector<segment_data> paths;
|
|
std::string reason;
|
|
};
|
|
bool plan_switch_link(switch_link &Plan) const;
|
|
void insert_linked_switch(switch_link const &Plan);
|
|
bool plan_branch_link(editor_track::branch_link &Link, std::string &Reason) const;
|
|
void finish_branch_link(editor_track::branch_link const &Link);
|
|
std::string link_problem(editor_track::snap_target const &Target, editor_track::branch_link const &Link) const;
|
|
bool stretchable(editor_track::snap_target const &Target) const;
|
|
std::vector<TTrack *> link_tracks(editor_track::snap_target const &Target, editor_track::branch_link const &Link, TTrack const &Style, std::vector<std::pair<TTrack *, editor_track::state>> &States, std::vector<TTrack *> &Created);
|
|
bool cut_straight(editor_track::straight const &Line, double const From, double const To, std::vector<std::pair<TTrack *, editor_track::state>> &States, std::vector<TTrack *> &Created, std::vector<TTrack *> &Removed, TTrack **Style);
|
|
// where a slip or a crossing goes for the cursor at Point on the straight Line: the crossing of Line with the rail track
|
|
// nearest the cursor, or the double slip there to be replaced. With no track crossing there and Side given (1 to the left, -1 to
|
|
// the right of Line), the slip brings the crossing track along at its own angle, turning off to that side ahead
|
|
struct slip_plan
|
|
{
|
|
std::string problem;
|
|
std::string note;
|
|
bool lone{false}; // no track crosses Line by the cursor
|
|
TTrack *replaces{nullptr};
|
|
TTrack *other{nullptr}; // the crossing track, none where the slip brings it along
|
|
glm::dvec2 crossing{0.0};
|
|
glm::dvec2 first{0.0, 1.0};
|
|
glm::dvec2 direction{0.0, 1.0};
|
|
double angle{0.0};
|
|
double alongfirst{0.0};
|
|
double half{0.0};
|
|
// where the slip brings its crossing track along: from the crossing to the joints of its template, past the frogs of the diamond,
|
|
// the straights of both tracks laid out that far; the ends of the straights there, in the order of the points
|
|
double reach{0.0};
|
|
std::array<glm::dvec3, 4> ends{};
|
|
editor_track::slip_curve curve;
|
|
std::array<glm::dvec3, 4> points{};
|
|
};
|
|
bool plan_double_slip(editor_track::straight const &Line, glm::dvec3 const &Point, editor_track::switch_template const &Shape, slip_plan &Plan, int const Side = 0) const;
|
|
// a slip is made for its skos: where the tracks cross at another one, the refusal, which tells the template made for theirs; empty
|
|
// where it fits, and for a crossing
|
|
std::string slip_skew(editor_track::switch_template const &Shape, double const Angle) const;
|
|
// the cursor where it points at the straight, at the height of the straight there
|
|
glm::dvec3 cursor_on_straight(editor_track::straight const &Line) const;
|
|
bool insert_double_slip(editor_track::straight const &Line, glm::dvec3 const &Point, editor_track::switch_template const &Shape, int const Side = 0);
|
|
// the side a slip dragged out on a straight with no track crossing it brings its crossing track to: the one through the quarter of
|
|
// the cursor
|
|
int lone_slip_side() const;
|
|
bool replace_double_slip(TTrack &Part, editor_track::switch_template const &Shape);
|
|
// Bend: what a path of the slip laid out as on straights turns into where it's bent into a curve
|
|
std::vector<TTrack *> build_double_slip(glm::dvec3 const &PointA, glm::dvec3 const &PointB, glm::dvec3 const &PointC, glm::dvec3 const &PointD, glm::dvec2 const &Crossing, double const Height, glm::dvec2 const &First, glm::dvec2 const &Second, double const Angle, editor_track::slip_curve const &Curve, TTrack &Style, std::string const &Type = "Rkpd",
|
|
std::function<segment_data(segment_data const &)> const &Bend = {});
|
|
// a slip switch bent into a curve of a side track (ST-T1-A6 11.4 pkt 4b): laid out on the tangent to the curve at its crossing, where
|
|
// it was pressed, and bent onto the curve as a switch laid into it is, its crossing track coming along with its ends free. Direction
|
|
// and Side as of a switch dragged into a curve: the crossing track goes ahead to that side, through the quarter of the cursor, and the
|
|
// slip curve of a single slip lies on that side
|
|
struct curved_slip
|
|
{
|
|
std::string problem;
|
|
std::string snapped; // what the ends of the slip were drawn to
|
|
double middle{0.0}; // the station of the crossing along the curve
|
|
double half{0.0}; // from the crossing to the ends of the slip
|
|
double reach{0.0}; // from the crossing to the joints of the template, the straights of both tracks laid out that far
|
|
int direction{1};
|
|
double angle{0.0};
|
|
editor_track::slip_curve curve;
|
|
// as the slip is laid out on the tangent, before it's bent: its crossing, its tracks going Direction along the curve, its ends
|
|
glm::dvec2 crossing{0.0};
|
|
glm::dvec2 first{0.0, 1.0};
|
|
glm::dvec2 second{0.0, 1.0};
|
|
std::array<glm::dvec3, 4> points{};
|
|
};
|
|
bool plan_curved_slip(editor_track::switch_template const &Shape, int const Direction, int const Side, curved_slip &Plan) const;
|
|
// the path of the slip laid out on the tangent, bent onto the curve
|
|
segment_data bent_slip_path(curved_slip const &Plan, segment_data const &Path) const;
|
|
// the two tracks through the slip and its slip curves, each from end to end, bent: the first track, the slip curve leaving it at its
|
|
// start, the second track, the other slip curve of a double slip
|
|
std::vector<segment_data> curved_slip_lines(curved_slip const &Plan, std::string const &Type) const;
|
|
// the straights of both tracks from the ends of the slip out to the joints of the template, bent
|
|
std::vector<segment_data> curved_slip_reaches(curved_slip const &Plan) const;
|
|
switch_curve::slip_report curved_slip_report(curved_slip const &Plan, std::string const &Type) const;
|
|
// the radii of the slip and its cant, as the view and the status tell them
|
|
static std::vector<std::string> slip_report_lines(switch_curve::slip_report const &Report);
|
|
void insert_curved_slip(int const Direction, int const Side);
|
|
bool start_extend(editor_track::snap_target const &End);
|
|
void finish_extend();
|
|
std::vector<segment_data> extend_pieces() const;
|
|
// the same for the track shown while it's dragged: its grade line fitted on the thread of the fitter, the frame not waiting for it
|
|
std::vector<segment_data> extend_preview() const;
|
|
// the free end of the path as the start of a new track; false if it isn't free or has no direction
|
|
static bool free_end(TTrack &Track, int const Path, bool const Atend, extend_tool &Tool);
|
|
// the free end new pieces are added at: the selected point if it's one, else the end, else the start
|
|
bool chosen_free_end(extend_tool &Tool);
|
|
// adds a straight (Side 0) or a curve to the left (1) or the right (-1) at the free end of the selected track
|
|
void extend_add(int const Side);
|
|
void render_extend_ui();
|
|
using track_layout = editor_track::layout;
|
|
// the shape dragged from a free end, as the mode of laying has it: a straight in the one of the straights, an arc and a straight in
|
|
// the one of a curve
|
|
track_layout m_track_layout{track_layout::straight};
|
|
double m_join_radius{0.0};
|
|
int m_join_variant{0};
|
|
TTrack const *m_join_track{nullptr};
|
|
editor_track::point_ref m_join_point;
|
|
mutable alignment::join_result m_join_last;
|
|
// the layout laid on from the end of From with the transition curves of the norms; none where it doesn't fit
|
|
std::optional<alignment::lay_result> eased_layout(TTrack const *From, glm::dvec3 const &Point, glm::dvec2 const &Direction, glm::dvec3 const &Target, double const Radius) const;
|
|
mutable std::optional<alignment::lay_result> m_eased_last;
|
|
mutable std::optional<std::pair<alignment::lay_request, std::optional<alignment::lay_result>>> m_eased_cache;
|
|
bool track_wheel(double const Offset);
|
|
// a touchpad sends fractions of a notch: a choice moves a step for each whole notch gathered, and only one in a gesture when
|
|
// Gesture; a pause, another key or the other way starts over
|
|
struct wheel_state
|
|
{
|
|
double rest{0.0};
|
|
double time{-10.0};
|
|
int keys{0};
|
|
bool spent{false};
|
|
};
|
|
wheel_state m_wheel;
|
|
int wheel_step(double const Offset, bool const Gesture);
|
|
std::string track_shaping(bool const Joined) const;
|
|
double design_speed(TTrack const *From, TTrack const *To) const;
|
|
// the track whose speed the design takes, none where it's the one set for the laying
|
|
TTrack const *speed_track(TTrack const *From, TTrack const *To) const;
|
|
// the tracks the laying under way goes on from and to
|
|
std::pair<TTrack const *, TTrack const *> laying_ends() const;
|
|
std::string design_speed_of(TTrack const *From, TTrack const *To) const;
|
|
// what ST-T1-A6 says of the sudden changes of the cant deficiency right behind a switch the pieces laid come out of at Start (From),
|
|
// or go into at End (To): of the end of its curve and the first sudden change of the pieces (9.11, tables 9.15, 9.16)
|
|
std::vector<std::string> switch_exit_warnings(TTrack const *From, glm::dvec3 const &Start, TTrack const *To, glm::dvec3 const &End, std::vector<segment_data> const &Pieces) const;
|
|
void give_own_speed(std::vector<TTrack *> const &Created) const;
|
|
std::vector<segment_data> join_pieces(TTrack const *From, editor_track::point_ref const &Frompoint, glm::dvec3 const &Start, glm::dvec2 const &Direction, editor_track::snap_target const &End, double &Length,
|
|
std::string &Error) const;
|
|
double m_extend_length{25.0};
|
|
double m_extend_radius{300.0};
|
|
bool extend_snap(editor_track::snap_target &Target) const;
|
|
void update_build_tools();
|
|
void draw_build_overlay() const;
|
|
// the joint before the blades of the switch being placed or the one selected and the tips of its blades
|
|
void draw_blade_tips() const;
|
|
// modes of the track editor, one at a time: path is the plain selection
|
|
using track_tab = editor_track_tab;
|
|
struct track_mode
|
|
{
|
|
char const *label;
|
|
char const *key;
|
|
track_tab tab;
|
|
char const *tooltip;
|
|
editor_icons::icon picture;
|
|
int family; // 0 builds the track, 1 equips it, 2 checks it
|
|
};
|
|
static std::array<track_mode, 16> const &track_modes();
|
|
bool track_plan_tab() const { return m_track_tab == track_tab::straights || m_track_tab == track_tab::route; }
|
|
// a tool of the station: they share its schematic
|
|
bool srk_tab() const { return m_track_tab == track_tab::station || m_track_tab == track_tab::station_signals || m_track_tab == track_tab::line_block; }
|
|
track_tab plan_tab_for(TTrack const *Track) const;
|
|
// the objects along the track: a tab for each tool
|
|
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_a{0.0};
|
|
double quick_b{0.0};
|
|
int fit_kind{3}; // of switch_design::tangent_fit
|
|
double quick_first{0.0}; // the radius of the first arc of an arc, a straight and an arc, 0: the R
|
|
bool picking{false}; // the switch clicked off the view, the orthophoto under it
|
|
std::vector<glm::dvec3> clicks;
|
|
bool on_view{true}; // the template shown in the view where its first points were clicked
|
|
switch_design::design measured; // what the points clicked so far make
|
|
bool measured_ready{false};
|
|
std::string measured_text;
|
|
int pointed{-1}; // the value under the mouse, its dimension shown on the drawing
|
|
int pointed_test{-1};
|
|
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();
|
|
void switch_designer_click(glm::dvec3 const &Point);
|
|
void switch_designer_measure();
|
|
void switch_designer_finish();
|
|
void draw_switch_designer_clicks() const;
|
|
void draw_cursor_ring(glm::dvec3 const &Point) const;
|
|
static std::string grade_line_key(TTrack const &Track);
|
|
static std::string grade_line_key(std::string const &Name, TTrack const &Track);
|
|
static void move_path_heights(segment_data &Path, double const First, double const Second, std::function<void(segment_data &)> const &After = {});
|
|
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();
|
|
// the track tools in the tool options window, and the selected path in the inspector
|
|
void render_track_tool_options();
|
|
void render_track_selection();
|
|
// the inspector with no track selected: in an empty scenery the one thing to do first, the first steps of the tutorial under it
|
|
void render_track_nothing_selected();
|
|
void show_track_tab(track_tab const Wanted) override;
|
|
bool track_analysis_tab() const { return m_track_tab == track_tab::profile || m_track_tab == track_tab::speed || m_track_tab == track_tab::joints || m_track_tab == track_tab::norms || m_track_tab == track_tab::infra; }
|
|
bool track_shortcut(int const Key);
|
|
bool track_busy() const; // something going on in the mode, which Esc drops before it leaves the mode
|
|
std::string track_mode_name() const;
|
|
void render_turnout_ui();
|
|
void render_switch_drive(TTrack &Switch, bool const Double);
|
|
struct track_name_edit
|
|
{
|
|
TTrack const *track{nullptr};
|
|
std::string synced;
|
|
char text[128]{};
|
|
editor_track::name_uses uses;
|
|
std::string status;
|
|
};
|
|
track_name_edit m_track_name;
|
|
void render_track_name(TTrack &Track);
|
|
void render_straight_ui();
|
|
track_tab m_track_tab{track_tab::path};
|
|
void delete_selected_track();
|
|
// the switch thrown over to its other path in the editor, its blades going over as in the simulation; the scenery keeps no state of it
|
|
void throw_switch(TTrack &Switch);
|
|
// the blades of the switches thrown in the editor moved on by the time of the frame: the time of the simulation stands still in it
|
|
void move_thrown_switches();
|
|
std::vector<TTrack *> m_thrown_switches;
|
|
std::string designs_trimmed(std::vector<TTrack *> const &Removed);
|
|
void start_straight_gesture(int const Tool);
|
|
void finish_straight_gesture();
|
|
void toggle_straight_set(TTrack &Track);
|
|
struct key_hint
|
|
{
|
|
char const *key;
|
|
std::string action;
|
|
char const *raw{nullptr}; // the key before it's translated, its gesture drawn from it
|
|
};
|
|
std::vector<key_hint> track_key_hints(bool const All) const;
|
|
// the keys and the actions of the hints in the language of the editor, the keys as they were kept for their pictures
|
|
static std::vector<key_hint> translated_hints(std::vector<key_hint> Hints);
|
|
// the card of the tool in use, the same in every field of work: its icon, name, family and key in its title row; unfolded, what
|
|
// it's for, how the mouse and the keys drive it and the link to all the shortcuts. Folded to its title row unless the user opened
|
|
// it, as the settings of the editor keep it for all the tools: the gestures are in the strip under the view as well
|
|
struct tool_card
|
|
{
|
|
editor_icons::icon picture{editor_icons::icon::count};
|
|
std::string name;
|
|
int family{0};
|
|
char const *key{nullptr};
|
|
char const *tooltip{nullptr}; // what the tool is for, untranslated
|
|
bool told_over{false}; // what it's for only over the title, not under it as well: there it pushed the settings down
|
|
std::vector<key_hint> hints; // translated
|
|
};
|
|
void render_tool_card(tool_card const &Card);
|
|
// the card of the track tool in use
|
|
void render_track_guide();
|
|
// a tool of the surroundings, the roads or the terrain: its button in the toolbar and its card in the tool options, the texts
|
|
// untranslated
|
|
struct section_tool
|
|
{
|
|
editor_icons::icon picture;
|
|
char const *label;
|
|
char const *key;
|
|
char const *tooltip;
|
|
std::vector<key_hint> hints;
|
|
};
|
|
static section_tool const &surroundings_tool(nodebank_panel::edit_mode const Mode);
|
|
section_tool road_tool_entry(int const Tool) const;
|
|
static section_tool const &terrain_tool_entry(terrain_tool const Tool);
|
|
void render_section_card(section_tool const &Tool);
|
|
// the card of the tool of the surroundings, the roads or the terrain in use, on top of its tool options
|
|
void render_surroundings_card();
|
|
void render_road_card();
|
|
void render_terrain_card();
|
|
std::string track_readout() const;
|
|
void draw_track_hints();
|
|
// a scenery with no tracks yet: in the middle of the view, how the first one is laid
|
|
void draw_empty_scenery_hint();
|
|
// path under the cursor, outlined before a click so it's known which one the click takes
|
|
track_hover m_hover;
|
|
track_hover track_under_cursor(TTrack const *Only = nullptr, float const Pixels = 0.0f) const;
|
|
track_hover split_spot() const;
|
|
void update_track_hover();
|
|
void draw_track_lines() const;
|
|
mutable std::size_t m_track_lines_drawn{0}; // the paths draw_track_lines drew in the last frame, for the self-test
|
|
// what the colours of the tracks in the view tell
|
|
enum class track_colouring { plain, radius, speed, grade };
|
|
track_colouring m_track_colouring{track_colouring::plain};
|
|
void draw_track_legend() const;
|
|
// the radii and lengths of the curves and the names and types of the switches written by them, from above, as on a plan
|
|
bool m_track_labels{true};
|
|
void draw_track_labels() const;
|
|
void draw_track_hover() const;
|
|
struct track_intent
|
|
{
|
|
enum class kind { none, gizmo, select, point, box, straight_set, straight_break, detour, straight_tool, straight_handle, route_vertex, route_grip, switch_at, switch_free, lay, lay_end, sweep, turntable_place, turntable_exit, turntable_fit, spread, extend_end, signal_place, signal_move, signal_read, switch_slide, pick_style, grade_line_pick, fouling, measure, route_trace, kilometrage, srk_boundary, srk_joint };
|
|
kind what{kind::none};
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
editor_track::point_ref point;
|
|
int index{-1};
|
|
glm::dvec3 position{0.0};
|
|
editor_track::snap_target snap;
|
|
std::string action;
|
|
};
|
|
track_intent m_intent;
|
|
// the measure between two points (M): on the ground, at a free end or on the axis of the track under the cursor
|
|
struct tape_state
|
|
{
|
|
bool active{false};
|
|
std::vector<glm::dvec3> points;
|
|
glm::dvec3 mouse{0.0};
|
|
};
|
|
tape_state m_tape;
|
|
void tape_update();
|
|
std::string tape_readout() const;
|
|
void draw_tape() const;
|
|
track_intent track_intent_at(int const Mods);
|
|
bool track_gesture_on() const;
|
|
void update_track_intent();
|
|
void track_press(track_intent const &Intent);
|
|
void turntable_press(track_intent const &Intent);
|
|
track_intent turntable_intent(glm::dvec3 const &Ground, bool const Shift);
|
|
void draw_track_intent() const;
|
|
editor_track::snap_target snap_free_end(glm::dvec3 const &Near, glm::vec2 const &Screen, TTrack const *Self, int const Category, std::vector<TTrack const *> const &Exclude) const;
|
|
void draw_free_ends(TTrack const *Self, int const Category, std::vector<TTrack const *> const &Exclude) const;
|
|
// the free ends of the rail tracks around the camera, looked for again after an edit or once the camera leaves the place
|
|
struct free_end_cache
|
|
{
|
|
int edits{-1};
|
|
glm::dvec3 centre{0.0};
|
|
double reach{0.0};
|
|
std::vector<glm::dvec3> points;
|
|
};
|
|
mutable free_end_cache m_free_end_cache;
|
|
std::vector<glm::dvec3> const &free_end_points(glm::dvec3 const &Centre, double const Reach) const;
|
|
struct point_drag
|
|
{
|
|
bool active{false};
|
|
bool moved{false};
|
|
glm::vec2 from{0.f};
|
|
double height{0.0};
|
|
std::size_t step{0};
|
|
};
|
|
point_drag m_point_drag;
|
|
struct handle_drag
|
|
{
|
|
bool active{false};
|
|
bool moved{false};
|
|
glm::vec2 from{0.f};
|
|
double height{0.0};
|
|
glm::dvec3 offset{0.0};
|
|
glm::dvec3 position{0.0};
|
|
};
|
|
handle_drag m_handle_drag;
|
|
void handle_drag_start(glm::dvec3 const &Anchor);
|
|
// Ground: the handle goes onto the ground, at the height of the ballast of the track, unless Shift is held
|
|
bool handle_drag_step(glm::dvec3 &Position, TTrack const *Ground = nullptr);
|
|
void point_drag_start(editor_track::point_ref const &Point);
|
|
void point_drag_update();
|
|
void point_drag_finish();
|
|
bool route_hit(int &Vertex, int &Grip) const;
|
|
int straight_handle_hit();
|
|
bool switch_reach(glm::dvec3 const &Ground, glm::dvec3 &Point);
|
|
glm::dvec3 cursor_ground() const;
|
|
glm::dvec3 cursor_level(double const Height) const;
|
|
glm::dvec3 cursor_terrain(double const Height);
|
|
double bed_height(glm::dvec3 const &Point, glm::dvec2 const &Direction, TTrack const *Style) const;
|
|
double nearby_ground(glm::dvec3 const &Point) const;
|
|
static std::pair<double, double> trackbed(TTrack const *Style);
|
|
std::vector<double> bed_heights(std::vector<glm::dvec3> const &Points, std::vector<glm::dvec2> const &Directions, TTrack const *Style) const;
|
|
void follow_ground(std::vector<segment_data> &Pieces, double const Height0, double const Grade0, double const Height1, double const Grade1, TTrack const *Style) const;
|
|
ground_follow::grading laying_grading(TTrack const *Style) const;
|
|
// the grade lines of the tracks shown while they're laid are fitted on a thread of their own, not to hold up the frames
|
|
mutable ground_follow::fitter m_fitter;
|
|
mutable bool m_follow_preview{false};
|
|
glm::dvec3 lay_bed(glm::dvec3 const &Point);
|
|
std::optional<glm::dvec3> m_cursor_override;
|
|
bool sweep_grabs(glm::dvec3 const &Point);
|
|
// menu of the path a click of the right mouse button lands on
|
|
struct track_context
|
|
{
|
|
track_hover target;
|
|
std::chrono::steady_clock::time_point pressed;
|
|
glm::vec3 angle{0.f};
|
|
glm::vec2 mouse{0.f};
|
|
bool armed{false};
|
|
bool pending{false};
|
|
};
|
|
track_context m_track_context;
|
|
void track_context_press();
|
|
void track_context_release();
|
|
void render_track_context();
|
|
void split_track_at(TTrack &Track, glm::dvec3 const &Point);
|
|
void focus_track(TTrack &Track, int const Path, glm::dvec3 const &Point) override;
|
|
// the camera flies over Duration seconds to the place Distance back from the target along Look, looking along it
|
|
void fly_to(glm::dvec3 const &Target, glm::dvec3 const &Look, double const Distance, double const Duration = 0.6) override;
|
|
// paths found by their names
|
|
struct track_search
|
|
{
|
|
char text[64]{};
|
|
std::string searched;
|
|
std::vector<TTrack *> found;
|
|
std::size_t total{0};
|
|
bool focus{false};
|
|
};
|
|
track_search m_track_search;
|
|
void render_track_search();
|
|
// paths selected together: Shift+LMB adds or takes one out, Shift+drag adds those in the box
|
|
std::vector<TTrack *> m_track_set;
|
|
struct track_box
|
|
{
|
|
bool active{false};
|
|
bool replace{false}; // the tracks in the box become the selection, else they join it
|
|
glm::vec2 from{0.f};
|
|
glm::vec2 to{0.f};
|
|
TTrack *hovered{nullptr};
|
|
};
|
|
track_box m_track_box;
|
|
glm::mat4 m_track_set_gizmo{1.0f};
|
|
bool m_track_set_using{false};
|
|
glm::dvec3 m_track_set_pivot{0.0};
|
|
std::vector<std::pair<TTrack *, std::vector<editor_track::joint>>> m_track_set_joints;
|
|
bool in_track_set(TTrack const *Track) const;
|
|
// the track is selected: alone or in the set
|
|
bool track_selected(TTrack const *Track) const;
|
|
// a click in the view: the track under the cursor becomes the selection, or nothing
|
|
void track_click_select(TTrack *Hovered);
|
|
bool track_set_begin(bool const Rotate);
|
|
void track_set_turn(double const Angle);
|
|
void track_set_move(glm::dvec3 const &Offset);
|
|
void track_set_end();
|
|
glm::dvec3 track_set_centre() const;
|
|
void track_set_toggle(TTrack &Track);
|
|
void track_set_prune();
|
|
void start_track_box(bool const Replace = false);
|
|
void finish_track_box();
|
|
void draw_track_set() const;
|
|
void render_track_set_ui();
|
|
void render_track_set_gizmo();
|
|
void track_set_delete();
|
|
struct track_spread
|
|
{
|
|
int stop{0};
|
|
bool same_rails{false};
|
|
bool same_bed{false};
|
|
bool same_speed{false};
|
|
float reach{0.f};
|
|
TTrack const *from{nullptr};
|
|
int signature{-1};
|
|
std::vector<TTrack *> preview;
|
|
double length{0.0};
|
|
};
|
|
mutable track_spread m_spread;
|
|
std::vector<TTrack *> track_spread_from(TTrack &Start) const;
|
|
std::vector<TTrack *> const &track_spread_preview(TTrack &Start) const;
|
|
void track_spread_apply(TTrack &Start);
|
|
void track_set_grow();
|
|
void render_track_spread_ui();
|
|
void draw_track_spread() const;
|
|
// the properties of the selected tracks in the inspector, one sheet for one track and for many; see editormodetrackprops.cpp
|
|
// the set when there's one, the selected track otherwise
|
|
std::vector<TTrack *> selected_tracks();
|
|
void select_tracks(std::vector<TTrack *> const &Tracks);
|
|
// changes each track which can be changed, in one step of the undo; false from Change: the track stays as it was
|
|
std::size_t tracks_apply(std::vector<TTrack *> const &Tracks, std::function<bool(TTrack &)> const &Change, bool const Rebuild, char const *What);
|
|
// the model of the timbers, with the fastenings where it has them, set on all the switches and crossings of the scenery, in one
|
|
// step of the undo; empty: the one of eu07.ini. returns: the tracks changed
|
|
std::size_t set_switch_timbers(std::string const &Model);
|
|
int track_property_index(std::string const &Key) const;
|
|
std::size_t track_property_apply(int const Property, std::vector<TTrack *> const &Tracks, std::string const &Text);
|
|
void track_field_finish();
|
|
void track_field_settle();
|
|
void track_textures_scan();
|
|
// a texture in use, offered first in the picker
|
|
struct texture_use
|
|
{
|
|
material_handle material{null_handle}; // null: its image is read by the name
|
|
std::string name;
|
|
int count{0}; // shown on its tile, 0: nothing
|
|
std::string note; // what's said of it above the tiles
|
|
};
|
|
// what the picker of a texture offers besides every texture of the folder
|
|
struct texture_offer
|
|
{
|
|
char const *title; // the heading of the ones in use
|
|
std::function<std::vector<texture_use>()> used; // gathered when the picker opens
|
|
char const *none; // the entry for no texture, nullptr: there's none
|
|
char const *none_name; // the name that entry gives
|
|
};
|
|
// every texture and material under the folder of the textures, read on the first use of the picker
|
|
void textures_index();
|
|
// the picker of a texture, in an open combo. returns: true when one is chosen, its name in Chosen
|
|
bool texture_picker(texture_offer const &Offer, std::string const &Current, bool const Mixed, std::string &Chosen);
|
|
// the same, of a texture of the rails (Kind 0) or of the trackbed (1)
|
|
bool track_texture_picker(int const Kind, std::string const &Current, bool const Mixed, std::string &Chosen);
|
|
// image of the texture of the name, 0 while there's none
|
|
std::uint64_t texture_image(std::vector<texture_use> const &Used, std::string const &Name);
|
|
std::uint64_t track_texture_image(int const Kind, std::string const &Name);
|
|
// a field of a texture: its image and its name, a click opens the picker, a material of the texture browser can be dropped on it.
|
|
// returns: true when another one was chosen, in Value
|
|
bool texture_field(char const *Label, float const Width, std::string &Value, texture_offer const &Offer);
|
|
// the same, for a name kept in a buffer
|
|
bool texture_field(char const *Label, float const Width, char *Buffer, std::size_t const Size, texture_offer const &Offer);
|
|
// the textures of the roads and junctions of the scenery
|
|
std::vector<texture_use> road_textures_used() const;
|
|
// the textures of the palette and of the water of the terrain; None: the entry for no texture of its own, nullptr: there's none
|
|
texture_offer terrain_texture_offer(char const *None);
|
|
void render_track_properties(std::vector<TTrack *> const &Tracks);
|
|
void render_track_set_header(std::vector<TTrack *> const &Tracks);
|
|
void render_track_select_tools(std::vector<TTrack *> const &Tracks);
|
|
void render_track_style(std::vector<TTrack *> const &Tracks);
|
|
void copy_track_style(TTrack const &Track);
|
|
std::size_t paste_track_style(std::vector<TTrack *> const &Tracks);
|
|
// which groups of the properties are pasted or put on the tracks by a preset, in the order of the groups of editormodetrackprops.cpp
|
|
using track_groups = std::array<bool, 12>;
|
|
// the values of the properties of the chosen groups put on the tracks, in one step of the undo. returns: the number of the
|
|
// tracks changed, none when no value is of the chosen groups
|
|
std::optional<std::size_t> apply_track_values(std::vector<std::pair<std::string, std::string>> const &Values, track_groups const &Groups, std::vector<TTrack *> const &Tracks, char const *What);
|
|
// presets of the properties of the tracks (editorTrackPresets), made from a track and put on the selected ones
|
|
void render_track_presets(std::vector<TTrack *> const &Tracks);
|
|
void render_track_presets_menu();
|
|
std::size_t apply_track_preset(int const Id, std::vector<TTrack *> const &Tracks);
|
|
std::vector<TTrack *> similar_tracks(int const Property, std::vector<TTrack *> const &Tracks) const;
|
|
// values of the properties over the selected tracks, each with the number of the tracks having it
|
|
struct track_values
|
|
{
|
|
std::size_t signature{0};
|
|
int generation{0};
|
|
int generation_seen{-1};
|
|
std::size_t history{0};
|
|
int frame{-100};
|
|
std::vector<std::vector<std::pair<std::string, int>>> values;
|
|
std::vector<std::size_t> applies;
|
|
std::size_t unsaved{0}; // of the tracks, changed since the file was written
|
|
};
|
|
track_values m_track_values;
|
|
// how the last value given in the sheet went: on how many tracks, and why not on the others
|
|
struct track_outcome
|
|
{
|
|
int property{-1};
|
|
std::string text;
|
|
bool refused{false}; // some tracks couldn't take it
|
|
std::size_t signature{0}; // of the tracks it was given to
|
|
std::size_t history{0};
|
|
double time{0.0};
|
|
};
|
|
track_outcome m_track_outcome;
|
|
// the lines under the rows of the sheet
|
|
struct track_note
|
|
{
|
|
enum class kind
|
|
{
|
|
typing,
|
|
done,
|
|
refused
|
|
};
|
|
int property{-1};
|
|
std::string text;
|
|
kind type{kind::done};
|
|
};
|
|
std::vector<track_note> m_track_notes;
|
|
// the field being typed in, with the tracks it was started on
|
|
struct track_field
|
|
{
|
|
int property{-1};
|
|
std::vector<TTrack *> tracks;
|
|
std::array<char, 256> text{};
|
|
std::string initial;
|
|
int frame{0};
|
|
};
|
|
track_field m_track_field;
|
|
std::array<std::vector<texture_use>, 2> m_track_textures; // of the rails, of the trackbed
|
|
std::vector<texture_use> m_texture_used; // the ones in use the open picker offers
|
|
std::array<char, 128> m_texture_filter{};
|
|
struct texture_index_entry
|
|
{
|
|
std::string name; // as the materials are named: relative to the folder of the textures, without the extension
|
|
std::string lowered;
|
|
bool material{false}; // there's a .mat file of the name
|
|
};
|
|
std::vector<texture_index_entry> m_texture_index; // sorted by the name
|
|
bool m_texture_indexed{false};
|
|
std::string m_texture_hovered; // the tile under the mouse in the picker, shown large above them
|
|
// properties taken from a track, to be set on the selected ones
|
|
struct track_style
|
|
{
|
|
std::string from;
|
|
std::vector<std::pair<std::string, std::string>> values;
|
|
// ticked at first by their groups: speed, environment, overhead line, track circuits, rails, trackbed, its shape, sleepers, ride and
|
|
// sound, frogs, sleeper placement, gauge (not by default: the gauge of the track pasted onto stays)
|
|
track_groups groups{false, false, false, false, true, true, true, true, false, true, true, false};
|
|
std::map<std::string, bool> ticks; // changed by hand, by the keys of the properties
|
|
bool picking{false}; // the next click on a track in the view takes its properties
|
|
bool reveal{false}; // its section of the inspector opens, a track having been taken
|
|
};
|
|
track_style m_track_style;
|
|
// a property of the track taken which the selected ones have otherwise
|
|
struct track_style_line
|
|
{
|
|
int property{-1};
|
|
std::string now; // as the selected tracks have it, or how many values they have
|
|
std::string taken; // as the track taken has it
|
|
std::size_t differ{0}; // of the selected tracks, the ones it changes
|
|
};
|
|
std::vector<track_style_line> track_style_lines(std::vector<TTrack *> const &Tracks);
|
|
bool track_style_takes(std::string const &Key) const;
|
|
struct track_presets_panel
|
|
{
|
|
int selected{0}; // id of the preset chosen in the inspector
|
|
int nameid{0}; // the preset whose name is in the field
|
|
char name[128]{};
|
|
};
|
|
track_presets_panel m_track_presets;
|
|
std::vector<std::vector<TTrack *>> m_track_similar;
|
|
TTrack const *m_track_list_hover{nullptr}; // in the list of the selected tracks
|
|
int m_track_list_hover_frame{-1};
|
|
using template_item = ::template_item;
|
|
using standing_template = ::standing_template;
|
|
// includes of the templates whose file names the test accepts, with the location in p2..p4 and the rotation in p5
|
|
std::vector<standing_template> standing_templates(std::function<bool(std::string const &)> const &Accept) const override;
|
|
struct switch_drive
|
|
{
|
|
standing_template standing;
|
|
int family{-1}; // -1: a drive not described for the editor, e.g. of Rainsted; it can be replaced, not turned over or moved
|
|
int index{-1};
|
|
};
|
|
std::optional<switch_drive> find_switch_drive(TTrack const &Switch, bool Wait = true);
|
|
// the drives standing in the scenery by the switch each is set to, read from the files once a frame for all the switches
|
|
std::map<std::string, switch_drive> const &switch_drives_standing(bool Wait = true);
|
|
struct drives_standing
|
|
{
|
|
std::map<std::string, switch_drive> by_switch;
|
|
int frame{-1};
|
|
int revision{-1}; // of the drives scanned
|
|
std::size_t instances{0};
|
|
};
|
|
std::optional<drives_standing> m_drives_standing; // emptied when an include changes
|
|
std::string missing_drive_variant(int const Family, bool const Rightswitch, bool const Driveright) const;
|
|
bool replace_switch_drive(TTrack &Switch, int Family, bool Flip);
|
|
void apply_switch_drive_choice(TTrack &Switch);
|
|
void switch_drive_captured(TTrack const &Track);
|
|
void switch_drives_committed(std::vector<TTrack *> const &Tracks);
|
|
// the drives of the switches deleted go with them, in the step of the undo history the deletion made last
|
|
void drives_deleted(std::vector<TTrack *> const &Switches);
|
|
// the file of a drive not described for the editor throwing one of the switches, empty when there's none; also one the editor
|
|
// kept beside a drive described for it
|
|
std::string undescribed_drive(std::vector<TTrack *> const &Switches);
|
|
// the drives of all the switches of the scenery set at the tips of their blades, the ones the earlier versions of the editor set at the
|
|
// joint before them too: once, as the scenery is opened, with no step of the undo history; how many moved
|
|
std::size_t drives_to_blade_tips();
|
|
bool m_drives_checked{false};
|
|
// the file of each variant of the drives scanned: its family and its index in the family
|
|
std::map<std::string, std::pair<int, int>, std::less<>> drive_variants() const;
|
|
// the switches a template of a drive throws, by what follows its first parameter in their names: "" for a variant described for the
|
|
// editor, and for any other template whose switch events throw the track named by its first parameter, as the drives of Rainsted do;
|
|
// "a".."d" for one of a double switch, whose switches are named <name>a..<name>d. none for a template which isn't a drive. the ones not
|
|
// described for the editor have no family (-1)
|
|
std::vector<std::string> const &drive_switches(std::string const &File, std::map<std::string, std::pair<int, int>, std::less<>> const &Variants);
|
|
std::map<std::string, std::vector<std::string>, std::less<>> m_drive_templates; // read once for each file
|
|
// a drive set to a switch the scenery hasn't got: left by a switch deleted or renamed by hand or in an earlier editor, its events
|
|
// throw nothing
|
|
struct stray_drive
|
|
{
|
|
scene::instance_handle instance{0};
|
|
std::vector<std::string> switches; // the names of the switches it throws, as its include gives them
|
|
std::string name; // of the switches missing from them
|
|
std::string file;
|
|
glm::dvec3 location{0.0};
|
|
};
|
|
// all the drives standing in the scenery, read from the files once while no include comes or goes
|
|
struct drives_named
|
|
{
|
|
std::vector<stray_drive> drives;
|
|
int revision{-1}; // of the drives scanned
|
|
std::size_t instances{0};
|
|
};
|
|
std::optional<drives_named> m_drives_named;
|
|
// the include of a drive or a template changed: what's kept of the drives standing is read again
|
|
void drives_changed();
|
|
// the drives whose switch isn't in the scenery, checked against the tracks each time
|
|
std::vector<stray_drive> stray_drives(bool Wait = false);
|
|
void render_stray_drives();
|
|
void draw_stray_drives();
|
|
scene::layer_handle output_layer(std::string const &Part) override;
|
|
// places them in the active layer or the given one, as one step of the undo. returns: how many were placed
|
|
std::size_t place_templates(std::vector<template_item> const &Items, std::string &Error, scene::layer_handle Layer = scene::layer_handle{}) override;
|
|
// moves them, as one step of the undo
|
|
std::size_t move_templates(std::vector<std::pair<standing_template, template_item>> const &Moves) override;
|
|
// takes them out, as one step of the undo
|
|
std::size_t remove_templates(std::vector<scene::instance_handle> const &Instances) override;
|
|
bool standing_signals(std::vector<standing_signal> &Signals, bool const Wait) override;
|
|
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) override;
|
|
std::string signal_templates_missing(std::vector<signal_order> const &Orders) override;
|
|
bool signal_heads(std::vector<signal_head> &Heads, bool const Wait) override;
|
|
std::string signal_mount(std::string const &Kind, std::string const &File) override;
|
|
std::size_t signal_reattach(std::vector<scene::instance_handle> const &Instances) override;
|
|
void select_signal(scene::instance_handle const Instance) override;
|
|
void render_signal_templates(std::vector<std::string> const &Kinds) override;
|
|
|
|
struct signal_template
|
|
{
|
|
std::string file;
|
|
std::string name;
|
|
std::string description;
|
|
std::string kind;
|
|
std::string mount;
|
|
std::string lamps;
|
|
std::string lean;
|
|
std::string read;
|
|
int parameters{0};
|
|
bool plate{false};
|
|
bool linked{false};
|
|
std::vector<int> speeds;
|
|
int aspects{0}; // of a block signal, 3 or 4
|
|
int arms{0}; // of a semaphore, 1 or 2, from its description
|
|
// m, of the zero of its model over the rail heads, from its description: where it stands by default
|
|
double height{0.0};
|
|
// m, how deep its model reaches under its zero, from its description: none, it isn't put on the ground
|
|
std::optional<double> depth;
|
|
// the aspects its description lists, by name (Sr1, Od2...) with the event giving each; empty for a template not described so
|
|
std::vector<std::pair<std::string, std::string>> aspect_events;
|
|
// 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;
|
|
};
|
|
// an indicator to put on a signal, a template described as one
|
|
struct indicator_template
|
|
{
|
|
std::string file;
|
|
std::string name;
|
|
std::string description;
|
|
std::string sign;
|
|
std::string place; // "head": under the lights of the signal, one under another; "foot": by its foot, the place in its model
|
|
std::vector<std::pair<std::string, std::string>> events;
|
|
};
|
|
struct signal_spot
|
|
{
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
glm::dvec3 axis{0.0};
|
|
glm::dvec2 travel{0.0, 1.0};
|
|
int side{1};
|
|
int list{2};
|
|
double offset{0.0};
|
|
glm::dvec3 position{0.0};
|
|
double yaw{0.0};
|
|
// the path and its list that read the signal: the track it stands by, or past the frog of a switch the track joined to the end
|
|
// of its path, which only the trains of that path run on
|
|
TTrack *reader{nullptr};
|
|
int reader_list{2};
|
|
};
|
|
struct signal_standing
|
|
{
|
|
standing_template include;
|
|
int kind{-1};
|
|
std::string name;
|
|
std::string read;
|
|
TTrack *track{nullptr};
|
|
int list{0};
|
|
// every path and list having the read, the first of them in track and list
|
|
std::vector<std::pair<TTrack *, int>> reads;
|
|
// the indicators put on it: named after it, at its foot, the highest first
|
|
std::vector<standing_template> indicators;
|
|
};
|
|
struct signal_tool
|
|
{
|
|
std::vector<signal_template> templates;
|
|
std::vector<indicator_template> indicators;
|
|
int revision{-1};
|
|
int kind{0};
|
|
std::array<int, 8> chosen{-1, -1, -1, -1, -1, -1, -1, -1};
|
|
bool armed{false}; // a click by a track places the chosen template
|
|
char filter[64]{};
|
|
char name[64]{"A"};
|
|
char plate[64]{};
|
|
std::array<char, 3> plate_index{}; // the speed index of the drawn plate, "4" or "12" for 1/2
|
|
bool plate_m{false}; // the drawn plate gets the "m" of a signal giving shunting signals too
|
|
char linked[64]{"none"};
|
|
float height{0.0f};
|
|
bool placing{false};
|
|
signal_spot press;
|
|
signal_spot press_raw; // where the press was, before it went to a round distance to the switch ahead
|
|
glm::vec2 pressed{0.f};
|
|
int facing{0};
|
|
std::vector<signal_standing> standing;
|
|
std::size_t standing_history{static_cast<std::size_t>(-1)};
|
|
double standing_time{-1.0};
|
|
int hover{-1};
|
|
scene::instance_handle selected{0};
|
|
bool moving{false};
|
|
glm::dvec2 grab{0.0};
|
|
signal_spot home;
|
|
bool home_valid{false};
|
|
signal_spot moved;
|
|
bool moved_valid{false};
|
|
// a click on a track gives the read of the signal selected to it
|
|
bool picking_read{false};
|
|
// the entry of the selected signal into the gauge of the paths around it, measured again as the history or the selection changes
|
|
struct
|
|
{
|
|
scene::instance_handle instance{0};
|
|
std::size_t history{static_cast<std::size_t>(-1)};
|
|
glm::dvec3 location{0.0}; // of the signal, which follows a dragged track without a new step of the history
|
|
gauge_tool::gauge_hit hit;
|
|
} gauge;
|
|
// the signal the gizmo has taken: as it stood then, the frame of its models, the size of the history before the step of the
|
|
// gizmo and the directives of its indicators
|
|
struct
|
|
{
|
|
scene::instance_handle instance{0};
|
|
signal_standing from;
|
|
glm::dmat3 frame{1.0};
|
|
std::size_t history{0};
|
|
std::vector<std::pair<scene::instance_handle, std::string>> directives;
|
|
} gizmo;
|
|
std::string status;
|
|
};
|
|
signal_tool m_signal;
|
|
// the way from the spot of a signal along its track to the switch the trains it faces come to first
|
|
track_trace::danger signal_danger(signal_spot const &Spot) const;
|
|
// the spot moved along its track to a round distance to the switch ahead, 50 m, 100 m..., when it's that near one; Alt leaves it
|
|
void signal_snap(signal_spot &Spot, signal_template const &Template) const;
|
|
// of the selected signal: the spot it stands at and the way to the switch ahead of it, kept until it or the history changes
|
|
struct signal_metre
|
|
{
|
|
scene::instance_handle instance{0};
|
|
std::size_t history{static_cast<std::size_t>(-1)};
|
|
glm::dvec3 location{0.0};
|
|
double yaw{0.0};
|
|
bool valid{false};
|
|
signal_spot spot;
|
|
track_trace::danger danger;
|
|
};
|
|
mutable signal_metre m_signal_metre;
|
|
signal_metre const &signal_metre_of(signal_standing const &Standing) const;
|
|
bool signal_scan(bool Wait = true);
|
|
signal_template const *signal_current() const;
|
|
signal_template const *signal_armed() const;
|
|
signal_template const *signal_template_of(std::string const &File) const;
|
|
// the template it is placed by: the one of its file if that is of its kind, else the one chosen for its kind. returns: nullptr if none
|
|
signal_template const *signal_template_for(signal_order const &Order) const;
|
|
bool signal_spot_at(TTrack &Track, int const Path, glm::dvec3 const &Point, glm::dvec3 const &Cursor, int const Facing, int const Side, signal_template const &Template, signal_spot &Spot) const;
|
|
void signal_refresh(bool const Force = false);
|
|
// the signals standing, read by the tracks as they are now, the templates as found so far
|
|
std::vector<signal_standing> signal_standing_now() const;
|
|
int signal_hit() const;
|
|
void signal_press(track_intent const &Intent);
|
|
void signal_release();
|
|
bool signal_place(signal_spot const &Spot, signal_template const &Template);
|
|
void signal_move_update();
|
|
// Moved: the signal moved from its track, the nearest track takes it if that's nearer by more than a little
|
|
bool signal_standing_spot(signal_standing const &Standing, signal_spot &Spot, bool const Moved = false) const;
|
|
bool signal_drop_at(signal_standing const &Standing, TTrack &Track, int const Path, glm::dvec3 const &Point, int const Side, signal_spot &Spot) const;
|
|
bool signal_move_to(signal_standing const &Standing, signal_spot const &Spot, char const *Read, char const *Unread);
|
|
indicator_template const *indicator_template_of(std::string const &File) const;
|
|
// the indicator put on the signal, named after it: under its lights below the ones there, or at its foot. returns: false if it can't be
|
|
bool signal_indicator_add(signal_standing const &Standing, indicator_template const &Indicator);
|
|
bool signal_indicator_remove(scene::instance_handle const Indicator);
|
|
// the indicators under the lights of the signal at Upper and Lower in its list, the highest first, swapped: each takes the place of the other
|
|
bool signal_indicators_swap(signal_standing const &Standing, std::size_t const Upper, std::size_t const Lower);
|
|
// the signal set the distance from the axis of its track in the plan and its height, raised over where it stands by default (over the rail heads, on a gantry), unless none
|
|
bool signal_set_across(signal_standing const &Standing, std::optional<double> const Offset, std::optional<double> const Height);
|
|
// the distance from the axis and the height over where it stands by default From has, carried to To, a spot of the same signal
|
|
// along its track: a signal set across or raised by hand keeps it as it is dragged or snapped
|
|
void signal_carry(signal_spot const &From, signal_spot &To, signal_template const &Template) const;
|
|
// the height of the zero of the model of a signal at Position by the track of the axis at Axis, as it stands by default: as far over
|
|
// the rail heads as its description gives, lower only where its bottom would hang over the ground; a gantry as high over the rails
|
|
// as chosen
|
|
double signal_default_height(signal_template const &Template, glm::dvec3 const &Axis, glm::dvec3 const &Position) const;
|
|
// how much higher the default height of To is than of From at Position by the track of the axis at Axis: what a signal given the
|
|
// template To in place of From goes up by, to stand as raised as it was
|
|
double signal_default_change(signal_template const &From, signal_template const &To, glm::dvec3 const &Axis, glm::dvec3 const &Position) const;
|
|
// the indicators of the signal moved after it to the place and the frame it has now, at the same place by it as they were, the
|
|
// directives they had going to Directives
|
|
void signal_indicators_follow(signal_standing const &Standing, glm::dmat3 const &Before, std::vector<std::pair<scene::instance_handle, std::string>> &Directives);
|
|
bool render_signal_indicators(signal_standing const &Found);
|
|
// the indicators put on the signal named Name standing at Location, as the scenery has them now, the highest first: the list of
|
|
// the tool is kept up only while the tool is open
|
|
std::vector<standing_template> signal_indicators_of(std::string const &Name, glm::dvec3 const &Location) const;
|
|
// the indicators of the signal named Before at Location named After it, the directives they had going to Directives once each
|
|
void signal_indicators_renamed(std::string const &Before, std::string const &After, glm::dvec3 const &Location, std::vector<std::pair<scene::instance_handle, std::string>> &Directives);
|
|
// the directives of more includes taken back by the step: one of a single include is made one of them
|
|
void history_add_directives(EditorSnapshot &Step, std::vector<std::pair<scene::instance_handle, std::string>> const &Directives);
|
|
// the signal of the selected include taken by the gizmo: its indicators go with it, and once it's let go it is moved as a drag of
|
|
// the signal tool moves it, read by the path it stands by then, out of the gauge, as one step of the history
|
|
void signal_gizmo_begin();
|
|
void signal_gizmo_step();
|
|
void signal_gizmo_end();
|
|
// the height of the lowest lamp of the signal in the world, from the geometry of its lamps; 0 when it has none
|
|
double signal_lowest_lamp(scene::instance_handle const Instance) const;
|
|
// the deepest entry of the models of the signal into the gauge of the paths around it
|
|
gauge_tool::gauge_hit signal_gauge(scene::instance_handle const Instance);
|
|
// the signal just placed or moved, at Local in its file, taken across away from the axis of each path whose gauge it enters, a few
|
|
// times at most, its directive changed with it. returns: the way it went, metres, and in Hit the entry it still makes
|
|
double signal_off_gauge(scene::instance_handle const Instance, std::string const &File, std::vector<std::string> &Values, glm::dvec3 Local, gauge_tool::gauge_hit &Hit);
|
|
// a sentence more to the status about it, none when the signal kept out of the gauge where it was put
|
|
void signal_gauge_note(std::string &Status, double const Shift, gauge_tool::gauge_hit const &Hit, bool const Gantry) const;
|
|
bool signal_flip(scene::instance_handle const Instance);
|
|
bool signal_turn(scene::instance_handle const Instance);
|
|
bool signal_swap(scene::instance_handle const Instance, std::string const &File);
|
|
// the signal set to the aspect in the editor, as its event sets it in the game: only how it looks, nothing saved
|
|
bool signal_show_aspect(scene::instance_handle const Instance, std::string const &Aspect, std::string const &Event);
|
|
signal_standing const *signal_standing_of(scene::instance_handle const Instance) const;
|
|
bool signal_delete(scene::instance_handle const Instance);
|
|
void signal_detach_events(std::string const &Read, std::vector<std::pair<TTrack *, editor_track::state>> &States);
|
|
// a track split in two: the reads of the signals placed since the scenery was opened, not bound yet, go to the piece by the signal
|
|
void signal_split(TTrack &Original, TTrack &Created);
|
|
// the list of a path the trains the signal faces read it from, as they run by the point of the path nearest to it
|
|
int signal_read_list(signal_standing const &Standing, TTrack const &Track, int const Path) const;
|
|
// the read of the signal in exactly these lists of these paths, as one step taken back by Ctrl+Z
|
|
bool signal_read_set(signal_standing const &Standing, std::vector<std::pair<TTrack *, int>> const &Reads);
|
|
// a click on a track while picking the path that reads the selected signal: its read goes there, or one more there with Add,
|
|
// or off it with Add when it's there already
|
|
bool signal_read_pick(TTrack &Track, int const Path, bool const Add);
|
|
std::string signal_read_label(TTrack const &Track, int const Path, bool const Add) const;
|
|
void signal_renamed(std::string const &Before, std::string const &After, EditorSnapshot &Snapshot);
|
|
// the plate a signal of this name gets when none is picked: one drawn by python/local/signal_plate.py with the given style
|
|
// ("look=toned", with "&index=12" and "&m=1" when it has them), or none for a name it can't carry
|
|
static std::string signal_plate(std::string const &Name, std::string const &Style);
|
|
// true for a plate signal_plate() gives, of any name and look
|
|
static bool signal_plate_drawn(std::string_view Plate);
|
|
static bool signal_plate_blank(std::string const &Name, std::string const &Plate);
|
|
static std::string signal_plate_text(std::string const &Name);
|
|
// what a drawn plate is drawn with but its name, kept through a rename; for one not drawn the look set in the editor
|
|
static std::string signal_plate_style(std::string const &Plate);
|
|
void signal_select(scene::instance_handle const Instance);
|
|
std::string signal_next_name(std::string const &Name) const;
|
|
void render_signal_ui();
|
|
void render_signal_palette();
|
|
void render_signal_selected();
|
|
// the paths reading the signal, each turned the other way or removed, a path picked or the one the editor gives. returns: true when they changed
|
|
bool render_signal_reads(signal_standing const &Found);
|
|
// of the signal selected: its template and another one for it, the aspects it can be set to; true when it got another one
|
|
bool render_signal_template(signal_standing const &Found, signal_template const &Item);
|
|
// the list of the templates the signal can take instead, Across those of another mount too: the file picked, empty for none
|
|
std::string signal_swap_combo(signal_template const &Item, bool const Across) const;
|
|
void render_signal_aspects(signal_standing const &Found, signal_template const &Item);
|
|
void draw_signal_overlay() const;
|
|
std::string signal_intent_label(signal_template const &Template, signal_spot const &Spot) const;
|
|
std::string signal_variant(signal_template const &Template, signal_spot const &Spot) const;
|
|
// what a deleted track carried and no other one took, its read events and track circuits, for a track laid in its place
|
|
struct orphan_record
|
|
{
|
|
TTrack *track{nullptr}; // retired; the record waits while it stays so
|
|
std::vector<std::pair<std::string, int>> events; // the name, the list it was on
|
|
std::vector<std::string> circuits;
|
|
// the tracks given the circuits: while one stays the circuits don't wait, once a step other than an undo removes one they
|
|
// are its own
|
|
std::vector<TTrack *> given;
|
|
bool fresh{false}; // made by the step being taken
|
|
};
|
|
std::vector<orphan_record> m_orphans;
|
|
std::string m_orphan_note; // shown by the cursor after the step which made it
|
|
void orphans_register(std::vector<TTrack *> const &Removed, std::vector<TTrack *> const &Kept);
|
|
// Created: made by the step, their circuits the ones of the tracks they were made from; Changed: the others it changed
|
|
void orphans_take_over(std::vector<TTrack *> const &Created, std::vector<TTrack *> const &Changed);
|
|
|
|
// a model laid along the track: bent to follow it, or repeated along it
|
|
struct sweep_tool
|
|
{
|
|
bool open{false};
|
|
bool expand{false};
|
|
char model[256]{};
|
|
char skin[128]{"none"};
|
|
char search[64]{};
|
|
std::vector<std::string> models;
|
|
bool scanned{false};
|
|
int revision{-1}; // of the include bank the templates were taken from
|
|
// parameters of a template laid along the track, with their names
|
|
std::string parameters_for;
|
|
std::vector<std::array<char, 128>> parameters;
|
|
std::vector<std::string> parameter_labels;
|
|
std::vector<bool> parameter_placement; // filled in with zeros: the template is placed in its own space
|
|
std::vector<std::vector<std::string>> parameter_choices; // variants of the textures a parameter is a part of the name of
|
|
int length_mode{2}; // 0: one copy as long as the original, 1: the length given, 2: the whole stretch of the line
|
|
double length{200.0};
|
|
sweep_node::state settings;
|
|
int axis{0}; // 0: the longer one of the model, 1: z, 2: x
|
|
double model_length{0.0};
|
|
std::string measured; // model the length is of
|
|
// the curve: the axis of the track
|
|
TTrack *curve_for{nullptr};
|
|
std::size_t curve_history{0};
|
|
struct piece
|
|
{
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
bool forward{true};
|
|
};
|
|
std::vector<piece> curve_pieces;
|
|
std::vector<segment_data> curve;
|
|
double curve_length{0.0};
|
|
std::vector<glm::dvec3> outline; // of the curve, for the preview
|
|
std::vector<double> stations;
|
|
// marking the stretch in the view: press where it starts, the distance from the track sets the offset, drag to the end
|
|
bool marking{false};
|
|
bool dragging{false};
|
|
double anchor{0.0}; // station the drag started at
|
|
sweep_node *edited{nullptr};
|
|
std::string status;
|
|
};
|
|
sweep_tool m_sweep;
|
|
// paths the models along curves were laid on, so they follow the changes of the paths
|
|
struct sweep_link
|
|
{
|
|
sweep_node *sweep{nullptr};
|
|
std::size_t piece{0};
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
bool reversed{false};
|
|
};
|
|
std::vector<sweep_link> m_sweep_links;
|
|
void sweep_curve();
|
|
void sweep_outline();
|
|
bool sweep_extend(bool const Atend, glm::dvec3 const &Cursor);
|
|
double sweep_station(glm::dvec3 const &Point, double &Lateral) const;
|
|
void sweep_scan_models();
|
|
void sweep_measure();
|
|
sweep_node::state sweep_definition() const;
|
|
void sweep_create();
|
|
void sweep_apply();
|
|
void sweep_delete(sweep_node &Sweep);
|
|
void sweep_edit(sweep_node &Sweep);
|
|
std::vector<sweep_node *> sweeps_near(TTrack const &Track) const;
|
|
bool sweep_press();
|
|
void sweep_drag();
|
|
void sweep_release();
|
|
// the same at a point of the world: Anywhere takes the press however far from the track it is
|
|
bool sweep_press_at(glm::dvec3 const &Point, bool const Anywhere);
|
|
void sweep_drag_at(glm::dvec3 const &Point);
|
|
void render_sweep_ui();
|
|
void draw_sweep_overlay() const;
|
|
void restore_sweeps(EditorSnapshot &Snapshot);
|
|
void sweeps_captured(TTrack const &Track);
|
|
void sweeps_committed(std::vector<TTrack *> const &Tracks);
|
|
void sweeps_split(TTrack &Original, TTrack &Created);
|
|
|
|
struct bend_source
|
|
{
|
|
TAnimModel *model{nullptr};
|
|
scene::instance_handle instance{0};
|
|
std::string file;
|
|
std::string skin{"none"};
|
|
std::vector<std::string> parameters;
|
|
glm::dmat4 transform{1.0};
|
|
glm::dvec3 scale{1.0};
|
|
scene::layer_handle layer{null_handle};
|
|
};
|
|
struct bend_tool
|
|
{
|
|
int axis{0};
|
|
bool turned{false};
|
|
int along_anchor{1};
|
|
int side_anchor{0};
|
|
int height_anchor{0};
|
|
glm::dvec3 point{0.0};
|
|
bool picking{false};
|
|
void const *tracks_for{nullptr};
|
|
glm::dvec3 tracks_at{0.0};
|
|
std::vector<std::pair<TTrack *, double>> tracks;
|
|
int track{0};
|
|
sweep_node *edited{nullptr};
|
|
std::string signature;
|
|
bool marker_valid{false};
|
|
glm::dvec3 marker{0.0};
|
|
std::string status;
|
|
int dragging{0}; // 1: the cross along and aside, 2: up, 3: only along, 4: the start of the model, 5: its end
|
|
sweep_node::state drag_state;
|
|
std::shared_ptr<sweep_node> drag_line; // the line as it was when the drag began
|
|
double drag_first{0.0}; // m along it, where the model began and ended then
|
|
double drag_last{0.0};
|
|
glm::dvec3 drag_anchor{0.0};
|
|
double drag_station{0.0};
|
|
std::string drag_label;
|
|
sweep_node *hover{nullptr};
|
|
bool over_marker{false};
|
|
int over_end{0}; // the handle under the cursor: 1 at the start of the model, 2 at its end
|
|
std::string label;
|
|
std::string details;
|
|
};
|
|
bend_tool m_bend;
|
|
bool bend_drag_start(int const Mods);
|
|
void bend_drag_update();
|
|
sweep_node *sweep_under(glm::dvec3 const &Point) const;
|
|
bool bend_click();
|
|
bool bend_shortcut();
|
|
bool bend_source_of_selection(bend_source &Source) const;
|
|
void bend_find_tracks(glm::dvec3 const &Point, void const *Key);
|
|
bool bend_definition(bend_source const &Source, TTrack &Track, sweep_node::state &State, std::vector<TTrack *> &Tracks);
|
|
void bend_selection();
|
|
void bend_edit(sweep_node::state const &State);
|
|
void bend_reanchor(sweep_node::state &State, int const Side, int const Height, glm::dvec3 const &Point) const;
|
|
double bend_fixed(sweep_node const &Sweep, glm::dvec3 const &Point) const;
|
|
void bend_stretch(sweep_node const &Sweep, double const Fixed, double const Length, glm::dvec3 const &Point, sweep_node::state &State) const;
|
|
// the model laid along another track: it stays where it stands, with its length
|
|
void bend_retrack(sweep_node const &Sweep, TTrack const &Track, sweep_node::state &State) const;
|
|
// the handles at the ends of the model, at the height and the side of its reference point
|
|
std::array<glm::dvec3, 2> bend_ends(sweep_node const &Sweep) const;
|
|
// a drag of the model begun: 1 the cross along and aside, 2 up, 3 only along, 4 the start, 5 the end
|
|
void bend_drag_begin(int const Kind);
|
|
// the end of the model taken to the point, the line lengthened through the tracks joined there; the length it has then
|
|
double bend_end_to(bool const Atend, glm::dvec3 const &Point, sweep_node::state &State) const;
|
|
std::string bend_selftest(std::string const &Command, std::istringstream &Words);
|
|
void sweep_relink(sweep_node const &Sweep);
|
|
void bend_pick(glm::dvec3 const &Point);
|
|
glm::dvec3 bend_marker(sweep_node const &Sweep) const;
|
|
void restore_bend(EditorSnapshot &Snapshot, bool const Undo);
|
|
void render_bend();
|
|
void draw_bend_overlay() const;
|
|
|
|
// script of editor actions given in the EU07_EDITOR_SELFTEST file, run a step at a time, for testing without a person
|
|
struct selftest
|
|
{
|
|
bool loaded{false};
|
|
std::vector<std::string> lines;
|
|
std::size_t next{0};
|
|
int wait{0};
|
|
bool quitting{false};
|
|
scripted_input input;
|
|
std::string badge; // the mouse or the keys drawn over the view, for the clips of the tutorial
|
|
glm::vec2 badge_at{0.0f}; // its bottom left corner, in the pixels of the window
|
|
std::map<std::string, double> marks; // the heights of the ends of tracks kept by mark, for expect lift
|
|
std::optional<std::pair<bool, bool>> terrain_kept; // the terrain made while laying, and the answer without it, before nmtquestion
|
|
};
|
|
selftest m_selftest;
|
|
using selftest_result = editor_selftest_result;
|
|
selftest_result selftest_scene(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_sleepers(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_sweep(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_track(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_switch(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_rails(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_join(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_signal(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_terrain(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_props(std::string const &command, std::istringstream &words);
|
|
selftest_result selftest_monkey(std::string const &command, std::istringstream &words);
|
|
// the expectations of the script, which make the run fail (editormodeselftestexpect.cpp)
|
|
selftest_result selftest_expect(std::string const &command, std::istringstream &words);
|
|
// the commands and the expectations of the editing through the model of the track geometry (editormodemodel.cpp)
|
|
selftest_result selftest_model(std::string const &command, std::istringstream &words);
|
|
|
|
// the track geometry edited through the model (editor-tracks-domain.md §3, §4, §8, §9; stage E4, editormodemodel.cpp), with the
|
|
// setting "Editing on the model (trial)" on: the project of the map opened with the scenery and written with it, a line laid by the
|
|
// lay tool or applied by the route design a line of the model, its tracks made by the generator and marked as its; the edits of such a
|
|
// line commands of the model, refused with the reasons or kept, one step of the history each; a line changed by hand written over only
|
|
// when the user says so; a track the scenarios name taken away only when the user says so. The old tracks stay as they are, edited by
|
|
// the old tools. Off, nothing of it runs
|
|
struct managed_track
|
|
{
|
|
layout::line_id line{layout::line_id::none};
|
|
std::size_t index{0}; // of the pieces of the line, from its start
|
|
std::string text; // its entry as written while it's as it was made: the generator's, or the file's it was read from
|
|
glm::dvec3 offset{0.0}; // of the placement the coordinates of the text are in
|
|
std::string baseline; // its own export as it was made: another one tells a change by the other tools
|
|
std::string kind{"track"}; // "switch": a switch track of a turnout, kept by the main track of the turnout (line)
|
|
std::size_t of{0}; // the tracks the line was made of with it: fewer of them there, the others were taken away by another tool
|
|
};
|
|
// how a run of commands goes on: the lines the user let write over, what's done after the last one
|
|
struct model_context
|
|
{
|
|
std::set<layout::line_id> overwrite;
|
|
std::string surface; // of the tracks made, else the one of the tracks of the line, else the lay tool's
|
|
std::function<void(std::vector<TTrack *> const &)> done; // with the tracks the last command made
|
|
std::vector<TTrack *> replaced; // old tracks the line made takes the place of, taken away in its step
|
|
bool joined{false}; // the step joined to the one before it: the commands of a batch after the first
|
|
};
|
|
// the project, the managed tracks, the question waiting for an answer, the scenario index (editormodemodel.cpp); made as it's needed
|
|
friend struct editor_model;
|
|
mutable std::unique_ptr<editor_model, editor_model_deleter> m_model;
|
|
editor_model &model() const;
|
|
// what the last command came to: refused, why; kept, what it did and what the norms tell of it
|
|
bool model_refused() const;
|
|
std::string model_message() const;
|
|
std::vector<std::string> model_notices() const;
|
|
std::string model_error() const;
|
|
void model_forget(scene::basic_node const *Node);
|
|
void model_plan_drop();
|
|
// the setting is on and the project of the map is open
|
|
bool model_on() const;
|
|
bool model_taken() const; // the setting as it was taken when the scenery was opened, for the session
|
|
// opens the project of the map once the scenery is there, and looks after the questions waiting for the scenario index
|
|
void model_update();
|
|
void model_open();
|
|
// the managed track, nullptr for an old one
|
|
managed_track const *model_track(TTrack const *Track) const;
|
|
// the tracks of the line in the scene, from its start
|
|
std::vector<TTrack *> model_line_tracks(layout::line_id const Line) const;
|
|
// the lines whose tracks were changed by the other tools since they were made
|
|
std::set<layout::line_id> model_seen_changed() const;
|
|
// the commands carried out one after another, each one step of the history: a refusal ends the run with its reasons, a line changed by
|
|
// hand asks first
|
|
void model_run(std::vector<layout::command> Commands, model_context Context);
|
|
// the tracks of the lines the command changed made again, those of the lines gone taken away: one step of the history with its token
|
|
std::vector<TTrack *> model_tracks_after(std::uint64_t const Token, layout::network const &Before, std::set<layout::line_id> const &Changed, std::set<layout::line_id> const &Removed, model_context const &Context);
|
|
void model_told(layout::outcome const &Outcome, bool const Refused, std::string const &What = {});
|
|
// the editor's step of a command taken back or brought again
|
|
void model_history(std::uint64_t const Token, bool const Undo);
|
|
// the save: the text of a managed track as made, the project written after the scenery
|
|
std::optional<std::string> model_path_text(TTrack const &Track, glm::dvec3 const &Offset);
|
|
void model_saved(bool const Success);
|
|
// the line the lay tool shows laid as a line of the model; false where it isn't one (not the straights, a curve the model doesn't lay
|
|
// yet), with why in Why, for the old way
|
|
bool model_lay(lay_line_plan const &Plan, editor_track::snap_target const &End, std::vector<TTrack *> &Created, std::string &Why);
|
|
// the route design open on the managed line, its curves as the model has them; its changes applied as commands of the model
|
|
bool route_from_model(layout::line_id const Line);
|
|
bool model_plan_apply();
|
|
// the route design applied to old tracks made a line of the model in their place, where the model lays it; false where it doesn't,
|
|
// with why in Why, for the old way
|
|
bool model_plan_convert(std::string &Why);
|
|
layout::line_id model_plan_line() const;
|
|
void render_model_plan();
|
|
// Del on a managed track takes its line away, a track the scenarios name goes only when the user says so; true: taken care of here
|
|
bool model_delete(TTrack *Track);
|
|
bool model_delete_set(std::vector<TTrack *> const &Tracks);
|
|
void model_delete_line(layout::line_id const Line);
|
|
// the tracks of the names go, or are renamed (Rename), only after the scenarios using the map are looked through, and the user says so
|
|
// where any names them
|
|
void model_check_users(std::vector<std::string> Names, std::function<void()> Then, bool const Rename = false);
|
|
// the track given the name (valid), as the inspector renames it: a name the scenarios use goes only when the user says so
|
|
void track_rename(TTrack &Track, std::string const &Name);
|
|
void render_model_windows();
|
|
std::string model_label(TTrack const *Track) const;
|
|
layout::network const &model_network() const;
|
|
// what the last command came to as the user reads it: the reasons and the notes of the norms in the language of the editor
|
|
std::string model_shown() const;
|
|
// a message of the model or of the norms, English as they make it, in the language of the editor
|
|
static std::string model_tr(std::string const &Text);
|
|
// the reasons of a refusal as the user reads them, the BLOCK limits of the norms of them formatted here
|
|
static std::string model_reasons_shown(layout::outcome const &Outcome);
|
|
static std::string model_notice_shown(layout::notice const &Notice);
|
|
|
|
// the turnouts of the lines of the model through the switch tool (editormodemodelturnout.cpp, stage E4b): the turnout whose track the
|
|
// managed track is, nullptr for none
|
|
layout::turnout const *model_turnout(TTrack const *Track) const;
|
|
// the type of the catalogue the template is of, empty for a template of the user's own
|
|
static std::string model_type_of(editor_track::switch_template const &Template);
|
|
// the line of the model one of the tracks of which runs through the point, within half a metre, and the chainage of the point on it
|
|
bool model_line_at(glm::dvec3 const &Point, std::vector<TTrack *> const &Tracks, layout::line_id &Line, double &Chainage) const;
|
|
// the turnout the switch dragged lays into a line of the model as it's let go now; none where it isn't dragged on a line of the model.
|
|
// Why: what keeps the template from being laid there
|
|
std::optional<layout::insert_turnout> model_switch_drag(std::string &Why) const;
|
|
std::optional<layout::insert_turnout> model_switch_command(std::vector<TTrack *> const &Tracks, glm::dvec3 const &Start, glm::dvec2 const &Heading, int const Side, editor_track::switch_template const &Shape, std::string &Why) const;
|
|
// the template armed laid as a turnout of the model, its start at the point running along the heading, its diverging track to the
|
|
// side (1 as the switch tool has it on the right); false where the point isn't on a line of the model, for the old way
|
|
bool model_switch_place(std::vector<TTrack *> const &Tracks, glm::dvec3 const &Start, glm::dvec2 const &Heading, int const Side);
|
|
// the switch dragged let go on a line of the model: laid as a turnout of the model, or refused; false for the old way
|
|
bool model_switch_finish();
|
|
bool model_switch_run(std::optional<layout::insert_turnout> const &Command, std::string const &Why);
|
|
void model_switch_done(std::vector<TTrack *> const &Created);
|
|
// the switch track of a turnout of the model moved along its line, given another template: true, taken care of here
|
|
bool model_switch_slide(TTrack &Switch, double const Distance);
|
|
bool model_switch_template(TTrack &Switch, editor_track::switch_template const &Shape);
|
|
void model_turnout_run(layout::command const &Command);
|
|
void model_turnout_remove(layout::turnout_id const Turnout);
|
|
// the crossover dragged between two lines of the model, as the solver of the connections plans it; false for the old way
|
|
bool model_connection();
|
|
// the first reason the switch dragged on a line of the model would be refused for as it's let go now, empty where it'd be laid
|
|
std::string model_switch_trial() const;
|
|
void render_model_turnout(TTrack &Track);
|
|
|
|
// the rest of the editing of a line of the model (editormodemodeledit.cpp, stage E4b): the line of the model the profile is open on from
|
|
// end to end, whether the route runs against it
|
|
layout::line_id model_profile_line(bool &Reversed) const;
|
|
// the profile opened on the whole line of the model of the track; false for an old track
|
|
bool model_profile_open(TTrack &Track);
|
|
// the grade line of the line of the model the profile is open on read from the model, applied as its command (set_grades)
|
|
void model_profile_load();
|
|
bool model_profile_apply();
|
|
// the curves of the line of the model open in the route design: one added at the chainage, one taken out
|
|
void model_vertex_add(double const Chainage);
|
|
void model_vertex_remove(std::size_t const Index);
|
|
void model_plan_reload(layout::line_id const Line);
|
|
void render_model_curves();
|
|
// the commands the changes of the route design come to, or why they can't be (English, model_tr shows it)
|
|
bool model_plan_commands(layout::line_id const Line, std::vector<layout::command> &Commands, std::string &Why) const;
|
|
// a handle of the route design dragged on a line of the model: tried as it goes, drawn by the line and the mouse
|
|
void model_plan_preview();
|
|
std::string model_plan_key() const; // the design of the route as the preview of the model was worked out for it
|
|
void draw_model_plan_preview() const;
|
|
bool m_model_delete_confirmed{false}; // the old delete let through, the scenarios looked through
|
|
selftest_result selftest_dispatch(std::string const &command, std::istringstream &words);
|
|
void selftest_step();
|
|
// a value typed during a gesture, taken instead of the one the cursor gives
|
|
std::string m_typed;
|
|
// what the typed value sets in the gesture under way, nullptr when the gesture takes none
|
|
char const *typed_meaning() const;
|
|
std::vector<double> typed_values() const;
|
|
bool typed_key(int const Key);
|
|
glm::dvec3 typed_lay(glm::dvec3 const &Mouse) const;
|
|
void typed_turn();
|
|
bool m_route_tab{true};
|
|
|
|
// vertical profile (grade line) along a route
|
|
struct profile_state
|
|
{
|
|
bool open{false};
|
|
TTrack *from{nullptr};
|
|
TTrack *to{nullptr};
|
|
TTrack *picked_from{nullptr};
|
|
TTrack *picked_to{nullptr};
|
|
double run_length{std::numeric_limits<double>::infinity()}; // the whole line through the track clicked
|
|
std::vector<TTrack *> followed; // the selection the route was last taken from
|
|
editor_track::route route;
|
|
std::vector<editor_track::route_sample> samples;
|
|
std::vector<TTrack *> created; // the paths the last apply split off the route
|
|
std::vector<double> terrain; // NaN where there's no terrain
|
|
std::vector<double> model; // the ground of the terrain model (NMT) as measured; NaN where it's not known
|
|
bool model_waiting{false}; // squares of the model under the route still to come
|
|
double model_polled{0.0};
|
|
// what the joined ends take their height and grade from, when it's a switch: shown on the plot
|
|
std::string start_inherits, end_inherits;
|
|
// depth of the formation under the grade line, the rail top, of the track of each sample: the formation, not the rails,
|
|
// lies on the ground
|
|
std::vector<double> beds;
|
|
profile::line line;
|
|
profile::context context;
|
|
std::vector<profile::issue> issues;
|
|
double origin{0.0}; // chainage of the start of the route
|
|
double departure{0.0}; // largest difference between the grade line and the track
|
|
profile::ground_fit fit;
|
|
// the heightmap terrain led to the grade line by a modifier: formation under the track, slopes down or up to the ground
|
|
struct earthworks
|
|
{
|
|
bool from_ballast{true};
|
|
double depth{0.7}; // m, formation below the top of the rail
|
|
double half_width{3.5}; // m, from the axis of the route to the edge of the formation
|
|
double slope{1.5}; // horizontal run of the slopes per metre of height
|
|
double reach{60.0}; // m, from the edge of the formation, where the slopes end even if they don't get to the ground
|
|
double rounding{1.5}; // m, over which the slopes bend into the formation and into the ground
|
|
bool generate{true};
|
|
// chunks of terrain made under the route by the last shaping
|
|
std::vector<std::pair<int, int>> generated;
|
|
// the modifier of the terrain made by the last shaping
|
|
std::string modifier;
|
|
} earthworks;
|
|
double view_from{0.0};
|
|
double view_to{100.0};
|
|
double view_centre{0.0};
|
|
float exaggeration{20.0f};
|
|
bool show_terrain{true};
|
|
bool show_model{true};
|
|
bool show_track{true};
|
|
bool show_plan{true};
|
|
bool whole_grade_line{true}; // applied, the tracks sharing the grade line of the route go with it
|
|
profile::line line_read; // the line before it was edited
|
|
bool fitting{false}; // the line comes from the fit to the terrain model: any error of it refuses it
|
|
std::vector<TTrack *> beside; // those of them lying by it, for the route and the state of the tracks below
|
|
std::tuple<TTrack const *, std::size_t, std::size_t, std::size_t> beside_of{nullptr, 0, 0, 0};
|
|
bool picking{false}; // a click on a track in the view puts it on the grade line of the route or takes it off
|
|
std::vector<TTrack const *> members; // of the grade line picked, wherever they are
|
|
std::tuple<int, std::size_t, std::size_t> members_of{-1, 0, 0};
|
|
int selected{-1};
|
|
int dragging{-1};
|
|
// where the point was grabbed: the mouse there, the point against the mouse; the point moves once the mouse does
|
|
ImVec2 drag_press{0.0f, 0.0f};
|
|
glm::dvec2 drag_grab{0.0};
|
|
bool drag_moved{false};
|
|
int curve_grip{-1};
|
|
bool panning{false};
|
|
bool changed{false};
|
|
double hover{-1.0};
|
|
// under the cursor in the strip
|
|
int hover_point{-1};
|
|
int hover_grip{-1};
|
|
bool hover_line{false};
|
|
int shown{-2}; // point in the side panel
|
|
bool show_remarks{false};
|
|
float strip_top{-1.0f}; // the top of the strip over the 3d view, -1 while it isn't shown
|
|
int edits{-1}; // of the tracks, when the route was last read
|
|
std::string status;
|
|
std::string error;
|
|
};
|
|
profile_state m_profile;
|
|
std::vector<stored_profile> m_profiles;
|
|
bool m_profiles_loaded{false};
|
|
void profile_library_load();
|
|
void profile_library_mark(std::vector<scene::layer_handle> Layers);
|
|
// the last step takes the kept grade lines back to the library given, as they were before it changed them
|
|
void profiles_to_history(std::vector<stored_profile> Library);
|
|
// the kept grade lines back to the library given, the step changing them given up before it went to the history
|
|
void profiles_restore(std::vector<stored_profile> Library);
|
|
// the tracks whose grade line was fitted, by name, with the shape they had then, kept as "//$t" comment lines: a track
|
|
// changed since, by hand or taken back, isn't fitted any more
|
|
struct fitted_mark
|
|
{
|
|
scene::layer_handle layer{null_handle};
|
|
std::uint64_t shape{0};
|
|
bool hand{false};
|
|
};
|
|
std::map<std::pair<std::string, std::uint64_t>, fitted_mark> m_fitted; // by the name and the shape: scenery files have names used twice
|
|
bool m_fitted_loaded{false};
|
|
void fitted_load();
|
|
void fitted_set(std::vector<TTrack *> const &Tracks, bool const Hand = false);
|
|
bool grade_fitted(TTrack const &Track);
|
|
bool grade_hand(TTrack const &Track); // its grade line was edited with the profile tool, and it wasn't changed since
|
|
bool nmt_stays(TTrack const &Track); // this putting of the tracks onto the terrain leaves it as it is
|
|
static std::uint64_t fitted_shape(TTrack const &Track);
|
|
int profile_find(bool &Reversed) const;
|
|
bool profile_restore();
|
|
bool profile_restore_parts();
|
|
// the route a kept design was laid over, as it runs now; none when its paths moved or are gone
|
|
std::optional<editor_track::route> profile_stored_route(stored_profile const &Entry, TTrack **From = nullptr, TTrack **To = nullptr) const;
|
|
// the kept designs over the tracks moved, as by the grade lines shared, laid anew onto them where they part from them; returns how
|
|
// many were, how many couldn't be without an error and are left as they were
|
|
std::pair<std::size_t, std::size_t> profile_refit_stored(std::unordered_set<TTrack const *> const &Moved);
|
|
void profile_store();
|
|
void profile_forget();
|
|
void profile_open_stored(std::size_t const Index);
|
|
void profile_edited();
|
|
// the radii of its neighbours were for the breaks of the grade it made, they follow the limits after it
|
|
void profile_remove_point(int const Index);
|
|
void render_profile_body();
|
|
void render_profile_strip();
|
|
void render_profile_header();
|
|
void render_profile_empty();
|
|
void render_profile_toolbar();
|
|
void render_profile_points();
|
|
void render_profile_source();
|
|
bool render_profile_parameters();
|
|
void render_profile_issues();
|
|
void profile_open(TTrack *From, TTrack *To);
|
|
void profile_open_run(TTrack &Track);
|
|
void profile_take(editor_track::route Route, TTrack *From, TTrack *To);
|
|
void profile_open_selection(std::vector<TTrack *> const &Tracks);
|
|
void profile_follow_selection();
|
|
void profile_resample();
|
|
// the ground of the terrain model under the route, as it was measured before any earthworks
|
|
void profile_sample_model();
|
|
void profile_recognize();
|
|
void profile_fit_ground();
|
|
// depth of the foot of the ballast under the rail top, and its distance from the axis
|
|
static std::pair<double, double> profile_ballast(TTrack const &Track);
|
|
// false for a track with no trackbed of its own, as the switches of the older sceneries whose bed is an include
|
|
static bool profile_own_bed(TTrack const &Track);
|
|
void profile_shape_ground();
|
|
std::pair<int, int> profile_generate_ground(std::vector<std::pair<double, double>> const &Beds, double const Reach);
|
|
void profile_restore_ground();
|
|
void render_profile_earthworks();
|
|
void profile_check();
|
|
// Terrain: the heightmap terrain follows the tracks changed. Bridges: stretches of the route over a bridge or a viaduct, the
|
|
// paths over them cut off at their ends and set to the bridge environment
|
|
void profile_apply(bool const Terrain = false, std::vector<profile::departure> const &Bridges = {}, double const Fewest = 0.0);
|
|
// the terrain under the tracks changed by the last Edits steps of the history which changed tracks
|
|
void profile_follow_terrain(std::size_t const Edits);
|
|
void profile_fit_view();
|
|
// the camera to the part of the route the plot shows; the plot to the part of the route the camera shows, its zoom kept
|
|
void profile_frame_view();
|
|
void profile_to_camera();
|
|
void profile_after_undo();
|
|
void profile_follow_edits();
|
|
struct profile_view;
|
|
void render_profile_canvas(float const Height);
|
|
void profile_fit_exaggeration(profile_view const &View);
|
|
void profile_navigate(profile_view const &View, bool const Hovered);
|
|
bool profile_canvas_edit(profile_view const &View, bool const Hovered);
|
|
void draw_profile_canvas(profile_view const &View, ImDrawList &Draw) const;
|
|
void profile_canvas_tooltip() const;
|
|
void render_profile_point();
|
|
void draw_profile_overlay() const;
|
|
|
|
// infrastructure along the track: objects bound to the paths follow their changes. bindings are kept in the
|
|
// scenery files as "//$b" comment lines
|
|
struct infra_candidate
|
|
{
|
|
infra::binding binding;
|
|
double offset{0.0}; // sideways from the axis
|
|
std::string reason;
|
|
bool chosen{false};
|
|
bool bound{false};
|
|
TTrack *reader{nullptr};
|
|
std::string event; // of that path
|
|
std::string cell;
|
|
bool loose{false};
|
|
TTrack *nearer{nullptr};
|
|
glm::dvec3 nearer_foot{0.0};
|
|
bool unread{false};
|
|
};
|
|
struct infra_window
|
|
{
|
|
bool open{false};
|
|
int scope{1}; // 0: the selected path, 1: the line through it, 2: the route of the vertical profile
|
|
float reach{1500.0f};
|
|
float corridor{8.0f};
|
|
bool follow{true};
|
|
bool show{true};
|
|
std::vector<infra::rule> rules{infra::default_rules()};
|
|
std::vector<TTrack *> tracks; // of the scope
|
|
std::vector<infra_candidate> candidates;
|
|
int filter{0};
|
|
int read{0};
|
|
int overruled{0};
|
|
int unread{0};
|
|
int elsewhere{0};
|
|
int hovered{-1};
|
|
std::string status;
|
|
std::string error;
|
|
};
|
|
infra_window m_infra;
|
|
std::vector<infra::binding> m_bindings;
|
|
std::vector<std::pair<scene::layer_handle, std::string>> m_bindings_unresolved; // lines kept as they are
|
|
bool m_bindings_loaded{false};
|
|
std::vector<infra::object_state> m_infra_buffer; // states of the objects before the change in progress
|
|
std::vector<std::pair<scene::instance_handle, std::string>> m_drive_buffer;
|
|
bool m_infra_suspended{false};
|
|
// the point objects which go with a path: the signals and the warning discs it reads, the SHP resonators, and the controls of the
|
|
// block sections, the signs and the posts by the path nearest to them
|
|
struct point_object
|
|
{
|
|
scene::instance_handle include{0};
|
|
glm::dvec3 location{0.0};
|
|
TTrack *reader{nullptr};
|
|
TTrack *nearest{nullptr}; // of one no path reads
|
|
infra::category group{infra::category::other};
|
|
};
|
|
std::vector<point_object> m_point_objects;
|
|
std::size_t m_point_objects_revision{static_cast<std::size_t>(-1)};
|
|
std::size_t m_point_objects_count{0};
|
|
void infra_adopt(TTrack &Track);
|
|
int infra_bound_count() const; // by the infra tool, not the ones a change of their track took along
|
|
std::set<std::pair<scene::basic_node const *, scene::instance_handle>> m_infra_carried; // the objects their tracks moved since the tool cleared it
|
|
std::string infra_carried_note(); // a line of the status telling how many, empty for none; clears them
|
|
void infra_load();
|
|
void infra_store();
|
|
void infra_forget(scene::basic_node const *Node);
|
|
std::vector<TTrack *> infra_scope() const;
|
|
void infra_recognize();
|
|
void infra_bind_chosen();
|
|
void infra_unbind(std::vector<std::size_t> Indices);
|
|
infra::binding *infra_find(infra::binding const &Binding);
|
|
infra::object_state infra_state_of(infra::binding const &Binding) const;
|
|
void infra_restore_state(infra::object_state const &State);
|
|
void infra_buffer(infra::binding const &Binding, bool const Refresh);
|
|
// editor_track::observer
|
|
void track_captured(TTrack const &Track) override;
|
|
void tracks_committed(std::vector<TTrack *> const &Tracks) override;
|
|
void track_retired(TTrack &Track) override;
|
|
void track_split(TTrack &Original, TTrack &Created, segment_data const &First) override;
|
|
void track_renamed(TTrack const &Track, std::string const &Old) override;
|
|
void infra_move(infra::binding &Binding);
|
|
void infra_attach(EditorSnapshot &Snapshot);
|
|
void render_infra_body();
|
|
|
|
gauge_tool m_gauge{*this, *this, *this, *this};
|
|
speed_tool m_speed{*this, *this, *this, *this};
|
|
joints_tool m_joints{*this, *this, *this, *this};
|
|
norms_tool m_norms{*this, *this, *this};
|
|
vehicle_tool m_vehicle{*this, *this};
|
|
hekto_tool m_hekto{*this, *this, *this, *this, *this, *this};
|
|
fouling_tool m_fouling{*this, *this, *this, *this, *this};
|
|
parallel_tool m_parallel{*this, *this, *this, *this};
|
|
srk_tool m_srk{*this, *this, *this, *this, *this, *this};
|
|
km_tool m_km{*this, *this, *this, *this};
|
|
track_ride m_ride;
|
|
minimap_tool m_minimap{*this, *this, m_ride};
|
|
std::vector<editor_tool *> m_tools{&m_gauge, &m_speed, &m_joints, &m_norms, &m_vehicle, &m_hekto, &m_fouling, &m_parallel, &m_srk, &m_km, &m_ride, &m_minimap};
|
|
|
|
void infra_rebase();
|
|
void render_infra_search();
|
|
void render_infra_candidates();
|
|
void render_infra_bound();
|
|
void draw_infra_overlay() const;
|
|
|
|
bool m_route_dragging{false};
|
|
alignment::design m_route_drag_from;
|
|
float m_track_snap_radius{1.0f};
|
|
bool m_track_align_tangent{true};
|
|
bool m_track_drag_connected{true};
|
|
|
|
// roads: a menu and a window of their own, independent from the edit modes of the toolset
|
|
// what a click of the build tool would make
|
|
struct road_plan
|
|
{
|
|
std::vector<segment_data> pieces; // axes of the pieces, in the order they're laid
|
|
editor_road::loose_end snap; // loose end of a road or arm of a junction the road is led to
|
|
editor_road::branch start; // junction made, or given another arm, for a road led out of the side of a road or out of a junction
|
|
bool hasstart{false};
|
|
editor_road::branch end; // the same for a road led into the side of a road or into a junction
|
|
bool hasend{false};
|
|
std::string error; // why there's nothing to make
|
|
};
|
|
struct road_tool
|
|
{
|
|
bool window{false}; // the road window is open, the left mouse button belongs to its tools
|
|
bool lanes{true}; // lanes of the roads are drawn as trajectories
|
|
int tool{0}; // 0: select, 1: build, 2: place
|
|
road_node *selected{nullptr};
|
|
junction_node *junction{nullptr}; // selected junction
|
|
roadpoint_node *marker{nullptr}; // selected level crossing or traffic point
|
|
std::vector<glm::dvec3> points; // selected points where the pieces meet or end
|
|
road_node::state settings; // layout shown in the window: of the selected piece, or of the pieces about to be built
|
|
bool whole{true}; // layout changes go to every piece of the road the selected one belongs to
|
|
bool varied{false}; // the selected piece is shown with lanes of its own for its end
|
|
bool chain{false}; // the point to build from is set
|
|
glm::dvec3 point{0.0}; // where the next piece starts
|
|
glm::dvec2 direction{0.0, 1.0}; // the way it has to leave that point
|
|
bool hasdirection{false};
|
|
bool reversed{false}; // the pieces are laid from their ends, to carry on a road from its start
|
|
double grade{0.0}; // slope the next piece has to start with, to carry on what it's attached to
|
|
bool hasgrade{false};
|
|
// the road being built leaves the side of a road, or a junction between its roads. the point to build from is the centre
|
|
// of the junction, which gets made, or gets another arm, along with the first piece
|
|
road_node *branchroad{nullptr};
|
|
double branchat{0.0}; // value of the curve parameter of the axis of that road
|
|
junction_node *branchjunction{nullptr};
|
|
float offset{0.1f}; // height above the ground the roads are built at
|
|
bool follow{true}; // built roads are led over the ground between the clicked points
|
|
float crossingspeed{30.f}; // speed limit on the junctions being made
|
|
float heightstep{0.1f}; // how much the selected points are raised or lowered at a time
|
|
// Alt+LMB on a point dragged up or down: the heights of the selected points changed by the drag, applied when let go
|
|
bool lifting{false};
|
|
float lift_mouse{0.0f}; // where on the screen the drag began, pixels down
|
|
double lift_scale{0.0}; // metres for a pixel at the point picked
|
|
std::vector<double> lift_from; // the heights of the selected points when the drag began
|
|
bool ring{false}; // the build tool makes roundabouts
|
|
float ringradius{15.f}; // of the middle of the road going around
|
|
std::string island{"none"}; // what the middle of a roundabout is covered with
|
|
float bankgrade{1.5f}; // metres a bank led to the ground runs for each metre it drops
|
|
// level crossings and traffic points
|
|
int placekind{0}; // what the place tool puts down: 0: level crossing, 1: spawn point, 2: removal point, 3: pedestrian crossing
|
|
roadpoint_node::state placing[4]; // what the next point of each kind is going to be like
|
|
float stopmargin{5.f}; // distance from the outermost track of a new crossing to the places the vehicles stop at
|
|
roadpoint_node::state target; // the point a click of the place tool would make at the moment
|
|
bool hastarget{false};
|
|
glm::dvec3 targetdirection{0.0}; // the way the traffic goes there
|
|
std::string targetnote; // what's worth knowing about that point, or why there's none
|
|
glm::dvec3 aimed{0.0}; // where the cursor was when the target was worked out, and for what kind of point
|
|
int aimedkind{-1};
|
|
char vehicles[4096]{}; // vehicles to add to the set of a spawn point, written the way they're put in a scenery
|
|
road_plan plan; // what a click would make at the moment, worked out once a frame for display
|
|
glm::dvec3 hover{0.0}; // point of a road or a junction under the cursor a road can be led out of
|
|
bool hashover{false};
|
|
glm::dvec3 mouse{0.0};
|
|
std::string status;
|
|
};
|
|
void render_road_tool_options();
|
|
// the change of the road tool
|
|
void road_choose_tool(int const Tool);
|
|
void render_road_selection();
|
|
bool render_road_layout(road_node::state &State);
|
|
bool render_road_material(char const *Label, std::string &Value);
|
|
void render_junction_layout(junction_node &Junction);
|
|
void junction_apply(junction_node &Junction, junction_node::state const &State);
|
|
// leads the banks of the corners of a junction to the ground beside it
|
|
void junction_bank_to_ground(junction_node &Junction);
|
|
// how far from specified point, and how far down, a slope of the grade set for the banks gets to the ground.
|
|
// Outwards: the way the slope leads, seen from above
|
|
std::pair<float, float> bank_reach(glm::dvec3 const &Edge, glm::dvec3 const &Outwards);
|
|
void draw_road_overlay() const;
|
|
void update_road_tool();
|
|
void road_click();
|
|
// the point where pieces meet or end nearest to the cursor on the screen, within a few pixels; it's found under the
|
|
// terrain too, where the click on the ground doesn't get near it
|
|
bool road_joint_on_screen(glm::dvec3 &Joint) const;
|
|
// Alt+LMB: the drag of the heights of the selected points begun on a point, and finished
|
|
bool road_lift_start();
|
|
void road_lift_finish();
|
|
double road_lift_offset() const;
|
|
void road_select(road_node *Road);
|
|
void junction_select(junction_node *Junction);
|
|
void road_apply();
|
|
bool road_delete();
|
|
bool road_split();
|
|
void road_cancel();
|
|
// sets the width of the road at the selected points, or the height of each of them
|
|
void road_point_width(float const Width);
|
|
void road_point_heights(std::vector<double> const &Heights);
|
|
bool road_points_apply(std::vector<std::pair<road_node *, road_node::state>> const &Changes, std::vector<std::pair<junction_node *, junction_node::state>> const &Junctions);
|
|
// takes the selected points out of their roads
|
|
bool road_points_delete();
|
|
// puts a roundabout around specified point
|
|
void road_roundabout(glm::dvec3 const &Ground);
|
|
// leads the banks of the selected piece, or of the whole road, to the ground beside it
|
|
void road_bank_to_ground();
|
|
// level crossings and traffic points
|
|
void roadpoint_select(roadpoint_node *Point);
|
|
// works out the point a click of the place tool would make. Fresh: even if the cursor is where it was the last time
|
|
void roadpoint_aim(bool const Fresh);
|
|
void roadpoint_place();
|
|
void roadpoint_apply(roadpoint_node &Point, roadpoint_node::state const &State);
|
|
// Point: the point the controls are for, nullptr for the one about to be made
|
|
bool render_roadpoint_layout(roadpoint_node::state &State, roadpoint_node const *Point);
|
|
// Fresh: the ground which wasn't looked up yet is gathered on the spot, instead of a bit of it each frame
|
|
road_plan road_preview(bool const Fresh);
|
|
// Firstgrade, Lastgrade: slopes the road has to start and end with, nullptr for none
|
|
void road_profile(std::vector<segment_data> &Pieces, double const *Firstgrade, double const *Lastgrade, bool const Fresh);
|
|
// height of the ground under each of the points, with the roads not taken for the ground. a point with nothing under it keeps its height
|
|
// Found: set for the points which have the ground under them
|
|
std::vector<double> ground_heights(std::vector<glm::dvec3> const &Points, bool const Fresh, std::vector<char> *Found = nullptr) const;
|
|
void push_road_snapshot(editor_road::record Record);
|
|
void restore_road_snapshot(EditorSnapshot const &Snapshot, std::vector<EditorSnapshot> &Opposite, bool const Undo);
|
|
road_tool m_roadtool;
|
|
};
|