Changeset 8387:f25e3d47fe86 in orange


Ignore:
Timestamp:
07/08/11 16:34:25 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
5aa4e05b669bb4dbd32feca357bc8dd78ec1fe96
Message:

Add a CircleCurve and use it in RadVizQt

Location:
orange/OrangeWidgets
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Prototypes/OWLinProjGraphQt.py

    r8379 r8387  
    6868        self.data_range[xBottom] = range 
    6969        self.data_range[yLeft] = range 
     70         
     71        self._extra_curves = [] 
    7072 
    7173    def setData(self, data, subsetData = None, **args): 
     
    8183    # update shown data. Set labels, coloring by className .... 
    8284    def updateData(self, labels = None, setAnchors = 0, **args): 
     85        self._extra_curves = [] 
    8386        self.clear() 
    8487        self.tooltipMarkers = [] 
     
    105108        if self.showAnchors: 
    106109            if self.hideRadius > 0: 
    107                 xdata = self.createXAnchors(100)*(self.hideRadius / 10) 
    108                 ydata = self.createYAnchors(100)*(self.hideRadius / 10) 
    109                 self.addCurve("hidecircle", QColor(200,200,200), QColor(200,200,200), 1, style = Qt.SolidLine, symbol = OWCurve.NoSymbol, xData = xdata.tolist() + [xdata[0]], yData = ydata.tolist() + [ydata[0]]) 
     110                circle = CircleCurve(QColor(200,200,200), QColor(200,200,200), radius = hideRadius) 
     111                self.add_custom_curve(circle) 
     112                self._extra_curves.append(circle) 
    110113 
    111114            # draw dots at anchors 
     
    128131                XAnchors = [a[0] for a in shownAnchorData] 
    129132                YAnchors = [a[1] for a in shownAnchorData] 
    130                 self.addCurve("dots", QColor(160,160,160), QColor(160,160,160), 10, style = Qt.NoPen, symbol = OWCurve.Ellipse, xData = XAnchors, yData = YAnchors, showFilledSymbols = 1) 
     133                self._extra_curves.append(self.addCurve("dots", QColor(160,160,160), QColor(160,160,160), 10, style = Qt.NoPen, symbol = OWCurve.Ellipse, xData = XAnchors, yData = YAnchors, showFilledSymbols = 1)) 
    131134 
    132135                # draw text at anchors 
     
    137140        if self.showAnchors and self.normalizeExamples: 
    138141            # draw "circle" 
    139             xdata = self.createXAnchors(100) 
    140             ydata = self.createYAnchors(100) 
    141             self.addCurve("circle", QColor(Qt.black), QColor(Qt.black), 1, style = Qt.SolidLine, symbol = OWCurve.NoSymbol, xData = xdata.tolist() + [xdata[0]], yData = ydata.tolist() + [ydata[0]]) 
     142            circle = CircleCurve() 
     143            self.add_custom_curve(circle) 
     144            self._extra_curves.append(circle) 
    142145 
    143146        self.potentialsClassifier = None # remove the classifier so that repaint won't recompute it 
     
    721724    def updateCurves(self): 
    722725        for c in self.itemList(): 
    723             if isinstance(c, OWCurve): 
     726            if isinstance(c, OWCurve) and c not in self._extra_curves: 
    724727                c.setPointSize(self.pointWidth) 
    725728                color = c.color() 
  • orange/OrangeWidgets/plot/owplot.py

    r8385 r8387  
    315315                 lineWidth = 1, pen = None, autoScale = 0, antiAlias = None, penAlpha = 255, brushAlpha = 255,  
    316316                 x_axis_key = xBottom, y_axis_key = yLeft): 
    317          
    318317        c = OWCurve(xData, yData, parent=self.graph_item) 
    319318        c.setAxes(x_axis_key, y_axis_key) 
     
    321320        c.name = name 
    322321        c.setAutoUpdate(False) 
    323         c.setContinuous(style is not Qt.NoPen) 
     322        c.setStyle(style) 
    324323        c.setColor(brushColor) 
    325324        c.setSymbol(symbol) 
  • orange/OrangeWidgets/plot/owtools.py

    r8374 r8387  
    102102            self.setPen(pen) 
    103103        self.name = name 
     104         
     105class CircleCurve(OWCurve): 
     106    def __init__(self, pen = QPen(Qt.black), brush = QBrush(Qt.NoBrush), xCenter = 0.0, yCenter = 0.0, radius = 1.0): 
     107        OWCurve.__init__(self) 
     108        self.setPen(pen) 
     109        self.setBrush(brush) 
     110        self._item = QGraphicsEllipseItem(self) 
     111        self.center = xCenter, yCenter 
     112        self.radius = radius 
     113        self._rect = QRectF(xCenter-radius, yCenter-radius, 2*radius, 2*radius) 
     114         
     115    def updateProperties(self): 
     116        self._item.setRect(self.graphTransform().mapRect(self.dataRect())) 
     117        self._item.setPen(self.pen()) 
     118        self._item.setBrush(self.brush()) 
     119         
     120    def dataRect(self): 
     121        x, y = self.center 
     122        r = self.radius 
     123        return QRectF(x-r, y-r, 2*r, 2*r) 
Note: See TracChangeset for help on using the changeset viewer.