Changeset 8275:b8af3cf18950 in orange


Ignore:
Timestamp:
05/25/11 19:59:59 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
65e55f16dc86bc536770cf3b3ec285d55f9bc710
Message:

Speed up curve drawing, using one PathItem instead of several LineItems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Graph/curve.py

    r8274 r8275  
    22from OWBaseWidget import * 
    33 
    4 from PyQt4.QtGui import QGraphicsItemGroup, QGraphicsEllipseItem, QGraphicsLineItem 
    5 from PyQt4.QtGui import QBrush, QPen 
     4from PyQt4.QtGui import QGraphicsItemGroup, QGraphicsEllipseItem, QGraphicsLineItem, QGraphicsPathItem 
     5from PyQt4.QtGui import QBrush, QPen, QPainterPath 
    66 
    77""" 
     
    2626        self.graph = graph 
    2727        self.items = [] 
    28         for i in range(len(data)-1): 
    29             (x, y) = self.graph.map_to_graph(data[i]) 
    30             (x1, y1) = self.graph.map_to_graph(data[i+1]) 
    31             item = QGraphicsLineItem( x, y, x1, y1, self ) 
    32             item.setPen(style.pen()) 
    33             self.items.append(item) 
     28        self.path = QPainterPath() 
     29        if data: 
     30            (start_x, start_y) = self.graph.map_to_graph(data[0]) 
     31            self.path.moveTo(start_x, start_y) 
     32            for data_point in data: 
     33                (x, y) = self.graph.map_to_graph(data_point) 
     34                self.path.lineTo(x, y) 
     35            self.path_item = QGraphicsPathItem(self.path, self) 
     36            self.path_item.setPen(style.pen()) 
     37            self.path_item.show() 
    3438     
    3539    def __setattr__(self, name, value): 
Note: See TracChangeset for help on using the changeset viewer.