From: nds Date: Fri, 29 May 2015 11:32:39 +0000 (+0300) Subject: A fix to abort sketch operation if nothing is displayed in the viewer but values... X-Git-Tag: V_1.2.0~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f20c290aeb9798bac01d536293c1eeec90785e1b;p=modules%2Fshaper.git A fix to abort sketch operation if nothing is displayed in the viewer but values of the feature are valid Scenario: start line creation, click 1st point, click 2nd point, click circle feature. The line become visible(to origin) in the previous version. Currently it is aborted, nothing is shown. --- diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 6ae486f6c..81652a0b3 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -139,7 +139,7 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject public slots: /// Called on call of command corresponded to a feature - void onFeatureTriggered(); + virtual void onFeatureTriggered(); /// Slolt called on object display /// \param theObject a data object diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b71077c86..e33202da3 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -592,6 +592,30 @@ bool PartSet_Module::deleteObjects() return true; } +void PartSet_Module::onFeatureTriggered() +{ + SessionPtr aMgr = ModelAPI_Session::get(); + // 1. check whether the delete should be processed in the module + ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); + bool isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation); + if (isNestedOp) { + // in case if in the viewer nothing is displayed, the create operation should not be + // comitted even if all values of the feature are initialized + if (!mySketchMgr->canDisplayCurrentCreatedFeature()) { + QAction* aCmd = dynamic_cast(sender()); + //Do nothing on uncheck + if (aCmd->isCheckable() && !aCmd->isChecked()) + return; + + // the action information should be saved before the operation is aborted + // because this abort leads to update command status, which unchecks this action + anOperation->abort(); + + launchOperation(aCmd->data().toString()); + } + } + ModuleBase_IModule::onFeatureTriggered(); +} void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index a215774c8..2d1786d49 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -137,6 +137,11 @@ public slots: /// Set a specific flag to restart the sketcher operation void onNoMoreWidgets(); + /// Redefines the parent method in order to customize the next case: + /// If the sketch nested operation is active and the presentation is not visualized in the viewer, + /// the operation should be always aborted. + virtual void onFeatureTriggered(); + /// Slolt called on object display /// \param theObject a data object /// \param theAIS a presentation object diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 3ccdbf563..b128427a4 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -868,13 +868,18 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const if (!anEditorWdg && !myIsPopupMenuActive) { // during a nested create operation, the feature is redisplayed only if the mouse over view // of there was a value modified in the property panel after the mouse left the view - aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow; + aCanDisplay = canDisplayCurrentCreatedFeature(); } } #endif return aCanDisplay; } +bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const +{ + return myIsPropertyPanelValueChanged || myIsMouseOverWindow; +} + bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const { bool isFoundObject = false; diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index f82f450f5..389fbf3b8 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -140,6 +140,10 @@ public: /// \param theObject a model object bool canDisplayObject(const ObjectPtr& theObject) const; + /// Returns true if the mouse is over viewer or property panel value is changed + /// \return boolean result + bool canDisplayCurrentCreatedFeature() const; + /// Returns state of constraints showing flag bool isConstraintsShown() const { return myIsConstraintsShown; }