Changeset 8543:837bf95aac41 in orange


Ignore:
Timestamp:
07/30/11 20:42:53 (3 years ago)
Author:
matejd <matejd@…>
Branch:
default
Convert:
cac715744ca238a40826d14181d18b607a59135e
Message:

Switched to OWLinProjQt parent

File:
1 edited

Legend:

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

    r8542 r8543  
    55""" 
    66 
    7 from OWVisWidget import * 
    87from plot.owplot3d import * 
    9 from OWkNNOptimization import OWVizRank 
    10 from OWFreeVizOptimization import * 
    11 import OWToolbars, OWGUI, orngTest 
    12 import orngVizRank 
     8from plot.owplotgui import OWPlotGUI 
     9from OWLinProjQt import * 
    1310 
    1411class OWRadviz3DPlot(OWPlot3D, orngScaleLinProjData): 
     
    1714        orngScaleLinProjData.__init__(self) 
    1815 
    19         self.show_value_lines = False 
    20         self.value_line_length = 0 
    21         self.use_different_symbols = True 
    22         self.use_different_colors = True 
    23         self.send_selection_on_update = False 
     16        self.point_width = 5 
     17        self.alpha_value = 255 
     18        self.show_filled_symbols = True 
     19        self.use_antialiasing = True 
     20        self.sendSelectionOnUpdate = False 
     21        self.setCanvasBackground = self.setCanvasColor 
    2422 
    25     def set_data(self, data, subset_data=None, **args): 
    26         orngScaleLinProjData.setData(self, data, subset_data, **args) 
     23        self.gui = OWPlotGUI(self) 
    2724 
    28 class OWRadviz3D(OWVisWidget): 
     25    def setData(self, data, subsetData=None, **args): 
     26        orngScaleLinProjData.setData(self, data, subsetData, **args) 
     27 
     28    def setCanvasColor(self, c): 
     29        pass 
     30 
     31    def updateData(self, labels=None, setAnchors=0, **args): 
     32        pass 
     33 
     34    def getSelectionsAsExampleTables(self, attrList, useAnchorData=1, addProjectedPositions=0): 
     35        return (None, None) 
     36 
     37    def replot(self): 
     38        pass 
     39 
     40class OWRadviz3D(OWLinProjQt): 
    2941    settingsList = ['showAllAttributes'] 
    30     jitter_size_nums = [0.0, 0.01, 0.1, 0.5, 1, 2, 3, 4, 5, 7, 10, 15, 20] 
    3142 
    3243    def __init__(self, parent=None, signalManager=None): 
    33         name = 'Radviz' 
    34         OWVisWidget.__init__(self, parent, signalManager, 'Radviz', TRUE) 
     44        OWLinProjQt.__init__(self, parent, signalManager, "Radviz", graphClass=OWRadviz3DPlot) 
    3545 
    36         self.inputs = [("Examples", ExampleTable, self.set_data, Default), 
    37                        ("Example Subset", ExampleTable, self.set_subset_data), 
    38                        ("Attribute Selection List", AttributeList, self.set_shown_attributes), 
    39                        ("Evaluation Results", orngTest.ExperimentResults, self.set_test_results), 
    40                        ("VizRank Learner", orange.Learner, self.set_vizrank_learner)] 
     46        self.inputs = [("Examples", ExampleTable, self.setData, Default), 
     47                       ("Example Subset", ExampleTable, self.setSubsetData), 
     48                       ("Attribute Selection List", AttributeList, self.setShownAttributes), 
     49                       ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults), 
     50                       ("VizRank Learner", orange.Learner, self.setVizRankLearner)] 
    4151        self.outputs = [("Selected Examples", ExampleTable), 
    4252                        ("Unselected Examples", ExampleTable), 
    4353                        ("Attribute Selection List", AttributeList)] 
    44  
    45         self.showAllAttributes = 0 
    46         self.showSelectedAttributes = 0 
    47         self.auto_send_selection = 0 
    48  
    49         self.plot = OWRadviz3DPlot(self, self.mainArea, name) 
    50         self.mainArea.layout().addWidget(self.plot) 
    51  
    52         self.vizrank = OWVizRank(self, self.signalManager, self.plot, orngVizRank.RADVIZ, name) 
    53         self.connect(self.graphButton, SIGNAL("clicked()"), self.save_to_file) 
    54  
    55         self.tabs = OWGUI.tabWidget(self.controlArea) 
    56         self.general_tab = OWGUI.createTabPage(self.tabs, 'Main') 
    57         self.settings_tab = OWGUI.createTabPage(self.tabs, 'Settings', canScroll=1) 
    58  
    59         self.createShowHiddenLists(self.general_tab, callback=self.update_plot_and_anchors) 
    60  
    61         self.optimization_buttons = OWGUI.widgetBox(self.general_tab, "Optimization Dialogs", orientation="horizontal") 
    62         self.vizrank_button = OWGUI.button(self.optimization_buttons, self, "VizRank", callback=self.vizrank.reshow, 
    63             tooltip="Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.", 
    64             debuggingEnabled=0) 
    65  
    66         self.wd_child_dialogs = [self.vizrank] 
    67  
    68         self.free_viz_dlg = FreeVizOptimization(self, self.signalManager, self.plot, name) 
    69         self.wd_child_dialogs.append(self.free_viz_dlg) 
    70         self.free_viz_dlg_button = OWGUI.button(self.optimization_buttons, 
    71             self, 'FreeViz', callback=self.free_viz_dlg.reshow, 
    72             tooltip="Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved", 
    73             debuggingEnabled=0) 
    74         self.zoom_select_toolbar = OWToolbars.ZoomSelectToolbar(self, self.general_tab, self.plot, self.auto_send_selection) 
    75         self.plot.auto_send_selection_callback = self.selection_changed 
    76         self.connect(self.zoom_select_toolbar.buttonSendSelections, SIGNAL("clicked()"), self.send_selections) 
    77  
    78         self.extra_top_box = OWGUI.widgetBox(self.settings_tab, orientation="vertical") 
    79         self.extra_top_box.hide() 
    80  
    81         #self.plot.gui.point_properties_box(self.SettingsTab) 
    82  
    83         box = OWGUI.widgetBox(self.settings_tab, "Jittering Options") 
    84         OWGUI.comboBoxWithCaption(box, self, "plot.jitter_size", 'Jittering size (% of range):', 
    85             callback=self.reset_plot_data, items=self.jitter_size_nums, sendSelectedValue=1, valueType=float) 
    86         OWGUI.checkBox(box, self, 'plot.jitter_continuous', 
    87             'Jitter continuous attributes', 
    88             callback=self.reset_plot_data, 
    89             tooltip="Does jittering apply also on continuous attributes?") 
    90  
    91         box = OWGUI.widgetBox(self.settings_tab, "Scaling Options") 
    92         OWGUI.qwtHSlider(box, self, "plot.scale_factor", 
    93             label='Inflate points by: ', 
    94             minValue=1.0, maxValue= 10.0, step=0.1, 
    95             callback=self.update_plot, 
    96             tooltip="If points lie too much together you can expand their position to improve perception", 
    97             maxWidth=90) 
    98  
    99         box = OWGUI.widgetBox(self.settings_tab, "General Graph Settings") 
    100         #self.graph.gui.show_legend_check_box(box) 
    101         bbox = OWGUI.widgetBox(box, orientation="horizontal") 
    102         OWGUI.checkBox(bbox, self, 'plot.show_value_lines', 'Show value lines  ', callback=self.update_plot) 
    103         OWGUI.qwtHSlider(bbox, self, 'plot.value_line_length', minValue=1, maxValue=10, step=1, callback=self.update_plot, showValueLabel=0) 
    104         OWGUI.checkBox(box, self, 'plot.use_different_symbols', 'Use different symbols', callback=self.update_plot, 
    105             tooltip="Show different class values using different symbols") 
    106         OWGUI.checkBox(box, self, 'plot.use_different_colors', 'Use different colors', 
    107             callback=self.update_plot, tooltip="Show different class values using different colors") 
    108  
    109         box = OWGUI.widgetBox(self.settings_tab, "Colors", orientation="horizontal") 
    110         OWGUI.button(box, self, "Colors", self.set_colors, 
    111             tooltip="Set the canvas background color and color palette for coloring variables", 
    112             debuggingEnabled=0) 
    113  
    114         self.tooltip_kind = 0 
    115         self.tooltip_value = 0 
    116         box = OWGUI.widgetBox(self.settings_tab, "Tooltips Settings") 
    117         OWGUI.comboBox(box, self, "tooltip_kind", 
    118             items=["Show line tooltips", "Show visible attributes", "Show all attributes"], 
    119             callback=self.update_plot) 
    120         OWGUI.comboBox(box, self, "tooltip_value", 
    121             items=["Tooltips show data values", "Tooltips show spring values"], 
    122             callback=self.update_plot, 
    123             tooltip="Do you wish that tooltips would show you original values of visualized"+\ 
    124                     "attributes or the 'spring' values (values between 0 and 1). \nSpring values "+\ 
    125                     "are scaled values that are used for determining the position of shown points."+\ 
    126                     "Observing these values will therefore enable you to \nunderstand why the points are placed where they are.") 
    127  
    128         self.auto_send_selection = 0 
    129         self.add_projected_positions = 0 
    130         box = OWGUI.widgetBox(self.settings_tab, "Auto Send Selected Data When...") 
    131         OWGUI.checkBox(box, self, 'auto_send_selection', 'Adding/Removing selection areas', 
    132             callback=self.selection_changed, tooltip="Send selected data whenever a selection area is added or removed") 
    133         OWGUI.checkBox(box, self, 'plot.send_selection_on_update', 'Moving/Resizing selection areas', 
    134             tooltip="Send selected data when a user moves or resizes an existing selection area") 
    135         OWGUI.comboBox(box, self, "add_projected_positions", 
    136             items=["Do not modify the domain", "Append projection as attributes", "Append projection as meta attributes"], 
    137             callback=self.send_selections) 
    138         self.selection_changed() 
    139  
    140         self.settings_tab.layout().addStretch(100) 
    141         self.resize(900, 700) 
    142  
    143     def selection_changed(self): 
    144         pass 
    145  
    146     def update_plot_and_anchors(self): 
    147         pass 
    148  
    149     def send_selections(self): 
    150         pass 
    151  
    152     def reset_plot_data(self): 
    153         pass 
    154  
    155     def update_plot(self): 
    156         pass 
    157  
    158     updateGraph = update_plot 
    159  
    160     def set_colors(self): 
    161         pass 
    162  
    163     def set_data(self, data): 
    164         self.data = data 
    165  
    166     def set_subset_data(self, subset_data): 
    167         self.subset_data = subset_data 
    168  
    169     def set_shown_attributes(self, attrs): 
    170         pass 
    171  
    172     def set_test_results(self, results): 
    173         pass 
    174  
    175     def set_vizrank_learner(self, leaner): 
    176         pass 
    177  
    178     def save_to_file(self, file): 
    179         pass 
    18054 
    18155if __name__ == '__main__': 
     
    18458    radviz.show() 
    18559    data = orange.ExampleTable('../../doc/datasets/iris') 
    186     radviz.set_data(data) 
     60    radviz.setData(data) 
    18761    radviz.handleNewSignals() 
    18862    app.exec_() 
Note: See TracChangeset for help on using the changeset viewer.