Changeset 8466:e499c3fb6fe2 in orange


Ignore:
Timestamp:
07/26/11 10:57:02 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
774559688ddc080e1f73f8e52c85ff92f9ed329a
Message:

Add more methods to OWPlotGUI and use them in ScatterPlot and LinProj

Location:
orange/OrangeWidgets
Files:
5 edited

Legend:

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

    r8379 r8466  
    143143        self.extraTopBox = OWGUI.widgetBox(self.SettingsTab, orientation = "vertical") 
    144144        self.extraTopBox.hide() 
    145  
    146         box = OWGUI.widgetBox(self.SettingsTab, "Point Properties") 
    147         OWGUI.hSlider(box, self, 'graph.pointWidth', label = "Size: ", minValue=1, maxValue=20, step=1, callback = self.graph.updateCurves) 
    148         OWGUI.hSlider(box, self, 'graph.alphaValue', label = "Transparency: ", minValue=0, maxValue=255, step=10, callback = self.graph.updateCurves) 
     145         
     146        self.graph.gui.point_properties_box(self.SettingsTab) 
    149147 
    150148        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options") 
     
    157155        box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings") 
    158156        #OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph) 
    159         OWGUI.checkBox(box, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph) 
     157        self.graph.gui.show_legend_check_box(box) 
    160158        bbox = OWGUI.widgetBox(box, orientation = "horizontal") 
    161159        OWGUI.checkBox(bbox, self, 'graph.showValueLines', 'Show value lines  ', callback = self.updateGraph) 
     
    163161        OWGUI.checkBox(box, self, 'graph.useDifferentSymbols', 'Use different symbols', callback = self.updateGraph, tooltip = "Show different class values using different symbols") 
    164162        OWGUI.checkBox(box, self, 'graph.useDifferentColors', 'Use different colors', callback = self.updateGraph, tooltip = "Show different class values using different colors") 
    165         OWGUI.checkBox(box, self, 'graph.showFilledSymbols', 'Show filled symbols', callback = self.updateGraph) 
    166         OWGUI.checkBox(box, self, 'graph.useAntialiasing', 'Use antialiasing', callback = self.updateGraph) 
     163        self.graph.gui.filled_symbols_check_box(box) 
     164        self.graph.gui.antialiasing_check_box(box) 
    167165        wbox = OWGUI.widgetBox(box, orientation = "horizontal") 
    168166        OWGUI.checkBox(wbox, self, 'graph.showProbabilities', 'Show probabilities'+'  ', callback = self.updateGraph, tooltip = "Show a background image with class probabilities") 
  • orange/OrangeWidgets/Prototypes/OWScatterPlotGraphQt.py

    r8462 r8466  
    404404##            for (p1, p2) in closure: 
    405405##                self.addCurve("", color, color, 1, QwtPlotCurve.Lines, OWPoint.NoSymbol, xData = [float(shortData[p1][0]), float(shortData[p2][0])], yData = [float(shortData[p1][1]), float(shortData[p2][1])], lineWidth = width) 
     406     
     407    def update_point_size(self): 
     408        if self.scatterWidget.attrSize: 
     409            self.scatterWidget.updateGraph() 
     410        else: 
     411            self.update_curves() 
     412     
    406413 
    407414    def addTip(self, x, y, attrIndices = None, dataindex = None, text = None): 
  • orange/OrangeWidgets/Prototypes/OWScatterPlotQt.py

    r8463 r8466  
    104104        # SETTINGS TAB 
    105105        # point width 
    106         pointBox = OWGUI.widgetBox(self.SettingsTab, "Point Properties") 
    107         OWGUI.hSlider(pointBox, self, 'graph.pointWidth', label = "Symbol size:   ", minValue=1, maxValue=20, step=1, callback = self.pointSizeChange) 
    108         OWGUI.hSlider(pointBox, self, 'graph.alphaValue', label = "Transparency: ", minValue=0, maxValue=255, step=10, callback = self.alphaChange) 
     106        self.graph.gui.point_properties_box(self.SettingsTab) 
    109107 
    110108        # ##### 
     
    119117        OWGUI.checkBox(box4, self, 'graph.showYLaxisTitle', 'Y axis title', callback = self.graph.setShowYLaxisTitle) 
    120118        OWGUI.checkBox(box4, self, 'graph.showAxisScale', 'Show axis scale', callback = self.updateGraph) 
    121         self.graph.gui.show_legend_check_box(box4) 
    122         self.graph.gui.filled_symbols_check_box(box4) 
    123         OWGUI.checkBox(box4, self, 'showGridlines', 'Show gridlines', callback = self.setShowGridlines) 
    124         self.graph.gui.antialiasing_check_box(box4) 
    125  
     119         
     120        g = self.graph.gui 
     121        g.add_widgets([g.ShowLegend, g.ShowFilledSymbols, g.ShowGridLines, g.Antialiasing], box4) 
     122         
    126123        box5 = OWGUI.widgetBox(box4, orientation = "horizontal") 
    127124        OWGUI.checkBox(box5, self, 'graph.showProbabilities', 'Show probabilities'+'  ', callback = self.updateGraph, tooltip = "Show a background image with class probabilities") 
     
    352349        self.progressBar.setTotalSteps(total) 
    353350        self.progressBar.setProgress(current) 
    354  
    355     def alphaChange(self): 
    356         for curve in self.graph.plot_items(): 
    357             if isinstance(curve, OWCurve): 
    358                 color = curve.color() 
    359                 color.setAlpha(self.graph.alpha_value) 
    360                 curve.set_color(color) 
    361         self.graph.replot() 
    362  
    363     def pointSizeChange(self): 
    364         if self.attrSize: 
    365             self.updateGraph() 
    366         else: 
    367             for curve in self.graph.plot_items(): 
    368                 if isinstance(curve, OWCurve): 
    369                     curve.set_point_size(self.graph.point_width) 
    370             self.graph.replot() 
    371  
     351         
    372352    def setShowGridlines(self): 
    373353        self.graph.enableGridXB(self.showGridlines) 
  • orange/OrangeWidgets/plot/owplot.py

    r8463 r8466  
    130130        self.show_filled_symbols = True 
    131131        self.alpha_value = 1 
     132        self.show_grid = False 
    132133         
    133134        self.palette = shared_palette() 
     
    599600        ## TODO: Implement this in Curve.cpp 
    600601        pass 
     602     
     603    def update_grid(self): 
     604        ## TODO: Implement gridlines 
     605        pass 
    601606         
    602607    def legend(self): 
     
    10091014        for c in self.plot_items(): 
    10101015            if isinstance(c, orangeplot.Curve): 
    1011                 au = c.autoUpdate() 
     1016                au = c.auto_update() 
    10121017                c.set_auto_update(False) 
    10131018                c.set_point_size(self.point_width) 
     
    10171022                c.set_auto_update(au) 
    10181023                c.update_properties() 
    1019                  
     1024     
     1025    update_point_size = update_curves 
     1026    update_alpha_value = update_curves 
     1027             
    10201028    def update_antialiasing(self): 
    10211029        self.setRenderHint(QPainter.Antialiasing, self.use_antialiasing) 
  • orange/OrangeWidgets/plot/owplotgui.py

    r8463 r8466  
    55        self._plot = plot 
    66         
     7    Antialiasing = 1 
     8    ShowLegend = 2 
     9    ShowFilledSymbols = 3 
     10    ShowGridLines = 4 
     11    PointSize = 5 
     12    AlphaValue = 6 
     13         
     14    def _get_callback(self, name): 
     15        return getattr(self._plot, name, self._plot.replot) 
     16         
     17    def _check_box(self, widget, value, label, cb_name): 
     18        OWGUI.checkBox(widget, self._plot, value, label, callback=self._get_callback(cb_name))     
     19         
    720    def antialiasing_check_box(self, widget): 
    8         OWGUI.checkBox(widget, self._plot, 'use_antialiasing', 'Use antialiasing', callback = self._plot.update_antialiasing) 
     21        self._check_box(widget, 'use_antialiasing', 'Use antialiasing', 'update_antialiasing') 
    922         
    1023    def show_legend_check_box(self, widget): 
    11         OWGUI.checkBox(widget, self._plot, 'show_legend', 'Show legend', callback = self._plot.update_legend) 
     24        self._check_box(widget, 'show_legend', 'Show legend', 'update_legend') 
    1225     
    1326    def filled_symbols_check_box(self, widget): 
    14         OWGUI.checkBox(widget, self._plot, 'show_filled_symbols', 'Show filled symbols', callback = self._plot.update_filled_symbols) 
    15  
     27        self._check_box(widget, 'show_filled_symbols', 'Show filled symbols', 'update_filled_symbols') 
     28         
     29    def grid_lines_check_box(self, widget): 
     30        self._check_box(widget, 'show_grid', 'Show gridlines', 'update_grid') 
     31         
     32    def _slider(self, widget, value, label, min_value, max_value, step, cb_name): 
     33        OWGUI.hSlider(widget, self._plot, value, label=label, minValue=min_value, maxValue=max_value, step=step, callback=self._get_callback(cb_name)) 
     34         
     35    def point_size_slider(self, widget): 
     36        self._slider(widget, 'point_width', "Symbol size:   ", 1, 20, 1, 'update_point_size') 
     37         
     38    def alpha_value_slider(self, widget): 
     39        self._slider(widget, 'alpha_value', "Transparency: ", 0, 255, 10, 'update_alpha_value') 
     40         
     41    def point_properties_box(self, widget): 
     42        return self.create_box([self.PointSize, self.AlphaValue], widget, "Point Properties") 
     43         
     44    _functions = { 
     45        Antialiasing : antialiasing_check_box, 
     46        ShowLegend : show_legend_check_box, 
     47        ShowFilledSymbols : filled_symbols_check_box, 
     48        ShowGridLines : grid_lines_check_box, 
     49        PointSize : point_size_slider, 
     50        AlphaValue : alpha_value_slider 
     51        } 
     52         
     53    def add_widget(self, id, widget): 
     54        if id in self._functions: 
     55            self._functions[id](self, widget) 
     56             
     57    def add_widgets(self, ids, widget): 
     58        for id in ids: 
     59            self.add_widget(id, widget) 
     60             
     61    def create_box(self, ids, widget, name): 
     62        box = OWGUI.widgetBox(widget, name) 
     63        self.add_widgets(ids, widget) 
     64        return box 
Note: See TracChangeset for help on using the changeset viewer.