From fb6327a29cb44836388e29ef7d06137fad863a49 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 2 Jun 2014 08:10:30 +0400 Subject: [PATCH] =?utf8?q?refs=20#78:=20reported=20by=20Herv=C3=A9=20Legra?= =?utf8?q?nd:=20do=20not=20create=20segment=20if=20mouse=20moved=20out=20o?= =?utf8?q?f=203D=20viewer=20without=20click?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit the canBeCommitted() method is implemented. --- src/ModuleBase/ModuleBase_IOperation.cpp | 5 +++++ src/ModuleBase/ModuleBase_IOperation.h | 4 ++++ src/PartSet/PartSet_OperationSketchLine.cpp | 5 +++++ src/PartSet/PartSet_OperationSketchLine.h | 6 +++++- src/XGUI/XGUI_OperationMgr.cpp | 8 ++++++-- 5 files changed, 25 insertions(+), 3 deletions(-) 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() -- 2.39.2