From 2e084ed18a0ae33b30d26008e0f3eb6b4196619f Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 17 Mar 2022 19:53:12 +0100 Subject: [PATCH] [FEM] remove some unused includes for some dialogs - also some style fixes made by MSVC --- src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp | 12 - src/Mod/Fem/Gui/TaskFemConstraintContact.cpp | 13 +- .../Fem/Gui/TaskFemConstraintDisplacement.cpp | 306 +++++++++--------- .../Gui/TaskFemConstraintFluidBoundary.cpp | 105 +++--- 4 files changed, 193 insertions(+), 243 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp index 28f2b4495f..e7b2c38f62 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp @@ -25,22 +25,10 @@ #ifndef _PreComp_ # include - # include -# include # include -# include -# include - -# include # include # include -# include -# include -# include -# include -# include -# include #endif #include diff --git a/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp b/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp index 68c30946c3..88c1bfe36f 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp @@ -26,19 +26,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include # include -# include -# include -# include -# include -# include -# include +# include # include #endif diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp index d5bc2c78f4..8f4f49dddb 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp @@ -26,23 +26,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include - -# include -# include -# include -# include -# include - -# include -# include -# include -# include # include +# include +# include #endif #include @@ -58,7 +44,7 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintDisplacement */ -TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemConstraintDisplacement *ConstraintView,QWidget *parent) +TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemConstraintDisplacement* ConstraintView, QWidget* parent) : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintDisplacement") { proxy = new QWidget(this); @@ -70,7 +56,7 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons createDeleteAction(ui->lw_references); deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); - connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), + connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); connect(ui->lw_references, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); @@ -95,24 +81,24 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons Fem::ConstraintDisplacement* pcConstraint = static_cast(ConstraintView->getObject()); double fStates[6]; bool bStates[12]; - fStates[0]=pcConstraint->xDisplacement.getValue(); - fStates[1]=pcConstraint->yDisplacement.getValue(); - fStates[2]=pcConstraint->zDisplacement.getValue(); - fStates[3]=pcConstraint->xRotation.getValue(); - fStates[4]=pcConstraint->yRotation.getValue(); - fStates[5]=pcConstraint->zRotation.getValue(); - bStates[0]=pcConstraint->xFix.getValue(); - bStates[1]=pcConstraint->xFree.getValue(); - bStates[2]=pcConstraint->yFix.getValue(); - bStates[3]=pcConstraint->yFree.getValue(); - bStates[4]=pcConstraint->zFix.getValue(); - bStates[5]=pcConstraint->zFree.getValue(); - bStates[6]=pcConstraint->rotxFix.getValue(); - bStates[7]=pcConstraint->rotxFree.getValue(); - bStates[8]=pcConstraint->rotyFix.getValue(); - bStates[9]=pcConstraint->rotyFree.getValue(); - bStates[10]=pcConstraint->rotzFix.getValue(); - bStates[11]=pcConstraint->rotzFree.getValue(); + fStates[0] = pcConstraint->xDisplacement.getValue(); + fStates[1] = pcConstraint->yDisplacement.getValue(); + fStates[2] = pcConstraint->zDisplacement.getValue(); + fStates[3] = pcConstraint->xRotation.getValue(); + fStates[4] = pcConstraint->yRotation.getValue(); + fStates[5] = pcConstraint->zRotation.getValue(); + bStates[0] = pcConstraint->xFix.getValue(); + bStates[1] = pcConstraint->xFree.getValue(); + bStates[2] = pcConstraint->yFix.getValue(); + bStates[3] = pcConstraint->yFree.getValue(); + bStates[4] = pcConstraint->zFix.getValue(); + bStates[5] = pcConstraint->zFree.getValue(); + bStates[6] = pcConstraint->rotxFix.getValue(); + bStates[7] = pcConstraint->rotxFree.getValue(); + bStates[8] = pcConstraint->rotyFix.getValue(); + bStates[9] = pcConstraint->rotyFree.getValue(); + bStates[10] = pcConstraint->rotzFix.getValue(); + bStates[11] = pcConstraint->rotzFree.getValue(); std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); @@ -190,202 +176,202 @@ void TaskFemConstraintDisplacement::updateUI() } } -void TaskFemConstraintDisplacement::x_changed(double val){ - if (val!=0) +void TaskFemConstraintDisplacement::x_changed(double val) { + if (val != 0) { ui->dispxfree->setChecked(false); ui->dispxfix->setChecked(false); } } -void TaskFemConstraintDisplacement::y_changed(double val){ - if (val!=0) +void TaskFemConstraintDisplacement::y_changed(double val) { + if (val != 0) { ui->dispyfree->setChecked(false); ui->dispyfix->setChecked(false); } } -void TaskFemConstraintDisplacement::z_changed(double val){ - if (val!=0) +void TaskFemConstraintDisplacement::z_changed(double val) { + if (val != 0) { ui->dispzfree->setChecked(false); ui->dispzfix->setChecked(false); } } -void TaskFemConstraintDisplacement::x_rot(double val){ - if (val!=0) +void TaskFemConstraintDisplacement::x_rot(double val) { + if (val != 0) { ui->rotxfree->setChecked(false); ui->rotxfix->setChecked(false); } } -void TaskFemConstraintDisplacement::y_rot(double val){ - if (val!=0) +void TaskFemConstraintDisplacement::y_rot(double val) { + if (val != 0) { ui->rotyfree->setChecked(false); ui->rotyfix->setChecked(false); } } -void TaskFemConstraintDisplacement::z_rot(double val){ - if (val!=0) +void TaskFemConstraintDisplacement::z_rot(double val) { + if (val != 0) { ui->rotzfree->setChecked(false); ui->rotzfix->setChecked(false); } } -void TaskFemConstraintDisplacement::fixx(int val){ - if (val==2) +void TaskFemConstraintDisplacement::fixx(int val) { + if (val == 2) { ui->dispxfree->setChecked(false); ui->spinxDisplacement->setValue(0); } - else if (ui->spinxDisplacement->value()==0) + else if (ui->spinxDisplacement->value() == 0) { - ui->dispxfree->setChecked(true); + ui->dispxfree->setChecked(true); } } -void TaskFemConstraintDisplacement::freex(int val){ - if (val==2) +void TaskFemConstraintDisplacement::freex(int val) { + if (val == 2) { ui->dispxfix->setChecked(false); ui->spinxDisplacement->setValue(0); } - else if (ui->spinxDisplacement->value()==0) + else if (ui->spinxDisplacement->value() == 0) { - ui->dispxfix->setChecked(true); + ui->dispxfix->setChecked(true); } } -void TaskFemConstraintDisplacement::fixy(int val){ - if (val==2) +void TaskFemConstraintDisplacement::fixy(int val) { + if (val == 2) { ui->dispyfree->setChecked(false); ui->spinyDisplacement->setValue(0); } - else if (ui->spinyDisplacement->value()==0) + else if (ui->spinyDisplacement->value() == 0) { - ui->dispyfree->setChecked(true); + ui->dispyfree->setChecked(true); } } -void TaskFemConstraintDisplacement::freey(int val){ - if (val==2) +void TaskFemConstraintDisplacement::freey(int val) { + if (val == 2) { ui->dispyfix->setChecked(false); ui->spinyDisplacement->setValue(0); } - else if (ui->spinyDisplacement->value()==0) + else if (ui->spinyDisplacement->value() == 0) { - ui->dispyfix->setChecked(true); + ui->dispyfix->setChecked(true); } } -void TaskFemConstraintDisplacement::fixz(int val){ - if (val==2) +void TaskFemConstraintDisplacement::fixz(int val) { + if (val == 2) { ui->dispzfree->setChecked(false); ui->spinzDisplacement->setValue(0); } - else if (ui->spinzDisplacement->value()==0) + else if (ui->spinzDisplacement->value() == 0) { - ui->dispzfree->setChecked(true); + ui->dispzfree->setChecked(true); } } -void TaskFemConstraintDisplacement::freez(int val){ - if (val==2) +void TaskFemConstraintDisplacement::freez(int val) { + if (val == 2) { ui->dispzfix->setChecked(false); ui->spinzDisplacement->setValue(0); } - else if (ui->spinzDisplacement->value()==0) + else if (ui->spinzDisplacement->value() == 0) { - ui->dispzfix->setChecked(true); + ui->dispzfix->setChecked(true); } } -void TaskFemConstraintDisplacement::rotfixx(int val){ - if (val==2) +void TaskFemConstraintDisplacement::rotfixx(int val) { + if (val == 2) { ui->rotxfree->setChecked(false); ui->spinxRotation->setValue(0); } - else if (ui->spinxRotation->value()==0) + else if (ui->spinxRotation->value() == 0) { - ui->rotxfree->setChecked(true); + ui->rotxfree->setChecked(true); } } -void TaskFemConstraintDisplacement::rotfreex(int val){ - if (val==2) +void TaskFemConstraintDisplacement::rotfreex(int val) { + if (val == 2) { ui->rotxfix->setChecked(false); ui->spinxRotation->setValue(0); } - else if (ui->spinxRotation->value()==0) + else if (ui->spinxRotation->value() == 0) { - ui->rotxfix->setChecked(true); + ui->rotxfix->setChecked(true); } } -void TaskFemConstraintDisplacement::rotfixy(int val){ - if (val==2) +void TaskFemConstraintDisplacement::rotfixy(int val) { + if (val == 2) { ui->rotyfree->setChecked(false); ui->spinyRotation->setValue(0); } - else if (ui->spinyRotation->value()==0) + else if (ui->spinyRotation->value() == 0) { - ui->rotyfree->setChecked(true); + ui->rotyfree->setChecked(true); } } -void TaskFemConstraintDisplacement::rotfreey(int val){ - if (val==2) +void TaskFemConstraintDisplacement::rotfreey(int val) { + if (val == 2) { ui->rotyfix->setChecked(false); ui->spinyRotation->setValue(0); } - else if (ui->spinyRotation->value()==0) + else if (ui->spinyRotation->value() == 0) { - ui->rotyfix->setChecked(true); + ui->rotyfix->setChecked(true); } } -void TaskFemConstraintDisplacement::rotfixz(int val){ - if (val==2) +void TaskFemConstraintDisplacement::rotfixz(int val) { + if (val == 2) { ui->rotzfree->setChecked(false); ui->spinzRotation->setValue(0); } - else if (ui->spinzRotation->value()==0) + else if (ui->spinzRotation->value() == 0) { - ui->rotzfree->setChecked(true); + ui->rotzfree->setChecked(true); } } -void TaskFemConstraintDisplacement::rotfreez(int val){ - if (val==2) +void TaskFemConstraintDisplacement::rotfreez(int val) { + if (val == 2) { ui->rotzfix->setChecked(false); ui->spinzRotation->setValue(0); } - else if (ui->spinzRotation->value()==0) + else if (ui->spinzRotation->value() == 0) { - ui->rotzfix->setChecked(true); + ui->rotzfix->setChecked(true); } } void TaskFemConstraintDisplacement::addToSelection() { std::vector selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document - if (selection.size() == 0){ + if (selection.size() == 0) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; } @@ -393,40 +379,40 @@ void TaskFemConstraintDisplacement::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object + for (std::vector::iterator it = selection.begin(); it != selection.end(); ++it) {//for every selected object if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } const std::vector& subNames = it->getSubNames(); App::DocumentObject* obj = it->getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element + for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element bool addMe = true; for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); - itr != SubElements.end(); - itr = std::find(++itr, SubElements.end(), subNames[subIt])) + itr != SubElements.end(); + itr = std::find(++itr, SubElements.end(), subNames[subIt])) {// for every sub element in selection that matches one in old list - if (obj == Objects[std::distance(SubElements.begin(), itr)]){//if selected sub element's object equals the one in old list then it was added before so don't add + if (obj == Objects[std::distance(SubElements.begin(), itr)]) {//if selected sub element's object equals the one in old list then it was added before so don't add addMe = false; } } // limit constraint such that only vertexes or faces or edges can be used depending on what was selected first std::string searchStr; if (subNames[subIt].find("Vertex") != std::string::npos) - searchStr="Vertex"; + searchStr = "Vertex"; else if (subNames[subIt].find("Edge") != std::string::npos) searchStr = "Edge"; else searchStr = "Face"; - for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr){ - if (SubElements[iStr].find(searchStr) == std::string::npos){ + for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr) { + if (SubElements[iStr].find(searchStr) == std::string::npos) { QString msg = tr("Only one type of selection (vertex,face or edge) per constraint allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); - addMe=false; + addMe = false; break; } } - if (addMe){ + if (addMe) { QSignalBlocker block(ui->lw_references); Objects.push_back(obj); SubElements.push_back(subNames[subIt]); @@ -442,7 +428,7 @@ void TaskFemConstraintDisplacement::addToSelection() void TaskFemConstraintDisplacement::removeFromSelection() { std::vector selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document - if (selection.size() == 0){ + if (selection.size() == 0) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; } @@ -450,7 +436,7 @@ void TaskFemConstraintDisplacement::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object + for (std::vector::iterator it = selection.begin(); it != selection.end(); ++it) {//for every selected object if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -458,19 +444,19 @@ void TaskFemConstraintDisplacement::removeFromSelection() const std::vector& subNames = it->getSubNames(); App::DocumentObject* obj = it->getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element + for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), subNames[subIt])) {// for every sub element in selection that matches one in old list - if (obj == Objects[std::distance(SubElements.begin(), itr)]){//if selected sub element's object equals the one in old list then it was added before so mark for deletion + if (obj == Objects[std::distance(SubElements.begin(), itr)]) {//if selected sub element's object equals the one in old list then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } } } std::sort(itemsToDel.begin(), itemsToDel.end()); - while (itemsToDel.size() > 0){ + while (itemsToDel.size() > 0) { Objects.erase(Objects.begin() + itemsToDel.back()); SubElements.erase(SubElements.begin() + itemsToDel.back()); itemsToDel.pop_back(); @@ -501,39 +487,39 @@ const std::string TaskFemConstraintDisplacement::getReferences() const return TaskFemConstraint::getReferences(items); } -double TaskFemConstraintDisplacement::get_spinxDisplacement() const{return ui->spinxDisplacement->value();} -double TaskFemConstraintDisplacement::get_spinyDisplacement() const{return ui->spinyDisplacement->value();} -double TaskFemConstraintDisplacement::get_spinzDisplacement() const{return ui->spinzDisplacement->value();} -double TaskFemConstraintDisplacement::get_spinxRotation() const{return ui->spinxRotation->value();} -double TaskFemConstraintDisplacement::get_spinyRotation() const{return ui->spinyRotation->value();} -double TaskFemConstraintDisplacement::get_spinzRotation() const{return ui->spinzRotation->value();} +double TaskFemConstraintDisplacement::get_spinxDisplacement() const { return ui->spinxDisplacement->value(); } +double TaskFemConstraintDisplacement::get_spinyDisplacement() const { return ui->spinyDisplacement->value(); } +double TaskFemConstraintDisplacement::get_spinzDisplacement() const { return ui->spinzDisplacement->value(); } +double TaskFemConstraintDisplacement::get_spinxRotation() const { return ui->spinxRotation->value(); } +double TaskFemConstraintDisplacement::get_spinyRotation() const { return ui->spinyRotation->value(); } +double TaskFemConstraintDisplacement::get_spinzRotation() const { return ui->spinzRotation->value(); } -bool TaskFemConstraintDisplacement::get_dispxfix() const{return ui->dispxfix->isChecked();} -bool TaskFemConstraintDisplacement::get_dispxfree() const{return ui->dispxfree->isChecked();} -bool TaskFemConstraintDisplacement::get_dispyfix() const{return ui->dispyfix->isChecked();} -bool TaskFemConstraintDisplacement::get_dispyfree() const{return ui->dispyfree->isChecked();} -bool TaskFemConstraintDisplacement::get_dispzfix() const{return ui->dispzfix->isChecked();} -bool TaskFemConstraintDisplacement::get_dispzfree() const{return ui->dispzfree->isChecked();} -bool TaskFemConstraintDisplacement::get_rotxfix() const{return ui->rotxfix->isChecked();} -bool TaskFemConstraintDisplacement::get_rotxfree() const{return ui->rotxfree->isChecked();} -bool TaskFemConstraintDisplacement::get_rotyfix() const{return ui->rotyfix->isChecked();} -bool TaskFemConstraintDisplacement::get_rotyfree() const{return ui->rotyfree->isChecked();} -bool TaskFemConstraintDisplacement::get_rotzfix() const{return ui->rotzfix->isChecked();} -bool TaskFemConstraintDisplacement::get_rotzfree() const{return ui->rotzfree->isChecked();} +bool TaskFemConstraintDisplacement::get_dispxfix() const { return ui->dispxfix->isChecked(); } +bool TaskFemConstraintDisplacement::get_dispxfree() const { return ui->dispxfree->isChecked(); } +bool TaskFemConstraintDisplacement::get_dispyfix() const { return ui->dispyfix->isChecked(); } +bool TaskFemConstraintDisplacement::get_dispyfree() const { return ui->dispyfree->isChecked(); } +bool TaskFemConstraintDisplacement::get_dispzfix() const { return ui->dispzfix->isChecked(); } +bool TaskFemConstraintDisplacement::get_dispzfree() const { return ui->dispzfree->isChecked(); } +bool TaskFemConstraintDisplacement::get_rotxfix() const { return ui->rotxfix->isChecked(); } +bool TaskFemConstraintDisplacement::get_rotxfree() const { return ui->rotxfree->isChecked(); } +bool TaskFemConstraintDisplacement::get_rotyfix() const { return ui->rotyfix->isChecked(); } +bool TaskFemConstraintDisplacement::get_rotyfree() const { return ui->rotyfree->isChecked(); } +bool TaskFemConstraintDisplacement::get_rotzfix() const { return ui->rotzfix->isChecked(); } +bool TaskFemConstraintDisplacement::get_rotzfree() const { return ui->rotzfree->isChecked(); } -bool TaskFemConstraintDisplacement::event(QEvent *e) +bool TaskFemConstraintDisplacement::event(QEvent* e) { return TaskFemConstraint::KeyEvent(e); } -void TaskFemConstraintDisplacement::changeEvent(QEvent *) +void TaskFemConstraintDisplacement::changeEvent(QEvent*) { -// TaskBox::changeEvent(e); -// if (e->type() == QEvent::LanguageChange) { -// ui->if_pressure->blockSignals(true); -// ui->retranslateUi(proxy); -// ui->if_pressure->blockSignals(false); -// } + // TaskBox::changeEvent(e); + // if (e->type() == QEvent::LanguageChange) { + // ui->if_pressure->blockSignals(true); + // ui->retranslateUi(proxy); + // ui->if_pressure->blockSignals(false); + // } } void TaskFemConstraintDisplacement::clearButtons(const SelectionChangeModes notThis) @@ -548,7 +534,7 @@ void TaskFemConstraintDisplacement::clearButtons(const SelectionChangeModes notT // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgFemConstraintDisplacement::TaskDlgFemConstraintDisplacement(ViewProviderFemConstraintDisplacement *ConstraintView) +TaskDlgFemConstraintDisplacement::TaskDlgFemConstraintDisplacement(ViewProviderFemConstraintDisplacement* ConstraintView) { this->ConstraintView = ConstraintView; assert(ConstraintView); @@ -566,7 +552,7 @@ void TaskDlgFemConstraintDisplacement::open() QString msg = QObject::tr("Constraint displacement"); Gui::Command::openCommand((const char*)msg.toUtf8()); ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts + Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts } } @@ -576,45 +562,45 @@ bool TaskDlgFemConstraintDisplacement::accept() const TaskFemConstraintDisplacement* parameterDisplacement = static_cast(parameter); try { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.xDisplacement = %f", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xDisplacement = %f", name.c_str(), parameterDisplacement->get_spinxDisplacement()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.yDisplacement = %f", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yDisplacement = %f", name.c_str(), parameterDisplacement->get_spinyDisplacement()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.zDisplacement = %f", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zDisplacement = %f", name.c_str(), parameterDisplacement->get_spinzDisplacement()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.xRotation = %f", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xRotation = %f", name.c_str(), parameterDisplacement->get_spinxRotation()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.yRotation = %f", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yRotation = %f", name.c_str(), parameterDisplacement->get_spinyRotation()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.zRotation = %f", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zRotation = %f", name.c_str(), parameterDisplacement->get_spinzRotation()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.xFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xFree = %s", name.c_str(), parameterDisplacement->get_dispxfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.xFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xFix = %s", name.c_str(), parameterDisplacement->get_dispxfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.yFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yFree = %s", name.c_str(), parameterDisplacement->get_dispyfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.yFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yFix = %s", name.c_str(), parameterDisplacement->get_dispyfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.zFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zFree = %s", name.c_str(), parameterDisplacement->get_dispzfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.zFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zFix = %s", name.c_str(), parameterDisplacement->get_dispzfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotxFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotxFree = %s", name.c_str(), parameterDisplacement->get_rotxfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotxFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotxFix = %s", name.c_str(), parameterDisplacement->get_rotxfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotyFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotyFree = %s", name.c_str(), parameterDisplacement->get_rotyfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotyFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotyFix = %s", name.c_str(), parameterDisplacement->get_rotyfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotzFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotzFree = %s", name.c_str(), parameterDisplacement->get_rotzfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotzFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotzFix = %s", name.c_str(), parameterDisplacement->get_rotzfix() ? "True" : "False"); std::string scale = parameterDisplacement->getScale(); //OvG: determine modified scale - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); @@ -627,7 +613,7 @@ bool TaskDlgFemConstraintDisplacement::accept() bool TaskDlgFemConstraintDisplacement::reject() { Gui::Command::abortCommand(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); Gui::Command::updateActive(); return true; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp index 740cf2ba7f..7bfbccb0cc 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp @@ -26,24 +26,10 @@ #ifndef _PreComp_ # include - # include -# include # include -# include -# include - -# include # include # include -# include -# include -# include -# include -# include -# include -# include -# include #endif #include @@ -71,11 +57,11 @@ using namespace Fem; //also defined in FemConstrainFluidBoundary and foamcasebuilder/basicbuilder.py, please update simultaneously //the second (index 1) is the default enum, as index 0 causes compiling error //static const char* BoundaryTypes[] = {"inlet","wall","outlet","freestream", "interface", NULL}; -static const char* WallSubtypes[] = {"unspecific", "fixed", "slip", "partialSlip", "moving", "rough", NULL}; -static const char* InletSubtypes[] = {"unspecific","totalPressure","uniformVelocity","volumetricFlowRate","massFlowRate",NULL}; -static const char* OutletSubtypes[] = {"unspecific","totalPressure","staticPressure","uniformVelocity", "outFlow", NULL}; -static const char* InterfaceSubtypes[] = {"unspecific","symmetry","wedge","cyclic","empty", "coupled", NULL}; -static const char* FreestreamSubtypes[] = {"unspecific", "freestream",NULL}; +static const char* WallSubtypes[] = { "unspecific", "fixed", "slip", "partialSlip", "moving", "rough", NULL }; +static const char* InletSubtypes[] = { "unspecific","totalPressure","uniformVelocity","volumetricFlowRate","massFlowRate",NULL }; +static const char* OutletSubtypes[] = { "unspecific","totalPressure","staticPressure","uniformVelocity", "outFlow", NULL }; +static const char* InterfaceSubtypes[] = { "unspecific","symmetry","wedge","cyclic","empty", "coupled", NULL }; +static const char* FreestreamSubtypes[] = { "unspecific", "freestream",NULL }; static const char* InterfaceSubtypeHelpTexts[] = { "invalid,select other valid interface subtype", @@ -83,7 +69,7 @@ static const char* InterfaceSubtypeHelpTexts[] = { "axis symmetric front and back surfaces", "periodic boundary in pair, treated as physical connected", "front and back for single layer 2D mesh, also axis-sym axis line", - "exchange boundary vale with external program, need extra manual setup like file name", NULL}; + "exchange boundary vale with external program, need extra manual setup like file name", NULL }; // defined in file FemConstraintFluidBoundary: // see Ansys fluet manual: Turbulence Specification method @@ -93,11 +79,11 @@ static const char* TurbulenceSpecificationHelpTexts[] = { "explicitly specific intensity k [SI unit] and dissipation rate epsilon [] / omega []", "intensity (0.05 ~ 0.15) and characteristic length scale of max eddy [m]", "intensity (0.05 ~ 0.15) and turbulent viscosity ratio", - "for fully developed internal flow, Turbulence intensity (0-1.0) 0.05 typical", NULL}; + "for fully developed internal flow, Turbulence intensity (0-1.0) 0.05 typical", NULL }; //static const char* ThermalBoundaryTypes[] = {"fixedValue","zeroGradient", "fixedGradient", "mixed", "heatFlux", "HTC","coupled", NULL}; -static const char* ThermalBoundaryHelpTexts[] = {"fixed Temperature [K]", "no heat transfer on boundary", "fixed value gradient [K/m]", - "mixed fixedGradient and fixedValue", "fixed heat flux [W/m2]", "Heat transfer coeff [W/(M2)/K]", "conjugate heat transfer with solid", NULL}; +static const char* ThermalBoundaryHelpTexts[] = { "fixed Temperature [K]", "no heat transfer on boundary", "fixed value gradient [K/m]", + "mixed fixedGradient and fixedValue", "fixed heat flux [W/m2]", "Heat transfer coeff [W/(M2)/K]", "conjugate heat transfer with solid", NULL }; // enable & disable quantityUI once valueType is selected // internal function not declared in header file @@ -121,7 +107,7 @@ void initComboBox(QComboBox* combo, const std::vector& textItems, c } /* TRANSLATOR FemGui::TaskFemConstraintFluidBoundary */ -TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemConstraintFluidBoundary *ConstraintView,QWidget *parent) +TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemConstraintFluidBoundary* ConstraintView, QWidget* parent) : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFluidBoundary") , dimension(-1) { @@ -194,7 +180,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemCo else { App::Document* aDoc = pcConstraint->getDocument(); std::vector fem = aDoc->getObjectsOfType(Fem::FemAnalysis::getClassTypeId()); - if (fem.size() >=1) { + if (fem.size() >= 1) { pcAnalysis = static_cast(fem[0]); // get the first } } @@ -217,16 +203,16 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemCo App::PropertyLink* pcLink = static_cast(prop); Part::Feature* pcPart = dynamic_cast(pcLink->getValue()); if (pcPart) { // deduct dimension from part_obj.Shape.ShapeType - const TopoDS_Shape & pShape = pcPart->Shape.getShape().getShape(); + const TopoDS_Shape& pShape = pcPart->Shape.getShape().getShape(); const TopAbs_ShapeEnum shapeType = pShape.IsNull() ? TopAbs_SHAPE : pShape.ShapeType(); - if (shapeType == TopAbs_SOLID || shapeType ==TopAbs_COMPSOLID) // COMPSOLID is solids connected by faces - dimension =3; + if (shapeType == TopAbs_SOLID || shapeType == TopAbs_COMPSOLID) // COMPSOLID is solids connected by faces + dimension = 3; else if (shapeType == TopAbs_FACE || shapeType == TopAbs_SHELL) - dimension =2; + dimension = 2; else if (shapeType == TopAbs_EDGE || shapeType == TopAbs_WIRE) - dimension =1; + dimension = 1; else - dimension =-1; // Vertex (0D) can not make mesh, Compound type might contain any types + dimension = -1; // Vertex (0D) can not make mesh, Compound type might contain any types } } } @@ -265,7 +251,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemCo } if (pcSolver->getPropertyByName("TurbulenceModel")) { pTurbulenceModel = static_cast(pcSolver->getPropertyByName("TurbulenceModel")); - if (pTurbulenceModel->getValueAsString() == std::string("laminar")){ + if (pTurbulenceModel->getValueAsString() == std::string("laminar")) { ui->tabTurbulenceBoundary->setEnabled(false); } else { @@ -389,7 +375,7 @@ void TaskFemConstraintFluidBoundary::updateSubtypeUI() if (boundaryType == "inlet" || boundaryType == "outlet") { ui->tabBasicBoundary->setEnabled(true); - if (subtype == "totalPressure" || subtype == "staticPressure"){ + if (subtype == "totalPressure" || subtype == "staticPressure") { ui->labelBoundaryValue->setText(QString::fromUtf8("pressure [Pa]")); ui->buttonDirection->setEnabled(false); ui->lineDirection->setEnabled(false); @@ -456,7 +442,7 @@ void TaskFemConstraintFluidBoundary::updateTurbulenceUI() /// hide/disable UI only happened in constructor, update helptext and label text here std::string turbulenceSpec = Base::Tools::toStdString(ui->comboTurbulenceSpecification->currentText()); ui->labelTurbulentIntensityValue->setText(tr("Intensity [0~1]")); - if (turbulenceSpec == "intensity&DissipationRate"){ + if (turbulenceSpec == "intensity&DissipationRate") { ui->labelTurbulentLengthValue->setText(tr("Dissipation Rate [m2/s3]")); } else if (turbulenceSpec == "intensity&LengthScale") { @@ -484,7 +470,7 @@ void TaskFemConstraintFluidBoundary::updateThermalBoundaryUI() ui->spinHTCoeffValue->setEnabled(false); ui->spinTemperatureValue->setEnabled(false); ui->spinHeatFluxValue->setEnabled(false); - if (thermalBoundaryType == "zeroGradient" || thermalBoundaryType == "coupled"){ + if (thermalBoundaryType == "zeroGradient" || thermalBoundaryType == "coupled") { return; } else if (thermalBoundaryType == "fixedValue") { @@ -561,7 +547,7 @@ void TaskFemConstraintFluidBoundary::onButtonDirection(const bool pressed) { // sets the normal vector of the currently selecteed planar face as direction - Q_UNUSED(pressed) + Q_UNUSED(pressed); clearButtons(SelectionChangeModes::none); @@ -646,10 +632,10 @@ double TaskFemConstraintFluidBoundary::getBoundaryValue(void) const std::string TaskFemConstraintFluidBoundary::getTurbulenceModel(void) const { - if(pTurbulenceModel){ + if (pTurbulenceModel) { return pTurbulenceModel->getValueAsString(); } - else{ + else { return "laminar"; } } @@ -671,10 +657,10 @@ double TaskFemConstraintFluidBoundary::getTurbulentLengthValue(void) const bool TaskFemConstraintFluidBoundary::getHeatTransferring(void) const { - if(pHeatTransferring){ + if (pHeatTransferring) { return pHeatTransferring->getValue(); } - else{ + else { return false; } } @@ -726,7 +712,7 @@ const std::string TaskFemConstraintFluidBoundary::getDirectionObject(void) const return ""; int pos = dir.find_last_of(":"); - return dir.substr(pos+1).c_str(); + return dir.substr(pos + 1).c_str(); } bool TaskFemConstraintFluidBoundary::getReverse() const @@ -854,12 +840,12 @@ void TaskFemConstraintFluidBoundary::updateUI() } } -bool TaskFemConstraintFluidBoundary::event(QEvent *e) +bool TaskFemConstraintFluidBoundary::event(QEvent* e) { return TaskFemConstraint::KeyEvent(e); } -void TaskFemConstraintFluidBoundary::changeEvent(QEvent *e) +void TaskFemConstraintFluidBoundary::changeEvent(QEvent* e) { TaskBox::changeEvent(e); if (e->type() == QEvent::LanguageChange) { @@ -884,7 +870,7 @@ void TaskFemConstraintFluidBoundary::clearButtons(const SelectionChangeModes not // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgFemConstraintFluidBoundary::TaskDlgFemConstraintFluidBoundary(ViewProviderFemConstraintFluidBoundary *ConstraintView) +TaskDlgFemConstraintFluidBoundary::TaskDlgFemConstraintFluidBoundary(ViewProviderFemConstraintFluidBoundary* ConstraintView) { this->ConstraintView = ConstraintView; assert(ConstraintView); @@ -912,11 +898,11 @@ bool TaskDlgFemConstraintFluidBoundary::accept() // no need to backup pcConstraint object content, if rejected, content can be recovered by transaction manager try { //Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Fluid boundary condition changed")); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.BoundaryType = '%s'", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.BoundaryType = '%s'", name.c_str(), boundary->getBoundaryType().c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Subtype = '%s'", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Subtype = '%s'", name.c_str(), boundary->getSubtype().c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.BoundaryValue = %f", + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.BoundaryValue = %f", name.c_str(), boundary->getBoundaryValue()); std::string dirname = boundary->getDirectionName().data(); @@ -926,15 +912,16 @@ bool TaskDlgFemConstraintFluidBoundary::accept() QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); buf = buf.arg(QString::fromStdString(dirname)); buf = buf.arg(QString::fromStdString(dirobj)); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str()); - } else { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str()); + } + else { + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Direction = None", name.c_str()); } //Reverse control is done at BoundaryType selection, this UI is hidden from user //Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %s", name.c_str(), boundary->getReverse() ? "True" : "False"); std::string scale = boundary->getScale(); //OvG: determine modified scale - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale // solver specific setting, physical model selection const Fem::FemSolverObject* pcSolver = boundary->getFemSolver(); @@ -946,16 +933,16 @@ bool TaskDlgFemConstraintFluidBoundary::accept() pTurbulenceModel = static_cast(pcSolver->getPropertyByName("TurbulenceModel")); if (pHeatTransferring && pHeatTransferring->getValue()) { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ThermalBoundaryType = '%s'",name.c_str(), boundary->getThermalBoundaryType().c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.TemperatureValue = %f",name.c_str(), boundary->getTemperatureValue()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.HeatFluxValue = %f",name.c_str(), boundary->getHeatFluxValue()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.HTCoeffValue = %f",name.c_str(), boundary->getHTCoeffValue()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.ThermalBoundaryType = '%s'", name.c_str(), boundary->getThermalBoundaryType().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TemperatureValue = %f", name.c_str(), boundary->getTemperatureValue()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.HeatFluxValue = %f", name.c_str(), boundary->getHeatFluxValue()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.HTCoeffValue = %f", name.c_str(), boundary->getHTCoeffValue()); } if (pTurbulenceModel && std::string(pTurbulenceModel->getValueAsString()) != "laminar") { // Invisic and DNS flow also does not need this //update turbulence and thermal boundary settings, only if those models are activated - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.TurbulenceSpecification = '%s'",name.c_str(), boundary->getTurbulenceSpecification().c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.TurbulentIntensityValue = %f",name.c_str(), boundary->getTurbulentIntensityValue()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.TurbulentLengthValue = %f",name.c_str(), boundary->getTurbulentLengthValue()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TurbulenceSpecification = '%s'", name.c_str(), boundary->getTurbulenceSpecification().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TurbulentIntensityValue = %f", name.c_str(), boundary->getTurbulentIntensityValue()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TurbulentLengthValue = %f", name.c_str(), boundary->getTurbulentLengthValue()); } } else { @@ -973,7 +960,7 @@ bool TaskDlgFemConstraintFluidBoundary::accept() bool TaskDlgFemConstraintFluidBoundary::reject() { Gui::Command::abortCommand(); // recover properties content - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); Gui::Command::updateActive(); return true;