]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 24 Dec 2014 13:44:51 +0000 (16:44 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 24 Dec 2014 13:44:51 +0000 (16:44 +0300)
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Workshop.cpp

index 00e90732e4cf4efeeaab495ead46ba72c097aa1f..e9cfa075f67bad5cf5122ded5504dd727fd3da76 100644 (file)
@@ -72,21 +72,6 @@ bool ModuleBase_Operation::isValid() const
   return aFactory->validate(myFeature);
 }
 
-//void ModuleBase_Operation::storeCustomValue()
-//{
-//  if (!myFeature) {
-//#ifdef _DEBUG
-//    qDebug() << "ModuleBase_Operation::storeCustom: " <<
-//    "trying to store value without opening a transaction.";
-//#endif
-//    return;
-//  }
-//
-//  ModuleBase_ModelWidget* aCustom = dynamic_cast<ModuleBase_ModelWidget*>(sender());
-//  if (aCustom)
-//    aCustom->storeValue();
-//}
-
 
 bool ModuleBase_Operation::canBeCommitted() const
 {
@@ -171,15 +156,13 @@ void ModuleBase_Operation::start()
 
 void ModuleBase_Operation::postpone()
 {
-  if (myPropertyPanel)
-    disconnect(myPropertyPanel, 0, this, 0);
+  postponeOperation();
   emit postponed();
 }
 
 void ModuleBase_Operation::resume()
 {
-  //  connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
-  //          this,            SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+  resumeOperation();
   emit resumed();
 }
 
@@ -187,8 +170,6 @@ void ModuleBase_Operation::abort()
 {
   abortOperation();
   emit aborted();
-  if (myPropertyPanel)
-    disconnect(myPropertyPanel, 0, this, 0);
 
   stopOperation();
 
@@ -199,9 +180,6 @@ void ModuleBase_Operation::abort()
 bool ModuleBase_Operation::commit()
 {
   if (canBeCommitted()) {
-    if (myPropertyPanel)
-      disconnect(myPropertyPanel, 0, this, 0);
-
     commitOperation();
     // check whether there are modifications performed during the current operation
     // in the model
@@ -347,8 +325,6 @@ void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp)
 { 
   myPropertyPanel = theProp; 
   myPropertyPanel->setEditingMode(isEditOperation());
-  //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
-  //        SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
 
   // 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. 
index a9333a7e8cf6796062e689e01f6cc068be5ebfcd..593758907ce179e7f908169e7580b849cc4d2e14 100644 (file)
@@ -205,6 +205,9 @@ signals:
   /// Virtual method called after operation committed (see commit() method for more description)
   virtual void afterCommitOperation() {}
 
+  /// Virtual method called after operation resume (see resume() method for more description)
+  virtual void resumeOperation() {}
+
   /// Send update message by loop
   void flushUpdated();
 
index 3f0846de18d86f9a4b894c193878ccf558bc29af..09bc3494f32fff71799e3cb536fcdd108b87348a 100644 (file)
@@ -144,11 +144,10 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
       if (aCustPrs.get() != NULL)
         aCustPrs->customisePresentation(theAIS);
     }
-    if (aCanBeShaded)
+    if (aCanBeShaded) {
       openLocalContext();
-
-    aContext->Load(anAISIO, -1, true);
-    activate(theObject);
+      activateObjects(myActiveSelectionModes);
+    }
   }
   if (isUpdateViewer)
     updateViewer();
@@ -230,16 +229,16 @@ void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
     AISObjectPtr anObj = myResult2AISObjectMap[theObject];
     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
     aContext->Deactivate(anAIS);
-    //if (aContext->HasOpenedContext()) {
-    //  aContext->Load(anAIS, -1, true);
-    //}
+    aContext->Load(anAIS, -1, true);
     // In order to clear active modes list
     if (theModes.size() > 0) {
       foreach(int aMode, theModes) {
+        //aContext->Load(anAIS, aMode, true);
         aContext->Activate(anAIS, aMode);
         qDebug("### 1. Activate obj %i, %i", (long)anAIS.Access(), aMode);
       }
     } else {
+      //aContext->Load(anAIS, 0, true);
       aContext->Activate(anAIS);
       qDebug("### 2. Activate obj %i", (long)anAIS.Access());
     }
@@ -249,11 +248,12 @@ void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
 void XGUI_Displayer::activateObjects(const QIntList& theModes)
 {
   // In order to avoid doblications of selection modes
-  myActiveSelectionModes.clear();
+  QIntList aNewModes;
   foreach (int aMode, theModes) {
-    if (!myActiveSelectionModes.contains(aMode))
-      myActiveSelectionModes.append(aMode);
+    if (!aNewModes.contains(aMode))
+      aNewModes.append(aMode);
   }
+  myActiveSelectionModes = aNewModes;
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // Open local context if there is no one
   if (!aContext->HasOpenedContext()) 
@@ -270,6 +270,7 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes)
   Handle(AIS_InteractiveObject) anAISIO;
   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
     anAISIO = aLIt.Value();
+    aContext->Load(anAISIO, -1, true);
     aContext->Deactivate(anAISIO);
     aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
     //Deactivate trihedron which can be activated in local selector
@@ -277,10 +278,12 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes)
       //aContext->Load(anAISIO, -1, true);
       // In order to clear active modes list
       if (myActiveSelectionModes.size() == 0) {
+        //aContext->Load(anAISIO, 0, true);
         aContext->Activate(anAISIO);
         qDebug("### 2. Activate all %i", (long)anAISIO.Access());
       } else {
         foreach(int aMode, myActiveSelectionModes) {
+          //aContext->Load(anAISIO, aMode, true);
           aContext->Activate(anAISIO, aMode);
           qDebug("### 1. Activate all %i, %i", (long)anAISIO.Access(), aMode);
         }
@@ -303,17 +306,16 @@ void XGUI_Displayer::deactivateObjects()
   displayedObjects(aContext, aPrsList);
 
   AIS_ListIteratorOfListOfInteractive aLIt;
-  Handle(AIS_Trihedron) aTrihedron;
+  //Handle(AIS_Trihedron) aTrihedron;
   Handle(AIS_InteractiveObject) anAISIO;
   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
     anAISIO = aLIt.Value();
     aContext->Deactivate(anAISIO);
-    aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
-    if (aTrihedron.IsNull()) {
-      //aContext->Load(anAISIO, -1, true);
-      qDebug("### Deactivate all %i", (long)anAISIO.Access());
-      //aContext->Activate(anAISIO);
-    }
+    //aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
+    //if (aTrihedron.IsNull()) {
+    //  qDebug("### Deactivate all %i", (long)anAISIO.Access());
+    //  //aContext->Activate(anAISIO);
+    //}
   }
 }
 
@@ -333,42 +335,6 @@ bool XGUI_Displayer::isActive(ObjectPtr theObject) const
   return aModes.Extent() > 0;
 }
 
-void XGUI_Displayer::stopSelection(const QObjectPtrList& theResults, const bool isStop,
-                                   const bool isUpdateViewer)
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (aContext.IsNull())
-    return;
-
-  Handle(AIS_Shape) anAIS;
-  QObjectPtrList::const_iterator anIt = theResults.begin(), aLast = theResults.end();
-  ObjectPtr aFeature;
-  for (; anIt != aLast; anIt++) {
-    aFeature = *anIt;
-    if (isVisible(aFeature))
-      anAIS = Handle(AIS_Shape)::DownCast(
-          myResult2AISObjectMap[aFeature]->impl<Handle(AIS_InteractiveObject)>());
-    if (anAIS.IsNull())
-      continue;
-
-    if (isStop) {
-      QColor aColor(Qt::white);
-      anAIS->SetColor(
-          Quantity_Color(aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255.,
-                         Quantity_TOC_RGB));
-      anAIS->Redisplay();
-    } else {
-      QColor aColor(Qt::red);
-      anAIS->SetColor(
-          Quantity_Color(aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255.,
-                         Quantity_TOC_RGB));
-      anAIS->Redisplay();
-    }
-  }
-  if (isUpdateViewer)
-    updateViewer();
-}
-
 void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -428,33 +394,6 @@ void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
      updateViewer();
  }
 
-//void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
-//{
-//  Handle(AIS_InteractiveContext) aContext = AISContext();
-//  if (aContext.IsNull())
-//    return;
-//
-//  QObjectPtrList aRemoved;
-//  foreach (ObjectPtr aFeature, myResult2AISObjectMap.keys()) {
-//    if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
-//      AISObjectPtr anObj = myResult2AISObjectMap[aFeature];
-//      if (!anObj)
-//        continue;
-//      Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
-//      if (!anAIS.IsNull()) {
-//        aContext->Remove(anAIS, false);
-//        aRemoved.append(aFeature);
-//      }
-//    }
-//  }
-//  foreach(ObjectPtr aObj, aRemoved) {
-//    myResult2AISObjectMap.remove(aObj);
-//  }
-//
-//  if (isUpdateViewer)
-//    updateViewer();
-//}
-
 void XGUI_Displayer::openLocalContext()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -481,7 +420,6 @@ void XGUI_Displayer::openLocalContext()
     //aContext->NotUseDisplayedObjects();
 
     //myUseExternalObjects = false;
-    myActiveSelectionModes.clear();
 
     SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
     for (;aIt.More(); aIt.Next()) {
@@ -533,7 +471,6 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
     if (isUpdateViewer)
       updateViewer();
     //myUseExternalObjects = false;
-    myActiveSelectionModes.clear();
 
     // Restore selection
     //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
index 2cc3bd4efb4b82cc356ca00eb491770b7b1293ae..0dfb1cae12935e1f2e7daab0d73f80d4b1dfa410 100644 (file)
@@ -56,13 +56,6 @@ class XGUI_EXPORT XGUI_Displayer
   /// Display the given AIS object. To hide this object use corresponde erase method
   void displayAIS(AISObjectPtr theAIS, bool isUpdate = true);
 
-  /// Stop the current selection and color the given features to the selection color
-  /// \param theFeatures a list of features to be disabled
-  /// \param theToStop the boolean state whether it it stopped or non stopped
-  /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void stopSelection(const QObjectPtrList& theFeatures, const bool isStop,
-                     const bool isUpdateViewer);
-
   /**
    * Add presentations which corresponds to the given features to current selection
    * \param theFeatures a list of features to be selected
@@ -86,10 +79,6 @@ class XGUI_EXPORT XGUI_Displayer
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   void eraseAll(const bool isUpdateViewer = true);
 
-  /// Erase AIS interactive objects, which has an empty feature in the internal map
-  /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  //void eraseDeletedResults(const bool isUpdateViewer = true);
-
   /// Deactivates selection of sub-shapes
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   void closeLocalContexts(const bool isUpdateViewer = true);
index fa583caead741b96b4c821e5adfb8c5a49a147cb..8d113e9d1eec0a1e2efa070116aa0c794d3aa5a1 100644 (file)
@@ -593,19 +593,21 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
 //******************************************************
 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
 {
+  ModuleBase_ISelection* aSel = mySelector->selection();
+  QObjectPtrList aObj = aSel->selectedPresentations();
   //!< No need for property panel
   updateCommandStatus();
   hidePropertyPanel();
   myPropertyPanel->cleanContent();
 
   // Activate objects created by current operation
-  FeaturePtr aFeature = theOperation->feature();
-  myDisplayer->activate(aFeature);
-  const std::list<ResultPtr>& aResults = aFeature->results();
-  std::list<ResultPtr>::const_iterator aIt;
-  for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-    myDisplayer->activate(*aIt);
-  }
+  //FeaturePtr aFeature = theOperation->feature();
+  //myDisplayer->activate(aFeature);
+  //const std::list<ResultPtr>& aResults = aFeature->results();
+  //std::list<ResultPtr>::const_iterator aIt;
+  //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+  //  myDisplayer->activate(*aIt);
+  //}
   myModule->operationStopped(theOperation);
 }