OGS
GeoTreeModel.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <vtkPolyDataAlgorithm.h>
18 #include <vector>
19 
20 #include "GeoLib/GeoType.h"
21 #include "GeoLib/PointVec.h"
22 #include "GeoLib/PolylineVec.h"
23 #include "GeoLib/SurfaceVec.h"
24 #include "Base/TreeModel.h"
25 
26 namespace GeoLib
27 {
28 struct GeoObject;
29 }
30 
31 class QString;
32 class QModelIndex;
33 class GeoTreeItem;
34 class GeoObjectListItem;
35 
40 class GeoTreeModel : public TreeModel
41 {
42  Q_OBJECT
43 
44 public:
45  explicit GeoTreeModel(QObject* parent = nullptr);
46  ~GeoTreeModel() override;
47 
53  void addPointList(QString geoName, GeoLib::PointVec const& pointVec);
55  void addPolylineList(QString geoName, GeoLib::PolylineVec const& polylineVec);
57  void appendPolylines(const std::string &name, GeoLib::PolylineVec const& polylineVec);
59  void addSurfaceList(QString geoName, GeoLib::SurfaceVec const& surfaceVec);
61  void appendSurfaces(const std::string &name, GeoLib::SurfaceVec const& surfaceVec);
63  const std::vector<GeoTreeItem*> &getLists() { return _lists; }
68  void removeGeoList(const std::string &name, GeoLib::GEOTYPE type);
69 
70  void renameGeometry(std::string const& old_name,
71  std::string const& new_name);
72 
73  void setNameForItem(const std::string &name, GeoLib::GEOTYPE type, std::size_t id, std::string item_name);
74 
75  /*
76  * Returns the geo-object specified by the given index.
77  * \param index Index of the requested item
78  * \param listName Here, the method will put the name of the geometry this object belongs to.
79  * \return A geo-object (Point / Polyline / Surface)
80  */
81  //const GeoLib::GeoObject* objectFromIndex( const QModelIndex& index, QString &geoName ) const;
82 
84  vtkPolyDataAlgorithm* vtkSource(const std::string &name, GeoLib::GEOTYPE type) const;
85 
86 private:
88  void addChildren(GeoObjectListItem* plyList,
89  GeoLib::PolylineVec const& polyline_vec,
90  std::size_t start_index,
91  std::size_t end_index);
92 
95  GeoLib::SurfaceVec const& surface_vec,
96  std::size_t start_index,
97  std::size_t end_index);
98 
99  std::vector<GeoTreeItem*> _lists;
100 };
Definition of the GEOTYPE enumeration.
Definition of the PointVec class.
Definition of the PolylineVec class.
Definition of the SurfaceVec class.
Definition of the TreeModel class.
This class manages pointers to Points in a std::vector along with a name. It also handles the deletin...
Definition: PointVec.h:39
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
Definition: TemplateVec.h:40
A TreeItem containing an additional GeoObject.
Definition: GeoTreeItem.h:27
A model for the GeoTreeView implementing a tree as a double-linked list.
Definition: GeoTreeModel.h:41
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.
const std::vector< GeoTreeItem * > & getLists()
Returns a list of all existing geometries.
Definition: GeoTreeModel.h:63
~GeoTreeModel() override
void renameGeometry(std::string const &old_name, std::string const &new_name)
void addChildren(GeoObjectListItem *sfcList, GeoLib::SurfaceVec const &surface_vec, std::size_t start_index, std::size_t end_index)
Adds children to the "Surfaces" node.
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
Definition: GeoTreeModel.h:99
A hierarchical model for a tree implemented as a double-linked list.
Definition: TreeModel.h:30
QModelIndex parent(const QModelIndex &index) const override
Definition: TreeModel.cpp:81
GEOTYPE
Definition: GeoType.h:25