-
Notifications
You must be signed in to change notification settings - Fork 23
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
jschlenger
wants to merge
21
commits into
tumcms:development
Choose a base branch
from
jschlenger:TreeViewer
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Tree viewer #429
Changes from all 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 4fab59d
Add TreeDialog to UI
jschlenger 773bafe
Adding first part of the tree model and tree item (not working yet)
jschlenger 49fe485
Small changes maily to treeModel and treeItem
jschlenger 4383357
Adding a ExpressModel to the ifcModel in order to be able to access i…
jschlenger 02418af
Add IfcTreeItem.cpp + some minor changes
jschlenger 6de63e9
Small improvements
jschlenger b54c255
Changes to the tree model
jschlenger bc8c767
Small changes to tree items (not working yet!)
jschlenger a1f2e4a
Change everything from shared pointers to pointers (not working yet!)
jschlenger 6226824
minor changes (still not working)
jschlenger 79b3c90
Just some testing
jschlenger e51816b
Merge branch 'development' of https://github.com/jschlenger/Open-Infr…
jschlenger 9df4951
Adapt to the newest version of ifcImporter.h
jschlenger b112e1f
Trying to exactly replicate the Qt 5.12 simple tree model example (no…
jschlenger 83a9654
All it takes to get it to work
jschlenger 15d3a2f
Letting the treeviewer show the list of all IfcEntities within the lo…
jschlenger 5a28961
Clean up IfcTreeItem
jschlenger a7d19f5
Clean up IfcTreeDialog
jschlenger 007fa6f
Clean up IfcTreeModel
jschlenger 42bdceb
Some code from old tree viewer versions
jschlenger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
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" | ||
#include "Exception\UnhandledException.h" | ||
#include <QFileSystemModel> | ||
#include <QTreeWidgetItem> | ||
|
||
#include <filesystem> | ||
#include <string> | ||
#include <iostream> | ||
#include <direct.h> | ||
|
||
OpenInfraPlatform::UserInterface::IfcTreeDialog::IfcTreeDialog(QWidget *parent /*= nullptr*/) : | ||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint), | ||
ui_(new Ui::IfcTreeDialog) | ||
{ | ||
ui_->setupUi(this); | ||
} | ||
|
||
OpenInfraPlatform::UserInterface::IfcTreeDialog::~IfcTreeDialog() | ||
{ | ||
|
||
} | ||
|
||
void OpenInfraPlatform::UserInterface::IfcTreeDialog::show() | ||
{ | ||
//testing treeview with contents of IFC file | ||
auto model = Core::DataManagement::DocumentManager::getInstance().getData().getLastModel(); | ||
if (std::dynamic_pointer_cast<oip::IfcModel>(model)) | ||
{ | ||
auto ifcModel = std::static_pointer_cast<OpenInfraPlatform::Core::IfcGeometryConverter::IfcModel>(model); | ||
auto expressModelShared = ifcModel->getExpressModel(); | ||
OpenInfraPlatform::EarlyBinding::EXPRESSModel *expressModel = expressModelShared.get(); | ||
IfcTreeModel *treeModel = new IfcTreeModel(expressModel); | ||
ui_->ifcTreeView->setModel(treeModel); | ||
((QDialog*)this)->show(); | ||
} | ||
else | ||
{ | ||
//only for now till the selected model is properly handled | ||
throw oip::UnhandledException("Last model is not a IFC model"); | ||
} | ||
} | ||
|
||
|
||
void OpenInfraPlatform::UserInterface::IfcTreeDialog::on_pushButtonClose_clicked() | ||
{ | ||
hide(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(QWidget *parent = nullptr); | ||
|
||
//! Virtual destructor. | ||
virtual ~IfcTreeDialog(); | ||
|
||
void show(); | ||
|
||
private Q_SLOTS: | ||
void on_pushButtonClose_clicked(); | ||
|
||
private: | ||
Ui::IfcTreeDialog* ui_; | ||
|
||
}; // end class IfcTree | ||
} // end namespace UserInterface | ||
} // end namespace OpenInfraPlatform | ||
|
||
namespace oip | ||
{ | ||
using OpenInfraPlatform::UserInterface::IfcTreeDialog; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
/* | ||
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(OpenInfraPlatform::EarlyBinding::EXPRESSEntity *data, IfcTreeItem *parentItem) | ||
{ | ||
data_ = data; | ||
parentItem_ = parentItem; | ||
//itemData_.push_back(data_->getStepLine()); | ||
itemData_.push_back(QString::fromStdString(data_->classname())); | ||
} | ||
|
||
//OpenInfraPlatform::UserInterface::IfcTreeItem::IfcTreeItem(std::shared_ptr<OpenInfraPlatform::EarlyBinding::EXPRESSObject> &data, IfcTreeItem * parent) | ||
// : m_managedData(data), m_parentItem(parent), parser_() | ||
//{ | ||
// parser_.thisPtr = this; | ||
//} | ||
|
||
OpenInfraPlatform::UserInterface::IfcTreeItem::IfcTreeItem(const QList<QVariant> &data, IfcTreeItem *parent) | ||
{ | ||
parentItem_ = parent; | ||
itemData_ = data; | ||
} | ||
|
||
OpenInfraPlatform::UserInterface::IfcTreeItem::~IfcTreeItem() | ||
{ | ||
qDeleteAll(childItems_); | ||
} | ||
|
||
void OpenInfraPlatform::UserInterface::IfcTreeItem::appendChild(IfcTreeItem *child) | ||
{ | ||
childItems_.append(child); | ||
} | ||
|
||
OpenInfraPlatform::UserInterface::IfcTreeItem *OpenInfraPlatform::UserInterface::IfcTreeItem::child(int row) | ||
{ | ||
//if (row < 0 || row >= m_childItems.size()) | ||
// return nullptr; | ||
return childItems_.value(row); //QList provides default values in case row is out of range | ||
} | ||
|
||
int OpenInfraPlatform::UserInterface::IfcTreeItem::childCount() const | ||
{ | ||
return childItems_.count(); | ||
} | ||
|
||
int OpenInfraPlatform::UserInterface::IfcTreeItem::columnCount() const | ||
{ | ||
return itemData_.count(); | ||
} | ||
|
||
QVariant OpenInfraPlatform::UserInterface::IfcTreeItem::data(int column) const | ||
{ | ||
//if (column < 0 || column >= m_itemData.size()) | ||
// return QVariant(); | ||
return itemData_.value(column); //QList provides default values in case row is out of range | ||
} | ||
|
||
//QVariant OpenInfraPlatform::UserInterface::IfcTreeItem::data(int column) const | ||
//{ | ||
// //auto attributes = getAttributeDescription()<OpenInfraPlatform::EarlyBinding::EXPRESSEntity>(*data_); | ||
// | ||
// //switch (column) | ||
// //{ | ||
// //case 0: | ||
// // return attributes.names_[row]; | ||
// // break; | ||
// //case 1: | ||
// // return attributes.value_[row]; | ||
// // break; | ||
// //case 2: | ||
// // return attributes.typename_[row]; | ||
// // break; | ||
// //} | ||
//} | ||
|
||
OpenInfraPlatform::UserInterface::IfcTreeItem *OpenInfraPlatform::UserInterface::IfcTreeItem::parentItem() | ||
{ | ||
return parentItem_; | ||
} | ||
|
||
int OpenInfraPlatform::UserInterface::IfcTreeItem::row() const | ||
{ | ||
if (parentItem_) | ||
return parentItem_->childItems_.indexOf(const_cast<IfcTreeItem*>(this)); | ||
|
||
return 0; | ||
} | ||
|
||
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 oip::UnhandledException(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_; | ||
//}; | ||
|
||
//void OpenInfraPlatform::UserInterface::IfcTreeItem::createChildren() | ||
//{ | ||
// auto func = [&](auto item)->void { | ||
// visit_struct::for_each(item, [&](const char* name, auto &value) { | ||
// IfcTreeItem* child; | ||
// //if(std::is_base_of<OpenInfraPlatform::IfcAlignment1x1::IfcAlignment1x1Object, decltype(value)>::value) { | ||
// // child = new TreeItem(value, this); | ||
// //} | ||
// //else { | ||
// // child = new TreeItem(OpenInfraPlatform::IfcAlignment1x1::IfcAlignment1x1Object(), this); | ||
// //} | ||
// std::shared_ptr<OpenInfraPlatform::EarlyBinding::EXPRESSObject> ptr = nullptr; | ||
// child = new IfcTreeItem(ptr, this); | ||
// QList<QVariant> itemData; | ||
// itemData << QVariant(name) << QVariant("") << QVariant(typeid(value).name()); | ||
// this->appendChild(child); | ||
// }); | ||
// }; | ||
// | ||
// auto parse = [&](auto item) { | ||
// visit_struct::for_each(item, parser_); | ||
// }; | ||
// | ||
// if (m_managedData && m_managedData.get() != nullptr) { | ||
// if (std::dynamic_pointer_cast<OpenInfraPlatform::EarlyBinding::EXPRESSEntity>(m_managedData)) { | ||
// //OpenInfraPlatform::IfcAlignment1x1::castToVisitableAndCall<decltype(parse), void>(std::dynamic_pointer_cast<OpenInfraPlatform::EarlyBinding::EXPRESSEntity>(m_managedData), parse); | ||
// } | ||
// } | ||
//} | ||
|
||
//void OpenInfraPlatform::UserInterface::TreeItem::setItemData(QList<QVariant> itemData) | ||
//{ | ||
// itemData_ = itemData; | ||
//} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use dynamic pointer cast as well