From: nds Date: Mon, 2 Jun 2014 04:10:30 +0000 (+0400) Subject: refs #78: reported by Hervé Legrand: do not create segment if mouse moved out of... X-Git-Tag: V_0.4.4~336^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fb6327a29cb44836388e29ef7d06137fad863a49;p=modules%2Fshaper.git refs #78: reported by Hervé Legrand: do not create segment if mouse moved out of 3D viewer without click the canBeCommitted() method is implemented. --- diff --git a/src/ModuleBase/ModuleBase_IOperation.cpp b/src/ModuleBase/ModuleBase_IOperation.cpp index 390cf96d2..378af8663 100644 --- a/src/ModuleBase/ModuleBase_IOperation.cpp +++ b/src/ModuleBase/ModuleBase_IOperation.cpp @@ -31,6 +31,11 @@ ModuleBase_OperationDescription* ModuleBase_IOperation::getDescription() const return myDescription; } +bool ModuleBase_IOperation::canBeCommitted() const +{ + return true; +} + bool ModuleBase_IOperation::isGranted(ModuleBase_IOperation* /*theOperation*/) const { return false; diff --git a/src/ModuleBase/ModuleBase_IOperation.h b/src/ModuleBase/ModuleBase_IOperation.h index ae10a849b..4af5c227f 100644 --- a/src/ModuleBase/ModuleBase_IOperation.h +++ b/src/ModuleBase/ModuleBase_IOperation.h @@ -55,6 +55,10 @@ public: /// /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 diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index fa16b1bf9..4ca7d3200 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -54,6 +54,11 @@ PartSet_OperationSketchLine::~PartSet_OperationSketchLine() { } +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(); diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h index 69a26936a..cda1781c4 100644 --- a/src/PartSet/PartSet_OperationSketchLine.h +++ b/src/PartSet/PartSet_OperationSketchLine.h @@ -36,7 +36,11 @@ public: /// 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; diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 3fb2cad89..514c5b2f1 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -115,8 +115,12 @@ bool XGUI_OperationMgr::canStopOperation() 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()