17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-20 21:04:37 +02:00
Files
maszyna/editor/editorSwitchStore.hpp
maj00r ff1710d9ea feat(editor): labels for a layman, light at the start; whole sceneries fitted to the terrain model
Labels:
- every button, field, tooltip and message of the editor reread for a beginner: short nouns for the fields with the
  sentence in the tooltip, the less used options under More settings, one glossary (field of work, template, track,
  grade), sides told from directions, degrees and per mille as signs, messages built from one format string
- plural forms through STR_P; the last entry of a po file is read too, and the Polish plural rule is in the header
- lang/editor_pl.po: the code pass entries merged, 391 entries no code uses and 3 duplicates dropped
- roads: the notes and errors naming a road translated; the build options and the layout fold the texture length,
  kerb sizes, traffic share, roundabout part, height over the ground and junction speed limit under More settings, the
  lanes start folded

Grade lines fitted to the terrain model (NMT), a line or the whole scenery at once:
- fit_ground: a robust fit on nodes 5 m apart; the ground parting from the line (a bridge, a viaduct, a wall) is gone
  past rather than followed, the bends keep off the switches as far as their curves reach, a run of bends the same way
  is one point of intersection, a curve with no room is as sharp as the room lets it be
- the ends of the line and the other paths of its switches leading into lines fitted already bound the line by what
  the tracks between can climb; ends meeting in the plan, laid apart in height by hand, are joined before the run
- apply_profile: the paths are split where split_path takes the parameter (a straight was cut in the wrong place, into
  pieces of a few centimetres the game takes for zero length), no piece shorter than the margin; the paths off the
  ends of the route are brought to its height
- Bytom: 1600 lines, grade breaks at the joints 89 -> 20; Tarnowskie Gory: 848 lines, 223 -> 3; no step over 2 cm
2026-10-19 15:27:50 +02:00

87 lines
3.8 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 <optional>
#include <string>
#include <vector>
#include <glm/glm.hpp>
#include "scene/scenelayers.h"
class TTrack;
// switches placed in the track editor, kept in the scenery files as "//$r" comment lines: their type, size and side, the
// paths a slip or a crossing is made of, their km and number, so a switch is known again without guessing from its shape
namespace switch_store
{
struct record
{
scene::layer_handle layer{null_handle};
std::string kind{"switch"}; // switch, slip, crossing, double, connection
std::string name; // the switch, or the base name of a slip or a crossing
std::string type{"Rz"}; // Rz, Rlj, Rld, Rkp, Rkpd, Skrz, Rpd, Rpj, - when unknown
std::string rail{"-"};
double radius{0.0}; // of the diverging track of the straight switch the type is made of
double ratio{0.0}; // n of 1:n
char hand{'-'}; // L, R as seen along the switch from its start
double a{0.0};
double b{0.0};
double main_radius{0.0}; // of the main track, signed: + to the right, - to the left, 0 straight
std::vector<std::string> parts; // the switch, the switches of a slip or of a double switch, the paths of a crossing
glm::dvec3 start{0.0}; // of the first part
glm::dvec2 direction{0.0, 1.0};
// ends of the main and the diverging track of the first part seen from its start: along, across, along, across. it stays the
// same as long as the switch is moved or turned as a whole, it changes when the switch gets bent out of its shape
glm::dvec4 shape{0.0};
bool shaped{false};
std::optional<double> km;
std::string number{"-"};
std::string source{"designed"}; // designed: from the catalogue, measured: copied from a switch of the scenery
double middle{0.0}; // the radius in the middle of the slip curves of a double slip with the blades outside of the diamond
// a crossover laid along a curve: the outer track went up by lift over it, level between the two points, with ramps of
// ramp m on both sides
double lift{0.0};
glm::dvec3 lift_from{0.0}, lift_to{0.0};
double ramp{0.0};
};
void reset();
void load();
std::vector<record> const &records();
// the record of the switch, slip or crossing the track is a part of, while its first part keeps the shape the record says
std::optional<record> of(TTrack const &Track);
// the record of the track by its name alone, also when the switch lost its shape
std::optional<record> named(TTrack const &Track);
// the connections of switches the switch is a part of
std::vector<record> connections(TTrack const &Track);
// records whose switches were moved or turned as a whole take their new place and km; returns their names
std::vector<std::string> follow();
// radius of the diverging track: of the type, bent with the main track for an arc switch
double branch_radius(record const &Record);
// keeps the record in the file of the layer, in place of the one with the same name
void put(record Entry, scene::layer_handle const Layer);
void place(record &Entry, TTrack const &First);
void classify(record &Entry, TTrack const &Switch);
void forget(std::string const &Name);
// on save: the records follow the renamed switches, the ones whose paths are gone are dropped
void tidy();
// "Rz 60E1-500-1:12 L", as the type is written on the lists of the switches
std::string label(record const &Record);
// the records as they were before the changes made since the last call, if there were any; the current ones become the base
std::optional<std::vector<record>> take_changes();
// the current records become the base, the changes made so far aren't a part of the undo history
void settle();
// puts the records back as they were, for undo and redo
void restore(std::vector<record> Records);
} // namespace switch_store