]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Enter processing is corrected according to modifications from Dev_1.5.0 (from BR_POST...
authornds <nds@opencascade.com>
Tue, 3 Nov 2015 09:29:48 +0000 (12:29 +0300)
committernds <nds@opencascade.com>
Tue, 3 Nov 2015 09:29:48 +0000 (12:29 +0300)
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.h
src/XGUI/XGUI_OperationMgr.cpp

index 3cbe89b5b4569b9970d29541b6cf10d410f037c0..29e89f3efff4863dffa23eccb418c231133f5a7a 100644 (file)
@@ -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())
index 41dbd684462e1261a6eab851b42cb66dc554199f..de02c0dfe5bf972adddf366c515562960c1a3cfe 100755 (executable)
@@ -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\r
   //! If the feature is correct, it returns an empty value\r
   //! \return string value\r
-  virtual QString getFeatureError(const FeaturePtr& theFeature);\r
+  virtual QString getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI = true);\r
 \r
   /// Returns list of granted operation indices\r
   virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;\r
@@ -203,6 +203,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param thePreviousState the previous state of the widget\r
   virtual void widgetStateChanged(int thePreviousState) {};\r
 \r
+  /// Returns true if the event is processed.\r
+  /// \param thePreviousAttributeID an index of the previous active attribute\r
+  virtual bool processEnter(const std::string& thePreviousAttributeID) { return false; };\r
+\r
 signals:\r
   /// Signal which is emitted when operation is launched\r
   void operationLaunched();\r
index 5861932e70b5487364aed8b9a0a8a50a1a149365..5358b23b1eb8df63241fd900b716c811c3fdc31e 100755 (executable)
@@ -400,11 +400,11 @@ void PartSet_Module::updateViewerMenu(const QMap<QString, QAction*>& 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);
+}
index a120f3be64bea3e9cd2ba99ef4729f827b2375d7..1a726e21268a9fa4ccd3c95aa670ad92ca8308a5 100755 (executable)
@@ -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,
index 4f89da66cb53fda5314ab793e16152e74b9471ca..ff37f046271aef492cc0f8be9901ee4c67390c9a 100755 (executable)
@@ -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());
index 577f9601d8a6006557fc23d42003e67a9f324566..c815b9c0c85afe2d5eed8b7e65ae31aaab450397 100644 (file)
@@ -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();
index 302dbded4fcf7dc9431689ec5d1334e3c271ad0f..a5ae29b2676b13f3c3c509b9f80766ebcd54a83c 100755 (executable)
@@ -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<ModuleBase_OperationFeature*>
                                                        (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<ModuleBase_OperationFeature*>
+                                                       (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<ModuleBase_OperationFeature*>
-                                                      (myWorkshop->currentOperation());
-  if (myIsInternalEditOperation)
-    myRestartingMode = RM_EmptyFeatureUsed;
-}
-
 void PartSet_SketcherReetntrantMgr::onBeforeStopped()
 {
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
index b72cc047deb5717be41230b78836531550bb96bc..156de40d9c85cc14e1a2185c2ca3e70d5af8a369 100755 (executable)
@@ -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();
index e169adcd5e32bcd00778fb3548f69577f0181804..8a9076633c1694fc1025e664191e3b14e919aa5a 100644 (file)
@@ -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<ModuleBase_OperationFeature*>(currentOperation());
-        if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
-          emit keyEnterReleased();
-          commitOperation();
+        if (!myWorkshop->module()->processEnter(aActiveWgt->attributeID())) {
+          ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
+          if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty()) {
+            emit keyEnterReleased();
+            commitOperation();
+          }
+          else
+            isAccepted = false;
         }
-        else
-          isAccepted = false;
       }
     }
     break;