mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 06:12:38 +00:00
ifcviewer: overhaul model/object ID tracking
Rename the two overloaded model identifiers and make object_id assignment single-authority, fixing a pick -> properties mismatch. Identifiers: - Per-model UUID fed_id -> model_id; the uint32 runtime handle model_id -> session_model_id (SessionState accessors + mirror hashes renamed to match). "fed_id" was a misnomer -- the federation is the whole collection, not one model. object_id assignment (fixes wrong class on click): - Producers (GeometryStreamer, .ifcview sidecar) now stamp model-LOCAL object_ids; ViewportCore::applyCachedModel is the sole authority that assigns the session-global id (base + local). Removed SceneLoader::next_object_id_, GeometryStreamer::lastObjectId(), and the streamer's start_object_id parameter. - The element table is stamped by the same base on both load paths (applySidecarData and onStreamerFinished), so registry ids match the ids pick returns. Previously the sidecar path double-rebased instances vs the registry (click IfcSite -> showed IfcDoor); the live-stream path had the same latent mismatch. Both closed. Naming / cleanup: - SceneLoader::addFiles -> queueModels; startStreamLoadFor -> loadFromGeometryStreamer; readSidecarMetadataOnly -> readSidecarMetadata. - Federation::addModel takes an explicit display_name (no QFileInfo fallback); callers pass QFileInfo(path).fileName(). - Disambiguate cryptic short locals (d->sidecar, m->model, c->chunk, ...) in SceneLoader, Federation, ViewportWindow, AreaMeasurement, SectionGizmoRenderer, and the SidecarData/SidecarReadPlan spots in ViewportCore. Tests: 125/125 pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -64,25 +64,25 @@ void SessionState::createLoader(ViewportWindow* viewport) {
|
||||
});
|
||||
connect(loader_, &SceneLoader::progressChanged, this, &SessionState::setProgress);
|
||||
connect(loader_, &SceneLoader::loadedFromSidecar, this,
|
||||
[this, format_elapsed](uint32_t model_id, qint64 elapsed_ms) {
|
||||
[this, format_elapsed](uint32_t session_model_id, qint64 elapsed_ms) {
|
||||
setStatusMessage("Loaded",
|
||||
QString("%1 from cache in %2")
|
||||
.arg(loader_->displayName(model_id))
|
||||
.arg(loader_->displayName(session_model_id))
|
||||
.arg(format_elapsed(elapsed_ms)));
|
||||
endProgress();
|
||||
emit modelGeometryReady(model_id);
|
||||
emit modelGeometryReady(session_model_id);
|
||||
});
|
||||
connect(loader_, &SceneLoader::loadedFromStream, this,
|
||||
[this, format_elapsed](uint32_t model_id, qint64 elapsed_ms) {
|
||||
[this, format_elapsed](uint32_t session_model_id, qint64 elapsed_ms) {
|
||||
setStatusMessage("Loaded",
|
||||
QString("%1 streamed in %2")
|
||||
.arg(loader_->displayName(model_id))
|
||||
.arg(loader_->displayName(session_model_id))
|
||||
.arg(format_elapsed(elapsed_ms)));
|
||||
endProgress();
|
||||
emit modelGeometryReady(model_id);
|
||||
emit modelGeometryReady(session_model_id);
|
||||
});
|
||||
connect(loader_, &SceneLoader::loadCancelled, this, [this](uint32_t model_id) {
|
||||
setStatusMessage("Cancelled", loader_->displayName(model_id));
|
||||
connect(loader_, &SceneLoader::loadCancelled, this, [this](uint32_t session_model_id) {
|
||||
setStatusMessage("Cancelled", loader_->displayName(session_model_id));
|
||||
endProgress();
|
||||
});
|
||||
connect(loader_, &SceneLoader::loadError, this,
|
||||
@@ -118,44 +118,44 @@ void SessionState::endProgress() {
|
||||
emit progressEnded();
|
||||
}
|
||||
|
||||
void SessionState::setModelMapping(const QString& fed_id, uint32_t model_id) {
|
||||
fed_id_to_model_id_[fed_id] = model_id;
|
||||
model_id_to_fed_id_[model_id] = fed_id;
|
||||
void SessionState::setModelMapping(const QString& model_id, uint32_t session_model_id) {
|
||||
model_id_to_session_model_id_[model_id] = session_model_id;
|
||||
session_model_id_to_model_id_[session_model_id] = model_id;
|
||||
}
|
||||
|
||||
void SessionState::removeModelMappingByFedId(const QString& fed_id) {
|
||||
cloud_metadata_.remove(fed_id);
|
||||
auto it = fed_id_to_model_id_.find(fed_id);
|
||||
if (it == fed_id_to_model_id_.end()) return;
|
||||
model_id_to_fed_id_.remove(it.value());
|
||||
fed_id_to_model_id_.erase(it);
|
||||
void SessionState::removeModelMappingByModelId(const QString& model_id) {
|
||||
cloud_metadata_.remove(model_id);
|
||||
auto it = model_id_to_session_model_id_.find(model_id);
|
||||
if (it == model_id_to_session_model_id_.end()) return;
|
||||
session_model_id_to_model_id_.remove(it.value());
|
||||
model_id_to_session_model_id_.erase(it);
|
||||
}
|
||||
|
||||
void SessionState::clearModelMappings() {
|
||||
fed_id_to_model_id_.clear();
|
||||
model_id_to_fed_id_.clear();
|
||||
model_id_to_session_model_id_.clear();
|
||||
session_model_id_to_model_id_.clear();
|
||||
cloud_metadata_.clear();
|
||||
}
|
||||
|
||||
void SessionState::setCloudMetadata(const QString& fed_id, const QVariantMap& metadata) {
|
||||
if (metadata.isEmpty()) cloud_metadata_.remove(fed_id);
|
||||
else cloud_metadata_.insert(fed_id, metadata);
|
||||
void SessionState::setCloudMetadata(const QString& model_id, const QVariantMap& metadata) {
|
||||
if (metadata.isEmpty()) cloud_metadata_.remove(model_id);
|
||||
else cloud_metadata_.insert(model_id, metadata);
|
||||
}
|
||||
|
||||
QVariantMap SessionState::cloudMetadata(const QString& fed_id) const {
|
||||
return cloud_metadata_.value(fed_id);
|
||||
QVariantMap SessionState::cloudMetadata(const QString& model_id) const {
|
||||
return cloud_metadata_.value(model_id);
|
||||
}
|
||||
|
||||
uint32_t SessionState::modelIdForFedId(const QString& fed_id) const {
|
||||
return fed_id_to_model_id_.value(fed_id, 0);
|
||||
uint32_t SessionState::sessionModelIdForModelId(const QString& model_id) const {
|
||||
return model_id_to_session_model_id_.value(model_id, 0);
|
||||
}
|
||||
|
||||
QString SessionState::fedIdForModelId(uint32_t model_id) const {
|
||||
return model_id_to_fed_id_.value(model_id);
|
||||
QString SessionState::modelIdForSessionModelId(uint32_t session_model_id) const {
|
||||
return session_model_id_to_model_id_.value(session_model_id);
|
||||
}
|
||||
|
||||
QList<uint32_t> SessionState::modelIds() const {
|
||||
return model_id_to_fed_id_.keys();
|
||||
QList<uint32_t> SessionState::sessionModelIds() const {
|
||||
return session_model_id_to_model_id_.keys();
|
||||
}
|
||||
|
||||
void SessionState::notifySelectionChanged() {
|
||||
@@ -174,8 +174,8 @@ void SessionState::notifyVisibilityChanged() {
|
||||
emit visibilityChanged();
|
||||
}
|
||||
|
||||
void SessionState::notifyModelGeometryReady(uint32_t model_id) {
|
||||
emit modelGeometryReady(model_id);
|
||||
void SessionState::notifyModelGeometryReady(uint32_t session_model_id) {
|
||||
emit modelGeometryReady(session_model_id);
|
||||
}
|
||||
|
||||
void SessionState::notifyProjectOpened(const QString& path) {
|
||||
|
||||
Reference in New Issue
Block a user