Salome HOME
refs #416: to store the open state of object browser items in the binary array
[modules/gui.git] / src / SVTK / SVTK_AreaPicker.cxx
index 974b2a012b52bf55d86e3cc859f9993d4edb50e2..863568928943ec20d9ba162e76fadd4e1cf0cf81 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -126,8 +126,8 @@ int SVTK_AreaPicker::Pick( double theSelectionX, double theSelectionY,
     SelectionMode theMode )
 {
   QVector< QPoint > aPoints;
-  aPoints.append( QPoint( theSelectionX, theSelectionY ) );
-  aPoints.append( QPoint( theSelectionX2, theSelectionY2 ) );
+  aPoints.append( QPoint( (int)theSelectionX, (int)theSelectionY ) );
+  aPoints.append( QPoint( (int)theSelectionX2, (int)theSelectionY2 ) );
   return Pick( aPoints, theRenderer, theMode );
 }
 
@@ -141,7 +141,10 @@ int SVTK_AreaPicker::Pick( QVector< QPoint >& thePoints,
   this->Renderer = theRenderer;
 
   if ( theMode == RectangleMode ) {
-    mySelection = {thePoints[0].x(), thePoints[0].y(), thePoints[1].x(), thePoints[1].y()};
+    mySelection[0] = thePoints[0].x();
+    mySelection[1] = thePoints[0].y();
+    mySelection[2] = thePoints[1].x();
+    mySelection[3] = thePoints[1].y();
   }
   else if( theMode == PolygonMode ) {
     int minX, minY, maxX, maxY;
@@ -157,7 +160,10 @@ int SVTK_AreaPicker::Pick( QVector< QPoint >& thePoints,
       if ( thePoints[i].y() > maxY )
       maxY = thePoints[i].y();
     }
-    mySelection = {minX, minY, maxX, maxY};
+    mySelection[0] = minX;
+    mySelection[1] = minY;
+    mySelection[2] = maxX;
+    mySelection[3] = maxY;
   }
 
   // Invoke start pick method if defined
@@ -264,8 +270,7 @@ void SVTK_AreaPicker::SelectVisiblePoints( QVector< QPoint >& thePoints,
         && aDX[1] <= mySelection[3];
     else
       if ( theMode == PolygonMode ) isInSelection =
-          SVTK_AreaPicker::isPointInPolygon( QPoint( aDX[0], aDX[1] ),
-              thePoints );
+       isPointInPolygon( QPoint( (int)aDX[0], (int)aDX[1] ), thePoints );
 
     // check whether visible and in selection window
     if ( isInSelection ) {
@@ -373,8 +378,7 @@ void SVTK_AreaPicker::SelectVisibleCells( QVector< QPoint >& thePoints,
         && aDX[1] <= mySelection[3];
     else
       if ( theMode == PolygonMode ) isInSelection =
-          SVTK_AreaPicker::isPointInPolygon( QPoint( aDX[0], aDX[1] ),
-              thePoints );
+       isPointInPolygon( QPoint( (int)aDX[0], (int)aDX[1] ), thePoints );
     // check whether visible and in selection window
     if ( isInSelection ) {
       vtkIdType aNumPts = aCell->GetNumberOfPoints();
@@ -389,8 +393,7 @@ void SVTK_AreaPicker::SelectVisibleCells( QVector< QPoint >& thePoints,
   }  //for all parts
 }
 
-bool SVTK_AreaPicker::isPointInPolygon( const QPoint& thePoint,
-    const QVector< QPoint >& thePolygon )
+bool SVTK_AreaPicker::isPointInPolygon( const QPoint& thePoint, const QVector<QPoint>& thePolygon )
 {
   double eps = 1.0;
   if ( thePolygon.size() < 3 ) return false;
@@ -412,13 +415,10 @@ bool SVTK_AreaPicker::isPointInPolygon( const QPoint& thePoint,
     double del = last_pt.x() * cur_pt.y() - cur_pt.x() * last_pt.y();
     double xy = cur_pt.x() * last_pt.x() + cur_pt.y() * last_pt.y();
 
-    sum +=
-        ( atan(
-            ( last_pt.x() * last_pt.x() + last_pt.y() * last_pt.y() - xy )
-                / del )
-            + atan(
-                ( cur_pt.x() * cur_pt.x() + cur_pt.y() * cur_pt.y() - xy )
-                    / del ) );
+    if ( del )
+      sum +=
+      ( atan( ( last_pt.x() * last_pt.x() + last_pt.y() * last_pt.y() - xy ) / del )
+      + atan( ( cur_pt.x() * cur_pt.x() + cur_pt.y() * cur_pt.y() - xy ) / del ) );
 
     last_pt = cur_pt;
   }