OGS
MeshView Class Reference

Detailed Description

The DataView is table view which acts as a base class for displaying several OGS data formats.

Definition at line 35 of file MeshView.h.

#include <MeshView.h>

Inheritance diagram for MeshView:
[legend]
Collaboration diagram for MeshView:
[legend]

Classes

struct  MeshAction
 

Public Slots

void updateView ()
 

Signals

void elementSelected (vtkUnstructuredGridAlgorithm const *const, unsigned, bool)
 
void enableSaveButton (bool)
 
void enableRemoveButton (bool)
 
void meshSelected (MeshLib::Mesh const &)
 
void openMeshFile (int)
 
void qualityCheckRequested (MeshLib::VtkMappedMeshSource *)
 
void removeSelectedMeshComponent ()
 
void requestCondSetupDialog (const std::string &, const GeoLib::GEOTYPE, const std::size_t, bool on_points)
 
void requestMeshRemoval (const QModelIndex &)
 
void requestMeshToGeometryConversion (const MeshLib::Mesh *)
 
void loadFEMCondFileRequested (const std::string)
 
void saveMeshAction ()
 

Public Member Functions

 MeshView (QWidget *parent=nullptr)
 
 ~MeshView () override
 

Protected Slots

void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override
 Is called when the selection of this view changes.
 

Private Slots

void openMap2dMeshDialog ()
 Opens a dialog for mapping 2d meshes.
 
void openRasterDataToMeshDialog ()
 Opens a dialog for assigning raster data to the mesh.
 
void openMeshEditDialog ()
 Opens a dialog for editing meshes.
 
void openValuesEditDialog ()
 Opens a dialog for editing material groups.
 
void openAddLayerDialog ()
 Opens a dialog for adding a layer to the mesh.
 
void addMesh ()
 Adds a new mesh.
 
void addDIRECTSourceTerms ()
 
void extractSurfaceMesh ()
 
void exportToTetGen ()
 
void loadDIRECTSourceTerms ()
 
void convertMeshToGeometry ()
 
void exportToShapefile () const
 
void removeMesh ()
 Remove the currently selected mesh.
 
void writeToFile () const
 Calls the FileDialog to save a mesh to a file.
 
void checkMeshQuality ()
 Calls the dialog for calculating an element quality metric.
 

Private Member Functions

void contextMenuEvent (QContextMenuEvent *event) override
 

Constructor & Destructor Documentation

◆ MeshView()

MeshView::MeshView ( QWidget * parent = nullptr)
explicit

Definition at line 46 of file MeshView.cpp.

46 : QTreeView(parent)
47{
48 setUniformRowHeights(true);
49 // resizeColumnsToContents();
50 // resizeRowsToContents();
51}

◆ ~MeshView()

MeshView::~MeshView ( )
overridedefault

Member Function Documentation

◆ addDIRECTSourceTerms

void MeshView::addDIRECTSourceTerms ( )
privateslot

Definition at line 439 of file MeshView.cpp.

440{
441 // QModelIndex const index = this->selectionModel()->currentIndex();
442 // MeshLib::Mesh const*const grid =
443 // static_cast<MeshModel*>(this->model())->getMesh(index);
444}

◆ addMesh

void MeshView::addMesh ( )
privateslot

◆ checkMeshQuality

void MeshView::checkMeshQuality ( )
privateslot

Calls the dialog for calculating an element quality metric.

Definition at line 452 of file MeshView.cpp.

453{
454 QModelIndex const index = this->selectionModel()->currentIndex();
455 MeshItem const* const item = static_cast<MeshItem*>(
456 static_cast<MeshModel*>(this->model())->getItem(index));
457 emit qualityCheckRequested(item->vtkSource());
458}
A TreeItem containing a mesh and the associated vtk object used in the Mesh Model.
Definition MeshItem.h:30
MeshLib::VtkMappedMeshSource * vtkSource() const
Returns the VTK object.
Definition MeshItem.h:44
void qualityCheckRequested(MeshLib::VtkMappedMeshSource *)
TreeItem * getItem(const QModelIndex &index) const

References TreeModel::getItem(), qualityCheckRequested(), and MeshItem::vtkSource().

Referenced by contextMenuEvent().

◆ contextMenuEvent()

void MeshView::contextMenuEvent ( QContextMenuEvent * event)
overrideprivate

Definition at line 117 of file MeshView.cpp.

118{
119 QModelIndex const& index = this->selectionModel()->currentIndex();
120 MeshItem const* const item = dynamic_cast<MeshItem*>(
121 static_cast<TreeItem*>(index.internalPointer()));
122
123 if (item == nullptr)
124 {
125 return;
126 }
127
128 unsigned const mesh_dim(item->getMesh()->getDimension());
129
130 std::vector<MeshAction> actions;
131 actions.push_back({new QAction("Map mesh...", this), 1, 2});
132 connect(actions.back().action, SIGNAL(triggered()), this,
133 SLOT(openMap2dMeshDialog()));
134 actions.push_back(
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,
140 SLOT(openMeshEditDialog()));
141 actions.push_back({new QAction("Add layer...", this), 1, 3});
142 connect(actions.back().action, SIGNAL(triggered()), this,
143 SLOT(openAddLayerDialog()));
144 actions.push_back({new QAction("Edit material groups...", this), 1, 3});
145 connect(actions.back().action, SIGNAL(triggered()), this,
146 SLOT(openValuesEditDialog()));
147 actions.push_back({new QAction("Extract surface...", this), 3, 3});
148 connect(actions.back().action, SIGNAL(triggered()), this,
149 SLOT(extractSurfaceMesh()));
150 actions.push_back(
151 {new QAction("Calculate element quality...", this), 2, 3});
152 connect(actions.back().action, SIGNAL(triggered()), this,
153 SLOT(checkMeshQuality()));
154 actions.push_back({new QAction("Convert to geometry", this), 1, 2});
155 connect(actions.back().action, SIGNAL(triggered()), this,
156 SLOT(convertMeshToGeometry()));
157 actions.push_back({new QAction("Export to Shapefile...", this), 2, 2});
158 connect(actions.back().action, SIGNAL(triggered()), this,
159 SLOT(exportToShapefile()));
160 actions.push_back({new QAction("Export to TetGen...", this), 3, 3});
161 connect(actions.back().action, SIGNAL(triggered()), this,
162 SLOT(exportToTetGen()));
163
164 QMenu menu(this);
165 for (MeshAction a : actions)
166 {
167 if (mesh_dim >= a.min_dim && mesh_dim <= a.max_dim)
168 {
169 menu.addAction(a.action);
170 }
171 }
172 menu.exec(event->globalPos());
173}
MeshLib::Mesh const * getMesh() const
Returns the mesh.
Definition MeshItem.h:42
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
void checkMeshQuality()
Calls the dialog for calculating an element quality metric.
Definition MeshView.cpp:452
void extractSurfaceMesh()
Definition MeshView.cpp:320
void openValuesEditDialog()
Opens a dialog for editing material groups.
Definition MeshView.cpp:271
void openMap2dMeshDialog()
Opens a dialog for mapping 2d meshes.
Definition MeshView.cpp:175
void openMeshEditDialog()
Opens a dialog for editing meshes.
Definition MeshView.cpp:259
void exportToTetGen()
Definition MeshView.cpp:390
void openRasterDataToMeshDialog()
Opens a dialog for assigning raster data to the mesh.
Definition MeshView.cpp:220
void convertMeshToGeometry()
Definition MeshView.cpp:353
void openAddLayerDialog()
Opens a dialog for adding a layer to the mesh.
Definition MeshView.cpp:283
void exportToShapefile() const
Definition MeshView.cpp:361
Objects nodes for the TreeModel.
Definition TreeItem.h:28

References checkMeshQuality(), convertMeshToGeometry(), exportToShapefile(), exportToTetGen(), extractSurfaceMesh(), MeshLib::Mesh::getDimension(), MeshItem::getMesh(), openAddLayerDialog(), openMap2dMeshDialog(), openMeshEditDialog(), openRasterDataToMeshDialog(), and openValuesEditDialog().

◆ convertMeshToGeometry

void MeshView::convertMeshToGeometry ( )
privateslot

Definition at line 353 of file MeshView.cpp.

354{
355 QModelIndex const index = this->selectionModel()->currentIndex();
356 MeshLib::Mesh const* const mesh =
357 static_cast<MeshModel*>(this->model())->getMesh(index);
359}
void requestMeshToGeometryConversion(const MeshLib::Mesh *)
OGSMesh getMesh(std::string const &name)

References getMesh(), and requestMeshToGeometryConversion().

Referenced by contextMenuEvent().

◆ elementSelected

void MeshView::elementSelected ( vtkUnstructuredGridAlgorithm const * const ,
unsigned ,
bool  )
signal

Referenced by selectionChanged().

◆ enableRemoveButton

void MeshView::enableRemoveButton ( bool )
signal

Referenced by removeMesh(), and selectionChanged().

◆ enableSaveButton

void MeshView::enableSaveButton ( bool )
signal

Referenced by removeMesh(), and selectionChanged().

◆ exportToShapefile

void MeshView::exportToShapefile ( ) const
privateslot

Definition at line 361 of file MeshView.cpp.

362{
363 QModelIndex const index = this->selectionModel()->currentIndex();
364 if (!index.isValid())
365 {
366 return;
367 }
368
369 QSettings const settings;
370 QFileInfo const fi(
371 settings.value("lastOpenedMeshFileDirectory").toString());
372 MeshLib::Mesh const* const mesh =
373 static_cast<MeshModel*>(this->model())->getMesh(index);
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())
380 {
382 if (!FileIO::SHPInterface::write2dMeshToSHP(fileName.toStdString(),
383 *mesh))
384 {
385 OGSError::box("Error exporting mesh\n to shapefile");
386 }
387 }
388}
static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh)
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.
const std::string getName() const
Get name of the mesh.
Definition Mesh.h:103
static void box(const QString &e)
Definition OGSError.cpp:23

References OGSError::box(), LastSavedFileDirectory::getDir(), getMesh(), MeshLib::Mesh::getName(), LastSavedFileDirectory::setDir(), and FileIO::SHPInterface::write2dMeshToSHP().

Referenced by contextMenuEvent().

◆ exportToTetGen

void MeshView::exportToTetGen ( )
privateslot

Definition at line 390 of file MeshView.cpp.

391{
392 QModelIndex const index = this->selectionModel()->currentIndex();
393 if (!index.isValid())
394 {
395 return;
396 }
397
398 MeshLib::Mesh const* const mesh =
399 static_cast<MeshModel*>(this->model())->getMesh(index);
400 QSettings const settings;
401 QFileDialog dialog(
402 this, "Write TetGen input file to",
403 settings.value("lastOpenedTetgenFileDirectory").toString(),
404 "TetGen Geometry (*.smesh)");
405 dialog.setDefaultSuffix("smesh");
406 if (dialog.exec())
407 {
408 QString const filename = dialog.getSaveFileName();
409 if (!filename.isEmpty())
410 {
412 std::vector<MeshLib::Node> attr;
413 tg.writeTetGenSmesh(filename.toStdString(), *mesh, attr);
414 }
415 }
416}
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)

References getMesh(), and FileIO::TetGenInterface::writeTetGenSmesh().

Referenced by contextMenuEvent().

◆ extractSurfaceMesh

void MeshView::extractSurfaceMesh ( )
privateslot

Definition at line 320 of file MeshView.cpp.

321{
322 QModelIndex const index = this->selectionModel()->currentIndex();
323 if (!index.isValid())
324 {
325 return;
326 }
327
328 MeshLib::Mesh const* const mesh =
329 static_cast<MeshModel*>(this->model())->getMesh(index);
331 if (dlg.exec() != QDialog::Accepted)
332 {
333 return;
334 }
335
336 Eigen::Vector3d const& dir(dlg.getNormal());
337 int const tolerance(dlg.getTolerance());
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"));
342 if (sfc_mesh)
343 {
344 static_cast<MeshModel*>(model())->addMesh(std::move(sfc_mesh));
345 }
346 else
347 {
349 " No surfaces found to extract\n using the specified parameters.");
350 }
351}
static MeshLib::Mesh * getMeshSurface(const MeshLib::Mesh &subsfc_mesh, Eigen::Vector3d const &dir, double angle, std::string_view subsfc_node_id_prop_name="", std::string_view subsfc_element_id_prop_name="", std::string_view face_id_prop_name="")
void addMesh()
Adds a new mesh.
Definition MeshView.cpp:97
A dialog window for managing properties for writing meshes to files.
Eigen::Vector3d const & getNormal() const

References addMesh(), OGSError::box(), getMesh(), MeshToolsLib::MeshSurfaceExtraction::getMeshSurface(), SurfaceExtractionDialog::getNormal(), and SurfaceExtractionDialog::getTolerance().

Referenced by contextMenuEvent().

◆ loadDIRECTSourceTerms

void MeshView::loadDIRECTSourceTerms ( )
privateslot

Definition at line 446 of file MeshView.cpp.

447{
448 QModelIndex const index = this->selectionModel()->currentIndex();
449 emit loadFEMCondFileRequested(index.data(0).toString().toStdString());
450}
void loadFEMCondFileRequested(const std::string)

References loadFEMCondFileRequested().

◆ loadFEMCondFileRequested

void MeshView::loadFEMCondFileRequested ( const std::string )
signal

Referenced by loadDIRECTSourceTerms().

◆ meshSelected

void MeshView::meshSelected ( MeshLib::Mesh const & )
signal

Referenced by selectionChanged().

◆ openAddLayerDialog

void MeshView::openAddLayerDialog ( )
privateslot

Opens a dialog for adding a layer to the mesh.

Definition at line 283 of file MeshView.cpp.

284{
285 QModelIndex const index = this->selectionModel()->currentIndex();
286 if (!index.isValid())
287 {
288 return;
289 }
290
291 MeshLib::Mesh const* const mesh =
292 static_cast<MeshModel*>(this->model())->getMesh(index);
293 if (mesh == nullptr)
294 {
295 return;
296 }
297
299 if (dlg.exec() != QDialog::Accepted)
300 {
301 return;
302 }
303
304 bool const copy_material_ids = false;
305 double const thickness(dlg.getThickness());
306 std::unique_ptr<MeshLib::Mesh> result(MeshToolsLib::addLayerToMesh(
307 *mesh, thickness, dlg.getName(), dlg.isTopLayer(), copy_material_ids,
308 std::nullopt));
309
310 if (result)
311 {
312 static_cast<MeshModel*>(model())->addMesh(std::move(result));
313 }
314 else
315 {
316 OGSError::box("Error adding layer to mesh.");
317 }
318}
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.
MeshLib::Mesh * addLayerToMesh(MeshLib::Mesh const &mesh, double const thickness, std::string const &name, bool const on_top, bool const copy_material_ids, std::optional< int > const layer_id)

References MeshToolsLib::addLayerToMesh(), addMesh(), OGSError::box(), getMesh(), AddLayerToMeshDialog::getName(), AddLayerToMeshDialog::getThickness(), and AddLayerToMeshDialog::isTopLayer().

Referenced by contextMenuEvent().

◆ openMap2dMeshDialog

void MeshView::openMap2dMeshDialog ( )
privateslot

Opens a dialog for mapping 2d meshes.

Definition at line 175 of file MeshView.cpp.

176{
177 MeshModel const* const model = static_cast<MeshModel*>(this->model());
178 QModelIndex const index = this->selectionModel()->currentIndex();
179 MeshLib::Mesh const* const mesh = model->getMesh(index);
180 if (mesh == nullptr)
181 {
182 return;
183 }
184
186 if (dlg.exec() != QDialog::Accepted)
187 {
188 return;
189 }
190
191 auto result = std::make_unique<MeshLib::Mesh>(*mesh);
192 result->setName(dlg.getNewMeshName());
193 if (dlg.useRasterMapping())
194 {
195 std::unique_ptr<GeoLib::Raster> raster{
197 if (!raster)
198 {
199 OGSError::box(QString::fromStdString(
200 "Error mapping mesh. Could not read raster file " +
201 dlg.getRasterPath()));
202 return;
203 }
205 *result, *raster, dlg.getNoDataReplacement(),
206 dlg.getIgnoreNoData()))
207 {
208 OGSError::box("Error mapping mesh.");
209 return;
210 }
211 }
212 else
213 {
215 dlg.getStaticValue());
216 }
217 static_cast<MeshModel*>(this->model())->addMesh(std::move(result));
218}
static GeoLib::Raster * readRaster(std::string const &fname)
A dialog window for mapping a 2d mesh based on a raster file.
std::string getNewMeshName() 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.
Definition MeshModel.cpp:96
static bool layerMapping(MeshLib::Mesh const &mesh, const GeoLib::Raster &raster, double nodata_replacement=0.0, bool const ignore_nodata=false)
static bool mapToStaticValue(MeshLib::Mesh const &mesh, double value)
Maps the elevation of all mesh nodes to the specified static value.

References addMesh(), OGSError::box(), MeshMapping2DDialog::getIgnoreNoData(), MeshModel::getMesh(), MeshMapping2DDialog::getNewMeshName(), MeshMapping2DDialog::getNoDataReplacement(), MeshMapping2DDialog::getRasterPath(), MeshMapping2DDialog::getStaticValue(), MeshToolsLib::MeshLayerMapper::layerMapping(), MeshToolsLib::MeshLayerMapper::mapToStaticValue(), FileIO::AsciiRasterInterface::readRaster(), and MeshMapping2DDialog::useRasterMapping().

Referenced by contextMenuEvent().

◆ openMeshEditDialog

void MeshView::openMeshEditDialog ( )
privateslot

Opens a dialog for editing meshes.

Definition at line 259 of file MeshView.cpp.

260{
261 MeshModel const* const model = static_cast<MeshModel*>(this->model());
262 QModelIndex const index = this->selectionModel()->currentIndex();
263 MeshLib::Mesh const* const mesh = model->getMesh(index);
264
265 MeshLayerEditDialog meshLayerEdit(mesh);
266 connect(&meshLayerEdit, SIGNAL(mshEditFinished(MeshLib::Mesh*)), model,
267 SLOT(addMesh(MeshLib::Mesh*)));
268 meshLayerEdit.exec();
269}
A dialog window for editing meshes in various ways.

References addMesh(), and MeshModel::getMesh().

Referenced by contextMenuEvent().

◆ openMeshFile

void MeshView::openMeshFile ( int )
signal

Referenced by addMesh().

◆ openRasterDataToMeshDialog

void MeshView::openRasterDataToMeshDialog ( )
privateslot

Opens a dialog for assigning raster data to the mesh.

Definition at line 220 of file MeshView.cpp.

221{
222 MeshModel const* const model = static_cast<MeshModel*>(this->model());
223 QModelIndex const index = this->selectionModel()->currentIndex();
224 MeshLib::Mesh const* mesh = model->getMesh(index);
225 if (mesh == nullptr)
226 {
227 return;
228 }
229
230 RasterDataToMeshDialog dlg(mesh->getName());
231 if (dlg.exec() != QDialog::Accepted)
232 {
233 return;
234 }
235
236 auto result = std::make_unique<MeshLib::Mesh>(*mesh);
237 result->setName(dlg.getMeshName());
238 std::unique_ptr<GeoLib::Raster> raster{
239 FileIO::AsciiRasterInterface::readRaster(dlg.getRasterPath())};
240 if (!raster)
241 {
242 OGSError::box(QString::fromStdString("Could not read raster file " +
243 dlg.getRasterPath()));
244 return;
245 }
246 if (dlg.createNodeArray())
247 {
249 *result, *raster, dlg.getNoDataReplacement(), dlg.getArrayName());
250 }
251 else
252 {
254 *result, *raster, dlg.getNoDataReplacement(), dlg.getArrayName());
255 }
256 static_cast<MeshModel*>(this->model())->addMesh(std::move(result));
257}
A dialog window for transferring raster data onto a mesh.
bool projectToNodes(MeshLib::Mesh &mesh, GeoLib::Raster const &raster, double const default_replacement, std::string const &array_name)
bool projectToElements(MeshLib::Mesh &mesh, GeoLib::Raster const &raster, double const default_replacement, std::string const &array_name)

References addMesh(), OGSError::box(), RasterDataToMeshDialog::createNodeArray(), RasterDataToMeshDialog::getArrayName(), MeshModel::getMesh(), RasterDataToMeshDialog::getMeshName(), MeshLib::Mesh::getName(), RasterDataToMeshDialog::getNoDataReplacement(), RasterDataToMeshDialog::getRasterPath(), MeshToolsLib::RasterDataToMesh::projectToElements(), MeshToolsLib::RasterDataToMesh::projectToNodes(), and FileIO::AsciiRasterInterface::readRaster().

Referenced by contextMenuEvent().

◆ openValuesEditDialog

void MeshView::openValuesEditDialog ( )
privateslot

Opens a dialog for editing material groups.

Definition at line 271 of file MeshView.cpp.

272{
273 MeshModel const* const model = static_cast<MeshModel*>(this->model());
274 QModelIndex const index = this->selectionModel()->currentIndex();
275 auto* mesh = const_cast<MeshLib::Mesh*>(model->getMesh(index));
276
277 MeshValueEditDialog valueEdit(mesh);
278 connect(&valueEdit, SIGNAL(valueEditFinished(MeshLib::Mesh*)), model,
279 SLOT(updateMesh(MeshLib::Mesh*)));
280 valueEdit.exec();
281}
A dialog window for changing the MaterialID for mesh elements.

References MeshModel::getMesh().

Referenced by contextMenuEvent().

◆ qualityCheckRequested

void MeshView::qualityCheckRequested ( MeshLib::VtkMappedMeshSource * )
signal

Referenced by checkMeshQuality().

◆ removeMesh

void MeshView::removeMesh ( )
privateslot

Remove the currently selected mesh.

Definition at line 102 of file MeshView.cpp.

103{
104 QModelIndex index(this->selectionModel()->currentIndex());
105 if (!index.isValid())
106 {
107 OGSError::box("No mesh selected.");
108 }
109 else
110 {
111 emit requestMeshRemoval(index);
112 emit enableSaveButton(false);
113 emit enableRemoveButton(false);
114 }
115}
void enableSaveButton(bool)
void requestMeshRemoval(const QModelIndex &)
void enableRemoveButton(bool)

References OGSError::box(), enableRemoveButton(), enableSaveButton(), and requestMeshRemoval().

◆ removeSelectedMeshComponent

void MeshView::removeSelectedMeshComponent ( )
signal

Referenced by selectionChanged().

◆ requestCondSetupDialog

void MeshView::requestCondSetupDialog ( const std::string & ,
const GeoLib::GEOTYPE ,
const std::size_t ,
bool on_points )
signal

◆ requestMeshRemoval

void MeshView::requestMeshRemoval ( const QModelIndex & )
signal

Referenced by removeMesh().

◆ requestMeshToGeometryConversion

void MeshView::requestMeshToGeometryConversion ( const MeshLib::Mesh * )
signal

Referenced by convertMeshToGeometry().

◆ saveMeshAction

void MeshView::saveMeshAction ( )
signal

◆ selectionChanged

void MeshView::selectionChanged ( const QItemSelection & selected,
const QItemSelection & deselected )
overrideprotectedslot

Is called when the selection of this view changes.

Definition at line 67 of file MeshView.cpp.

69{
70 Q_UNUSED(deselected);
71 if (!selected.isEmpty())
72 {
74 const QModelIndex idx = *(selected.indexes().begin());
75 const TreeItem* tree_item =
76 static_cast<TreeModel*>(this->model())->getItem(idx);
77
78 const auto* list_item = dynamic_cast<const MeshItem*>(tree_item);
79 if (list_item)
80 {
81 emit enableSaveButton(true);
82 emit enableRemoveButton(true);
83 emit meshSelected(*list_item->getMesh());
84 }
85 else
86 {
87 emit enableSaveButton(false);
88 emit enableRemoveButton(false);
89 emit elementSelected(
90 dynamic_cast<const MeshItem*>(tree_item->parentItem())
91 ->vtkSource(),
92 static_cast<unsigned>(tree_item->row()), true);
93 }
94 }
95}
void meshSelected(MeshLib::Mesh const &)
void removeSelectedMeshComponent()
void elementSelected(vtkUnstructuredGridAlgorithm const *const, unsigned, bool)
TreeItem * parentItem() const
Definition TreeItem.cpp:115
int row() const
Definition TreeItem.cpp:73
A hierarchical model for a tree implemented as a double-linked list.
Definition TreeModel.h:30

References elementSelected(), enableRemoveButton(), enableSaveButton(), meshSelected(), TreeItem::parentItem(), removeSelectedMeshComponent(), TreeItem::row(), and MeshItem::vtkSource().

◆ updateView

void MeshView::updateView ( )
slot

Definition at line 55 of file MeshView.cpp.

56{
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++)
62 {
63 resizeColumnToContents(i);
64 }
65}

◆ writeToFile

void MeshView::writeToFile ( ) const
privateslot

Calls the FileDialog to save a mesh to a file.

Definition at line 418 of file MeshView.cpp.

419{
420 QModelIndex const index = this->selectionModel()->currentIndex();
421 if (!index.isValid())
422 {
423 OGSError::box("No mesh selected.");
424 return;
425 }
426
427 MeshLib::Mesh const* const mesh =
428 static_cast<MeshModel*>(this->model())->getMesh(index);
429 if (mesh == nullptr)
430 {
431 OGSError::box("No mesh selected.");
432 return;
433 }
434
435 SaveMeshDialog dlg(*mesh);
436 dlg.exec();
437}
A dialog window for managing properties for writing meshes to files.

References OGSError::box(), and getMesh().


The documentation for this class was generated from the following files: