]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Commit of the current operation if the preselection is activated.
authornds <natalia.donis@opencascade.com>
Thu, 11 Dec 2014 11:57:27 +0000 (14:57 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 11 Dec 2014 11:57:27 +0000 (14:57 +0300)
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_Workshop.cpp

index 89b1957d30a4585c5d0827674d2c6875c7645df6..58d0c2d9c0e51ce2c9a84d76c542b0b50982f892 100644 (file)
@@ -232,13 +232,15 @@ void ModuleBase_Operation::setRunning(bool theState)
 
 bool ModuleBase_Operation::activateByPreselection()
 {
-  if (!myPropertyPanel)
-    return false;
-  if (myPreSelection.empty())
+  if (!myPropertyPanel || myPreSelection.empty()) {
+    myPropertyPanel->activateNextWidget(NULL);
     return false;
+  }
   const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
-  if (aWidgets.empty())
+  if (aWidgets.empty()) {
+    myPropertyPanel->activateNextWidget(NULL);
     return false;
+  }
   
   ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0;
   QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
@@ -261,19 +263,14 @@ bool ModuleBase_Operation::activateByPreselection()
       aFilledWgt = aWgt;
     }
   }
-  if (isSet && canBeCommitted()) {
-    // if all widgets are filled with selection - commit
-    // in order to commit the operation outside of starting procedure - use timer event
-    QTimer::singleShot(50, this, SLOT(commit()));
+
+  if (aFilledWgt) {
+    myPropertyPanel->activateNextWidget(aFilledWgt);
+    emit activatedByPreselection();
     return true;
   }
-  else {
-    //activate next widget
-    if (aFilledWgt) {
-      myPropertyPanel->activateNextWidget(aFilledWgt);
-      return true;
-    }
-  }
+  else
+    myPropertyPanel->activateNextWidget(NULL);
   return false;
 }
 
index acefc9ee8613acb1222096260aab10763487fb55..17233f0f289c25dac63bc012466e1d79e18be90f 100644 (file)
@@ -142,6 +142,7 @@ signals:
   void stopped();  /// the operation is aborted or committed
   void resumed();  /// the operation is resumed
   void postponed();  /// the operation is postponed
+  void activatedByPreselection(); /// the operation is filled with existing preselection
 
  public slots:
   /// Starts operation
index 886c5765890cf95cbca239ddccbec35bbaf0e6df..4ac9d96b709666849d749de12eb6d65399f03d2c 100644 (file)
@@ -248,8 +248,10 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged()
 
   //QObjectPtrList aObjects = myWorkshop->selection()->selectedPresentations();
   QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected();
-  if (aSelected.size() > 0)
-    setSelection(aSelected.first());
+  if (aSelected.size() > 0) {
+    if (setSelection(aSelected.first()))
+      emit focusOutWidget(this);
+  }
 }
 
 //********************************************************************
@@ -306,7 +308,6 @@ bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue)
   }
   if (isValid(aObject, aShape)) {
     setObject(aObject, aShape);
-    emit focusOutWidget(this);
     return true;
   }
   return false;
index 65cc6e200a0113957f69b1458b402138b6666cb5..b47766109400766128c4500219ebca36d200086d 100644 (file)
@@ -112,6 +112,8 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 
   XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
   connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
+  connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
+          this, SLOT(onOperationActivatedByPreselection()));
 
   connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
           this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
@@ -570,6 +572,24 @@ void PartSet_Module::onEnterReleased()
   myRestartingMode = RM_EmptyFeatureUsed;
 }
 
+void PartSet_Module::onOperationActivatedByPreselection()
+{
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  if (!aOperation)
+    return;
+
+  // Set final definitions if they are necessary
+  //propertyPanelDefined(aOperation);
+
+  /// Commit sketcher operations automatically
+  FeaturePtr aFeature = aOperation->feature();
+  std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+            std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+  if (aSPFeature) {
+    aOperation->commit();
+  }
+}
+
 void PartSet_Module::onNoMoreWidgets()
 {
   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
index b2edc3205cc91cb2d5f738eb4b7156ea20c22440..129df5353712c3eee24cb768c238807cdadfb8be 100644 (file)
@@ -96,6 +96,10 @@ protected slots:
   /// Set a specific type of restarting the current operation
   void onEnterReleased();
 
+  /// SLOT, that is called by the current operation filling with the preselection.
+  /// It commits the operation of it is can be committed
+  void onOperationActivatedByPreselection();
+
   /// Launches the operation from current highlighting
   void launchEditing();
 
index 94e5026e251f9d7b5502bbcf4096fafa14854847..4a5449caf2e66607ad4d0105a4d3599ae383e501 100644 (file)
@@ -103,6 +103,8 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
   connect(theOperation, SIGNAL(committed()), SLOT(onOperationComitted()));
   connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
   connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
+  connect(theOperation, SIGNAL(activatedByPreselection()),
+          SIGNAL(operationActivatedByPreselection()));
 
   theOperation->start();
   onValidateOperation();
index 29a340b0dad6dc55092248d56aa861fe2fbfe66a..8c8acfb3d7468a2bd16e90f08a9b26e4c8dc3b50 100644 (file)
@@ -108,9 +108,13 @@ signals:
   /// Signal is emitted after the validate methods calls.
   void operationValidated(bool);
 
+  /// Signal is emitted after the current operation is filled with existing preselection.
+  void operationActivatedByPreselection();
+
   /// Signal is emitted after the key released click.
   void keyEnterReleased();
 
+
  protected:
 
   /// Commits the current operatin if it is valid
index b77c27bbdf8fcf4660233f91d6d9927a7948e063..91041203fbebba9cb8d49beae6d96b76ea0999a9 100644 (file)
@@ -593,8 +593,7 @@ void XGUI_Workshop::onOperationStarted()
     // Do not activate widgets by default if the current operation is editing operation
     // Because we don't know which widget is going to be edited. 
     if ((!aOperation->isEditOperation())) {
-      if (!aOperation->activateByPreselection())
-        myPropertyPanel->activateNextWidget(NULL);
+      aOperation->activateByPreselection();
     }
     // Set final definitions if they are necessary
     myModule->propertyPanelDefined(aOperation);