]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Edit created feature after noMoreWidgets. Restart the creation operation by click...
authornds <nds@opencascade.com>
Mon, 26 Oct 2015 12:51:21 +0000 (15:51 +0300)
committernds <nds@opencascade.com>
Mon, 26 Oct 2015 12:51:21 +0000 (15:51 +0300)
src/ModuleBase/ModuleBase_IPropertyPanel.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_Workshop.cpp

index c8c0f17215af55092aa3e6c2247a1677ac39490d..6335c5b67437337d1b12a8be2a048a0d9cdf7a1c 100644 (file)
@@ -78,7 +78,8 @@ signals:
   void widgetActivated(ModuleBase_ModelWidget* theWidget);
 
   /// Emited when there is no next widget
-  void noMoreWidgets();
+  /// \param thePreviousAttributeID an attribute key of the previous active widget
+  void noMoreWidgets(const std::string& thePreviousAttributeID);
 
 public slots:
   /// Activate the next widget in the property panel
index ac927a6fc829a29b21b12dde0f5b9876faf12d32..bbe6d029300518cb130f01521d083b3552a34dbb 100755 (executable)
@@ -253,7 +253,7 @@ void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation)
   }
 
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
-  if (!aFOperation || aFOperation->isEditOperation())
+  if (!aFOperation)
     return;
   // the selection is cleared after commit the create operation
   // in order to do not use the same selected objects in the restarted operation
@@ -270,10 +270,34 @@ void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation)
                      myRestartingMode == RM_EmptyFeatureUsed)) {
     myLastOperationId = aFOperation->id();
     myLastFeature = myRestartingMode == RM_LastFeatureUsed ? aFOperation->feature() : FeaturePtr();
-    if (!sketchMgr()->sketchSolverError())
-      launchOperation(myLastOperationId);
+    if (!sketchMgr()->sketchSolverError()) {
+      if (!aFOperation->isEditOperation()) {
+        FeaturePtr anOperationFeature = aFOperation->feature();
+        if (anOperationFeature.get() != NULL) {
+          editFeature(anOperationFeature);
+          // 4. activate the first obligatory widget
+          if (!myPreviousAttributeID.empty()) {
+            ModuleBase_Operation* anEditOperation = currentOperation();
+            if (anEditOperation) {
+              ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
+              ModuleBase_ModelWidget* aPreviousAttributeWidget = 0;
+              QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+              for (int i = 0, aNb = aWidgets.size(); i < aNb && !aPreviousAttributeWidget; i++) {
+                if (aWidgets[i]->attributeID() == myPreviousAttributeID)
+                  aPreviousAttributeWidget = aWidgets[i];
+              }
+              if (aPreviousAttributeWidget)
+                aPreviousAttributeWidget->focusTo();
+            }
+          }
+        }
+      }
+      else {
+        launchOperation(myLastOperationId);
+        breakOperationSequence();
+      }
+    }
   }
-  breakOperationSequence();
 }
 
 void PartSet_Module::breakOperationSequence()
@@ -557,7 +581,10 @@ void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* the
 
 void PartSet_Module::onEnterReleased()
 {
-  myRestartingMode = RM_EmptyFeatureUsed;
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                                  (currentOperation());
+  if (!aFOperation->isEditOperation())
+    myRestartingMode = RM_EmptyFeatureUsed;
 }
 
 void PartSet_Module::onOperationActivatedByPreselection()
@@ -572,13 +599,15 @@ void PartSet_Module::onOperationActivatedByPreselection()
   }
 }
 
-void PartSet_Module::onNoMoreWidgets()
+void PartSet_Module::onNoMoreWidgets(const std::string& thePreviousAttributeID)
 {
   ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
   if (anOperation) {
     if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
-      if (myRestartingMode != RM_Forbided)
+      if (myRestartingMode != RM_Forbided) {
         myRestartingMode = RM_LastFeatureUsed;
+        myPreviousAttributeID = thePreviousAttributeID;
+      }
       XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
       XGUI_Workshop* aWorkshop = aConnector->workshop();
       XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
index 6f79f809283059866917d0d294430681e317cf8e..5128d3f193e1c4d253bfc46a0012f54fcc2f542c 100644 (file)
@@ -206,7 +206,7 @@ public:
 public slots:
   /// SLOT, that is called by no more widget signal emitted by property panel
   /// Set a specific flag to restart the sketcher operation
-  void onNoMoreWidgets();
+  void onNoMoreWidgets(const std::string& thePreviousAttributeID);
 
   /// 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,
@@ -274,6 +274,8 @@ protected slots:
    QString myLastOperationId;
    FeaturePtr myLastFeature;
 
+   std::string myPreviousAttributeID;
+
    // Automatical restarting mode flag
    RestartingMode myRestartingMode;
 
index 83a388576ba9ef3969c0e449005cbd1f1434cd26..968457ffe19d1e90074e8f6158a4f4b5223ab051 100644 (file)
@@ -118,9 +118,9 @@ void XGUI_ActionsMgr::update()
     }
     // TODO(SBH): Get defaults state of actions from XML and remove the following method
     updateByDocumentKind();
-    updateCheckState();
     updateByPlugins(anActiveFeature);
   }
+  updateCheckState();
 }
 
 void XGUI_ActionsMgr::updateCheckState()
index 3838f78868d384e056105fdf810ee01a6d28aeef..d1eea76877338175fb693231fc0153611709a193 100644 (file)
@@ -197,7 +197,9 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
   if (theWidget == myActiveWidget) {
     return;
   }
+  std::string aPreviosAttributeID;
   if(myActiveWidget) {
+    aPreviosAttributeID = myActiveWidget->attributeID();
     myActiveWidget->deactivate();
     myActiveWidget->setHighlighted(false);
   }
@@ -210,8 +212,8 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
   if (myActiveWidget) {
     emit widgetActivated(theWidget);
   } else if (!isEditingMode()) {
-    emit noMoreWidgets();
-    setFocusOnOkButton();
+    emit noMoreWidgets(aPreviosAttributeID);
+    //setFocusOnOkButton();
   }
 }
 
index 3af0fc6e30b7b9554c69e7a3a722057ca38ef801..4f5e03c28dac1759a55079d49c98c5ee27f83c4d 100644 (file)
@@ -1010,7 +1010,8 @@ void XGUI_Workshop::createDockWidgets()
 
   QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort);
   connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation()));
-  connect(myPropertyPanel, SIGNAL(noMoreWidgets()), myModule, SLOT(onNoMoreWidgets()));
+  connect(myPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)),
+          myModule, SLOT(onNoMoreWidgets(const std::string&)));
   connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)),
           myOperationMgr,  SLOT(onKeyReleased(QKeyEvent*)));
   //connect(myOperationMgr,  SIGNAL(validationStateChanged(bool)),