#endif
ModuleBase_OperationFeature::ModuleBase_OperationFeature(const QString& theId, QObject* theParent)
-: ModuleBase_Operation(theId, theParent),
- myIsEditing(false)
+: ModuleBase_Operation(theId, theParent), myIsEditing(false), myNeedToBeAborted(false)
{
}
/// \return theFeature a feature
FeaturePtr previousCurrentFeature();
+ /// Set whether the operation should be aborted. By default the state is false in operation
+ /// \param theState abort state
+ void setNeedToBeAborted(const bool theState) { myNeedToBeAborted = theState; }
+
+ /// Returns valid state of the operation
+ /// \return custom validity state (it is almost always true)
+ bool isNeedToBeAborted() const { return myNeedToBeAborted; }
+
public slots:
/// Starts operation
/// Public slot. Verifies whether operation can be started and starts operation.
/// Editing feature flag
bool myIsEditing;
+ /// State used only if the operation should not be commited
+ bool myNeedToBeAborted;
+
/// List of pre-selected object
QList<std::shared_ptr<ModuleBase_ViewerPrs>> myPreSelection;
return;
if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
- bool isStarted = false;
- if (!module()->sketchMgr()->sketchSolverError()) {
- if (myRestartingMode != RM_Forbided) {
- myRestartingMode = RM_LastFeatureUsed;
- isStarted = startInternalEdit(thePreviousAttributeID);
+ if (aFOperation->isNeedToBeAborted()) {
+ aFOperation->abort();
+ }
+ else {
+ bool isStarted = false;
+ if (!module()->sketchMgr()->sketchSolverError()) {
+ if (myRestartingMode != RM_Forbided) {
+ myRestartingMode = RM_LastFeatureUsed;
+ isStarted = startInternalEdit(thePreviousAttributeID);
+ }
}
+ if (!isStarted)
+ aFOperation->commit();
}
- if (!isStarted)
- aFOperation->commit();
}
}
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
if (anActiveWgt)
+ {
isAccepted = anActiveWgt && anActiveWgt->processAction(ActionEscape);
+ if (isAccepted) {
+ ModuleBase_OperationFeature* aFOperation =
+ dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
+ if (aFOperation)
+ aFOperation->setNeedToBeAborted(true);
+ }
+ }
}
if (!isAccepted)
{