mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 05:09:20 +02:00
move bended model alongside track
This commit is contained in:
@@ -1656,6 +1656,12 @@ void editor_mode::render_bend()
|
|||||||
state.height = overhead + kRailTop;
|
state.height = overhead + kRailTop;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
double along{sweep->distance_at(bend_fixed(*sweep, state.point))};
|
||||||
|
if (ImGui::InputDouble(STR_C("along the track (m)"), &along, 0.1, 1.0, "%.2f"))
|
||||||
|
{
|
||||||
|
bend_stretch(*sweep, along, stretch, state.point, state);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
double length{stretch};
|
double length{stretch};
|
||||||
if (ImGui::InputDouble(STR_C("length (m)"), &length, 0.5, 5.0, "%.2f") && length > 0.1)
|
if (ImGui::InputDouble(STR_C("length (m)"), &length, 0.5, 5.0, "%.2f") && length > 0.1)
|
||||||
{
|
{
|
||||||
@@ -1708,6 +1714,7 @@ void editor_mode::render_bend()
|
|||||||
ImGui::SetTooltip("%s", STR_C("Puts the edge facing the track at the distance chosen from its axis, set back by the widening of the gauge in the curves.\n"
|
ImGui::SetTooltip("%s", STR_C("Puts the edge facing the track at the distance chosen from its axis, set back by the widening of the gauge in the curves.\n"
|
||||||
"Stands on the plane of the rail heads carried on to its edge: lower on the inner side of a canted curve,\n"
|
"Stands on the plane of the rail heads carried on to its edge: lower on the inner side of a canted curve,\n"
|
||||||
"higher on the outer one; on the inner side also set back by the cant times the height of the edge / 1.5"));
|
"higher on the outer one; on the inner side also set back by the cant times the height of the edge / 1.5"));
|
||||||
|
ImGui::TextDisabled("%s", STR_C("In the view: drag the blue cross along the track and aside; Shift: height; Ctrl: only along"));
|
||||||
if (changed)
|
if (changed)
|
||||||
bend_edit(state);
|
bend_edit(state);
|
||||||
if (ImGui::Button(STR_C("Done")))
|
if (ImGui::Button(STR_C("Done")))
|
||||||
@@ -1876,7 +1883,7 @@ bool editor_mode::bend_drag_start(int const Mods)
|
|||||||
if (false == projection.project(marker, screen))
|
if (false == projection.project(marker, screen))
|
||||||
return false;
|
return false;
|
||||||
auto const &mouse{ImGui::GetIO().MousePos};
|
auto const &mouse{ImGui::GetIO().MousePos};
|
||||||
if ((mouse.x - screen.x) * (mouse.x - screen.x) + (mouse.y - screen.y) * (mouse.y - screen.y) > 14.0f * 14.0f)
|
if ((mouse.x - screen.x) * (mouse.x - screen.x) + (mouse.y - screen.y) * (mouse.y - screen.y) > 18.0f * 18.0f)
|
||||||
return false;
|
return false;
|
||||||
tool.dragging = (Mods & GLFW_MOD_SHIFT) != 0 ? 2 : (Mods & GLFW_MOD_CONTROL) != 0 ? 3 : 1;
|
tool.dragging = (Mods & GLFW_MOD_SHIFT) != 0 ? 2 : (Mods & GLFW_MOD_CONTROL) != 0 ? 3 : 1;
|
||||||
tool.drag_state = sweep->definition();
|
tool.drag_state = sweep->definition();
|
||||||
@@ -1912,8 +1919,8 @@ void editor_mode::bend_drag_update()
|
|||||||
}
|
}
|
||||||
if (tool.over_marker)
|
if (tool.over_marker)
|
||||||
{
|
{
|
||||||
tool.label = STR("Drag: offset from the track");
|
tool.label = STR("Drag: along the track and aside");
|
||||||
tool.details = STR("Shift: height Ctrl: along the track");
|
tool.details = STR("Shift: height Ctrl: only along the track");
|
||||||
}
|
}
|
||||||
else if (ui()->mode() == nodebank_panel::MODIFY && m_input.mouse.button(GLFW_MOUSE_BUTTON_RIGHT) != GLFW_PRESS)
|
else if (ui()->mode() == nodebank_panel::MODIFY && m_input.mouse.button(GLFW_MOUSE_BUTTON_RIGHT) != GLFW_PRESS)
|
||||||
{
|
{
|
||||||
@@ -1957,6 +1964,26 @@ void editor_mode::bend_drag_update()
|
|||||||
auto const step{0.01};
|
auto const step{0.01};
|
||||||
auto const snap = [&](double const Value) { return std::round(Value / step) * step; };
|
auto const snap = [&](double const Value) { return std::round(Value / step) * step; };
|
||||||
auto state{tool.drag_state};
|
auto state{tool.drag_state};
|
||||||
|
auto const slide = [&](double const Shift) {
|
||||||
|
auto const span{(tool.drag_state.to < 0.0 ? sweep->length() : tool.drag_state.to) - tool.drag_state.from};
|
||||||
|
auto from{tool.drag_state.from + Shift};
|
||||||
|
auto to{from + span};
|
||||||
|
if (span > 0.1 && span <= sweep->length() + 1e-6)
|
||||||
|
{
|
||||||
|
if (from < 0.0)
|
||||||
|
{
|
||||||
|
to -= from;
|
||||||
|
from = 0.0;
|
||||||
|
}
|
||||||
|
if (to > sweep->length())
|
||||||
|
{
|
||||||
|
from = std::max(0.0, sweep->length() - span);
|
||||||
|
to = from + span;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state.from = from;
|
||||||
|
state.to = to;
|
||||||
|
};
|
||||||
if (tool.dragging == 2)
|
if (tool.dragging == 2)
|
||||||
{
|
{
|
||||||
glm::dvec3 origin, direction;
|
glm::dvec3 origin, direction;
|
||||||
@@ -1979,22 +2006,18 @@ void editor_mode::bend_drag_update()
|
|||||||
return;
|
return;
|
||||||
double lateral;
|
double lateral;
|
||||||
auto const station{sweep->project(point, lateral)};
|
auto const station{sweep->project(point, lateral)};
|
||||||
|
auto const shift{snap(station - tool.drag_station)};
|
||||||
|
slide(shift);
|
||||||
if (tool.dragging == 1)
|
if (tool.dragging == 1)
|
||||||
{
|
{
|
||||||
auto const at{sweep->frame_at(station)};
|
auto const at{sweep->frame_at(station)};
|
||||||
state.lateral = snap(lateral - sweep->setback(at));
|
state.lateral = snap(lateral - sweep->setback(at));
|
||||||
if (std::abs(state.lateral) < step)
|
if (std::abs(state.lateral) < step)
|
||||||
state.lateral = std::copysign(step, tool.drag_state.lateral);
|
state.lateral = std::copysign(step, tool.drag_state.lateral);
|
||||||
tool.drag_label = format(STR_C("%.2f m from the track axis"), std::abs(state.lateral));
|
tool.drag_label = format(STR_C("%.2f m from the track, %+.2f m along"), std::abs(state.lateral), shift);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
auto const shift{snap(station - tool.drag_station)};
|
|
||||||
state.from = tool.drag_state.from + shift;
|
|
||||||
if (tool.drag_state.to >= 0.0)
|
|
||||||
state.to = tool.drag_state.to + shift;
|
|
||||||
tool.drag_label = format(STR_C("%+.2f m along the track"), shift);
|
tool.drag_label = format(STR_C("%+.2f m along the track"), shift);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (false == (state == sweep->definition()))
|
if (false == (state == sweep->definition()))
|
||||||
sweep->define(state);
|
sweep->define(state);
|
||||||
|
|||||||
@@ -3638,6 +3638,9 @@ msgstr "od osi toru (m, + w prawo)"
|
|||||||
msgid "over the rail head (m)"
|
msgid "over the rail head (m)"
|
||||||
msgstr "nad główką szyny (m)"
|
msgstr "nad główką szyny (m)"
|
||||||
|
|
||||||
|
msgid "along the track (m)"
|
||||||
|
msgstr "wzdłuż toru (m)"
|
||||||
|
|
||||||
msgid "length (m)"
|
msgid "length (m)"
|
||||||
msgstr "długość (m)"
|
msgstr "długość (m)"
|
||||||
|
|
||||||
@@ -3686,6 +3689,18 @@ msgstr "Zapisz i otwórz"
|
|||||||
msgid "In the view: drag the blue cross sideways to set the offset, with Shift up and down, with Ctrl along the track"
|
msgid "In the view: drag the blue cross sideways to set the offset, with Shift up and down, with Ctrl along the track"
|
||||||
msgstr "W widoku: przeciągnij niebieski celownik w bok, żeby ustawić odsunięcie, z Shift w górę i w dół, z Ctrl wzdłuż toru"
|
msgstr "W widoku: przeciągnij niebieski celownik w bok, żeby ustawić odsunięcie, z Shift w górę i w dół, z Ctrl wzdłuż toru"
|
||||||
|
|
||||||
|
msgid "In the view: drag the blue cross along the track and aside; Shift: height; Ctrl: only along"
|
||||||
|
msgstr "W widoku: przeciągnij niebieski celownik wzdłuż toru i w bok; Shift: wysokość; Ctrl: tylko wzdłuż"
|
||||||
|
|
||||||
|
msgid "Drag: along the track and aside"
|
||||||
|
msgstr "Przeciągnij: wzdłuż toru i w bok"
|
||||||
|
|
||||||
|
msgid "Shift: height Ctrl: only along the track"
|
||||||
|
msgstr "Shift: wysokość Ctrl: tylko wzdłuż toru"
|
||||||
|
|
||||||
|
msgid "%.2f m from the track, %+.2f m along"
|
||||||
|
msgstr "%.2f m od toru, %+.2f m wzdłuż"
|
||||||
|
|
||||||
msgid "Drag: offset from the track; Shift: height; Ctrl: along the track"
|
msgid "Drag: offset from the track; Shift: height; Ctrl: along the track"
|
||||||
msgstr "Przeciągnij: odsunięcie od toru; Shift: wysokość; Ctrl: wzdłuż toru"
|
msgstr "Przeciągnij: odsunięcie od toru; Shift: wysokość; Ctrl: wzdłuż toru"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user