From f065098717add37b87c846406315ed3cbeadcc46 Mon Sep 17 00:00:00 2001 From: maj00r <73280030+maj00r@users.noreply.github.com> Date: Mon, 23 Nov 2026 13:59:37 +0100 Subject: [PATCH] feat(editor): the lay tool a step at a time, its settings folded while the points are clicked While the points of a line were clicked, the same things were told in four places at once: the card of the tool with seven gestures, the panel (the points not laid, the buttons, the modes with their explanation, the speed with its chips, the height, the curves with their legend), six lines by the cursor with the full texts of the norms, and the gestures again in the bar under the view. The panel of the lay tool now goes by states, each with one line of what to do now at its top (editor-lay-flow.md): - Ready, nothing clicked: "Click on the ground or at a free end of a track" (with a curve traced: "Click points along the curve on the photo"), and the three settings: the shape [Straights | Curve], with what it makes of the points under the "?" beside it (a click opens its lesson), the radii of a curve traced in the same place, the speed (the field and its chips), the height [Fitted | Point to point | Flat]. The rest under More settings, the pieces added at the free end of the selected track there too. - Clicking, a point or more: "Click the next bends" and the keys "Enter lays, Backspace takes back a point, Esc drops". The line in one line, "Length 300 m, 2 curves, slowest 35 km/h", and a badge, green "meets the norms" or orange "2 curves below the norms for 100 km/h"; "details" (or the badge) opens the curves one by one, the breaches of the norms in their words, how the curves go on from those of the tracks joined, the speed designed for, the grades and what the norms say where the line goes on from a switch. The legend of the labels is by the cursor over a curve. [Lay (Enter)] as the main button and [Drop]. The settings folded to one line, "Straights, 100 km/h, through the points" (a curve traced with its radii), a pencil at its end opening them. The details open under it all, so the buttons stay where they are. - Laid: back to ready, with one line over the settings, "Laid 214 m (14 tracks), Ctrl+Z undoes" in green, the rest of what the laying told under "notes" beside it. It goes as the history moves on or back. - Dragged out of a free end: "Drag to lay from the end; let go to lay it", the line of its length and radius with the badge, the settings as the line of their summary. The drag tells the line laid as Enter does. - By the cursor, the leg drawn to it in a line or two: "straight 40 m", "curve R 76 m, up to 35 km/h" with the sign of a warning (drawn, the font has no glyph of it) and the line in orange where it's below the norms; joining a free end, the shape of the join, a line that can't be laid, Alt, the first Esc and what Tab switched to. The texts of the norms are in the details only. - The labels in the view short: "R 198, up to 60 km/h", orange below the norms; the straights as before. - The bar under the view shows the three gestures of the state: ready "LMB the first point, LMB on a free end from the end, Tab a curve from the photo"; clicking "LMB the next bend, Enter lay, Backspace take back". The rest of them in the card unfolded and in F1, Ctrl+Shift+wheel (the speed) added there; the length typed after the three. Nothing is taken away: what the panel showed is behind a fold, the pencil, the "?" or F1. The messages the lay tool logs for the self-tests keep their words, the line laid told as "Laid 214 m (14 tracks)" now. The flow: application/editorflow.h, the step line, the summary line with its pencil, the badge with its details, the message of one line with the rest in its tooltip, for the panels of other tools as well. Self-test: expect laypanel , and the case lf_1_lay_panel_states through the states, in straights and in a curve traced. lang/editor_pl.po: the Polish of the new texts as the spec words them; the laying texts of "the photo" named the orthophoto as the rest of the editor ("na ortofotomapie", "z ortofotomapy"). --- application/editorflow.h | 179 ++++++ application/editormode.h | 55 +- application/editormodelay.cpp | 542 +++++++++++++++---- application/editormodeselftest.cpp | 2 + application/editormodeselftestexpect.cpp | 33 +- application/editormodetrack.cpp | 153 ++---- application/editormodetrackshared.h | 18 + lang/editor_pl.po | 138 ++++- tests/editor/README.md | 7 + tests/editor/cases/lf_1_lay_panel_states.txt | 34 ++ 10 files changed, 947 insertions(+), 214 deletions(-) create mode 100644 application/editorflow.h create mode 100644 tests/editor/cases/lf_1_lay_panel_states.txt diff --git a/application/editorflow.h b/application/editorflow.h new file mode 100644 index 000000000..5bc5c30d3 --- /dev/null +++ b/application/editorflow.h @@ -0,0 +1,179 @@ +/* +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/. +*/ + +#pragma once + +// the flow of the panel of a tool: one line of what to do now at its top, the settings folded to a line of their summary while +// they aren't being changed, what's being made as one line of its quality with a badge, the details of it on demand + +#include "application/editormodeshared.h" + +#include "imgui/imgui.h" +#include +#include +#include +#include + +namespace editor_flow +{ + +ImVec4 constexpr kGood{0.40f, 0.85f, 0.45f, 1.0f}; +ImVec4 constexpr kBelow{1.0f, 0.58f, 0.18f, 1.0f}; +ImVec4 constexpr kRefused{1.0f, 0.38f, 0.30f, 1.0f}; + +// the sign of a warning in the text by the cursor: the font has no glyph of its own for it, a triangle is drawn in its place +inline constexpr std::string_view kWarningMark{" \xE2\x9A\xA0"}; + +// a pencil, drawn: the sign of a line which opens what it sums up for editing +inline void draw_pencil(ImDrawList &List, ImVec2 const Centre, float const Size, ImU32 const Colour) +{ + auto const half{Size * 0.5f}; + auto const thick{std::max(2.0f, std::round(Size * 0.26f)) * 0.5f}; + float constexpr diagonal{0.70710678f}; + // along the diagonal from the tip at the lower left to the end at the upper right; across it + ImVec2 const tip{Centre.x - half, Centre.y + half}; + ImVec2 const end{Centre.x + half, Centre.y - half}; + ImVec2 const across{diagonal * thick, diagonal * thick}; + ImVec2 const neck{tip.x + diagonal * Size * 0.32f, tip.y - diagonal * Size * 0.32f}; + List.AddQuadFilled(ImVec2(neck.x - across.x, neck.y - across.y), ImVec2(end.x - across.x, end.y - across.y), ImVec2(end.x + across.x, end.y + across.y), ImVec2(neck.x + across.x, neck.y + across.y), Colour); + List.AddTriangleFilled(ImVec2(neck.x - across.x, neck.y - across.y), ImVec2(neck.x + across.x, neck.y + across.y), tip, Colour); +} + +// the sign of a warning, drawn: a triangle with the mark in it +inline void draw_warning(ImDrawList &List, ImVec2 const Centre, float const Size, ImU32 const Colour) +{ + auto const half{Size * 0.5f}; + List.AddTriangleFilled(ImVec2(Centre.x, Centre.y - half), ImVec2(Centre.x + half * 1.1f, Centre.y + half * 0.85f), ImVec2(Centre.x - half * 1.1f, Centre.y + half * 0.85f), Colour); + auto const ink{IM_COL32(20, 20, 20, 255)}; + List.AddLine(ImVec2(Centre.x, Centre.y - half * 0.3f), ImVec2(Centre.x, Centre.y + half * 0.3f), ink, std::max(1.0f, Size * 0.13f)); + List.AddCircleFilled(ImVec2(Centre.x, Centre.y + half * 0.58f), std::max(1.0f, Size * 0.07f), ink); +} + +// the one line of what to do now, at the top of the panel of the tool: larger and white, with the accent of the tools of building at +// its left; the keys of the step under it, dimmed +inline void step_line(char const *Text, char const *Keys = nullptr) +{ + auto *list{ImGui::GetWindowDrawList()}; + auto const font{ImGui::GetFontSize()}; + auto const top{ImGui::GetCursorScreenPos()}; + auto const bar{std::max(3.0f, std::round(font * 0.22f))}; + auto const indent{bar + std::round(font * 0.5f)}; + ImGui::Indent(indent); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); + ImGui::SetWindowFontScale(1.12f); + ImGui::TextWrapped("%s", Text); + ImGui::SetWindowFontScale(1.0f); + ImGui::PopStyleColor(); + if (Keys != nullptr && *Keys != '\0') + { + ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled)); + ImGui::TextWrapped("%s", Keys); + ImGui::PopStyleColor(); + } + auto const bottom{ImGui::GetItemRectMax().y}; + ImGui::Unindent(indent); + list->AddRectFilled(top, ImVec2(top.x + bar, bottom), family_colour(0), bar * 0.5f); + ImGui::Spacing(); +} + +// settings folded to the line of their summary, a pencil at its end: a click on it opens them, another one folds them again; true when +// clicked +inline bool summary_line(char const *Id, std::string const &Text, bool const Open, char const *Tooltip = nullptr) +{ + auto const height{ImGui::GetFrameHeight()}; + auto const width{std::max(1.0f, ImGui::GetContentRegionAvail().x)}; + auto const at{ImGui::GetCursorScreenPos()}; + ImGui::PushID(Id); + auto const clicked{ImGui::InvisibleButton("##summary", ImVec2(width, height))}; + ImGui::PopID(); + auto const hovered{ImGui::IsItemHovered()}; + if (hovered) + { + ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); + if (Tooltip != nullptr && *Tooltip != '\0') + ImGui::SetTooltip("%s", Tooltip); + } + auto *list{ImGui::GetWindowDrawList()}; + list->AddRectFilled(at, ImVec2(at.x + width, at.y + height), ImGui::GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), std::round(height * 0.3f)); + auto const pad{std::round(ImGui::GetStyle().FramePadding.x)}; + auto const pencil{std::round(height * 0.5f)}; + auto const right{at.x + width - pad - pencil}; + list->PushClipRect(at, ImVec2(right - pad, at.y + height), true); + list->AddText(ImVec2(at.x + pad, std::round(at.y + (height - ImGui::GetTextLineHeight()) * 0.5f)), ImGui::GetColorU32(ImGuiCol_Text), Text.c_str()); + list->PopClipRect(); + auto const colour{Open ? family_colour(0) : ImGui::GetColorU32(hovered ? ImGuiCol_Text : ImGuiCol_TextDisabled)}; + draw_pencil(*list, ImVec2(right + pencil * 0.5f, at.y + height * 0.5f), pencil, colour); + return clicked; +} + +// a link which opens what it names under it and folds it again, a marker after it pointing right while folded, down while open; true +// when clicked +inline bool fold_link(char const *Id, char const *Text, bool &Open) +{ + auto const size{ImGui::CalcTextSize(Text)}; + auto const mark{std::round(ImGui::GetFontSize() * 0.3f)}; + auto const height{ImGui::GetFrameHeight()}; + auto const at{ImGui::GetCursorScreenPos()}; + ImGui::PushID(Id); + auto const clicked{ImGui::InvisibleButton("##fold", ImVec2(size.x + mark * 3.5f, height))}; + ImGui::PopID(); + auto const hovered{ImGui::IsItemHovered()}; + if (hovered) + ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); + auto *list{ImGui::GetWindowDrawList()}; + auto const colour{ImGui::GetColorU32(hovered || Open ? ImGuiCol_Text : ImGuiCol_TextDisabled)}; + auto const y{std::round(at.y + (height - size.y) * 0.5f)}; + list->AddText(ImVec2(at.x, y), colour, Text); + list->AddLine(ImVec2(at.x, y + size.y), ImVec2(at.x + size.x, y + size.y), (colour & ~IM_COL32_A_MASK) | IM_COL32(0, 0, 0, 110)); + ImVec2 const centre{at.x + size.x + mark * 2.0f, at.y + height * 0.5f}; + if (Open) + list->AddTriangleFilled(ImVec2(centre.x - mark, centre.y - mark * 0.6f), ImVec2(centre.x + mark, centre.y - mark * 0.6f), ImVec2(centre.x, centre.y + mark * 0.8f), colour); + else + list->AddTriangleFilled(ImVec2(centre.x - mark * 0.6f, centre.y - mark), ImVec2(centre.x - mark * 0.6f, centre.y + mark), ImVec2(centre.x + mark * 0.8f, centre.y), colour); + if (clicked) + Open = !Open; + return clicked; +} + +// the quality of what's being made at a glance: a badge, green where it meets what it should, orange where it doesn't, and beside it the +// link to the details it sums up; a click on either opens them +inline void quality_badge(char const *Id, char const *Text, bool const Good, char const *Details, bool &Open) +{ + ImGui::PushID(Id); + if (state_chip(Text, Good ? kGood : kBelow)) + Open = !Open; + auto const room{ImGui::CalcTextSize(Details).x + ImGui::GetFontSize() * 1.2f}; + same_line_if_fits(room); + fold_link("##details", Details, Open); + ImGui::PopID(); +} + +// one line of a message in its colour, the rest of it in the tooltip of the line; true when the message has more lines than the one +inline bool message_line(std::string_view const Text, ImVec4 const &Colour) +{ + auto const end{Text.find('\n')}; + std::string const first{Text.substr(0, end)}; + ImGui::PushStyleColor(ImGuiCol_Text, Colour); + ImGui::TextWrapped("%s", first.c_str()); + ImGui::PopStyleColor(); + if (end == std::string_view::npos) + return false; + if (ImGui::IsItemHovered()) + { + std::string const rest{Text.substr(end + 1)}; + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(std::round(ImGui::GetFontSize() * 32.0f)); + ImGui::TextUnformatted(rest.c_str()); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } + return true; +} + +} // namespace editor_flow diff --git a/application/editormode.h b/application/editormode.h index 19ed4ea31..28278f497 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -1902,9 +1902,20 @@ class editor_mode : public application_mode, private editor_track::observer, pri bool own_speed{false}; // the speed of the style also where the track goes on from one with its own, the new tracks given it std::string status; double status_time{-100.0}; + // what Tab switched to, told by the cursor a while: the step at the top of the panel says it for good + std::string hint; + double hint_time{-100.0}; std::string skew; // what Alt turned the straight to double escape_time{-100.0}; // when Esc was pressed over points not laid: the second Esc drops them std::size_t history{0}; // the step of the history the track laid last was begun at + // the panel: the settings opened from the line of their summary while the points are clicked, the details of the line shown, the + // notes of the line laid + bool settings_open{false}; + bool details_open{false}; + bool notes_open{false}; + // the status tells of a line laid just now, as long as the history stays at the step it was laid with + bool laid_now{false}; + std::size_t laid_step{0}; // the line laid last, told in the inspector while the last of its tracks stays the selection the laying left struct laid_curve { @@ -1932,8 +1943,50 @@ class editor_mode : public application_mode, private editor_track::observer, pri void lay_back(); void lay_escape(); std::size_t lay_pending() const; // the points clicked and not laid yet + // the states of the panel of the lay tool, each with a step of its own: nothing clicked yet, the points being clicked, a line laid + // just now (one line over the state of nothing clicked), the shape dragged out of a free end + enum class lay_state + { + ready, + clicking, + laid, + extending + }; + lay_state lay_panel_state() const; + // the state of the panel of the lay tool in words, for the expectations of the self-test + std::string shown_lay_panel() const; + // the line shown at a glance: its length, its curves, the speed of the slowest one and how many are below the norms for the speed + // it's designed for + struct lay_quality + { + bool valid{false}; + double length{0.0}; + std::size_t curves{0}; + double slowest{0.0}; + std::size_t below{0}; + double speed{0.0}; + }; + lay_quality lay_quality_now() const; + std::string lay_settings_summary() const; + // what the cursor tells of the leg drawn to it, in a line or two + std::vector lay_leg() const; + // why the line shown can't be laid, or what's told of a leg not of a design; empty where it only breaks the norms, which the details + // of the panel list + std::string lay_error() const; + std::string lay_readout() const; + // the same of the shape dragged out of a free end with the lay tool on: of Length, the sharpest arc of Radius, joined to Joined, + // Warned of by the norms where it goes on from a switch + std::string extend_leg(double const Length, double const Radius, TTrack const *Joined, bool const Warned) const; void render_lay_ui(); - void render_lay_status(); + void render_lay_step(lay_state const State); + void render_lay_settings(); + void render_lay_quality(); + void render_lay_details(); + void render_lay_buttons(); + void render_lay_more(); + void render_lay_status(lay_state const State); + // a line laid by the lay tool, told in its panel: the length, the tracks, how to take it back + void lay_told(double const Length, std::size_t const Tracks); void lay_click(); void lay_finish(editor_track::snap_target const &End); void lay_cancel(); diff --git a/application/editormodelay.cpp b/application/editormodelay.cpp index c73aa2e0e..83f8896c6 100644 --- a/application/editormodelay.cpp +++ b/application/editormodelay.cpp @@ -15,6 +15,7 @@ http: #include "application/editorprojection.h" #include "application/editormodeshared.h" #include "application/editorgestures.h" +#include "application/editorflow.h" #include "editor/editorFormat.hpp" #include "editor/editorAlignmentStore.hpp" #include "editor/editorSwitchStore.hpp" @@ -973,6 +974,13 @@ void editor_mode::finish_extend() ui()->set_node(m_node); nmt_fit_laid(from, created.back()->m_paths.front().points[segment_data::point::end]); m_nmt_state.laying = false; + if (m_lay.active) + { + double length{0.0}; + for (auto const &piece : pieces) + length += bezier{piece}.plan_length(); + lay_told(length, created.size()); + } straight_refresh(); } @@ -1997,15 +2005,15 @@ void editor_mode::lay_switch_mode() m_track_layout = tool.mode == lay_mode::curve ? track_layout::arc_straight : track_layout::straight; if (tool.mode == lay_mode::curve) first_step_done(first_step::trace); - tool.status = tool.mode == lay_mode::curve ? STR("Curve: click points along the middle of the track, the curve ends at the last one. Tab: back to the straights") - : STR("Straights: each point clicked is a bend of the straights, eased with a large curve. Tab: a curve traced on the photo"); - tool.status_time = ImGui::GetTime(); + tool.hint = tool.mode == lay_mode::curve ? STR("Curve traced on the photo, Tab: the straights") : STR("Straights, Tab: a curve traced on the photo"); + tool.hint_time = ImGui::GetTime(); } void editor_mode::lay_click() { auto &tool{m_lay}; tool.status.clear(); + tool.laid_now = false; lay_trim(); auto const snap{tool.mouse_snap}; if (snap.track != nullptr && false == tool.points.empty() && glm::distance(snap.position, tool.points.front()) > 1.0) @@ -2053,6 +2061,7 @@ void editor_mode::lay_finish(editor_track::snap_target const &End) tool.status_time = ImGui::GetTime(); if (pieces.empty()) { + tool.laid_now = false; tool.status = error.empty() ? std::string{STR_C("Click at least two points")} : error; if (End.track != nullptr && false == tool.points.empty()) { @@ -2084,7 +2093,7 @@ void editor_mode::lay_finish(editor_track::snap_target const &End) first_step_done(first_step::bend); if (End.track != nullptr) first_step_done(first_step::join); - tool.status = format(STR_P("Laid %.1f m of track in %zu piece, Ctrl+Z takes it back", "Laid %.1f m of track in %zu pieces, Ctrl+Z takes it back", static_cast(created.size())), length, created.size()); + lay_told(length, created.size()); if (false == error.empty()) tool.status += "\n" + error; if (eased.has_value() && eased->compound) @@ -2132,9 +2141,20 @@ void editor_mode::lay_finish(editor_track::snap_target const &End) tool.points.clear(); tool.modes.clear(); tool.start = {}; + tool.laid_step = m_history.size(); straight_refresh(); } +void editor_mode::lay_told(double const Length, std::size_t const Tracks) +{ + auto &tool{m_lay}; + tool.status = format(STR_P("Laid %.0f m (%zu track) · Ctrl+Z undoes", "Laid %.0f m (%zu tracks) · Ctrl+Z undoes", static_cast(Tracks)), Length, Tracks); + tool.status_time = ImGui::GetTime(); + tool.laid_now = true; + tool.notes_open = false; + tool.laid_step = m_history.size(); +} + void editor_mode::lay_enter() { auto &tool{m_lay}; @@ -2174,6 +2194,8 @@ void editor_mode::lay_cancel() tool.preview.clear(); tool.plan = {}; tool.status.clear(); + tool.laid_now = false; + tool.settings_open = false; } std::size_t editor_mode::lay_pending() const @@ -2330,76 +2352,295 @@ alignment::limits editor_mode::laying_norms() const return norms; } -void editor_mode::render_lay_ui() +editor_mode::lay_state editor_mode::lay_panel_state() const { - auto &tool{m_lay}; - // the points clicked are no track until they're laid: said first, with the keys as buttons - if (tool.points.size() > 1) + if (m_extend.active) + return lay_state::extending; + if (false == m_lay.points.empty()) + return lay_state::clicking; + if (m_lay.laid_now && m_lay.laid_step == m_history.size()) + return lay_state::laid; + return lay_state::ready; +} + +namespace +{ + +// the speed an arc lets the trains through at, in steps of 5 km/h as the labels tell it +double arc_speed(double const Radius, alignment::limits const &Norms) +{ + return Radius > 0.0 ? std::floor(alignment::speed_limit(Radius, Norms) / 5.0) * 5.0 : 0.0; +} + +// the length of the pieces and the radius of the sharpest arc among them, the one of the layout eased in its place where there's one +std::pair pieces_measure(std::vector const &Pieces, std::optional const &Eased) +{ + double length{0.0}; + double radius{0.0}; + for (auto const &piece : Pieces) { - auto const pending{lay_pending()}; - ImGui::TextColored(ImVec4(1.0f, 0.83f, 0.3f, 1.0f), "%s", format(STR_P("Not laid yet: %zu point", "Not laid yet: %zu points", static_cast(pending)), pending).c_str()); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.18f, 0.45f, 0.22f, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.24f, 0.56f, 0.28f, 1.0f)); - if (ImGui::Button(STR_C("Lay (Enter)"))) - { - // the cursor is over the panel: no free end under it to join - tool.mouse_snap = {}; - lay_enter(); - } - ImGui::PopStyleColor(2); - ImGui::SameLine(); - if (ImGui::Button(STR_C("Drop the points"))) - lay_cancel(); - item_tooltip("Esc twice does the same"); - ImGui::Separator(); + length += bezier{piece}.plan_length(); + if (auto const r{piece_plan_radius(piece)}; r >= 0.5 && (radius == 0.0 || r < radius)) + radius = r; } - if (int mode{tool.mode == lay_mode::curve ? 1 : 0}; - segmented("laymode", mode, - {{0, STR_C("Straights Tab"), "Each point clicked is a bend of the straights: the bend eased with two transition curves meeting, with no cant, of a large radius; where they don't fit, an arc with the transitions and the cant of the norms, as large as fits"}, - {1, STR_C("Curve Tab"), "Click points along the middle of a curve seen on the photo: the curve, compound or with a straight in it, is fitted to them and ends at the last one, heading as they do there. It comes from the straight before it, of the points clicked before or of the free end, and goes on with the curve of a free end, a switch too, where the points turn its way"}}) && - (mode == 1) != (tool.mode == lay_mode::curve)) - lay_switch_mode(); - if (tool.mode == lay_mode::straights) + if (Eased.has_value() && false == Eased->pieces.empty()) + radius = Eased->radius; + return {length, radius}; +} + +// the leg the cursor draws as a curve: its radius, the speed it lets the trains through at, the sign of a warning where that's below +// the norms +std::string curve_leg(std::string const &Radii, double const Speed, bool const Meets) +{ + auto text{Speed > 0.0 ? format(STR_C("curve R %s m · up to %.0f km/h"), Radii.c_str(), Speed) : format(STR_C("curve R %s m"), Radii.c_str())}; + if (false == Meets) + text += editor_flow::kWarningMark; + return text; +} + +// how far a curve traced is from the points clicked along it: green within 10 cm, yellow within 30 cm, red farther +ImU32 departure_colour(double const Departure) +{ + if (Departure <= 0.1) + return IM_COL32(90, 220, 110, 255); + if (Departure <= 0.3) + return IM_COL32(255, 200, 60, 255); + return IM_COL32(255, 90, 70, 255); +} + +std::string first_line(std::string const &Text) +{ + return Text.substr(0, Text.find('\n')); +} + +} // namespace + +editor_mode::lay_quality editor_mode::lay_quality_now() const +{ + auto const &lay{m_lay}; + auto const norms{laying_norms()}; + lay_quality quality; + auto const [from, to]{laying_ends()}; + quality.speed = design_speed(from, to); + if (false == m_extend.active && lay.plan.shape.valid && false == lay.preview.empty()) { - ImGui::TextDisabled("%s", STR_C("Radius of the curves at the bends")); - ImGui::SameLine(); - if (ImGui::SmallButton("?##corners")) + quality.length = lay.preview_length; + quality.speed = lay.plan.design.speed; + for (auto const &curve : lay.plan.shape.curves) { - m_first_steps_open = true; - m_tutorial_goto = "Radius of the curves at the bends"; - } - // the explanation over the button: under it, it pushed the speed and the height out of the panel at 1366 x 768 - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::PushTextWrapPos(std::round(ImGui::GetFontSize() * 30.0f)); - ImGui::TextUnformatted(STR_C("The largest radius that fits between your points is taken: two transition curves meeting, with no cant, from 6000 m down to 2000 m, and below that an arc with the transitions and the cant of the norms")); - ImGui::TextDisabled("%s", STR_C("What it is: the lesson of the tutorial")); - ImGui::PopTextWrapPos(); - ImGui::EndTooltip(); + auto const speed{arc_speed(curve_sharpest(curve), norms)}; + quality.slowest = quality.curves == 0 ? speed : std::min(quality.slowest, speed); + ++quality.curves; + if (false == alignment::meets_norms(curve, lay.plan.design)) + ++quality.below; } } else { - segmented("layradii", tool.radii, - {{0, STR_C("Auto"), "As few radii as follow the points, up to three"}, {1, STR_C("1 R"), "One radius"}, {2, STR_C("2 R"), "A compound curve of two radii"}, {3, STR_C("3 R"), "A compound curve of three radii"}}); - ImGui::Checkbox(STR_C("Two curves with a straight between them, where the points show one"), &tool.straights_between); - item_tooltip("The points along the curve may make two curves, turning the same way or not, with a straight between them, where these follow the points much closer than one curve"); - if (auto const &traces{tool.plan.traces}; false == traces.empty() && false == traces.back().offsets.empty()) + auto const [length, radius]{pieces_measure(m_extend.active ? extend_preview() : lay.preview, m_eased_last)}; + quality.length = m_extend.active ? length : lay.preview_length; + if (radius > 0.0) { - auto const &trace{traces.back()}; - auto const colour = [](double const Departure) { return Departure <= 0.1 ? IM_COL32(90, 220, 110, 255) : Departure <= 0.3 ? IM_COL32(255, 200, 60, 255) : IM_COL32(255, 90, 70, 255); }; - metric_tiles({{format("%zu", trace.points.size()), STR_C("points"), ImGui::GetColorU32(ImGuiCol_Text)}, - {format("%.0f cm", trace.rms * 100.0), STR_C("departure"), colour(trace.rms)}, - {format("%.0f cm", trace.worst * 100.0), STR_C("at most"), colour(trace.worst)}}); - } - else - { - ImGui::PushTextWrapPos(0.0f); - ImGui::TextDisabled("%s", STR_C("Click points along the middle of the track on the photo; the curve ends at the last one")); - ImGui::PopTextWrapPos(); + quality.curves = 1; + quality.slowest = arc_speed(radius, norms); + quality.below = quality.slowest > 0.0 && quality.slowest < quality.speed ? 1 : 0; } } + quality.valid = quality.length > 0.0; + return quality; +} + +std::string editor_mode::lay_settings_summary() const +{ + auto const &lay{m_lay}; + std::string text{lay.mode == lay_mode::curve ? STR_C("Curve") : STR_C("Straights")}; + if (lay.mode == lay_mode::curve) + { + static char const *const radii[]{"Auto", "1 R", "2 R", "3 R"}; + text += std::string{" · "} + STR_C(radii[std::clamp(lay.radii, 0, 3)]); + } + auto const [from, to]{laying_ends()}; + text += format(" · %.0f km/h", design_speed(from, to)); + static char const *const heights[]{"along the ground", "through the points", "level"}; + return text + " · " + STR_C(heights[std::clamp(static_cast(EditorSettings.heights()), 0, 2)]); +} + +std::vector editor_mode::lay_leg() const +{ + auto const &lay{m_lay}; + auto const norms{laying_norms()}; + std::vector lines; + if (lay.plan.shape.valid) + { + // the straight the cursor is at the end of, and the curve of the last bend before it + auto const &shape{lay.plan.shape}; + if (false == shape.elements.empty() && shape.elements.back().kind == alignment::element_kind::straight) + lines.push_back(format(STR_C("straight %.0f m"), shape.elements.back().length)); + if (false == shape.curves.empty()) + { + auto const &curve{shape.curves.back()}; + lines.push_back(curve_leg(curve_radii(curve), arc_speed(curve_sharpest(curve), norms), alignment::meets_norms(curve, lay.plan.design))); + } + return lines; + } + if (lay.preview.empty()) + return lines; + if (auto const radius{pieces_measure(lay.preview, m_eased_last).second}; radius > 0.0) + { + auto const [from, to]{laying_ends()}; + auto const speed{arc_speed(radius, norms)}; + lines.push_back(curve_leg(format("%.0f", radius), speed, speed <= 0.0 || speed >= design_speed(from, to))); + } + else + lines.push_back(format(STR_C("straight %.0f m"), lay.preview_length)); + return lines; +} + +std::string editor_mode::extend_leg(double const Length, double const Radius, TTrack const *Joined, bool const Warned) const +{ + auto const speed{arc_speed(Radius, laying_norms())}; + auto text{Radius > 0.0 ? curve_leg(format("%.0f", Radius), speed, false == Warned && (speed <= 0.0 || speed >= design_speed(m_extend.track, Joined))) : format(STR_C("straight %.0f m"), Length)}; + if (Radius <= 0.0 && Warned) + text += editor_flow::kWarningMark; + if (Joined != nullptr) + text += " · " + format(STR_C("joins %s"), name_of(*Joined).c_str()); + // the shape of a curve, of the layout chosen or of the join; a straight says it all + if (Radius <= 0.0) + return text; + return text + "\n" + first_line(track_shaping(Joined != nullptr)); +} + +std::string editor_mode::lay_error() const +{ + auto const &lay{m_lay}; + // a line of a design laid with the norms broken is told so by its curves, in orange, and by the badge of the panel + if (lay.preview_error.empty() || (false == lay.preview.empty() && lay.plan.shape.valid)) + return {}; + return lay.preview_error; +} + +std::string editor_mode::lay_readout() const +{ + auto const &lay{m_lay}; + auto const now{ImGui::GetTime()}; + std::vector lines; + if (lay.points.empty()) + lines.emplace_back(lay.mouse_snap.track != nullptr ? STR_C("goes on from this end of the track") : STR_C("start")); + else + lines = lay_leg(); + // where the leg ends: the free end it joins, the shape of the track joined to it + if (false == lay.points.empty() && lay.mouse_snap.track != nullptr) + { + auto const joins{format(STR_C("joins %s"), name_of(*lay.mouse_snap.track).c_str())}; + if (lines.empty()) + lines.push_back(joins); + else + lines.front() += " · " + joins; + } + if (lay.points.size() == 1 && lay.mouse_snap.track != nullptr) + lines.push_back(first_line(track_shaping(lay.start.track != nullptr))); + if (auto const error{lay_error()}; false == error.empty()) + lines.push_back(first_line(error)); + if (ImGui::GetIO().KeyAlt && false == lay.points.empty()) + { + auto const offset{plan_of(lay.mouse - lay.points.back())}; + auto const degrees{std::fmod(glm::degrees(std::atan2(offset.x, offset.y)) + 360.0, 360.0)}; + lines.push_back(lay.skew.empty() ? format(STR_C("azimuth %.0f deg"), degrees) : lay.skew); + } + // the warning of the first Esc leads, where it's read first; what was laid, and what Tab switched to, a while after + if (now - lay.escape_time < 3.0) + lines.insert(lines.begin(), first_line(lay.status)); + else if (false == lay.status.empty() && now - lay.status_time < 4.0) + lines.push_back(first_line(lay.status)); + if (false == lay.hint.empty() && now - lay.hint_time < 4.0) + lines.push_back(lay.hint); + return lines_of(lines); +} + +void editor_mode::render_lay_ui() +{ + auto &tool{m_lay}; + auto const state{lay_panel_state()}; + render_lay_step(state); + if (state == lay_state::clicking || state == lay_state::extending) + { + render_lay_quality(); + if (state == lay_state::clicking) + render_lay_buttons(); + // the settings as the line of their summary while the points are clicked: it opens them + auto const [from, to]{laying_ends()}; + auto const speed{from != nullptr || to != nullptr ? design_speed_of(from, to) : std::string{}}; + if (editor_flow::summary_line("##laysettings", lay_settings_summary(), tool.settings_open, speed.c_str())) + tool.settings_open = !tool.settings_open; + if (tool.settings_open) + render_lay_settings(); + render_lay_status(state); + // the details under it all: opened, they don't push the buttons out of the panel + if (tool.details_open) + render_lay_details(); + return; + } + // the line laid just now, told in one line over the settings + if (state == lay_state::laid) + render_lay_status(state); + tool.settings_open = false; + tool.details_open = false; + render_lay_settings(); + if (state != lay_state::laid) + render_lay_status(state); +} + +void editor_mode::render_lay_step(lay_state const State) +{ + auto const curve{m_lay.mode == lay_mode::curve}; + switch (State) + { + case lay_state::extending: editor_flow::step_line(STR_C("Drag to lay from the end; let go to lay it")); break; + case lay_state::clicking: + editor_flow::step_line(curve ? STR_C("Click points along the curve on the photo") : STR_C("Click the next bends"), + m_lay.points.size() > 1 ? STR_C("Enter lays · Backspace takes back a point · Esc drops") : STR_C("Backspace takes back the point · Esc drops")); + break; + default: editor_flow::step_line(curve ? STR_C("Click points along the curve on the photo") : STR_C("Click on the ground or at a free end of a track")); break; + } +} + +void editor_mode::render_lay_settings() +{ + auto &tool{m_lay}; + // the shape, what it makes of the points under the question mark beside it + if (ImGui::BeginTable("##layshape", 2, ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("##choice", ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn("##why", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableNextColumn(); + if (int mode{tool.mode == lay_mode::curve ? 1 : 0}; + segmented("laymode", mode, + {{0, STR_C("Straights Tab"), "Each point clicked is a bend of the straights: the bend eased with two transition curves meeting, with no cant, of a large radius; where they don't fit, an arc with the transitions and the cant of the norms, as large as fits"}, + {1, STR_C("Curve Tab"), "Click points along the middle of a curve seen on the photo: the curve, compound or with a straight in it, is fitted to them and ends at the last one, heading as they do there. It comes from the straight before it, of the points clicked before or of the free end, and goes on with the curve of a free end, a switch too, where the points turn its way"}}) && + (mode == 1) != (tool.mode == lay_mode::curve)) + lay_switch_mode(); + ImGui::TableNextColumn(); + auto const curve{tool.mode == lay_mode::curve}; + if (ImGui::SmallButton("?##layshape")) + { + m_first_steps_open = true; + m_tutorial_goto = curve ? "Curves" : "Radius of the curves at the bends"; + } + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(std::round(ImGui::GetFontSize() * 30.0f)); + ImGui::TextUnformatted(curve ? STR_C("Click points along the middle of the track on the photo; the curve ends at the last one") + : STR_C("The largest radius that fits between your points is taken: two transition curves meeting, with no cant, from 6000 m down to 2000 m, and below that an arc with the transitions and the cant of the norms")); + ImGui::TextDisabled("%s", STR_C("What it is: the lesson of the tutorial")); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } + ImGui::EndTable(); + } + if (tool.mode == lay_mode::curve) + segmented("layradii", tool.radii, + {{0, STR_C("Auto"), "As few radii as follow the points, up to three"}, {1, STR_C("1 R"), "One radius"}, {2, STR_C("2 R"), "A compound curve of two radii"}, {3, STR_C("3 R"), "A compound curve of three radii"}}); // the name on the left of the field, as in the inspector, the values to pick with a click under it if (begin_fields("##layspeed")) { @@ -2422,40 +2663,130 @@ void editor_mode::render_lay_ui() EditorSettings.heights(static_cast(heights)); EditorSettings.save(); } - // the curves of the line shown, those below the norms in the colour of a warning: they're laid all the same - if (auto const &plan{tool.plan}; tool.active && plan.shape.valid && false == plan.shape.curves.empty()) + render_lay_more(); +} + +void editor_mode::render_lay_quality() +{ + auto &tool{m_lay}; + auto const quality{lay_quality_now()}; + if (false == quality.valid) + return; + // the length, the curves and the slowest of them in a line, the norms as a badge; the curves one by one and what they break in the + // details it opens + auto line{quality.curves == 0 ? format(STR_C("Length %.0f m · straight"), quality.length) + : format(STR_P("Length %.0f m · %zu curve", "Length %.0f m · %zu curves", static_cast(quality.curves)), quality.length, quality.curves)}; + if (quality.curves > 0 && quality.slowest > 0.0) + line += format(STR_C(" · slowest %.0f km/h"), quality.slowest); + ImGui::TextWrapped("%s", line.c_str()); + auto const badge{quality.below == 0 ? std::string{STR_C("meets the norms")} + : format(STR_P("%zu curve below the norms for %.0f km/h", "%zu curves below the norms for %.0f km/h", static_cast(quality.below)), quality.below, quality.speed)}; + editor_flow::quality_badge("##layquality", badge.c_str(), quality.below == 0, STR_C("details"), tool.details_open); +} + +void editor_mode::render_lay_details() +{ + auto const &tool{m_lay}; + auto const &plan{tool.plan}; + auto const warning{editor_flow::kBelow}; + ImGui::Indent(); + ImGui::PushTextWrapPos(0.0f); + // the curves one by one, those below the norms in the colour of a warning: they're laid all the same; what each breaks, and what its + // label says, by the cursor over it + if (false == m_extend.active && plan.shape.valid) { - ImGui::SeparatorText(STR_C("Curves of the track laid")); - ImGui::TextDisabled("%s", STR_C("R: radius, L: transition curve (m), h: cant (mm)")); for (auto const &curve : plan.shape.curves) { - auto const meets{alignment::meets_norms(curve, plan.design)}; auto const text{format("%d. %s", curve.vertex + 1, curve_label(curve, laying_norms()).c_str())}; - if (meets) + if (alignment::meets_norms(curve, plan.design)) ImGui::TextUnformatted(text.c_str()); else - ImGui::TextColored(ImVec4(1.0f, 0.55f, 0.15f, 1.0f), "%s", text.c_str()); - if (ImGui::IsItemHovered()) - { - std::string notes; - auto const tag{format(STR_C("Vertex %zu"), static_cast(curve.vertex + 1))}; - for (auto const &warning : plan.shape.warnings) - if (warning.rfind(tag + ":", 0) == 0) - notes += (notes.empty() ? "" : "\n") + warning; - ImGui::SetTooltip("%s", notes.empty() ? STR_C("Meets the norms for the speed") : notes.c_str()); - } + ImGui::TextColored(warning, "%s", text.c_str()); + if (false == ImGui::IsItemHovered()) + continue; + std::string notes; + auto const tag{format(STR_C("Vertex %zu"), static_cast(curve.vertex + 1))}; + for (auto const ¬e : plan.shape.warnings) + if (note.rfind(tag + ":", 0) == 0) + notes += (notes.empty() ? "" : "\n") + note; + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(std::round(ImGui::GetFontSize() * 32.0f)); + ImGui::TextUnformatted(notes.empty() ? STR_C("Meets the norms for the speed") : notes.c_str()); + ImGui::TextDisabled("%s", STR_C("R: radius, L: transition curve (m), h: cant (mm)")); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } + // what the curves break, in the words of the norms, and what else the line shown was told + for (auto const ¬e : plan.shape.warnings) + ImGui::TextColored(warning, "%s", note.c_str()); + if (false == tool.preview_error.empty() && tool.preview_error != lines_of(plan.shape.warnings)) + ImGui::TextColored(warning, "%s", tool.preview_error.c_str()); + if (false == plan.shape.curves.empty()) + { + if (auto const on{curve_goes_on(plan.shape.curves.front())}; false == on.empty()) + ImGui::TextDisabled("%s", on.c_str()); + if (auto const on{curve_goes_on(plan.shape.curves.back())}; plan.shape.curves.size() > 1 && false == on.empty()) + ImGui::TextDisabled("%s", on.c_str()); + } + // how close a curve traced follows the points clicked along it + if (tool.mode == lay_mode::curve && false == plan.traces.empty() && false == plan.traces.back().offsets.empty()) + { + auto const &trace{plan.traces.back()}; + metric_tiles({{format("%zu", trace.points.size()), STR_C("points"), ImGui::GetColorU32(ImGuiCol_Text)}, + {format("%.0f cm", trace.rms * 100.0), STR_C("departure"), departure_colour(trace.rms)}, + {format("%.0f cm", trace.worst * 100.0), STR_C("at most"), departure_colour(trace.worst)}}); } } - if (auto *track{selected_track()}; track != nullptr) + else if (auto const eased{eased_of(m_eased_last)}; false == eased.empty()) + ImGui::TextDisabled("%s", eased.c_str()); + // the speed it's designed for, the grades, what the norms say of it where it goes on from a switch + auto const [from, to]{laying_ends()}; + ImGui::TextDisabled("%s", design_speed_of(from, to).c_str()); + auto const pieces{m_extend.active ? extend_preview() : tool.preview}; + if (auto const vertical{pieces.empty() ? std::string{} : vertical_of(pieces)}; false == vertical.empty()) + ImGui::TextDisabled("%s", vertical.c_str()); + std::vector exits; + if (m_extend.active) { - std::string reason; - if (editor_track::can_edit_geometry(*track, reason)) - render_extend_ui(); + editor_track::snap_target target; + auto const snapped{extend_snap(target) && target.track != nullptr}; + exits = switch_exit_warnings(m_extend.track, m_extend.point, snapped ? target.track : nullptr, target.position, pieces); } - if (false == ImGui::TreeNode(STR_C("More settings"))) + else + exits = switch_exit_warnings(tool.start.track, tool.points.empty() ? tool.mouse : tool.points.front(), tool.mouse_snap.track, tool.mouse_snap.position, pieces); + for (auto const &exit : exits) + ImGui::TextColored(warning, "%s", exit.c_str()); + ImGui::PopTextWrapPos(); + ImGui::Unindent(); +} + +void editor_mode::render_lay_buttons() +{ + auto &tool{m_lay}; + // the points clicked are no track until they're laid: Enter lays them, a single point is none + ImGui::BeginDisabled(tool.points.size() < 2); + if (main_button(STR_C("Lay (Enter)"), ImVec2(0.0f, 0.0f))) { - render_lay_status(); + // the cursor is over the panel: no free end under it to join + tool.mouse_snap = {}; + lay_enter(); + } + ImGui::EndDisabled(); + ImGui::SameLine(); + if (ImGui::Button(STR_C("Drop"))) + lay_cancel(); + item_tooltip("Drops the points not laid yet; Esc twice does the same"); +} + +void editor_mode::render_lay_more() +{ + auto &tool{m_lay}; + if (false == ImGui::TreeNode(STR_C("More settings"))) return; + if (tool.mode == lay_mode::curve) + { + ImGui::Checkbox(STR_C("Two curves with a straight between them, where the points show one"), &tool.straights_between); + item_tooltip("The points along the curve may make two curves, turning the same way or not, with a straight between them, where these follow the points much closer than one curve"); } ImGui::Checkbox(STR_C("This speed also on from a track with a speed of its own"), &tool.own_speed); item_tooltip("Off: a track laid on from another one, or joined to it, is designed for the speed of that track and takes it.\nOn: it's designed for the speed above and the new tracks get it.\nWhile laying: Ctrl+Shift+wheel"); @@ -2532,19 +2863,46 @@ void editor_mode::render_lay_ui() texture_row(0, STR_C("Rails"), tool.style.rail); texture_row(1, STR_C("Trackbed"), tool.style.ballast); } + // pieces added at the free end of the selected track, one by one + if (auto const *track{selected_track()}; track != nullptr) + { + std::string reason; + if (editor_track::can_edit_geometry(*track, reason)) + render_extend_ui(); + } ImGui::TreePop(); - render_lay_status(); } -void editor_mode::render_lay_status() +void editor_mode::render_lay_status(lay_state const State) { - auto const &tool{m_lay}; + auto &tool{m_lay}; if (scene::Layers.active() == null_handle) - ImGui::TextColored(ImVec4(1.0f, 0.7f, 0.2f, 1.0f), STR_C("The scenery isn't opened for editing: new track won't be saved")); - if (tool.active && false == tool.preview_error.empty()) - ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.3f, 1.0f), "%s", tool.preview_error.c_str()); - if (false == tool.status.empty()) - ImGui::TextWrapped("%s", tool.status.c_str()); + editor_flow::message_line(STR_C("The scenery isn't opened for editing: new track won't be saved"), ImVec4(1.0f, 0.7f, 0.2f, 1.0f)); + if (auto const error{lay_error()}; tool.active && State == lay_state::clicking && false == error.empty()) + editor_flow::message_line(error, tool.preview.empty() ? editor_flow::kRefused : ImVec4(1.0f, 0.7f, 0.2f, 1.0f)); + if (tool.status.empty()) + return; + if (State != lay_state::laid) + { + // a line laid before, taken back or gone on from since, isn't told any more + if (false == tool.laid_now) + editor_flow::message_line(tool.status, ImVec4(1.0f, 0.7f, 0.2f, 1.0f)); + return; + } + // the line laid: one line of it, what else there is to tell of it under the link beside it + auto const end{tool.status.find('\n')}; + editor_flow::message_line(tool.status.substr(0, end), editor_flow::kGood); + if (end == std::string::npos) + return; + same_line_if_fits(ImGui::CalcTextSize(STR_C("notes")).x + ImGui::GetFontSize() * 1.2f); + editor_flow::fold_link("##laynotes", STR_C("notes"), tool.notes_open); + if (false == tool.notes_open) + return; + ImGui::Indent(); + ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled)); + ImGui::TextWrapped("%s", tool.status.c_str() + end + 1); + ImGui::PopStyleColor(); + ImGui::Unindent(); } bool editor_mode::laid_shown() const diff --git a/application/editormodeselftest.cpp b/application/editormodeselftest.cpp index ba2b6dd9b..bd63b6ec3 100644 --- a/application/editormodeselftest.cpp +++ b/application/editormodeselftest.cpp @@ -241,6 +241,8 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c // expect laycursor the point the line of the lay tool goes to from its last point, in the plan // expect terrain <0|1> the terrain model made under the tracks as they're laid / around the camera within the // download area / the question of the terrain open +// expect laypanel the state of the panel of the lay tool, as its step tells it, and +// whether its settings are shown or folded to the line of their summary // expect steps the steps of the history Ctrl+Z takes back, the ones made together counted once // each expect logs SELFTEST PASS or SELFTEST FAIL; a failed one, or a command no group takes, // makes the run end with editor_selftest::failed_exit_code diff --git a/application/editormodeselftestexpect.cpp b/application/editormodeselftestexpect.cpp index bc2244665..5e72c4f4b 100644 --- a/application/editormodeselftestexpect.cpp +++ b/application/editormodeselftestexpect.cpp @@ -466,6 +466,21 @@ void expect_selected(std::string const &What, std::istringstream &Words, std::op expectation(glm::distance(*Selected, wanted) <= tolerance, What, format("%.3f %.3f %.3f", Selected->x, Selected->y, Selected->z), format("%.3f %.3f %.3f within %.3f", wanted.x, wanted.y, wanted.z, tolerance)); } +// expect laypanel : the state the panel of the lay tool is in, as the step at its top tells it, and whether its +// settings are shown or folded to the line of their summary +void expect_panel(std::string const &What, std::istringstream &Words, std::string const &Got) +{ + std::string wanted; + for (std::string word; Words >> word;) + wanted += (wanted.empty() ? "" : " ") + word; + if (wanted.empty()) + { + expectation(false, What, "malformed", "the state of the panel"); + return; + } + expectation(Got == wanted, What, Got, wanted); +} + // what the editor shows, for the expectations of what the user sees struct shown_state { @@ -477,6 +492,7 @@ struct shown_state std::string tool; std::map windows; // shortcuts, settings, weather, orthophoto std::optional selected; // where the node selected stands + std::string lay_panel; // the state of the panel of the lay tool and whether its settings are shown }; // the expectations of what the editor shows; false: no expectation of the kind @@ -498,6 +514,8 @@ bool expect_shown(std::string const &Kind, std::string const &What, std::istring expect_window(What, Words, Shown.windows); else if (Kind == "selected") expect_selected(What, Words, Shown.selected); + else if (Kind == "laypanel") + expect_panel(What, Words, Shown.lay_panel); else return false; return true; @@ -565,12 +583,23 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com { shown_state shown{m_switch.status, ui()->refusal_shown(), ui()->status_line(), m_lay.mouse, {{"grow", m_nmt_state.grow}, {"area", EditorSettings.terrain_model().area}, {"prompt", m_nmt_state.prompt}}, tool_name(ui()->mode()), - {{"shortcuts", m_shortcuts_open}, {"settings", m_settings_open}, {"weather", m_environment_open}, {"orthophoto", m_orthophoto_window}}, std::nullopt}; + {{"shortcuts", m_shortcuts_open}, {"settings", m_settings_open}, {"weather", m_environment_open}, {"orthophoto", m_orthophoto_window}}, std::nullopt, + shown_lay_panel()}; if (m_node != nullptr) shown.selected = m_node->location(); if (false == expect_shown(kind, what, words, shown)) expectation(false, what, "no expectation " + kind, - "cant, joint, records, speed, gauge, track, route, norms, findings, height, lift, includes, status, statuslacks, refusal, statusline, laycursor, terrain, tool, window, selected or steps"); + "cant, joint, records, speed, gauge, track, route, norms, findings, height, lift, includes, status, statuslacks, refusal, statusline, laycursor, terrain, tool, window, " + "selected, laypanel or steps"); } return selftest_result::handled; } + +std::string editor_mode::shown_lay_panel() const +{ + static char const *const states[]{"ready", "clicking", "laid", "extending"}; + auto const panel{lay_panel_state()}; + // the settings are shown before the first point and after the line is laid, folded to their line while the points are clicked + auto const shown{panel == lay_state::ready || panel == lay_state::laid || m_lay.settings_open}; + return std::string{states[static_cast(panel)]} + (shown ? " shown" : " folded"); +} diff --git a/application/editormodetrack.cpp b/application/editormodetrack.cpp index 91a3e77ab..dbd4d314d 100644 --- a/application/editormodetrack.cpp +++ b/application/editormodetrack.cpp @@ -15,6 +15,7 @@ http: #include "application/editorprojection.h" #include "application/editormodeshared.h" #include "application/editorgestures.h" +#include "application/editorflow.h" #include "editor/editorFormat.hpp" #include "editor/editorAlignmentStore.hpp" #include "editor/editorSwitchStore.hpp" @@ -2017,28 +2018,27 @@ std::vector editor_mode::track_key_hints(bool const All) std::vector hints; bool gizmo{false}; auto const *selected{selected_track()}; - if (m_lay.active) + // the lay tool: the three gestures of its state first, those the bar under the view shows, the others after them for the card and F1; + // a shape dragged out of a free end tells its own + if (m_lay.active && false == m_extend.active) { bool const curve{m_lay.mode == lay_mode::curve}; - auto const *tab{curve ? "back to the bends of straights" : "trace a curve on the photo"}; + auto const *tab{curve ? "back to the straights" : "a curve from the photo"}; + auto const *next{curve ? "the next point along the curve" : "the next bend"}; + auto const *alt{"the direction in steps of 15 degrees, or 1:9, 1:6.6... to a straight track"}; if (m_lay.points.empty()) - hints = {{"LMB", "start, on the ground or at a free end"}, {"Tab", tab}, {"Drag from a free end", "lays the shape to the cursor"}, {"Shift+click a straight", "a parallel track (N)"}, {"Alt", "the direction in steps of 15 degrees, or 1:9, 1:6.6... to a straight track"}, {"Esc", "stop laying"}}; + hints = {{"LMB", "the first point"}, {"LMB on a free end", "from the end"}, {"Tab", tab}, {"Drag from a free end", "lays the shape to the cursor"}, {"Shift+click a straight", "a parallel track (N)"}, {"Alt", alt}, {"Esc", "stop laying"}}; else if (m_lay.points.size() > 1) - { // the points clicked are no track until Enter: it comes right after the click, where the bar at the bottom shows it - hints = {{"LMB", curve ? "a point along the middle of the curve, which ends at the last one" : "a bend of the straights, eased with a large curve"}, {"Enter", "lay the points clicked"}, - {"Backspace", "take back the point"}, {"LMB on a free end", "join and lay"}, {"Tab", tab}, {"Alt", "the direction in steps of 15 degrees, or 1:9, 1:6.6... to a straight track"}, - {"Esc", "twice: drop the points not laid"}}; - } + hints = {{"LMB", next}, {"Enter", "lay"}, {"Backspace", "take back"}, {"LMB on a free end", "join and lay"}, {"Tab", tab}, {"Alt", alt}, {"Esc", "twice: drop the points not laid"}}; else { - hints = {{"LMB", curve ? "a point along the middle of the curve, which ends at the last one" : "a bend of the straights, eased with a large curve"}, {"LMB on a free end", "join and lay"}, {"Tab", tab}}; + hints = {{"LMB", next}, {"LMB on a free end", "join and lay"}, {"Backspace", "take back"}}; if (m_lay.mouse_snap.track != nullptr && m_lay.start.track != nullptr) hints.insert(hints.end(), {{"Ctrl+wheel", "radius"}, {"Shift+wheel", "another shape"}}); else if (m_lay.mouse_snap.track != nullptr && curve) hints.push_back({"Ctrl+wheel", "radius"}); - hints.insert(hints.end(), {{"Alt", "the direction in steps of 15 degrees, or 1:9, 1:6.6... to a straight track"}, {"Enter", "stop laying"}, - {"Backspace", "take back the point"}, {"Esc", "stop laying"}}); + hints.insert(hints.end(), {{"Ctrl+Shift+wheel", "speed"}, {"Tab", tab}, {"Alt", alt}, {"Enter", "stop laying"}, {"Esc", "stop laying"}}); } } else if (false == m_straights.detour.empty()) @@ -2054,7 +2054,7 @@ std::vector editor_mode::track_key_hints(bool const All) hints.insert(hints.end(), {{"Ctrl+wheel", "radius"}, {"Shift+wheel", "another shape"}}); else if (m_track_layout != track_layout::straight) hints.push_back({"Ctrl+wheel", "radius"}); - hints.insert(hints.end(), {{"Release", "build"}, {"Esc", "cancel"}}); + hints.insert(hints.end(), {{"Release", "build"}, {"Esc", "cancel"}, {"Ctrl+Shift+wheel", "speed"}}); } else if (m_switch.placing && m_switch.free) hints = m_switch.free_end.track != nullptr ? std::vector{{"Drag sideways", "side of the diverging track"}, @@ -2219,8 +2219,9 @@ std::vector editor_mode::track_key_hints(bool const All) *points = {"Drag an end", "a joint: the neighbours follow; a free end: a new track out of it, with Ctrl it moves"}; gizmo = false; } + // the length typed goes after the three gestures of the lay tool, which the bar under the view keeps to if (auto const *meaning{typed_meaning()}; meaning != nullptr) - hints.insert(hints.begin() + std::min(1, hints.size()), {"0-9", meaning}); + hints.insert(hints.begin() + std::min(m_lay.active && false == m_extend.active ? 3 : 1, hints.size()), {"0-9", meaning}); if (All) { if (gizmo && m_gizmo_snap > 0.0f) @@ -2278,6 +2279,9 @@ std::string editor_mode::track_readout() const return link_summary(target, link, editor_track::branch_radius(m_extend.track->m_paths[1])); if (snapped && pieces.empty()) return format(STR_C("no track fits to the end of %s"), name(target.track).c_str()); + auto const warnings{switch_exit_warnings(m_extend.track, m_extend.point, snapped ? target.track : nullptr, target.position, pieces)}; + if (m_lay.active) + return extend_leg(length, radius, snapped ? target.track : nullptr, false == warnings.empty()) + (reason.empty() ? std::string{} : "\n" + reason); auto text{radius > 0.0 ? format("L %.2f m R %.0f m", length, radius) + speed_of(radius, laying_norms()) : format("L %.2f m %s", length, STR_C("straight"))}; if (auto const eased{eased_of(m_eased_last)}; false == eased.empty()) text += "\n" + eased; @@ -2286,101 +2290,14 @@ std::string editor_mode::track_readout() const text += "\n" + vertical; if (snapped) text += "\n" + format(STR_C("joins %s"), name(target.track).c_str()); - for (auto const &warning : switch_exit_warnings(m_extend.track, m_extend.point, snapped ? target.track : nullptr, target.position, pieces)) + for (auto const &warning : warnings) text += "\n" + warning; if (false == reason.empty()) text += "\n" + reason; return text + "\n" + track_shaping(snapped); } if (m_lay.active) - { - auto const &lay{m_lay}; - // of a list of warnings only the first one by the cursor, the panel lists them all; named, not told by its side, which the - // docks can change - auto const first_of = [](std::string const &Lines) { - auto const end{Lines.find('\n')}; - if (end == std::string::npos) - return Lines; - auto const more{static_cast(std::count(Lines.begin() + end, Lines.end(), '\n'))}; - return Lines.substr(0, end) + "\n" + format(STR_P("and %zu more, listed in the tool options", "and %zu more, listed in the tool options", static_cast(more)), more); - }; - std::string text; - if (lay.points.empty()) - text = lay.mouse_snap.track != nullptr ? std::string{STR_C("goes on from this end of the track")} : std::string{STR_C("start")}; - else if (false == lay.preview.empty() && lay.plan.shape.valid) - { - // the curve the cursor makes now: of the last bend, or the one traced - auto const &plan{lay.plan}; - text = format("L %.1f m", lay.preview_length); - if (false == plan.shape.curves.empty()) - { - auto const &curve{plan.shape.curves.back()}; - text += " " + curve_label(curve, laying_norms()); - if (false == alignment::meets_norms(curve, plan.design)) - text += "\n" + STR("this curve doesn't meet the norms, it's laid all the same"); - // the curves next to the free ends going on from the curves of their tracks: the first and the last one - if (auto const on{curve_goes_on(plan.shape.curves.front())}; false == on.empty()) - text += "\n" + on; - if (auto const on{curve_goes_on(curve)}; plan.shape.curves.size() > 1 && false == on.empty()) - text += "\n" + on; - } - if (lay.mode == lay_mode::curve && false == plan.traces.empty() && false == plan.traces.back().offsets.empty()) - { - auto const &trace{plan.traces.back()}; - text += "\n" + format(STR_C("%zu points, departure %.0f cm, at most %.0f cm"), trace.points.size(), trace.rms * 100.0, trace.worst * 100.0); - } - auto const [from, to]{laying_ends()}; - text += "\n" + design_speed_of(from, to); - if (auto const vertical{vertical_of(lay.preview)}; false == vertical.empty()) - text += "\n" + vertical; - } - else if (false == lay.preview.empty()) - { - double radius{0.0}; - bool straight{false}; - for (auto const &piece : lay.preview) - { - auto const r{piece_plan_radius(piece)}; - if (r < 0.5) - straight = true; - else if (radius == 0.0 || r < radius) - radius = r; - } - if (m_eased_last.has_value() && false == m_eased_last->pieces.empty()) - radius = m_eased_last->radius; - if (radius > 0.0) - text = (straight ? format("L %.1f m %s + R %.0f m", lay.preview_length, STR_C("straight"), radius) : format("L %.1f m R %.0f m", lay.preview_length, radius)) + speed_of(radius, laying_norms()); - else - text = format("L %.1f m %s", lay.preview_length, STR_C("straight")); - if (auto const eased{eased_of(m_eased_last)}; false == eased.empty()) - text += "\n" + eased; - { - auto const [from, to]{laying_ends()}; - text += "\n" + design_speed_of(from, to); - } - if (auto const vertical{vertical_of(lay.preview)}; false == vertical.empty()) - text += "\n" + vertical; - } - for (auto const &warning : switch_exit_warnings(lay.start.track, lay.points.empty() ? lay.mouse : lay.points.front(), lay.mouse_snap.track, lay.mouse_snap.position, lay.preview)) - text += "\n" + warning; - if (false == lay.points.empty() && lay.mouse_snap.track != nullptr) - text += "\n" + format(STR_C("joins %s"), name(lay.mouse_snap.track).c_str()); - if (false == lay.preview_error.empty()) - text += "\n" + first_of(lay.preview_error); - if (lay.points.size() == 1 && lay.mouse_snap.track != nullptr) - text += "\n" + track_shaping(lay.start.track != nullptr); - // the bends are laid by default, the bar at the bottom tells of Tab: only the curve traced is named - if (lay.mode == lay_mode::curve) - text += "\n" + std::string{STR_C("Curve traced, Tab: the bends of straights")}; - if (ImGui::GetIO().KeyAlt && false == lay.points.empty()) - text += "\n" + (lay.skew.empty() ? format(STR_C("azimuth %.0f deg"), azimuth(lay.points.back(), lay.mouse)) : lay.skew); - // the warning of the first Esc leads, where it's read first - if (ImGui::GetTime() - lay.escape_time < 3.0) - text = lay.status + "\n" + text; - else if (false == lay.status.empty() && ImGui::GetTime() - lay.status_time < 4.0) - text += "\n" + first_of(lay.status); - return text; - } + return lay_readout(); auto const &state{m_straights}; if (state.tool_placed && state.tool_mouse) { @@ -2620,8 +2537,28 @@ void editor_mode::draw_track_hints() readout += (readout.empty() ? "" : "\n") + std::string{"= "} + m_typed + "_ " + STR(meaning); if (readout.empty() || ImGui::GetIO().WantCaptureMouse) return; + // a line with the sign of a warning in it is drawn in the colour of one, the sign drawn at its end: the font has no glyph of it + std::vector> lines; + std::size_t begin{0}; + while (begin <= readout.size()) + { + auto const end{std::min(readout.find('\n', begin), readout.size())}; + auto line{readout.substr(begin, end - begin)}; + auto const mark_at{line.find(editor_flow::kWarningMark)}; + auto const warned{mark_at != std::string::npos}; + if (warned) + line.erase(mark_at, editor_flow::kWarningMark.size()); + lines.emplace_back(std::move(line), warned); + begin = end + 1; + } + auto const mark{std::round(ImGui::GetTextLineHeight() * 0.9f)}; + ImVec2 size{0.0f, 0.0f}; + for (auto const &[line, warned] : lines) + { + size.x = std::max(size.x, ImGui::CalcTextSize(line.c_str()).x + (warned ? mark * 1.6f : 0.0f)); + size.y += ImGui::GetTextLineHeight(); + } auto *foreground{ImGui::GetForegroundDrawList(ImGui::GetMainViewport())}; - auto const size{ImGui::CalcTextSize(readout.c_str())}; // right below the cursor, or on its other side where the view ends: it doesn't cover the panels by the view auto const low{editor_ui::view_min()}; auto const high{editor_ui::view_max()}; @@ -2634,7 +2571,13 @@ void editor_mode::draw_track_hints() at.y = std::max(at.y, low.y + 10.0f); foreground->AddRectFilled(ImVec2(at.x - 6.0f, at.y - 4.0f), ImVec2(at.x + size.x + 6.0f, at.y + size.y + 4.0f), IM_COL32(0, 0, 0, 190), 4.0f); foreground->AddRect(ImVec2(at.x - 6.0f, at.y - 4.0f), ImVec2(at.x + size.x + 6.0f, at.y + size.y + 4.0f), overlay_color::marked, 4.0f); - foreground->AddText(at, IM_COL32(255, 255, 255, 255), readout.c_str()); + for (auto const &[line, warned] : lines) + { + foreground->AddText(at, warned ? overlay_color::warning : IM_COL32(255, 255, 255, 255), line.c_str()); + if (warned) + editor_flow::draw_warning(*foreground, ImVec2(at.x + ImGui::CalcTextSize(line.c_str()).x + mark * 0.9f, at.y + ImGui::GetTextLineHeight() * 0.5f), mark, overlay_color::warning); + at.y += ImGui::GetTextLineHeight(); + } } void editor_mode::draw_blade_tips() const @@ -3118,7 +3061,7 @@ void editor_mode::draw_build_overlay() const { for (auto const &curve : plan.shape.curves) if (curve.vertex >= 0 && curve.vertex < static_cast(plan.shape.vertex_chainages.size())) - label_at(alignment::evaluate(plan.shape, plan.shape.vertex_chainages[curve.vertex]).position, curve_label(curve, laying_norms()), + label_at(alignment::evaluate(plan.shape, plan.shape.vertex_chainages[curve.vertex]).position, curve_short(curve, laying_norms()), alignment::meets_norms(curve, plan.design) ? overlay_color::marked : overlay_color::warning); for (auto const &e : plan.shape.elements) if (e.kind == alignment::element_kind::straight && e.length >= 20.0) diff --git a/application/editormodetrackshared.h b/application/editormodetrackshared.h index 8c15ac319..4da767d4d 100644 --- a/application/editormodetrackshared.h +++ b/application/editormodetrackshared.h @@ -102,6 +102,24 @@ inline std::string curve_label(alignment::curve_report const &Curve, alignment:: return text + speed_of(curve_sharpest(Curve), Limits); } +// the radius of a curve, the radii of a compound one one after another +inline std::string curve_radii(alignment::curve_report const &Curve) +{ + if (Curve.radii.empty()) + return format("%.0f", Curve.radius); + std::string text; + for (std::size_t i = 0; i < Curve.radii.size(); ++i) + text += format(i == 0 ? "%.0f" : "/%.0f", Curve.radii[i]); + return text; +} + +// a curve of the line laid in a few words, for its label in the view: the radius and the speed its sharpest arc lets the trains through at +inline std::string curve_short(alignment::curve_report const &Curve, alignment::limits const &Limits) +{ + auto const speed{std::floor(alignment::speed_limit(curve_sharpest(Curve), Limits) / 5.0) * 5.0}; + return speed > 0.0 ? format(STR_C("R %s · up to %.0f km/h"), curve_radii(Curve).c_str(), speed) : "R " + curve_radii(Curve); +} + inline std::string lines_of(std::vector const &Texts) { std::string text; diff --git a/lang/editor_pl.po b/lang/editor_pl.po index a38bad646..31541b32a 100644 --- a/lang/editor_pl.po +++ b/lang/editor_pl.po @@ -10168,7 +10168,7 @@ msgid "Measure" msgstr "Miarka" msgid "Trace the curve on the photo" -msgstr "Odrysuj łuk ze zdjęcia" +msgstr "Odrysuj łuk z ortofotomapy" msgid "Click points along the middle of the track on the orthophoto: after each click the curve takes the radius, or the radii of a compound curve and their shares, which follow the points best. The straights and the transition curves stay" msgstr "Klikaj punkty po środku toru na ortofotomapie: po każdym kliknięciu łuk dobiera promień, albo promienie łuku koszowego i ich udziały, tak żeby szedł po punktach. Proste i krzywe przejściowe zostają" @@ -10192,7 +10192,7 @@ msgid "A compound curve of three radii" msgstr "Łuk koszowy z trzech promieni" msgid "Click points along the middle of the track on the photo, spread over the whole curve; a few on the straights at its ends help too" -msgstr "Klikaj punkty po środku toru na zdjęciu, rozłożone na cały łuk; kilka na prostych przy jego końcach też pomaga" +msgstr "Klikaj punkty po środku toru na ortofotomapie, rozłożone na cały łuk; kilka na prostych przy jego końcach też pomaga" msgid "points" msgstr "punktów" @@ -10216,7 +10216,7 @@ msgid "Click: take this point out" msgstr "LPM: usuń ten punkt" msgid "Click: a point in the middle of the track on the photo. Enter: apply, Esc: drop" -msgstr "LPM: punkt na środku toru na zdjęciu. Enter: zastosuj, Esc: porzuć" +msgstr "LPM: punkt na środku toru na ortofotomapie. Enter: zastosuj, Esc: porzuć" msgid "Click: one more point, the curve follows. Ctrl+click: take a point out" msgstr "LPM: kolejny punkt, łuk idzie za nimi. Ctrl+LPM: usuń punkt" @@ -11744,7 +11744,7 @@ msgid "Curve: click points along the middle of the track, the last two on the st msgstr "Łuk: klikaj punkty po środku toru, dwa ostatnie na prostej za łukiem. Tab: z powrotem proste" msgid "Straights: each point clicked is a bend of the straights, eased with a large curve. Tab: a curve traced on the photo" -msgstr "Proste: każdy kliknięty punkt to załamanie prostych, wyokrąglone dużym łukiem. Tab: łuk odrysowany ze zdjęcia" +msgstr "Proste: każdy kliknięty punkt to załamanie prostych, wyokrąglone dużym łukiem. Tab: łuk odrysowany z ortofotomapy" msgid "Straights Tab" msgstr "Proste Tab" @@ -11756,7 +11756,7 @@ msgid "Each point clicked is a bend of the straights: the bend eased with two tr msgstr "Każdy kliknięty punkt to załamanie prostych: wyokrąglone dwiema stycznymi krzywymi przejściowymi bez przechyłki, o dużym promieniu; gdzie się nie mieszczą, łukiem z krzywymi przejściowymi i przechyłką według norm, tak dużym, jak się mieści" msgid "Click points along the middle of a curve seen on the photo, the last two on the straight after it: the curve, compound or with a straight in it, is fitted to them. It comes from the straight before it, of the points clicked before or of the free end" -msgstr "Klikaj punkty po środku łuku widocznego na zdjęciu, dwa ostatnie na prostej za nim: łuk, także koszowy albo z prostą w środku, zostanie do nich dopasowany. Wychodzi z prostej przed nim, wyznaczonej punktami klikniętymi wcześniej albo wolnym końcem" +msgstr "Klikaj punkty po środku łuku widocznego na ortofotomapie, dwa ostatnie na prostej za nim: łuk, także koszowy albo z prostą w środku, zostanie do nich dopasowany. Wychodzi z prostej przed nim, wyznaczonej punktami klikniętymi wcześniej albo wolnym końcem" msgid "Radius of the curves at the bends" msgstr "Promień łuków na załamaniach" @@ -11780,7 +11780,7 @@ msgid "The points along the curve may make two curves, turning the same way or n msgstr "Punkty wzdłuż łuku mogą dać dwa łuki, w tę samą stronę albo przeciwne, z prostą między nimi, gdy trzymają się punktów dużo lepiej niż jeden łuk" msgid "Click points along the middle of the track on the photo, the last two on the straight after the curve" -msgstr "Klikaj punkty po środku toru na zdjęciu, dwa ostatnie na prostej za łukiem" +msgstr "Klikaj punkty po środku toru na ortofotomapie, dwa ostatnie na prostej za łukiem" msgid "Curves of the track laid" msgstr "Łuki kładzionego toru" @@ -11810,7 +11810,7 @@ msgid "back to the bends of straights" msgstr "z powrotem załamania prostych" msgid "trace a curve on the photo" -msgstr "odrysuj łuk ze zdjęcia" +msgstr "odrysuj łuk z ortofotomapy" msgid "a point along the middle of the curve, the last two on the straight after it" msgstr "punkt po środku łuku, dwa ostatnie na prostej za nim" @@ -11828,7 +11828,7 @@ msgid "Tab while laying" msgstr "Tab przy układaniu" msgid "The points clicked next go along the middle of a curve seen on the photo, the last two on the straight after it; Tab again: back to the bends" -msgstr "Następne punkty idą po środku łuku widocznego na zdjęciu, dwa ostatnie na prostej za nim; ponownie Tab: z powrotem załamania" +msgstr "Następne punkty idą po środku łuku widocznego na ortofotomapie, dwa ostatnie na prostej za nim; ponownie Tab: z powrotem załamania" msgid "Type the length of the next straight, Enter puts the point" msgstr "Wpisz długość następnej prostej, Enter stawia punkt" @@ -11891,7 +11891,7 @@ msgid "Keep to the points clicked" msgstr "Trzymaj się kliknięć" msgid "The scenery keeps the points clicked when the line was laid: a curve whose transitions or cants are changed gets its radii fitted to them again, so it stays where it was seen on the photo" -msgstr "Sceneria pamięta punkty kliknięte przy kładzeniu linii: łuk ze zmienioną przejściówką albo przechyłką dostaje promienie dopasowane do nich od nowa, więc zostaje tam, gdzie był widoczny na zdjęciu" +msgstr "Sceneria pamięta punkty kliknięte przy kładzeniu linii: łuk ze zmienioną przejściówką albo przechyłką dostaje promienie dopasowane do nich od nowa, więc zostaje tam, gdzie był widoczny na ortofotomapie" msgid "Fit all to them" msgstr "Dopasuj wszystkie" @@ -12123,13 +12123,13 @@ msgid "Every place where the line turns gets a curve, as big as fits. An orange msgstr "Każde miejsce, w którym linia skręca, dostaje łuk, tak duży, jak się zmieści. Pomarańczowy opis znaczy, że łuk nie spełnia przepisów dla prędkości ustawionej w panelu" msgid "A curve seen on the photo: click points along its middle, the last two on the straight after it; one of two or three radii comes out a compound curve" -msgstr "Łuk widoczny na zdjęciu: klikaj punkty wzdłuż jego środka, dwa ostatnie na prostej za nim; łuk o dwóch albo trzech promieniach wychodzi jako koszowy" +msgstr "Łuk widoczny na ortofotomapie: klikaj punkty wzdłuż jego środka, dwa ostatnie na prostej za nim; łuk o dwóch albo trzech promieniach wychodzi jako koszowy" msgid "Lay a track that turns" msgstr "Ułóż tor, który skręca" msgid "Press Tab to copy a curve from the photo" -msgstr "Naciśnij Tab, żeby odrysować łuk ze zdjęcia" +msgstr "Naciśnij Tab, żeby odrysować łuk z ortofotomapy" msgid "Change the size of the joining curve with Ctrl+wheel" msgstr "Zmień wielkość łuku łączącego Ctrl+kółkiem" @@ -12306,16 +12306,16 @@ msgid "To copy a curve from the orthophoto: press Tab, then click points along t msgstr "Żeby odrysować łuk z ortofotomapy: naciśnij Tab i klikaj punkty wzdłuż środka łuku; łuk skończy się na ostatnim" msgid "The points clicked next go along the middle of a curve seen on the photo, which ends at the last one; Tab again: back to the bends" -msgstr "Następne punkty idą po środku łuku widocznego na zdjęciu, który kończy się na ostatnim; ponownie Tab: z powrotem załamania" +msgstr "Następne punkty idą po środku łuku widocznego na ortofotomapie, który kończy się na ostatnim; ponownie Tab: z powrotem załamania" msgid "Curve: click points along the middle of the track, the curve ends at the last one. Tab: back to the straights" msgstr "Łuk: klikaj punkty po środku toru, łuk kończy się na ostatnim. Tab: z powrotem proste" msgid "Click points along the middle of a curve seen on the photo: the curve, compound or with a straight in it, is fitted to them and ends at the last one, heading as they do there. It comes from the straight before it, of the points clicked before or of the free end, and goes on with the curve of a free end, a switch too, where the points turn its way" -msgstr "Klikaj punkty po środku łuku widocznego na zdjęciu: łuk, także koszowy albo z prostą w środku, zostanie do nich dopasowany i kończy się na ostatnim, w kierunku, w jakim tam biegną. Wychodzi z prostej przed nim, wyznaczonej punktami klikniętymi wcześniej albo wolnym końcem, a gdy punkty skręcają w stronę łuku wolnego końca, także rozjazdu, ten łuk idzie dalej" +msgstr "Klikaj punkty po środku łuku widocznego na ortofotomapie: łuk, także koszowy albo z prostą w środku, zostanie do nich dopasowany i kończy się na ostatnim, w kierunku, w jakim tam biegną. Wychodzi z prostej przed nim, wyznaczonej punktami klikniętymi wcześniej albo wolnym końcem, a gdy punkty skręcają w stronę łuku wolnego końca, także rozjazdu, ten łuk idzie dalej" msgid "Click points along the middle of the track on the photo; the curve ends at the last one" -msgstr "Klikaj punkty po środku toru na zdjęciu; łuk kończy się na ostatnim" +msgstr "Klikaj punkty po środku toru na ortofotomapie; łuk kończy się na ostatnim" msgid "a point along the middle of the curve, which ends at the last one" msgstr "punkt po środku łuku, który kończy się na ostatnim" @@ -14719,3 +14719,113 @@ msgstr "Pod kursorem nie ma ziemi: model stoi %.0f m przed kamerą (%.0f, %.0f)" msgid "The diverging track %.0f km/h, the main one no limit" msgstr "Tor zwrotny %.0f km/h, zasadniczy bez ograniczenia" + +# scenery editor: the flow of the lay tool, a step at a time + +msgid "Click on the ground or at a free end of a track" +msgstr "Kliknij na terenie albo na wolnym końcu toru" + +msgid "Click the next bends" +msgstr "Klikaj kolejne załamania" + +msgid "Click points along the curve on the photo" +msgstr "Klikaj punkty wzdłuż łuku na ortofotomapie" + +msgid "Enter lays · Backspace takes back a point · Esc drops" +msgstr "Enter układa · Backspace cofa punkt · Esc porzuca" + +msgid "Backspace takes back the point · Esc drops" +msgstr "Backspace cofa punkt · Esc porzuca" + +msgid "Drag to lay from the end; let go to lay it" +msgstr "Przeciągnij, aby ułożyć od końca; puść, aby położyć" + +msgid "Laid %.0f m (%zu track) · Ctrl+Z undoes" +msgid_plural "Laid %.0f m (%zu tracks) · Ctrl+Z undoes" +msgstr[0] "Ułożono %.0f m (%zu tor) · Ctrl+Z cofa" +msgstr[1] "Ułożono %.0f m (%zu tory) · Ctrl+Z cofa" +msgstr[2] "Ułożono %.0f m (%zu torów) · Ctrl+Z cofa" + +msgid "notes" +msgstr "uwagi" + +msgid "Straights" +msgstr "Proste" + +msgid "along the ground" +msgstr "po terenie" + +msgid "through the points" +msgstr "przez punkty" + +msgid "level" +msgstr "poziomo" + +msgid "Length %.0f m · straight" +msgstr "Długość %.0f m · prosta" + +msgid "Length %.0f m · %zu curve" +msgid_plural "Length %.0f m · %zu curves" +msgstr[0] "Długość %.0f m · %zu łuk" +msgstr[1] "Długość %.0f m · %zu łuki" +msgstr[2] "Długość %.0f m · %zu łuków" + +msgid " · slowest %.0f km/h" +msgstr " · najwolniej %.0f km/h" + +msgid "meets the norms" +msgstr "zgodne z normami" + +msgid "%zu curve below the norms for %.0f km/h" +msgid_plural "%zu curves below the norms for %.0f km/h" +msgstr[0] "%zu łuk poniżej norm dla %.0f km/h" +msgstr[1] "%zu łuki poniżej norm dla %.0f km/h" +msgstr[2] "%zu łuków poniżej norm dla %.0f km/h" + +msgid "details" +msgstr "szczegóły" + +msgid "Drop" +msgstr "Porzuć" + +msgid "Drops the points not laid yet; Esc twice does the same" +msgstr "Porzuca punkty jeszcze nieułożone; to samo robi dwa razy Esc" + +msgid "curve R %s m · up to %.0f km/h" +msgstr "łuk R %s m · do %.0f km/h" + +msgid "curve R %s m" +msgstr "łuk R %s m" + +msgid "R %s · up to %.0f km/h" +msgstr "R %s · do %.0f km/h" + +msgid "Curve traced on the photo, Tab: the straights" +msgstr "Łuk odrysowany z ortofotomapy, Tab: proste" + +msgid "Straights, Tab: a curve traced on the photo" +msgstr "Proste, Tab: łuk odrysowany z ortofotomapy" + +msgid "the first point" +msgstr "pierwszy punkt" + +msgid "from the end" +msgstr "od końca" + +msgid "a curve from the photo" +msgstr "łuk z ortofotomapy" + +msgid "back to the straights" +msgstr "z powrotem proste" + +msgid "the next bend" +msgstr "następne załamanie" + +msgid "the next point along the curve" +msgstr "następny punkt łuku" + +msgid "take back" +msgstr "cofnij" + +msgid "Ctrl+Shift+wheel" +msgstr "Ctrl+Shift+kółko" diff --git a/tests/editor/README.md b/tests/editor/README.md index c7639ad04..71d65f27f 100644 --- a/tests/editor/README.md +++ b/tests/editor/README.md @@ -86,6 +86,7 @@ The expectations (`expect ...`), each logged as `SELFTEST PASS ` or | `expect statusline ` | the status line of the editor (also shown in the layers window) holds the text, or doesn't | | `expect laycursor ` | the point the line of the lay tool goes to from its last point clicked, in the plan | | `expect terrain <0\|1>` | the terrain model is made under the tracks as they're laid / around the camera within the download area / the question of the terrain of a new scenery is open | +| `expect laypanel ` | the state of the panel of the lay tool, as the step at its top tells it, and whether its settings are shown or folded to the line of their summary | | `expect steps ` | the steps of the history Ctrl+Z takes back, the ones made together counted once: none made by a change refused | | `expect tool ` | the tool of the surroundings in use: `select`, `insert`, `brush`, `fill`, `copy`, or `track` while the field of work of the tracks is | | `expect window <0\|1>` | the window of the shortcuts (F1), of the settings of the editor, of the weather and the time, of the settings of the orthophoto is open | @@ -132,3 +133,9 @@ and the consistency of the interface of the editor (P2 of the plan of the editor | --- | --- | | `c_1_bank_card_arms_insert` | a model of the node bank clicked with the select tool of the surroundings arms the insert tool with it; inserted where there's no ground under the cursor it stands at the height 0 where the cursor points, and the status says where | | `c_2_esc_closes_shortcuts` | Esc closes the window of the shortcuts, as F1 does, also in the tracks | + +and the flow of the lay tool, a step at a time: + +| case | fix | +| --- | --- | +| `lf_1_lay_panel_states` | the panel of the lay tool goes from ready, its settings shown, to clicking, its settings folded to a line, to the line laid told over the settings, and back to ready when it's taken back; the same in the mode of a curve traced | diff --git a/tests/editor/cases/lf_1_lay_panel_states.txt b/tests/editor/cases/lf_1_lay_panel_states.txt new file mode 100644 index 000000000..7807f6cd3 --- /dev/null +++ b/tests/editor/cases/lf_1_lay_panel_states.txt @@ -0,0 +1,34 @@ +# Laying flow: the panel of the lay tool goes through its states, each with its step at its top. Nothing clicked: its settings shown. +# Points clicked: the settings folded to the line of their summary. The line laid with Enter: told in one line over the settings +# shown again. Taken back with Ctrl+Z: ready, the line laid no more told. The same in the mode of a curve traced. The points go on +# the empty ground between the turntable tt1 and the curves (x 220..270), the camera straight above them +wait 5 +tap f3 +wait 2 +tap l +wait 2 +camera 245 200 150 245 0 150.5 +wait 3 +expect laypanel ready shown +layp 225 120 +wait 2 +expect laypanel clicking folded +layp 235 165 250 185 +wait 2 +expect laypanel clicking folded +layenter +wait 2 +expect laypanel laid shown +undo +wait 2 +expect laypanel ready shown +laymode curve +wait 2 +expect laypanel ready shown +layp 225 120 235 165 245 180 +wait 2 +expect laypanel clicking folded +laycancel +wait 2 +expect laypanel ready shown +quit