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.
 
void reject () override
 Instructions if the Cancel-Button has been pressed.
 

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 29 of file GMSHPrefsDialog.cpp.

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

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

◆ ~GMSHPrefsDialog()

GMSHPrefsDialog::~GMSHPrefsDialog ( )
override

Definition at line 86 of file GMSHPrefsDialog.cpp.

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

References _allGeo, and _selGeo.

Member Function Documentation

◆ accept

void GMSHPrefsDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 140 of file GMSHPrefsDialog.cpp.

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

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

◆ getSelectedObjects()

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

◆ on_deselectGeoButton_pressed

void GMSHPrefsDialog::on_deselectGeoButton_pressed ( )
privateslot

Definition at line 107 of file GMSHPrefsDialog.cpp.

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

References _allGeo, and _selGeo.

◆ on_radioAdaptive_toggled

void GMSHPrefsDialog::on_radioAdaptive_toggled ( bool isTrue)
privateslot

Definition at line 122 of file GMSHPrefsDialog.cpp.

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

Referenced by GMSHPrefsDialog().

◆ on_selectGeoButton_pressed

void GMSHPrefsDialog::on_selectGeoButton_pressed ( )
privateslot

Definition at line 92 of file GMSHPrefsDialog.cpp.

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

References _allGeo, and _selGeo.

◆ reject

void GMSHPrefsDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 192 of file GMSHPrefsDialog.cpp.

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

◆ 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: