mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-08 22:07:20 +01:00
feat(editor): the drive of a switch stands by the tips of its blades, not at the joint before them, and goes with the switch deleted. A drive placed, changed or carried along with its switch is set where the blades begin, as they're shaped or where the diverging track is broken at the tip of a planed blade, along the main track there, its heading and its tilt taken there; the drives the earlier versions of the editor set at the joints are moved there once, as the scenery is opened and the templates are known, with no step of the undo history, to be saved with it. Deleting a switch, a double switch or a set of tracks takes the drives of the switches along in the same step, Ctrl+Z brings them back. The joint before the blades and the tips of the blades of the switch being placed or the one selected are marked across the track in the view, so the tips seen on the photo aren't taken for the start of the switch. Selftests bladetips, drivetips; on a copy of test42 the drive of z1 went from the joint to 1.248 m, deleted with z1, back with Ctrl+Z
This commit is contained in:
@@ -292,6 +292,41 @@ bool editor_mode::replace_switch_drive(TTrack &Switch, int const Family, bool co
|
||||
return true;
|
||||
}
|
||||
|
||||
void editor_mode::drives_deleted(std::vector<TTrack *> const &Switches)
|
||||
{
|
||||
if (m_history.empty())
|
||||
return;
|
||||
for (auto const *track : Switches)
|
||||
{
|
||||
if (track == nullptr || track->eType != tt_Switch)
|
||||
continue;
|
||||
auto const found{find_switch_drive(*track)};
|
||||
if (false == found.has_value() || false == scene::Layers.removable(found->standing.instance) || scene::Layers.instance(found->standing.instance).removed)
|
||||
continue;
|
||||
scene::Layers.removed(found->standing.instance, true);
|
||||
m_history.back().instances.push_back(found->standing.instance);
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t editor_mode::drives_to_blade_tips()
|
||||
{
|
||||
// the drives the earlier versions of the editor set at the joint before the blades among them
|
||||
std::vector<TTrack *> switches;
|
||||
std::vector<std::pair<scene::instance_handle, std::string>> before;
|
||||
for (auto *track : simulation::Paths.sequence())
|
||||
{
|
||||
if (track == nullptr || track->m_editorremoved || track->eType != tt_Switch)
|
||||
continue;
|
||||
if (auto const found{find_switch_drive(*track)}; found.has_value() && scene::Layers.removable(found->standing.instance))
|
||||
{
|
||||
switches.push_back(track);
|
||||
before.emplace_back(found->standing.instance, scene::Layers.directive(found->standing.instance));
|
||||
}
|
||||
}
|
||||
switch_drives_committed(switches);
|
||||
return static_cast<std::size_t>(std::count_if(before.begin(), before.end(), [](auto const &Before) { return scene::Layers.directive(Before.first) != Before.second; }));
|
||||
}
|
||||
|
||||
bool editor_mode::render_switch_drive_choice()
|
||||
{
|
||||
auto &tool{m_switch};
|
||||
|
||||
Reference in New Issue
Block a user