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.7 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
void setHome(SessionState& session, ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
auto camera = vp.cameraState();
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");
}
void goHome(SessionState& session, ViewportWindow& vp) {
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();
vp.setCamera(
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");
}
void viewSelected(ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.focusOnSelectedObject();
}
void fly(SessionState& session, ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.requestActivate();
vp.enterFpsMode();
session.setStatusMessage("Mode", "Fly mode active");
}
void toggleSection(SessionState& session, ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.toggleSectionTool();
session.setStatusMessage("Section",
vp.sectionToolActive() ? "Section tool active" : "Section tool off");
}
void clearSection(SessionState& session, ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.clearSectionPlanes();
session.setStatusMessage("Section", "Section planes cleared");
}
void toggleDistance(ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.toggleLengthTool();
}
void toggleArea(ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.toggleAreaTool();
}
void toggleVolume(ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.toggleVolumeTool();
}
void hideSelected(ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.hideSelectedElements();
}
void isolateSelected(ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.isolateSelectedElements();
}
void showAll(ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.showAllElements();
}
void invertVisibility(ViewportWindow& vp) {
2026-05-15 17:08:08 +10:00
vp.invertElementVisibility();
}
2026-05-20 09:38:10 +10:00
} // namespace bonsaiviewer::modules::viewport::commands