+ fix whitespaces

This commit is contained in:
wmayer 2015-05-26 17:55:38 +02:00
parent cd4952dee4
commit 24b71377e1
6 changed files with 314 additions and 318 deletions

View File

@ -1,24 +1,24 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Author: Przemo Firszt <przemo@firszt.eu> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* Copyright (c) 2015 FreeCAD Developers *
* Author: Przemo Firszt <przemo@firszt.eu> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
@ -41,41 +41,41 @@ PROPERTY_SOURCE(Fem::ConstraintPressure, Fem::Constraint);
ConstraintPressure::ConstraintPressure()
{
ADD_PROPERTY(Pressure,(0.0));
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintPressure",
App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where arrows are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintPressure",
App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
ADD_PROPERTY(Pressure,(0.0));
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintPressure",
App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where arrows are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintPressure",
App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintPressure::execute(void)
{
return Constraint::execute();
return Constraint::execute();
}
const char* ConstraintPressure::getViewProviderName(void) const
{
return "FemGui::ViewProviderFemConstraintPressure";
return "FemGui::ViewProviderFemConstraintPressure";
}
void ConstraintPressure::onChanged(const App::Property* prop)
{
Constraint::onChanged(prop);
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
if (getPoints(points, normals)) {
Points.setValues(points);
Normals.setValues(normals);
Points.touch();
}
} else if (prop == &Reversed) {
Points.touch();
}
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
if (getPoints(points, normals)) {
Points.setValues(points);
Normals.setValues(normals);
Points.touch();
}
} else if (prop == &Reversed) {
Points.touch();
}
}

View File

@ -29,26 +29,27 @@
namespace Fem {
class AppFemExport ConstraintPressure : public Fem::Constraint {
PROPERTY_HEADER(Fem::ConstraintPressure);
class AppFemExport ConstraintPressure : public Fem::Constraint
{
PROPERTY_HEADER(Fem::ConstraintPressure);
public:
ConstraintPressure(void);
public:
ConstraintPressure(void);
App::PropertyFloat Pressure;
App::PropertyBool Reversed;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
App::PropertyFloat Pressure;
App::PropertyBool Reversed;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/// recalculate the object
virtual App::DocumentObjectExecReturn *execute(void);
/// recalculate the object
virtual App::DocumentObjectExecReturn *execute(void);
/// returns the type name of the ViewProvider
const char* getViewProviderName(void) const;
/// returns the type name of the ViewProvider
const char* getViewProviderName(void) const;
protected:
virtual void onChanged(const App::Property* prop);
};
protected:
virtual void onChanged(const App::Property* prop);
};
}

View File

@ -51,173 +51,175 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintPressure */
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "Fem_ConstraintPressure")
: TaskFemConstraint(ConstraintView, parent, "Fem_ConstraintPressure")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintPressure();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintPressure();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
QAction* action = new QAction(tr("Delete"), ui->lw_references);
action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
ui->lw_references->addAction(action);
ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);
QAction* action = new QAction(tr("Delete"), ui->lw_references);
action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
ui->lw_references->addAction(action);
ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->if_pressure, SIGNAL(valueChanged(Base::Quantity)),
this, SLOT(onPressureChanged(Base::Quantity)));
connect(ui->b_add_reference, SIGNAL(pressed()),
this, SLOT(onButtonReference()));
connect(ui->cb_reverse_direction, SIGNAL(toggled(bool)),
this, SLOT(onCheckReverse(bool)));
connect(ui->if_pressure, SIGNAL(valueChanged(Base::Quantity)),
this, SLOT(onPressureChanged(Base::Quantity)));
connect(ui->b_add_reference, SIGNAL(pressed()),
this, SLOT(onButtonReference()));
connect(ui->cb_reverse_direction, SIGNAL(toggled(bool)),
this, SLOT(onCheckReverse(bool)));
this->groupLayout()->addWidget(proxy);
this->groupLayout()->addWidget(proxy);
// Temporarily prevent unnecessary feature recomputes
ui->if_pressure->blockSignals(true);
ui->lw_references->blockSignals(true);
ui->b_add_reference->blockSignals(true);
ui->cb_reverse_direction->blockSignals(true);
// Temporarily prevent unnecessary feature recomputes
ui->if_pressure->blockSignals(true);
ui->lw_references->blockSignals(true);
ui->b_add_reference->blockSignals(true);
ui->cb_reverse_direction->blockSignals(true);
// Get the feature data
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
double f = pcConstraint->Pressure.getValue();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
bool reversed = pcConstraint->Reversed.getValue();
// Get the feature data
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
double f = pcConstraint->Pressure.getValue();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
bool reversed = pcConstraint->Reversed.getValue();
// Fill data into dialog elements
ui->if_pressure->setMinimum(0);
ui->if_pressure->setMaximum(FLOAT_MAX);
//1000 because FreeCAD used kPa internally
Base::Quantity p = Base::Quantity(1000 * f, Base::Unit::Stress);
double val = p.getValueAs(Base::Quantity::MegaPascal);
ui->if_pressure->setValue(p);
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
}
if (Objects.size() > 0) {
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
}
ui->cb_reverse_direction->setChecked(reversed);
// Fill data into dialog elements
ui->if_pressure->setMinimum(0);
ui->if_pressure->setMaximum(FLOAT_MAX);
//1000 because FreeCAD used kPa internally
Base::Quantity p = Base::Quantity(1000 * f, Base::Unit::Stress);
double val = p.getValueAs(Base::Quantity::MegaPascal);
ui->if_pressure->setValue(p);
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
}
if (Objects.size() > 0) {
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
}
ui->cb_reverse_direction->setChecked(reversed);
ui->if_pressure->blockSignals(false);
ui->lw_references->blockSignals(false);
ui->b_add_reference->blockSignals(false);
ui->cb_reverse_direction->blockSignals(false);
ui->if_pressure->blockSignals(false);
ui->lw_references->blockSignals(false);
ui->b_add_reference->blockSignals(false);
ui->cb_reverse_direction->blockSignals(false);
updateUI();
updateUI();
}
TaskFemConstraintPressure::~TaskFemConstraintPressure()
{
delete ui;
delete ui;
}
void TaskFemConstraintPressure::updateUI()
{
if (ui->lw_references->model()->rowCount() == 0) {
// Go into reference selection mode if no reference has been selected yet
onButtonReference(true);
return;
}
if (ui->lw_references->model()->rowCount() == 0) {
// Go into reference selection mode if no reference has been selected yet
onButtonReference(true);
return;
}
}
void TaskFemConstraintPressure::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if ((msg.Type != Gui::SelectionChanges::AddSelection) ||
// Don't allow selection in other document
(strcmp(msg.pDocName, ConstraintView->getObject()->getDocument()->getName()) != 0) ||
// Don't allow selection mode none
(selectionMode != selref) ||
// Don't allow empty smenu/submenu
(!msg.pSubName || msg.pSubName[0] == '\0')) {
return;
}
if ((msg.Type != Gui::SelectionChanges::AddSelection) ||
// Don't allow selection in other document
(strcmp(msg.pDocName, ConstraintView->getObject()->getDocument()->getName()) != 0) ||
// Don't allow selection mode none
(selectionMode != selref) ||
// Don't allow empty smenu/submenu
(!msg.pSubName || msg.pSubName[0] == '\0')) {
return;
}
std::string subName(msg.pSubName);
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(msg.pObjectName);
std::string subName(msg.pSubName);
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(msg.pObjectName);
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
if (subName.substr(0,4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
}
// Avoid duplicates
std::size_t pos = 0;
for (; pos < Objects.size(); pos++)
if (obj == Objects[pos])
break;
if (subName.substr(0,4) != "Face") {
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
return;
}
// Avoid duplicates
std::size_t pos = 0;
for (; pos < Objects.size(); pos++) {
if (obj == Objects[pos])
break;
}
if (pos != Objects.size())
if (subName == SubElements[pos])
return;
if (pos != Objects.size()) {
if (subName == SubElements[pos])
return;
}
// add the new reference
Objects.push_back(obj);
SubElements.push_back(subName);
pcConstraint->References.setValues(Objects,SubElements);
ui->lw_references->addItem(makeRefText(obj, subName));
// add the new reference
Objects.push_back(obj);
SubElements.push_back(subName);
pcConstraint->References.setValues(Objects,SubElements);
ui->lw_references->addItem(makeRefText(obj, subName));
// Turn off reference selection mode
onButtonReference(false);
Gui::Selection().clearSelection();
updateUI();
// Turn off reference selection mode
onButtonReference(false);
Gui::Selection().clearSelection();
updateUI();
}
void TaskFemConstraintPressure::onPressureChanged(const Base::Quantity& f)
{
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
double val = f.getValueAs(Base::Quantity::MegaPascal);
pcConstraint->Pressure.setValue(val);
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
double val = f.getValueAs(Base::Quantity::MegaPascal);
pcConstraint->Pressure.setValue(val);
}
void TaskFemConstraintPressure::onReferenceDeleted() {
int row = ui->lw_references->currentIndex().row();
TaskFemConstraint::onReferenceDeleted(row);
ui->lw_references->model()->removeRow(row);
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
int row = ui->lw_references->currentIndex().row();
TaskFemConstraint::onReferenceDeleted(row);
ui->lw_references->model()->removeRow(row);
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
}
void TaskFemConstraintPressure::onCheckReverse(const bool pressed)
{
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
pcConstraint->Reversed.setValue(pressed);
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
pcConstraint->Reversed.setValue(pressed);
}
const std::string TaskFemConstraintPressure::getReferences() const
{
int rows = ui->lw_references->model()->rowCount();
std::vector<std::string> items;
for (int r = 0; r < rows; r++) {
items.push_back(ui->lw_references->item(r)->text().toStdString());
}
return TaskFemConstraint::getReferences(items);
int rows = ui->lw_references->model()->rowCount();
std::vector<std::string> items;
for (int r = 0; r < rows; r++) {
items.push_back(ui->lw_references->item(r)->text().toStdString());
}
return TaskFemConstraint::getReferences(items);
}
double TaskFemConstraintPressure::getPressure(void) const
{
Base::Quantity pressure = ui->if_pressure->getQuantity();
double pressure_in_MPa = pressure.getValueAs(Base::Quantity::MegaPascal);
return pressure_in_MPa;
Base::Quantity pressure = ui->if_pressure->getQuantity();
double pressure_in_MPa = pressure.getValueAs(Base::Quantity::MegaPascal);
return pressure_in_MPa;
}
bool TaskFemConstraintPressure::getReverse() const
{
return ui->cb_reverse_direction->isChecked();
return ui->cb_reverse_direction->isChecked();
}
void TaskFemConstraintPressure::changeEvent(QEvent *e)
{
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);
}
}
//**************************************************************************
@ -226,50 +228,50 @@ void TaskFemConstraintPressure::changeEvent(QEvent *e)
TaskDlgFemConstraintPressure::TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintPressure(ConstraintView);;
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintPressure(ConstraintView);;
Content.push_back(parameter);
Content.push_back(parameter);
}
//==== calls from the TaskView ===============================================================
void TaskDlgFemConstraintPressure::open()
{
// a transaction is already open at creation time of the panel
if (!Gui::Command::hasPendingCommand()) {
QString msg = QObject::tr("Constraint normal stress");
Gui::Command::openCommand((const char*)msg.toUtf8());
}
// a transaction is already open at creation time of the panel
if (!Gui::Command::hasPendingCommand()) {
QString msg = QObject::tr("Constraint normal stress");
Gui::Command::openCommand((const char*)msg.toUtf8());
}
}
bool TaskDlgFemConstraintPressure::accept()
{
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintPressure* parameterPressure = static_cast<const TaskFemConstraintPressure*>(parameter);
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",
name.c_str(), parameterPressure->getPressure());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %s",
name.c_str(), parameterPressure->getReverse() ? "True" : "False");
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what()));
return false;
}
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Pressure = %f",
name.c_str(), parameterPressure->getPressure());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %s",
name.c_str(), parameterPressure->getReverse() ? "True" : "False");
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what()));
return false;
}
return TaskDlgFemConstraint::accept();
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintPressure::reject()
{
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::updateActive();
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::updateActive();
return true;
return true;
}
#include "moc_TaskFemConstraintPressure.cpp"

View File

@ -34,45 +34,43 @@
class Ui_TaskFemConstraintPressure;
namespace App {
class Property;
}
namespace Gui {
class ViewProvider;
}
namespace FemGui {
class TaskFemConstraintPressure : public TaskFemConstraint {
Q_OBJECT public:
TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent = 0);
virtual ~TaskFemConstraintPressure();
double getPressure(void) const;
virtual const std::string getReferences() const;
bool getReverse(void) const;
class TaskFemConstraintPressure : public TaskFemConstraint
{
Q_OBJECT
private Q_SLOTS:
void onReferenceDeleted(void);
void onPressureChanged(const Base::Quantity & f);
void onCheckReverse(bool);
public:
TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent = 0);
virtual ~TaskFemConstraintPressure();
double getPressure(void) const;
virtual const std::string getReferences() const;
bool getReverse(void) const;
protected:
virtual void changeEvent(QEvent *e);
private Q_SLOTS:
void onReferenceDeleted(void);
void onPressureChanged(const Base::Quantity & f);
void onCheckReverse(bool);
private:
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
void updateUI();
Ui_TaskFemConstraintPressure* ui;
};
protected:
virtual void changeEvent(QEvent *e);
class TaskDlgFemConstraintPressure : public TaskDlgFemConstraint {
Q_OBJECT public:
TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView);
virtual void open();
virtual bool accept();
virtual bool reject();
private:
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
void updateUI();
Ui_TaskFemConstraintPressure* ui;
};
class TaskDlgFemConstraintPressure : public TaskDlgFemConstraint
{
Q_OBJECT
public:
TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView);
virtual void open();
virtual bool accept();
virtual bool reject();
};
};
} //namespace FemGui
#endif // GUI_TASKVIEW_TaskFemConstraintPressure_H

View File

@ -45,8 +45,8 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintPressure, FemGui::ViewProviderF
ViewProviderFemConstraintPressure::ViewProviderFemConstraintPressure()
{
sPixmap = "Fem_ConstraintPressure";
ADD_PROPERTY(FaceColor,(0.0f,0.2f,0.8f));
sPixmap = "Fem_ConstraintPressure";
ADD_PROPERTY(FaceColor,(0.0f,0.2f,0.8f));
}
ViewProviderFemConstraintPressure::~ViewProviderFemConstraintPressure()
@ -56,37 +56,37 @@ ViewProviderFemConstraintPressure::~ViewProviderFemConstraintPressure()
//FIXME setEdit needs a careful review
bool ViewProviderFemConstraintPressure::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
// When double-clicking on the item for this constraint the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgFemConstraintPressure *constrDlg = qobject_cast<TaskDlgFemConstraintPressure *>(dlg);
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = 0; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != NULL) {
// Ignore the request to open another dialog
return false;
} else {
constraintDialog = new TaskFemConstraintPressure(this);
return true;
}
}
if (ModNum == ViewProvider::Default) {
// When double-clicking on the item for this constraint the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgFemConstraintPressure *constrDlg = qobject_cast<TaskDlgFemConstraintPressure *>(dlg);
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = 0; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != NULL) {
// Ignore the request to open another dialog
return false;
} else {
constraintDialog = new TaskFemConstraintPressure(this);
return true;
}
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
// clear the selection (convenience)
Gui::Selection().clearSelection();
// start the edit dialog
if (constrDlg)
Gui::Control().showDialog(constrDlg);
else
Gui::Control().showDialog(new TaskDlgFemConstraintPressure(this));
return true;
}
else {
return ViewProviderDocumentObject::setEdit(ModNum);
}
// start the edit dialog
if (constrDlg)
Gui::Control().showDialog(constrDlg);
else
Gui::Control().showDialog(new TaskDlgFemConstraintPressure(this));
return true;
}
else {
return ViewProviderDocumentObject::setEdit(ModNum);
}
}
#define ARROWLENGTH 5
@ -94,50 +94,50 @@ bool ViewProviderFemConstraintPressure::setEdit(int ModNum)
void ViewProviderFemConstraintPressure::updateData(const App::Property* prop)
{
// Gets called whenever a property of the attached object changes
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(this->getObject());
// Gets called whenever a property of the attached object changes
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(this->getObject());
if (pShapeSep->getNumChildren() == 0) {
// Set up the nodes
SoMultipleCopy* cp = new SoMultipleCopy();
cp->ref();
cp->matrix.setNum(0);
cp->addChild((SoNode*)createArrow(ARROWLENGTH, ARROWHEADRADIUS));
pShapeSep->addChild(cp);
}
if (pShapeSep->getNumChildren() == 0) {
// Set up the nodes
SoMultipleCopy* cp = new SoMultipleCopy();
cp->ref();
cp->matrix.setNum(0);
cp->addChild((SoNode*)createArrow(ARROWLENGTH, ARROWHEADRADIUS));
pShapeSep->addChild(cp);
}
if (strcmp(prop->getName(),"Points") == 0) {
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();
if (points.size() != normals.size()) {
return;
}
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
if (strcmp(prop->getName(),"Points") == 0) {
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();
if (points.size() != normals.size()) {
return;
}
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
cp->matrix.setNum(points.size());
SbMatrix* matrices = cp->matrix.startEditing();
int idx = 0;
SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
cp->matrix.setNum(points.size());
SbMatrix* matrices = cp->matrix.startEditing();
int idx = 0;
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
SbVec3f base(p->x, p->y, p->z);
SbVec3f dir(n->x, n->y, n->z);
double rev;
if (pcConstraint->Reversed.getValue()) {
base = base + dir * ARROWLENGTH;
rev = 1;
} else {
rev = -1;
}
SbRotation rot(SbVec3f(0, rev, 0), dir);
SbMatrix m;
m.setTransform(base, rot, SbVec3f(1,1,1));
matrices[idx] = m;
idx++;
n++;
}
cp->matrix.finishEditing();
}
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
SbVec3f base(p->x, p->y, p->z);
SbVec3f dir(n->x, n->y, n->z);
double rev;
if (pcConstraint->Reversed.getValue()) {
base = base + dir * ARROWLENGTH;
rev = 1;
} else {
rev = -1;
}
SbRotation rot(SbVec3f(0, rev, 0), dir);
SbMatrix m;
m.setTransform(base, rot, SbVec3f(1,1,1));
matrices[idx] = m;
idx++;
n++;
}
cp->matrix.finishEditing();
}
ViewProviderFemConstraint::updateData(prop);
ViewProviderFemConstraint::updateData(prop);
}

View File

@ -28,25 +28,20 @@
#include <TopoDS_Shape.hxx>
#include "ViewProviderFemConstraint.h"
namespace Gui {
class View3DInventorViewer;
namespace TaskView {
class TaskDialog;
}
}
namespace FemGui {
class FemGuiExport ViewProviderFemConstraintPressure : public FemGui::ViewProviderFemConstraint {
PROPERTY_HEADER(FemGui::ViewProviderFemConstraintPressure);
class FemGuiExport ViewProviderFemConstraintPressure : public FemGui::ViewProviderFemConstraint
{
PROPERTY_HEADER(FemGui::ViewProviderFemConstraintPressure);
public:
ViewProviderFemConstraintPressure();
virtual ~ViewProviderFemConstraintPressure();
virtual void updateData(const App::Property*);
public:
ViewProviderFemConstraintPressure();
virtual ~ViewProviderFemConstraintPressure();
virtual void updateData(const App::Property*);
protected:
virtual bool setEdit(int ModNum);
};
protected:
virtual bool setEdit(int ModNum);
};
}
#endif // GUI_VIEWPROVIDERFEMCONSTRAINTPRESSURE_H