Files
IfcOpenShell/src/bonsaiviewer/modules/viewport/Commands.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

103 lines
3.9 KiB
C++
Raw Normal View History

2026-05-15 17:08:08 +10:00
// This file was generated with the assistance of an AI coding tool.
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#include "Commands.h"
#include "../../SessionState.h"
#include "../../../ifcviewer/Federation.h"
#include "../../../ifcviewer/ViewportWindow.h"
2026-05-15 17:08:08 +10:00
2026-05-20 09:38:10 +10:00
namespace bonsaiviewer::modules::viewport::commands {
2026-05-15 17:08:08 +10:00
2026-07-03 08:38:57 +10:00
void setHome(SessionState& session, ViewportWindow& viewport) {
auto camera = viewport.cameraState();
2026-05-15 17:08:08 +10:00
Federation::HomeView home_view;
home_view.target = camera.target;
home_view.distance = camera.distance;
home_view.yaw = camera.yaw;
home_view.pitch = camera.pitch;
session.federation()->setHomeView(home_view);
session.setStatusMessage("Camera", "Home view updated");
}
2026-07-03 08:38:57 +10:00
void goHome(SessionState& session, ViewportWindow& viewport) {
2026-05-15 17:08:08 +10:00
Federation* federation = session.federation();
if (!federation->hasHomeView()) {
session.setStatusMessage("Camera", "No home view set for this project");
return;
}
const auto& home_view = federation->homeView();
2026-07-03 08:38:57 +10:00
viewport.setCamera(
2026-05-15 17:08:08 +10:00
home_view.target.x(), home_view.target.y(), home_view.target.z(),
home_view.distance, home_view.yaw, home_view.pitch);
session.setStatusMessage("Camera", "Home view restored");
}
2026-07-03 08:38:57 +10:00
void viewSelected(ViewportWindow& viewport) {
viewport.focusOnSelectedObject();
2026-05-15 17:08:08 +10:00
}
2026-07-03 08:38:57 +10:00
void fly(SessionState& session, ViewportWindow& viewport) {
viewport.requestActivate();
viewport.enterFpsMode();
2026-05-15 17:08:08 +10:00
session.setStatusMessage("Mode", "Fly mode active");
}
2026-07-03 08:38:57 +10:00
void toggleSection(SessionState& session, ViewportWindow& viewport) {
viewport.toggleSectionTool();
2026-05-15 17:08:08 +10:00
session.setStatusMessage("Section",
2026-07-03 08:38:57 +10:00
viewport.sectionToolActive() ? "Section tool active" : "Section tool off");
2026-05-15 17:08:08 +10:00
}
2026-07-03 08:38:57 +10:00
void clearSection(SessionState& session, ViewportWindow& viewport) {
viewport.clearSectionPlanes();
2026-05-15 17:08:08 +10:00
session.setStatusMessage("Section", "Section planes cleared");
}
2026-07-03 08:38:57 +10:00
void toggleDistance(ViewportWindow& viewport) {
viewport.toggleLengthTool();
2026-05-15 17:08:08 +10:00
}
2026-07-03 08:38:57 +10:00
void toggleArea(ViewportWindow& viewport) {
viewport.toggleAreaTool();
2026-05-15 17:08:08 +10:00
}
2026-07-03 08:38:57 +10:00
void toggleVolume(ViewportWindow& viewport) {
viewport.toggleVolumeTool();
2026-05-15 17:08:08 +10:00
}
2026-07-03 08:38:57 +10:00
void hideSelected(ViewportWindow& viewport) {
viewport.hideSelectedElements();
2026-05-15 17:08:08 +10:00
}
2026-07-03 08:38:57 +10:00
void isolateSelected(ViewportWindow& viewport) {
viewport.isolateSelectedElements();
2026-05-15 17:08:08 +10:00
}
2026-07-03 08:38:57 +10:00
void showAll(ViewportWindow& viewport) {
viewport.showAllElements();
2026-05-15 17:08:08 +10:00
}
2026-07-03 08:38:57 +10:00
void invertVisibility(ViewportWindow& viewport) {
viewport.invertElementVisibility();
2026-05-15 17:08:08 +10:00
}
2026-05-20 09:38:10 +10:00
} // namespace bonsaiviewer::modules::viewport::commands