28 QList<QVariant> rootData;
45 auto const& points = pointVec.
getVector();
47 QList<QVariant> geoData;
48 geoData << QVariant(geoName) <<
""
56 QList<QVariant> pointData;
64 geo->appendChild(pointList);
66 std::size_t nPoints = points.size();
68 for (std::size_t j = 0; j < nPoints; j++)
71 QList<QVariant> pnt_data;
73 pnt_data << static_cast<unsigned>(j) << QString::number(pnt[0],
'f')
74 << QString::number(pnt[1],
'f') << QString::number(pnt[2],
'f')
77 pnt_data, pointList,
static_cast<const GeoLib::Point*
>(&pnt)));
84 QVariant pnt_data(pointList->child(pnt->second)
85 ->setData(4, QString::fromStdString(pnt->first)));
88 INFO(
"Geometry '{:s}' built. {:d} points added.", geoName.toStdString(),
101 for (
int i = 0; i < nLists; i++)
111 ERR(
"GeoTreeModel::addPolylineList(): No corresponding geometry for "
113 geoName.toStdString());
117 auto const& lines = polylineVec.
getVector();
119 QList<QVariant> plyData;
120 plyData <<
"Polylines"
137 if (name == list->data(0).toString().toStdString())
139 for (
int j = 0; j < list->childCount(); j++)
148 parent->vtkSource()->Modified();
159 std::size_t start_index,
160 std::size_t end_index)
162 auto const& lines = polyline_vec.
getVector();
164 for (std::size_t i = start_index; i < end_index; i++)
166 QList<QVariant> line_data;
167 line_data.reserve(4);
168 line_data <<
"Line " + QString::number(i) <<
""
173 auto* lineItem(
new GeoTreeItem(line_data, plyList, &line));
176 auto nPoints =
static_cast<int>(lines[i]->getNumberOfPoints());
177 for (
int j = 0; j < nPoints; j++)
180 QList<QVariant> pnt_data;
182 pnt_data << static_cast<int>(line.
getPointID(j))
183 << QString::number(pnt[0],
'f')
184 << QString::number(pnt[1],
'f')
185 << QString::number(pnt[2],
'f');
187 lineItem->appendChild(
new TreeItem(pnt_data, lineItem));
195 QVariant pnt_data(plyList->
child(pnt->second)
196 ->
setData(1, QString::fromStdString(pnt->first)));
199 INFO(
"{:d} polylines added.", end_index - start_index);
209 for (
int i = 0; i < nLists; i++)
219 ERR(
"GeoTreeModel::addSurfaceList(): No corresponding geometry for "
221 geoName.toStdString());
225 auto const& surfaces = surfaceVec.
getVector();
227 QList<QVariant> sfcData;
228 sfcData <<
"Surfaces"
245 if (name == list->data(0).toString().toStdString())
247 int nChildren = list->childCount();
248 for (
int j = 0; j < nChildren; j++)
256 parent->vtkSource()->Modified();
268 std::size_t start_index,
269 std::size_t end_index)
271 auto const& surfaces = surface_vec.
getVector();
273 const std::vector<GeoLib::Point*>& nodesVec(
274 *(surfaces[start_index]->getPointVec()));
275 for (std::size_t i = start_index; i < end_index; i++)
277 QList<QVariant> surface;
279 surface <<
"Surface " + QString::number(i) <<
""
284 auto* surfaceItem(
new GeoTreeItem(surface, sfcList, &sfc));
287 auto nElems =
static_cast<int>(surfaces[i]->getNumberOfTriangles());
288 for (
int j = 0; j < nElems; j++)
290 QList<QVariant> elem;
293 elem << j << static_cast<int>(triangle[0])
294 <<
static_cast<int>(triangle[1])
295 <<
static_cast<int>(triangle[2]);
296 auto* child(
new TreeItem(elem, surfaceItem));
297 surfaceItem->appendChild(child);
299 for (
int k = 0; k < 3; k++)
301 QList<QVariant> node;
304 node << static_cast<int>(triangle[k])
305 << QString::number(pnt[0],
'f')
306 << QString::number(pnt[1],
'f')
307 << QString::number(pnt[2],
'f');
308 child->appendChild(
new TreeItem(node, child));
317 QVariant pnt_data(sfcList->
child(pnt->second)
318 ->
setData(1, QString::fromStdString(pnt->first)));
321 INFO(
"{:d} surfaces added.", end_index - start_index);
325 std::string
const& new_name)
327 for (
auto tree_item_entry :
_lists)
329 if (old_name == tree_item_entry->data(0).toString().toStdString())
331 QVariant new_entry(QString::fromStdString(new_name));
332 tree_item_entry->setData(0, new_entry);
336 for (
auto tree_item_entry :
_lists)
338 if (new_name == tree_item_entry->data(0).toString().toStdString())
340 INFO(
"Found tree_item_entry with name '{:s}'.", new_name);
350 for (std::size_t i = 0; i <
_lists.size(); i++)
352 if (name ==
_lists[i]->
data(0).toString().toStdString())
354 for (
int j = 0; j <
_lists[i]->childCount(); j++)
359 QModelIndex
index = createIndex(j, 0,
_lists[i]->child(j));
365 if (
_lists[i]->childCount() == 0)
377 std::size_t nLists =
_lists.size();
378 for (std::size_t i = 0; i < nLists; i++)
380 if (name ==
_lists[i]->
data(0).toString().toStdString())
382 for (
int j = 0; j <
_lists[i]->childCount(); j++)
386 if (item->getType() == type)
399 std::string item_name)
401 std::string geo_type_str;
407 geo_type_str =
"Points";
411 geo_type_str =
"Polylines";
414 geo_type_str =
"Surfaces";
423 { return (name == geo->data(0).toString().toStdString()); });
425 for (
int i = 0; i < (*it)->childCount(); i++)
427 if (geo_type_str == (*it)->child(i)->data(0).toString().toStdString())
430 item->
setData(col_idx, QString::fromStdString(item_name));
Definition of the GeoObjectListItem class.
Definition of the GeoTreeItem class.
Definition of the GeoTreeModel class.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the OGSError class.
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
std::size_t getPointID(std::size_t const i) const
const Point * getPoint(std::size_t i) const
returns the i-th point contained in the polyline
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
NameIdMap::const_iterator getNameIDMapBegin() const
Returns the begin of the name id mapping structure.
std::vector< T * > const & getVector() const
NameIdMap::const_iterator getNameIDMapEnd() const
Returns the end of the name id mapping structure.
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
vtkPolyDataAlgorithm * vtkSource() const
Returns the Vtk polydata source object.
A TreeItem containing an additional GeoObject.
void appendPolylines(const std::string &name, GeoLib::PolylineVec const &polylineVec)
Appends polylines to the "Polyline"-subtree.
void addSurfaceList(QString geoName, GeoLib::SurfaceVec const &surfaceVec)
Adds a subtree "Surfaces" to an existing geometry with the given name.
void addPointList(QString geoName, GeoLib::PointVec const &pointVec)
vtkPolyDataAlgorithm * vtkSource(const std::string &name, GeoLib::GEOTYPE type) const
Returns the vtk-object indicated by type of the geometry indicated by name.
void renameGeometry(std::string const &old_name, std::string const &new_name)
void appendSurfaces(const std::string &name, GeoLib::SurfaceVec const &surfaceVec)
Appends surfaces to the "Surface"-subtree.
void setNameForItem(const std::string &name, GeoLib::GEOTYPE type, std::size_t id, std::string item_name)
void addPolylineList(QString geoName, GeoLib::PolylineVec const &polylineVec)
Adds a subtree "Polylines" to an existing geometry with the given name.
void addChildren(GeoObjectListItem *plyList, GeoLib::PolylineVec const &polyline_vec, std::size_t start_index, std::size_t end_index)
Adds children to the "Polylines" node.
void removeGeoList(const std::string &name, GeoLib::GEOTYPE type)
GeoTreeModel(QObject *parent=nullptr)
std::vector< GeoTreeItem * > _lists
static void box(const QString &e)
Objects nodes for the TreeModel.
virtual int childCount() const
void appendChild(TreeItem *item)
TreeItem * child(int row) const
virtual bool setData(int column, const QVariant &value)
virtual QVariant data(int column) const
A hierarchical model for a tree implemented as a double-linked list.
bool removeRows(int position, int count, const QModelIndex &parent) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
QModelIndex parent(const QModelIndex &index) const override