]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Shift selection to edit some lines.
authornds <natalia.donis@opencascade.com>
Fri, 23 May 2014 10:24:00 +0000 (14:24 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 23 May 2014 10:24:00 +0000 (14:24 +0400)
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationEditLine.h
src/PartSet/PartSet_OperationSketch.cpp

index df852732c792b915f7c5f663c053d5fb873153f1..d69aab8e0ab2793a2c05372cb97afcbdf7b9025b 100644 (file)
@@ -35,7 +35,7 @@ using namespace std;
 PartSet_OperationEditLine::PartSet_OperationEditLine(const QString& theId,
                                                  QObject* theParent,
                                               boost::shared_ptr<ModelAPI_Feature> theFeature)
-: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false)
 {
 }
 
@@ -94,12 +94,20 @@ void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_V
       aFeature = theHighlighted.front().feature();
 
     if (aFeature && aFeature == feature()) { // continue the feature edit
-      blockSelection(true);
     }
     else {
+      XGUI_ViewerPrs aFeaturePrs = myFeatures.front();
       commit();
       emit featureConstructed(feature(), FM_Deactivation);
-      if (aFeature) {
+
+      bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
+      if(aHasShift && !theHighlighted.empty()) {
+        std::list<XGUI_ViewerPrs> aSelected;
+        aSelected.push_back(aFeaturePrs);
+        aSelected.push_back(theHighlighted.front());
+        emit setSelection(aSelected);
+      }
+      else if (aFeature) {
         emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
       }
     }
@@ -113,6 +121,7 @@ void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_Vie
 
   gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
 
+  blockSelection(true);
   if (myCurPoint.myIsInitialized) {
     double aCurX, aCurY;
     PartSet_Tools::ConvertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY);
@@ -165,7 +174,8 @@ void PartSet_OperationEditLine::startOperation()
   // do nothing in order to do not create a new feature
   emit multiSelectionEnabled(false);
 
-  blockSelection(true);
+  if (myFeatures.size() > 1)
+    blockSelection(true);
 
   myCurPoint.clear();
 }
@@ -181,6 +191,10 @@ void PartSet_OperationEditLine::stopOperation()
 
 void PartSet_OperationEditLine::blockSelection(bool isBlocked, const bool isRestoreSelection)
 {
+  if (myIsBlockedSelection == isBlocked)
+    return;
+
+  myIsBlockedSelection = isBlocked;
   if (isBlocked) {
     emit setSelection(std::list<XGUI_ViewerPrs>());
     emit stopSelection(myFeatures, true);
index 219d23b2c9eb4aec94114620833bd5edb4e9f2aa..d42d0e545fb38022f6f716bd69b77935b83425bc 100644 (file)
@@ -142,6 +142,7 @@ private:
   std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
   Point myCurPoint; ///< the current 3D point clicked or moved
   gp_Pnt myCurPressed; ///< the current 3D point clicked or moved
+  bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
 };
 
 #endif
index 5aff76e1c24159b33c4cc7d052c6a7f6373345da..eb65c3659515f3b4d05274a1e9121905a8916345 100644 (file)
@@ -63,7 +63,7 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketch::sketch() const
 }
 
 void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                           const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                           const std::list<XGUI_ViewerPrs>& theSelected,
                                            const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
   if (!hasSketchPlane()) {
@@ -75,6 +75,12 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
     }
   }
   else {
+    // if shift button is pressed and there are some already selected objects, the operation should
+    // not be started. We just want to combine some selected objects.
+    bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
+    if (aHasShift && theSelected.size() > 0)
+      return;
+
     if (theHighlighted.size() == 1) {
       boost::shared_ptr<ModelAPI_Feature> aFeature = theHighlighted.front().feature();
       if (aFeature)