Changeset 9380:153dd11ec53b in orange


Ignore:
Timestamp:
12/17/11 10:46:01 (2 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
96ae5b9916b8008e7191f88764f9ccd4d044545f
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orangeqt/plot.cpp

    r9363 r9380  
    333333Point* Plot::nearest_point(const QPointF& pos) 
    334334{ 
     335    QPointF zoomedPos = graph_item->transform().inverted().map(pos); 
    335336    QPair<double, Point*> closest_point; 
    336337    closest_point.first = std::numeric_limits<double>::max(); 
     
    341342        foreach (Point* p, hash) 
    342343        { 
    343             const double d = distance(p->pos(), pos); 
     344            const double d = distance(p->pos(), zoomedPos); 
    344345            if (d < closest_point.first) 
    345346            { 
     
    349350        } 
    350351    } 
    351  
     352     
     353     
     354    if (closest_point.second) 
     355    { 
     356        // In case of zooming, we want the actual distance on the screen,  
     357        // rather then the distance on the non-zoomed canvas 
     358        closest_point.first = distance(graph_item->transform().map(closest_point.second->pos()), pos); 
     359    } 
     360         
    352361    if(closest_point.second && closest_point.first <= closest_point.second->size()) 
    353362    { 
Note: See TracChangeset for help on using the changeset viewer.