Merge pull request #11126 from marioalexis84/Fem-task_temperature
Fem: Connect constraint temperature spinboxes to properties and task dialog rework - fixes #11109
This commit is contained in:
@@ -66,24 +66,28 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->if_temperature->setMinimum(0);
|
||||
ui->if_temperature->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_temperature->setMinimum(0);
|
||||
ui->qsb_temperature->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_cflux->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_cflux->setMaximum(FLOAT_MAX);
|
||||
|
||||
std::string constraint_type = pcConstraint->ConstraintType.getValueAsString();
|
||||
if (constraint_type == "Temperature") {
|
||||
ui->rb_temperature->setChecked(true);
|
||||
ui->if_temperature->setValue(pcConstraint->Temperature.getQuantityValue());
|
||||
App::PropertyEnumeration* constrType = &pcConstraint->ConstraintType;
|
||||
QStringList qTypeList;
|
||||
for (auto item : constrType->getEnumVector()) {
|
||||
qTypeList << QString::fromUtf8(item.c_str());
|
||||
}
|
||||
|
||||
ui->if_temperature->bind(pcConstraint->Temperature);
|
||||
ui->if_temperature->setUnit(pcConstraint->Temperature.getUnit());
|
||||
}
|
||||
else if (constraint_type == "CFlux") {
|
||||
ui->rb_cflux->setChecked(true);
|
||||
std::string str = "Concentrated heat flux";
|
||||
ui->if_temperature->setValue(pcConstraint->CFlux.getQuantityValue());
|
||||
ui->if_temperature->bind(pcConstraint->CFlux);
|
||||
ui->if_temperature->setUnit(pcConstraint->CFlux.getUnit());
|
||||
}
|
||||
ui->cb_constr_type->addItems(qTypeList);
|
||||
ui->cb_constr_type->setCurrentIndex(constrType->getValue());
|
||||
onConstrTypeChanged(constrType->getValue());
|
||||
|
||||
ui->qsb_temperature->setValue(pcConstraint->Temperature.getQuantityValue());
|
||||
ui->qsb_temperature->bind(pcConstraint->Temperature);
|
||||
ui->qsb_temperature->setUnit(pcConstraint->Temperature.getUnit());
|
||||
|
||||
ui->qsb_cflux->setValue(pcConstraint->CFlux.getQuantityValue());
|
||||
ui->qsb_cflux->bind(pcConstraint->CFlux);
|
||||
ui->qsb_cflux->setUnit(pcConstraint->CFlux.getUnit());
|
||||
|
||||
ui->lw_references->clear();
|
||||
for (std::size_t i = 0; i < Objects.size(); i++) {
|
||||
@@ -108,12 +112,22 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(
|
||||
&QListWidget::itemClicked,
|
||||
this,
|
||||
&TaskFemConstraintTemperature::setSelection);
|
||||
connect(ui->rb_temperature, &QRadioButton::clicked, this, &TaskFemConstraintTemperature::Temp);
|
||||
connect(ui->rb_cflux, &QRadioButton::clicked, this, &TaskFemConstraintTemperature::Flux);
|
||||
connect(ui->cb_constr_type,
|
||||
qOverload<int>(&QComboBox::activated),
|
||||
this,
|
||||
&TaskFemConstraintTemperature::onConstrTypeChanged);
|
||||
connect(ui->qsb_temperature,
|
||||
qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
&TaskFemConstraintTemperature::onTempChanged);
|
||||
connect(ui->qsb_cflux,
|
||||
qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
&TaskFemConstraintTemperature::onCFluxChanged);
|
||||
|
||||
// Selection buttons
|
||||
buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd);
|
||||
buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove);
|
||||
buttonGroup->addButton(ui->btnAdd, static_cast<int>(SelectionChangeModes::refAdd));
|
||||
buttonGroup->addButton(ui->btnRemove, static_cast<int>(SelectionChangeModes::refRemove));
|
||||
|
||||
updateUI();
|
||||
}
|
||||
@@ -129,20 +143,41 @@ void TaskFemConstraintTemperature::updateUI()
|
||||
}
|
||||
}
|
||||
|
||||
void TaskFemConstraintTemperature::Temp()
|
||||
void TaskFemConstraintTemperature::onTempChanged(double)
|
||||
{
|
||||
Fem::ConstraintTemperature* pcConstraint =
|
||||
static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
|
||||
ui->if_temperature->setUnit(pcConstraint->Temperature.getUnit());
|
||||
ui->if_temperature->setValue(pcConstraint->Temperature.getQuantityValue());
|
||||
std::string name = ConstraintView->getObject()->getNameInDocument();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.Temperature = \"%s\"",
|
||||
name.c_str(),
|
||||
get_temperature().c_str());
|
||||
}
|
||||
|
||||
void TaskFemConstraintTemperature::Flux()
|
||||
void TaskFemConstraintTemperature::onCFluxChanged(double)
|
||||
{
|
||||
Fem::ConstraintTemperature* pcConstraint =
|
||||
static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
|
||||
ui->if_temperature->setUnit(pcConstraint->CFlux.getUnit());
|
||||
ui->if_temperature->setValue(pcConstraint->CFlux.getQuantityValue());
|
||||
std::string name = ConstraintView->getObject()->getNameInDocument();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.CFlux = \"%s\"",
|
||||
name.c_str(),
|
||||
get_cflux().c_str());
|
||||
}
|
||||
|
||||
void TaskFemConstraintTemperature::onConstrTypeChanged(int item)
|
||||
{
|
||||
auto obj = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
|
||||
obj->ConstraintType.setValue(item);
|
||||
const char* type = obj->ConstraintType.getValueAsString();
|
||||
if (strcmp(type, "Temperature") == 0) {
|
||||
ui->qsb_temperature->setVisible(true);
|
||||
ui->qsb_cflux->setVisible(false);
|
||||
ui->lbl_temperature->setVisible(true);
|
||||
ui->lbl_cflux->setVisible(false);
|
||||
}
|
||||
else if (strcmp(type, "CFlux") == 0) {
|
||||
ui->qsb_cflux->setVisible(true);
|
||||
ui->qsb_temperature->setVisible(false);
|
||||
ui->lbl_cflux->setVisible(true);
|
||||
ui->lbl_temperature->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskFemConstraintTemperature::addToSelection()
|
||||
@@ -270,25 +305,17 @@ const std::string TaskFemConstraintTemperature::getReferences() const
|
||||
|
||||
std::string TaskFemConstraintTemperature::get_temperature() const
|
||||
{
|
||||
return ui->if_temperature->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_temperature->value().getSafeUserString().toStdString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintTemperature::get_cflux() const
|
||||
{
|
||||
return ui->if_temperature->value().getSafeUserString().toStdString();
|
||||
return ui->qsb_cflux->value().getSafeUserString().toStdString();
|
||||
}
|
||||
|
||||
std::string TaskFemConstraintTemperature::get_constraint_type() const
|
||||
{
|
||||
std::string type;
|
||||
|
||||
if (ui->rb_temperature->isChecked()) {
|
||||
type = "\"Temperature\"";
|
||||
}
|
||||
else if (ui->rb_cflux->isChecked()) {
|
||||
type = "\"CFlux\"";
|
||||
}
|
||||
return type;
|
||||
return ui->cb_constr_type->currentText().toStdString();
|
||||
}
|
||||
|
||||
bool TaskFemConstraintTemperature::event(QEvent* e)
|
||||
@@ -357,7 +384,7 @@ bool TaskDlgFemConstraintTemperature::accept()
|
||||
|
||||
try {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.ConstraintType = %s",
|
||||
"App.ActiveDocument.%s.ConstraintType = \"%s\"",
|
||||
name.c_str(),
|
||||
parameterTemperature->get_constraint_type().c_str());
|
||||
if (type == "Temperature") {
|
||||
|
||||
@@ -55,8 +55,9 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void onReferenceDeleted();
|
||||
void Temp();
|
||||
void Flux();
|
||||
void onConstrTypeChanged(int item);
|
||||
void onCFluxChanged(double);
|
||||
void onTempChanged(double);
|
||||
void addToSelection() override;
|
||||
void removeFromSelection() override;
|
||||
|
||||
|
||||
@@ -49,42 +49,45 @@
|
||||
<widget class="QListWidget" name="lw_references"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_temperature">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_constr_type">
|
||||
<property name="text">
|
||||
<string>Temperature</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
<string>Constraint type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_cflux">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cb_constr_type"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_temperature">
|
||||
<property name="text">
|
||||
<string>Temperature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="qsb_temperature">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">K</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_cflux">
|
||||
<property name="text">
|
||||
<string>Concentrated heat flux</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layoutTemperature">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_type">
|
||||
<property name="text">
|
||||
<string>Temperature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="if_temperature">
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="qsb_cflux">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">K</string>
|
||||
<string notr="true">mW</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
|
||||
Reference in New Issue
Block a user