Changeset 8209:618db2c1fdb4 in orange


Ignore:
Timestamp:
08/18/11 09:44:03 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
5e6bbb1d0d77be81b33efaf4e7ebc5c940796153
Message:

Improvements in QWParallelCoordinates: disable AA, make axes zoomable, and ensure legend is always created and respects the 'show_legend' setting.

Location:
orange/OrangeWidgets
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Visualize Qt/OWParallelCoordinatesQt.py

    r8173 r8209  
    9393        OWGUI.checkBox(box, self, 'graph.showAttrValues', 'Show attribute values', callback = self.updateGraph) 
    9494        OWGUI.checkBox(box, self, 'graph.useSplines', 'Show splines', callback = self.updateGraph, tooltip  = "Show lines using splines") 
    95         OWGUI.checkBox(box, self, 'graph.show_legend', 'Show legend', callback = self.updateGraph) 
     95         
     96        self.graph.gui.show_legend_check_box(box) 
    9697 
    9798        box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance") 
  • orange/OrangeWidgets/Visualize Qt/OWParallelGraphQt.py

    r8173 r8209  
    3939        self.bottomPixmap = QPixmap(os.path.join(orngEnviron.directoryNames["widgetDir"], "icons/upgreenarrow.png")) 
    4040        self.topPixmap = QPixmap(os.path.join(orngEnviron.directoryNames["widgetDir"], "icons/downgreenarrow.png")) 
     41        self.update_antialiasing(False) 
    4142 
    4243    def setData(self, data, subsetData = None, **args): 
     
    189190        for i in range(len(attributes)): 
    190191            id = UserAxis + i 
    191         self.add_axis(UserAxis + i, line = QLineF(i, 0, i, 1), arrows = AxisStart | AxisEnd) 
    192         self.axes[id].always_horizontal_text = True 
     192        a = self.add_axis(id, line = QLineF(i, 0, i, 1), arrows = AxisStart | AxisEnd, zoomable = True) 
     193        a.always_horizontal_text = True 
     194        a.max_text_width = 100 
    193195            if self.showAttrValues == 1: 
    194196                attr = self.dataDomain[attributes[i]] 
     
    283285        if self.dataHasClass: 
    284286            if self.dataDomain.classVar.varType == orange.VarTypes.Discrete: 
    285                 legendKeys = [] 
     287                self.legend().clear() 
    286288                varValues = getVariableValuesSorted(self.dataDomain.classVar) 
    287                 #self.addCurve("<b>" + self.dataDomain.classVar.name + ":</b>", QColor(0,0,0), QColor(0,0,0), 0, symbol = OWPoint.NoSymbol, enableLegend = 1) 
    288289                for ind in range(len(varValues)): 
    289                     #self.addCurve(varValues[ind], self.discPalette[ind], self.discPalette[ind], 15, symbol = OWPoint.Rect, enableLegend = 1) 
    290                     legendKeys.append((varValues[ind], self.discPalette[ind])) 
    291                 if legendKeys != self.oldLegendKeys: 
    292                     self.oldLegendKeys = legendKeys 
    293                     self.legend().clear() 
    294                     for (name, color) in legendKeys: 
    295                         self.legend().add_item(self.dataDomain.classVar.name, name, OWPoint(OWPoint.Rect, color, self.point_width)) 
     290                    self.legend().add_item(self.dataDomain.classVar.name, varValues[ind], OWPoint(OWPoint.Rect, self.discPalette[ind], self.point_width)) 
    296291            else: 
    297292                values = self.attrValues[self.dataDomain.classVar.name] 
  • orange/OrangeWidgets/plot/owaxis.py

    r8172 r8209  
    3636from math import * 
    3737 
    38 from PyQt4.QtGui import QGraphicsItem, QGraphicsLineItem, QGraphicsTextItem, QPainterPath, QGraphicsPathItem, QGraphicsScene, QTransform 
     38from PyQt4.QtGui import QGraphicsItem, QGraphicsLineItem, QGraphicsTextItem, QPainterPath, QGraphicsPathItem, QGraphicsScene, QTransform, QGraphicsRectItem, QPen 
    3939from PyQt4.QtCore import QLineF, QPointF, qDebug, QRectF, Qt 
    4040 
     
    7676        self.arrow_path = path 
    7777        self.label_items = [] 
     78        self.label_bg_items = [] 
    7879        self.tick_items = [] 
    7980        self._ticks = [] 
     
    192193        n = len(self._ticks) 
    193194        resize_plot_item_list(self.label_items, n, QGraphicsTextItem, self) 
     195        resize_plot_item_list(self.label_bg_items, n, QGraphicsRectItem, self) 
    194196        resize_plot_item_list(self.tick_items, n, QGraphicsLineItem, self) 
    195197         
     
    230232            item.setDefaultTextColor(text_color) 
    231233             
     234            self.label_bg_items[i].setRect(item.boundingRect()) 
     235            self.label_bg_items[i].setPen(QPen(Qt.NoPen)) 
     236            self.label_bg_items[i].setBrush(self.plot.color(OWPalette.Canvas)) 
     237             
    232238            item = self.tick_items[i] 
    233239            item.setVisible(True) 
  • orange/OrangeWidgets/plot/owplot.py

    r8198 r8209  
    5858    "activateRectangleSelection" : "activate_rectangle_selection",  
    5959    "activatePolygonSelection" : "activate_polygon_selection",  
     60    "activatePanning" : "activate_panning", 
    6061    "getSelectedPoints" : "get_selected_points", 
    6162    "setAxisScale" : "set_axis_scale", 
     
    505506        ''' 
    506507        self.state = SELECT_POLYGON 
     508         
     509    def activate_panning(self): 
     510        ''' 
     511            Activates the panning mode, where the user can move the zoom projection by dragging the mouse 
     512        ''' 
     513        self.state = PANNING 
    507514         
    508515    def set_show_main_title(self, b): 
     
    781788        if not axis_id in CartesianAxes: 
    782789            self.setShowAxisTitle(axis_id, True) 
     790        return a 
    783791         
    784792    def remove_all_axes(self, user_only = True): 
     
    10071015    def update_legend(self): 
    10081016        self._legend.setVisible(self.show_legend) 
     1017        if self.show_legend: 
     1018            r = self._legend.boundingRect() 
     1019            qDebug('Moving legend from ' + repr(r)) 
     1020            self.ensure_inside(r, self.contentsRect()) 
     1021            qDebug('to ' + repr(r)) 
     1022            self._legend.setPos(r.topLeft()) 
    10091023         
    10101024    def update_filled_symbols(self): 
Note: See TracChangeset for help on using the changeset viewer.