Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree viewer #429

Draft
wants to merge 21 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6b789bd
Add Button to UI that will open the Ifc Tree once it is implemented
jschlenger Apr 7, 2021
4fab59d
Add TreeDialog to UI
jschlenger Apr 8, 2021
773bafe
Adding first part of the tree model and tree item (not working yet)
jschlenger Apr 15, 2021
49fe485
Small changes maily to treeModel and treeItem
jschlenger Apr 20, 2021
4383357
Adding a ExpressModel to the ifcModel in order to be able to access i…
jschlenger Apr 20, 2021
02418af
Add IfcTreeItem.cpp + some minor changes
jschlenger Apr 21, 2021
6de63e9
Small improvements
jschlenger Apr 23, 2021
b54c255
Changes to the tree model
jschlenger May 21, 2021
bc8c767
Small changes to tree items (not working yet!)
jschlenger May 21, 2021
a1f2e4a
Change everything from shared pointers to pointers (not working yet!)
jschlenger May 21, 2021
6226824
minor changes (still not working)
jschlenger May 28, 2021
79b3c90
Just some testing
jschlenger Jul 1, 2021
e51816b
Merge branch 'development' of https://github.com/jschlenger/Open-Infr…
jschlenger Jul 1, 2021
9df4951
Adapt to the newest version of ifcImporter.h
jschlenger Jul 1, 2021
b112e1f
Trying to exactly replicate the Qt 5.12 simple tree model example (no…
jschlenger Jul 1, 2021
83a9654
All it takes to get it to work
jschlenger Jul 1, 2021
15d3a2f
Letting the treeviewer show the list of all IfcEntities within the lo…
jschlenger Jul 1, 2021
5a28961
Clean up IfcTreeItem
jschlenger Jul 1, 2021
a7d19f5
Clean up IfcTreeDialog
jschlenger Jul 1, 2021
007fa6f
Clean up IfcTreeModel
jschlenger Jul 1, 2021
42bdceb
Some code from old tree viewer versions
jschlenger Jul 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ set(OpenInfraPlatform_UserInterface_Forms
UserInterface/Forms/MainWindow.ui
UserInterface/Forms/LicenseAndCopyrightInformation.ui
UserInterface/Forms/PreferencesDialog.ui
UserInterface/Forms/IfcTreeDialog.ui

# Currently not included.
#UserInterface/Forms/CreateAccidentReport.ui
Expand Down
6 changes: 6 additions & 0 deletions Core/src/IfcGeometryConverter/IfcGeometryModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "IfcGeometryModel.h"
#include "Exception\UnhandledException.h"


void OpenInfraPlatform::Core::IfcGeometryConverter::IfcModel::reset()
{
for( auto geom : geometries_ )
Expand All @@ -37,6 +38,11 @@ void OpenInfraPlatform::Core::IfcGeometryConverter::IfcModel::addGeometry(std::s
geometryMutex_.unlock();
}

void OpenInfraPlatform::Core::IfcGeometryConverter::IfcModel::addExpressModel(std::shared_ptr<OpenInfraPlatform::EarlyBinding::EXPRESSModel> expressModel)
{
expressModel_ = expressModel;
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Interface IModel implementation
bool OpenInfraPlatform::Core::IfcGeometryConverter::IfcModel::isEmpty() const
Expand Down
10 changes: 8 additions & 2 deletions Core/src/IfcGeometryConverter/IfcGeometryModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <IModel.h>

#include "namespace.h"
#include "EXPRESS/EXPRESSModel.h"

typedef buw::VertexPosition3Color3Normal3 VertexLayout;

Expand Down Expand Up @@ -80,15 +81,20 @@ namespace OpenInfraPlatform
std::vector<std::shared_ptr<GeometryDescription>> geometries_;
std::mutex geometryMutex_;

std::string filename_;
oip::GeorefMetadata georefMeta_;
std::string filename_;
oip::GeorefMetadata georefMeta_;

std::shared_ptr<oip::EXPRESSModel> expressModel_;

public:
void reset();

void addGeometry(std::shared_ptr<GeometryDescription> geometry);
std::vector<std::shared_ptr<GeometryDescription>> const &geometries() const { return geometries_; }

void addExpressModel(std::shared_ptr<OpenInfraPlatform::EarlyBinding::EXPRESSModel> expressModel);
std::shared_ptr<OpenInfraPlatform::EarlyBinding::EXPRESSModel> const getExpressModel() const { return expressModel_; }

// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Interface IModel implementation
// ---------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions Core/src/IfcGeometryConverter/IfcImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class IfcImporterT
georefConverter->init(expressModel);
ifcModel->setGeoref(georefConverter->getGeorefMetadata());

//store a pointer to the express model in the in the ifc model (used for the tree viewer)
ifcModel->addExpressModel(expressModel);
jschlenger marked this conversation as resolved.
Show resolved Hide resolved

// collect all geometries
if (!collectGeometryData(expressModel))
return ifcModel;
Expand Down
53 changes: 53 additions & 0 deletions UserInterface/Dialogues/IfcTreeDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright (c) 2021 Technical University of Munich
Chair of Computational Modeling and Simulation.

TUM Open Infra Platform is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 3
as published by the Free Software Foundation.

TUM Open Infra Platform 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
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "IfcTreeDialog.h"
#include "IfcTreeModel.h"
#include "ui_IfcTreeDialog.h"
#include "DataManagement/General/Data.h"

OpenInfraPlatform::UserInterface::IfcTreeDialog::IfcTreeDialog(OpenInfraPlatform::UserInterface::View* view, QWidget *parent /*= nullptr*/) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
ui_(new Ui::IfcTreeDialog),
view_(view)
{
ui_->setupUi(this);
//ui_->ifcTreeWidget->setAnimated(true);
//ui_->ifcTreeView->setModel(new IfcTreeModel());
}

OpenInfraPlatform::UserInterface::IfcTreeDialog::~IfcTreeDialog()
{

}

void OpenInfraPlatform::UserInterface::IfcTreeDialog::show()
{
//for first testing just get last model, later this will be changed to selecting the model need
auto model = Core::DataManagement::DocumentManager::getInstance().getData().getLastModel();
auto ifcModel = std::static_pointer_cast<OpenInfraPlatform::Core::IfcGeometryConverter::IfcModel>(model);
jschlenger marked this conversation as resolved.
Show resolved Hide resolved
auto expressModel = ifcModel->getExpressModel();
auto treeModel = new IfcTreeModel(expressModel);
ui_->ifcTreeView->setModel(treeModel);
((QDialog*)this)->show();
}


void OpenInfraPlatform::UserInterface::IfcTreeDialog::on_pushButtonClose_clicked()
{
hide();
}
55 changes: 55 additions & 0 deletions UserInterface/Dialogues/IfcTreeDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright (c) 2021 Technical University of Munich
Chair of Computational Modeling and Simulation.

TUM Open Infra Platform is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 3
as published by the Free Software Foundation.

TUM Open Infra Platform 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
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "ui_IfcTreeDialog.h"
#include "ViewPanel/View.h"

#include <QDialog>
#include <iostream>

namespace OpenInfraPlatform
{
namespace UserInterface
{
class IfcTreeDialog : public QDialog
{
Q_OBJECT;

public:
IfcTreeDialog(OpenInfraPlatform::UserInterface::View* view, QWidget *parent = nullptr);

//! Virtual destructor.
virtual ~IfcTreeDialog();

void show();

private Q_SLOTS:
void on_pushButtonClose_clicked();

private:
Ui::IfcTreeDialog* ui_;
OpenInfraPlatform::UserInterface::View* view_;
}; // end class IfcTree
} // end namespace UserInterface
} // end namespace OpenInfraPlatform

namespace oip
{
using OpenInfraPlatform::UserInterface::IfcTreeDialog;
}
131 changes: 131 additions & 0 deletions UserInterface/Dialogues/IfcTreeItem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
Copyright (c) 2021 Technical University of Munich
Chair of Computational Modeling and Simulation.

TUM Open Infra Platform is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 3
as published by the Free Software Foundation.

TUM Open Infra Platform 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
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "IfcTreeItem.h"
#include <QStringList>
#include <type_traits>
#include <cstdlib>
#include "Exception\UnhandledException.h"
#include "visit_struct\visit_struct.hpp"


OpenInfraPlatform::UserInterface::IfcTreeItem::IfcTreeItem(std::shared_ptr<OpenInfraPlatform::EarlyBinding::EXPRESSEntity> data, std::shared_ptr<IfcTreeItem> parentItem)
:data_(data), parentItem_(parentItem)
{}

OpenInfraPlatform::UserInterface::IfcTreeItem::~IfcTreeItem()
{
childItems_.clear();
}

void OpenInfraPlatform::UserInterface::IfcTreeItem::appendchild(std::shared_ptr<IfcTreeItem> child)
{
childItems_.append(child);
}

std::shared_ptr<OpenInfraPlatform::UserInterface::IfcTreeItem> OpenInfraPlatform::UserInterface::IfcTreeItem::child(int row)
{
if (row < 0 || row >= childItems_.size())
return nullptr;
jschlenger marked this conversation as resolved.
Show resolved Hide resolved
return childItems_.at(row);
}

int OpenInfraPlatform::UserInterface::IfcTreeItem::childCount() const
{
return childItems_.count();
}

int OpenInfraPlatform::UserInterface::IfcTreeItem::columnCount() const
{
return 3;
}

QVariant OpenInfraPlatform::UserInterface::IfcTreeItem::data(int row, int column) const
{
//auto attributes = getAttributeDescription();

//switch (column)
//{
//case 0:
// return attributes.names_[row];
// break;
//case 1:
// return attributes.value_[row];
// break;
//case 2:
// return attributes.typename_[row];
// break;
//}
return QVariant();
}

int OpenInfraPlatform::UserInterface::IfcTreeItem::row()
{
if (parentItem_)
{
return parentItem_->childItems_.indexOf(shared_from_this());
}
return 0;
}

std::shared_ptr<OpenInfraPlatform::UserInterface::IfcTreeItem> OpenInfraPlatform::UserInterface::IfcTreeItem::parentItem()
{
if (parentItem_)
return parentItem_;

return std::shared_ptr<IfcTreeItem>();
jschlenger marked this conversation as resolved.
Show resolved Hide resolved
}

QString OpenInfraPlatform::UserInterface::IfcTreeItem::getIfcClassName() const
{
std::string ifcClassName = data_->classname();
return QString::fromStdString(ifcClassName);
}

struct OpenInfraPlatform::UserInterface::IfcTreeItem::getAttributeDescription
{

template <class T> typename std::enable_if<visit_struct::traits::is_visitable<T>::value && std::is_base_of<OpenInfraPlatform::EarlyBinding::EXPRESSEntity, T>::value, void>::type
operator()(T entity)
{
visit_struct::for_each(entity, [&](const char* name, const auto &value) {
names_.push_back(name);
typename_ = typeid(T).name(entity);
value_.push_back(value);

});
}

//This is a dummy function which should never be called but is required by the compiler since it could theoretically be called. Throws exception.
template <class T> typename std::enable_if<!std::is_base_of<OpenInfraPlatform::EarlyBinding::EXPRESSEntity, T>::value, void>::type
operator()(T& entity) const
{
std::string message = "Invalid function call. " + std::string(typeid(entity).name()) + " isn't a member of EXPRESSEntity.";
throw buw::Exception(message);
}

//This is a dummy function which should never be called but is required by the compiler since it could theoretically be called. Throws exception.
void operator()(OpenInfraPlatform::EarlyBinding::EXPRESSEntity& entity) const
{
throw oip::UnhandledException("Invalid function call (IfcTreeItem::getAttributeDescription)");
}

std::vector<const char*> names_;
std::vector<const char*> typename_;
std::vector <QVariant> value_;

};
60 changes: 60 additions & 0 deletions UserInterface/Dialogues/IfcTreeItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright (c) 2021 Technical University of Munich
Chair of Computational Modeling and Simulation.

TUM Open Infra Platform is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 3
as published by the Free Software Foundation.

TUM Open Infra Platform 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
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef IFCTREEITEM_H
#define IFCTREEITEM_H

#include "EXPRESS/EXPRESSReference.h"
#include <QVariant>


namespace OpenInfraPlatform {
namespace UserInterface {

class IfcTreeItem : public std::enable_shared_from_this<IfcTreeItem>
{
public:
IfcTreeItem(std::shared_ptr<OpenInfraPlatform::EarlyBinding::EXPRESSEntity> data, std::shared_ptr<IfcTreeItem> parentItem = nullptr);
~IfcTreeItem();

void appendchild(std::shared_ptr<IfcTreeItem> child);

std::shared_ptr<IfcTreeItem> child(int row);
int childCount() const;
int columnCount() const;
QVariant data(int row, int column) const;
int row();
std::shared_ptr<IfcTreeItem> parentItem();
QString getIfcClassName() const;

private:
QList<std::shared_ptr<IfcTreeItem>> childItems_;
std::shared_ptr<OpenInfraPlatform::EarlyBinding::EXPRESSEntity> data_;
std::shared_ptr<IfcTreeItem> parentItem_;

struct getAttributeDescription;
};
}
}


#endif //IFCTREEITEM_H

namespace oip
{
using OpenInfraPlatform::UserInterface::IfcTreeItem;
}
Empty file.
Loading