diff --git a/application/editormode.cpp b/application/editormode.cpp index 11160ea15..46c34c6b5 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -1915,6 +1915,9 @@ void editor_mode::render_settings() ImGui::SetTooltip("%s", STR_C("A line laid in the straights, or applied by the route design, becomes a line of the model of the track geometry: its tracks are made by the model, " "its edits checked against the norms and refused with the reasons, the project of the map kept next to it.\n" "The tracks there were stay as they are, edited the old way. Off, the editor works as it did")); + // taken when a scenery is opened: changed meanwhile, the model and the scene would go out of step + if (model != model_taken()) + ImGui::TextDisabled("%s", STR_C("Takes effect with the next scenery opened")); if (auto const error{model_error()}; model && false == error.empty()) ImGui::TextColored(ImVec4(1.0f, 0.6f, 0.2f, 1.0f), "%s", format(STR_C("The project of the map can't be opened: %s"), error.c_str()).c_str()); } @@ -2999,6 +3002,9 @@ void editor_mode::area_grow() auto const now{ImGui::GetTime()}; if (now - m_area_grow_time < 5.0 || m_area_drawing.active || m_orthophoto.area().empty() || (false == m_orthophoto.enabled() && false == m_lay.active)) return; + // every 5 s, whatever comes of it: set only by a growth, an area which didn't grow, or at its limit, was rastered and flood filled + // every frame + m_area_grow_time = now; auto const &config{m_orthophoto.settings()}; if (config.north == 0.0 && config.east == 0.0) return; @@ -3044,13 +3050,27 @@ void editor_mode::draw_orthophoto_failures() const screen_projection const projection; auto *drawlist{ImGui::GetBackgroundDrawList(ImGui::GetMainViewport())}; auto const height{static_cast(m_orthophoto.settings().height)}; + // in the 3D view on the ground, where the photo draped over it lies: at the height of the layer they stood off the tiles they mark + // where the terrain lies well above or below it. Seen from above the height doesn't matter + auto const grounded{m_orthophoto.settings().drape && false == Global.EditorOrtho}; auto const colour{IM_COL32(240, 70, 60, 210)}; std::size_t drawn{0}; for (auto const &[low, high] : failed) { if (++drawn > 400) break; - glm::dvec3 const corners[]{{low.x, height, low.y}, {high.x, height, low.y}, {high.x, height, high.y}, {low.x, height, high.y}}; + std::vector corners{{low.x, height, low.y}, {high.x, height, low.y}, {high.x, height, high.y}, {low.x, height, high.y}}; + if (grounded) + { + std::vector above{corners}; + for (auto &corner : above) + corner.y = 10000.0; + std::vector found; + auto const ground{ground_heights(above, false, &found)}; + for (std::size_t i = 0; i < corners.size(); ++i) + if (found[i] != 0) + corners[i].y = ground[i]; + } for (int i = 0; i < 4; ++i) projection.line(drawlist, corners[i], corners[(i + 1) % 4], colour, 2.0f); projection.line(drawlist, corners[0], corners[2], (colour & ~IM_COL32_A_MASK) | IM_COL32(0, 0, 0, 110), 1.5f); diff --git a/application/editormode.h b/application/editormode.h index 22ec753cc..d9a244ba7 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -1992,6 +1992,7 @@ class editor_mode : public application_mode, private editor_track::observer, pri }; std::optional shown; std::vector traced_key; // what the line traced shown was worked out for: its points, the free end reached, the edits + trace::settings traced_with; // and the settings of the trace: the setup, the norms // the cursor the line is being worked out for, kept till all its fits are done: what it was worked out from struct settling_cursor { @@ -2166,6 +2167,7 @@ class editor_mode : public application_mode, private editor_track::observer, pri mutable alignment::stretch_fitter m_stretch_fitter; // a fit the line asked the thread for isn't done yet: the line is one of the fits meanwhile mutable bool m_fits_waiting{false}; + mutable bool m_grades_waiting{false}; // the grade line of the line shown not fitted yet, a stopgap shown meanwhile // how much more the curve at the cursor was turned last to reach it, the first one tried for the next line mutable double m_turned_last{0.0}; void render_switch_ui(); @@ -3497,6 +3499,7 @@ class editor_mode : public application_mode, private editor_track::observer, pri glm::dvec3 offset{0.0}; // of the placement the coordinates of the text are in std::string baseline; // its own export as it was made: another one tells a change by the other tools std::string kind{"track"}; // "switch": a switch track of a turnout, kept by the main track of the turnout (line) + std::size_t of{0}; // the tracks the line was made of with it: fewer of them there, the others were taken away by another tool }; // how a run of commands goes on: the lines the user let write over, what's done after the last one struct model_context @@ -3505,6 +3508,7 @@ class editor_mode : public application_mode, private editor_track::observer, pri std::string surface; // of the tracks made, else the one of the tracks of the line, else the lay tool's std::function const &)> done; // with the tracks the last command made std::vector replaced; // old tracks the line made takes the place of, taken away in its step + bool joined{false}; // the step joined to the one before it: the commands of a batch after the first }; // the project, the managed tracks, the question waiting for an answer, the scenario index (editormodemodel.cpp); made as it's needed friend struct editor_model; @@ -3519,6 +3523,7 @@ class editor_mode : public application_mode, private editor_track::observer, pri void model_plan_drop(); // the setting is on and the project of the map is open bool model_on() const; + bool model_taken() const; // the setting as it was taken when the scenery was opened, for the session // opens the project of the map once the scenery is there, and looks after the questions waiting for the scenario index void model_update(); void model_open(); @@ -3616,6 +3621,7 @@ class editor_mode : public application_mode, private editor_track::observer, pri bool model_plan_commands(layout::line_id const Line, std::vector &Commands, std::string &Why) const; // a handle of the route design dragged on a line of the model: tried as it goes, drawn by the line and the mouse void model_plan_preview(); + std::string model_plan_key() const; // the design of the route as the preview of the model was worked out for it void draw_model_plan_preview() const; bool m_model_delete_confirmed{false}; // the old delete let through, the scenarios looked through selftest_result selftest_dispatch(std::string const &command, std::istringstream &words); diff --git a/application/editormodelay.cpp b/application/editormodelay.cpp index ceeb416bb..0da5e8aa0 100644 --- a/application/editormodelay.cpp +++ b/application/editormodelay.cpp @@ -263,7 +263,8 @@ void editor_mode::update_build_tools() for (auto const &point : points) traced_key.insert(traced_key.end(), {point.x, point.y, point.z}); traced_key.insert(traced_key.end(), {end.track != nullptr ? 1.0 : 0.0, static_cast(m_track_edits), static_cast(lay_heights_now()), lay.style.velocity}); - if (lay.shown.has_value() && traced_key == lay.traced_key) + // the setup and the norms the curves are checked by: "It's a side track" lays again a curve refused on a main one + if (lay.shown.has_value() && traced_key == lay.traced_key && trace_settings() == lay.traced_with) { auto const &shown{*lay.shown}; lay.preview = shown.preview; @@ -276,10 +277,15 @@ void editor_mode::update_build_tools() } } m_fits_waiting = false; + m_grades_waiting = false; m_follow_preview = true; lay.preview = lay_pieces(points, modes, end, lay.preview_length, lay.preview_error, &lay.plan); m_follow_preview = false; - lay.traced_key = traced_key; + // shown with a stopgap grade line while the fitter works on it: worked out again the next frame, not kept for these points, so the + // grade line fitted is taken once it's done rather than at the next click + lay.traced_key = m_grades_waiting ? std::vector{} : traced_key; + if (false == traced_key.empty()) + lay.traced_with = trace_settings(); if (false == m_fits_waiting || false == lay.whole) { lay.shown = lay_tool::worked_out{lay.preview, lay.preview_error, lay.preview_length, lay.plan, m_eased_last, m_join_last, lay.points}; @@ -2100,6 +2106,12 @@ bool editor_mode::traced_line(std::vector const &Points, editor_trac Error = line.error == "points" ? STR_C("Click at least two points") : STR_C("No line follows the points clicked along it"); return false; } + // no candidate reaching the free end, the line open at the last point: laid so, the end was taken for joined and a gap left + if (double constexpr kReached{0.05}; joined && plan_distance(line.design.end, End.position) > kReached) + { + Error = STR_C("No line follows the points clicked to the free end: click nearer to it, or lay the line to the last point"); + return false; + } Plan.traced = line; Plan.design = line.design; Plan.design.start.y = Points.front().y; @@ -2312,7 +2324,6 @@ void editor_mode::lay_click() tool.modes.push_back(tool.mode); tool.sigmas.push_back(click_sigma_at(point)); tool.heights.push_back(tool.mouse_height); - tool.continuing = false; if (lay_traced() && tool.points.size() >= 3) first_step_done(first_step::trace_points); // a point clicked near the edge of the view: the view glides on to bring it nearer to the middle @@ -2671,7 +2682,9 @@ bool editor_mode::lay_terrain_coming_at(std::size_t const Index) const editorSettings::lay_heights editor_mode::lay_heights_now() const { - return click_heights::heights_for(EditorSettings.heights(), m_lay.mode == lay_mode::traced, m_lay.heights_chosen); + // the points traced on the photo are sparse, the ground rising and falling between them; a track dragged out of a free end isn't + // made of them, so it keeps the setting while the clicks are traced + return click_heights::heights_for(EditorSettings.heights(), m_lay.mode == lay_mode::traced && false == m_extend.active, m_lay.heights_chosen); } bool editor_mode::lay_terrain_coming() const diff --git a/application/editormodemodel.cpp b/application/editormodemodel.cpp index 8916f05a3..ef920c883 100644 --- a/application/editormodemodel.cpp +++ b/application/editormodemodel.cpp @@ -103,9 +103,10 @@ std::optional &run_setting() return value; } +// a self-test which sets none edits the old way, whatever the tester ticked in their own editor: the older cases are written for it bool model_setting() { - return run_setting().value_or(EditorSettings.model_editing()); + return run_setting().value_or(selftest_script("EU07_EDITOR_SELFTEST") == nullptr && EditorSettings.model_editing()); } void expectation(bool const Passed, std::string const &What, std::string const &Got, std::string const &Wanted) @@ -293,15 +294,25 @@ void editor_mode::model_plan_drop() bool editor_mode::model_on() const { - return model_setting() && model().session.is_open(); + return model().on && model().session.is_open(); +} + +bool editor_mode::model_taken() const +{ + return model().on; } void editor_mode::model_update() { - if (false == model_setting()) - return; - if (false == model().tried && Global.editor_session && false == scene::Layers.empty()) - model_open(); + if (false == model().tried) + { + if (false == Global.editor_session || scene::Layers.empty()) + return; + model().tried = true; + model().on = model_setting(); + if (model().on) + model_open(); + } if (false == model_on()) return; // the index built is taken, and kept between the sessions @@ -349,10 +360,12 @@ void editor_mode::model_open() model().tracks.clear(); std::map> files; std::map counts; + std::map written; for (auto const &node : model().session.project().generated) { if (node.kind != "track" && node.kind != "switch") continue; + ++written[node.line]; auto *track{simulation::Paths.find(node.name)}; if (track == nullptr || track->m_editorremoved) continue; @@ -374,6 +387,9 @@ void editor_mode::model_open() entry.baseline = export_of(*track); model().tracks[track] = std::move(entry); } + // a track the files had and the scene hasn't is one of the line taken away, as one the user takes away later + for (auto &[node, entry] : model().tracks) + entry.of = written[entry.line]; scene::Layers.path_writer = [this](TTrack const &Track, glm::dvec3 const &Offset) { return model_path_text(Track, Offset); }; // the scenario index of the map built in the background, kept between the sessions (not for the self-tests, which leave nothing behind) auto &store{model().store}; @@ -417,12 +433,32 @@ std::vector editor_mode::model_line_tracks(layout::line_id const Line) std::set editor_mode::model_seen_changed() const { std::set result; + // a line short of tracks: some of the ones the model made taken away by another tool, a switch put in say. The model's own steps, + // their undos and redos with them, take a line's tracks away and bring them back all together + struct line_count + { + std::size_t there{0}; // the tracks of the line in the scene + std::size_t made{0}; // of how many the model made of it with them + bool known{false}; // tracks of it were made, all of them gone now where none is there + }; + std::map counts; for (auto const &[node, entry] : model().tracks) { auto const *track{dynamic_cast(node)}; - if (track != nullptr && false == track->m_editorremoved && false == result.contains(entry.line) && export_of(*track) != entry.baseline) + if (track == nullptr) + continue; + auto &line{counts[entry.line]}; + line.known = line.known || entry.of > 0; + if (track->m_editorremoved) + continue; + ++line.there; + line.made = std::max(line.made, entry.of); + if (false == result.contains(entry.line) && export_of(*track) != entry.baseline) result.insert(entry.line); } + for (auto const &[id, line] : counts) + if ((line.there < line.made || (line.there == 0 && line.known)) && model().session.network().find(id) != nullptr) + result.insert(id); return result; } @@ -521,10 +557,20 @@ void editor_mode::model_run(std::vector Commands, model_context return; } created = model_tracks_after(applied.token, before, applied.changed, applied.removed, Context); + // the commands of one batch after the first joined to it: one Ctrl+Z takes back all of it, none leaves the line half edited + Context.joined = true; std::string what{format(STR_C("%s: done"), STR_C(layout::command_name(command)))}; if (false == applied.changed.empty()) what = format(STR_P("%s: line %s, %zu track", "%s: line %s, %zu tracks", static_cast(created.size())), STR_C(layout::command_name(command)), line_name(*applied.changed.begin()).c_str(), created.size()); model_told(applied.outcome, false, what); + // what the generator couldn't make as the line has it, told with the outcome: the tracks are laid, a piece a few millimetres + // off the line say, so it isn't refused + for (auto const &error : model().made_errors) + if (std::ranges::find(model().notices, error) == model().notices.end()) + { + model().notices.push_back(error); + model().shown_notices.push_back(error); + } Commands.erase(Commands.begin()); } if (Context.done) @@ -559,6 +605,7 @@ std::vector editor_mode::model_tracks_after(std::uint64_t const Token, turnouts.insert(id); std::vector removed; auto surface{Context.surface}; + model().made_errors.clear(); for (auto const line : going) for (auto *track : model_line_tracks(line)) { @@ -605,7 +652,10 @@ std::vector editor_mode::model_tracks_after(std::uint64_t const Token, { auto const made{model().session.generate(line)}; for (auto const &error : made.errors) + { WriteLog("Editor: model: the tracks of line " + line_name(line) + ": " + error, logtype::generic); + model().made_errors.push_back(error); + } for (auto const &piece : made.pieces) put(line, piece.text, piece.name, "track"); } @@ -616,7 +666,10 @@ std::vector editor_mode::model_tracks_after(std::uint64_t const Token, continue; auto const made{model().session.generate(id)}; for (auto const &error : made.errors) + { WriteLog(format("Editor: model: the tracks of turnout %u: %s", layout::number(id), error.c_str()), logtype::generic); + model().made_errors.push_back(error); + } if (made.parts.empty()) put(turnout->main, made.text, made.name, "switch"); for (auto const &part : made.parts) @@ -633,6 +686,8 @@ std::vector editor_mode::model_tracks_after(std::uint64_t const Token, editor_track::commit(created); for (auto &[track, entry] : entries) { + // the tracks the line was made of, its turnouts' switch tracks among them + entry.of = indices[entry.line]; entry.baseline = export_of(*track); model().tracks[track] = std::move(entry); } @@ -649,6 +704,8 @@ std::vector editor_mode::model_tracks_after(std::uint64_t const Token, g_redo.clear(); } m_history.back().model_token = Token; + if (Context.joined) + m_history.back().joined = true; if (std::ranges::any_of(removed, [&](TTrack const *Track) { return Track == m_node; })) { m_node = created.empty() ? nullptr : created.back(); @@ -732,7 +789,11 @@ void editor_mode::model_saved(bool const Success) std::string error; if (false == model().session.save(error)) { - ui()->set_status(format(STR_C("The project of the map isn't saved: %s"), error.c_str()), true); + auto status{format(STR_C("The project of the map isn't saved: %s"), error.c_str())}; + // the scenery just saved without the assumptions of the project: they're in neither file till the next save puts them back + if (m_setup_moving) + status += "\n" + STR("Save again: till then the assumptions of the project are in neither file"); + ui()->set_status(status, true); WriteLog("Editor: the project of the map isn't saved: " + error, logtype::generic); setup_project_saved(false); return; @@ -1376,8 +1437,13 @@ editor_mode::selftest_result editor_mode::selftest_model(std::string const &comm words >> on; // for this run, not kept in the settings of the editor run_setting() = on != 0; - if (on != 0 && false == model().tried && false == scene::Layers.empty()) - model_open(); + model().on = on != 0; + if (on != 0 && false == scene::Layers.empty()) + { + model().tried = true; + if (false == model().session.is_open()) + model_open(); + } WriteLog(format("SELFTEST modelediting %d: the project %s, %zu lines", on, model().session.is_open() ? "open" : "not open", model().session.network().lines().size())); return selftest_result::handled; } @@ -1726,18 +1792,48 @@ editor_mode::selftest_result editor_mode::selftest_model(std::string const &comm } if (what == "modelspacing") { - // how far the other line runs from the point of the line at the chainage, within the bounds - unsigned line{0}, other{0}; - double chainage{0.0}, low{0.0}, high{0.0}; + // how far the other line runs from the point of the line at the chainage, within the bounds: above 0 to the left of the line as it + // runs (left_of, as the offset of the parallel tool), below 0 to its right, so a line laid on the other side fails it + unsigned line{0}; + unsigned other{0}; + double chainage{0.0}; + double low{0.0}; + double high{0.0}; words >> line >> other >> chainage >> low >> high; auto const *one{model_network().find(static_cast(line))}; auto const *two{model_network().find(static_cast(other))}; auto got{std::numeric_limits::quiet_NaN()}; if (one != nullptr && two != nullptr && one->solved.valid() && two->solved.valid()) - layout::chainage_of(two->solved, one->solved.position(std::clamp(chainage, 0.0, one->solved.length)), &got); + { + auto const at{std::clamp(chainage, 0.0, one->solved.length)}; + auto const point{one->solved.position(at)}; + auto const across{two->solved.position(layout::chainage_of(two->solved, point, &got))}; + if (glm::dot(across - point, layout::left_of(glm::normalize(one->solved.tangent(at)))) < 0.0) + got = -got; + } expectation(got >= low && got <= high, format("modelspacing %u %u %.1f", line, other, chainage), format("%.4f", got), format("%.4f .. %.4f", low, high)); return selftest_result::handled; } + if (what == "modelside") + { + // the side the diverging track of the switch leaves its main track to, as the switch runs from its start: right where the + // cross product of the two in the plan is above 0, as a switch record has R (switch_store::classify), left below it + std::string name; + std::string wanted; + words >> name >> wanted; + auto const *track{simulation::Paths.find(name)}; + std::string got{"none"}; + if (track != nullptr && false == track->m_editorremoved && track->eType == tt_Switch && track->m_paths.size() >= 2) + { + auto const &main{track->m_paths[0].points}; + auto const &diverging{track->m_paths[1].points}; + auto const along{glm::dvec2{main[segment_data::point::end].x - main[segment_data::point::start].x, main[segment_data::point::end].z - main[segment_data::point::start].z}}; + auto const off{glm::dvec2{diverging[segment_data::point::end].x - main[segment_data::point::start].x, diverging[segment_data::point::end].z - main[segment_data::point::start].z}}; + got = along.x * off.y - along.y * off.x > 0.0 ? "right" : "left"; + } + expectation(got == wanted, "modelside " + name, got, wanted); + return selftest_result::handled; + } if (what == "modelnodes") { // the nodes of the model: a line laid on from the free end of another one shares the node there @@ -1794,7 +1890,10 @@ editor_mode::selftest_result editor_mode::selftest_model(std::string const &comm std::string wanted; words >> wanted; auto const &preview{model().preview}; - auto const got{preview.key.empty() ? std::string{"none"} : std::string{"shown"}}; + auto got{preview.key.empty() ? std::string{"none"} : std::string{"shown"}}; + // current: worked out for the design as it is now, not left as the first frame of the drag showed it + if (wanted == "current" && false == preview.key.empty()) + got = preview.key == model_plan_key() ? "current" : "stale"; expectation(got == wanted, "modelpreview " + wanted, got + (preview.key.empty() ? "" : (preview.refused ? " refused: " : ": ") + editor_selftest::one_line(preview.text)), wanted); return selftest_result::handled; } diff --git a/application/editormodemodel.h b/application/editormodemodel.h index 460f5d533..bf86a8099 100644 --- a/application/editormodemodel.h +++ b/application/editormodemodel.h @@ -50,7 +50,11 @@ struct model_question struct editor_model { project::session session; - bool tried{false}; // the project opened for the scenery, or failed to + bool tried{false}; // the setting taken for the scenery opened, the project opened if it's on, or failed to + // the setting as it was when the scenery was opened, kept for the session: turned on later, an edit made the old way before was + // written back as the file had it; turned off before a save, the scenery was saved without its project. A change of it takes + // effect with the next scenery opened + bool on{false}; std::string error; std::unordered_map tracks; project::index_cache index; @@ -75,6 +79,7 @@ struct editor_model glm::dvec3 offset{0.0}; }; std::vector written; + std::vector made_errors; // of the generator, by the tracks of the last command std::map marks; // the self-test's copies of the network, for expect modelsame std::string shown; // the message as the user reads it, in the language of the editor std::vector shown_notices; // the notices so diff --git a/application/editormodemodeledit.cpp b/application/editormodemodeledit.cpp index 8f737c513..4de8bb8a6 100644 --- a/application/editormodemodeledit.cpp +++ b/application/editormodemodeledit.cpp @@ -145,7 +145,13 @@ bool editor_mode::model_profile_apply() state.error = model_shown(); return true; } - if (command.grades == line->shape.grades) + // the same breaks, within what taking the chainages to the route and back changes of them: compared exactly, an Apply with no edit + // added a step + auto const unchanged{std::ranges::equal(command.grades, line->shape.grades, [](auto const &A, auto const &B) { + double constexpr kNear{1e-6}; + return std::abs(A.chainage - B.chainage) < kNear && std::abs(A.elevation - B.elevation) < kNear && std::abs(A.vertical_radius - B.vertical_radius) < kNear * std::max(1.0, B.vertical_radius); + })}; + if (unchanged) { state.status = STR_C("Nothing changed"); return true; @@ -252,6 +258,14 @@ void editor_mode::model_plan_reload(layout::line_id const Line) // a handle of the route design dragged on a line of the model: the line as the model lays it and the norms' line, before it's let go +std::string editor_mode::model_plan_key() const +{ + std::string key; + for (auto const &vertex : m_route.design.vertices) + key += format("%.4f %.4f %.4f %.3f %.3f %.3f %.1f;", vertex.position.x, vertex.position.y, vertex.offset, vertex.radius, vertex.transition_in, vertex.transition_out, vertex.cant); + return key; +} + void editor_mode::model_plan_preview() { auto &preview{model().preview}; @@ -263,9 +277,7 @@ void editor_mode::model_plan_preview() } // the first and the last vertex of two or more are dragged along the tangents of the ends by their offsets, which their positions // don't follow (model_plan_commands places them so): without the offset the preview stayed as its first frame showed it - std::string key; - for (auto const &vertex : m_route.design.vertices) - key += format("%.4f %.4f %.4f %.3f %.3f %.3f %.1f;", vertex.position.x, vertex.position.y, vertex.offset, vertex.radius, vertex.transition_in, vertex.transition_out, vertex.cant); + auto const key{model_plan_key()}; if (key == preview.key) return; preview = {}; diff --git a/application/editormodenmt.cpp b/application/editormodenmt.cpp index 5e8cd7c47..416cfc8df 100644 --- a/application/editormodenmt.cpp +++ b/application/editormodenmt.cpp @@ -2519,6 +2519,10 @@ void editor_mode::nmt_place_scenery(glm::dvec2 const &Point) state.under = false; state.anchors.clear(); state.anchor_cells.clear(); + // the line in the panel of the laying waited for the scenery to be placed on the map: its terrain loads now, as the offer has it. + // Left so, the line said the scenery wasn't placed and nothing loaded + if (state.prompt && false == state.offer_loading && m_nmt.placed()) + nmt_accept_offer(); } void editor_mode::nmt_offer() diff --git a/application/editormodeprofile.cpp b/application/editormodeprofile.cpp index 31dec8c22..553d6b705 100644 --- a/application/editormodeprofile.cpp +++ b/application/editormodeprofile.cpp @@ -776,6 +776,8 @@ void editor_mode::profile_open(TTrack *From, TTrack *To) auto &state{m_profile}; state.open = true; state.status.clear(); + // what was wrong with the route opened before isn't of this one + state.error.clear(); editor_track::route route; if (false == editor_track::find_route(From, To, route, state.error)) return; diff --git a/application/editormoderoute.cpp b/application/editormoderoute.cpp index 9656f96cb..81e0d6e0e 100644 --- a/application/editormoderoute.cpp +++ b/application/editormoderoute.cpp @@ -1622,7 +1622,11 @@ void editor_mode::render_route_gizmo() continue; auto const secant{1.0 / std::cos(curve.deflection * 0.5) - 1.0}; if (secant > 1e-6) + { vertex.radius = std::max(10.0, std::round(distance / secant)); + // the speed a trace laid the curve slower for was of the radius it fitted + vertex.speed = 0.0; + } } route_update(); model_plan_preview(); @@ -2192,7 +2196,14 @@ bool editor_mode::render_route_vertex(int const Index) item_tooltip("The curve begins right at the end of the fragment, at the curvature of the track adjoining there, where it turns the same way; its radius is the one " "which begins it there, the transition at that end goes between the two curves"); } - changed |= field("##radius", vertex.radius, 5.0f, vertex.compound ? STR_C("R1 %.0f m") : STR_C("R %.0f m"), overlay_color::grip, "Radius of the arc: drag sideways, or a double click to type it", part::arc); + // a curve a trace laid slower than the line: told, and laid at the speed of the line once its radius is changed, made wider say + if (vertex.speed > 0.0) + ImGui::TextDisabled("%s", format(STR_C("Laid for %.0f km/h, slower than the line: a change of its radius lays it at the speed of the line"), vertex.speed).c_str()); + if (field("##radius", vertex.radius, 5.0f, vertex.compound ? STR_C("R1 %.0f m") : STR_C("R %.0f m"), overlay_color::grip, "Radius of the arc: drag sideways, or a double click to type it", part::arc)) + { + changed = true; + vertex.speed = 0.0; + } ImGui::SameLine(); changed |= field("##cant", vertex.cant, 1.0f, STR_C("cant %.0f mm"), IM_COL32(240, 170, 60, 255), vertex.compound ? "Height of the outer rail above the inner one on the sharpest arc; the arcs with no cant of their own get it in proportion to their curvature" diff --git a/application/editormodeselftest.cpp b/application/editormodeselftest.cpp index c80bee905..dbd9788ee 100644 --- a/application/editormodeselftest.cpp +++ b/application/editormodeselftest.cpp @@ -145,6 +145,8 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c // Tab; curve: a curve traced between bends, the shape of before, reached by the self-test alone; default: // as the user who hasn't chosen, traced where the photo is on // laysigma the noise of the clicks from now on; 0: two pixels of the view at each +// laysettings <0|1> the settings of the lay tool opened under the line of their summary, or folded into it, as a +// click on that line does while the points are clicked // endcurves logs every free end of the rails: where, the way out and the curvature its track goes on with // curvejoint logs the paths meeting at the end nearest the point, the curvature of each and its jump from the ones before to the ones after // cantcheck