mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 23:44:58 +01:00
feat(editor): the profile takes the switch zones from the //$r records: the parts of a double slip and the paths of a crossing make one zone from its first part to its last, a crossing made of plain paths is a zone too, the zone is named by the number and the type of the switch; a switch with no record stays a zone named by its path; self-test vprofile logs the zones
This commit is contained in:
@@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "editor/editorFormat.hpp"
|
#include "editor/editorFormat.hpp"
|
||||||
#include "editor/editorAlignmentStore.hpp"
|
#include "editor/editorAlignmentStore.hpp"
|
||||||
#include "editor/editorGeometry.hpp"
|
#include "editor/editorGeometry.hpp"
|
||||||
|
#include "editor/editorSwitchStore.hpp"
|
||||||
|
|
||||||
#include "world/Track.h"
|
#include "world/Track.h"
|
||||||
#include "scene/scenelayers.h"
|
#include "scene/scenelayers.h"
|
||||||
@@ -430,9 +431,26 @@ void editor_mode::profile_resample()
|
|||||||
context.length = state.route.length;
|
context.length = state.route.length;
|
||||||
if (samples.empty())
|
if (samples.empty())
|
||||||
return;
|
return;
|
||||||
|
std::optional<switch_store::record> open;
|
||||||
for (auto const &span : state.route.spans)
|
for (auto const &span : state.route.spans)
|
||||||
if (span.track->eType != tt_Normal)
|
{
|
||||||
|
if (auto const found{switch_store::named(*span.track)})
|
||||||
|
{
|
||||||
|
if (open.has_value() && open->name == found->name && span.from - context.switches.back().to <= std::max(found->a + found->b, context.switches.back().to - context.switches.back().from))
|
||||||
|
{
|
||||||
|
context.switches.back().to = span.to;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto const label{switch_store::label(*found)};
|
||||||
|
context.switches.push_back({span.from, span.to, found->number != "-" ? found->number + ' ' + label : label});
|
||||||
|
open = found;
|
||||||
|
}
|
||||||
|
else if (span.track->eType != tt_Normal)
|
||||||
|
{
|
||||||
context.switches.push_back({span.from, span.to, span.track->name()});
|
context.switches.push_back({span.from, span.to, span.track->name()});
|
||||||
|
open.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
context.start_elevation = samples.front().position.y;
|
context.start_elevation = samples.front().position.y;
|
||||||
context.end_elevation = samples.back().position.y;
|
context.end_elevation = samples.back().position.y;
|
||||||
context.start_joined = editor_track::adjoining_grade(state.route, false, context.start_grade);
|
context.start_joined = editor_track::adjoining_grade(state.route, false, context.start_grade);
|
||||||
|
|||||||
@@ -1090,6 +1090,8 @@ editor_mode::selftest_result editor_mode::selftest_track(std::string const &comm
|
|||||||
m_profile.origin = 0.0;
|
m_profile.origin = 0.0;
|
||||||
profile_open(first, last);
|
profile_open(first, last);
|
||||||
WriteLog(format("SELFTEST vprofile: %zu spans, %.3f m, km of the start %.3f", m_profile.route.spans.size(), m_profile.route.length, m_profile.origin / 1000.0));
|
WriteLog(format("SELFTEST vprofile: %zu spans, %.3f m, km of the start %.3f", m_profile.route.spans.size(), m_profile.route.length, m_profile.origin / 1000.0));
|
||||||
|
for (auto const &zone : m_profile.context.switches)
|
||||||
|
WriteLog(format("SELFTEST vprofile zone %.3f %.3f %s", zone.from, zone.to, zone.name.c_str()));
|
||||||
return selftest_result::handled;
|
return selftest_result::handled;
|
||||||
}
|
}
|
||||||
if (command == "backwardcurve")
|
if (command == "backwardcurve")
|
||||||
|
|||||||
Reference in New Issue
Block a user