Files
IfcOpenShell/src/interface/MainWindow.cpp
T

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

463 lines
21 KiB
C++
Raw Normal View History

2026-05-05 07:29:32 +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/>. *
* *
********************************************************************************/
2026-05-05 18:02:02 +10:00
#include "MainWindow.h"
2026-05-05 07:29:32 +10:00
2026-05-05 18:02:02 +10:00
#include "../ifcviewer/AppSettings.h"
2026-05-07 12:21:55 +10:00
#include "../ifcviewer/Federation.h"
2026-05-05 18:02:02 +10:00
#include "../ifcviewer/SceneLoader.h"
#include "../ifcviewer/ViewportWindow.h"
2026-05-06 10:47:03 +10:00
#include "ElementRegistry.h"
2026-05-07 17:10:04 +10:00
#include "SessionState.h"
2026-05-07 12:21:55 +10:00
#include "components/Buttons.h"
2026-05-06 10:47:03 +10:00
#include "components/Panel.h"
#include "components/Style.h"
2026-05-07 12:21:55 +10:00
#include "components/Tabs.h"
2026-05-09 19:43:26 +10:00
#include "modules/models/Controller.h"
#include "modules/todo/Panel.h"
#include "modules/models/View.h"
#include "modules/models/Panel.h"
#include "modules/project/Controller.h"
#include "modules/properties/View.h"
#include "modules/properties/Panel.h"
#include "modules/settings/Dialog.h"
#include "modules/spatial_hierarchy/View.h"
#include "modules/spatial_hierarchy/Panel.h"
#include "modules/viewport/Controller.h"
#include "modules/viewport/Panel.h"
2026-05-05 07:29:32 +10:00
#include <QDockWidget>
2026-05-07 12:21:55 +10:00
#include <QFileInfo>
2026-05-05 07:29:32 +10:00
#include <QHBoxLayout>
#include <QIcon>
#include <QLabel>
#include <QMessageBox>
#include <QSignalBlocker>
#include <QStackedWidget>
#include <QStatusBar>
#include <QToolButton>
#include <QVBoxLayout>
2026-05-05 18:02:02 +10:00
namespace ifcinterface::shell {
2026-05-05 07:29:32 +10:00
2026-05-05 18:02:02 +10:00
MainWindow::MainWindow(QWidget* parent)
2026-05-05 07:29:32 +10:00
: QMainWindow(parent)
{
2026-05-07 12:21:55 +10:00
federation_ = new Federation(this);
2026-05-06 10:47:03 +10:00
element_registry_ = new ifcinterface::ElementRegistry(this);
2026-05-07 17:10:04 +10:00
session_state_ = new ifcinterface::SessionState(this);
session_state_->bindFederation(federation_);
session_state_->bindElementRegistry(element_registry_);
2026-05-07 12:21:55 +10:00
connect(federation_, &Federation::dirtyChanged, this, [this](bool dirty) {
setWindowModified(dirty);
updateWindowTitle();
});
2026-05-09 07:11:58 +10:00
connect(session_state_, &ifcinterface::SessionState::modelsChanged,
this, &MainWindow::updateWindowTitle);
connect(session_state_, &ifcinterface::SessionState::projectOpened,
this, [this](const QString&) { updateWindowTitle(); });
connect(session_state_, &ifcinterface::SessionState::projectSaved,
this, [this](const QString&) { updateWindowTitle(); });
connect(session_state_, &ifcinterface::SessionState::projectReset,
this, &MainWindow::updateWindowTitle);
2026-05-05 07:29:32 +10:00
setupChrome();
setupViewport();
2026-05-06 10:47:03 +10:00
setupPanels();
2026-05-05 07:29:32 +10:00
setupStatus();
setupLoader();
setupRibbon();
resize(1720, 980);
}
2026-05-05 18:02:02 +10:00
void MainWindow::setupChrome() {
2026-05-06 13:13:37 +10:00
setObjectName("appWindow");
2026-05-05 07:29:32 +10:00
setDockOptions(QMainWindow::AllowNestedDocks |
QMainWindow::AllowTabbedDocks |
QMainWindow::GroupedDragging);
2026-05-07 12:21:55 +10:00
updateWindowTitle();
2026-05-05 07:29:32 +10:00
}
2026-05-05 18:02:02 +10:00
QToolButton* MainWindow::makePanelToggle(const QString& text, QDockWidget* dock) {
2026-05-09 07:11:58 +10:00
auto* button = components::buttons::makeButton(text, ":/icons/sidebar-expand.svg", this);
2026-05-05 07:29:32 +10:00
button->setCheckable(true);
button->setChecked(dock->isVisible());
connect(button, &QToolButton::toggled, dock, [dock](bool checked) {
dock->setVisible(checked);
if (checked) dock->raise();
});
connect(dock, &QDockWidget::visibilityChanged, button, [button](bool visible) {
const QSignalBlocker blocker(button);
button->setChecked(visible);
});
return button;
}
2026-05-05 18:02:02 +10:00
QWidget* MainWindow::buildHomeRibbonPage() {
2026-05-05 07:29:32 +10:00
auto* page = new QFrame(this);
page->setObjectName("ribbonPage");
auto* row = new QHBoxLayout(page);
row->setContentsMargins(6, 4, 6, 4);
row->setSpacing(0);
2026-05-09 07:11:58 +10:00
auto* new_project = components::buttons::makeButton("New Project", ":/icons/plus-square.svg", this);
connect(new_project, &QToolButton::clicked, this, [this]() {
project_controller_->newProject();
});
auto* open_project = components::buttons::makeButton("Open Project", ":/icons/download-square.svg", this);
connect(open_project, &QToolButton::clicked, this, [this]() {
project_controller_->openProject();
});
auto* open_cloud = components::buttons::makeButton("Open Cloud", ":/icons/cloud-square.svg", this);
2026-05-05 07:29:32 +10:00
connect(open_cloud, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Project", "Open Cloud Project coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* open_recent = components::buttons::makeButton("Open Recent", ":/icons/clock-rotate-right.svg", this);
2026-05-05 07:29:32 +10:00
connect(open_recent, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Project", "Open Recent coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* save_project = components::buttons::makeButton("Save Project", ":/icons/floppy-disk.svg", this);
connect(save_project, &QToolButton::clicked, this, [this]() {
project_controller_->saveProject();
});
auto* save_project_as = components::buttons::makeButton("Save As", ":/icons/floppy-disk-arrow-in.svg", this);
connect(save_project_as, &QToolButton::clicked, this, [this]() {
project_controller_->saveProjectAs();
});
2026-05-05 07:29:32 +10:00
2026-05-09 07:11:58 +10:00
auto* add_model = components::buttons::makeButton("Add Model", ":/icons/cube.svg", this);
connect(add_model, &QToolButton::clicked, this, [this]() {
models_controller_->addFiles();
});
auto* sync_models = components::buttons::makeButton("Sync Models", ":/icons/refresh-double.svg", this);
2026-05-05 07:29:32 +10:00
connect(sync_models, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Models", "Sync models coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* settings_button = components::buttons::makeButton("Settings", ":/icons/settings.svg", this);
2026-05-05 07:29:32 +10:00
connect(settings_button, &QToolButton::clicked, this, [this]() {
2026-05-09 19:43:26 +10:00
modules::settings::SettingsDialog dialog(this);
2026-05-06 21:35:12 +10:00
dialog.exec();
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
row->addWidget(components::buttons::makeButtonGroup("PROJECT", {new_project, open_project, open_cloud, open_recent, save_project, save_project_as}, this));
row->addWidget(components::buttons::makeButtonGroup("MODELS", {add_model, sync_models}, this));
row->addWidget(components::buttons::makeButtonGroup("SETTINGS", {settings_button}, this));
2026-05-05 07:29:32 +10:00
row->addStretch(1);
return page;
}
2026-05-05 18:02:02 +10:00
QWidget* MainWindow::buildNavigateRibbonPage() {
2026-05-05 07:29:32 +10:00
auto* page = new QFrame(this);
page->setObjectName("ribbonPage");
auto* row = new QHBoxLayout(page);
row->setContentsMargins(2, 4, 2, 4);
row->setSpacing(0);
2026-05-09 07:11:58 +10:00
auto* set_home = components::buttons::makeButton("Set Home", ":/icons/home.svg", this);
connect(set_home, &QToolButton::clicked, this, [this]() {
viewport_controller_->setHomeView();
});
auto* go_home = components::buttons::makeButton("Go Home", ":/icons/home-alt.svg", this);
connect(go_home, &QToolButton::clicked, this, [this]() {
viewport_controller_->goHomeView();
});
auto* view_all = components::buttons::makeButton("View All", ":/icons/cube-scan.svg", this);
2026-05-05 07:29:32 +10:00
connect(view_all, &QToolButton::clicked, this, [this]() {
2026-05-07 14:45:23 +10:00
if (viewport_widget_) viewport_widget_->viewport()->viewAll();
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* view_selected = components::buttons::makeButton("View Selected", ":/icons/cube-scan-solid.svg", this);
2026-05-05 07:29:32 +10:00
connect(view_selected, &QToolButton::clicked, this, [this]() {
2026-05-07 14:45:23 +10:00
if (viewport_widget_) viewport_widget_->viewport()->focusOnSelectedObject();
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* plan_view = components::buttons::makeButton("Plan", ":/icons/planimetry.svg", this);
2026-05-05 07:29:32 +10:00
connect(plan_view, &QToolButton::clicked, this, [this]() {
2026-05-07 14:45:23 +10:00
if (viewport_widget_) viewport_widget_->viewport()->setStandardView(90.0f, 90.0f);
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* front_view = components::buttons::makeButton("Front", ":/icons/city.svg", this);
2026-05-05 07:29:32 +10:00
connect(front_view, &QToolButton::clicked, this, [this]() {
2026-05-07 14:45:23 +10:00
if (viewport_widget_) viewport_widget_->viewport()->setStandardView(0.0f, 0.0f);
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* side_view = components::buttons::makeButton("Side", ":/icons/building.svg", this);
2026-05-05 07:29:32 +10:00
connect(side_view, &QToolButton::clicked, this, [this]() {
2026-05-07 14:45:23 +10:00
if (viewport_widget_) viewport_widget_->viewport()->setStandardView(90.0f, 0.0f);
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* align_object = components::buttons::makeButton("Align Object", ":/icons/cellar.svg", this);
2026-05-05 07:29:32 +10:00
connect(align_object, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Orientation", "Align to object coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* projection_button = components::buttons::makeButton("Perspective", ":/icons/perspective-view.svg", this);
2026-05-05 07:29:32 +10:00
connect(projection_button, &QToolButton::clicked, this, [this, projection_button]() {
2026-05-07 14:45:23 +10:00
if (!viewport_widget_) return;
viewport_widget_->viewport()->toggleProjection();
projection_button->setText(
viewport_widget_->viewport()->projectionOrtho() ? "Ortho" : "Perspective");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* orbit_mode = components::buttons::makeButton("Orbit", ":/icons/rotate-camera-right.svg", this);
2026-05-05 07:29:32 +10:00
connect(orbit_mode, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Mode", "Orbit mode active");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* fly_mode = components::buttons::makeButton("Fly", ":/icons/drone.svg", this);
2026-05-05 07:29:32 +10:00
connect(fly_mode, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Mode", "Fly mode coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
row->addWidget(components::buttons::makeButtonGroup("CAMERA", {set_home, go_home, view_all, view_selected}, this));
row->addWidget(components::buttons::makeButtonGroup("ORIENTATION", {plan_view, front_view, side_view, align_object, projection_button}, this));
row->addWidget(components::buttons::makeButtonGroup("MODE", {orbit_mode, fly_mode}, this));
2026-05-05 07:29:32 +10:00
row->addStretch(1);
return page;
}
2026-05-05 18:02:02 +10:00
QWidget* MainWindow::buildInspectRibbonPage() {
2026-05-05 07:29:32 +10:00
auto* page = new QFrame(this);
page->setObjectName("ribbonPage");
auto* row = new QHBoxLayout(page);
row->setContentsMargins(2, 4, 2, 4);
row->setSpacing(0);
2026-05-09 07:11:58 +10:00
auto* hide_selected = components::buttons::makeButton("Hide", ":/icons/eye-closed.svg", this);
2026-05-05 07:29:32 +10:00
connect(hide_selected, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Selection", "Hide selected coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* isolate_selected = components::buttons::makeButton("Isolate", ":/icons/eye-solid.svg", this);
2026-05-05 07:29:32 +10:00
connect(isolate_selected, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Selection", "Isolate selected coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* show_all = components::buttons::makeButton("Show All", ":/icons/eye.svg", this);
2026-05-05 07:29:32 +10:00
connect(show_all, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Selection", "Show all coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* invert_selection = components::buttons::makeButton("Invert", ":/icons/intersect.svg", this);
2026-05-05 07:29:32 +10:00
connect(invert_selection, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Selection", "Invert selection coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* distance = components::buttons::makeButton("Distance", ":/icons/select-edge3d.svg", this);
2026-05-05 07:29:32 +10:00
connect(distance, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Measure", "Distance coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* area = components::buttons::makeButton("Area", ":/icons/select-face3d.svg", this);
2026-05-05 07:29:32 +10:00
connect(area, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Measure", "Area coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
auto* volume = components::buttons::makeButton("Volume", ":/icons/select-point3d.svg", this);
2026-05-05 07:29:32 +10:00
connect(volume, &QToolButton::clicked, this, [this]() {
2026-05-07 17:10:04 +10:00
session_state_->setStatusMessage("Measure", "Volume coming soon");
2026-05-05 07:29:32 +10:00
});
2026-05-09 07:11:58 +10:00
row->addWidget(components::buttons::makeButtonGroup("SELECTION", {hide_selected, isolate_selected, show_all, invert_selection}, this));
row->addWidget(components::buttons::makeButtonGroup("MEASURE", {distance, area, volume}, this));
2026-05-05 07:29:32 +10:00
row->addStretch(1);
return page;
}
2026-05-05 18:02:02 +10:00
QWidget* MainWindow::buildPanelsRibbonPage() {
2026-05-05 07:29:32 +10:00
auto* page = new QFrame(this);
page->setObjectName("ribbonPage");
auto* row = new QHBoxLayout(page);
row->setContentsMargins(2, 4, 2, 4);
row->setSpacing(0);
2026-05-09 07:11:58 +10:00
row->addWidget(components::buttons::makeButtonGroup("DATA", {
2026-05-06 10:47:03 +10:00
makePanelToggle("Models", models_panel_),
makePanelToggle("Spatial", spatial_panel_),
makePanelToggle("Layers", layers_panel_),
makePanelToggle("Properties", properties_panel_)
2026-05-09 07:11:58 +10:00
}, this));
row->addWidget(components::buttons::makeButtonGroup("QUERY", {
2026-05-06 10:47:03 +10:00
makePanelToggle("Views", stored_views_panel_),
makePanelToggle("Search", search_panel_),
makePanelToggle("Sheets", spreadsheet_panel_),
makePanelToggle("Audit", audit_panel_)
2026-05-09 07:11:58 +10:00
}, this));
row->addWidget(components::buttons::makeButtonGroup("COLLABORATE", {
2026-05-06 10:47:03 +10:00
makePanelToggle("Clash", clash_panel_),
makePanelToggle("Issues", issues_panel_)
2026-05-09 07:11:58 +10:00
}, this));
2026-05-05 07:29:32 +10:00
row->addStretch(1);
return page;
}
2026-05-05 18:02:02 +10:00
void MainWindow::setupRibbon() {
2026-05-05 07:29:32 +10:00
auto* shell = new QFrame(this);
auto* shell_layout = new QVBoxLayout(shell);
shell_layout->setContentsMargins(0, 0, 0, 0);
shell_layout->setSpacing(0);
2026-05-07 12:21:55 +10:00
ribbon_tabs_ = new components::TabBar(shell);
2026-05-05 07:29:32 +10:00
ribbon_tabs_->addTab("Home");
ribbon_tabs_->addTab("Navigate");
ribbon_tabs_->addTab("Inspect");
ribbon_tabs_->addTab("Panels");
ribbon_tabs_->setCurrentIndex(0);
auto* ribbon_band = new QFrame(shell);
ribbon_band->setObjectName("ribbonBand");
auto* band_layout = new QVBoxLayout(ribbon_band);
band_layout->setContentsMargins(0, 0, 0, 0);
band_layout->setSpacing(0);
ribbon_pages_ = new QStackedWidget(ribbon_band);
ribbon_pages_->addWidget(buildHomeRibbonPage());
ribbon_pages_->addWidget(buildNavigateRibbonPage());
ribbon_pages_->addWidget(buildInspectRibbonPage());
ribbon_pages_->addWidget(buildPanelsRibbonPage());
band_layout->addWidget(ribbon_pages_);
shell_layout->addWidget(ribbon_tabs_);
shell_layout->addWidget(ribbon_band);
2026-05-07 12:21:55 +10:00
connect(ribbon_tabs_, &components::TabBar::currentChanged,
2026-05-05 07:29:32 +10:00
ribbon_pages_, &QStackedWidget::setCurrentIndex);
setMenuWidget(shell);
}
2026-05-05 18:02:02 +10:00
void MainWindow::setupViewport() {
2026-05-09 19:43:26 +10:00
viewport_widget_ = new modules::viewport::ViewportPanel(this);
2026-05-07 14:45:23 +10:00
setCentralWidget(viewport_widget_);
2026-05-05 07:29:32 +10:00
}
2026-05-06 10:47:03 +10:00
void MainWindow::setupPanels() {
2026-05-09 19:43:26 +10:00
models_panel_ = new modules::models::ModelsPanel(this);
spatial_panel_ = new modules::spatial_hierarchy::SpatialHierarchyPanel(this);
properties_panel_ = new modules::properties::PropertiesPanel(this);
2026-05-05 18:02:02 +10:00
2026-05-09 19:43:26 +10:00
models_controller_ = new modules::models::ModelsPanelController(
this, models_panel_, session_state_, viewport_widget_->viewport(), this);
models_view_ = new modules::models::ModelsPanelView(models_panel_, session_state_, this);
spatial_view_ = new modules::spatial_hierarchy::SpatialHierarchyPanelView(spatial_panel_, session_state_, this);
properties_view_ = new modules::properties::PropertiesPanelView(properties_panel_, session_state_, this);
2026-05-05 18:02:02 +10:00
2026-05-09 19:43:26 +10:00
layers_panel_ = new components::Panel("Layers", new modules::todo::TodoPanel("Layers", this), this);
2026-05-06 10:47:03 +10:00
stored_views_panel_ = new components::Panel(
2026-05-09 19:43:26 +10:00
"Stored Views", new modules::todo::TodoPanel("Stored Views", this), this);
2026-05-06 10:47:03 +10:00
search_panel_ = new components::Panel(
2026-05-09 19:43:26 +10:00
"Search and Query", new modules::todo::TodoPanel("Search and Query", this), this);
2026-05-06 10:47:03 +10:00
spreadsheet_panel_ = new components::Panel(
2026-05-09 19:43:26 +10:00
"Spreadsheet", new modules::todo::TodoPanel("Spreadsheet", this), this);
audit_panel_ = new components::Panel("Audit", new modules::todo::TodoPanel("Audit", this), this);
clash_panel_ = new components::Panel("Clash", new modules::todo::TodoPanel("Clash", this), this);
issues_panel_ = new components::Panel("Issues", new modules::todo::TodoPanel("Issues", this), this);
2026-05-06 10:47:03 +10:00
addDockWidget(Qt::LeftDockWidgetArea, models_panel_);
addDockWidget(Qt::LeftDockWidgetArea, spatial_panel_);
splitDockWidget(models_panel_, spatial_panel_, Qt::Vertical);
addDockWidget(Qt::RightDockWidgetArea, properties_panel_);
addDockWidget(Qt::RightDockWidgetArea, layers_panel_);
addDockWidget(Qt::RightDockWidgetArea, stored_views_panel_);
addDockWidget(Qt::RightDockWidgetArea, search_panel_);
addDockWidget(Qt::RightDockWidgetArea, spreadsheet_panel_);
addDockWidget(Qt::RightDockWidgetArea, audit_panel_);
addDockWidget(Qt::RightDockWidgetArea, clash_panel_);
addDockWidget(Qt::RightDockWidgetArea, issues_panel_);
tabifyDockWidget(properties_panel_, layers_panel_);
tabifyDockWidget(layers_panel_, stored_views_panel_);
tabifyDockWidget(stored_views_panel_, search_panel_);
tabifyDockWidget(search_panel_, spreadsheet_panel_);
tabifyDockWidget(spreadsheet_panel_, audit_panel_);
tabifyDockWidget(audit_panel_, clash_panel_);
tabifyDockWidget(clash_panel_, issues_panel_);
properties_panel_->raise();
layers_panel_->hide();
stored_views_panel_->hide();
search_panel_->hide();
spreadsheet_panel_->hide();
audit_panel_->hide();
clash_panel_->hide();
issues_panel_->hide();
resizeDocks({models_panel_, properties_panel_}, {290, 330}, Qt::Horizontal);
resizeDocks({models_panel_, spatial_panel_}, {280, 240}, Qt::Vertical);
2026-05-05 07:29:32 +10:00
}
2026-05-05 18:02:02 +10:00
void MainWindow::setupStatus() {
2026-05-05 07:29:32 +10:00
status_mode_label_ = new QLabel("Ready", this);
status_selection_label_ = new QLabel("No selection", this);
status_perf_label_ = new QLabel(this);
status_perf_label_->setVisible(AppSettings::instance().showStats());
statusBar()->setSizeGripEnabled(false);
statusBar()->addWidget(status_mode_label_);
statusBar()->addWidget(status_selection_label_, 1);
statusBar()->addPermanentWidget(status_perf_label_);
connect(&AppSettings::instance(), &AppSettings::showStatsChanged, this, [this](bool show) {
status_perf_label_->setVisible(show);
if (!show) status_perf_label_->clear();
});
2026-05-07 17:10:04 +10:00
connect(session_state_, &ifcinterface::SessionState::statusMessageChanged,
this, [this](const QString& mode, const QString& detail) {
status_mode_label_->setText(mode);
status_selection_label_->setText(detail);
});
session_state_->setStatusMessage("Ready", "No selection");
2026-05-05 07:29:32 +10:00
}
2026-05-05 18:02:02 +10:00
void MainWindow::setupLoader() {
2026-05-07 14:45:23 +10:00
loader_ = new SceneLoader(viewport_widget_->viewport(), this);
2026-05-06 10:47:03 +10:00
element_registry_->bindLoader(loader_);
2026-05-07 17:10:04 +10:00
session_state_->bindLoader(loader_);
2026-05-09 07:11:58 +10:00
models_controller_->bindLoader(loader_);
2026-05-09 19:43:26 +10:00
viewport_controller_ = new modules::viewport::ViewportController(
2026-05-07 17:10:04 +10:00
session_state_, viewport_widget_->viewport(), this);
2026-05-09 19:43:26 +10:00
project_controller_ = new modules::project::ProjectController(
2026-05-09 07:11:58 +10:00
this, federation_, session_state_, element_registry_,
viewport_widget_->viewport(), models_controller_, viewport_controller_, this);
2026-05-05 07:29:32 +10:00
2026-05-07 14:45:23 +10:00
connect(viewport_widget_->viewport(), &ViewportWindow::frameStatsUpdated, this,
2026-05-05 07:29:32 +10:00
[this](const ViewportWindow::FrameStats& s) {
if (!status_perf_label_->isVisible()) return;
status_perf_label_->setText(
QString("%1 fps | %2 ms | %3/%4 obj | %5/%6 tri | %7 draws")
.arg(s.fps, 0, 'f', 1)
.arg(s.frame_time_ms, 0, 'f', 1)
.arg(s.visible_objects)
.arg(s.total_objects)
.arg(s.visible_triangles)
.arg(s.total_triangles)
.arg(s.gl_draw_calls));
});
2026-05-07 17:10:04 +10:00
connect(viewport_widget_->viewport(), &ViewportWindow::objectPicked,
this, [this](uint32_t object_id) {
session_state_->setSelectedObjectId(object_id);
session_state_->notifySelectionChanged();
});
2026-05-05 07:29:32 +10:00
}
2026-05-07 12:21:55 +10:00
void MainWindow::updateWindowTitle() {
const QString project_path = federation_ ? federation_->filePath() : QString();
if (project_path.isEmpty() && (!federation_ || federation_->models().empty())) {
setWindowTitle("IfcOpenShell Interface");
} else if (project_path.isEmpty()) {
setWindowTitle("untitled[*] - IfcOpenShell Interface");
} else {
setWindowTitle(QFileInfo(project_path).fileName() + "[*] - IfcOpenShell Interface");
}
}
2026-05-05 18:02:02 +10:00
} // namespace ifcinterface::shell