OGS
MeshModel.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 <memory>
7
8#include "MeshLib/MeshEnums.h"
9
11
12namespace DataHolderLib
13{
14class Project;
15}
16
17namespace MeshLib {
18class Mesh;
19}
20
21class vtkUnstructuredGridAlgorithm;
22
26class MeshModel : public TreeModel
27{
28 Q_OBJECT
29
30public:
31 explicit MeshModel(DataHolderLib::Project& project,
32 QObject* parent = nullptr);
33
35 void addMesh(std::unique_ptr<MeshLib::Mesh> mesh);
36
38 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
39
40public slots:
42 void addMesh(MeshLib::Mesh* mesh);
44 const MeshLib::Mesh* getMesh(const QModelIndex &idx) const;
46 const MeshLib::Mesh* getMesh(const std::string &name) const;
48 bool removeMesh(const QModelIndex &idx);
50 bool removeMesh(const std::string &name);
52 void updateMesh(MeshLib::Mesh* /*mesh*/);
54 void updateModel();
56 vtkUnstructuredGridAlgorithm* vtkSource(const QModelIndex &idx) const;
58 vtkUnstructuredGridAlgorithm* vtkSource(const std::string &name) const;
59
60private:
62 void addMeshObject(const MeshLib::Mesh* mesh);
63
65 //bool isUniqueMeshName(std::string &name);
67
69 static std::map<MeshLib::MeshElemType, QVariant> createMeshElemTypeMap();
70
71 static const std::map<MeshLib::MeshElemType, QVariant> elem_type_map;
72 static const QVariant element_str;
73
74signals:
75 void meshAdded(MeshModel*, const QModelIndex&);
76 void meshRemoved(MeshModel*, const QModelIndex&);
77};
void meshAdded(MeshModel *, const QModelIndex &)
void updateModel()
Updates the model based on the ProjectData-object.
bool removeMesh(const QModelIndex &idx)
Removes the mesh with the given index.
static std::map< MeshLib::MeshElemType, QVariant > createMeshElemTypeMap()
Creates a static map of all element type name-strings in QVariant format.
static const std::map< MeshLib::MeshElemType, QVariant > elem_type_map
Definition MeshModel.h:71
void addMesh(std::unique_ptr< MeshLib::Mesh > mesh)
Adds a new mesh.
Definition MeshModel.cpp:41
static const QVariant element_str
Definition MeshModel.h:72
void meshRemoved(MeshModel *, const QModelIndex &)
vtkUnstructuredGridAlgorithm * vtkSource(const QModelIndex &idx) const
Returns the VTK source item for the mesh with the given index.
DataHolderLib::Project & _project
Checks if the name of the mesh is already exists, if so it generates a unique name.
Definition MeshModel.h:66
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns used for the data list.
Definition MeshModel.cpp:34
void addMeshObject(const MeshLib::Mesh *mesh)
Adds the mesh to the GUI-Mesh-Model und -View.
Definition MeshModel.cpp:55
const MeshLib::Mesh * getMesh(const QModelIndex &idx) const
Returns the mesh with the given index.
Definition MeshModel.cpp:85
MeshModel(DataHolderLib::Project &project, QObject *parent=nullptr)
Definition MeshModel.cpp:23
void updateMesh(MeshLib::Mesh *)
Updates the model/view for a mesh.
QModelIndex parent(const QModelIndex &index) const override
Definition TreeModel.cpp:70
TreeModel(QObject *parent=nullptr)
Definition TreeModel.cpp:15