17#include <QContextMenuEvent>
48 setUniformRowHeights(
true);
57 setAlternatingRowColors(
true);
58 setColumnWidth(0, 150);
59 std::size_t nColumns =
60 (this->model() !=
nullptr) ? this->model()->columnCount() : 0;
61 for (std::size_t i = 1; i < nColumns; i++)
63 resizeColumnToContents(i);
68 const QItemSelection& deselected)
71 if (!selected.isEmpty())
74 const QModelIndex idx = *(selected.indexes().begin());
76 static_cast<TreeModel*
>(this->model())->getItem(idx);
78 const auto* list_item =
dynamic_cast<const MeshItem*
>(tree_item);
92 static_cast<unsigned>(tree_item->
row()),
true);
104 QModelIndex index(this->selectionModel()->currentIndex());
105 if (!index.isValid())
119 QModelIndex
const& index = this->selectionModel()->currentIndex();
121 static_cast<TreeItem*
>(index.internalPointer()));
130 std::vector<MeshAction> actions;
131 actions.push_back({
new QAction(
"Map mesh...",
this), 1, 2});
132 connect(actions.back().action, SIGNAL(triggered()),
this,
135 {
new QAction(
"Assign raster data to mesh...",
this), 1, 2});
136 connect(actions.back().action, SIGNAL(triggered()),
this,
138 actions.push_back({
new QAction(
"Extend mesh to 3D...",
this), 2, 3});
139 connect(actions.back().action, SIGNAL(triggered()),
this,
141 actions.push_back({
new QAction(
"Add layer...",
this), 1, 3});
142 connect(actions.back().action, SIGNAL(triggered()),
this,
144 actions.push_back({
new QAction(
"Edit material groups...",
this), 1, 3});
145 connect(actions.back().action, SIGNAL(triggered()),
this,
147 actions.push_back({
new QAction(
"Extract surface...",
this), 3, 3});
148 connect(actions.back().action, SIGNAL(triggered()),
this,
151 {
new QAction(
"Calculate element quality...",
this), 2, 3});
152 connect(actions.back().action, SIGNAL(triggered()),
this,
154 actions.push_back({
new QAction(
"Convert to geometry",
this), 1, 2});
155 connect(actions.back().action, SIGNAL(triggered()),
this,
157 actions.push_back({
new QAction(
"Export to Shapefile...",
this), 2, 2});
158 connect(actions.back().action, SIGNAL(triggered()),
this,
160 actions.push_back({
new QAction(
"Export to TetGen...",
this), 3, 3});
161 connect(actions.back().action, SIGNAL(triggered()),
this,
167 if (mesh_dim >= a.min_dim && mesh_dim <= a.max_dim)
169 menu.addAction(a.action);
172 menu.exec(event->globalPos());
178 QModelIndex
const index = this->selectionModel()->currentIndex();
186 if (dlg.exec() != QDialog::Accepted)
191 auto result = std::make_unique<MeshLib::Mesh>(*mesh);
195 std::unique_ptr<GeoLib::Raster> raster{
200 "Error mapping mesh. Could not read raster file " +
223 QModelIndex
const index = this->selectionModel()->currentIndex();
231 if (dlg.exec() != QDialog::Accepted)
236 auto result = std::make_unique<MeshLib::Mesh>(*mesh);
238 std::unique_ptr<GeoLib::Raster> raster{
242 OGSError::box(QString::fromStdString(
"Could not read raster file " +
262 QModelIndex
const index = this->selectionModel()->currentIndex();
266 connect(&meshLayerEdit, SIGNAL(mshEditFinished(
MeshLib::Mesh*)), model,
268 meshLayerEdit.exec();
274 QModelIndex
const index = this->selectionModel()->currentIndex();
278 connect(&valueEdit, SIGNAL(valueEditFinished(
MeshLib::Mesh*)), model,
285 QModelIndex
const index = this->selectionModel()->currentIndex();
286 if (!index.isValid())
299 if (dlg.exec() != QDialog::Accepted)
304 bool const copy_material_ids =
false;
322 QModelIndex
const index = this->selectionModel()->currentIndex();
323 if (!index.isValid())
331 if (dlg.exec() != QDialog::Accepted)
336 Eigen::Vector3d
const& dir(dlg.
getNormal());
338 std::unique_ptr<MeshLib::Mesh> sfc_mesh(
340 *mesh, dir, tolerance,
"Bulk Mesh Node IDs",
341 "Bulk Mesh Element IDs",
"Bulk Mesh Face IDs"));
349 " No surfaces found to extract\n using the specified parameters.");
355 QModelIndex
const index = this->selectionModel()->currentIndex();
363 QModelIndex
const index = this->selectionModel()->currentIndex();
364 if (!index.isValid())
369 QSettings
const settings;
371 settings.value(
"lastOpenedMeshFileDirectory").toString());
374 QString
const fileName = QFileDialog::getSaveFileName(
375 nullptr,
"Convert mesh to shapefile...",
377 QString::fromStdString(mesh->
getName()),
378 "ESRI Shapefile (*.shp)");
379 if (!fileName.isEmpty())
392 QModelIndex
const index = this->selectionModel()->currentIndex();
393 if (!index.isValid())
400 QSettings
const settings;
402 this,
"Write TetGen input file to",
403 settings.value(
"lastOpenedTetgenFileDirectory").toString(),
404 "TetGen Geometry (*.smesh)");
405 dialog.setDefaultSuffix(
"smesh");
408 QString
const filename = dialog.getSaveFileName();
409 if (!filename.isEmpty())
412 std::vector<MeshLib::Node> attr;
420 QModelIndex
const index = this->selectionModel()->currentIndex();
421 if (!index.isValid())
448 QModelIndex
const index = this->selectionModel()->currentIndex();
454 QModelIndex
const index = this->selectionModel()->currentIndex();
456 static_cast<MeshModel*
>(this->model())->getItem(index));
Definition of the AddLayerToMeshDialog class.
Definition of AddLayerToMesh class.
Definition of the AsciiRasterInterface class.
Definition of the ImportFileTypes enumeration.
Manages the last directory used for saving a file.
Definition of the MeshItem class.
Definition of the MeshLayerEditDialog class.
Definition of the MeshModel class.
Definition of the MeshValueEditDialog class.
Definition of the MeshView class.
Definition of the Mesh class.
Definition of the Node class.
Definition of the OGSError class.
Implementation of the SHPInterface class.
Definition of the SaveMeshDialog class.
Definition of the TetGenInterface class.
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.
OGSMesh getMesh(std::string const &name)