]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Mon, 19 May 2014 15:24:40 +0000 (19:24 +0400)
committernds <natalia.donis@opencascade.com>
Mon, 19 May 2014 15:24:40 +0000 (19:24 +0400)
Restore selection after operation edit.

src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index 8f2ef6e4fcd893ac39722dc243fcde3f8775232f..198cfbe64dcc1250cc028f031274ad3a1aaecccb 100644 (file)
@@ -198,8 +198,16 @@ void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
 void PartSet_Module::onStopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop)
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-  aDisplayer->StopSelection(theFeatures, isStop);
-  
+  aDisplayer->StopSelection(theFeatures, isStop, false);
+  if (!isStop) {
+    std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+    boost::shared_ptr<ModelAPI_Feature> aFeature;
+    for (; anIt != aLast; anIt++) {
+      activateFeature((*anIt).feature(), false);
+    }
+  }
+  aDisplayer->SetSelected(theFeatures, false);
+  aDisplayer->UpdateViewer();
 }
 
 void PartSet_Module::onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
index cbfb9413cfb483fecdb4a6cda6d64873be08c666..d597eda0c6ac71df619d29ea8dbe45fd99399e4a 100644 (file)
@@ -120,6 +120,7 @@ void XGUI_Displayer::Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
       // If there was a problem here, try the first solution with close/open local context.
       anAIS->Set(theShape);
       anAIS->Redisplay();
+
       /*if (aContext->IsSelected(anAIS)) {
         aContext->AddOrRemoveSelected(anAIS, false);
         aContext->AddOrRemoveSelected(anAIS, false);
@@ -147,8 +148,6 @@ void XGUI_Displayer::ActivateInLocalContext(boost::shared_ptr<ModelAPI_Feature>
   Handle(AIS_Shape) anAIS;
   if (IsVisible(theFeature))
     anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[theFeature]);
-  //if (!anAIS.IsNull())
-  //  return;
 
   // Activate selection of objects from prs
   if (!anAIS.IsNull()) {
@@ -156,30 +155,19 @@ void XGUI_Displayer::ActivateInLocalContext(boost::shared_ptr<ModelAPI_Feature>
     aContext->Deactivate(anAIS);
 
     std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
-    QString aDebugStr = QString(featureInfo(theFeature).c_str()) + QString("; modes: ");
     for (; anIt != aLast; anIt++)
     {
       aContext->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)*anIt));
-         aDebugStr += QString("%1").arg(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)*anIt)) + QString(", ");
        }
-    /*if (theModes.empty()) {
-      aContext->Deactivate(anAIS);
-      aContext->Activate(anAIS, -1);
-         aContext->ClearSelected();
-         aDebugStr += " deactivated";
-         QColor aColor(Qt::white);
-         anAIS->SetColor(Quantity_Color(aColor.red()/255., aColor.green()/255., aColor.blue()/255., Quantity_TOC_RGB));
-       }*/
-       qDebug(aDebugStr.toStdString().c_str());
   }
 
   if (isUpdateViewer)
     aContext->UpdateCurrentViewer();
 }
 
-void XGUI_Displayer::StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop)
+void XGUI_Displayer::StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
+                                   const bool isUpdateViewer)
 {
-  return;
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   Handle(AIS_Shape) anAIS;
@@ -193,19 +181,43 @@ void XGUI_Displayer::StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures,
       continue;
 
     if (isStop) {
-      aContext->Deactivate(anAIS);
-      aContext->Activate(anAIS, -1);
       aContext->ClearSelected();
+      aContext->Deactivate(anAIS);
       
-      //aDebugStr += " deactivated";
       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));
+      QColor aColor(Qt::red);
+      anAIS->SetColor(Quantity_Color(aColor.red()/255., aColor.green()/255., aColor.blue()/255., Quantity_TOC_RGB));
+      anAIS->Redisplay();
     }
   }
+  if (isUpdateViewer)
+    aContext->UpdateCurrentViewer();
+}
+
+void XGUI_Displayer::SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer)
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+
+  std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+  boost::shared_ptr<ModelAPI_Feature> aFeature;
+
+  Handle(AIS_Shape) anAIS;
+  aContext->ClearSelected();
+
+  for (; anIt != aLast; anIt++) {
+    aFeature = (*anIt).feature();
+    if (IsVisible(aFeature))
+      anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]);
+    if (anAIS.IsNull())
+      continue;
+    aContext->AddOrRemoveSelected(anAIS, false);
+  }
+  if (isUpdateViewer)
+    aContext->UpdateCurrentViewer();
 }
 
 void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
index 5e0b334e5bc0fd250119468c936987afae28edad..5973cd67e6d1ce064356503dff519a7b2514201e 100644 (file)
@@ -81,7 +81,14 @@ public:
   /// 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
-  void StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop);
+  /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+  void StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
+                     const bool isUpdateViewer);
+
+  /// Set the features are selected
+  /// \param theFeatures a list of features to be selected
+  /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+  void SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer);
 
   /// Erase the feature and a shape.
   /// \param theFeature a feature instance