Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)