18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 09:36:48 +01:00
Files
maszyna/application/editormodenorms.h
T
maj00r 075a66d169 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.
2026-11-23 23:24:28 +01:00

73 lines
2.7 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "application/editortool.h"
#include "editor/editorNormsReport.hpp"
#include <string>
#include <vector>
// the norms of the track geometry checked on the tracks laid, read only: a line or the whole scenery against a profile and a class
// of the line, what's beyond the limits listed in the track analysis window, a row clicked showing the place
class norms_tool final : public editor_tool
{
public:
norms_tool(editor_selection &Selection, editor_view &View, editor_history &History) : m_selection{Selection}, m_view{View}, m_history{History} {}
void update() override;
void draw_overlay() const override;
void render_options() override;
void forget(scene::basic_node const *Node) override;
editor_selftest_result selftest(std::string const &Command, std::istringstream &Words) override;
void set_open(bool const Open) { m_state.open = Open; }
// what the last check found, for the expectations of the self-test
std::vector<norms_report::entry> const &results() const { return m_state.results; }
// the profile and the class of the line the checks are made against, as the assumptions of the project have them
void defaults(norms::profile_id const Profile, norms::line_class const &Line);
// the lines of the whole scenery checked against them, from now on, frame after frame, the window open on the report
void check_scenery();
bool checking() const { return false == m_state.queue.empty(); }
// the lines of the check done last with a finding of the tier or worse
std::size_t lines_beyond(norms::tier const Tier) const;
private:
editor_selection &m_selection;
editor_view &m_view;
editor_history &m_history;
// a line to check: its paths, and the one span whose findings alone are kept (the diverging track of a switch), -1 all
struct pending
{
std::vector<norms_report::span> spans;
int own{-1};
};
struct state
{
bool open{false};
int scope{0}; // 0: the line through the selected path, 1: the whole scenery
int profile{0};
norms_report::options options;
bool notes{false}; // the values above the recommended ones listed too
std::vector<pending> queue;
std::size_t next{0};
std::vector<norms_report::checked_line> lines;
std::vector<norms_report::entry> results;
int selected{-1};
std::size_t history{0}; // size of the undo history at the check
std::string status;
};
state m_state;
void start();
void finish();
void focus(int const Index);
std::vector<int> listed() const;
void render_class();
void render_results();
};