diff --git a/src/app.cpp b/src/app.cpp index 073303a..a7de154 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -5648,7 +5648,7 @@ private: } // Reference pictures: flat, see-through, a little behind the plane through the middle. for (const Reference& ref : scene_.references) { - if (!ref.visible) continue; + if (!ref.visible || (ref.ownViewOnly && !lookingAt(ref.axis))) continue; const Picture& pic = picture(ref); if (!pic.ok) continue; const auto c = referenceCorners(ref, pic.aspect); @@ -7310,6 +7310,8 @@ private: undoable([&] { return ImGui::DragFloat("Width (m)", &ref->width, 0.005f, -100.0f, 100.0f, "%.3f"); }); ImGui::TextDisabled("A minus width flips it."); undoable([&] { return ImGui::SliderFloat("See-through", &ref->opacity, 0.05f, 1.0f); }); + if (ImGui::Checkbox("Only in its own view", &ref->ownViewOnly)) dirty_ = true; + if (ImGui::IsItemHovered()) ImGui::SetTooltip("Shown only looking straight at it (front, side or top): out of the way in the 3D view and the others"); if (ImGui::Button("Remove picture", ImVec2(w, 0))) deleteSelected(); ImGui::End(); return; @@ -8250,6 +8252,14 @@ private: } } + // Looking straight at a reference picture's plane (the front picture from the front or the back...). + bool lookingAt(Axis a) const { + switch (a) { + case Axis::Front: return view_ == View::Front || view_ == View::Back; + case Axis::Top: return view_ == View::Top || view_ == View::Bottom; + default: return view_ == View::Left || view_ == View::Right; + } + } std::string workspaceDir() const { return keel::prefPath() + "workspaces/"; } void resetLayout() { layoutAgain_ = true, layoutDone_ = false; diff --git a/src/scene.cpp b/src/scene.cpp index 4ee3294..770c84f 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -224,7 +224,7 @@ std::string sceneText(const Scene& scene) { for (const SceneScript& s : scene.scripts) out << "script " << quoted(s.name) << " " << s.code.size() << "\n" << s.code << "\n"; for (const Reference& r : scene.references) out << "reference " << quoted(r.path) << " " << axisName(r.axis) << " " << r.offset.x << " " << r.offset.y << " " << r.width << " " << r.opacity - << " " << r.visible << "\n"; + << " " << r.visible << " " << r.ownViewOnly << "\n"; // Folders by their place in the file (1 up; 0 the top), as ids change on loading. std::map folderAt; for (size_t i = 0; i < scene.folders.size(); ++i) folderAt[scene.folders[i].id] = i + 1; @@ -339,6 +339,7 @@ std::optional parseScene(std::istream& in, const std::string& path, std:: r.path = readQuoted(l); std::string axis; l >> axis >> r.offset.x >> r.offset.y >> r.width >> r.opacity >> r.visible; + if (!(l >> r.ownViewOnly)) r.ownViewOnly = false; // (not in files from before 0.8) r.axis = axis == "front" ? Axis::Front : axis == "top" ? Axis::Top : Axis::Side; s.references.push_back(r); } else if (word == "look") { diff --git a/src/scene.h b/src/scene.h index 7638b02..cbd2583 100644 --- a/src/scene.h +++ b/src/scene.h @@ -112,6 +112,7 @@ struct Reference { float width = 1.0f; // metres across float opacity = 0.6f; bool visible = true; + bool ownViewOnly = false; // (shown only looking straight at it: a front drawing not in the way from the side) }; // The Render tab's light and look.