17#include <vtkUnstructuredGridAlgorithm.h>
38 QList<QVariant> rootData;
39 rootData <<
"Mesh Name"
71 QVariant
const display_name(QString::fromStdString(mesh->
getName()));
72 QList<QVariant> meshData;
73 meshData << display_name <<
""
79 std::vector<MeshLib::Element*>
const& elems = mesh->
getElements();
80 auto const nElems(
static_cast<int>(elems.size()));
82 for (
int i = 0; i < nElems; i++)
84 QList<QVariant> elemData;
88 newMesh->appendChild(
new TreeItem(elemData, newMesh));
108 WARN(
"MeshModel::getMesh(): Specified index does not exist.");
117 if (item->data(0).toString().toStdString() == name)
123 INFO(
"MeshModel::getMesh(): No entry found with name \"{:s}\".", name);
134 return this->
removeMesh(item->getMesh()->getName());
146 if (item->
data(0).toString().toStdString() == name)
156 INFO(
"MeshModel::removeMesh(): No entry found with name \"{:s}\".", name);
177 for (
auto const& mesh : mesh_vec)
188 std::vector<MeshLib::MeshElemType>
const& elem_types(
190 std::map<MeshLib::MeshElemType, QVariant> elem_map;
209 INFO(
"MeshModel::vtkSource(): Specified index does not exist.");
214 const std::string& name)
const
219 if (item->data(0).toString().toStdString() == name)
225 INFO(
"MeshModel::vtkSource(): No entry found with name \"{:s}\".", name);
Definition of the Element class.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the MeshItem class.
Definition of the MeshModel class.
Definition of the Node class.
Definition of the TreeItem class.
const std::vector< std::unique_ptr< MeshLib::Mesh > > & getMeshObjects() const
Returns all the meshes with their respective names.
bool removeMesh(const std::string &name)
void addMesh(std::unique_ptr< MeshLib::Mesh > mesh)
A TreeItem containing a mesh and the associated vtk object used in the Mesh Model.
MeshLib::Mesh const * getMesh() const
Returns the mesh.
MeshLib::VtkMappedMeshSource * vtkSource() const
Returns the VTK object.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
const std::string getName() const
Get name of the mesh.
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
void addMesh(std::unique_ptr< MeshLib::Mesh > mesh)
Adds a new mesh.
static const QVariant element_str
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.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns used for the data list.
void addMeshObject(const MeshLib::Mesh *mesh)
Adds the mesh to the GUI-Mesh-Model und -View.
const MeshLib::Mesh * getMesh(const QModelIndex &idx) const
Returns the mesh with the given index.
MeshModel(DataHolderLib::Project &project, QObject *parent=nullptr)
void updateMesh(MeshLib::Mesh *)
Updates the model/view for a mesh.
Objects nodes for the TreeModel.
virtual int childCount() const
void appendChild(TreeItem *item)
TreeItem * child(int row) const
bool removeChildren(int position, int count)
virtual QVariant data(int column) const
A hierarchical model for a tree implemented as a double-linked list.
TreeItem * getItem(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QModelIndex parent(const QModelIndex &index) const override
std::string MeshElemType2String(const MeshElemType t)
Given a MeshElemType this returns the appropriate string.
std::vector< MeshElemType > getMeshElemTypes()
Returns a vector of all mesh element types.
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.