Changeset 8281:6088cef8713e in orange


Ignore:
Timestamp:
05/28/11 17:25:13 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
9a3a50498763c9b4f1bf36a7db4067a61d7b2e61
Message:

Add support for plotting discrete points, which is still quite slow

Location:
orange/OrangeWidgets
Files:
3 edited

Legend:

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

    r8280 r8281  
    11 
    22from OWBaseWidget import * 
     3from palette import * 
    34 
    45from PyQt4.QtGui import QGraphicsItemGroup, QGraphicsEllipseItem, QGraphicsLineItem, QGraphicsPathItem 
     
    2728        self.style = style 
    2829        self.graph = graph 
     30        self.continuous = False 
    2931        self.update() 
    3032     
     
    3537        self.items = [] 
    3638        self.path = QPainterPath() 
    37         if self.data: 
     39        if not self.data: 
     40            return 
     41        if self.continuous: 
    3842            (start_x, start_y) = self.graph.map_to_graph(self.data[0]) 
    3943            self.path.moveTo(start_x, start_y) 
     
    4448            self.path_item.setPen(self.style.pen()) 
    4549            self.path_item.show() 
     50        else: 
     51            s = self.style.point_size 
     52            shape = self.style.point_shape 
     53            for p in self.data: 
     54                (x, y) = self.graph.map_to_graph(p) 
     55                if shape is CircleShape: 
     56                    i = QGraphicsEllipseItem(x-s/2, y-s/2, s, s, self) 
     57                elif shape is SquareShape: 
     58                    i = QGraphicsRectItem(x-s/2, y-s/2, s, s, self) 
     59                i.setPen(self.style.pen()) 
     60                i.setBrush(self.style.brush()) 
    4661         
    47      
  • orange/OrangeWidgets/Graph/palette.py

    r8274 r8281  
    3535""" 
    3636 
    37 from PyQt4.QtGui import QColor, QPen 
     37from PyQt4.QtGui import QColor, QPen, QBrush 
    3838from PyQt4.QtCore import Qt 
    3939 
     
    6161        p.setWidth(self.width) 
    6262        return p 
     63         
     64    def brush(self): 
     65        return QBrush(self.color) 
    6366 
    6467class Palette: 
  • orange/OrangeWidgets/QtGraph.py

    r8280 r8281  
    9292        self.map_to_graph = self.map_to_graph_cart 
    9393        self.map_from_graph = self.map_from_graph_cart 
     94         
     95        ## Performance optimization 
     96        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) 
    9497 
    9598        self.update() 
     
    279282        pass 
    280283         
    281     def addCurve(self, name, brushColor = Qt.black, penColor = Qt.black, size = 5, style = Qt.SolidLine,  
     284    def addCurve(self, name, brushColor = Qt.black, penColor = Qt.black, size = 5, style = Qt.NoPen,  
    282285                 symbol = palette.EllipseShape, enableLegend = 0, xData = [], yData = [], showFilledSymbols = None, 
    283286                 lineWidth = 1, pen = None, autoScale = 0, antiAlias = None, penAlpha = 255, brushAlpha = 255): 
Note: See TracChangeset for help on using the changeset viewer.