From 3243f96972000edf9a00bd654212dc1d7d4342b3 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 3 Nov 2015 12:29:48 +0300 Subject: [PATCH] Enter processing is corrected according to modifications from Dev_1.5.0 (from BR_POSTPONED_PREVIEW) --- src/ModuleBase/ModuleBase_IModule.cpp | 2 +- src/ModuleBase/ModuleBase_IModule.h | 6 ++- src/PartSet/PartSet_Module.cpp | 11 +++-- src/PartSet/PartSet_Module.h | 6 ++- src/PartSet/PartSet_SketcherMgr.cpp | 7 +--- src/PartSet/PartSet_SketcherMgr.h | 2 +- src/PartSet/PartSet_SketcherReetntrantMgr.cpp | 40 +++++++++++-------- src/PartSet/PartSet_SketcherReetntrantMgr.h | 11 ++--- src/XGUI/XGUI_OperationMgr.cpp | 14 ++++--- 9 files changed, 60 insertions(+), 39 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 3cbe89b5b..29e89f3ef 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -78,7 +78,7 @@ const char* toString(ModelAPI_ExecState theExecState) #undef TO_STRING } -QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature) +QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI) { QString anError; if (!theFeature.get() || !theFeature->data()->isValid() || theFeature->isAction()) diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 41dbd6844..de02c0dfe 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -189,7 +189,7 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject //! Returns the feature error if the current state of the feature in the module is not correct //! If the feature is correct, it returns an empty value //! \return string value - virtual QString getFeatureError(const FeaturePtr& theFeature); + virtual QString getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI = true); /// Returns list of granted operation indices virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; @@ -203,6 +203,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param thePreviousState the previous state of the widget virtual void widgetStateChanged(int thePreviousState) {}; + /// Returns true if the event is processed. + /// \param thePreviousAttributeID an index of the previous active attribute + virtual bool processEnter(const std::string& thePreviousAttributeID) { return false; }; + signals: /// Signal which is emitted when operation is launched void operationLaunched(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 5861932e7..5358b23b1 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -400,11 +400,11 @@ void PartSet_Module::updateViewerMenu(const QMap& theStdActio myMenuMgr->updateViewerMenu(theStdActions); } -QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature) +QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI) { - QString anError = ModuleBase_IModule::getFeatureError(theFeature); + QString anError = ModuleBase_IModule::getFeatureError(theFeature, isCheckGUI); if (anError.isEmpty()) - anError = sketchMgr()->getFeatureError(theFeature); + anError = sketchMgr()->getFeatureError(theFeature, isCheckGUI); return anError; } @@ -1040,3 +1040,8 @@ void PartSet_Module::widgetStateChanged(int thePreviousState) { mySketchMgr->widgetStateChanged(thePreviousState); } + +bool PartSet_Module::processEnter(const std::string& thePreviousAttributeID) +{ + return mySketchReentrantMgr->processEnter(thePreviousAttributeID); +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index a120f3be6..1a726e212 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -206,7 +206,7 @@ public: //! Returns the feature error if the current state of the feature in the module is not correct //! If the feature is correct, it returns an empty value //! \return string value - virtual QString getFeatureError(const FeaturePtr& theFeature); + virtual QString getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI = true); /// Returns list of granted operation indices virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; @@ -215,6 +215,10 @@ public: /// \thePrevState the previous widget value state virtual void widgetStateChanged(int thePreviousState); + /// Returns true if the event is processed. It gives the reentrance manager to process the enter. + /// \param thePreviousAttributeID an index of the previous active attribute + virtual bool processEnter(const std::string& thePreviousAttributeID); + public slots: /// 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, diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 4f89da66c..ff37f0462 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -605,9 +605,6 @@ void PartSet_SketcherMgr::onApplicationStarted() aReentranceMgr, SLOT(onWidgetActivated())); } - XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); - connect(anOpMgr, SIGNAL(keyEnterReleased()), aReentranceMgr, SLOT(onEnterReleased())); - XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer(); connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort())); connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort())); @@ -678,7 +675,7 @@ bool PartSet_SketcherMgr::sketchSolverError() return anError; } -QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature) +QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI) { QString anError = ""; if (!theFeature.get() || !theFeature->data()->isValid()) @@ -691,7 +688,7 @@ QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature) } else { ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); - if (anActiveWidget) { + if (isCheckGUI && anActiveWidget) { ModuleBase_ModelWidget::ValueState aState = anActiveWidget->getValueState(); if (aState != ModuleBase_ModelWidget::Stored) { AttributePtr anAttr = anActiveWidget->feature()->attribute(anActiveWidget->attributeID()); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 577f9601d..c815b9c0c 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -180,7 +180,7 @@ public: //! Incorrect states: the feature is sketch, the solver error value //! The feature value is reset, this is the flag of sketch mgr //! \return string value - QString getFeatureError(const FeaturePtr& theFeature); + QString getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI = true); /// Returns list of strings which contains id's of sketch operations static const QStringList& sketchOperationIdList(); diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 302dbded4..a5ae29b26 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -173,25 +173,44 @@ void PartSet_SketcherReetntrantMgr::onNoMoreWidgets(const std::string& thePrevio { if (!isActiveMgr()) return; - XGUI_OperationMgr* anOpMgr = workshop()->operationMgr(); - if (!anOpMgr->isApplyEnabled()) - return; ModuleBase_OperationFeature* aFOperation = dynamic_cast (myWorkshop->currentOperation()); + if (!myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty()) + return; + if (aFOperation) { if (PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) { - XGUI_OperationMgr* anOpMgr = workshop()->operationMgr(); if (myRestartingMode != RM_Forbided) { myRestartingMode = RM_LastFeatureUsed; startInternalEdit(thePreviousAttributeID); } - else + else { aFOperation->commit(); + } } } } +bool PartSet_SketcherReetntrantMgr::processEnter(const std::string& thePreviousAttributeID) +{ + bool isDone = false; + + if (!isActiveMgr()) + return isDone; + + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (myWorkshop->currentOperation()); + if (!myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty()) + return isDone; + + myRestartingMode = RM_EmptyFeatureUsed; + startInternalEdit(thePreviousAttributeID); + isDone = true; + + return isDone; +} + void PartSet_SketcherReetntrantMgr::onVertexSelected() { if (!isActiveMgr()) @@ -217,17 +236,6 @@ void PartSet_SketcherReetntrantMgr::onVertexSelected() } } -void PartSet_SketcherReetntrantMgr::onEnterReleased() -{ - if (!isActiveMgr()) - return; - - ModuleBase_OperationFeature* aFOperation = dynamic_cast - (myWorkshop->currentOperation()); - if (myIsInternalEditOperation) - myRestartingMode = RM_EmptyFeatureUsed; -} - void PartSet_SketcherReetntrantMgr::onBeforeStopped() { ModuleBase_OperationFeature* aFOperation = dynamic_cast diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.h b/src/PartSet/PartSet_SketcherReetntrantMgr.h index b72cc047d..156de40d9 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.h +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.h @@ -51,6 +51,12 @@ public: /// or return null. If the current widget of the operation is a viewer selector, it returns null. ModuleBase_ModelWidget* internalActiveWidget() const; + /// if the internal flags allow it and the manager is active, it starts an internal edit operation + /// for the created operation. + /// \param thePreviousAttributeID an index of the previous active attribute + //bool restartOperation(const std::string& thePreviousAttributeID); + bool processEnter(const std::string& thePreviousAttributeID); + /// Resets the internal flags /// \param theOperation a started operation void operationStarted(ModuleBase_Operation* theOperation); @@ -100,11 +106,6 @@ private slots: /// the current feature is a line and there are not obligate widgets anymore void onVertexSelected(); - /// SLOT, that is called by enter key released - /// Set a specific type of restarting the current operation to do not use the feature - /// for initialization of a new started operation. - void onEnterReleased(); - /// Deactivates selection and filters of the first operation widget if it is an internal /// 'edit' operation void onBeforeStopped(); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index e169adcd5..8a9076633 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -503,13 +503,15 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget(); if (!aActiveWgt || !aActiveWgt->processEnter()) { - ModuleBase_OperationFeature* aFOperation = dynamic_cast(currentOperation()); - if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) { - emit keyEnterReleased(); - commitOperation(); + if (!myWorkshop->module()->processEnter(aActiveWgt->attributeID())) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast(currentOperation()); + if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty()) { + emit keyEnterReleased(); + commitOperation(); + } + else + isAccepted = false; } - else - isAccepted = false; } } break; -- 2.39.2