Changeset 8301:02650b786a08 in orange


Ignore:
Timestamp:
06/05/11 16:31:48 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
dcf365785c63863eac96b2c39e71795330634fdf
Message:

Animated zooming

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWGraphQt.py

    r8300 r8301  
    6969from Graph import * 
    7070from PyQt4.QtGui import QGraphicsView,  QGraphicsScene, QPainter, QTransform 
    71 from PyQt4.QtCore import QPointF 
     71from PyQt4.QtCore import QPointF, QPropertyAnimation 
    7272 
    7373from OWDlgs import OWChooseImageSizeDlg 
     
    127127        self.mouseStaticClickHandler = self.mouseStaticClick 
    128128         
    129         self.zoom_factor = 1 
     129        self._zoom_factor = 1 
    130130        self.zoom_point = None 
    131131        self.zoom_transform = QTransform() 
     
    361361        self.graph_area = QRectF(graph_rect) 
    362362         
    363         self.zoom_transform = self.transform_for_zoom(self.zoom_factor, self.zoom_point, self.graph_area) 
     363        self.zoom_transform = self.transform_for_zoom(self._zoom_factor, self.zoom_point, self.graph_area) 
    364364        self.zoom_rect = self.zoom_transform.mapRect(self.graph_area) 
    365365             
     
    421421        if self.state == ZOOMING: 
    422422            if event.button() == Qt.LeftButton: 
    423                 self.zoom_factor = self.zoom_factor * 2 
     423                end_zoom_factor = self._zoom_factor * 2 
    424424            elif event.button() == Qt.RightButton: 
    425                 self.zoom_factor = max(self.zoom_factor/2, 1) 
     425                end_zoom_factor = max(self._zoom_factor/2, 1) 
    426426            self.zoom_point = (QPointF(event.pos())) 
    427             qDebug(str(self.zoom_factor) + ' ' + str(self.zoom_point)) 
    428             self.replot() 
     427            self.zoom_animation = QPropertyAnimation(self, 'zoom_factor') 
     428            self.zoom_animation.setStartValue(float(self._zoom_factor)) 
     429            self.zoom_animation.setEndValue(float(end_zoom_factor)) 
     430          #  self.zoom_animation.setEasingCurve(QEasingCurve.Linear) 
     431            self.zoom_animation.start(QAbstractAnimation.DeleteWhenStopped) 
    429432            return True 
    430433        else: 
     
    449452        t.translate(-point.x(), -point.y()) 
    450453        return t 
     454 
     455    @pyqtProperty(QRectF) 
     456    def zoom_area(self): 
     457        return self._zoom_area 
     458         
     459    @zoom_area.setter 
     460    def zoom_area(self, value): 
     461        self._zoom_area = value 
     462        self.zoom_transform = self.transform_from_rects(self._zoom_area, self.graph_area) 
     463        self.zoom_rect = self.zoom_transform.mapRect(self.graph_area) 
     464        self.replot() 
     465         
     466    @pyqtProperty(float) 
     467    def zoom_factor(self): 
     468        return self._zoom_factor 
     469         
     470    @zoom_factor.setter 
     471    def zoom_factor(self, value): 
     472        qDebug(str(value)) 
     473        self._zoom_factor = value 
     474        self.replot() 
Note: See TracChangeset for help on using the changeset viewer.