OGS
GeoTreeModel.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <vtkPolyDataAlgorithm.h>
7#include <vector>
8
9#include "GeoLib/GeoType.h"
10#include "GeoLib/PointVec.h"
11#include "GeoLib/PolylineVec.h"
12#include "GeoLib/SurfaceVec.h"
13#include "Base/TreeModel.h"
14
15namespace GeoLib
16{
17struct GeoObject;
18}
19
20class QString;
21class QModelIndex;
22class GeoTreeItem;
24
29class GeoTreeModel : public TreeModel
30{
31 Q_OBJECT
32
33public:
34 explicit GeoTreeModel(QObject* parent = nullptr);
35 ~GeoTreeModel() override;
36
42 void addPointList(QString geoName, GeoLib::PointVec const& pointVec);
44 void addPolylineList(QString geoName, GeoLib::PolylineVec const& polylineVec);
46 void appendPolylines(const std::string &name, GeoLib::PolylineVec const& polylineVec);
48 void addSurfaceList(QString geoName, GeoLib::SurfaceVec const& surfaceVec);
50 void appendSurfaces(const std::string &name, GeoLib::SurfaceVec const& surfaceVec);
52 const std::vector<GeoTreeItem*> &getLists() { return _lists; }
57 void removeGeoList(const std::string &name, GeoLib::GEOTYPE type);
58
59 void renameGeometry(std::string const& old_name,
60 std::string const& new_name);
61
62 void setNameForItem(const std::string &name, GeoLib::GEOTYPE type, std::size_t id, std::string item_name);
63
64 /*
65 * Returns the geo-object specified by the given index.
66 * \param index Index of the requested item
67 * \param listName Here, the method will put the name of the geometry this object belongs to.
68 * \return A geo-object (Point / Polyline / Surface)
69 */
70 //const GeoLib::GeoObject* objectFromIndex( const QModelIndex& index, QString &geoName ) const;
71
73 vtkPolyDataAlgorithm* vtkSource(const std::string &name, GeoLib::GEOTYPE type) const;
74
75private:
77 void addChildren(GeoObjectListItem* plyList,
78 GeoLib::PolylineVec const& polyline_vec,
79 std::size_t start_index,
80 std::size_t end_index);
81
83 void addChildren(GeoObjectListItem* sfcList,
84 GeoLib::SurfaceVec const& surface_vec,
85 std::size_t start_index,
86 std::size_t end_index);
87
88 std::vector<GeoTreeItem*> _lists;
89};
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Definition PointVec.h:25
A TreeItem containing an additional GeoObject.
Definition GeoTreeItem.h:16
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)
const std::vector< GeoTreeItem * > & getLists()
Returns a list of all existing geometries.
vtkPolyDataAlgorithm * vtkSource(const std::string &name, GeoLib::GEOTYPE type) const
Returns the vtk-object indicated by type of the geometry indicated by name.
~GeoTreeModel() override
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
QModelIndex parent(const QModelIndex &index) const override
Definition TreeModel.cpp:70
TreeModel(QObject *parent=nullptr)
Definition TreeModel.cpp:15
GEOTYPE
Definition GeoType.h:12
TemplateVec< GeoLib::Surface > SurfaceVec
Definition SurfaceVec.h:17
TemplateVec< GeoLib::Polyline > PolylineVec
class PolylineVec encapsulate a std::vector of Polylines additional one can give the vector of polyli...
Definition PolylineVec.h:16