@@ -61,11 +61,10 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
61
61
&QAction::triggered,
62
62
this ,
63
63
&TaskFemConstraintHeatflux::onReferenceDeleted);
64
-
65
- connect (ui->rb_convection , &QRadioButton::clicked, this , &TaskFemConstraintHeatflux::Conv);
66
- connect (ui->rb_radiation , &QRadioButton::clicked, this , &TaskFemConstraintHeatflux::Rad);
67
- connect (ui->rb_dflux , &QRadioButton::clicked, this , &TaskFemConstraintHeatflux::Flux);
68
-
64
+ connect (ui->cb_constr_type ,
65
+ qOverload<int >(&QComboBox::activated),
66
+ this ,
67
+ &TaskFemConstraintHeatflux::onConstrTypeChanged);
69
68
connect (ui->qsb_heat_flux ,
70
69
qOverload<double >(&QuantitySpinBox::valueChanged),
71
70
this ,
@@ -105,11 +104,20 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
105
104
ui->btnRemove ->blockSignals (true );
106
105
107
106
// Get the feature data
108
- Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
107
+ auto pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
109
108
std::vector<App::DocumentObject*> Objects = pcConstraint->References .getValues ();
110
109
std::vector<std::string> SubElements = pcConstraint->References .getSubValues ();
111
110
112
111
// Fill data into dialog elements
112
+ App::PropertyEnumeration* constrType = &pcConstraint->ConstraintType ;
113
+ QStringList qTypeList;
114
+ for (auto item : constrType->getEnumVector ()) {
115
+ qTypeList << QString::fromUtf8 (item.c_str ());
116
+ }
117
+ ui->cb_constr_type ->addItems (qTypeList);
118
+ ui->cb_constr_type ->setCurrentIndex (constrType->getValue ());
119
+ ui->sw_heatflux ->setCurrentIndex (constrType->getValue ());
120
+
113
121
ui->qsb_ambienttemp_conv ->setMinimum (0 );
114
122
ui->qsb_ambienttemp_conv ->setMaximum (FLOAT_MAX);
115
123
@@ -130,21 +138,6 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
130
138
131
139
ui->qsb_heat_flux ->setValue (pcConstraint->DFlux .getQuantityValue ());
132
140
133
- std::string constraint_type = pcConstraint->ConstraintType .getValueAsString ();
134
-
135
- if (constraint_type == " Convection" ) {
136
- ui->rb_convection ->setChecked (true );
137
- ui->sw_heatflux ->setCurrentIndex (0 );
138
- }
139
- else if (constraint_type == " Radiation" ) {
140
- ui->rb_radiation ->setChecked (true );
141
- ui->sw_heatflux ->setCurrentIndex (1 );
142
- }
143
- else if (constraint_type == " DFlux" ) {
144
- ui->rb_dflux ->setChecked (true );
145
- ui->sw_heatflux ->setCurrentIndex (2 );
146
- }
147
-
148
141
ui->lw_references ->clear ();
149
142
for (std::size_t i = 0 ; i < Objects.size (); i++) {
150
143
ui->lw_references ->addItem (makeRefText (Objects[i], SubElements[i]));
@@ -216,37 +209,53 @@ void TaskFemConstraintHeatflux::Conv()
216
209
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
217
210
std::string name = ConstraintView->getObject ()->getNameInDocument ();
218
211
Gui::Command::doCommand (Gui::Command::Doc,
219
- " App.ActiveDocument.%s.ConstraintType = %s " ,
212
+ " App.ActiveDocument.%s.ConstraintType = \" %s \" " ,
220
213
name.c_str (),
221
- get_constraint_type ().c_str ());
214
+ getConstraintType ().c_str ());
222
215
ui->qsb_ambienttemp_conv ->setValue (pcConstraint->AmbientTemp .getQuantityValue ());
223
216
ui->qsb_film_coef ->setValue (pcConstraint->FilmCoef .getQuantityValue ());
224
- ui->sw_heatflux ->setCurrentIndex (0 );
217
+ ui->sw_heatflux ->setCurrentIndex (1 );
225
218
}
226
219
227
220
void TaskFemConstraintHeatflux::Rad ()
228
221
{
229
222
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
230
223
std::string name = ConstraintView->getObject ()->getNameInDocument ();
231
224
Gui::Command::doCommand (Gui::Command::Doc,
232
- " App.ActiveDocument.%s.ConstraintType = %s " ,
225
+ " App.ActiveDocument.%s.ConstraintType = \" %s \" " ,
233
226
name.c_str (),
234
- get_constraint_type ().c_str ());
227
+ getConstraintType ().c_str ());
235
228
ui->qsb_ambienttemp_rad ->setValue (pcConstraint->AmbientTemp .getQuantityValue ());
236
229
ui->dsb_emissivity ->setValue (pcConstraint->Emissivity .getValue ());
237
- ui->sw_heatflux ->setCurrentIndex (1 );
230
+ ui->sw_heatflux ->setCurrentIndex (2 );
238
231
}
239
232
240
233
void TaskFemConstraintHeatflux::Flux ()
241
234
{
242
235
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
243
236
std::string name = ConstraintView->getObject ()->getNameInDocument ();
244
237
Gui::Command::doCommand (Gui::Command::Doc,
245
- " App.ActiveDocument.%s.ConstraintType = %s " ,
238
+ " App.ActiveDocument.%s.ConstraintType = \" %s \" " ,
246
239
name.c_str (),
247
- get_constraint_type ().c_str ());
240
+ getConstraintType ().c_str ());
248
241
ui->qsb_heat_flux ->setValue (pcConstraint->DFlux .getQuantityValue ());
249
- ui->sw_heatflux ->setCurrentIndex (2 );
242
+ ui->sw_heatflux ->setCurrentIndex (0 );
243
+ }
244
+
245
+ void TaskFemConstraintHeatflux::onConstrTypeChanged (int item)
246
+ {
247
+ auto obj = ConstraintView->getObject <Fem::ConstraintHeatflux>();
248
+ obj->ConstraintType .setValue (item);
249
+ const char * type = obj->ConstraintType .getValueAsString ();
250
+ if (strcmp (type, " DFlux" ) == 0 ) {
251
+ this ->Flux ();
252
+ }
253
+ else if (strcmp (type, " Convection" ) == 0 ) {
254
+ this ->Conv ();
255
+ }
256
+ else if (strcmp (type, " Radiation" ) == 0 ) {
257
+ this ->Rad ();
258
+ }
250
259
}
251
260
252
261
void TaskFemConstraintHeatflux::addToSelection ()
@@ -401,14 +410,17 @@ const std::string TaskFemConstraintHeatflux::getReferences() const
401
410
402
411
std::string TaskFemConstraintHeatflux::getAmbientTemp () const
403
412
{
404
- if (ui->rb_convection ->isChecked ()) {
413
+ std::string type = this ->getConstraintType ();
414
+ if (type == " Convection" ) {
405
415
return ui->qsb_ambienttemp_conv ->value ().getSafeUserString ();
406
416
}
407
- if (ui-> rb_radiation -> isChecked () ) {
417
+ else if (type == " Convection " ) {
408
418
return ui->qsb_ambienttemp_rad ->value ().getSafeUserString ();
409
419
}
410
- auto obj = ConstraintView->getObject <Fem::ConstraintHeatflux>();
411
- return obj->AmbientTemp .getQuantityValue ().getSafeUserString ();
420
+ else {
421
+ auto obj = ConstraintView->getObject <Fem::ConstraintHeatflux>();
422
+ return obj->AmbientTemp .getQuantityValue ().getSafeUserString ();
423
+ }
412
424
}
413
425
414
426
std::string TaskFemConstraintHeatflux::getFilmCoef () const
@@ -426,19 +438,9 @@ double TaskFemConstraintHeatflux::getEmissivity() const
426
438
return ui->dsb_emissivity ->value ();
427
439
}
428
440
429
- std::string TaskFemConstraintHeatflux::get_constraint_type () const
441
+ std::string TaskFemConstraintHeatflux::getConstraintType () const
430
442
{
431
- std::string type;
432
- if (ui->rb_convection ->isChecked ()) {
433
- type = " \" Convection\" " ;
434
- }
435
- else if (ui->rb_radiation ->isChecked ()) {
436
- type = " \" Radiation\" " ;
437
- }
438
- else if (ui->rb_dflux ->isChecked ()) {
439
- type = " \" DFlux\" " ;
440
- }
441
- return type;
443
+ return ui->cb_constr_type ->currentText ().toStdString ();
442
444
}
443
445
444
446
void TaskFemConstraintHeatflux::changeEvent (QEvent* e)
0 commit comments