17 #include <QIntValidator>
34 this->xOriginEdit->setValidator(origin_x_validator);
36 this->yOriginEdit->setValidator(origin_y_validator);
38 this->zOriginEdit->setValidator(origin_z_validator);
41 this->xLengthEdit->setValidator(x_length_validator);
43 this->yLengthEdit->setValidator(y_length_validator);
45 this->zLengthEdit->setValidator(z_length_validator);
47 auto* x_n_elem_validator =
new QIntValidator(1, 10000000,
this);
48 this->xElemEdit->setValidator(x_n_elem_validator);
49 auto* y_n_elem_validator =
new QIntValidator(1, 10000000,
this);
50 this->yElemEdit->setValidator(y_n_elem_validator);
51 auto* z_n_elem_validator =
new QIntValidator(1, 10000000,
this);
52 this->zElemEdit->setValidator(z_n_elem_validator);
57 this->yLengthLabel->setEnabled(
false);
58 this->yLengthEdit->setEnabled(
false);
59 this->zLengthLabel->setEnabled(
false);
60 this->zLengthEdit->setEnabled(
false);
61 this->yElemLabel->setEnabled(
false);
62 this->yElemEdit->setEnabled(
false);
63 this->zElemLabel->setEnabled(
false);
64 this->zElemEdit->setEnabled(
false);
69 this->yLengthLabel->setEnabled(
true);
70 this->yLengthEdit->setEnabled(
true);
71 this->zLengthLabel->setEnabled(
false);
72 this->zLengthEdit->setEnabled(
false);
73 this->yElemLabel->setEnabled(
true);
74 this->yElemEdit->setEnabled(
true);
75 this->zElemLabel->setEnabled(
false);
76 this->zElemEdit->setEnabled(
false);
81 this->yLengthLabel->setEnabled(
true);
82 this->yLengthEdit->setEnabled(
true);
83 this->zLengthLabel->setEnabled(
true);
84 this->zLengthEdit->setEnabled(
true);
85 this->yElemLabel->setEnabled(
true);
86 this->yElemEdit->setEnabled(
true);
87 this->zElemLabel->setEnabled(
true);
88 this->zElemEdit->setEnabled(
true);
93 this->xLengthLabel->setText(
"Mesh size in x");
94 this->yLengthLabel->setText(
"Mesh size in y");
95 this->zLengthLabel->setText(
"Mesh size in z");
100 this->xLengthLabel->setText(
"Element size in x");
101 this->yLengthLabel->setText(
"Element size in y");
102 this->zLengthLabel->setText(
"Element size in z");
107 QString
const type_str =
108 (this->meshExtentButton->isChecked()) ?
"mesh" :
"element";
109 if (this->xLengthEdit->text().isEmpty())
112 "\nextent in x-direction.");
115 if (this->xElemEdit->text().isEmpty())
117 OGSError::box(
"Please specify number of\nelements in x-direction.");
120 if (this->xOriginEdit->text().isEmpty() ||
121 this->yOriginEdit->text().isEmpty() ||
122 this->zOriginEdit->text().isEmpty())
124 OGSError::box(
"Please specify coordinates\nof mesh origin.");
127 if (this->meshNameEdit->text().isEmpty())
133 if (!this->lineButton->isChecked())
135 if (this->yLengthEdit->text().isEmpty())
138 "\nextent in y-direction.");
141 if (this->yElemEdit->text().isEmpty())
143 OGSError::box(
"Please specify number of\nelements in y-direction.");
148 if (this->prismButton->isChecked() || this->hexButton->isChecked())
150 if (this->zLengthEdit->text().isEmpty())
153 "\nextent in z-direction.");
156 if (this->zElemEdit->text().isEmpty())
158 OGSError::box(
"Please specify number of\nelements in z-direction.");
172 if ((this->xLengthEdit->text().toDouble() <= 0) ||
173 (this->yLengthEdit->text().toDouble() <= 0) ||
174 (this->zLengthEdit->text().toDouble() <= 0))
180 if ((this->xElemEdit->text().toDouble() <= 0) ||
181 (this->yElemEdit->text().toDouble() <= 0) ||
182 (this->zElemEdit->text().toDouble() <= 0))
184 OGSError::box(
"Number of elements needs to be larger than 0.");
188 GeoLib::Point const origin(this->xOriginEdit->text().toDouble(),
189 this->yOriginEdit->text().toDouble(),
190 this->zOriginEdit->text().toDouble());
191 std::string
const name(this->meshNameEdit->text().toStdString());
193 if (this->lineButton->isChecked())
195 if (this->meshExtentButton->isChecked())
198 this->xLengthEdit->text().toDouble(),
199 this->xElemEdit->text().toInt(), origin,
name);
204 this->xElemEdit->text().toInt(),
205 this->xLengthEdit->text().toDouble(), origin,
name);
208 else if (this->triButton->isChecked())
210 if (this->meshExtentButton->isChecked())
213 this->xLengthEdit->text().toDouble(),
214 this->yLengthEdit->text().toDouble(),
215 this->xElemEdit->text().toInt(),
216 this->yElemEdit->text().toInt(), origin,
name);
221 this->xElemEdit->text().toInt(),
222 this->yElemEdit->text().toInt(),
223 this->xLengthEdit->text().toDouble(),
224 this->yLengthEdit->text().toDouble(), origin,
name);
227 else if (this->quadButton->isChecked())
229 if (this->meshExtentButton->isChecked())
232 this->xLengthEdit->text().toDouble(),
233 this->yLengthEdit->text().toDouble(),
234 this->xElemEdit->text().toInt(),
235 this->yElemEdit->text().toInt(), origin,
name);
240 this->xElemEdit->text().toInt(),
241 this->yElemEdit->text().toInt(),
242 this->xLengthEdit->text().toDouble(),
243 this->yLengthEdit->text().toDouble(), origin,
name);
246 else if (this->prismButton->isChecked())
248 if (this->meshExtentButton->isChecked())
251 this->xLengthEdit->text().toDouble(),
252 this->yLengthEdit->text().toDouble(),
253 this->zLengthEdit->text().toDouble(),
254 this->xElemEdit->text().toInt(),
255 this->yElemEdit->text().toInt(),
256 this->zElemEdit->text().toInt(), origin,
name);
261 this->xLengthEdit->text().toDouble(),
262 this->yLengthEdit->text().toDouble(),
263 this->zLengthEdit->text().toDouble(),
264 this->xElemEdit->text().toInt(),
265 this->yElemEdit->text().toInt(),
266 this->zElemEdit->text().toInt(), origin,
name);
269 else if (this->hexButton->isChecked())
271 if (this->meshExtentButton->isChecked())
274 this->xLengthEdit->text().toDouble(),
275 this->yLengthEdit->text().toDouble(),
276 this->zLengthEdit->text().toDouble(),
277 this->xElemEdit->text().toInt(),
278 this->yElemEdit->text().toInt(),
279 this->zElemEdit->text().toInt(), origin,
name);
284 this->xElemEdit->text().toInt(),
285 this->yElemEdit->text().toInt(),
286 this->zElemEdit->text().toInt(),
287 this->xLengthEdit->text().toDouble(),
288 this->yLengthEdit->text().toDouble(),
289 this->zLengthEdit->text().toDouble(), origin,
name);
301 assert(mat_ids !=
nullptr);
304 this->done(QDialog::Accepted);
Definition of the CreateStructuredGridDialog class.
Definition of the Point class.
Definition of the OGSError class.
Implementation of the StrictDoubleValidator class.
void accept() override
Instructions if the OK-Button has been pressed.
CreateStructuredGridDialog(QDialog *parent=nullptr)
void on_lineButton_toggled() const
void enable3dWidgets() const
void on_meshExtentButton_toggled()
void enable2dWidgets() const
void on_elemExtentButton_toggled()
void meshAdded(MeshLib::Mesh *mesh)
bool inputIsEmpty() const
Checks if all necessary inputs have been specified.
Properties & getProperties()
std::size_t getNumberOfElements() const
Get the number of elements.
PropertyVector< T > * createNewPropertyVector(std::string const &name, MeshItemType mesh_item_type, std::size_t n_components=1)
static void box(const QString &e)
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow
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")
Mesh * generateLineMesh(const BaseLib::ISubdivision &div, MathLib::Point3d const &origin=MathLib::ORIGIN, std::string const &mesh_name="mesh")
Mesh * generateRegularTriMesh(const BaseLib::ISubdivision &div_x, const BaseLib::ISubdivision &div_y, MathLib::Point3d const &origin=MathLib::ORIGIN, std::string const &mesh_name="mesh")
Mesh * generateRegularQuadMesh(const BaseLib::ISubdivision &div_x, const BaseLib::ISubdivision &div_y, MathLib::Point3d const &origin=MathLib::ORIGIN, std::string const &mesh_name="mesh")
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")