diff --git a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx index d7e580cdb..d5f11d235 100644 --- a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx +++ b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx @@ -24,6 +24,7 @@ // File : EntityGUI_SketcherDlg.cxx // Author : Renaud NEDELEC, Open CASCADE S.A.S. +// SALOME includes #include "EntityGUI_FeatureDetectorDlg.h" #include @@ -51,7 +52,9 @@ #include #include +#include +// OCCT includes #include #include #include @@ -67,11 +70,11 @@ #include -#include - +// C++ includes #include #include +// boost includes #include // Constructors @@ -440,7 +443,7 @@ void EntityGUI_FeatureDetectorDlg::setEndPnt(const gp_Pnt& theEndPnt) { myEndPnt = theEndPnt; MESSAGE("myEndPnt = ("<GetImgHeight() > 0) showImageSample(); } @@ -451,8 +454,14 @@ void EntityGUI_FeatureDetectorDlg::setEndPnt(const gp_Pnt& theEndPnt) bool EntityGUI_FeatureDetectorDlg::setSelectionRect() { // Set detection rectangle in the background image coordinates system - QPoint topLeft = QPoint(myStartPnt.X() - pictureLeft, pictureTop - myStartPnt.Y()); - QPoint bottomRight = QPoint(myEndPnt.X() - pictureLeft, pictureTop - myEndPnt.Y()); + double left = std::min( myStartPnt.X(), myEndPnt.X() ); + double top = std::max( myStartPnt.Y(), myEndPnt.Y() ); + double right = std::max( myStartPnt.X(), myEndPnt.X() ); + double bottom = std::min( myStartPnt.Y(), myEndPnt.Y() ); + + QPoint topLeft = QPoint(left - pictureLeft, pictureTop - top ); + QPoint bottomRight = QPoint(right - pictureLeft, pictureTop - bottom); + myRect = QRect(topLeft, bottomRight); return (!myRect.isEmpty() && myRect.width() > 1);