17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-31 23:59:03 +01:00

Editor checkpoint: turnout domain service, web->editor rename, Id-1 templates

Checkpoint of the editor branch so work isn't carried loose across a branch
switch. Builds.

- maj0sted turnout geometry moved into the domain: domain::lay_turnout lays the
  diverging path (pre-blade lead, blade at beta, arc of alfa-beta, frog rail) and
  solve_junction is a thin adapter onto it.
- the maj0sted web/ tree renamed to editor/ (namespace and paths) - there is no
  WASM here, it's plain native C++ the editor calls.
- click places the switch at its start (początek rozjazdu); the branch's leaving
  straight is locked tangent to the frog; switches can be slid along the through
  track and flipped L/P.
- Polish turnout templates carry catalogue length (Id-1-consistent lengths), plus
  blade-angle and pre-blade fields (left 0 until the catalogue figures are in).
- TURNOUT_SPEC.md: the Bezier-based runtime/model contract.
- also folds in other pending branch changes (scenery, tests) to leave a clean tree.
This commit is contained in:
maj00r
2026-08-01 19:55:33 +02:00
committed by maj00r
parent d069743265
commit 707b4de2f4
41 changed files with 2224 additions and 471 deletions

View File

@@ -33,10 +33,10 @@ target_link_libraries(maj0sted_test_render PRIVATE maj0sted::maj0sted)
target_include_directories(maj0sted_test_render PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME render COMMAND maj0sted_test_render)
add_executable(maj0sted_test_web test_web.cpp)
target_link_libraries(maj0sted_test_web PRIVATE maj0sted::maj0sted)
target_include_directories(maj0sted_test_web PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME web COMMAND maj0sted_test_web)
add_executable(maj0sted_test_editor test_editor.cpp)
target_link_libraries(maj0sted_test_editor PRIVATE maj0sted::maj0sted)
target_include_directories(maj0sted_test_editor PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME editor COMMAND maj0sted_test_editor)
add_executable(maj0sted_test_tile_cache test_tile_cache.cpp)
target_link_libraries(maj0sted_test_tile_cache PRIVATE maj0sted::maj0sted)

View File

@@ -5,9 +5,9 @@
#include "maj0sted/app/editor_document.hpp"
using namespace maj0sted::app;
using maj0sted::web::GapFit;
using maj0sted::web::NiweletaSpec;
using maj0sted::web::StraightSpec;
using maj0sted::editor::GapFit;
using maj0sted::editor::NiweletaSpec;
using maj0sted::editor::StraightSpec;
namespace {
@@ -28,14 +28,28 @@ EditorDocument sample_document() {
NiweletaSpec b;
b.name = "Bocznica z spacją";
b.straights = {StraightSpec{500000.25, 300000.75, 500200.0, 300000.0}};
b.straights[0].rel_kind = 1;
b.straights[0].rel_niw = 0;
b.straights[0].rel_str = 0;
b.straights[0].rel_offset = -4.5;
doc.niwelety = {a, b};
doc.view_x = 500100.5;
doc.view_y = 300050.25;
doc.view_extent = 420.0;
doc.origin_set = true;
doc.georeferenced = true;
doc.origin_x = 500000.0;
doc.origin_y = 300000.0;
return doc;
}
bool same(const StraightSpec& x, const StraightSpec& y) {
return x.x1 == y.x1 && x.y1 == y.y1 && x.x2 == y.x2 && x.y2 == y.y2 &&
x.hidden == y.hidden;
x.hidden == y.hidden && x.rel_kind == y.rel_kind &&
x.rel_niw == y.rel_niw && x.rel_str == y.rel_str &&
x.rel_offset == y.rel_offset && x.rel_cot == y.rel_cot &&
x.rel_side == y.rel_side && x.rel_length == y.rel_length;
}
bool same(const GapFit& x, const GapFit& y) {
@@ -46,6 +60,13 @@ bool same(const GapFit& x, const GapFit& y) {
}
void check_equal(const EditorDocument& x, const EditorDocument& y) {
CHECK(x.view_x == y.view_x);
CHECK(x.view_y == y.view_y);
CHECK(x.view_extent == y.view_extent);
CHECK(x.origin_set == y.origin_set);
CHECK(x.georeferenced == y.georeferenced);
CHECK(x.origin_x == y.origin_x);
CHECK(x.origin_y == y.origin_y);
CHECK(x.niwelety.size() == y.niwelety.size());
if (x.niwelety.size() != y.niwelety.size()) return;
for (std::size_t n = 0; n < x.niwelety.size(); ++n) {

View File

@@ -2,14 +2,14 @@
#include <numbers>
#include "check.hpp"
#include "maj0sted/web/editor.hpp"
#include "maj0sted/web/solve.hpp"
#include "maj0sted/editor/editor.hpp"
#include "maj0sted/editor/solve.hpp"
using namespace maj0sted::web;
using namespace maj0sted::editor;
namespace {
bool has_kind(const std::vector<WebPolyline>& polylines, int kind) {
bool has_kind(const std::vector<PlanPolyline>& polylines, int kind) {
for (const auto& p : polylines) {
if (p.kind == kind) return true;
}
@@ -120,7 +120,7 @@ void editor_emits_two_rails_at_standard_gauge() {
CHECK(solved[0].polylines[0].straight_index == 0);
CHECK(solved[0].polylines[0].gap == -1);
CHECK(std::abs(solved[0].polylines[0].length - 5.0) < 1e-9);
const WebPolyline* arc = nullptr;
const PlanPolyline* arc = nullptr;
for (const auto& polyline : solved[0].polylines) {
if (polyline.kind == 1) {
arc = &polyline;
@@ -138,7 +138,7 @@ void editor_emits_two_rails_at_standard_gauge() {
void editor_exposes_transition_radius_range() {
const auto solved = solve_project({short_corner(5.0, 2.0)});
const WebPolyline* transition = nullptr;
const PlanPolyline* transition = nullptr;
for (const auto& polyline : solved[0].polylines) {
if (polyline.kind == 2) {
transition = &polyline;

View File

@@ -4,9 +4,9 @@
#include <vector>
#include "check.hpp"
#include "maj0sted/web/tile_cache.hpp"
#include "maj0sted/editor/tile_cache.hpp"
using namespace maj0sted::web;
using namespace maj0sted::editor;
namespace {