+ use undo/redo for Fem constraint force dialog

This commit is contained in:
wmayer
2015-02-27 11:21:05 +01:00
parent 36e4758b72
commit 6721139630
3 changed files with 25 additions and 0 deletions

View File

@@ -82,6 +82,10 @@ void ConstraintForce::onChanged(const App::Property* prop)
direction = -direction;
DirectionVector.setValue(direction);
} else if (prop == &Reversed) {
// if the direction is invalid try to compute it again
if (naturalDirectionVector.Length() < Precision::Confusion()) {
naturalDirectionVector = getDirection(Direction);
}
if (naturalDirectionVector.Length() >= Precision::Confusion()) {
if (Reversed.getValue() && (DirectionVector.getValue() == naturalDirectionVector)) {
DirectionVector.setValue(-naturalDirectionVector);

View File

@@ -329,6 +329,15 @@ TaskDlgFemConstraintForce::TaskDlgFemConstraintForce(ViewProviderFemConstraintFo
//==== calls from the TaskView ===============================================================
void TaskDlgFemConstraintForce::open()
{
// a transaction is already open at creation time of the panel
if (!Gui::Command::hasPendingCommand()) {
QString msg = QObject::tr("Constraint force");
Gui::Command::openCommand((const char*)msg.toUtf8());
}
}
bool TaskDlgFemConstraintForce::accept()
{
std::string name = ConstraintView->getObject()->getNameInDocument();
@@ -360,4 +369,14 @@ bool TaskDlgFemConstraintForce::accept()
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintForce::reject()
{
// roll back the changes
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::updateActive();
return true;
}
#include "moc_TaskFemConstraintForce.cpp"

View File

@@ -83,7 +83,9 @@ public:
TaskDlgFemConstraintForce(ViewProviderFemConstraintForce *ConstraintView);
/// is called by the framework if the dialog is accepted (Ok)
virtual void open();
virtual bool accept();
virtual bool reject();
};