18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 02:42:46 +01:00
Files
maszyna/application/editormodemodel.h
T
maj00r dce6f9d11c 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.
2026-11-23 18:48:19 +01:00

76 lines
2.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
// The state of the editing through the model of the track geometry (stage E4), shared by the files of it: editormodemodel.cpp, the project
// and the lines; editormodemodelturnout.cpp, the turnouts; editormodemodeledit.cpp, the grade line, the curves and the parallel track.
#include "application/editormode.h"
#include "editor/project/projectSession.hpp"
#include "editor/project/scenarioIndexCache.hpp"
#include <functional>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
// what the entry of the track has between its length and its path (the width ... the visibility with the materials); empty where it isn't
// a plain track
std::string model_surface_of(TTrack const &Track);
// what waits for the user's answer in a window of its own
struct model_question
{
enum class kind
{
none,
hand, // the lines changed by hand: written over, or the change by hand kept
waiting, // the scenarios using the map being looked through, before the tracks named go
scenarios // the scenarios naming the tracks: taken away anyway, or not
};
kind what{kind::none};
std::set<layout::line_id> lines;
std::vector<std::string> names; // the tracks to go
std::vector<project::scenario_use> users;
std::function<void(bool)> answer; // true: written over, taken away anyway
bool rename{false}; // the tracks named are to be renamed, not taken away
bool opened{false};
};
struct editor_model
{
project::session session;
bool tried{false}; // the project opened for the scenery, or failed to
std::string error;
std::unordered_map<scene::basic_node const *, editor_mode::managed_track> tracks;
project::index_cache index;
std::filesystem::path store; // the file the index is kept in between the sessions, none for the self-tests
model_question question;
// the line the route design is open on, its vertices as the model has them
struct plan_link
{
layout::line_id line{layout::line_id::none};
std::vector<layout::vertex_id> vertices;
alignment::design original;
double split{-1.0}; // the chainage the split field holds, below 0 the middle of the line
} plan;
std::string message; // what the last command came to: why it was refused, or what the norms tell of it
bool refused{false};
std::vector<std::string> notices;
std::vector<std::pair<TTrack const *, std::string>> written; // by the save under way, the texts written
std::map<std::string, layout::network> marks; // the self-test's copies of the network, for expect modelsame
std::string shown; // the message as the user reads it, in the language of the editor
std::vector<std::string> shown_notices; // the notices so
};