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. More...
 

Private Slots

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

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 433 of file MeshView.cpp.

434 {
435  // QModelIndex const index = this->selectionModel()->currentIndex();
436  // MeshLib::Mesh const*const grid =
437  // static_cast<MeshModel*>(this->model())->getMesh(index);
438 }

◆ addMesh

void MeshView::addMesh ( )
privateslot

◆ checkMeshQuality

void MeshView::checkMeshQuality ( )
privateslot

Calls the dialog for calculating an element quality metric.

Definition at line 446 of file MeshView.cpp.

447 {
448  QModelIndex const index = this->selectionModel()->currentIndex();
449  MeshItem const* const item = static_cast<MeshItem*>(
450  static_cast<MeshModel*>(this->model())->getItem(index));
451  emit qualityCheckRequested(item->vtkSource());
452 }
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 *)

References 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("Edit mesh...", 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:71
void checkMeshQuality()
Calls the dialog for calculating an element quality metric.
Definition: MeshView.cpp:446
void extractSurfaceMesh()
Definition: MeshView.cpp:319
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:389
void openRasterDataToMeshDialog()
Opens a dialog for assigning raster data to the mesh.
Definition: MeshView.cpp:220
void convertMeshToGeometry()
Definition: MeshView.cpp:352
void openAddLayerDialog()
Opens a dialog for adding a layer to the mesh.
Definition: MeshView.cpp:283
void exportToShapefile() const
Definition: MeshView.cpp:360
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 352 of file MeshView.cpp.

353 {
354  QModelIndex const index = this->selectionModel()->currentIndex();
355  MeshLib::Mesh const* const mesh =
356  static_cast<MeshModel*>(this->model())->getMesh(index);
358 }
void requestMeshToGeometryConversion(const MeshLib::Mesh *)

References 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 360 of file MeshView.cpp.

361 {
362  QModelIndex const index = this->selectionModel()->currentIndex();
363  if (!index.isValid())
364  {
365  return;
366  }
367 
368  QSettings const settings;
369  QFileInfo const fi(
370  settings.value("lastOpenedMeshFileDirectory").toString());
371  MeshLib::Mesh const* const mesh =
372  static_cast<MeshModel*>(this->model())->getMesh(index);
373  QString const fileName = QFileDialog::getSaveFileName(
374  nullptr, "Convert mesh to shapefile...",
376  QString::fromStdString(mesh->getName()),
377  "ESRI Shapefile (*.shp)");
378  if (!fileName.isEmpty())
379  {
381  if (!FileIO::SHPInterface::write2dMeshToSHP(fileName.toStdString(),
382  *mesh))
383  {
384  OGSError::box("Error exporting mesh\n to shapefile");
385  }
386  }
387 }
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:92
static void box(const QString &e)
Definition: OGSError.cpp:23

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

Referenced by contextMenuEvent().

◆ exportToTetGen

void MeshView::exportToTetGen ( )
privateslot

Definition at line 389 of file MeshView.cpp.

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

Referenced by contextMenuEvent().

◆ extractSurfaceMesh

void MeshView::extractSurfaceMesh ( )
privateslot

Definition at line 319 of file MeshView.cpp.

320 {
321  QModelIndex const index = this->selectionModel()->currentIndex();
322  if (!index.isValid())
323  {
324  return;
325  }
326 
327  MeshLib::Mesh const* const mesh =
328  static_cast<MeshModel*>(this->model())->getMesh(index);
330  if (dlg.exec() != QDialog::Accepted)
331  {
332  return;
333  }
334 
335  Eigen::Vector3d const& dir(dlg.getNormal());
336  int const tolerance(dlg.getTolerance());
337  std::unique_ptr<MeshLib::Mesh> sfc_mesh(
339  *mesh, dir, tolerance, "Bulk Mesh Node IDs",
340  "Bulk Mesh Element IDs", "Bulk Mesh Face IDs"));
341  if (sfc_mesh)
342  {
343  static_cast<MeshModel*>(model())->addMesh(std::move(sfc_mesh));
344  }
345  else
346  {
348  " No surfaces found to extract\n using the specified parameters.");
349  }
350 }
static MeshLib::Mesh * getMeshSurface(const MeshLib::Mesh &subsfc_mesh, Eigen::Vector3d const &dir, double angle, std::string const &subsfc_node_id_prop_name="", std::string const &subsfc_element_id_prop_name="", std::string const &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
static double const tolerance

References addMesh(), OGSError::box(), MeshLib::MeshSurfaceExtraction::getMeshSurface(), SurfaceExtractionDialog::getNormal(), SurfaceExtractionDialog::getTolerance(), and ParameterLib::tolerance.

Referenced by contextMenuEvent().

◆ loadDIRECTSourceTerms

void MeshView::loadDIRECTSourceTerms ( )
privateslot

Definition at line 440 of file MeshView.cpp.

441 {
442  QModelIndex const index = this->selectionModel()->currentIndex();
443  emit loadFEMCondFileRequested(index.data(0).toString().toStdString());
444 }
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(MeshLib::addLayerToMesh(
307  *mesh, thickness, dlg.getName(), dlg.isTopLayer(), copy_material_ids));
308 
309  if (result)
310  {
311  static_cast<MeshModel*>(model())->addMesh(std::move(result));
312  }
313  else
314  {
315  OGSError::box("Error adding layer to mesh.");
316  }
317 }
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 thickness, std::string const &name, bool on_top, bool copy_material_ids)

References MeshLib::addLayerToMesh(), addMesh(), OGSError::box(), 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  }
204  if (!MeshLib::MeshLayerMapper::layerMapping(*result, *raster,
205  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)
Reads raster file by detecting type based on extension and then calling the appropriate method.
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.
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.
Definition: MeshModel.cpp:96

References addMesh(), OGSError::box(), MeshMapping2DDialog::getIgnoreNoData(), MeshModel::getMesh(), MeshMapping2DDialog::getNewMeshName(), MeshMapping2DDialog::getNoDataReplacement(), MeshMapping2DDialog::getRasterPath(), MeshMapping2DDialog::getStaticValue(), MeshLib::MeshLayerMapper::layerMapping(), MeshLib::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 projectToElements(MeshLib::Mesh &mesh, GeoLib::Raster const &raster, double const default_replacement, std::string const &array_name)
bool projectToNodes(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(), MeshLib::RasterDataToMesh::projectToElements(), MeshLib::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 412 of file MeshView.cpp.

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

References OGSError::box().


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