17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 20:19:20 +02:00
Files
maszyna/scene/scenenodegroups.cppm
maj00r c15e200e37 Merge the track layout editor into cpp20-modules, ported to modules
The editor branch was written against headers and the PCH, both of which this
branch has done away with, so its own files were ported rather than merged: the
five headers it added are now interface units and their .cpp files module
implementation units.

- editor/{puwg1992,polandmap,turnouts,orthophoto} become eu07.editor.* modules,
  application/planpanel becomes eu07.application.planpanel. The plan tool keeps
  to its own module rather than joining the eu07.simcore partitions: it stands on
  the editor's libraries and eu07.application.uilayer, not on the simulation core,
  so :editoruilayer can export import it without a cycle.
- glm arrives by import eu07.glm, never by include, as the rest of the tree does.
  maj0sted is header-only and glm-free, so its headers stay includes in the global
  module fragment - every unit that names those types includes them itself, since
  a global fragment is not visible across units.
- the one textual conflict was :editoruilayer's include block against this
  branch's imports; resolved this branch's way plus the planpanel import.

Builds with clang 22 (-DWITH_BETTER_RENDERER=OFF) and starts into the editor on
empty ground with -editor alone.
2026-09-13 12:36:21 +02:00

105 lines
3.1 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/.
*/
module;
#include <array>
#include <chrono>
#include <deque>
#include <limits>
#include <mutex>
#include <sstream>
#include <type_traits>
#include <utility>
#include <cstddef>
#include <ostream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include "global_include/interfaces/ITexture_macros.h"
export module eu07.scene.scenenodegroups;
import eu07.utilities.classes;
import eu07.simcore;
import eu07.widgets.map_objects;
export {
namespace scene {
struct basic_group {
// members
std::vector<scene::basic_node *> nodes;
std::vector<basic_event *> events;
};
// holds lists of grouped scene nodes
class node_groups {
// NOTE: during scenario deserialization encountering *.inc file causes creation of a new group on the group stack
// this allows all nodes listed in this *.inc file to be grouped and potentially modified together by the editor.
public:
// constructors
node_groups() = default;
// methods
// requests creation of a new node group. returns: handle to the group
group_handle
create();
// indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty
group_handle
close();
// drops every group without touching node pointers — call when the region that owned
// those nodes is about to be (or has just been) destroyed, before a scenery reload
void
clear();
// update minimap objects
void
update_map();
// returns current active group, or null_handle if group stack is empty
group_handle
handle() const;
// places provided node in specified group
void
insert( scene::group_handle const Group, scene::basic_node *Node );
// places provided event in specified group
void
insert( scene::group_handle const Group, basic_event *Event );
// grants direct access to specified group
scene::basic_group &
group( scene::group_handle const Group ) {
return m_groupmap[ Group ]; }
// sends basic content of the class in legacy (text) format to provided stream
void
export_as_text( std::ostream &Output, bool const Dirty ) const;
private:
// types
using group_map = std::unordered_map<scene::group_handle, scene::basic_group>;
// methods
// removes specified group from the group list and group information from the group's nodes
void
erase( group_map::const_iterator Group );
// creates handle for a new group
group_handle
create_handle();
bool
assign_cross_switch(map::track_switch&sw, std::string &sw_name, const std::string &id, size_t idx);
// members
group_map m_groupmap; // map of established node groups
std::stack<scene::group_handle> m_activegroup; // helper, group to be assigned to newly created nodes
};
extern node_groups Groups;
} // scene
//---------------------------------------------------------------------------
} // export