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"
|
|
|
|
|
|
2026-05-16 17:04:23 +10:00
|
|
|
#include "FederationItemModel.h"
|
2026-05-09 22:00:19 +10:00
|
|
|
#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-20 09:38:10 +10:00
|
|
|
namespace bonsaiviewer::modules::models {
|
2026-05-09 22:00:19 +10:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2026-05-15 17:08:08 +10:00
|
|
|
void collectGroupsRecursive(const Federation::Group* group,
|
|
|
|
|
const QString& exclude_subtree_root,
|
|
|
|
|
QList<GroupOption>& out) {
|
|
|
|
|
if (group->id == exclude_subtree_root) return;
|
|
|
|
|
out.append({group->id, group->display_name});
|
|
|
|
|
for (const auto& child : group->children) {
|
|
|
|
|
collectGroupsRecursive(child.get(), exclude_subtree_root, out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-09 22:00:19 +10:00
|
|
|
} // namespace
|
|
|
|
|
|
2026-05-16 17:04:23 +10:00
|
|
|
QList<GroupOption> validMoveTargets(const Federation& federation,
|
|
|
|
|
const QString& exclude_subtree_root) {
|
|
|
|
|
QList<GroupOption> out;
|
|
|
|
|
for (const auto& root : federation.rootGroups()) {
|
|
|
|
|
collectGroupsRecursive(root.get(), exclude_subtree_root, out);
|
|
|
|
|
}
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-09 22:00:19 +10:00
|
|
|
ModelsPanelView::ModelsPanelView(ModelsPanel* widget,
|
2026-05-20 09:38:10 +10:00
|
|
|
bonsaiviewer::SessionState* session_state,
|
2026-05-09 22:00:19 +10:00
|
|
|
QObject* parent)
|
2026-05-15 17:08:08 +10:00
|
|
|
: QObject(parent)
|
|
|
|
|
, widget_(widget)
|
|
|
|
|
, session_state_(session_state)
|
2026-05-16 17:04:23 +10:00
|
|
|
, model_(new FederationItemModel(session_state->federation(), this))
|
2026-05-09 22:00:19 +10:00
|
|
|
{
|
2026-05-16 17:04:23 +10:00
|
|
|
widget_->setModel(model_);
|
|
|
|
|
|
|
|
|
|
// Coarse signals: full rebuild + re-style. The granular Federation
|
|
|
|
|
// signals are handled inside FederationItemModel and don't reach here.
|
|
|
|
|
auto rebuild = [this]() { model_->rebuildAll(); };
|
|
|
|
|
connect(session_state_, &SessionState::projectReset, this, rebuild);
|
|
|
|
|
connect(session_state_, &SessionState::projectOpened, this, rebuild);
|
2026-05-20 09:38:10 +10:00
|
|
|
connect(&bonsaiviewer::ViewerSettings::instance(),
|
|
|
|
|
&bonsaiviewer::ViewerSettings::themeChanged,
|
2026-05-16 17:04:23 +10:00
|
|
|
this, rebuild);
|
2026-05-15 17:08:08 +10:00
|
|
|
}
|
|
|
|
|
|
2026-05-20 09:38:10 +10:00
|
|
|
} // namespace bonsaiviewer::modules::models
|