Reference pictures: 'only in its own view' (out of the way in 3D and the other views); saved

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-21 08:02:12 +02:00
commit 2f68430354
3 changed files with 14 additions and 2 deletions

View file

@ -5648,7 +5648,7 @@ private:
} }
// Reference pictures: flat, see-through, a little behind the plane through the middle. // Reference pictures: flat, see-through, a little behind the plane through the middle.
for (const Reference& ref : scene_.references) { for (const Reference& ref : scene_.references) {
if (!ref.visible) continue; if (!ref.visible || (ref.ownViewOnly && !lookingAt(ref.axis))) continue;
const Picture& pic = picture(ref); const Picture& pic = picture(ref);
if (!pic.ok) continue; if (!pic.ok) continue;
const auto c = referenceCorners(ref, pic.aspect); 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"); }); undoable([&] { return ImGui::DragFloat("Width (m)", &ref->width, 0.005f, -100.0f, 100.0f, "%.3f"); });
ImGui::TextDisabled("A minus width flips it."); ImGui::TextDisabled("A minus width flips it.");
undoable([&] { return ImGui::SliderFloat("See-through", &ref->opacity, 0.05f, 1.0f); }); 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(); if (ImGui::Button("Remove picture", ImVec2(w, 0))) deleteSelected();
ImGui::End(); ImGui::End();
return; 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/"; } std::string workspaceDir() const { return keel::prefPath() + "workspaces/"; }
void resetLayout() { void resetLayout() {
layoutAgain_ = true, layoutDone_ = false; layoutAgain_ = true, layoutDone_ = false;

View file

@ -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 SceneScript& s : scene.scripts) out << "script " << quoted(s.name) << " " << s.code.size() << "\n" << s.code << "\n";
for (const Reference& r : scene.references) for (const Reference& r : scene.references)
out << "reference " << quoted(r.path) << " " << axisName(r.axis) << " " << r.offset.x << " " << r.offset.y << " " << r.width << " " << r.opacity 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. // Folders by their place in the file (1 up; 0 the top), as ids change on loading.
std::map<uint32_t, size_t> folderAt; std::map<uint32_t, size_t> folderAt;
for (size_t i = 0; i < scene.folders.size(); ++i) folderAt[scene.folders[i].id] = i + 1; for (size_t i = 0; i < scene.folders.size(); ++i) folderAt[scene.folders[i].id] = i + 1;
@ -339,6 +339,7 @@ std::optional<Scene> parseScene(std::istream& in, const std::string& path, std::
r.path = readQuoted(l); r.path = readQuoted(l);
std::string axis; std::string axis;
l >> axis >> r.offset.x >> r.offset.y >> r.width >> r.opacity >> r.visible; 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; r.axis = axis == "front" ? Axis::Front : axis == "top" ? Axis::Top : Axis::Side;
s.references.push_back(r); s.references.push_back(r);
} else if (word == "look") { } else if (word == "look") {

View file

@ -112,6 +112,7 @@ struct Reference {
float width = 1.0f; // metres across float width = 1.0f; // metres across
float opacity = 0.6f; float opacity = 0.6f;
bool visible = true; 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. // The Render tab's light and look.