]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Wed, 14 May 2014 07:25:48 +0000 (11:25 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 14 May 2014 07:25:48 +0000 (11:25 +0400)
Edit for milti selected lines

13 files changed:
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationEditLine.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/XGUI/XGUI_Viewer.cpp

index 2ad243d68852dc33424da4a2821e584c65b1f722..d7a92caf5118640d66b07f755918bc2985742a8a 100644 (file)
@@ -143,7 +143,6 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
     if (aSelector) {
       NCollection_List<TopoDS_Shape> aList;
       aSelector->selectedShapes(aList);
-
       aPresentations = myWorkshop->displayer()->GetViewerPrs(aList);
     }
     aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aPresentations);
@@ -156,7 +155,14 @@ void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView());
+    XGUI_SelectionMgr* aSelector = myWorkshop->selector();
+    std::list<XGUI_ViewerPrs> aPresentations;
+    if (aSelector) {
+      NCollection_List<TopoDS_Shape> aList;
+      aSelector->selectedShapes(aList);
+      aPresentations = myWorkshop->displayer()->GetViewerPrs(aList);
+    }
+    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView(), aPresentations);
   }
 }
 
@@ -202,6 +208,12 @@ void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
   aViewer->enableMultiselection(theEnabled);
 }
 
+void PartSet_Module::onSelectionEnabled(bool theEnabled)
+{
+  XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+  aViewer->enableSelection(theEnabled);
+}
+
 void PartSet_Module::onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
                                           int theMode)
 {
@@ -252,6 +264,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
             this, SLOT(onLaunchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)));
     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
             this, SLOT(onMultiSelectionEnabled(bool)));
+    connect(aPreviewOp, SIGNAL(selectionEnabled(bool)),
+            this, SLOT(onSelectionEnabled(bool)));
 
     PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
     if (aSketchOp) {
index 82fe68b4f7828c02f65695d3b18f165b55294a26..6138a43dc6ed539da34e0daba492b97e3c84930d 100644 (file)
@@ -79,6 +79,10 @@ public slots:
   /// \param theEnabled the enabled state
   void onMultiSelectionEnabled(bool theEnabled);
 
+  /// SLOT, to switch on/off the selection in the viewer
+  /// \param theEnabled the enabled state
+  void onSelectionEnabled(bool theEnabled);
+
   /// SLOT, to visualize the feature in another local context mode
   /// \param theFeature the feature to be put in another local context mode
   /// \param theMode the mode appeared on the feature
index 5f7c7ebcaeb43ba48d9859ae80a7f4e9a1b1ae75..f0049b007d46a956a908173655af8fda6266e2f6 100644 (file)
@@ -58,27 +58,39 @@ void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_V
   if (!(theEvent->buttons() &  Qt::LeftButton))
     return;
   gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
-  myCurPressed = aPoint;
+  myCurPoint.setPoint(aPoint);
 }
 
-void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                           const std::list<XGUI_ViewerPrs>& theSelected)
 {
   if (!(theEvent->buttons() &  Qt::LeftButton))
     return;
-
-  double aCurX, aCurY;
-  PartSet_Tools::ConvertTo2D(myCurPressed, mySketch, theView, aCurX, aCurY);
-
-  double aX, anY;
   gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
-  PartSet_Tools::ConvertTo2D(aPoint, mySketch, theView, aX, anY);
-
-  double aDeltaX = aX - aCurX;
-  double aDeltaY = anY - aCurY;
 
-  moveLinePoint(aDeltaX, aDeltaY, LINE_ATTR_START);
-  moveLinePoint(aDeltaX, aDeltaY, LINE_ATTR_END);
-  myCurPressed = aPoint;
+  if (myCurPoint.myIsInitialized) {
+    double aCurX, aCurY;
+    PartSet_Tools::ConvertTo2D(myCurPoint.myPoint, mySketch, theView, aCurX, aCurY);
+
+    double aX, anY;
+    PartSet_Tools::ConvertTo2D(aPoint, mySketch, theView, aX, anY);
+
+    double aDeltaX = aX - aCurX;
+    double aDeltaY = anY - aCurY;
+
+    moveLinePoint(feature(), aDeltaX, aDeltaY, LINE_ATTR_START);
+    moveLinePoint(feature(), aDeltaX, aDeltaY, LINE_ATTR_END);
+
+    /*std::list<XGUI_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
+    for (; anIt != aLast; anIt++) {
+      boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).feature();
+      if (!aFeature)
+        continue;
+      moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_START);
+      moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_END);
+    }*/
+  }
+  myCurPoint.setPoint(aPoint);
 }
 
 void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
@@ -99,12 +111,13 @@ void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_
 void PartSet_OperationEditLine::startOperation()
 {
   // do nothing in order to do not create a new feature
-  emit multiSelectionEnabled(false);
+  emit selectionEnabled(false);
+  myCurPoint.clear();
 }
 
 void PartSet_OperationEditLine::stopOperation()
 {
-  emit multiSelectionEnabled(true);
+  emit selectionEnabled(true);
 }
 
 boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature()
@@ -113,10 +126,14 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature()
   return boost::shared_ptr<ModelAPI_Feature>();
 }
 
-void  PartSet_OperationEditLine::moveLinePoint(double theDeltaX, double theDeltaY,
+void  PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                                               double theDeltaX, double theDeltaY,
                                                const std::string& theAttribute)
 {
-  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  if (!theFeature)
+    return;
+
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
 
index a935f2f700e8db04cb09043288957df174ff52eb..826a5f9aedf77a4132e8dcf6fc3d94db16e2a0fc 100644 (file)
@@ -19,6 +19,33 @@ class QMouseEvent;
 class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
 {
   Q_OBJECT
+  /// Struct to define gp point, with the state is the point is initialized
+  struct Point
+  {
+    /// Constructor
+    Point() {}
+    /// Constructor
+    /// \param thePoint the point
+    Point(gp_Pnt thePoint)
+    {
+      setPoint(thePoint);
+    }
+    ~Point() {}
+
+    /// clear the initialized flag.
+    void clear() { myIsInitialized = false; }
+    /// set the point and switch on the initialized flag
+    /// \param thePoint the point
+    void setPoint(const gp_Pnt& thePoint)
+    {
+      myIsInitialized = true;
+      myPoint = thePoint;
+    }
+
+    bool myIsInitialized; /// the state whether the point is set
+    gp_Pnt myPoint; /// the point
+  };
+
 public:
   /// Returns the operation type key
   static std::string Type() { return "EditLine"; }
@@ -53,13 +80,15 @@ public:
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
+  /// \param theSelected the list of selected presentations
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView,
+                          const std::list<XGUI_ViewerPrs>& theSelected);
   /// Gives the current selected objects to be processed by the operation
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
   /// \param theSelected the list of selected presentations
  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                             const std::list<XGUI_ViewerPrs>& theSelected);
+                            const std::list<XGUI_ViewerPrs>& theSelected);
 protected:
   /// \brief Virtual method called when operation is started
   /// Virtual method called when operation started (see start() method for more description)
@@ -77,14 +106,17 @@ protected:
 
 protected:
   /// \brief Save the point to the line.
+  /// \param theFeature the source feature
   /// \param theDeltaX the delta for X coordinate is moved
   /// \param theDeltaY the delta for Y coordinate is moved
   /// \param theAttribute the start or end attribute of the line
-  void  moveLinePoint(double theDeltaX, double theDeltaY,
+  void  moveLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                      double theDeltaX, double theDeltaY,
                       const std::string& theAttribute);
 
 private:
   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
+  Point myCurPoint; ///< the current 3D point clicked or moved
   gp_Pnt myCurPressed; ///< the current 3D point clicked or moved
 };
 
index 04de171122195a125f810da00003b7a9bb22e75f..e5290aa77eb9bc3cbd86ec285cb4b6afdf623019 100644 (file)
@@ -5,8 +5,10 @@
 #include <PartSet_OperationSketch.h>
 
 #include <PartSet_OperationEditLine.h>
+#include <PartSet_Tools.h>
 
 #include <SketchPlugin_Sketch.h>
+
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <GeomAlgoAPI_FaceBuilder.h>
@@ -23,6 +25,8 @@
 #include <QDebug>
 #endif
 
+#include <QMouseEvent>
+
 using namespace std;
 
 PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId,
@@ -52,19 +56,27 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
 {
   if (theSelected.empty())
     return;
-  XGUI_ViewerPrs aPrs = theSelected.front();
 
   if (!myIsEditMode) {
+    XGUI_ViewerPrs aPrs = theSelected.front();
     const TopoDS_Shape& aShape = aPrs.shape();
     if (!aShape.IsNull()) {
       setSketchPlane(aShape);
       myIsEditMode = true;
     }
   }
-  else {
-    if (aPrs.feature())
-      emit launchOperation(PartSet_OperationEditLine::Type(), aPrs.feature());
-  }
+}
+
+void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                         const std::list<XGUI_ViewerPrs>& theSelected)
+{
+  if (!myIsEditMode || !(theEvent->buttons() &  Qt::LeftButton) || theSelected.empty())
+    return;
+
+  boost::shared_ptr<ModelAPI_Feature> aFeature = PartSet_Tools::NearestFeature(theEvent->pos(),
+                                                              theView, feature(), theSelected);
+  if (aFeature)
+    emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
 }
 
 void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
@@ -107,4 +119,3 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
   boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
   emit planeSelected(aDir->x(), aDir->y(), aDir->z());
 }
-
index acc374e41d5570233c5d3feda7ec12f66a943a60..227722dc7c91b9849a8227e11e76d575a40d09d8 100644 (file)
@@ -40,6 +40,12 @@ public:
   /// \param theSelected the list of selected presentations
   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
                              const std::list<XGUI_ViewerPrs>& theSelected);
+  /// Gives the current mouse point in the viewer
+  /// \param thePoint a point clicked in the viewer
+  /// \param theEvent the mouse event
+  /// \param theSelected the list of selected presentations
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView,
+                          const std::list<XGUI_ViewerPrs>& theSelected);
 
 signals:
   /// signal about the sketch plane is selected
index 85c0a2c30297b796bc0e6f4b7dcce66843cbf2c9..4113c3cba83fbab23eed59174fbd7e08d98cb4a3 100644 (file)
@@ -47,6 +47,7 @@ void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3
                                                 const std::list<XGUI_ViewerPrs>& theSelected)
 {
 }
-void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                             const std::list<XGUI_ViewerPrs>& theSelected)
 {
 }
index d133585150c33d23a80a6b2b739743e1d366cf6e..b30f29935ba303eae52adcf9576b3e45ba1de2b0 100644 (file)
@@ -67,7 +67,9 @@ public:
   /// Processes the mouse move in the point
   /// \param thePoint a 3D point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
+  /// \param theSelected the list of selected presentations
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView,
+                          const std::list<XGUI_ViewerPrs>& theSelected);
 
   /// Processes the key pressed in the view
   /// \param theKey a key value
@@ -87,6 +89,10 @@ signals:
   /// \param theEnabled the boolean state
   void multiSelectionEnabled(bool theEnabled);
 
+  /// signal to enable/disable usual selection in the viewer
+  /// \param theEnabled the boolean state
+  void selectionEnabled(bool theEnabled);
+
 protected:
   /// Creates an operation new feature
   /// In addition to the default realization it appends the created line feature to
index 6baec986ba39e33eafc782d074e307fd88eb242d..97fd78c7458142d2d08ae6f017575c402ab72b4c 100644 (file)
@@ -79,9 +79,11 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
 {
   double aX, anY;
 
+  bool isFoundPoint = false;
   gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
   if (theSelected.empty()) {
     PartSet_Tools::ConvertTo2D(aPoint, mySketch, theView, aX, anY);
+    isFoundPoint = true;
   }
   else {
     XGUI_ViewerPrs aPrs = theSelected.front();
@@ -93,6 +95,7 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
         if (!aVertex.IsNull()) {
           aPoint = BRep_Tool::Pnt(aVertex);
           PartSet_Tools::ConvertTo2D(aPoint, mySketch, theView, aX, anY);
+          isFoundPoint = true;
 
           setConstraints(aX, anY);
         }
@@ -119,10 +122,14 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
             default:
             break;
           }
+          isFoundPoint = true;
         }
       }
     }
   }
+  //if (!isFoundPoint)
+  //  return;
+
   switch (myPointSelectionMode)
   {
     case SM_FirstPoint: {
@@ -142,7 +149,8 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
   }
 }
 
-void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                             const std::list<XGUI_ViewerPrs>& /*theSelected*/)
 {
   switch (myPointSelectionMode)
   {
index c06462d7a50be8d57ca010e09198db29aad83824..b048ef8a7b451dc018878adf551a88a37d0a41af 100644 (file)
@@ -57,7 +57,9 @@ public:
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
+  /// \param theSelected the list of selected presentations
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView,
+                          const std::list<XGUI_ViewerPrs>& theSelected);
   /// Processes the key pressed in the view
   /// \param theKey a key value
   virtual void keyReleased(const int theKey);
index 3caf619cac56abe93aec6f184246c39c315b0f8b..2c7a93b069bab6d65eaaab70c0fd1612d4444d42 100644 (file)
@@ -9,11 +9,15 @@
 
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Dir.h>
+#include <GeomDataAPI_Point2D.h>
 
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_XYZ.h>
 
 #include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Line.h>
+
+#include <XGUI_ViewerPrs.h>
 
 #include <V3d_View.hxx>
 #include <gp_Pln.hxx>
@@ -139,3 +143,53 @@ void PartSet_Tools::ProjectPointOnLine(double theX1, double theY1, double theX2,
     theY = aPoint.Y();
   }
 }
+
+boost::shared_ptr<ModelAPI_Feature> PartSet_Tools::NearestFeature(QPoint thePoint,
+                                                   Handle_V3d_View theView,
+                                                   boost::shared_ptr<ModelAPI_Feature> theSketch,
+                                                   const std::list<XGUI_ViewerPrs>& theFeatures)
+{
+  double aX, anY;
+  gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, theView);
+  PartSet_Tools::ConvertTo2D(aPoint, theSketch, theView, aX, anY);
+
+  boost::shared_ptr<ModelAPI_Feature> aFeature;
+  std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+
+  boost::shared_ptr<ModelAPI_Feature> aDeltaFeature;   
+  double aMinDelta = -1;
+  XGUI_ViewerPrs aPrs;
+  for (; anIt != aLast; anIt++) {
+    aPrs = *anIt;
+    if (!aPrs.feature())
+      continue;
+    double aDelta = DistanceToPoint(aPrs.feature(), aX, anY);
+    if (aMinDelta < 0 || aMinDelta > aDelta) {
+      aMinDelta = aDelta;
+      aDeltaFeature = aPrs.feature();
+    }
+  }
+  return aDeltaFeature;
+}
+
+double PartSet_Tools::DistanceToPoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                                      double theX, double theY)
+{
+  double aDelta = 0;
+  if (theFeature->getKind() != "SketchLine")
+    return aDelta;
+
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+  double aX, anY;
+  PartSet_Tools::ProjectPointOnLine(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y(), theX, theY, aX, anY);
+
+  aDelta = gp_Pnt(theX, theY, 0).Distance(gp_Pnt(aX, anY, 0));
+
+  return aDelta;
+}
index ecb28b7444f022ad8b7ed99404832f981295e9e4..957585b2666dca460af873a780ded28db3174d94 100644 (file)
 
 #include <boost/shared_ptr.hpp>
 
+#include <list>
+
 class Handle_V3d_View;
 class ModelAPI_Feature;
+class XGUI_ViewerPrs;
 
 /*!
  \class PartSet_Tools
@@ -61,6 +64,22 @@ public:
   /// \param theY2 the vertical coordinate of the second line point
   static void ProjectPointOnLine(double theX1, double theY1, double theX2, double theY2,
                                  double thePointX, double thePointY, double& theX, double& theY);
+
+  /// Returns a feature that is under the mouse point
+  /// \param thePoint a screen point
+  /// \param theView a 3D view
+  /// \param theSketch the sketch feature
+  /// \param theFeatures the list of selected presentations
+  static boost::shared_ptr<ModelAPI_Feature> NearestFeature(QPoint thePoint, Handle_V3d_View theView,
+                                                     boost::shared_ptr<ModelAPI_Feature> theSketch,
+                                                     const std::list<XGUI_ViewerPrs>& theFeatures);
+private:
+  /// Return the distance between the feature and the point
+  /// \param theFeature feature object
+  /// \param theX the horizontal coordinate of the point
+  /// \param theX the vertical coordinate of the point
+  static double DistanceToPoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                                double theX, double theY);
 };
 
 #endif
index 12eae6e4a4e550a648a410585fedb08536ae2803..b5b5aaedccec41b460b3aa7b6d4f6ba5b63ee8bf 100644 (file)
@@ -519,8 +519,10 @@ void XGUI_Viewer::onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
 */
 void XGUI_Viewer::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
 {
-  if (!mySelectionEnabled) return;
-  if (theEvent->button() != Qt::LeftButton) return;
+  if (!mySelectionEnabled || theEvent->button() != Qt::LeftButton) {
+    emit mouseRelease(theWindow, theEvent);
+    return;
+  }
 
   myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
   bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);