ifcviewer: load rdb/ifc as property data source on sidecar hit

Sidecar hits skipped opening the underlying .rdb/.ifc, so ifcFile() was
null and the property panel only showed cached name/type/guid. Now, after
a sidecar hit, a background thread opens <stem>.rdb (preferred) or
<stem>.ifc and hands the file to GeometryStreamer via setIfcFile(), with
a dataSourceReady signal so the UI refreshes the current selection.

Gated behind a new AppSettings::loadDataSource toggle (default on) so
users can opt into geometry-only viewing; when off, the sidecar-hit
thread is skipped and the stream-path ifc_file_ is released after
the sidecar write completes.

Also adds *.ifcview to the Add Files dialog filter so a cache can be
opened directly without its source file present.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-04-24 13:45:04 +10:00
parent eea2398e07
commit 8f7c8dc1d2
10 changed files with 153 additions and 1 deletions
+17 -1
View File
@@ -49,6 +49,8 @@ MainWindow::MainWindow(QWidget* parent)
this, &MainWindow::onSidecarElementsReady);
connect(loader_, &SceneLoader::loadedFromSidecar,
this, &MainWindow::onLoadedFromSidecar);
connect(loader_, &SceneLoader::dataSourceReady,
this, &MainWindow::onDataSourceReady);
connect(loader_, &SceneLoader::streamedElementsReady,
this, &MainWindow::onStreamedElementsReady);
connect(loader_, &SceneLoader::loadedFromStream,
@@ -141,7 +143,9 @@ void MainWindow::setupMenus() {
void MainWindow::onFileOpen() {
QStringList paths = QFileDialog::getOpenFileNames(
this, "Add IFC Files", QString(),
"IFC Files (*.ifc *.ifcxml *.ifczip);;All Files (*)");
"IFC Files (*.ifc *.ifcxml *.ifczip);;"
"IFC Viewer Cache (*.ifcview);;"
"All Files (*)");
if (!paths.isEmpty()) {
addFiles(paths);
}
@@ -254,6 +258,18 @@ void MainWindow::onSidecarElementsReady(uint32_t mid,
qDebug(" Tree build: %lld ms (%zu elements)", t.elapsed(), elements.size());
}
void MainWindow::onDataSourceReady(uint32_t mid) {
// Re-populate if the current selection belongs to this model, since
// populateProperties() now has an ifcFile() to query.
auto items = element_tree_->selectedItems();
if (items.isEmpty()) return;
uint32_t object_id = items.first()->data(0, Qt::UserRole).toUInt();
auto it = element_map_.find(object_id);
if (it != element_map_.end() && it->second.model_id == mid) {
populateProperties(object_id);
}
}
void MainWindow::onLoadedFromSidecar(uint32_t /*mid*/, qint64 elapsed_ms) {
progress_bar_->setVisible(false);
status_label_->setText(QString("%1 elements across %2 model(s) — loaded from cache in %3")