6#include <QContextMenuEvent>
37 setUniformRowHeights(
true);
46 setAlternatingRowColors(
true);
47 setColumnWidth(0, 150);
48 std::size_t nColumns =
49 (this->model() !=
nullptr) ? this->model()->columnCount() : 0;
50 for (std::size_t i = 1; i < nColumns; i++)
52 resizeColumnToContents(i);
57 const QItemSelection& deselected)
60 if (!selected.isEmpty())
63 const QModelIndex idx = *(selected.indexes().begin());
65 static_cast<TreeModel*
>(this->model())->getItem(idx);
67 const auto* list_item =
dynamic_cast<const MeshItem*
>(tree_item);
81 static_cast<unsigned>(tree_item->
row()),
true);
93 QModelIndex index(this->selectionModel()->currentIndex());
108 QModelIndex
const& index = this->selectionModel()->currentIndex();
110 static_cast<TreeItem*
>(index.internalPointer()));
119 std::vector<MeshAction> actions;
120 actions.push_back({
new QAction(
"Map mesh...",
this), 1, 2});
121 connect(actions.back().action, SIGNAL(triggered()),
this,
124 {
new QAction(
"Assign raster data to mesh...",
this), 1, 2});
125 connect(actions.back().action, SIGNAL(triggered()),
this,
127 actions.push_back({
new QAction(
"Extend mesh to 3D...",
this), 2, 3});
128 connect(actions.back().action, SIGNAL(triggered()),
this,
130 actions.push_back({
new QAction(
"Add layer...",
this), 1, 3});
131 connect(actions.back().action, SIGNAL(triggered()),
this,
133 actions.push_back({
new QAction(
"Edit material groups...",
this), 1, 3});
134 connect(actions.back().action, SIGNAL(triggered()),
this,
136 actions.push_back({
new QAction(
"Extract surface...",
this), 3, 3});
137 connect(actions.back().action, SIGNAL(triggered()),
this,
140 {
new QAction(
"Calculate element quality...",
this), 2, 3});
141 connect(actions.back().action, SIGNAL(triggered()),
this,
143 actions.push_back({
new QAction(
"Convert to geometry",
this), 1, 2});
144 connect(actions.back().action, SIGNAL(triggered()),
this,
146 actions.push_back({
new QAction(
"Export to Shapefile...",
this), 2, 2});
147 connect(actions.back().action, SIGNAL(triggered()),
this,
149 actions.push_back({
new QAction(
"Export to TetGen...",
this), 3, 3});
150 connect(actions.back().action, SIGNAL(triggered()),
this,
156 if (mesh_dim >= a.min_dim && mesh_dim <= a.max_dim)
158 menu.addAction(a.action);
161 menu.exec(event->globalPos());
167 QModelIndex
const index = this->selectionModel()->currentIndex();
175 if (dlg.exec() != QDialog::Accepted)
180 auto result = std::make_unique<MeshLib::Mesh>(*mesh);
184 std::unique_ptr<GeoLib::Raster> raster{
189 "Error mapping mesh. Could not read raster file " +
212 QModelIndex
const index = this->selectionModel()->currentIndex();
220 if (dlg.exec() != QDialog::Accepted)
225 auto result = std::make_unique<MeshLib::Mesh>(*mesh);
227 std::unique_ptr<GeoLib::Raster> raster{
231 OGSError::box(QString::fromStdString(
"Could not read raster file " +
251 QModelIndex
const index = this->selectionModel()->currentIndex();
255 connect(&meshLayerEdit, SIGNAL(mshEditFinished(
MeshLib::Mesh*)), model,
257 meshLayerEdit.exec();
263 QModelIndex
const index = this->selectionModel()->currentIndex();
267 connect(&valueEdit, SIGNAL(valueEditFinished(
MeshLib::Mesh*)), model,
274 QModelIndex
const index = this->selectionModel()->currentIndex();
275 if (!index.isValid())
281 static_cast<MeshModel*
>(this->model())->getMesh(index);
288 if (dlg.exec() != QDialog::Accepted)
293 bool const copy_material_ids =
false;
311 QModelIndex
const index = this->selectionModel()->currentIndex();
312 if (!index.isValid())
318 static_cast<MeshModel*
>(this->model())->getMesh(index);
320 if (dlg.exec() != QDialog::Accepted)
325 Eigen::Vector3d
const& dir(dlg.
getNormal());
327 std::unique_ptr<MeshLib::Mesh> sfc_mesh(
329 *mesh, dir, tolerance,
"Bulk Mesh Node IDs",
330 "Bulk Mesh Element IDs",
"Bulk Mesh Face IDs"));
338 " No surfaces found to extract\n using the specified parameters.");
344 QModelIndex
const index = this->selectionModel()->currentIndex();
346 static_cast<MeshModel*
>(this->model())->getMesh(index);
352 QModelIndex
const index = this->selectionModel()->currentIndex();
353 if (!index.isValid())
358 QSettings
const settings;
360 settings.value(
"lastOpenedMeshFileDirectory").toString());
362 static_cast<MeshModel*
>(this->model())->getMesh(index);
363 QString
const fileName = QFileDialog::getSaveFileName(
364 nullptr,
"Convert mesh to shapefile...",
366 QString::fromStdString(mesh->
getName()),
367 "ESRI Shapefile (*.shp)");
368 if (!fileName.isEmpty())
381 QModelIndex
const index = this->selectionModel()->currentIndex();
382 if (!index.isValid())
388 static_cast<MeshModel*
>(this->model())->getMesh(index);
389 QSettings
const settings;
391 this,
"Write TetGen input file to",
392 settings.value(
"lastOpenedTetgenFileDirectory").toString(),
393 "TetGen Geometry (*.smesh)");
394 dialog.setDefaultSuffix(
"smesh");
397 QString
const filename = dialog.getSaveFileName();
398 if (!filename.isEmpty())
401 std::vector<MeshLib::Node> attr;
409 QModelIndex
const index = this->selectionModel()->currentIndex();
410 if (!index.isValid())
417 static_cast<MeshModel*
>(this->model())->getMesh(index);
437 QModelIndex
const index = this->selectionModel()->currentIndex();
443 QModelIndex
const index = this->selectionModel()->currentIndex();
A dialog window for adding a layer to the top or bottom of a mesh.
std::string getName() const
Returns the name of the new mesh.
bool isTopLayer() const
Returns if the top layer button is selected (if false, bottom is selected).
double getThickness() const
Returns the thickness of the new layer.
static GeoLib::Raster * readRaster(std::string const &fname)
static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh)
static bool writeTetGenSmesh(const std::string &file_name, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name, const std::vector< GeoLib::Point > &attribute_points)
static void setDir(const QString &path)
Sets the directory last used for saving a file.
static const QString getDir()
Returns the directory last used for saving a file.
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.
A dialog window for editing meshes in various ways.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
const std::string getName() const
Get name of the mesh.
A dialog window for mapping a 2d mesh based on a raster file.
std::string getNewMeshName() const
bool getIgnoreNoData() const
bool useRasterMapping() const
std::string getRasterPath() const
double getNoDataReplacement() const
double getStaticValue() const
const MeshLib::Mesh * getMesh(const QModelIndex &idx) const
Returns the mesh with the given index.
A dialog window for changing the MaterialID for mesh elements.
void enableSaveButton(bool)
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override
Is called when the selection of this view changes.
void checkMeshQuality()
Calls the dialog for calculating an element quality metric.
void extractSurfaceMesh()
void meshSelected(MeshLib::Mesh const &)
void qualityCheckRequested(MeshLib::VtkMappedMeshSource *)
void contextMenuEvent(QContextMenuEvent *event) override
void openValuesEditDialog()
Opens a dialog for editing material groups.
MeshView(QWidget *parent=nullptr)
void openMap2dMeshDialog()
Opens a dialog for mapping 2d meshes.
void openMeshEditDialog()
Opens a dialog for editing meshes.
void writeToFile() const
Calls the FileDialog to save a mesh to a file.
void requestMeshToGeometryConversion(const MeshLib::Mesh *)
void addMesh()
Adds a new mesh.
void removeSelectedMeshComponent()
void openRasterDataToMeshDialog()
Opens a dialog for assigning raster data to the mesh.
void convertMeshToGeometry()
void loadDIRECTSourceTerms()
void openAddLayerDialog()
Opens a dialog for adding a layer to the mesh.
void elementSelected(vtkUnstructuredGridAlgorithm const *const, unsigned, bool)
void requestMeshRemoval(const QModelIndex &)
void loadFEMCondFileRequested(const std::string)
void addDIRECTSourceTerms()
void removeMesh()
Remove the currently selected mesh.
void exportToShapefile() const
void enableRemoveButton(bool)
static void box(const QString &e)
A dialog window for transferring raster data onto a mesh.
std::string getArrayName() const
std::string getMeshName() const
bool createNodeArray() const
double getNoDataReplacement() const
std::string getRasterPath() const
A dialog window for managing properties for writing meshes to files.
Objects nodes for the TreeModel.
TreeItem * parentItem() const
A hierarchical model for a tree implemented as a double-linked list.
TreeItem * getItem(const QModelIndex &index) const