OGS
GMSHPrefsDialog Class Reference

Detailed Description

A dialog window for setting preferences for GMSH.

Definition at line 30 of file GMSHPrefsDialog.h.

#include <GMSHPrefsDialog.h>

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

Signals

void requestMeshing (std::vector< std::string > &, unsigned, double, double, double, bool)
 

Public Member Functions

 GMSHPrefsDialog (GeoLib::GEOObjects const &geoObjects, QDialog *parent=nullptr)
 
 ~GMSHPrefsDialog () override
 

Private Slots

void on_selectGeoButton_pressed ()
 
void on_deselectGeoButton_pressed ()
 
void on_radioAdaptive_toggled (bool isTrue)
 
void accept () override
 Instructions if the OK-Button has been pressed. More...
 
void reject () override
 Instructions if the Cancel-Button has been pressed. More...
 

Private Member Functions

std::vector< std::string > getSelectedObjects (QStringList list)
 

Private Attributes

QStringListModel * _allGeo
 
QStringListModel * _selGeo
 

Constructor & Destructor Documentation

◆ GMSHPrefsDialog()

GMSHPrefsDialog::GMSHPrefsDialog ( GeoLib::GEOObjects const &  geoObjects,
QDialog *  parent = nullptr 
)
explicit

Definition at line 28 of file GMSHPrefsDialog.cpp.

30  : QDialog(parent),
31  _allGeo(new QStringListModel),
32  _selGeo(new QStringListModel)
33 {
34  setupUi(this);
35 
36  // default parameters
37  this->param1->setText("2");
38  this->param2->setText("0.3");
39  this->param3->setText("0.05");
40  this->param4->setText("0");
41 
42  // object will be deleted by Qt
43  auto* max_number_of_points_in_quadtree_leaf_validator(
44  new StrictIntValidator(1, 1000, this->param1));
45  param1->setValidator(max_number_of_points_in_quadtree_leaf_validator);
46  // object will be deleted by Qt
47  auto* mesh_density_scaling_pnts_validator(
48  new StrictDoubleValidator(0, 1, 5, this->param2));
49  param2->setValidator(mesh_density_scaling_pnts_validator);
50  // object will be deleted by Qt#
51  auto* mesh_density_scaling_stations_validator(
52  new StrictDoubleValidator(0, 1, 5, this->param3));
53  param3->setValidator(mesh_density_scaling_stations_validator);
54 
55  auto geoNames = geoObjects.getGeometryNames();
56 
57  // get station names
58  std::vector<std::string> geo_station_names;
59  geoObjects.getStationVectorNames(geo_station_names);
60 
61  std::copy(geo_station_names.begin(), geo_station_names.end(),
62  std::back_inserter(geoNames));
63 
64  std::size_t nGeoObjects(geoNames.size());
65 
66  QStringList list;
67  for (unsigned i = 0; i < nGeoObjects; ++i)
68  {
69  list.append(QString::fromStdString(geoNames[i]));
70  }
71 
72  if (list.empty())
73  {
74  this->selectGeoButton->setDisabled(true);
75  this->deselectGeoButton->setDisabled(true);
76  list.append("[No geometry available.]");
77  }
78  _allGeo->setStringList(list);
79  this->allGeoView->setModel(_allGeo);
80  this->selectedGeoView->setModel(_selGeo);
81  this->radioAdaptive->toggle(); // default is adaptive meshing
82  this->on_radioAdaptive_toggled(true);
83 }
void on_radioAdaptive_toggled(bool isTrue)
QStringListModel * _selGeo
QStringListModel * _allGeo
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow
A validator for an input field which only accepts integers. Source code adapted from Qt developer faq...
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37

References _allGeo, _selGeo, MathLib::LinAlg::copy(), GeoLib::GEOObjects::getGeometryNames(), GeoLib::GEOObjects::getStationVectorNames(), and on_radioAdaptive_toggled().

◆ ~GMSHPrefsDialog()

GMSHPrefsDialog::~GMSHPrefsDialog ( )
override

Definition at line 85 of file GMSHPrefsDialog.cpp.

86 {
87  delete _allGeo;
88  delete _selGeo;
89 }

References _allGeo, and _selGeo.

Member Function Documentation

◆ accept

void GMSHPrefsDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 139 of file GMSHPrefsDialog.cpp.

140 {
141  if (this->_selGeo->stringList().empty())
142  {
144  "No geometry selected. Geometric data\n is necessary for mesh "
145  "generation.");
146  return;
147  }
148 
149  std::vector<std::string> selectedObjects =
150  this->getSelectedObjects(_selGeo->stringList());
151  unsigned max_number_of_points_in_quadtree_leaf(10);
152  double mesh_density_scaling_pnts(0.5);
153  double mesh_density_scaling_stations(0.05);
154  double val4(-1);
155 
156  if (this->radioAdaptive->isChecked())
157  {
158  double const min_scaling_factor(1e-10);
159  max_number_of_points_in_quadtree_leaf =
160  BaseLib::str2number<unsigned>(param1->text().toStdString());
161  if (max_number_of_points_in_quadtree_leaf == 0)
162  {
163  max_number_of_points_in_quadtree_leaf = 10;
164  }
165  mesh_density_scaling_pnts = fabs(param2->text().toDouble());
166  if (mesh_density_scaling_pnts < min_scaling_factor)
167  {
168  mesh_density_scaling_pnts = min_scaling_factor;
169  }
170  mesh_density_scaling_stations = param3->text().toDouble();
171  if (mesh_density_scaling_stations < min_scaling_factor)
172  {
173  mesh_density_scaling_stations = min_scaling_factor;
174  }
175  }
176  else
177  {
178  val4 = param4->text().toDouble();
179  }
180 
181  bool delete_geo_file = this->geoFileDelete->isChecked();
182  emit requestMeshing(selectedObjects,
183  max_number_of_points_in_quadtree_leaf,
184  mesh_density_scaling_pnts,
185  mesh_density_scaling_stations,
186  val4,
187  delete_geo_file);
188  this->done(QDialog::Accepted);
189 }
std::vector< std::string > getSelectedObjects(QStringList list)
void requestMeshing(std::vector< std::string > &, unsigned, double, double, double, bool)
static void box(const QString &e)
Definition: OGSError.cpp:23

References _selGeo, OGSError::box(), getSelectedObjects(), and requestMeshing().

◆ getSelectedObjects()

std::vector< std::string > GMSHPrefsDialog::getSelectedObjects ( QStringList  list)
private

Definition at line 196 of file GMSHPrefsDialog.cpp.

197 {
198  std::vector<std::string> indexList;
199  std::transform(list.begin(), list.end(), std::back_inserter(indexList),
200  [](auto const& index) { return index.toStdString(); });
201  return indexList;
202 }

Referenced by accept().

◆ on_deselectGeoButton_pressed

void GMSHPrefsDialog::on_deselectGeoButton_pressed ( )
privateslot

Definition at line 106 of file GMSHPrefsDialog.cpp.

107 {
108  QModelIndexList selected =
109  this->selectedGeoView->selectionModel()->selectedIndexes();
110  QStringList list = _allGeo->stringList();
111 
112  for (auto& index : selected)
113  {
114  list.append(index.data().toString());
115 
116  _selGeo->removeRow(index.row());
117  }
118  _allGeo->setStringList(list);
119 }

References _allGeo, and _selGeo.

◆ on_radioAdaptive_toggled

void GMSHPrefsDialog::on_radioAdaptive_toggled ( bool  isTrue)
privateslot

Definition at line 121 of file GMSHPrefsDialog.cpp.

122 {
123  if (isTrue) // meshing set to adaptive
124  {
125  this->param1->setEnabled(true);
126  this->param2->setEnabled(true);
127  this->param3->setEnabled(true);
128  this->param4->setEnabled(false);
129  }
130  else // meshing set to homogeneous
131  {
132  this->param1->setEnabled(false);
133  this->param2->setEnabled(false);
134  this->param3->setEnabled(false);
135  this->param4->setEnabled(true);
136  }
137 }

Referenced by GMSHPrefsDialog().

◆ on_selectGeoButton_pressed

void GMSHPrefsDialog::on_selectGeoButton_pressed ( )
privateslot

Definition at line 91 of file GMSHPrefsDialog.cpp.

92 {
93  QModelIndexList selected =
94  this->allGeoView->selectionModel()->selectedIndexes();
95  QStringList list = _selGeo->stringList();
96 
97  for (auto& index : selected)
98  {
99  list.append(index.data().toString());
100 
101  _allGeo->removeRow(index.row());
102  }
103  _selGeo->setStringList(list);
104 }

References _allGeo, and _selGeo.

◆ reject

void GMSHPrefsDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 191 of file GMSHPrefsDialog.cpp.

192 {
193  this->done(QDialog::Rejected);
194 }

◆ requestMeshing

void GMSHPrefsDialog::requestMeshing ( std::vector< std::string > &  ,
unsigned  ,
double  ,
double  ,
double  ,
bool   
)
signal

Referenced by accept().

Member Data Documentation

◆ _allGeo

QStringListModel* GMSHPrefsDialog::_allGeo
private

◆ _selGeo

QStringListModel* GMSHPrefsDialog::_selGeo
private

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