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"
|
2026-06-04 11:11:14 +10:00
|
|
|
#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-06-04 11:11:14 +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");
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void viewSelected(ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.focusOnSelectedObject();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void fly(SessionState& session, ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.requestActivate();
|
|
|
|
|
vp.enterFpsMode();
|
|
|
|
|
session.setStatusMessage("Mode", "Fly mode active");
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void clearSection(SessionState& session, ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.clearSectionPlanes();
|
|
|
|
|
session.setStatusMessage("Section", "Section planes cleared");
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void toggleDistance(ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.toggleLengthTool();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void toggleArea(ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.toggleAreaTool();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void toggleVolume(ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.toggleVolumeTool();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void hideSelected(ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.hideSelectedElements();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void isolateSelected(ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.isolateSelectedElements();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
void showAll(ViewportWindow& vp) {
|
2026-05-15 17:08:08 +10:00
|
|
|
vp.showAllElements();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
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
|