mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Route bonsai through wgpu; delete the GL backend
Bonsai now drives the wgpu viewport for both sidecar and direct-IFC
loads. The GL viewer and its supporting state classes are gone.
SceneLoader rewire:
- Takes WgpuViewportWindow* instead of ViewportWindow*.
- Sidecar path reads metadata only (readSidecarMetadataOnly) and hands
the StreamingSidecar off to the new applyCachedModel. Field accesses
inside applySidecarData go through .meta.
- Direct-IFC path uses the wgpu A-path (upload{Mesh,Instance}Chunk +
finalizeModel). The applyLodExtension call is dropped — wgpu has no
live LOD1 splice; LOD1 still lands in the on-disk sidecar for the
next open.
Bonsai migration:
- ViewportWindow → WgpuViewportWindow across MainWindow, Measurement,
SessionState, and every modules/*/{Commands,Panel,View}.{h,cpp} —
116 sites total. Same s/OverlayRenderer::/WgpuOverlayRenderer::/
rename, 12 sites.
- Includes flipped from ../ifcviewer/ViewportWindow.h to
../ifcviewer-wgpu/WgpuViewportWindow.h. OverlayRenderer.h include
dropped (transitively reached via the viewport header).
- BonsaiViewer links IfcViewerWgpu in addition to IfcViewer for the
duration of the migration; the GL-side IfcViewer also publicly links
IfcViewerWgpu so SceneLoader can resolve WgpuViewportWindow.
GL backend deletion:
- src/ifcviewer/ViewportWindow.{cpp,h}, BvhAccel.*, OverlayRenderer.*,
Selection.*, Visibility.* all gone.
- src/ifcviewer-minimal/ removed entirely (MinimalWindow drove the GL
viewport).
- src/ifcviewer/tests: test_bvh_accel, test_selection, test_visibility
removed. The first has no replacement (wgpu doesn't use a per-instance
BVH); the latter two are ported separately. test_lod_builder,
test_sidecar_cache, test_instanced_geometry, test_federation remain
(backend-agnostic).
- IfcViewer's CMakeLists drops OpenGL, Qt::OpenGL, Qt::Widgets — none
of the surviving translation units reach for them.
Build flag plumbing:
- BUILD_BONSAIVIEWER now auto-enables BUILD_BONSAIVIEWER_WGPU since
SceneLoader requires the wgpu lib for its WgpuViewportWindow* arg.
- The wgpu subprojects add_subdirectory ahead of the GL one so
IfcViewerWgpu exists when IfcViewer's link evaluates.
- src/ifcviewer-minimal subdir reference removed from cmake/CMakeLists.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
################################################################################
|
||||
# #
|
||||
# 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/>. #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
message("Running CMakeLists.txt in /src/ifcviewer-minimal")
|
||||
|
||||
file(GLOB IFCVIEWER_MINIMAL_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
file(GLOB IFCVIEWER_MINIMAL_H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
||||
set(IFCVIEWER_MINIMAL_FILES ${IFCVIEWER_MINIMAL_CPP_FILES} ${IFCVIEWER_MINIMAL_H_FILES})
|
||||
|
||||
add_executable(IfcViewerMinimal ${IFCVIEWER_MINIMAL_FILES})
|
||||
|
||||
set_target_properties(IfcViewerMinimal PROPERTIES
|
||||
AUTOMOC ON
|
||||
WIN32_EXECUTABLE ON
|
||||
MACOSX_BUNDLE ON
|
||||
)
|
||||
|
||||
target_link_libraries(IfcViewerMinimal PRIVATE IfcViewer)
|
||||
|
||||
install(TARGETS IfcViewerMinimal EXPORT ${IFCOPENSHELL_EXPORT_TARGETS})
|
||||
ifcopenshell_deploy_qt_runtime(IfcViewerMinimal)
|
||||
@@ -1,161 +0,0 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* 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 "MinimalWindow.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
#include <QStatusBar>
|
||||
#include <QDebug>
|
||||
|
||||
MinimalWindow::MinimalWindow(QWidget* parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
viewport_ = new ViewportWindow();
|
||||
viewport_container_ = QWidget::createWindowContainer(viewport_, this);
|
||||
viewport_container_->setMinimumSize(400, 300);
|
||||
viewport_container_->setFocusPolicy(Qt::StrongFocus);
|
||||
setCentralWidget(viewport_container_);
|
||||
|
||||
status_label_ = new QLabel("Ready");
|
||||
stats_label_ = new QLabel();
|
||||
stats_label_->setVisible(AppSettings::instance().showStats());
|
||||
statusBar()->addWidget(status_label_, 1);
|
||||
statusBar()->addPermanentWidget(stats_label_);
|
||||
|
||||
loader_ = new SceneLoader(viewport_, this);
|
||||
loader_->setShouldReadSidecar(true);
|
||||
loader_->setShouldWriteSidecar(true);
|
||||
connect(loader_, &SceneLoader::loadStarted,
|
||||
this, &MinimalWindow::onLoadStarted);
|
||||
connect(loader_, &SceneLoader::loadedFromSidecar,
|
||||
this, &MinimalWindow::onLoadedFromSidecar);
|
||||
connect(loader_, &SceneLoader::loadedFromStream,
|
||||
this, &MinimalWindow::onLoadedFromStream);
|
||||
connect(loader_, &SceneLoader::loadCancelled,
|
||||
this, &MinimalWindow::onLoadCancelled);
|
||||
connect(loader_, &SceneLoader::loadError,
|
||||
this, &MinimalWindow::onLoadError);
|
||||
connect(loader_, &SceneLoader::allLoadsFinished,
|
||||
this, &MinimalWindow::onAllLoadsFinished);
|
||||
|
||||
connect(viewport_, &ViewportWindow::frameStatsUpdated, this,
|
||||
[this](const ViewportWindow::FrameStats& s) {
|
||||
if (!stats_label_->isVisible()) return;
|
||||
stats_label_->setText(
|
||||
QString("%1 fps | %2 ms | %3/%4 obj | %5/%6 tri | %7 gl_draws (%8 sub)")
|
||||
.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)
|
||||
.arg(s.indirect_sub_draws));
|
||||
});
|
||||
|
||||
connect(&AppSettings::instance(), &AppSettings::showStatsChanged, this, [this](bool show) {
|
||||
stats_label_->setVisible(show);
|
||||
if (!show) stats_label_->clear();
|
||||
});
|
||||
|
||||
setWindowTitle("IfcViewerMinimal");
|
||||
resize(1200, 800);
|
||||
}
|
||||
|
||||
void MinimalWindow::addFiles(const QStringList& paths) {
|
||||
loader_->addFiles(paths);
|
||||
}
|
||||
|
||||
static QString formatElapsed(qint64 ms) {
|
||||
return (ms >= 1000)
|
||||
? QString::number(ms / 1000.0, 'f', 2) + " s"
|
||||
: QString::number(ms) + " ms";
|
||||
}
|
||||
|
||||
void MinimalWindow::onLoadStarted(uint32_t /*mid*/, QString display_name) {
|
||||
status_label_->setText("Loading: " + display_name);
|
||||
}
|
||||
|
||||
void MinimalWindow::onLoadedFromSidecar(uint32_t mid, qint64 elapsed_ms) {
|
||||
status_label_->setText(QString("%1 loaded from cache in %2")
|
||||
.arg(loader_->displayName(mid))
|
||||
.arg(formatElapsed(elapsed_ms)));
|
||||
}
|
||||
|
||||
void MinimalWindow::onLoadedFromStream(uint32_t mid, qint64 elapsed_ms) {
|
||||
status_label_->setText(QString("%1 streamed in %2")
|
||||
.arg(loader_->displayName(mid))
|
||||
.arg(formatElapsed(elapsed_ms)));
|
||||
}
|
||||
|
||||
void MinimalWindow::onLoadCancelled(uint32_t mid) {
|
||||
status_label_->setText(QString("%1 load cancelled")
|
||||
.arg(loader_->displayName(mid)));
|
||||
}
|
||||
|
||||
void MinimalWindow::onLoadError(uint32_t /*mid*/, QString message) {
|
||||
qWarning("IfcViewerMinimal error: %s", qPrintable(message));
|
||||
status_label_->setText("Error: " + message);
|
||||
}
|
||||
|
||||
void MinimalWindow::onAllLoadsFinished() {
|
||||
status_label_->setText(QString("Loaded %1 model(s)").arg(loader_->modelCount()));
|
||||
applyPendingBenchmark();
|
||||
}
|
||||
|
||||
void MinimalWindow::setPendingCamera(const QString& params) {
|
||||
pending_camera_ = params;
|
||||
}
|
||||
|
||||
void MinimalWindow::setPendingBenchmark(int frames) {
|
||||
pending_benchmark_ = frames;
|
||||
}
|
||||
|
||||
void MinimalWindow::setPendingScreenshot(const QString& path) {
|
||||
pending_screenshot_ = path;
|
||||
}
|
||||
|
||||
void MinimalWindow::applyPendingBenchmark() {
|
||||
if (pending_camera_.isEmpty() && pending_benchmark_ <= 0
|
||||
&& pending_screenshot_.isEmpty()) return;
|
||||
|
||||
if (!pending_camera_.isEmpty()) {
|
||||
QStringList parts = pending_camera_.split(',');
|
||||
if (parts.size() == 6) {
|
||||
viewport_->setCamera(
|
||||
parts[0].toFloat(), parts[1].toFloat(), parts[2].toFloat(),
|
||||
parts[3].toFloat(), parts[4].toFloat(), parts[5].toFloat());
|
||||
qDebug("Camera set: %s", qPrintable(pending_camera_));
|
||||
} else {
|
||||
qWarning("--camera expects 6 comma-separated values: tx,ty,tz,dist,yaw,pitch");
|
||||
}
|
||||
pending_camera_.clear();
|
||||
}
|
||||
|
||||
if (pending_benchmark_ > 0) {
|
||||
qDebug("Starting benchmark: %d frames", pending_benchmark_);
|
||||
viewport_->setBenchmarkFrames(pending_benchmark_);
|
||||
pending_benchmark_ = 0;
|
||||
}
|
||||
|
||||
if (!pending_screenshot_.isEmpty()) {
|
||||
viewport_->captureNextFrameToPng(pending_screenshot_, /*quit_after=*/true);
|
||||
pending_screenshot_.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* 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/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef MINIMALWINDOW_H
|
||||
#define MINIMALWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QLabel>
|
||||
|
||||
#include "ViewportWindow.h"
|
||||
#include "SceneLoader.h"
|
||||
|
||||
class MinimalWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MinimalWindow(QWidget* parent = nullptr);
|
||||
~MinimalWindow() = default;
|
||||
|
||||
void addFiles(const QStringList& paths);
|
||||
void setPendingCamera(const QString& params);
|
||||
void setPendingBenchmark(int frames);
|
||||
// One-shot framebuffer capture queued for the next render. Forwarded
|
||||
// to ViewportWindow::captureNextFrameToPng; the viewport handles the
|
||||
// glReadPixels + PNG save + optional QCoreApplication::quit.
|
||||
void setPendingScreenshot(const QString& path);
|
||||
|
||||
private slots:
|
||||
void onLoadStarted(uint32_t mid, QString display_name);
|
||||
void onLoadedFromSidecar(uint32_t mid, qint64 elapsed_ms);
|
||||
void onLoadedFromStream(uint32_t mid, qint64 elapsed_ms);
|
||||
void onLoadCancelled(uint32_t mid);
|
||||
void onLoadError(uint32_t mid, QString message);
|
||||
void onAllLoadsFinished();
|
||||
|
||||
private:
|
||||
void applyPendingBenchmark();
|
||||
|
||||
ViewportWindow* viewport_ = nullptr;
|
||||
SceneLoader* loader_ = nullptr;
|
||||
QWidget* viewport_container_ = nullptr;
|
||||
QLabel* status_label_ = nullptr;
|
||||
QLabel* stats_label_ = nullptr;
|
||||
|
||||
QString pending_camera_;
|
||||
int pending_benchmark_ = 0;
|
||||
QString pending_screenshot_;
|
||||
};
|
||||
|
||||
#endif // MINIMALWINDOW_H
|
||||
@@ -1,70 +0,0 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* 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 <QApplication>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
#include "MinimalWindow.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("IfcViewerMinimal");
|
||||
app.setOrganizationName("IfcOpenShell");
|
||||
|
||||
QSurfaceFormat fmt;
|
||||
fmt.setVersion(4, 5);
|
||||
fmt.setProfile(QSurfaceFormat::CoreProfile);
|
||||
fmt.setDepthBufferSize(24);
|
||||
fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
|
||||
fmt.setSamples(4);
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("IfcOpenShell minimal IFC viewer — benchmarking and debugging");
|
||||
parser.addHelpOption();
|
||||
parser.addPositionalArgument("files", "IFC file(s) to open", "[files...]");
|
||||
parser.addOption({{"c", "camera"},
|
||||
"Set camera: tx,ty,tz,dist,yaw,pitch", "params"});
|
||||
parser.addOption({{"b", "benchmark"},
|
||||
"Run N frames then print stats and exit", "frames"});
|
||||
parser.addOption({{"s", "screenshot"},
|
||||
"Render one frame after load, save to PATH as PNG, exit", "path"});
|
||||
parser.process(app);
|
||||
|
||||
MinimalWindow window;
|
||||
window.show();
|
||||
|
||||
auto args = parser.positionalArguments();
|
||||
if (!args.isEmpty()) {
|
||||
window.addFiles(args);
|
||||
}
|
||||
|
||||
if (parser.isSet("camera")) {
|
||||
window.setPendingCamera(parser.value("camera"));
|
||||
}
|
||||
if (parser.isSet("benchmark")) {
|
||||
window.setPendingBenchmark(parser.value("benchmark").toInt());
|
||||
}
|
||||
if (parser.isSet("screenshot")) {
|
||||
window.setPendingScreenshot(parser.value("screenshot"));
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user