[FEM] task dialogs: remove unused includes

- also some code style fixes from MSVC
This commit is contained in:
Uwe
2022-03-17 23:31:17 +01:00
parent b7e1dd9ee9
commit 7ccfe10af4
12 changed files with 414 additions and 600 deletions

View File

@@ -33,9 +33,9 @@
using namespace FemGui;
DlgSettingsFemCcxImp::DlgSettingsFemCcxImp( QWidget* parent )
: PreferencePage( parent )
, ui(new Ui_DlgSettingsFemCcxImp)
DlgSettingsFemCcxImp::DlgSettingsFemCcxImp(QWidget* parent)
: PreferencePage(parent)
, ui(new Ui_DlgSettingsFemCcxImp)
{
ui->setupUi(this);
// set ranges
@@ -104,16 +104,16 @@ void DlgSettingsFemCcxImp::loadSettings()
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Fem/Ccx");
int index = hGrp->GetInt("Solver", 0);
int index = hGrp->GetInt("Solver", 0);
if (index > -1) ui->cmb_solver->setCurrentIndex(index);
index = hGrp->GetInt("AnalysisType", 0);
index = hGrp->GetInt("AnalysisType", 0);
if (index > -1) ui->cb_analysis_type->setCurrentIndex(index);
}
/**
* Sets the strings of the subwidgets using the current language.
*/
void DlgSettingsFemCcxImp::changeEvent(QEvent *e)
void DlgSettingsFemCcxImp::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {
int c_index = ui->cb_analysis_type->currentIndex();

View File

@@ -24,36 +24,18 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintFixed.h"
#include <App/Document.h>
#include <Gui/Command.h>
#include <Gui/SelectionObject.h>
#include <Mod/Fem/App/FemConstraintFixed.h>
#include "TaskFemConstraintFixed.h"
#include "ui_TaskFemConstraintFixed.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/SelectionObject.h>
#include <Mod/Part/App/PartFeature.h>
using namespace FemGui;
@@ -61,8 +43,8 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintFixed */
TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *ConstraintView,QWidget *parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFixed")
TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed* ConstraintView, QWidget* parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFixed")
{ //Note change "Fixed" in line above to new constraint name
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintFixed();
@@ -73,14 +55,14 @@ TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *C
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*)));
this->groupLayout()->addWidget(proxy);
/* Note: */
/* Note: */
// Get the feature data
Fem::ConstraintFixed* pcConstraint = static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
@@ -123,7 +105,7 @@ void TaskFemConstraintFixed::updateUI()
void TaskFemConstraintFixed::addToSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -131,40 +113,40 @@ void TaskFemConstraintFixed::addToSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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;
}
std::vector<std::string> subNames=it->getSubNames();
std::vector<std::string> subNames = it->getSubNames();
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
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<std::string>::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;
break;
}
}
if (addMe){
if (addMe) {
QSignalBlocker block(ui->lw_references);
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
@@ -180,7 +162,7 @@ void TaskFemConstraintFixed::addToSelection()
void TaskFemConstraintFixed::removeFromSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -188,27 +170,27 @@ void TaskFemConstraintFixed::removeFromSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
if(!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
for (std::vector<Gui::SelectionObject>::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<std::string>& 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<std::string>::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();
@@ -239,12 +221,12 @@ const std::string TaskFemConstraintFixed::getReferences() const
return TaskFemConstraint::getReferences(items);
}
bool TaskFemConstraintFixed::event(QEvent *e)
bool TaskFemConstraintFixed::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintFixed::changeEvent(QEvent *)
void TaskFemConstraintFixed::changeEvent(QEvent*)
{
}
@@ -260,7 +242,7 @@ void TaskFemConstraintFixed::clearButtons(const SelectionChangeModes notThis)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintFixed::TaskDlgFemConstraintFixed(ViewProviderFemConstraintFixed *ConstraintView)
TaskDlgFemConstraintFixed::TaskDlgFemConstraintFixed(ViewProviderFemConstraintFixed* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -278,7 +260,7 @@ void TaskDlgFemConstraintFixed::open()
QString msg = QObject::tr("Constraint fixed");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
@@ -287,14 +269,14 @@ bool TaskDlgFemConstraintFixed::accept()
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintFixed* parameters = static_cast<const TaskFemConstraintFixed*>(parameter);
std::string scale = parameters->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
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintFixed::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;

View File

@@ -21,48 +21,25 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <Precision.hxx>
# include <TopoDS.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Plane.hxx>
# include <gp_Pln.hxx>
# include <gp_Ax1.hxx>
# include <BRepAdaptor_Curve.hxx>
# include <Geom_Line.hxx>
# include <gp_Lin.hxx>
#endif
#include "ui_TaskFemConstraintForce.h"
#include "TaskFemConstraintForce.h"
#include <Base/Console.h>
#include <Base/Tools.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/OriginFeature.h>
#include <App/PropertyGeo.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Gui/Selection.h>
#include <Gui/SelectionObject.h>
#include <Gui/Command.h>
#include <Gui/SelectionObject.h>
#include <Gui/ViewProvider.h>
#include <Mod/Fem/App/FemConstraintForce.h>
#include <Mod/Fem/App/FemTools.h>
#include <Mod/Part/App/PartFeature.h>
#include "TaskFemConstraintForce.h"
#include "ui_TaskFemConstraintForce.h"
using namespace FemGui;
@@ -70,7 +47,7 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintForce */
TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce *ConstraintView,QWidget *parent)
TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce* ConstraintView, QWidget* parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintForce")
{
// we need a separate container widget to add all controls to
@@ -316,7 +293,7 @@ TaskFemConstraintForce::getDirection(const std::vector<Gui::SelectionObject>& se
void TaskFemConstraintForce::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);
@@ -379,7 +356,7 @@ const std::string TaskFemConstraintForce::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 TaskFemConstraintForce::getReverse() const
@@ -392,12 +369,12 @@ TaskFemConstraintForce::~TaskFemConstraintForce()
delete ui;
}
bool TaskFemConstraintForce::event(QEvent *e)
bool TaskFemConstraintForce::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintForce::changeEvent(QEvent *e)
void TaskFemConstraintForce::changeEvent(QEvent* e)
{
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
@@ -420,7 +397,7 @@ void TaskFemConstraintForce::clearButtons(const SelectionChangeModes notThis)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintForce::TaskDlgFemConstraintForce(ViewProviderFemConstraintForce *ConstraintView)
TaskDlgFemConstraintForce::TaskDlgFemConstraintForce(ViewProviderFemConstraintForce* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -438,7 +415,7 @@ void TaskDlgFemConstraintForce::open()
QString msg = QObject::tr("Constraint force");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
@@ -450,7 +427,7 @@ bool TaskDlgFemConstraintForce::accept()
try {
//Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "FEM force constraint changed"));
if (parameterForce->getForce()<=0)
if (parameterForce->getForce() <= 0)
{
QMessageBox::warning(parameter, tr("Input error"), tr("Please specify a force greater than 0"));
return false;
@@ -458,7 +435,7 @@ bool TaskDlgFemConstraintForce::accept()
else
{
QByteArray num = QByteArray::number(parameterForce->getForce());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Force = %s",name.c_str(), num.data());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Force = %s", name.c_str(), num.data());
}
std::string dirname = parameterForce->getDirectionName().data();
@@ -469,15 +446,16 @@ bool TaskDlgFemConstraintForce::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());
}
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %s", name.c_str(), parameterForce->getReverse() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Reversed = %s", name.c_str(), parameterForce->getReverse() ? "True" : "False");
scale = parameterForce->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()));
@@ -491,7 +469,7 @@ bool TaskDlgFemConstraintForce::reject()
{
// roll back the changes
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;

View File

@@ -26,41 +26,26 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintHeatflux.h"
#include "TaskFemConstraintHeatflux.h"
#include "ui_TaskFemConstraintHeatflux.h"
#include <App/Application.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/SelectionObject.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Fem/App/FemConstraintHeatflux.h>
#include "TaskFemConstraintHeatflux.h"
#include "ui_TaskFemConstraintHeatflux.h"
using namespace FemGui;
using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintHeatflux */
TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHeatflux *ConstraintView,QWidget *parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintHeatflux")
TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHeatflux* ConstraintView, QWidget* parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintHeatflux")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintHeatflux();
@@ -71,8 +56,8 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHe
createDeleteAction(ui->lw_references);
deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
connect(ui->rb_convection, SIGNAL(clicked(bool)), this, SLOT(Conv()));
connect(ui->rb_dflux, SIGNAL(clicked(bool)), this, SLOT(Flux()));
connect(ui->rb_convection, SIGNAL(clicked(bool)), this, SLOT(Conv()));
connect(ui->rb_dflux, SIGNAL(clicked(bool)), this, SLOT(Flux()));
connect(ui->if_heatflux, SIGNAL(valueChanged(double)),
this, SLOT(onHeatFluxChanged(double)));
@@ -115,7 +100,8 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHe
ui->if_ambienttemp->setValue(t);
Base::Quantity f = Base::Quantity(pcConstraint->FilmCoef.getValue(), Base::Unit::ThermalTransferCoefficient);
ui->if_filmcoef->setValue(f);
} else if (constraint_type == "DFlux") {
}
else if (constraint_type == "DFlux") {
ui->rb_dflux->setChecked(1);
ui->sw_heatflux->setCurrentIndex(1);
Base::Quantity c = Base::Quantity(pcConstraint->DFlux.getValue(), Base::Unit::HeatFlux);
@@ -189,7 +175,7 @@ void TaskFemConstraintHeatflux::Conv()
{
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ConstraintType = %s",name.c_str(), get_constraint_type().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.ConstraintType = %s", name.c_str(), get_constraint_type().c_str());
Base::Quantity t = Base::Quantity(300, Base::Unit::Temperature);
ui->if_ambienttemp->setValue(t);
pcConstraint->AmbientTemp.setValue(300);
@@ -203,7 +189,7 @@ void TaskFemConstraintHeatflux::Flux()
{
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ConstraintType = %s",name.c_str(), get_constraint_type().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.ConstraintType = %s", name.c_str(), get_constraint_type().c_str());
Base::Quantity c = Base::Quantity(0, Base::Unit::HeatFlux);
ui->if_heatflux->setValue(c);
pcConstraint->DFlux.setValue(0);
@@ -213,7 +199,7 @@ void TaskFemConstraintHeatflux::Flux()
void TaskFemConstraintHeatflux::addToSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -221,7 +207,7 @@ void TaskFemConstraintHeatflux::addToSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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;
@@ -229,28 +215,28 @@ void TaskFemConstraintHeatflux::addToSelection()
const std::vector<std::string>& subNames = it->getSubNames();
App::DocumentObject* obj = it->getObject();
if (subNames.size() > 0){
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){
if (subNames.size() > 0) {
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {
if (subNames[subIt].substr(0, 4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Selection must only consist of faces!"));
return;
}
}
}
else{
else {
//fix me, if an object is selected completely, getSelectionEx does not return any SubElements
}
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<std::string>::iterator itr=std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
for (std::vector<std::string>::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 don't add
addMe=false;
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;
}
}
if (addMe){
if (addMe) {
QSignalBlocker block(ui->lw_references);
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
@@ -266,7 +252,7 @@ void TaskFemConstraintHeatflux::addToSelection()
void TaskFemConstraintHeatflux::removeFromSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -275,38 +261,38 @@ void TaskFemConstraintHeatflux::removeFromSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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!"));
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
const std::vector<std::string>& subNames = it->getSubNames();
App::DocumentObject* obj = it->getObject();
if (subNames.size() > 0){
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){
if (subNames.size() > 0) {
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {
if (subNames[subIt].substr(0, 4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Selection must only consist of faces!"));
return;
}
}
}
else{
else {
//fix me, if an object is selected completely, getSelectionEx does not return any SubElements
}
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<std::string>::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();
@@ -339,15 +325,15 @@ const std::string TaskFemConstraintHeatflux::getReferences() const
double TaskFemConstraintHeatflux::getAmbientTemp(void) const
{
Base::Quantity temperature = ui->if_ambienttemp->getQuantity();
Base::Quantity temperature = ui->if_ambienttemp->getQuantity();
double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin);
return temperature_in_kelvin;
}
double TaskFemConstraintHeatflux::getFilmCoef(void) const
{
Base::Quantity filmcoef = ui->if_filmcoef->getQuantity();
double filmcoef_in_units = filmcoef.getValueAs(Base::Quantity(1.0,Base::Unit::ThermalTransferCoefficient));
Base::Quantity filmcoef = ui->if_filmcoef->getQuantity();
double filmcoef_in_units = filmcoef.getValueAs(Base::Quantity(1.0, Base::Unit::ThermalTransferCoefficient));
return filmcoef_in_units;
}
@@ -355,18 +341,19 @@ std::string TaskFemConstraintHeatflux::get_constraint_type(void) const {
std::string type;
if (ui->rb_convection->isChecked()) {
type = "\"Convection\"";
} else if (ui->rb_dflux->isChecked()) {
}
else if (ui->rb_dflux->isChecked()) {
type = "\"DFlux\"";
}
return type;
}
bool TaskFemConstraintHeatflux::event(QEvent *e)
bool TaskFemConstraintHeatflux::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintHeatflux::changeEvent(QEvent *e)
void TaskFemConstraintHeatflux::changeEvent(QEvent* e)
{
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
@@ -390,7 +377,7 @@ void TaskFemConstraintHeatflux::clearButtons(const SelectionChangeModes notThis)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintHeatflux::TaskDlgFemConstraintHeatflux(ViewProviderFemConstraintHeatflux *ConstraintView)
TaskDlgFemConstraintHeatflux::TaskDlgFemConstraintHeatflux(ViewProviderFemConstraintHeatflux* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -408,7 +395,7 @@ void TaskDlgFemConstraintHeatflux::open()
QString msg = QObject::tr("Constraint heat flux");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
@@ -419,15 +406,15 @@ bool TaskDlgFemConstraintHeatflux::accept()
std::string scale = "1";
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.AmbientTemp = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.AmbientTemp = %f",
name.c_str(), parameterHeatflux->getAmbientTemp());
/*Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.FaceTemp = %f",
name.c_str(), parameterHeatflux->getFaceTemp());*/
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.FilmCoef = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.FilmCoef = %f",
name.c_str(), parameterHeatflux->getFilmCoef());
scale = parameterHeatflux->getScale(); //OvG: determine modified scale
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s",
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) {
@@ -441,7 +428,7 @@ bool TaskDlgFemConstraintHeatflux::accept()
bool TaskDlgFemConstraintHeatflux::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;

View File

@@ -26,33 +26,15 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintInitialTemperature.h"
#include <Gui/Command.h>
#include <Mod/Fem/App/FemConstraintInitialTemperature.h>
#include "TaskFemConstraintInitialTemperature.h"
#include "ui_TaskFemConstraintInitialTemperature.h"
#include <App/Application.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
using namespace FemGui;
@@ -60,8 +42,8 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintInitialTemperature */
TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature(ViewProviderFemConstraintInitialTemperature *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintInitialTemperature")
TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature(ViewProviderFemConstraintInitialTemperature* ConstraintView, QWidget* parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintInitialTemperature")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintInitialTemperature();
@@ -89,12 +71,12 @@ TaskFemConstraintInitialTemperature::~TaskFemConstraintInitialTemperature()
double TaskFemConstraintInitialTemperature::get_temperature() const
{
Base::Quantity temperature = ui->if_temperature->getQuantity();
Base::Quantity temperature = ui->if_temperature->getQuantity();
double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin);
return temperature_in_kelvin;
}
void TaskFemConstraintInitialTemperature::changeEvent(QEvent *)
void TaskFemConstraintInitialTemperature::changeEvent(QEvent*)
{
}
@@ -102,7 +84,7 @@ void TaskFemConstraintInitialTemperature::changeEvent(QEvent *)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintInitialTemperature::TaskDlgFemConstraintInitialTemperature(ViewProviderFemConstraintInitialTemperature *ConstraintView)
TaskDlgFemConstraintInitialTemperature::TaskDlgFemConstraintInitialTemperature(ViewProviderFemConstraintInitialTemperature* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -119,7 +101,7 @@ void TaskDlgFemConstraintInitialTemperature::open()
QString msg = QObject::tr("Constraint initial temperature");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
@@ -129,11 +111,11 @@ bool TaskDlgFemConstraintInitialTemperature::accept()
const TaskFemConstraintInitialTemperature* parameterTemperature = static_cast<const TaskFemConstraintInitialTemperature*>(parameter);
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.initialTemperature = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.initialTemperature = %f",
name.c_str(), parameterTemperature->get_temperature());
std::string scale = parameterTemperature->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()));
@@ -141,10 +123,10 @@ bool TaskDlgFemConstraintInitialTemperature::accept()
}
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
if (!ConstraintView->getObject()->isValid())
throw Base::RuntimeError(ConstraintView->getObject()->getStatusString());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
@@ -158,7 +140,7 @@ bool TaskDlgFemConstraintInitialTemperature::accept()
bool TaskDlgFemConstraintInitialTemperature::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;

View File

@@ -20,36 +20,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <sstream>
#endif
#include "TaskFemConstraintOnBoundary.h"
#include <App/Application.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/SelectionObject.h>
using namespace FemGui;
@@ -57,7 +30,7 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintOnBoundary */
TaskFemConstraintOnBoundary::TaskFemConstraintOnBoundary(ViewProviderFemConstraint *ConstraintView, QWidget *parent, const char* pixmapname)
TaskFemConstraintOnBoundary::TaskFemConstraintOnBoundary(ViewProviderFemConstraint* ConstraintView, QWidget* parent, const char* pixmapname)
: TaskFemConstraint(ConstraintView, parent, pixmapname)
, selChangeMode(SelectionChangeModes::none)
{
@@ -78,11 +51,13 @@ void TaskFemConstraintOnBoundary::_addToSelection(bool checked)
this->clearButtons(SelectionChangeModes::refAdd);
selChangeMode = SelectionChangeModes::refAdd;
ConstraintView->highlightReferences(true);
} else {
}
else {
this->addToSelection();
clearButtons(SelectionChangeModes::none);
}
} else {
}
else {
exitSelectionChangeMode();
}
}
@@ -96,16 +71,18 @@ void TaskFemConstraintOnBoundary::_removeFromSelection(bool checked)
this->clearButtons(SelectionChangeModes::refRemove);
selChangeMode = SelectionChangeModes::refRemove;
ConstraintView->highlightReferences(true);
} else {
}
else {
this->removeFromSelection();
clearButtons(SelectionChangeModes::none);
}
} else {
}
else {
exitSelectionChangeMode();
}
}
void TaskFemConstraintOnBoundary::onSelectionChanged(const Gui::SelectionChanges&msg)
void TaskFemConstraintOnBoundary::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (msg.Type == Gui::SelectionChanges::AddSelection) {
switch (selChangeMode) {

View File

@@ -27,51 +27,30 @@
#ifndef _PreComp_
# include <sstream>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <Precision.hxx>
# include <TopoDS.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Plane.hxx>
# include <gp_Pln.hxx>
# include <gp_Ax1.hxx>
# include <BRepAdaptor_Curve.hxx>
# include <Geom_Line.hxx>
# include <gp_Lin.hxx>
#endif
#include "TaskFemConstraintPlaneRotation.h"
#include "ui_TaskFemConstraintPlaneRotation.h"
#include <App/Application.h>
#include <App/Document.h>
#include <App/PropertyGeo.h>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Gui/Selection.h>
#include <Gui/SelectionObject.h>
#include <App/DocumentObject.h>
#include <Gui/Command.h>
#include <Gui/SelectionObject.h>
#include <Gui/ViewProvider.h>
#include <Mod/Fem/App/FemConstraintPlaneRotation.h>
#include <Mod/Fem/App/FemTools.h>
#include <Mod/Part/App/PartFeature.h>
#include "TaskFemConstraintPlaneRotation.h"
#include "ui_TaskFemConstraintPlaneRotation.h"
using namespace FemGui;
using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintPlaneRotation */
TaskFemConstraintPlaneRotation::TaskFemConstraintPlaneRotation(ViewProviderFemConstraintPlaneRotation *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintPlaneRotation")
TaskFemConstraintPlaneRotation::TaskFemConstraintPlaneRotation(ViewProviderFemConstraintPlaneRotation* ConstraintView, QWidget* parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintPlaneRotation")
{ //Note change "planerotation" in line above to new constraint name
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintPlaneRotation();
@@ -82,14 +61,14 @@ TaskFemConstraintPlaneRotation::TaskFemConstraintPlaneRotation(ViewProviderFemCo
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*)));
this->groupLayout()->addWidget(proxy);
/* Note: */
/* Note: */
// Get the feature data
Fem::ConstraintPlaneRotation* pcConstraint = static_cast<Fem::ConstraintPlaneRotation*>(ConstraintView->getObject());
@@ -107,8 +86,8 @@ TaskFemConstraintPlaneRotation::TaskFemConstraintPlaneRotation(ViewProviderFemCo
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
updateUI();
}
@@ -130,14 +109,14 @@ void TaskFemConstraintPlaneRotation::updateUI()
void TaskFemConstraintPlaneRotation::addToSelection()
{
int rows = ui->lw_references->model()->rowCount();
if (rows == 1){
if (rows == 1) {
QMessageBox::warning(this, tr("Selection error"), tr("Only one face can be selected for a plane rotation constraint!"));
Gui::Selection().clearSelection();
return;
}
else {
std::vector<Gui::SelectionObject> 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;
}
@@ -145,52 +124,52 @@ void TaskFemConstraintPlaneRotation::addToSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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<std::string>& subNames = it->getSubNames();
App::DocumentObject* obj = it->getObject();
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
const std::vector<std::string>& subNames = it->getSubNames();
App::DocumentObject* obj = it->getObject();
if (subNames.size() == 1){
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
bool addMe = true;
if ((subNames[subIt].substr(0, 4) != "Face")) {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
}
Part::Feature* feat = static_cast<Part::Feature*>(obj);
TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subNames[subIt].c_str());
if ((subNames[subIt].substr(0, 4) == "Face")) {
if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) {
QMessageBox::warning(this, tr("Selection error"), tr("Only planar faces can be picked"));
if (subNames.size() == 1) {
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element
bool addMe = true;
if ((subNames[subIt].substr(0, 4) != "Face")) {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
}
}
for (std::vector<std::string>::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 don't add
addMe=false;
Part::Feature* feat = static_cast<Part::Feature*>(obj);
TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subNames[subIt].c_str());
if ((subNames[subIt].substr(0, 4) == "Face")) {
if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) {
QMessageBox::warning(this, tr("Selection error"), tr("Only planar faces can be picked"));
return;
}
}
for (std::vector<std::string>::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 don't add
addMe = false;
}
}
if (addMe) {
QSignalBlocker block(ui->lw_references);
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
}
}
if (addMe){
QSignalBlocker block(ui->lw_references);
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
}
}
}
else {
QMessageBox::warning(this, tr("Selection error"), tr("Only one face can be selected for a plane rotation constraint!"));
Gui::Selection().clearSelection();
return;
}
//Update UI
pcConstraint->References.setValues(Objects, SubElements);
updateUI();
else {
QMessageBox::warning(this, tr("Selection error"), tr("Only one face can be selected for a plane rotation constraint!"));
Gui::Selection().clearSelection();
return;
}
//Update UI
pcConstraint->References.setValues(Objects, SubElements);
updateUI();
}
}
}
@@ -198,7 +177,7 @@ void TaskFemConstraintPlaneRotation::addToSelection()
void TaskFemConstraintPlaneRotation::removeFromSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -206,27 +185,27 @@ void TaskFemConstraintPlaneRotation::removeFromSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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<std::string>& subNames=it->getSubNames();
const std::vector<std::string>& 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<std::string>::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();
@@ -257,12 +236,12 @@ const std::string TaskFemConstraintPlaneRotation::getReferences() const
return TaskFemConstraint::getReferences(items);
}
bool TaskFemConstraintPlaneRotation::event(QEvent *e)
bool TaskFemConstraintPlaneRotation::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintPlaneRotation::changeEvent(QEvent *)
void TaskFemConstraintPlaneRotation::changeEvent(QEvent*)
{
}
@@ -270,7 +249,7 @@ void TaskFemConstraintPlaneRotation::changeEvent(QEvent *)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintPlaneRotation::TaskDlgFemConstraintPlaneRotation(ViewProviderFemConstraintPlaneRotation *ConstraintView)
TaskDlgFemConstraintPlaneRotation::TaskDlgFemConstraintPlaneRotation(ViewProviderFemConstraintPlaneRotation* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -288,7 +267,7 @@ void TaskDlgFemConstraintPlaneRotation::open()
QString msg = QObject::tr("Constraint planerotation");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
@@ -297,14 +276,14 @@ bool TaskDlgFemConstraintPlaneRotation::accept()
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintPlaneRotation* parameters = static_cast<const TaskFemConstraintPlaneRotation*>(parameter);
std::string scale = parameters->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
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintPlaneRotation::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;

View File

@@ -24,34 +24,17 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintPressure.h"
#include <Gui/Command.h>
#include <Gui/SelectionObject.h>
#include <Mod/Fem/App/FemConstraintPressure.h>
#include "TaskFemConstraintPressure.h"
#include "ui_TaskFemConstraintPressure.h"
#include <App/Application.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/SelectionObject.h>
#include <Mod/Part/App/PartFeature.h>
using namespace FemGui;
@@ -59,7 +42,7 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintPressure */
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent)
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure* ConstraintView, QWidget* parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintPressure")
{ //Note change "pressure" in line above to new constraint name
proxy = new QWidget(this);
@@ -71,7 +54,7 @@ TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPr
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*)));
@@ -81,7 +64,7 @@ TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPr
this->groupLayout()->addWidget(proxy);
/* Note: */
/* Note: */
// Get the feature data
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
@@ -95,7 +78,7 @@ TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPr
ui->if_pressure->setValue(p);
bool reversed = pcConstraint->Reversed.getValue();
ui->checkBoxReverse->setChecked(reversed);
/* */
/* */
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
@@ -132,12 +115,12 @@ void TaskFemConstraintPressure::onCheckReverse(const bool pressed)
{
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
pcConstraint->Reversed.setValue(pressed);
}
}
void TaskFemConstraintPressure::addToSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -145,7 +128,7 @@ void TaskFemConstraintPressure::addToSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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;
@@ -153,21 +136,21 @@ void TaskFemConstraintPressure::addToSelection()
const std::vector<std::string>& 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;
if (subNames[subIt].substr(0, 4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
}
if (subNames[subIt].substr(0, 4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
}
for (std::vector<std::string>::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
addMe=false;
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;
}
}
if (addMe){
if (addMe) {
QSignalBlocker block(ui->lw_references);
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
@@ -183,7 +166,7 @@ void TaskFemConstraintPressure::addToSelection()
void TaskFemConstraintPressure::removeFromSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -191,27 +174,27 @@ void TaskFemConstraintPressure::removeFromSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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!"));
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
const std::vector<std::string>& subNames=it->getSubNames();
const std::vector<std::string>& 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<std::string>::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr,SubElements.end(), subNames[subIt]))
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();
@@ -245,7 +228,7 @@ const std::string TaskFemConstraintPressure::getReferences() const
/* Note: */
double TaskFemConstraintPressure::get_Pressure() const
{
Base::Quantity pressure = ui->if_pressure->getQuantity();
Base::Quantity pressure = ui->if_pressure->getQuantity();
double pressure_in_MPa = pressure.getValueAs(Base::Quantity::MegaPascal);
return pressure_in_MPa;
}
@@ -255,12 +238,12 @@ bool TaskFemConstraintPressure::get_Reverse() const
return ui->checkBoxReverse->isChecked();
}
bool TaskFemConstraintPressure::event(QEvent *e)
bool TaskFemConstraintPressure::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintPressure::changeEvent(QEvent *)
void TaskFemConstraintPressure::changeEvent(QEvent*)
{
}
@@ -276,7 +259,7 @@ void TaskFemConstraintPressure::clearButtons(const SelectionChangeModes notThis)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintPressure::TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView)
TaskDlgFemConstraintPressure::TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -294,36 +277,36 @@ void TaskDlgFemConstraintPressure::open()
QString msg = QObject::tr("Constraint pressure");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
bool TaskDlgFemConstraintPressure::accept()
{
/* Note: */
/* Note: */
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintPressure* parameterPressure = static_cast<const TaskFemConstraintPressure*>(parameter);
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Pressure = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Pressure = %f",
name.c_str(), parameterPressure->get_Pressure());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %s",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Reversed = %s",
name.c_str(), parameterPressure->get_Reverse() ? "True" : "False");
std::string scale = parameterPressure->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()));
return false;
}
/* */
/* */
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintPressure::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;

View File

@@ -21,36 +21,27 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QMessageBox>
#endif
#include "ui_TaskFemConstraintBearing.h"
#include "TaskFemConstraintPulley.h"
#include <App/Application.h>
#include <App/Document.h>
#include <App/PropertyGeo.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/ViewProvider.h>
#include <Mod/Fem/App/FemConstraintPulley.h>
#include <Mod/Part/App/PartFeature.h>
#include <Base/Console.h>
#include "TaskFemConstraintPulley.h"
#include "ui_TaskFemConstraintBearing.h"
using namespace FemGui;
using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintPulley */
TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley *ConstraintView,QWidget *parent)
TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley* ConstraintView, QWidget* parent)
: TaskFemConstraintGear(ConstraintView, parent, "FEM_ConstraintPulley")
{
connect(ui->spinOtherDiameter, SIGNAL(valueChanged(double)),
@@ -157,7 +148,7 @@ double TaskFemConstraintPulley::getCenterDistance(void) const
return ui->spinCenterDistance->value();
}
void TaskFemConstraintPulley::changeEvent(QEvent *e)
void TaskFemConstraintPulley::changeEvent(QEvent* e)
{
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
@@ -178,7 +169,7 @@ void TaskFemConstraintPulley::changeEvent(QEvent *e)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintPulley::TaskDlgFemConstraintPulley(ViewProviderFemConstraintPulley *ConstraintView)
TaskDlgFemConstraintPulley::TaskDlgFemConstraintPulley(ViewProviderFemConstraintPulley* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -196,7 +187,7 @@ void TaskDlgFemConstraintPulley::open()
QString msg = QObject::tr("Constraint pulley");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
@@ -207,10 +198,10 @@ bool TaskDlgFemConstraintPulley::accept()
try {
//Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "FEM pulley constraint changed"));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.OtherDiameter = %f",name.c_str(), parameterPulley->getOtherDiameter());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.CenterDistance = %f",name.c_str(), parameterPulley->getCenterDistance());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.IsDriven = %s",name.c_str(), parameterPulley->getIsDriven() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.TensionForce = %f",name.c_str(), parameterPulley->getTensionForce());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.OtherDiameter = %f", name.c_str(), parameterPulley->getOtherDiameter());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.CenterDistance = %f", name.c_str(), parameterPulley->getCenterDistance());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.IsDriven = %s", name.c_str(), parameterPulley->getIsDriven() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TensionForce = %f", name.c_str(), parameterPulley->getTensionForce());
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));

View File

@@ -24,34 +24,18 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintSpring.h"
#include "TaskFemConstraintSpring.h"
#include "ui_TaskFemConstraintSpring.h"
#include <App/Application.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/SelectionObject.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Fem/App/FemConstraintSpring.h>
#include "TaskFemConstraintSpring.h"
#include "ui_TaskFemConstraintSpring.h"
using namespace FemGui;
@@ -59,8 +43,8 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintSpring */
TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring *ConstraintView, QWidget *parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintSpring")
TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring* ConstraintView, QWidget* parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintSpring")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintSpring();
@@ -71,14 +55,14 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring
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*)));
this->groupLayout()->addWidget(proxy);
/* Note: */
/* Note: */
// Get the feature data
Fem::ConstraintSpring* pcConstraint = static_cast<Fem::ConstraintSpring*>(ConstraintView->getObject());
@@ -97,7 +81,7 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring
Base::Quantity ts = Base::Quantity((pcConstraint->tangentialStiffness.getValue()), Base::Unit::Stiffness);
ui->if_tan->setValue(ts);
/* */
/* */
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
@@ -134,7 +118,7 @@ void TaskFemConstraintSpring::updateUI()
void TaskFemConstraintSpring::addToSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -142,7 +126,7 @@ void TaskFemConstraintSpring::addToSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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;
@@ -150,21 +134,21 @@ void TaskFemConstraintSpring::addToSelection()
const std::vector<std::string>& 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;
if (subNames[subIt].substr(0, 4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
}
if (subNames[subIt].substr(0, 4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
}
for (std::vector<std::string>::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
addMe=false;
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;
}
}
if (addMe){
if (addMe) {
QSignalBlocker block(ui->lw_references);
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
@@ -180,7 +164,7 @@ void TaskFemConstraintSpring::addToSelection()
void TaskFemConstraintSpring::removeFromSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -188,27 +172,27 @@ void TaskFemConstraintSpring::removeFromSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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!"));
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
const std::vector<std::string>& subNames=it->getSubNames();
const std::vector<std::string>& 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<std::string>::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr,SubElements.end(), subNames[subIt]))
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();
@@ -242,25 +226,25 @@ const std::string TaskFemConstraintSpring::getReferences() const
/* Note: */
double TaskFemConstraintSpring::get_normalStiffness() const
{
Base::Quantity stiffness = ui->if_norm->getQuantity();
Base::Quantity stiffness = ui->if_norm->getQuantity();
double stiffness_double = stiffness.getValueAs(Base::Quantity::NewtonPerMeter);
return stiffness_double;
}
double TaskFemConstraintSpring::get_tangentialStiffness() const
{
Base::Quantity stiffness = ui->if_tan->getQuantity();
Base::Quantity stiffness = ui->if_tan->getQuantity();
double stiffness_double = stiffness.getValueAs(Base::Quantity::NewtonPerMeter);
return stiffness_double;
}
bool TaskFemConstraintSpring::event(QEvent *e)
bool TaskFemConstraintSpring::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintSpring::changeEvent(QEvent *)
void TaskFemConstraintSpring::changeEvent(QEvent*)
{
}
@@ -276,7 +260,7 @@ void TaskFemConstraintSpring::clearButtons(const SelectionChangeModes notThis)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintSpring::TaskDlgFemConstraintSpring(ViewProviderFemConstraintSpring *ConstraintView)
TaskDlgFemConstraintSpring::TaskDlgFemConstraintSpring(ViewProviderFemConstraintSpring* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -294,37 +278,37 @@ void TaskDlgFemConstraintSpring::open()
QString msg = QObject::tr("Constraint spring");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
bool TaskDlgFemConstraintSpring::accept()
{
/* Note: */
/* Note: */
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintSpring* parameterStiffness = static_cast<const TaskFemConstraintSpring*>(parameter);
//const TaskFemConstraintSpring* parameterTan = static_cast<const TaskFemConstraintSpring>(parameter);
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.normalStiffness = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.normalStiffness = %f",
name.c_str(), parameterStiffness->get_normalStiffness());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.tangentialStiffness = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.tangentialStiffness = %f",
name.c_str(), parameterStiffness->get_tangentialStiffness());
std::string scale = parameterStiffness->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()));
return false;
}
/* */
/* */
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintSpring::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;

View File

@@ -26,35 +26,18 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <sstream>
# include <QAction>
# include <QMessageBox>
# include <QKeyEvent>
# include <QRegExp>
# include <QTextStream>
#endif
#include "Mod/Fem/App/FemConstraintTemperature.h"
#include <App/Document.h>
#include <Gui/Command.h>
#include <Gui/SelectionObject.h>
#include <Mod/Fem/App/FemConstraintTemperature.h>
#include "TaskFemConstraintTemperature.h"
#include "ui_TaskFemConstraintTemperature.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/SelectionObject.h>
#include <Mod/Part/App/PartFeature.h>
using namespace FemGui;
@@ -62,8 +45,8 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintTemperature */
TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView,QWidget *parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintTemperature")
TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature* ConstraintView, QWidget* parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintTemperature")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintTemperature();
@@ -74,12 +57,12 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstr
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*)));
connect(ui->rb_temperature, SIGNAL(clicked(bool)), this, SLOT(Temp()));
connect(ui->rb_cflux, SIGNAL(clicked(bool)), this, SLOT(Flux()));
connect(ui->rb_temperature, SIGNAL(clicked(bool)), this, SLOT(Temp()));
connect(ui->rb_cflux, SIGNAL(clicked(bool)), this, SLOT(Flux()));
connect(ui->if_temperature, SIGNAL(valueChanged(double)),
this, SLOT(onTempCfluxChanged(double)));
@@ -104,7 +87,8 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstr
ui->lbl_type->setText(qstr);
Base::Quantity t = Base::Quantity(pcConstraint->Temperature.getValue(), Base::Unit::Temperature);
ui->if_temperature->setValue(t);
} else if (constraint_type == "CFlux") {
}
else if (constraint_type == "CFlux") {
ui->rb_cflux->setChecked(1);
std::string str = "Concentrated heat flux";
QString qstr = QString::fromStdString(str);
@@ -149,7 +133,8 @@ void TaskFemConstraintTemperature::onTempCfluxChanged(double val)
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
if (ui->rb_temperature->isChecked()) {
pcConstraint->Temperature.setValue(val);
} else {
}
else {
pcConstraint->CFlux.setValue(val);
}
}
@@ -158,7 +143,7 @@ void TaskFemConstraintTemperature::Temp()
{
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ConstraintType = %s",name.c_str(), get_constraint_type().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.ConstraintType = %s", name.c_str(), get_constraint_type().c_str());
std::string str = "Temperature";
QString qstr = QString::fromStdString(str);
ui->lbl_type->setText(qstr);
@@ -171,7 +156,7 @@ void TaskFemConstraintTemperature::Flux()
{
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ConstraintType = %s",name.c_str(), get_constraint_type().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.ConstraintType = %s", name.c_str(), get_constraint_type().c_str());
std::string str = "Concentrated heat flux";
QString qstr = QString::fromStdString(str);
ui->lbl_type->setText(qstr);
@@ -183,7 +168,7 @@ void TaskFemConstraintTemperature::Flux()
void TaskFemConstraintTemperature::addToSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -191,24 +176,24 @@ void TaskFemConstraintTemperature::addToSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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;
}
std::vector<std::string> subNames=it->getSubNames();
std::vector<std::string> subNames = it->getSubNames();
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
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<std::string>::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;
}
}
if (addMe){
if (addMe) {
QSignalBlocker block(ui->lw_references);
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
@@ -224,7 +209,7 @@ void TaskFemConstraintTemperature::addToSelection()
void TaskFemConstraintTemperature::removeFromSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -232,27 +217,27 @@ void TaskFemConstraintTemperature::removeFromSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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!"));
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
const std::vector<std::string>& subNames=it->getSubNames();
const std::vector<std::string>& 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<std::string>::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();
@@ -283,14 +268,14 @@ const std::string TaskFemConstraintTemperature::getReferences() const
return TaskFemConstraint::getReferences(items);
}
double TaskFemConstraintTemperature::get_temperature() const{
Base::Quantity temperature = ui->if_temperature->getQuantity();
double TaskFemConstraintTemperature::get_temperature() const {
Base::Quantity temperature = ui->if_temperature->getQuantity();
double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin);
return temperature_in_kelvin;
}
double TaskFemConstraintTemperature::get_cflux() const{
Base::Quantity cflux = ui->if_temperature->getQuantity();
double TaskFemConstraintTemperature::get_cflux() const {
Base::Quantity cflux = ui->if_temperature->getQuantity();
double cflux_in_watt = cflux.getValueAs(Base::Quantity::Watt);
return cflux_in_watt;
}
@@ -299,25 +284,26 @@ std::string TaskFemConstraintTemperature::get_constraint_type(void) const {
std::string type;
if (ui->rb_temperature->isChecked()) {
type = "\"Temperature\"";
} else if (ui->rb_cflux->isChecked()) {
}
else if (ui->rb_cflux->isChecked()) {
type = "\"CFlux\"";
}
return type;
}
bool TaskFemConstraintTemperature::event(QEvent *e)
bool TaskFemConstraintTemperature::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintTemperature::changeEvent(QEvent *)
void TaskFemConstraintTemperature::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 TaskFemConstraintTemperature::clearButtons(const SelectionChangeModes notThis)
@@ -332,7 +318,7 @@ void TaskFemConstraintTemperature::clearButtons(const SelectionChangeModes notTh
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintTemperature::TaskDlgFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView)
TaskDlgFemConstraintTemperature::TaskDlgFemConstraintTemperature(ViewProviderFemConstraintTemperature* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -350,7 +336,7 @@ void TaskDlgFemConstraintTemperature::open()
QString msg = QObject::tr("Constraint temperature");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
@@ -361,7 +347,7 @@ bool TaskDlgFemConstraintTemperature::accept()
try {
std::string scale = parameterTemperature->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()));
@@ -374,7 +360,7 @@ bool TaskDlgFemConstraintTemperature::accept()
bool TaskDlgFemConstraintTemperature::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;

View File

@@ -27,46 +27,29 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintTransform.h"
#include <Gui/Command.h>
#include <Gui/SelectionObject.h>
#include <Mod/Fem/App/FemConstraintTransform.h>
#include <Mod/Part/App/PartFeature.h>
#include "TaskFemConstraintTransform.h"
#include "ui_TaskFemConstraintTransform.h"
#include <App/Application.h>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/SelectionObject.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Fem/App/FemTools.h>
#include <math.h>
using namespace FemGui;
using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintTransform */
TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraintTransform *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintTransform")
TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraintTransform* ConstraintView, QWidget* parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintTransform")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintTransform();
@@ -78,7 +61,7 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraint
deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
// highlight seletcted list items in the model
connect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
connect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
connect(ui->lw_Rect, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
@@ -89,8 +72,8 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraint
this->groupLayout()->addWidget(proxy);
connect(ui->rb_rect, SIGNAL(clicked(bool)), this, SLOT(Rect()));
connect(ui->rb_cylin, SIGNAL(clicked(bool)), this, SLOT(Cyl()));
connect(ui->rb_rect, SIGNAL(clicked(bool)), this, SLOT(Rect()));
connect(ui->rb_cylin, SIGNAL(clicked(bool)), this, SLOT(Cyl()));
connect(ui->sp_X, SIGNAL(valueChanged(int)), this, SLOT(x_Changed(int)));
connect(ui->sp_Y, SIGNAL(valueChanged(int)), this, SLOT(y_Changed(int)));
@@ -111,7 +94,8 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraint
ui->sw_transform->setCurrentIndex(0);
ui->rb_rect->setChecked(1);
ui->rb_cylin->setChecked(0);
} else if (transform_type == "Cylindrical") {
}
else if (transform_type == "Cylindrical") {
ui->sw_transform->setCurrentIndex(1);
ui->rb_rect->setChecked(0);
ui->rb_cylin->setChecked(1);
@@ -120,7 +104,7 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraint
ui->lw_Rect->clear();
//Transformable surfaces
Gui::Command::doCommand(Gui::Command::Doc,TaskFemConstraintTransform::getSurfaceReferences((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str());
Gui::Command::doCommand(Gui::Command::Doc, TaskFemConstraintTransform::getSurfaceReferences((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str());
std::vector<App::DocumentObject*> ObjDispl = pcConstraint->RefDispl.getValues();
std::vector<std::string> SubElemDispl = pcConstraint->RefDispl.getSubValues();
@@ -143,17 +127,17 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraint
int p = 0;
for (std::size_t i = 0; i < ObjDispl.size(); i++) {
for (std::size_t j = 0; j < Objects.size(); j++) {
if ((makeRefText(ObjDispl[i], SubElemDispl[i]))==(makeRefText(Objects[j], SubElements[j]))){
if ((makeRefText(ObjDispl[i], SubElemDispl[i])) == (makeRefText(Objects[j], SubElements[j]))) {
p++;
}
}
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
updateUI();
if ((p==0) && (Objects.size() > 0)) {
if ((p == 0) && (Objects.size() > 0)) {
QMessageBox::warning(this, tr("Constraint update error"), tr("The transformable faces have changed. Please add only the transformable faces and remove non-transformable faces!"));
return;
}
@@ -178,43 +162,43 @@ void TaskFemConstraintTransform::updateUI()
}
}
void TaskFemConstraintTransform::x_Changed(int i){
void TaskFemConstraintTransform::x_Changed(int i) {
Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
double x = i;
pcConstraint->X_rot.setValue(x);
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.X_rot = %f", name.c_str(), x);
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.X_rot = %f", name.c_str(), x);
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
pcConstraint->References.setValues(Objects,SubElements);
pcConstraint->References.setValues(Objects, SubElements);
}
void TaskFemConstraintTransform::y_Changed(int i){
void TaskFemConstraintTransform::y_Changed(int i) {
Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
double y = i;
pcConstraint->Y_rot.setValue(y);
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Y_rot = %f", name.c_str(), y);
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Y_rot = %f", name.c_str(), y);
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
pcConstraint->References.setValues(Objects,SubElements);
pcConstraint->References.setValues(Objects, SubElements);
}
void TaskFemConstraintTransform::z_Changed(int i){
void TaskFemConstraintTransform::z_Changed(int i) {
Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
double z = i;
pcConstraint->Z_rot.setValue(z);
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Z_rot = %f", name.c_str(), z);
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Z_rot = %f", name.c_str(), z);
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
pcConstraint->References.setValues(Objects,SubElements);
pcConstraint->References.setValues(Objects, SubElements);
}
void TaskFemConstraintTransform::Rect(){
void TaskFemConstraintTransform::Rect() {
ui->sw_transform->setCurrentIndex(0);
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.TransformType = %s",name.c_str(), get_transform_type().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TransformType = %s", name.c_str(), get_transform_type().c_str());
Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
if (Objects.size() > 0) {
@@ -223,13 +207,13 @@ void TaskFemConstraintTransform::Rect(){
}
}
void TaskFemConstraintTransform::Cyl(){
void TaskFemConstraintTransform::Cyl() {
ui->sw_transform->setCurrentIndex(1);
ui->sp_X->setValue(0);
ui->sp_Y->setValue(0);
ui->sp_Z->setValue(0);
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.TransformType = %s",name.c_str(), get_transform_type().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TransformType = %s", name.c_str(), get_transform_type().c_str());
Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
if (Objects.size() > 0) {
@@ -243,18 +227,18 @@ void TaskFemConstraintTransform::addToSelection()
{
int rows = ui->lw_Rect->model()->rowCount();
std::vector<Gui::SelectionObject> 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;
}
if (rows==1){
if (rows == 1) {
QMessageBox::warning(this, tr("Selection error"), tr("Only one face for rectangular transform constraint!"));
Gui::Selection().clearSelection();
return;
}
if ((rows==0) && (selection.size()>=2)){
if ((rows == 0) && (selection.size() >= 2)) {
QMessageBox::warning(this, tr("Selection error"), tr("Only one face for rectangular transform constraint!"));
Gui::Selection().clearSelection();
return;
@@ -266,20 +250,20 @@ void TaskFemConstraintTransform::addToSelection()
std::vector<App::DocumentObject*> ObjDispl = pcConstraint->RefDispl.getValues();
std::vector<std::string> SubElemDispl = pcConstraint->RefDispl.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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!"));
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
const std::vector<std::string>& subNames = it->getSubNames();
App::DocumentObject* obj = it->getObject();
if (subNames.size() != 1){
if (subNames.size() != 1) {
QMessageBox::warning(this, tr("Selection error"), tr("Only one face for transform constraint!"));
Gui::Selection().clearSelection();
return;
}
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
bool addMe=true;
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element
bool addMe = true;
if (subNames[subIt].substr(0, 4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
@@ -295,27 +279,27 @@ void TaskFemConstraintTransform::addToSelection()
}
}
}
for (std::vector<std::string>::iterator itr=std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
for (std::vector<std::string>::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 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;
}
}
if (addMe){
disconnect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
if (addMe) {
disconnect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
for (std::size_t i = 0; i < ObjDispl.size(); i++) {
if ((makeRefText(ObjDispl[i], SubElemDispl[i])) == (makeRefText(obj, subNames[subIt]))){
if ((makeRefText(ObjDispl[i], SubElemDispl[i])) == (makeRefText(obj, subNames[subIt]))) {
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
ui->lw_Rect->addItem(makeRefText(obj, subNames[subIt]));
connect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
connect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
}
}
if (Objects.size() == 0){
if (Objects.size() == 0) {
QMessageBox::warning(this, tr("Selection error"), tr("Only transformable faces can be selected! Apply displacement constraint to surface first then apply constraint to surface"));
Gui::Selection().clearSelection();
return;
@@ -363,7 +347,7 @@ void TaskFemConstraintTransform::addToSelection()
void TaskFemConstraintTransform::removeFromSelection()
{
std::vector<Gui::SelectionObject> 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;
}
@@ -371,7 +355,7 @@ void TaskFemConstraintTransform::removeFromSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::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;
@@ -379,19 +363,19 @@ void TaskFemConstraintTransform::removeFromSelection()
const std::vector<std::string>& 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<std::string>::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();
@@ -422,14 +406,14 @@ void TaskFemConstraintTransform::onReferenceDeleted() {
TaskFemConstraintTransform::removeFromSelection();
}
std::string TaskFemConstraintTransform::getSurfaceReferences(std::string showConstr="")
std::string TaskFemConstraintTransform::getSurfaceReferences(std::string showConstr = "")
// https://forum.freecadweb.org/viewtopic.php?f=18&t=43650
{
return "\n\
doc = FreeCAD.ActiveDocument\n\
for obj in doc.Objects:\n\
if obj.isDerivedFrom(\"Fem::FemAnalysis\"):\n\
if doc."+showConstr+" in obj.Group:\n\
if doc." + showConstr + " in obj.Group:\n\
analysis = obj\n\
A = []\n\
i = 0\n\
@@ -450,41 +434,42 @@ for member in analysis.Group:\n\
ss.append(member)\n\
i = i+1\n\
if i>0:\n\
doc."+showConstr+".RefDispl = [x]\n\
doc."+showConstr+".NameDispl = ss\n\
doc." + showConstr + ".RefDispl = [x]\n\
doc." + showConstr + ".NameDispl = ss\n\
else:\n\
doc."+showConstr+".RefDispl = None\n\
doc."+showConstr+".NameDispl = []\n";
doc." + showConstr + ".RefDispl = None\n\
doc." + showConstr + ".NameDispl = []\n";
}
/* Note: */
double TaskFemConstraintTransform::get_X_rot() const{return ui->sp_X->value();}
double TaskFemConstraintTransform::get_Y_rot() const{return ui->sp_Y->value();}
double TaskFemConstraintTransform::get_Z_rot() const{return ui->sp_Z->value();}
double TaskFemConstraintTransform::get_X_rot() const { return ui->sp_X->value(); }
double TaskFemConstraintTransform::get_Y_rot() const { return ui->sp_Y->value(); }
double TaskFemConstraintTransform::get_Z_rot() const { return ui->sp_Z->value(); }
std::string TaskFemConstraintTransform::get_transform_type(void) const {
std::string transform;
if (ui->rb_rect->isChecked()) {
transform = "\"Rectangular\"";
} else if (ui->rb_cylin->isChecked()) {
}
else if (ui->rb_cylin->isChecked()) {
transform = "\"Cylindrical\"";
}
return transform;
}
bool TaskFemConstraintTransform::event(QEvent *e)
bool TaskFemConstraintTransform::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintTransform::changeEvent(QEvent *){
void TaskFemConstraintTransform::changeEvent(QEvent*) {
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintTransform::TaskDlgFemConstraintTransform(ViewProviderFemConstraintTransform *ConstraintView)
TaskDlgFemConstraintTransform::TaskDlgFemConstraintTransform(ViewProviderFemConstraintTransform* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -502,41 +487,41 @@ void TaskDlgFemConstraintTransform::open()
QString msg = QObject::tr("Constraint transform");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
bool TaskDlgFemConstraintTransform::accept()
{
/* Note: */
/* Note: */
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintTransform* parameters = static_cast<const TaskFemConstraintTransform*>(parameter);
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.X_rot = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.X_rot = %f",
name.c_str(), parameters->get_X_rot());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Y_rot = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Y_rot = %f",
name.c_str(), parameters->get_Y_rot());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Z_rot = %f",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Z_rot = %f",
name.c_str(), parameters->get_Z_rot());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.TransformType = %s",
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TransformType = %s",
name.c_str(), parameters->get_transform_type().c_str());
std::string scale = parameters->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()));
return false;
}
/* */
/* */
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintTransform::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;