OGS
MeshModel.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <memory>
18 
19 #include "MeshLib/MeshEnums.h"
20 
21 #include "Base/TreeModel.h"
22 
23 namespace DataHolderLib
24 {
25 class Project;
26 }
27 
28 namespace MeshLib {
29 class Mesh;
30 }
31 
32 class vtkUnstructuredGridAlgorithm;
33 
37 class MeshModel : public TreeModel
38 {
39  Q_OBJECT
40 
41 public:
42  explicit MeshModel(DataHolderLib::Project& project,
43  QObject* parent = nullptr);
44 
46  void addMesh(std::unique_ptr<MeshLib::Mesh> mesh);
47 
49  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
50 
51 public slots:
53  void addMesh(MeshLib::Mesh* mesh);
55  const MeshLib::Mesh* getMesh(const QModelIndex &idx) const;
57  const MeshLib::Mesh* getMesh(const std::string &name) const;
59  bool removeMesh(const QModelIndex &idx);
61  bool removeMesh(const std::string &name);
63  void updateMesh(MeshLib::Mesh* /*mesh*/);
65  void updateModel();
67  vtkUnstructuredGridAlgorithm* vtkSource(const QModelIndex &idx) const;
69  vtkUnstructuredGridAlgorithm* vtkSource(const std::string &name) const;
70 
71 private:
73  void addMeshObject(const MeshLib::Mesh* mesh);
74 
76  //bool isUniqueMeshName(std::string &name);
78 
80  static std::map<MeshLib::MeshElemType, QVariant> createMeshElemTypeMap();
81 
82  static const std::map<MeshLib::MeshElemType, QVariant> elem_type_map;
83  static const QVariant element_str;
84 
85 signals:
86  void meshAdded(MeshModel*, const QModelIndex&);
87  void meshRemoved(MeshModel*, const QModelIndex&);
88 };
Definition of mesh-related Enumerations.
Definition of the TreeModel class.
void meshAdded(MeshModel *, const QModelIndex &)
void updateModel()
Updates the model based on the ProjectData-object.
Definition: MeshModel.cpp:174
bool removeMesh(const QModelIndex &idx)
Removes the mesh with the given index.
Definition: MeshModel.cpp:127
static std::map< MeshLib::MeshElemType, QVariant > createMeshElemTypeMap()
Creates a static map of all element type name-strings in QVariant format.
Definition: MeshModel.cpp:186
static const std::map< MeshLib::MeshElemType, QVariant > elem_type_map
Definition: MeshModel.h:82
void addMesh(std::unique_ptr< MeshLib::Mesh > mesh)
Adds a new mesh.
Definition: MeshModel.cpp:52
static const QVariant element_str
Definition: MeshModel.h:83
void meshRemoved(MeshModel *, const QModelIndex &)
vtkUnstructuredGridAlgorithm * vtkSource(const QModelIndex &idx) const
Returns the VTK source item for the mesh with the given index.
Definition: MeshModel.cpp:201
DataHolderLib::Project & _project
Checks if the name of the mesh is already exists, if so it generates a unique name.
Definition: MeshModel.h:77
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns used for the data list.
Definition: MeshModel.cpp:45
void addMeshObject(const MeshLib::Mesh *mesh)
Adds the mesh to the GUI-Mesh-Model und -View.
Definition: MeshModel.cpp:66
const MeshLib::Mesh * getMesh(const QModelIndex &idx) const
Returns the mesh with the given index.
Definition: MeshModel.cpp:96
MeshModel(DataHolderLib::Project &project, QObject *parent=nullptr)
Definition: MeshModel.cpp:34
void updateMesh(MeshLib::Mesh *)
Updates the model/view for a mesh.
Definition: MeshModel.cpp:160
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