@@ -61,11 +61,10 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
6161 &QAction::triggered,
6262 this ,
6363 &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);
6968 connect (ui->qsb_heat_flux ,
7069 qOverload<double >(&QuantitySpinBox::valueChanged),
7170 this ,
@@ -105,11 +104,20 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
105104 ui->btnRemove ->blockSignals (true );
106105
107106 // Get the feature data
108- Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
107+ auto pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
109108 std::vector<App::DocumentObject*> Objects = pcConstraint->References .getValues ();
110109 std::vector<std::string> SubElements = pcConstraint->References .getSubValues ();
111110
112111 // 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+
113121 ui->qsb_ambienttemp_conv ->setMinimum (0 );
114122 ui->qsb_ambienttemp_conv ->setMaximum (FLOAT_MAX);
115123
@@ -130,21 +138,6 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
130138
131139 ui->qsb_heat_flux ->setValue (pcConstraint->DFlux .getQuantityValue ());
132140
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-
148141 ui->lw_references ->clear ();
149142 for (std::size_t i = 0 ; i < Objects.size (); i++) {
150143 ui->lw_references ->addItem (makeRefText (Objects[i], SubElements[i]));
@@ -216,37 +209,53 @@ void TaskFemConstraintHeatflux::Conv()
216209 Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
217210 std::string name = ConstraintView->getObject ()->getNameInDocument ();
218211 Gui::Command::doCommand (Gui::Command::Doc,
219- " App.ActiveDocument.%s.ConstraintType = %s " ,
212+ " App.ActiveDocument.%s.ConstraintType = \" %s \" " ,
220213 name.c_str (),
221- get_constraint_type ().c_str ());
214+ getConstraintType ().c_str ());
222215 ui->qsb_ambienttemp_conv ->setValue (pcConstraint->AmbientTemp .getQuantityValue ());
223216 ui->qsb_film_coef ->setValue (pcConstraint->FilmCoef .getQuantityValue ());
224- ui->sw_heatflux ->setCurrentIndex (0 );
217+ ui->sw_heatflux ->setCurrentIndex (1 );
225218}
226219
227220void TaskFemConstraintHeatflux::Rad ()
228221{
229222 Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
230223 std::string name = ConstraintView->getObject ()->getNameInDocument ();
231224 Gui::Command::doCommand (Gui::Command::Doc,
232- " App.ActiveDocument.%s.ConstraintType = %s " ,
225+ " App.ActiveDocument.%s.ConstraintType = \" %s \" " ,
233226 name.c_str (),
234- get_constraint_type ().c_str ());
227+ getConstraintType ().c_str ());
235228 ui->qsb_ambienttemp_rad ->setValue (pcConstraint->AmbientTemp .getQuantityValue ());
236229 ui->dsb_emissivity ->setValue (pcConstraint->Emissivity .getValue ());
237- ui->sw_heatflux ->setCurrentIndex (1 );
230+ ui->sw_heatflux ->setCurrentIndex (2 );
238231}
239232
240233void TaskFemConstraintHeatflux::Flux ()
241234{
242235 Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject <Fem::ConstraintHeatflux>();
243236 std::string name = ConstraintView->getObject ()->getNameInDocument ();
244237 Gui::Command::doCommand (Gui::Command::Doc,
245- " App.ActiveDocument.%s.ConstraintType = %s " ,
238+ " App.ActiveDocument.%s.ConstraintType = \" %s \" " ,
246239 name.c_str (),
247- get_constraint_type ().c_str ());
240+ getConstraintType ().c_str ());
248241 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+ }
250259}
251260
252261void TaskFemConstraintHeatflux::addToSelection ()
@@ -401,14 +410,17 @@ const std::string TaskFemConstraintHeatflux::getReferences() const
401410
402411std::string TaskFemConstraintHeatflux::getAmbientTemp () const
403412{
404- if (ui->rb_convection ->isChecked ()) {
413+ std::string type = this ->getConstraintType ();
414+ if (type == " Convection" ) {
405415 return ui->qsb_ambienttemp_conv ->value ().getSafeUserString ();
406416 }
407- if (ui-> rb_radiation -> isChecked () ) {
417+ else if (type == " Convection " ) {
408418 return ui->qsb_ambienttemp_rad ->value ().getSafeUserString ();
409419 }
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+ }
412424}
413425
414426std::string TaskFemConstraintHeatflux::getFilmCoef () const
@@ -426,19 +438,9 @@ double TaskFemConstraintHeatflux::getEmissivity() const
426438 return ui->dsb_emissivity ->value ();
427439}
428440
429- std::string TaskFemConstraintHeatflux::get_constraint_type () const
441+ std::string TaskFemConstraintHeatflux::getConstraintType () const
430442{
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 ();
442444}
443445
444446void TaskFemConstraintHeatflux::changeEvent (QEvent* e)
0 commit comments