From 19b2f10d1dba660ad725c3f1bf0c59a1cbad3bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20de=20Vill=C3=A8le?= <25150288+Thibaulltt@users.noreply.github.com> Date: Wed, 25 Mar 2026 02:31:23 +0100 Subject: [PATCH 1/4] feat: add a per-structure slicing plane button --- src/structure.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/structure.cpp b/src/structure.cpp index 9e6c3ee2..9386ffe3 100644 --- a/src/structure.cpp +++ b/src/structure.cpp @@ -92,22 +92,34 @@ void Structure::buildUI() { // Toggle whether slice planes apply if (ImGui::BeginMenu("Slice planes")) { + if (ImGui::Button("Add slice plane")) { + openSlicePlaneMenu = true; + addSlicePlane(); + } + if (ImGui::Button("...for this structure only")) { + openSlicePlaneMenu = true; + SlicePlane* plane = addSlicePlane(std::string("Slice plane of ") + this->name); + /* Set all structures to ignore this plane, except for this one in particular! */ + for (auto const& supermap: state::structures) { + for (auto const& map: supermap.second) { + map.second->setIgnoreSlicePlane(plane->name, supermap.first != this->typeName() or map.first != this->name); + } + } + } + ImGui::Separator(); + ImGui::TextUnformatted("Applies to this structure:"); + ImGui::Indent(20); if (state::slicePlanes.empty()) { // if there are none, show a helpful message - if (ImGui::Button("Add slice plane")) { - openSlicePlaneMenu = true; - addSlicePlane(); - } + ImGui::TextWrapped("< none >"); } else { // otherwise, show toggles for each - ImGui::TextUnformatted("Applies to this structure:"); - ImGui::Indent(20); for (std::unique_ptr& s : state::slicePlanes) { bool ignorePlane = getIgnoreSlicePlane(s->name); if (ImGui::MenuItem(s->name.c_str(), NULL, !ignorePlane)) setIgnoreSlicePlane(s->name, !ignorePlane); } - ImGui::Indent(-20); } + ImGui::Indent(-20); ImGui::TextUnformatted(""); ImGui::Separator(); ImGui::TextUnformatted("Note: Manage slice planes in"); From 9f340c1603f55107362ccfbb92e7dd1c12a031f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20de=20Vill=C3=A8le?= <25150288+Thibaulltt@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:01:40 +0100 Subject: [PATCH 2/4] fix: don't try to be fancy with names --- src/structure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structure.cpp b/src/structure.cpp index 9386ffe3..da8bf5e6 100644 --- a/src/structure.cpp +++ b/src/structure.cpp @@ -98,7 +98,7 @@ void Structure::buildUI() { } if (ImGui::Button("...for this structure only")) { openSlicePlaneMenu = true; - SlicePlane* plane = addSlicePlane(std::string("Slice plane of ") + this->name); + SlicePlane* plane = addSlicePlane(); /* Set all structures to ignore this plane, except for this one in particular! */ for (auto const& supermap: state::structures) { for (auto const& map: supermap.second) { From 82857b129395c9f05293b4f5f9fa294fe143e0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20de=20Vill=C3=A8le?= <25150288+Thibaulltt@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:15:25 +0100 Subject: [PATCH 3/4] fix: respect MSVC operator definitions See https://learn.microsoft.com/en-us/cpp/cpp/keywords-cpp?view=msvc-170 on note (b). --- src/structure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structure.cpp b/src/structure.cpp index da8bf5e6..1e60a9b1 100644 --- a/src/structure.cpp +++ b/src/structure.cpp @@ -102,7 +102,7 @@ void Structure::buildUI() { /* Set all structures to ignore this plane, except for this one in particular! */ for (auto const& supermap: state::structures) { for (auto const& map: supermap.second) { - map.second->setIgnoreSlicePlane(plane->name, supermap.first != this->typeName() or map.first != this->name); + map.second->setIgnoreSlicePlane(plane->name, (supermap.first != this->typeName() || map.first != this->name)); } } } From 8b9d05394e84eed38734ceaeed05fc603e6860f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20de=20Vill=C3=A8le?= <25150288+Thibaulltt@users.noreply.github.com> Date: Thu, 26 Mar 2026 11:05:43 +0100 Subject: [PATCH 4/4] feat: keep structure slice plane menu open --- src/structure.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/structure.cpp b/src/structure.cpp index 1e60a9b1..55f9b6a5 100644 --- a/src/structure.cpp +++ b/src/structure.cpp @@ -92,6 +92,8 @@ void Structure::buildUI() { // Toggle whether slice planes apply if (ImGui::BeginMenu("Slice planes")) { + /* We want to keep the menu open, as we might toggle on/off many slice planes at once. */ + ImGui::PushItemFlag(ImGuiItemFlags_AutoClosePopups, false); if (ImGui::Button("Add slice plane")) { openSlicePlaneMenu = true; addSlicePlane(); @@ -125,6 +127,7 @@ void Structure::buildUI() { ImGui::TextUnformatted("Note: Manage slice planes in"); ImGui::TextUnformatted(" View --> Slice Planes."); + ImGui::PopItemFlag(); ImGui::EndMenu(); }