OGS
CreateStructuredGridDialog Class Reference

Detailed Description

A dialog window for managing general Data Explorer settings.

Definition at line 14 of file CreateStructuredGridDialog.h.

#include <CreateStructuredGridDialog.h>

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

Signals

void meshAdded (MeshLib::Mesh *mesh)

Public Member Functions

 CreateStructuredGridDialog (QDialog *parent=nullptr)

Private Slots

void on_lineButton_toggled () const
void on_triButton_toggled () const
void on_quadButton_toggled () const
void on_prismButton_toggled () const
void on_hexButton_toggled () const
void on_meshExtentButton_toggled ()
void on_elemExtentButton_toggled ()
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

void enable2dWidgets () const
void enable3dWidgets () const
void setValidators ()
bool inputIsEmpty () const
 Checks if all necessary inputs have been specified.

Constructor & Destructor Documentation

◆ CreateStructuredGridDialog()

CreateStructuredGridDialog::CreateStructuredGridDialog ( QDialog * parent = nullptr)
explicit

Definition at line 13 of file CreateStructuredGridDialog.cpp.

14 : QDialog(parent)
15{
16 setupUi(this);
18}

References setValidators().

Member Function Documentation

◆ accept

void CreateStructuredGridDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 154 of file CreateStructuredGridDialog.cpp.

155{
156 if (inputIsEmpty())
157 {
158 return;
159 }
160
161 if ((this->xLengthEdit->text().toDouble() <= 0) ||
162 (this->yLengthEdit->text().toDouble() <= 0) ||
163 (this->zLengthEdit->text().toDouble() <= 0))
164 {
165 OGSError::box("Length needs to be larger than 0.");
166 return;
167 }
168
169 if ((this->xElemEdit->text().toDouble() <= 0) ||
170 (this->yElemEdit->text().toDouble() <= 0) ||
171 (this->zElemEdit->text().toDouble() <= 0))
172 {
173 OGSError::box("Number of elements needs to be larger than 0.");
174 return;
175 }
176
177 GeoLib::Point const origin(this->xOriginEdit->text().toDouble(),
178 this->yOriginEdit->text().toDouble(),
179 this->zOriginEdit->text().toDouble());
180 std::string const name(this->meshNameEdit->text().toStdString());
181 MeshLib::Mesh* mesh(nullptr);
182 if (this->lineButton->isChecked())
183 {
184 if (this->meshExtentButton->isChecked())
185 {
187 this->xLengthEdit->text().toDouble(),
188 this->xElemEdit->text().toInt(), origin, name);
189 }
190 else
191 {
193 this->xElemEdit->text().toInt(),
194 this->xLengthEdit->text().toDouble(), origin, name);
195 }
196 }
197 else if (this->triButton->isChecked())
198 {
199 if (this->meshExtentButton->isChecked())
200 {
202 this->xLengthEdit->text().toDouble(),
203 this->yLengthEdit->text().toDouble(),
204 this->xElemEdit->text().toInt(),
205 this->yElemEdit->text().toInt(), origin, name);
206 }
207 else
208 {
210 this->xElemEdit->text().toInt(),
211 this->yElemEdit->text().toInt(),
212 this->xLengthEdit->text().toDouble(),
213 this->yLengthEdit->text().toDouble(), origin, name);
214 }
215 }
216 else if (this->quadButton->isChecked())
217 {
218 if (this->meshExtentButton->isChecked())
219 {
221 this->xLengthEdit->text().toDouble(),
222 this->yLengthEdit->text().toDouble(),
223 this->xElemEdit->text().toInt(),
224 this->yElemEdit->text().toInt(), origin, name);
225 }
226 else
227 {
229 this->xElemEdit->text().toInt(),
230 this->yElemEdit->text().toInt(),
231 this->xLengthEdit->text().toDouble(),
232 this->yLengthEdit->text().toDouble(), origin, name);
233 }
234 }
235 else if (this->prismButton->isChecked())
236 {
237 if (this->meshExtentButton->isChecked())
238 {
240 this->xLengthEdit->text().toDouble(),
241 this->yLengthEdit->text().toDouble(),
242 this->zLengthEdit->text().toDouble(),
243 this->xElemEdit->text().toInt(),
244 this->yElemEdit->text().toInt(),
245 this->zElemEdit->text().toInt(), origin, name);
246 }
247 else
248 {
250 this->xLengthEdit->text().toDouble(),
251 this->yLengthEdit->text().toDouble(),
252 this->zLengthEdit->text().toDouble(),
253 this->xElemEdit->text().toInt(),
254 this->yElemEdit->text().toInt(),
255 this->zElemEdit->text().toInt(), origin, name);
256 }
257 }
258 else if (this->hexButton->isChecked())
259 {
260 if (this->meshExtentButton->isChecked())
261 {
263 this->xLengthEdit->text().toDouble(),
264 this->yLengthEdit->text().toDouble(),
265 this->zLengthEdit->text().toDouble(),
266 this->xElemEdit->text().toInt(),
267 this->yElemEdit->text().toInt(),
268 this->zElemEdit->text().toInt(), origin, name);
269 }
270 else
271 {
273 this->xElemEdit->text().toInt(),
274 this->yElemEdit->text().toInt(),
275 this->zElemEdit->text().toInt(),
276 this->xLengthEdit->text().toDouble(),
277 this->yLengthEdit->text().toDouble(),
278 this->zLengthEdit->text().toDouble(), origin, name);
279 }
280 }
281
282 if (mesh == nullptr)
283 {
284 OGSError::box("Error creating mesh.");
285 return;
286 }
287
288 auto* const mat_ids = mesh->getProperties().createNewPropertyVector<int>(
289 "MaterialIDs", MeshLib::MeshItemType::Cell);
290 assert(mat_ids != nullptr);
291 mat_ids->resize(mesh->getNumberOfElements());
292 emit meshAdded(mesh);
293 this->done(QDialog::Accepted);
294}
void meshAdded(MeshLib::Mesh *mesh)
bool inputIsEmpty() const
Checks if all necessary inputs have been specified.
static void box(const QString &e)
Definition OGSError.cpp:13
MeshLib::Mesh * generateLineMesh(const BaseLib::ISubdivision &div, MathLib::Point3d const &origin=MathLib::ORIGIN, std::string const &mesh_name="mesh")
MeshLib::Mesh * generateRegularQuadMesh(const BaseLib::ISubdivision &div_x, const BaseLib::ISubdivision &div_y, MathLib::Point3d const &origin=MathLib::ORIGIN, std::string const &mesh_name="mesh")
MeshLib::Mesh * generateRegularPrismMesh(const double x_length, const double y_length, const double z_length, const std::size_t x_subdivision, const std::size_t y_subdivision, const std::size_t z_subdivision, MathLib::Point3d const &origin=MathLib::ORIGIN, std::string const &mesh_name="mesh")
MeshLib::Mesh * generateRegularTriMesh(const BaseLib::ISubdivision &div_x, const BaseLib::ISubdivision &div_y, MathLib::Point3d const &origin=MathLib::ORIGIN, std::string const &mesh_name="mesh")
MeshLib::Mesh * generateRegularHexMesh(const BaseLib::ISubdivision &div_x, const BaseLib::ISubdivision &div_y, const BaseLib::ISubdivision &div_z, MathLib::Point3d const &origin=MathLib::ORIGIN, std::string const &mesh_name="mesh")

References OGSError::box(), MeshLib::Cell, MeshLib::Properties::createNewPropertyVector(), MeshToolsLib::MeshGenerator::generateLineMesh(), MeshToolsLib::MeshGenerator::generateRegularHexMesh(), MeshToolsLib::MeshGenerator::generateRegularPrismMesh(), MeshToolsLib::MeshGenerator::generateRegularQuadMesh(), MeshToolsLib::MeshGenerator::generateRegularTriMesh(), MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getProperties(), inputIsEmpty(), and meshAdded().

◆ enable2dWidgets()

void CreateStructuredGridDialog::enable2dWidgets ( ) const
private

Definition at line 56 of file CreateStructuredGridDialog.cpp.

57{
58 this->yLengthLabel->setEnabled(true);
59 this->yLengthEdit->setEnabled(true);
60 this->zLengthLabel->setEnabled(false);
61 this->zLengthEdit->setEnabled(false);
62 this->yElemLabel->setEnabled(true);
63 this->yElemEdit->setEnabled(true);
64 this->zElemLabel->setEnabled(false);
65 this->zElemEdit->setEnabled(false);
66}

Referenced by on_quadButton_toggled(), and on_triButton_toggled().

◆ enable3dWidgets()

void CreateStructuredGridDialog::enable3dWidgets ( ) const
private

Definition at line 68 of file CreateStructuredGridDialog.cpp.

69{
70 this->yLengthLabel->setEnabled(true);
71 this->yLengthEdit->setEnabled(true);
72 this->zLengthLabel->setEnabled(true);
73 this->zLengthEdit->setEnabled(true);
74 this->yElemLabel->setEnabled(true);
75 this->yElemEdit->setEnabled(true);
76 this->zElemLabel->setEnabled(true);
77 this->zElemEdit->setEnabled(true);
78}

Referenced by on_hexButton_toggled(), and on_prismButton_toggled().

◆ inputIsEmpty()

bool CreateStructuredGridDialog::inputIsEmpty ( ) const
private

Checks if all necessary inputs have been specified.

Definition at line 94 of file CreateStructuredGridDialog.cpp.

95{
96 QString const type_str =
97 (this->meshExtentButton->isChecked()) ? "mesh" : "element";
98 if (this->xLengthEdit->text().isEmpty())
99 {
100 OGSError::box("Please specify " + type_str +
101 "\nextent in x-direction.");
102 return true;
103 }
104 if (this->xElemEdit->text().isEmpty())
105 {
106 OGSError::box("Please specify number of\nelements in x-direction.");
107 return true;
108 }
109 if (this->xOriginEdit->text().isEmpty() ||
110 this->yOriginEdit->text().isEmpty() ||
111 this->zOriginEdit->text().isEmpty())
112 {
113 OGSError::box("Please specify coordinates\nof mesh origin.");
114 return true;
115 }
116 if (this->meshNameEdit->text().isEmpty())
117 {
118 OGSError::box("Please specify mesh name.");
119 return true;
120 }
121
122 if (!this->lineButton->isChecked())
123 {
124 if (this->yLengthEdit->text().isEmpty())
125 {
126 OGSError::box("Please specify " + type_str +
127 "\nextent in y-direction.");
128 return true;
129 }
130 if (this->yElemEdit->text().isEmpty())
131 {
132 OGSError::box("Please specify number of\nelements in y-direction.");
133 return true;
134 }
135 }
136
137 if (this->prismButton->isChecked() || this->hexButton->isChecked())
138 {
139 if (this->zLengthEdit->text().isEmpty())
140 {
141 OGSError::box("Please specify " + type_str +
142 "\nextent in z-direction.");
143 return true;
144 }
145 if (this->zElemEdit->text().isEmpty())
146 {
147 OGSError::box("Please specify number of\nelements in z-direction.");
148 return true;
149 }
150 }
151 return false;
152}

References OGSError::box().

Referenced by accept().

◆ meshAdded

void CreateStructuredGridDialog::meshAdded ( MeshLib::Mesh * mesh)
signal

Referenced by accept().

◆ on_elemExtentButton_toggled

void CreateStructuredGridDialog::on_elemExtentButton_toggled ( )
privateslot

Definition at line 87 of file CreateStructuredGridDialog.cpp.

88{
89 this->xLengthLabel->setText("Element size in x");
90 this->yLengthLabel->setText("Element size in y");
91 this->zLengthLabel->setText("Element size in z");
92}

◆ on_hexButton_toggled

void CreateStructuredGridDialog::on_hexButton_toggled ( ) const
inlineprivateslot

Definition at line 26 of file CreateStructuredGridDialog.h.

References enable3dWidgets().

◆ on_lineButton_toggled

void CreateStructuredGridDialog::on_lineButton_toggled ( ) const
privateslot

Definition at line 44 of file CreateStructuredGridDialog.cpp.

45{
46 this->yLengthLabel->setEnabled(false);
47 this->yLengthEdit->setEnabled(false);
48 this->zLengthLabel->setEnabled(false);
49 this->zLengthEdit->setEnabled(false);
50 this->yElemLabel->setEnabled(false);
51 this->yElemEdit->setEnabled(false);
52 this->zElemLabel->setEnabled(false);
53 this->zElemEdit->setEnabled(false);
54}

◆ on_meshExtentButton_toggled

void CreateStructuredGridDialog::on_meshExtentButton_toggled ( )
privateslot

Definition at line 80 of file CreateStructuredGridDialog.cpp.

81{
82 this->xLengthLabel->setText("Mesh size in x");
83 this->yLengthLabel->setText("Mesh size in y");
84 this->zLengthLabel->setText("Mesh size in z");
85}

◆ on_prismButton_toggled

void CreateStructuredGridDialog::on_prismButton_toggled ( ) const
inlineprivateslot

Definition at line 25 of file CreateStructuredGridDialog.h.

25{ enable3dWidgets(); }

References enable3dWidgets().

◆ on_quadButton_toggled

void CreateStructuredGridDialog::on_quadButton_toggled ( ) const
inlineprivateslot

Definition at line 24 of file CreateStructuredGridDialog.h.

References enable2dWidgets().

◆ on_triButton_toggled

void CreateStructuredGridDialog::on_triButton_toggled ( ) const
inlineprivateslot

Definition at line 23 of file CreateStructuredGridDialog.h.

23{ enable2dWidgets(); }

References enable2dWidgets().

◆ reject

void CreateStructuredGridDialog::reject ( )
inlineoverrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 34 of file CreateStructuredGridDialog.h.

34{ this->done(QDialog::Rejected); };

◆ setValidators()

void CreateStructuredGridDialog::setValidators ( )
private

Definition at line 20 of file CreateStructuredGridDialog.cpp.

21{
22 auto* origin_x_validator = new StrictDoubleValidator(this);
23 this->xOriginEdit->setValidator(origin_x_validator);
24 auto* origin_y_validator = new StrictDoubleValidator(this);
25 this->yOriginEdit->setValidator(origin_y_validator);
26 auto* origin_z_validator = new StrictDoubleValidator(this);
27 this->zOriginEdit->setValidator(origin_z_validator);
28
29 auto* x_length_validator = new StrictDoubleValidator(0, 10000000, 10, this);
30 this->xLengthEdit->setValidator(x_length_validator);
31 auto* y_length_validator = new StrictDoubleValidator(0, 10000000, 10, this);
32 this->yLengthEdit->setValidator(y_length_validator);
33 auto* z_length_validator = new StrictDoubleValidator(0, 10000000, 10, this);
34 this->zLengthEdit->setValidator(z_length_validator);
35
36 auto* x_n_elem_validator = new QIntValidator(1, 10000000, this);
37 this->xElemEdit->setValidator(x_n_elem_validator);
38 auto* y_n_elem_validator = new QIntValidator(1, 10000000, this);
39 this->yElemEdit->setValidator(y_n_elem_validator);
40 auto* z_n_elem_validator = new QIntValidator(1, 10000000, this);
41 this->zElemEdit->setValidator(z_n_elem_validator);
42}

Referenced by CreateStructuredGridDialog().


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