+ use undo/redo for Fem constraint force dialog
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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();
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user