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

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

index 198cfbe64dcc1250cc028f031274ad3a1aaecccb..5214dd6e1d10dbaeecb3c991a5a4342ccd6fd109 100644 (file)
@@ -195,7 +195,8 @@ void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
   aViewer->enableMultiselection(theEnabled);
 }
 
-void PartSet_Module::onStopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop)
+void PartSet_Module::onStopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
+                                     const bool isToSelect)
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   aDisplayer->StopSelection(theFeatures, isStop, false);
@@ -206,7 +207,8 @@ void PartSet_Module::onStopSelection(const std::list<XGUI_ViewerPrs>& theFeature
       activateFeature((*anIt).feature(), false);
     }
   }
-  aDisplayer->SetSelected(theFeatures, false);
+  if (isToSelect)
+    aDisplayer->SetSelected(theFeatures, false);
   aDisplayer->UpdateViewer();
 }
 
@@ -267,8 +269,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
 
     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
             this, SLOT(onMultiSelectionEnabled(bool)));
-    connect(aPreviewOp, SIGNAL(stopSelection(const std::list<XGUI_ViewerPrs>&, const bool)),
-            this, SLOT(onStopSelection(const std::list<XGUI_ViewerPrs>&, const bool)));
+    connect(aPreviewOp, SIGNAL(stopSelection(const std::list<XGUI_ViewerPrs>&, const bool, const bool)),
+            this, SLOT(onStopSelection(const std::list<XGUI_ViewerPrs>&, const bool, const bool)));
 
     PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
     if (aSketchOp) {
index cba0367e6b4a245fcd7cd40e4f6b5ee5fdf8eb2a..bfb57de78e397849fa8accfe82d35f20236a01a6 100644 (file)
@@ -92,10 +92,12 @@ public slots:
   /// \param theEnabled the enabled state
   void onMultiSelectionEnabled(bool theEnabled);
 
-  /// SLOT, to stop or start selection for the features
+  /// SLOT, to stop or start selection mode for the features
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
-  void onStopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop);
+  /// \param isToSelect the boolean state whether the features should be selected
+  void onStopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
+                       const bool isToSelect);
 
   /// SLOT, to visualize the feature in another local context mode
   /// \param theFeature the feature to be put in another local context mode
index 2c39948d759ffd3a1dc3829e879fde5a4e39cac0..941195a5692caac9ba45b09f13babcf73c752576 100644 (file)
@@ -42,10 +42,7 @@ bool PartSet_OperationEditLine::isGranted() const
 
 std::list<int> PartSet_OperationEditLine::getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const
 {
-  std::list<int> aModes;
-  aModes.push_back(-1);
-  return aModes;
-  //return PartSet_OperationSketchBase::getSelectionModes(theFeature);
+  return PartSet_OperationSketchBase::getSelectionModes(theFeature);
 }
 
 void PartSet_OperationEditLine::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
@@ -100,16 +97,12 @@ void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_
 {
   std::list<XGUI_ViewerPrs> aFeatures = myFeatures;
   if (myFeatures.size() == 1) {
-    boost::shared_ptr<ModelAPI_Feature> aFeature;
-    if (!theSelected.empty())
-      aFeature = theSelected.front().feature();
-
-    if (aFeature == feature())
+    if (theSelected.empty())
       return;
-  
-   commit();
-   if (aFeature)
-     emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
+
+    boost::shared_ptr<ModelAPI_Feature> aFeature = theSelected.front().feature();
+    commit();
+    emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
   }
   else {
     commit();
@@ -126,14 +119,15 @@ void PartSet_OperationEditLine::startOperation()
 {
   // do nothing in order to do not create a new feature
   emit multiSelectionEnabled(false);
-  emit stopSelection(myFeatures, true);
+  emit stopSelection(myFeatures, true, false);
   myCurPoint.clear();
 }
 
 void PartSet_OperationEditLine::stopOperation()
 {
   emit multiSelectionEnabled(true);
-  emit stopSelection(myFeatures, false);
+  bool isSelectFeatures = myFeatures.size() > 1;
+  emit stopSelection(myFeatures, false, isSelectFeatures);
   myFeatures.clear();
 }
 
index 4fb941df9784f9af42e88024506c17e7ad76b232..d8154f86c247344ad21065c450540dcf7b005780 100644 (file)
@@ -103,7 +103,9 @@ signals:
   /// signal to enable/disable selection in the viewer
   /// \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 theToStop);
+  /// \param isToSelect the boolean state whether the features should be selected
+  void stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool theToStop,
+                     const bool isToSelect);
 
   /// signal to enable/disable usual selection in the viewer
   /// \param theEnabled the boolean state
index d597eda0c6ac71df619d29ea8dbe45fd99399e4a..73515eae779dc9ba8e501c4a2e8c13b9cbfddb40 100644 (file)
@@ -181,9 +181,6 @@ void XGUI_Displayer::StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures,
       continue;
 
     if (isStop) {
-      aContext->ClearSelected();
-      aContext->Deactivate(anAIS);
-      
       QColor aColor(Qt::white);
       anAIS->SetColor(Quantity_Color(aColor.red()/255., aColor.green()/255., aColor.blue()/255., Quantity_TOC_RGB));
       anAIS->Redisplay();