Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions src/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,42 @@ 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();
}
if (ImGui::Button("...for this structure only")) {
openSlicePlaneMenu = true;
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) {
map.second->setIgnoreSlicePlane(plane->name, (supermap.first != this->typeName() || 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<SlicePlane>& 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");
ImGui::TextUnformatted(" View --> Slice Planes.");

ImGui::PopItemFlag();
ImGui::EndMenu();
}

Expand Down