mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 10:46:45 +01:00
482777f742
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.
96 lines
3.8 KiB
C++
96 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
|
|
|
|
// 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;
|
|
// by the save under way, the texts written and the placement of the file each went into
|
|
struct written_track
|
|
{
|
|
TTrack const *track{nullptr};
|
|
std::string text;
|
|
glm::dvec3 offset{0.0};
|
|
};
|
|
std::vector<written_track> 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
|
|
std::string proposal; // the solver's best proposal for a crossover refused
|
|
std::pair<std::string, std::string> drag; // the switch dragged on a line of the model as it was tried: its command, why it's refused
|
|
double turnout_move{5.0}; // m, the distance the inspector moves a turnout by
|
|
double vertex_at{-1.0}; // m, the chainage the route design adds a curve of a line of the model at, below 0 the middle of the line
|
|
// a handle of the route design dragged on a line of the model: its changes tried on a copy of the network as they're made, the line as
|
|
// the model lays it then and what the norms say of it, before the drag is let go
|
|
struct plan_preview
|
|
{
|
|
std::string key; // the design tried
|
|
bool refused{false};
|
|
std::string text; // why it's refused, or the norms' line
|
|
std::vector<glm::dvec3> points; // of the line as laid, 2 m apart
|
|
} preview;
|
|
};
|
|
|