the canBeCommitted() method is implemented.
return myDescription;
}
+bool ModuleBase_IOperation::canBeCommitted() const
+{
+ return true;
+}
+
bool ModuleBase_IOperation::isGranted(ModuleBase_IOperation* /*theOperation*/) const
{
return false;
/// /returns the instance of the description class
ModuleBase_OperationDescription* getDescription() const;
+ /// Verifies whether this operator can be commited.
+ /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
+ virtual bool canBeCommitted() const;
+
/// Verifies whether this operator can be always started above any already running one
/// \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
/// This method must be redefined in derived operation if operation of derived class
{
}
+bool PartSet_OperationSketchLine::canBeCommitted() const
+{
+ return myPointSelectionMode == SM_DonePoint;
+}
+
bool PartSet_OperationSketchLine::isGranted(ModuleBase_IOperation* theOperation) const
{
return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
/// Destructor
virtual ~PartSet_OperationSketchLine();
- /// Returns that this operator can be started above already running one.
+ /// Verifies whether this operator can be commited.
+ /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
+ virtual bool canBeCommitted() const;
+
+ /// Returns that this operator can be started above already running one.
/// The runned operation should be the sketch feature modified operation
/// \param theOperation the previous running operation
virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
void XGUI_OperationMgr::onCommitOperation()
{
ModuleBase_Operation* anOperation = currentOperation();
- if (anOperation)
- anOperation->commit();
+ if (anOperation) {
+ if (anOperation->canBeCommitted())
+ anOperation->commit();
+ else
+ anOperation->abort();
+ }
}
void XGUI_OperationMgr::onAbortOperation()