Commits

Anonymous committed 153dd11

Take zooming into accout when finding the closest point for selection. Fixes ticket #1035

  • Participants
  • Parent commits bd6641b

Comments (0)

Files changed (1)

File source/orangeqt/plot.cpp

 
 Point* Plot::nearest_point(const QPointF& pos)
 {
+    QPointF zoomedPos = graph_item->transform().inverted().map(pos);
     QPair<double, Point*> closest_point;
     closest_point.first = std::numeric_limits<double>::max();
     closest_point.second = 0;
     {
         foreach (Point* p, hash)
         {
-            const double d = distance(p->pos(), pos);
+            const double d = distance(p->pos(), zoomedPos);
             if (d < closest_point.first)
             {
                 closest_point.first = d;
             }
         }
     }
-
+    
+    
+    if (closest_point.second)
+    {
+        // In case of zooming, we want the actual distance on the screen, 
+        // rather then the distance on the non-zoomed canvas
+        closest_point.first = distance(graph_item->transform().map(closest_point.second->pos()), pos);
+    }
+		
     if(closest_point.second && closest_point.first <= closest_point.second->size())
     {
         return closest_point.second;