Example #1
0
    def __init__(self, parent=None, signalManager=None, name="Vulcano Plot"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Examples", ExampleTable, self.setData)]
        self.outputs = [("Examples with selected attributes", ExampleTable)]

        self.genes_in_columns = False

        self.showXTitle = True
        self.showYTitle = True

        self.auto_commit = False
        self.selection_changed_flag = False
        self.target_group = None, []
        self.label_selections = []

        self.graph = VulcanoGraph(self)
        self.connect(self.graph, SIGNAL("selectionChanged()"),
                     self.on_selection_changed)
        self.mainArea.layout().addWidget(self.graph)

        self.loadSettings()

        ## GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoLabel = OWGUI.label(box, self, "")
        self.infoLabel.setText("No data on input")
        self.infoLabel2 = OWGUI.label(box, self, "")
        self.infoLabel2.setText("0 selected genes")
        
        box = OWGUI.widgetBox(self.controlArea, "Target Labels")
        
        self.target_widget = LabelSelectionWidget(self)
        self.connect(self.target_widget,
                     SIGNAL("selection_changed(PyQt_PyObject, PyQt_PyObject)"),
                     self.on_target_changed)
        self.connect(self.target_widget,
                     SIGNAL("label_activated(int)"),
                     self.on_label_activated)
        
        box.layout().addWidget(self.target_widget)
        
        self.genesInColumnsCheck = OWGUI.checkBox(box, self, "genes_in_columns",
                                    "Genes in columns", 
                                    callback=[self.init_from_data, self.plot])

        box = OWGUI.widgetBox(self.controlArea, "Settings")
        OWGUI.hSlider(box, self, "graph.symbolSize", label="Symbol size:   ", minValue=2, maxValue=20, step=1, callback = self.graph.updateSymbolSize)
        OWGUI.checkBox(box, self, "showXTitle", "X axis title", callback=self.setAxesTitles)
        OWGUI.checkBox(box, self, "showYTitle", "Y axis title", callback=self.setAxesTitles)
        
        toolbar = ZoomSelectToolbar(self, self.controlArea, self.graph, buttons=[ZoomSelectToolbar.IconSelect, ZoomSelectToolbar.IconZoom, ZoomSelectToolbar.IconPan])
        
        top_layout = toolbar.layout()
        top_layout.setDirection(QBoxLayout.TopToBottom)
        button_layotu = QHBoxLayout()
        top_layout.insertLayout(0, button_layotu)
        
        for i in range(1, top_layout.count()):
            item = top_layout.itemAt(1)
            top_layout.removeItem(item)
            button_layotu.addItem(item)
        
        OWGUI.checkBox(toolbar, self, "graph.symetricSelections", "Symetric selection", callback=self.graph.reselect)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        b = OWGUI.button(box, self, "Commit", callback=self.commit, default=True)
        cb = OWGUI.checkBox(box, self, "auto_commit", "Commit automatically")
        OWGUI.setStopper(self, b, cb, "selection_changed_flag", self.commit_if)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        
        OWGUI.rubber(self.controlArea)

        self.data = None
        self.target_group = None, []
        self.current_selection = []

        self.graph.reselect(True)
        self.resize(800, 600)
    def __init__(self, parent=None, signalManager = None):
#        self.callbackDeposit = [] # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager, 'Expression Profiles', 1)

        #set default settings
        self.ShowAverageProfile = 1
        self.ShowSingleProfiles = 0
        self.PointWidth = 2
        self.CurveWidth = 1
        self.AverageCurveWidth = 4
        self.BoxPlotWidth = 2
        self.SelectedClasses = []
        self.Classes = []
        self.autoSendSelected = 0
        self.selectionChangedFlag = False

        self.CutLow = 0; self.CutHigh = 0; self.CutEnabled = 0
        
        self.profileLabel = None

        #load settings
        self.loadSettings()

        # GUI
        self.graph = profilesGraph(self, self.mainArea, "")
        self.mainArea.layout().addWidget(self.graph)
        self.graph.hide()
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        # GUI definition
        self.tabs = OWGUI.tabWidget(self.space)

        # GRAPH TAB
        GraphTab = OWGUI.createTabPage(self.tabs, "Graph")

        ## display options
        self.infoLabel = OWGUI.widgetLabel(OWGUI.widgetBox(GraphTab, "Info"), "No data on input.")
        displayOptBox = OWGUI.widgetBox(GraphTab, "Display") #QVButtonGroup("Display", GraphTab)
        displayOptButtons = ['Majority Class', 'Majority Class Probability', 'Target Class Probability', 'Number of Instances']
        OWGUI.checkBox(displayOptBox, self, 'ShowSingleProfiles', 'Expression Profiles', tooltip='', callback=self.updateShowSingleProfiles)
        OWGUI.checkBox(displayOptBox, self, 'ShowAverageProfile', 'Box Plot', tooltip='', callback=self.updateShowAverageProfile)

        ## class selection (classQLB)
        self.classQVGB = OWGUI.widgetBox(GraphTab, "Classes") #QVGroupBox(GraphTab)
##        self.classQVGB.setTitle("Classes")
        self.classQLB = OWGUI.listBox(self.classQVGB, self, "SelectedClasses", "Classes", selectionMode=QListWidget.MultiSelection, callback=self.classSelectionChange) #QListBox(self.classQVGB)
##        self.classQLB.setSelectionMode(QListBox.Multi)
        self.unselectAllClassedQLB = OWGUI.button(self.classQVGB, self, "Unselect all", callback=self.SUAclassQLB) #QPushButton("(Un)Select All", self.classQVGB)
##        self.connect(self.unselectAllClassedQLB, SIGNAL("clicked()"), self.SUAclassQLB)
##        self.connect(self.classQLB, SIGNAL("selectionChanged()"), self.classSelectionChange)

        ## show single/average profile
##        self.showAverageQLB = QPushButton("Box Plot", self.classQVGB)
##        self.showAverageQLB.setToggleButton(1)
##        self.showAverageQLB.setOn(self.ShowAverageProfile)
##        self.showSingleQLB = QPushButton("Single Profiles", self.classQVGB)
##        self.showSingleQLB.setToggleButton(1)
##        self.showSingleQLB.setOn(self.ShowSingleProfiles)
##        self.connect(self.showAverageQLB, SIGNAL("toggled(bool)"), self.updateShowAverageProfile)
##        self.connect(self.showSingleQLB, SIGNAL("toggled(bool)"), self.updateShowSingleProfiles)

##        self.tabs.insertTab(GraphTab, "Graph")

        # SETTINGS TAB
        SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") #QVGroupBox(self)

        self.profileLabelComboBox = OWGUI.comboBox(SettingsTab, self, 'profileLabel', 'Profile Labels', sendSelectedValue=True, valueType=str)
        OWGUI.hSlider(SettingsTab, self, 'PointWidth', box='Point Width', minValue=0, maxValue=9, step=1, callback=self.updatePointWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'CurveWidth', box='Profile Width', minValue=1, maxValue=9, step=1, callback=self.updateCurveWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'AverageCurveWidth', box='Average Profile Width', minValue=1, maxValue=9, step=1, callback=self.updateAverageCurveWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'BoxPlotWidth', box='Box Plot Width', minValue=0, maxValue=9, step=1, callback=self.updateBoxPlotWidth, ticks=1)
        OWGUI.checkBox(SettingsTab, self, 'graph.renderAntialiased', "Render antialiased", callback=self.graph.setCurveRenderHints)


    ## graph y scale
        box = OWGUI.widgetBox(SettingsTab, "Threshold/ Values") #QVButtonGroup("Threshol/ Values", SettingsTab)
        OWGUI.checkBox(box, self, 'CutEnabled', "Enabled", callback=self.setCutEnabled)
        self.sliderCutLow = OWGUI.qwtHSlider(box, self, 'CutLow', label='Low:', labelWidth=33, minValue=-20, maxValue=0, step=0.1, precision=1, ticks=0, maxWidth=80, callback=self.updateYaxis)
        self.sliderCutHigh = OWGUI.qwtHSlider(box, self, 'CutHigh', label='High:', labelWidth=33, minValue=0, maxValue=20, step=0.1, precision=1, ticks=0, maxWidth=80, callback=self.updateYaxis)
        if not self.CutEnabled:
            self.sliderCutLow.box.setDisabled(1)
            self.sliderCutHigh.box.setDisabled(1)

##        self.tabs.insertTab(SettingsTab, "Settings")

        self.toolbarSelection = ZoomSelectToolbar(self, self.controlArea, self.graph, self.autoSendSelected, buttons=(ZoomSelectToolbar.IconZoom, ZoomSelectToolbar.IconPan, ZoomSelectToolbar.IconSelect, ZoomSelectToolbar.IconSpace,
                                                                       ZoomSelectToolbar.IconRemoveLast, ZoomSelectToolbar.IconRemoveAll, ZoomSelectToolbar.IconSendSelection))
        cb = OWGUI.checkBox(self.controlArea, self, "autoSendSelected", "Auto send on selection change")
        OWGUI.setStopper(self, self.toolbarSelection.buttonSendSelections, cb, "selectionChangedFlag", self.commit)
        
        # inputs
        # data and graph temp variables
        
        self.inputs = [("Examples", ExampleTable, self.data, Default + Multiple)]
        self.outputs = [("Examples", ExampleTable, Default)]

        # temp variables
        self.MAdata = []
        self.classColor = None
        self.classBrighterColor = None
        self.numberOfClasses  = 0
        self.classValues = []
        self.ctrlPressed = False
        self.attrIcons = self.createAttributeIconDict()

        self.graph.canvas().setMouseTracking(1)

#        self.zoomStack = []
##        self.connect(self.graph,
##                     SIGNAL('plotMousePressed(const QMouseEvent&)'),
##                     self.onMousePressed)
##        self.connect(self.graph,
##                     SIGNAL('plotMouseReleased(const QMouseEvent&)'),
##                     self.onMouseReleased)
        self.resize(800,600)
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates",
                          True)

        #add a graph widget
        self.graph = OWParallelGraph(self, self.mainArea)
        self.mainArea.layout().addWidget(self.graph)

        self.showAllAttributes = 0

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Data Subset", ExampleTable, self.setSubsetData),
                       ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = [("Selected Data", ExampleTable),
                        ("Other Data", ExampleTable),
                        ("Features", AttributeList)]

        #set default settings
        self.data = None
        self.subsetData = None
        self.autoSendSelection = 1
        self.attrDiscOrder = "Unordered"
        self.attrContOrder = "Unordered"
        self.projections = None
        self.correlationDict = {}
        self.middleLabels = "Correlations"
        self.attributeSelectionList = None
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph.jitterSize = 10
        self.graph.showDistributions = 1
        self.graph.showStatistics = 0
        self.graph.showAttrValues = 1
        self.graph.useSplines = 0
        self.graph.enabledLegend = 1

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph)
        self.connect(self.shownAttribsLB,
                     SIGNAL('itemDoubleClicked(QListWidgetItem*)'),
                     self.flipAttribute)

        self.optimizationDlg = ParallelOptimization(
            self, signalManager=self.signalManager)
        self.optimizationDlgButton = OWGUI.button(
            self.GeneralTab,
            self,
            "Optimization Dialog",
            callback=self.optimizationDlg.reshow,
            debuggingEnabled=0)

        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(
            self,
            self.GeneralTab,
            self.graph,
            self.autoSendSelection,
            buttons=(1, 2, 0, 7, 8))
        self.connect(self.zoomSelectToolbar.buttonSendSelections,
                     SIGNAL("clicked()"), self.sendSelections)

        #connect controls to appropriate functions
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        # ####################################
        # SETTINGS functionality
        box = OWGUI.widgetBox(self.SettingsTab, "Transparency")
        OWGUI.hSlider(box,
                      self,
                      'graph.alphaValue',
                      label="Examples: ",
                      minValue=0,
                      maxValue=255,
                      step=10,
                      callback=self.updateGraph,
                      tooltip="Alpha value used for drawing example lines")
        OWGUI.hSlider(
            box,
            self,
            'graph.alphaValue2',
            label="Rest:     ",
            minValue=0,
            maxValue=255,
            step=10,
            callback=self.updateGraph,
            tooltip="Alpha value used to draw statistics, example subsets, ..."
        )

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBox(box,
                       self,
                       "graph.jitterSize",
                       label='Jittering size (% of size):  ',
                       orientation='horizontal',
                       callback=self.setJitteringSize,
                       items=self.jitterSizeNums,
                       sendSelectedValue=1,
                       valueType=float)

        # visual settings
        box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings")

        OWGUI.checkBox(box,
                       self,
                       'graph.showAttrValues',
                       'Show attribute values',
                       callback=self.updateGraph)
        OWGUI.checkBox(box,
                       self,
                       'graph.useAntialiasing',
                       'Use antialiasing',
                       callback=self.updateGraph)
        OWGUI.checkBox(box,
                       self,
                       'graph.useSplines',
                       'Show splines',
                       callback=self.updateGraph,
                       tooltip="Show lines using splines")
        OWGUI.checkBox(box,
                       self,
                       'graph.enabledLegend',
                       'Show legend',
                       callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance")
        resizeColsBox = OWGUI.widgetBox(box, 0, "horizontal", 0)
        OWGUI.label(resizeColsBox, self, "Increase/decrease distance: ")
        OWGUI.toolButton(resizeColsBox,
                         self,
                         "+",
                         callback=self.increaseAxesDistance,
                         tooltip="Increase the distance between the axes",
                         width=30,
                         height=20)
        OWGUI.toolButton(resizeColsBox,
                         self,
                         "-",
                         callback=self.decreaseAxesDistance,
                         tooltip="Decrease the distance between the axes",
                         width=30,
                         height=20)
        OWGUI.rubber(resizeColsBox)
        OWGUI.checkBox(
            box,
            self,
            "graph.autoUpdateAxes",
            "Auto scale X axis",
            tooltip="Auto scale X axis to show all visualized attributes",
            callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Statistical Information")
        OWGUI.comboBox(
            box,
            self,
            "graph.showStatistics",
            label="Statistics: ",
            orientation="horizontal",
            labelWidth=90,
            items=["No statistics", "Means, deviations", "Median, quartiles"],
            callback=self.updateGraph,
            sendSelectedValue=0,
            valueType=int)
        OWGUI.comboBox(
            box,
            self,
            "middleLabels",
            label="Middle labels: ",
            orientation="horizontal",
            labelWidth=90,
            items=["No labels", "Correlations", "VizRank"],
            callback=self.updateGraph,
            tooltip=
            "The information do you wish to view on top in the middle of coordinate axes",
            sendSelectedValue=1,
            valueType=str)
        OWGUI.checkBox(
            box,
            self,
            'graph.showDistributions',
            'Show distributions',
            callback=self.updateGraph,
            tooltip=
            "Show bars with distribution of class values (only for discrete attributes)"
        )

        box = OWGUI.widgetBox(self.SettingsTab,
                              "Colors",
                              orientation="horizontal")
        OWGUI.button(
            box,
            self,
            "Set colors",
            self.setColors,
            tooltip=
            "Set the canvas background color and color palette for coloring continuous variables",
            debuggingEnabled=0)

        box = OWGUI.widgetBox(self.SettingsTab,
                              "Auto Send Selected Data When...")
        OWGUI.checkBox(
            box,
            self,
            'autoSendSelection',
            'Adding/Removing selection areas',
            callback=self.selectionChanged,
            tooltip=
            "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(
            box,
            self,
            'graph.sendSelectionOnUpdate',
            'Moving/Resizing selection areas',
            tooltip=
            "Send selected data when a user moves or resizes an existing selection area"
        )
        self.graph.autoSendSelectionCallback = self.selectionChanged

        self.SettingsTab.layout().addStretch(100)
        self.icons = self.createAttributeIconDict()

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        apply([
            self.zoomSelectToolbar.actionZooming,
            self.zoomSelectToolbar.actionRectangleSelection,
            self.zoomSelectToolbar.actionPolygonSelection
        ][self.toolbarSelection], [])
        self.cbShowAllAttributes()

        self.resize(900, 700)
Example #4
0
    def __init__(self, parent=None, signalManager=None):
        #        self.callbackDeposit = [] # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager, 'Expression Profiles',
                          1)

        #set default settings
        self.ShowAverageProfile = 1
        self.ShowSingleProfiles = 0
        self.PointWidth = 2
        self.CurveWidth = 1
        self.AverageCurveWidth = 4
        self.BoxPlotWidth = 2
        self.SelectedClasses = []
        self.Classes = []
        self.autoSendSelected = 0
        self.selectionChangedFlag = False

        self.CutLow = 0
        self.CutHigh = 0
        self.CutEnabled = 0

        self.profileLabel = None

        #load settings
        self.loadSettings()

        # GUI
        self.graph = profilesGraph(self, self.mainArea, "")
        self.mainArea.layout().addWidget(self.graph)
        self.graph.hide()
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        # GUI definition
        self.tabs = OWGUI.tabWidget(self.space)

        # GRAPH TAB
        GraphTab = OWGUI.createTabPage(self.tabs, "Graph")

        ## display options
        self.infoLabel = OWGUI.widgetLabel(OWGUI.widgetBox(GraphTab, "Info"),
                                           "No data on input.")
        displayOptBox = OWGUI.widgetBox(
            GraphTab, "Display")  #QVButtonGroup("Display", GraphTab)
        displayOptButtons = [
            'Majority Class', 'Majority Class Probability',
            'Target Class Probability', 'Number of Instances'
        ]
        OWGUI.checkBox(displayOptBox,
                       self,
                       'ShowSingleProfiles',
                       'Expression Profiles',
                       tooltip='',
                       callback=self.updateShowSingleProfiles)
        OWGUI.checkBox(displayOptBox,
                       self,
                       'ShowAverageProfile',
                       'Box Plot',
                       tooltip='',
                       callback=self.updateShowAverageProfile)

        ## class selection (classQLB)
        self.classQVGB = OWGUI.widgetBox(GraphTab,
                                         "Classes")  #QVGroupBox(GraphTab)
        ##        self.classQVGB.setTitle("Classes")
        self.classQLB = OWGUI.listBox(
            self.classQVGB,
            self,
            "SelectedClasses",
            "Classes",
            selectionMode=QListWidget.MultiSelection,
            callback=self.classSelectionChange)  #QListBox(self.classQVGB)
        ##        self.classQLB.setSelectionMode(QListBox.Multi)
        self.unselectAllClassedQLB = OWGUI.button(
            self.classQVGB, self, "Unselect all", callback=self.SUAclassQLB
        )  #QPushButton("(Un)Select All", self.classQVGB)
        ##        self.connect(self.unselectAllClassedQLB, SIGNAL("clicked()"), self.SUAclassQLB)
        ##        self.connect(self.classQLB, SIGNAL("selectionChanged()"), self.classSelectionChange)

        ## show single/average profile
        ##        self.showAverageQLB = QPushButton("Box Plot", self.classQVGB)
        ##        self.showAverageQLB.setToggleButton(1)
        ##        self.showAverageQLB.setOn(self.ShowAverageProfile)
        ##        self.showSingleQLB = QPushButton("Single Profiles", self.classQVGB)
        ##        self.showSingleQLB.setToggleButton(1)
        ##        self.showSingleQLB.setOn(self.ShowSingleProfiles)
        ##        self.connect(self.showAverageQLB, SIGNAL("toggled(bool)"), self.updateShowAverageProfile)
        ##        self.connect(self.showSingleQLB, SIGNAL("toggled(bool)"), self.updateShowSingleProfiles)

        ##        self.tabs.insertTab(GraphTab, "Graph")

        # SETTINGS TAB
        SettingsTab = OWGUI.createTabPage(self.tabs,
                                          "Settings")  #QVGroupBox(self)

        self.profileLabelComboBox = OWGUI.comboBox(SettingsTab,
                                                   self,
                                                   'profileLabel',
                                                   'Profile Labels',
                                                   sendSelectedValue=True,
                                                   valueType=str)
        OWGUI.hSlider(SettingsTab,
                      self,
                      'PointWidth',
                      box='Point Width',
                      minValue=0,
                      maxValue=9,
                      step=1,
                      callback=self.updatePointWidth,
                      ticks=1)
        OWGUI.hSlider(SettingsTab,
                      self,
                      'CurveWidth',
                      box='Profile Width',
                      minValue=1,
                      maxValue=9,
                      step=1,
                      callback=self.updateCurveWidth,
                      ticks=1)
        OWGUI.hSlider(SettingsTab,
                      self,
                      'AverageCurveWidth',
                      box='Average Profile Width',
                      minValue=1,
                      maxValue=9,
                      step=1,
                      callback=self.updateAverageCurveWidth,
                      ticks=1)
        OWGUI.hSlider(SettingsTab,
                      self,
                      'BoxPlotWidth',
                      box='Box Plot Width',
                      minValue=0,
                      maxValue=9,
                      step=1,
                      callback=self.updateBoxPlotWidth,
                      ticks=1)
        OWGUI.checkBox(SettingsTab,
                       self,
                       'graph.renderAntialiased',
                       "Render antialiased",
                       callback=self.graph.setCurveRenderHints)

        ## graph y scale
        box = OWGUI.widgetBox(
            SettingsTab, "Threshold/ Values"
        )  #QVButtonGroup("Threshol/ Values", SettingsTab)
        OWGUI.checkBox(box,
                       self,
                       'CutEnabled',
                       "Enabled",
                       callback=self.setCutEnabled)
        self.sliderCutLow = OWGUI.qwtHSlider(box,
                                             self,
                                             'CutLow',
                                             label='Low:',
                                             labelWidth=33,
                                             minValue=-20,
                                             maxValue=0,
                                             step=0.1,
                                             precision=1,
                                             ticks=0,
                                             maxWidth=80,
                                             callback=self.updateYaxis)
        self.sliderCutHigh = OWGUI.qwtHSlider(box,
                                              self,
                                              'CutHigh',
                                              label='High:',
                                              labelWidth=33,
                                              minValue=0,
                                              maxValue=20,
                                              step=0.1,
                                              precision=1,
                                              ticks=0,
                                              maxWidth=80,
                                              callback=self.updateYaxis)
        if not self.CutEnabled:
            self.sliderCutLow.box.setDisabled(1)
            self.sliderCutHigh.box.setDisabled(1)

##        self.tabs.insertTab(SettingsTab, "Settings")

        self.toolbarSelection = ZoomSelectToolbar(
            self,
            self.controlArea,
            self.graph,
            self.autoSendSelected,
            buttons=(ZoomSelectToolbar.IconZoom, ZoomSelectToolbar.IconPan,
                     ZoomSelectToolbar.IconSelect, ZoomSelectToolbar.IconSpace,
                     ZoomSelectToolbar.IconRemoveLast,
                     ZoomSelectToolbar.IconRemoveAll,
                     ZoomSelectToolbar.IconSendSelection))
        cb = OWGUI.checkBox(self.controlArea, self, "autoSendSelected",
                            "Auto send on selection change")
        OWGUI.setStopper(self, self.toolbarSelection.buttonSendSelections, cb,
                         "selectionChangedFlag", self.commit)

        # inputs
        # data and graph temp variables

        self.inputs = [("Examples", ExampleTable, self.data,
                        Default + Multiple)]
        self.outputs = [("Examples", ExampleTable, Default)]

        # temp variables
        self.MAdata = []
        self.classColor = None
        self.classBrighterColor = None
        self.numberOfClasses = 0
        self.classValues = []
        self.ctrlPressed = False
        self.attrIcons = self.createAttributeIconDict()

        self.graph.canvas().setMouseTracking(1)

        #        self.zoomStack = []
        ##        self.connect(self.graph,
        ##                     SIGNAL('plotMousePressed(const QMouseEvent&)'),
        ##                     self.onMousePressed)
        ##        self.connect(self.graph,
        ##                     SIGNAL('plotMouseReleased(const QMouseEvent&)'),
        ##                     self.onMouseReleased)
        self.resize(800, 600)
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates", True)

        #add a graph widget
        self.graph = OWParallelGraph(self, self.mainArea)
        self.mainArea.layout().addWidget(self.graph)

        self.showAllAttributes = 0

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Data Subset", ExampleTable, self.setSubsetData),
                       ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = [("Selected Data", ExampleTable),
                        ("Other Data", ExampleTable),
                        ("Features", AttributeList)]

        #set default settings
        self.data = None
        self.subsetData = None
        self.autoSendSelection = 1
        self.attrDiscOrder = "Unordered"
        self.attrContOrder = "Unordered"
        self.projections = None
        self.correlationDict = {}
        self.middleLabels = "Correlations"
        self.attributeSelectionList = None
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph.jitterSize = 10
        self.graph.showDistributions = 1
        self.graph.showStatistics = 0
        self.graph.showAttrValues = 1
        self.graph.useSplines = 0
        self.graph.enabledLegend = 1

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph)
        self.connect(self.shownAttribsLB, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.flipAttribute)

        self.optimizationDlg = ParallelOptimization(self, signalManager=self.signalManager)
        self.optimizationDlgButton = OWGUI.button(self.GeneralTab, self, "Optimization Dialog",
                                                  callback=self.optimizationDlg.reshow, debuggingEnabled=0)

        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection,
                                                              buttons=(1, 2, 0, 7, 8))
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)

        #connect controls to appropriate functions
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        # ####################################
        # SETTINGS functionality
        box = OWGUI.widgetBox(self.SettingsTab, "Transparency")
        OWGUI.hSlider(box, self, 'graph.alphaValue', label="Examples: ", minValue=0, maxValue=255, step=10,
                      callback=self.updateGraph, tooltip="Alpha value used for drawing example lines")
        OWGUI.hSlider(box, self, 'graph.alphaValue2', label="Rest:     ", minValue=0, maxValue=255, step=10,
                      callback=self.updateGraph, tooltip="Alpha value used to draw statistics, example subsets, ...")

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBox(box, self, "graph.jitterSize", label='Jittering size (% of size):  ', orientation='horizontal',
                       callback=self.setJitteringSize, items=self.jitterSizeNums, sendSelectedValue=1, valueType=float)

        # visual settings
        box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings")

        OWGUI.checkBox(box, self, 'graph.showAttrValues', 'Show attribute values', callback=self.updateGraph)
        OWGUI.checkBox(box, self, 'graph.useAntialiasing', 'Use antialiasing', callback=self.updateGraph)
        OWGUI.checkBox(box, self, 'graph.useSplines', 'Show splines', callback=self.updateGraph,
                       tooltip="Show lines using splines")
        OWGUI.checkBox(box, self, 'graph.enabledLegend', 'Show legend', callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance")
        resizeColsBox = OWGUI.widgetBox(box, 0, "horizontal", 0)
        OWGUI.label(resizeColsBox, self, "Increase/decrease distance: ")
        OWGUI.toolButton(resizeColsBox, self, "+", callback=self.increaseAxesDistance,
                         tooltip="Increase the distance between the axes", width=30, height=20)
        OWGUI.toolButton(resizeColsBox, self, "-", callback=self.decreaseAxesDistance,
                         tooltip="Decrease the distance between the axes", width=30, height=20)
        OWGUI.rubber(resizeColsBox)
        OWGUI.checkBox(box, self, "graph.autoUpdateAxes", "Auto scale X axis",
                       tooltip="Auto scale X axis to show all visualized attributes", callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Statistical Information")
        OWGUI.comboBox(box, self, "graph.showStatistics", label="Statistics: ", orientation="horizontal", labelWidth=90,
                       items=["No statistics", "Means, deviations", "Median, quartiles"], callback=self.updateGraph,
                       sendSelectedValue=0, valueType=int)
        OWGUI.comboBox(box, self, "middleLabels", label="Middle labels: ", orientation="horizontal", labelWidth=90,
                       items=["No labels", "Correlations", "VizRank"], callback=self.updateGraph,
                       tooltip="The information do you wish to view on top in the middle of coordinate axes",
                       sendSelectedValue=1, valueType=str)
        OWGUI.checkBox(box, self, 'graph.showDistributions', 'Show distributions', callback=self.updateGraph,
                       tooltip="Show bars with distribution of class values (only for discrete attributes)")

        box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation="horizontal")
        OWGUI.button(box, self, "Set colors", self.setColors,
                     tooltip="Set the canvas background color and color palette for coloring continuous variables",
                     debuggingEnabled=0)

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(box, self, 'autoSendSelection', 'Adding/Removing selection areas',
                       callback=self.selectionChanged,
                       tooltip="Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas',
                       tooltip="Send selected data when a user moves or resizes an existing selection area")
        self.graph.autoSendSelectionCallback = self.selectionChanged

        self.SettingsTab.layout().addStretch(100)
        self.icons = self.createAttributeIconDict()

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection,
               self.zoomSelectToolbar.actionPolygonSelection][self.toolbarSelection], [])
        self.cbShowAllAttributes()

        self.resize(900, 700)