mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-02 08:09:14 +01:00
refactor(editor): the hectometre posts and the fouling points are tools of their own
The fifth and the sixth tool out of editor_mode, the two lineside ones sharing their file. Placing, moving and taking out the templates which stand by the track become services of the editor, with the template types of their own, and so do the tab of the track tools shown, the ground under a point and the first step done. The context menu, the click on a fouling point in the view and the lineside tabs go through the public calls of the tools. The self-test commands hekto and fouling move with them and log the same as before.
This commit is contained in:
@@ -10,6 +10,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -18,13 +21,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "editor/editorTrack.hpp"
|
||||
#include "utilities/Classes.h"
|
||||
|
||||
class TTrack;
|
||||
class editor_nmt;
|
||||
namespace scene
|
||||
{
|
||||
class basic_node;
|
||||
}
|
||||
|
||||
enum class editor_selftest_result
|
||||
{
|
||||
@@ -36,6 +36,8 @@ enum class editor_selftest_result
|
||||
|
||||
enum class editor_first_step { tracks, lay, laid, wheel, join, turnout, undo, save, drive, look, top, select, shape, profile, profile_point, profile_apply, terrain, nmt, plan, plan_band, plan_apply, signal, posts, count };
|
||||
|
||||
enum class editor_track_tab { straights, route, path, turnout, profile, speed, joints, infra, lay, lineside, turntable, signals, parallel };
|
||||
|
||||
struct track_hover
|
||||
{
|
||||
TTrack *track{nullptr};
|
||||
@@ -50,6 +52,27 @@ struct tool_tab
|
||||
bool expand{false};
|
||||
};
|
||||
|
||||
// scenery templates standing by the track, placed and checked by the editor
|
||||
struct template_item
|
||||
{
|
||||
std::string file;
|
||||
glm::dvec3 location{0.0}; // world space
|
||||
double yaw{0.0};
|
||||
std::vector<std::string> rest; // parameters after the rotation
|
||||
bool described{false};
|
||||
std::string track;
|
||||
glm::dvec2 tilt{0.0}; // rot.x and rot.z of a described template, degrees
|
||||
std::map<std::string, std::string> values;
|
||||
};
|
||||
struct standing_template
|
||||
{
|
||||
scene::instance_handle instance{0};
|
||||
std::string file; // lower case, forward slashes
|
||||
glm::dvec3 location{0.0};
|
||||
double yaw{0.0};
|
||||
std::vector<std::string> values;
|
||||
};
|
||||
|
||||
struct nmt_place
|
||||
{
|
||||
glm::dvec3 position{0.0}; // on the axis of the path
|
||||
@@ -70,6 +93,8 @@ class editor_services
|
||||
virtual glm::dvec3 camera_position() const = 0;
|
||||
virtual track_hover const &hovered_track() const = 0;
|
||||
virtual void first_step_done(editor_first_step const Step) = 0;
|
||||
virtual void show_track_tab(editor_track_tab const Wanted) = 0;
|
||||
virtual glm::dvec3 placement_on_ground(glm::dvec3 Location) = 0;
|
||||
virtual void fly_to(glm::dvec3 const &Target, glm::dvec3 const &Look, double const Distance, double const Duration = 0.6) = 0;
|
||||
virtual void focus_track(TTrack &Track, int const Path, glm::dvec3 const &Point) = 0;
|
||||
virtual void set_current_node(scene::basic_node *Node) = 0;
|
||||
@@ -80,6 +105,10 @@ class editor_services
|
||||
virtual editor_nmt &terrain_model() = 0;
|
||||
virtual double terrain_model_offset() const = 0;
|
||||
virtual bool terrain_model_fitted() const = 0;
|
||||
virtual std::vector<standing_template> standing_templates(std::function<bool(std::string const &)> const &Accept) const = 0;
|
||||
virtual std::size_t place_templates(std::vector<template_item> const &Items, std::string &Error) = 0;
|
||||
virtual std::size_t move_templates(std::vector<std::pair<standing_template, template_item>> const &Moves) = 0;
|
||||
virtual std::size_t remove_templates(std::vector<scene::instance_handle> const &Instances) = 0;
|
||||
virtual void push_track_snapshot(std::vector<std::pair<TTrack *, editor_track::state>> States, std::vector<TTrack *> Created = {}, std::vector<TTrack *> Removed = {}) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user