-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathIfcTreeItem.cpp
More file actions
151 lines (132 loc) · 4.64 KB
/
IfcTreeItem.cpp
File metadata and controls
151 lines (132 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
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(data_->classname());
}
OpenInfraPlatform::UserInterface::IfcTreeItem::IfcTreeItem()
{
data_ = nullptr;
parentItem_ = nullptr;
std::string text = "Title";
itemData_.push_back(text);
}
OpenInfraPlatform::UserInterface::IfcTreeItem::~IfcTreeItem()
{
//childItems_.clear();
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 >= childItems_.size())
throw oip::UnhandledException("Child index out of range (IfcTreeItem::child)");
return childItems_.at(row);
}
int OpenInfraPlatform::UserInterface::IfcTreeItem::childCount() const
{
int nrOfChilds = childItems_.count();
return nrOfChilds;
}
int OpenInfraPlatform::UserInterface::IfcTreeItem::columnCount() const
{
int nrOfColumns = itemData_.size(); //size right here?
return nrOfColumns;
}
QVariant OpenInfraPlatform::UserInterface::IfcTreeItem::data(int column) const
{
if (column < 0 || column >= itemData_.size())
return QVariant();
//QString text = QString::fromStdString(itemData_.at(column));
return QString("text");
}
//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;
// //}
//
// //return QVariant();
// return getIfcClassName();
//}
int OpenInfraPlatform::UserInterface::IfcTreeItem::row() const
{
if (parentItem_)
{
return parentItem_->childItems_.indexOf(const_cast<IfcTreeItem*>(this));
}
return 0;
}
OpenInfraPlatform::UserInterface::IfcTreeItem* OpenInfraPlatform::UserInterface::IfcTreeItem::parentItem()
{
return parentItem_;
}
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_;
//};