2026-05-09 22:00:19 +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 "View.h"
|
|
|
|
|
|
|
|
|
|
#include "Panel.h"
|
|
|
|
|
|
2026-05-15 07:22:31 +10:00
|
|
|
#include "../../ViewerSettings.h"
|
2026-05-09 22:00:19 +10:00
|
|
|
#include "../../SessionState.h"
|
|
|
|
|
#include "../../../ifcviewer/Federation.h"
|
|
|
|
|
|
2026-05-15 07:22:31 +10:00
|
|
|
namespace ifcviewerfull::modules::models {
|
2026-05-09 22:00:19 +10:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
TreeNode makeGroupNode(const Federation* federation, const Federation::Group* group) {
|
|
|
|
|
TreeNode node;
|
|
|
|
|
node.id = group->id;
|
|
|
|
|
node.name = group->display_name;
|
|
|
|
|
node.kind = ItemKind::Group;
|
|
|
|
|
node.visible = group->visible;
|
|
|
|
|
|
|
|
|
|
for (const auto& child_group : group->children) {
|
|
|
|
|
node.children.append(makeGroupNode(federation, child_group.get()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const auto& model : federation->models()) {
|
|
|
|
|
if (model.group_id != group->id) continue;
|
|
|
|
|
node.children.append({
|
|
|
|
|
model.id,
|
|
|
|
|
model.display_name,
|
|
|
|
|
ItemKind::Model,
|
|
|
|
|
federation->isModelEffectivelyVisible(model.id),
|
|
|
|
|
{}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
ModelsPanelView::ModelsPanelView(ModelsPanel* widget,
|
2026-05-15 07:22:31 +10:00
|
|
|
ifcviewerfull::SessionState* session_state,
|
2026-05-09 22:00:19 +10:00
|
|
|
QObject* parent)
|
|
|
|
|
: QObject(parent), widget_(widget), session_state_(session_state)
|
|
|
|
|
{
|
2026-05-15 07:22:31 +10:00
|
|
|
connect(session_state_, &ifcviewerfull::SessionState::modelsChanged,
|
2026-05-09 22:00:19 +10:00
|
|
|
this, [this]() { reload(); });
|
2026-05-15 07:22:31 +10:00
|
|
|
connect(session_state_, &ifcviewerfull::SessionState::federationStructureChanged,
|
2026-05-09 22:00:19 +10:00
|
|
|
this, [this]() { reload(); });
|
2026-05-15 07:22:31 +10:00
|
|
|
connect(session_state_, &ifcviewerfull::SessionState::visibilityChanged,
|
2026-05-09 22:00:19 +10:00
|
|
|
this, [this]() { reload(); });
|
2026-05-15 07:22:31 +10:00
|
|
|
connect(session_state_, &ifcviewerfull::SessionState::projectReset,
|
2026-05-09 22:00:19 +10:00
|
|
|
this, [this]() { reload(); });
|
2026-05-15 07:22:31 +10:00
|
|
|
connect(session_state_, &ifcviewerfull::SessionState::projectOpened,
|
2026-05-09 22:00:19 +10:00
|
|
|
this, [this](const QString&) { reload(); });
|
2026-05-15 07:22:31 +10:00
|
|
|
connect(&ifcviewerfull::ViewerSettings::instance(),
|
|
|
|
|
&ifcviewerfull::ViewerSettings::themeChanged,
|
2026-05-14 11:30:10 +10:00
|
|
|
this, [this]() { reload(); });
|
2026-05-09 22:00:19 +10:00
|
|
|
|
|
|
|
|
reload();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelsPanelView::reload() {
|
|
|
|
|
Federation* federation = session_state_->federation();
|
|
|
|
|
QList<TreeNode> nodes;
|
|
|
|
|
for (const auto& root_group : federation->rootGroups()) {
|
|
|
|
|
nodes.append(makeGroupNode(federation, root_group.get()));
|
|
|
|
|
}
|
|
|
|
|
for (const auto& model : federation->models()) {
|
|
|
|
|
if (!model.group_id.isEmpty()) continue;
|
|
|
|
|
nodes.append({
|
|
|
|
|
model.id,
|
|
|
|
|
model.display_name,
|
|
|
|
|
ItemKind::Model,
|
|
|
|
|
federation->isModelEffectivelyVisible(model.id),
|
|
|
|
|
{}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
widget_->setNodes(nodes);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-15 07:22:31 +10:00
|
|
|
} // namespace ifcviewerfull::modules::models
|