mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 18:56:49 +01:00
feat(editor): the parallel tool beside a line of the model lays a line of the model, its arcs concentric
Continues E4b (editor-tracks-domain.md §8, "Odsuń tor równoległy"): with the editing on the model on, the parallel tool beside a track of a line of the model lays a new line of the model at the spacing, one create_line, checked by the norms. - editor/layout/layoutParallel: the line alongside a line, pure: the legs of the tangents offset, the vertices where the offset legs meet, the arcs concentric with the line's, the radius less on the inside of a curve and more on the outside, the transitions recomputed from the shift of the arc so the centre stays the line's; the cant and the class of the line, its grade breaks at the same share of the length. In a curve the spacing is widened by the widening of the gauge of both tracks on the sides facing each other (PLK tom II annex 1, gauge::curve_widening, under R 250 m), where the transitions of the curve can take it; where they can't, told so. The norms of the track geometry have no spacing of their own yet. - The tool tells the line laid, the spacing in each curve widened, what the norms warn of; refused, why, nothing changed. Self-test: expect modelspacing <line> <other> <m> <low> <high>. The case m_13_parallel (a line laid on the inside of the curve of a line of the model, 4.5 m on the straight and in the arc, one step). Tests: U: the line alongside a straight and alongside three curves on both sides, laid, the arcs concentric within 2 mm; alongside a curve of R 200 m the spacing widened by the gauges, the transitions longer on the inside and shorter on the outside; not widened where a curve has no transitions, told why. lang/editor_pl.po: the Polish of the new texts.
This commit is contained in:
@@ -20,6 +20,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "application/editormodeshared.h"
|
||||
#include "application/editoruilayer.h"
|
||||
#include "editor/editorFormat.hpp"
|
||||
#include "editor/layout/layoutParallel.hpp"
|
||||
#include "utilities/Logs.h"
|
||||
#include "utilities/translation.h"
|
||||
#include "world/Track.h"
|
||||
@@ -360,3 +361,52 @@ void editor_mode::render_model_curves()
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
// a track laid alongside a line of the model by the parallel tool
|
||||
|
||||
bool editor_mode::model_parallel(TTrack &Source, double const Spacing, int const Side, std::string &Status, std::string &Error)
|
||||
{
|
||||
auto const *managed{model_track(&Source)};
|
||||
if (managed == nullptr)
|
||||
return false;
|
||||
Status.clear();
|
||||
Error.clear();
|
||||
if (layout::owner_of(model_network(), managed->line) != nullptr)
|
||||
{
|
||||
Error = STR_C("A turnout has no line of its own: select a track of a line beside it");
|
||||
return true;
|
||||
}
|
||||
// the side of the tool and the left of the model: the same offset of the axis
|
||||
auto const plan{layout::parallel_line(model_network(), managed->line, Spacing * static_cast<double>(Side))};
|
||||
if (false == plan.valid)
|
||||
{
|
||||
for (auto const &error : plan.errors)
|
||||
Error += (Error.empty() ? "" : "\n") + model_tr(error);
|
||||
return true;
|
||||
}
|
||||
model_context context;
|
||||
context.surface = model_surface_of(Source);
|
||||
auto const line{managed->line};
|
||||
auto const spacings{plan.spacings};
|
||||
context.done = [this, &Status, line, Spacing, spacings](std::vector<TTrack *> const &Created) {
|
||||
if (false == Created.empty())
|
||||
{
|
||||
m_node = Created.back();
|
||||
ui()->set_node(m_node);
|
||||
}
|
||||
Status = format(STR_C("A line alongside line %s, %.2f m away"), line_name(line).c_str(), Spacing);
|
||||
for (std::size_t i = 0; i < spacings.size(); ++i)
|
||||
if (spacings[i] > Spacing + 1e-4)
|
||||
Status += "\n" + format(STR_C("In the curve at W%zu: %.3f m"), i + 1, spacings[i]);
|
||||
Status += "\n" + model_shown();
|
||||
for (auto const ¬ice : model_notices())
|
||||
Status += "\n" + notice;
|
||||
};
|
||||
model_run({plan.command}, context);
|
||||
if (model_refused())
|
||||
Error = model_shown();
|
||||
for (auto const ¬e : plan.notes)
|
||||
(model_refused() ? Error : Status) += "\n" + model_tr(note);
|
||||
WriteLog(format("Editor: model: a line alongside line %s, %.2f m to the %s: %s", line_name(line).c_str(), Spacing, Side > 0 ? "right" : "left", editor_selftest::one_line(model_message()).c_str()), logtype::generic);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user