Changeset 8306:07e102903abf in orange


Ignore:
Timestamp:
06/11/11 11:32:39 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
6b2fdd84dbeebb9015e78dd816db88b5b0cb61e1
Message:

Fix transformations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWGraphQt.py

    r8304 r8306  
    114114        self.addAxis(yLeft, True) 
    115115         
    116         self.map_to_graph = self.map_to_graph_cart 
    117         self.map_from_graph = self.map_from_graph_cart 
    118116        self.map_transform = QTransform() 
    119117         
     
    143141    def map_to_graph(self, point, axes = None): 
    144142        (x, y) = point 
     143        ret = QPointF(x, y) * self.map_transform 
     144        return (ret.x(), ret.y()) 
     145         
     146    def map_from_graph(self, point, axes = None): 
     147        (x, y) = point 
     148        ret = QPointF(x, y) * self.map_transform.inverted() 
     149        return (ret.x(), ret.y()) 
    145150         
    146151    def saveToFile(self, extraButtons = []): 
     
    343348        min_x, max_x, t = self.axes[axes[0]].scale 
    344349        min_y, max_y, t = self.axes[axes[1]].scale 
    345         data_rect = QRectF(min_x, max_y, max_x-min_y, min_y-max_y) 
    346         qDebug(repr(data_rect)) 
     350        data_rect = QRectF(min_x, max_y, max_x-min_x, min_y-max_y) 
    347351        self.map_transform = self.transform_from_rects(data_rect,  self.zoom_rect) 
    348352         
     
    415419            elif event.button() == Qt.RightButton: 
    416420                end_zoom_factor = max(self._zoom_factor/2, 1) 
    417             self.zoom_point = (QPointF(event.pos())) 
     421            t, ok = self.zoom_transform.inverted() 
     422            if not ok: 
     423                return False 
     424            self.zoom_point = t.map(QPointF(event.pos())) 
    418425            self.zoom_animation = QPropertyAnimation(self, 'zoom_factor') 
    419426            self.zoom_animation.setStartValue(float(self._zoom_factor)) 
    420427            self.zoom_animation.setEndValue(float(end_zoom_factor)) 
    421           #  self.zoom_animation.setEasingCurve(QEasingCurve.Linear) 
    422428            self.zoom_animation.start(QAbstractAnimation.DeleteWhenStopped) 
    423429            return True 
Note: See TracChangeset for help on using the changeset viewer.