def __init__(self, parent=None, signalManager=None, name="Linear Projection", graphClass=None): OWVisWidget.__init__(self, parent, signalManager, name, TRUE) self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes), ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults), ("VizRank Learner", orange.Learner, self.setVizRankLearner), ("Distances", orange.SymMatrix, self.setDistances)] self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable), ("Features", AttributeList), ("FreeViz Learner", orange.Learner)] # local variables self.showAllAttributes = 0 self.valueScalingType = 0 self.autoSendSelection = 1 self.data = None self.subsetData = None self.distances = None self.toolbarSelection = 0 self.classificationResults = None self.outlierValues = None self.attributeSelectionList = None self.colorSettings = None self.selectedSchemaIndex = 0 self.addProjectedPositions = 0 self.resetAnchors = 0 #add a graph widget if graphClass: self.graph = graphClass(self, self.mainArea, name) else: self.graph = OWLinProjGraph(self, self.mainArea, name) self.mainArea.layout().addWidget(self.graph) # graph variables self.graph.manualPositioning = 0 self.graph.hideRadius = 0 self.graph.showAnchors = 1 self.graph.jitterContinuous = 0 self.graph.showProbabilities = 0 self.graph.useDifferentSymbols = 0 self.graph.useDifferentColors = 1 self.graph.tooltipKind = 0 self.graph.tooltipValue = 0 self.graph.scaleFactor = 1.0 self.graph.squareGranularity = 3 self.graph.spaceBetweenCells = 1 self.graph.showAxisScale = 0 self.graph.showValueLines = 0 self.graph.valueLineLength = 5 #load settings self.loadSettings() ## # cluster dialog ## self.clusterDlg = ClusterOptimization(self, self.signalManager, self.graph, name) ## self.graph.clusterOptimization = self.clusterDlg # optimization dialog if name.lower() == "radviz": self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.RADVIZ, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile) elif name.lower() == "polyviz": self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.POLYVIZ, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) else: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile) self.optimizationDlg = self.vizrank # for backward compatibility self.graph.normalizeExamples = ( name.lower() == "radviz" ) # ignore settings!! if we have radviz then normalize, otherwise not. #GUI # add a settings dialog and initialize its values self.tabs = OWGUI.tabWidget(self.controlArea) self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings", canScroll=1) #add controls to self.controlArea widget self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraphAndAnchors) self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization Dialogs", orientation="horizontal") self.vizrankButton = OWGUI.button( self.optimizationButtons, self, "VizRank", callback=self.vizrank.reshow, tooltip= "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.", debuggingEnabled=0) self.wdChildDialogs = [self.vizrank ] # used when running widget debugging # freeviz dialog if name.lower() in ["linear projection", "radviz"]: self.freeVizDlg = FreeVizOptimization(self, self.signalManager, self.graph, name) self.wdChildDialogs.append(self.freeVizDlg) self.freeVizDlgButton = OWGUI.button( self.optimizationButtons, self, "FreeViz", callback=self.freeVizDlg.reshow, tooltip= "Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved", debuggingEnabled=0) if name.lower() == "linear projection": self.freeVizLearner = FreeVizLearner(self.freeVizDlg) self.send("FreeViz Learner", self.freeVizLearner) ## self.clusterDetectionDlgButton = OWGUI.button(self.optimizationButtons, self, "Cluster", callback = self.clusterDlg.reshow, debuggingEnabled = 0) ## self.vizrankButton.setMaximumWidth(63) ## self.clusterDetectionDlgButton.setMaximumWidth(63) ## self.freeVizDlgButton.setMaximumWidth(63) ## self.connect(self.clusterDlg.startOptimizationButton , SIGNAL("clicked()"), self.optimizeClusters) ## self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster) self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar( self, self.GeneralTab, self.graph, self.autoSendSelection) self.graph.autoSendSelectionCallback = self.selectionChanged self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections) # #################################### # SETTINGS TAB # ##### self.extraTopBox = OWGUI.widgetBox(self.SettingsTab, orientation="vertical") self.extraTopBox.hide() box = OWGUI.widgetBox(self.SettingsTab, "Point Properties") OWGUI.hSlider(box, self, 'graph.pointWidth', label="Size: ", minValue=1, maxValue=20, step=1, callback=self.updateGraph) OWGUI.hSlider(box, self, 'graph.alphaValue', label="Transparency: ", minValue=0, maxValue=255, step=10, callback=self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options") OWGUI.comboBoxWithCaption(box, self, "graph.jitterSize", 'Jittering size (% of range):', callback=self.resetGraphData, items=self.jitterSizeNums, sendSelectedValue=1, valueType=float) OWGUI.checkBox( box, self, 'graph.jitterContinuous', 'Jitter continuous attributes', callback=self.resetGraphData, tooltip="Does jittering apply also on continuous attributes?") box = OWGUI.widgetBox(self.SettingsTab, "Scaling Options") OWGUI.qwtHSlider( box, self, "graph.scaleFactor", label='Inflate points by: ', minValue=1.0, maxValue=10.0, step=0.1, callback=self.updateGraph, tooltip= "If points lie too much together you can expand their position to improve perception", maxWidth=90) box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings") #OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph) OWGUI.checkBox(box, self, 'graph.showLegend', 'Show legend', callback=self.updateGraph) bbox = OWGUI.widgetBox(box, orientation="horizontal") OWGUI.checkBox(bbox, self, 'graph.showValueLines', 'Show value lines ', callback=self.updateGraph) OWGUI.qwtHSlider(bbox, self, 'graph.valueLineLength', minValue=1, maxValue=10, step=1, callback=self.updateGraph, showValueLabel=0) OWGUI.checkBox( box, self, 'graph.useDifferentSymbols', 'Use different symbols', callback=self.updateGraph, tooltip="Show different class values using different symbols") OWGUI.checkBox( box, self, 'graph.useDifferentColors', 'Use different colors', callback=self.updateGraph, tooltip="Show different class values using different colors") OWGUI.checkBox(box, self, 'graph.showFilledSymbols', 'Show filled symbols', callback=self.updateGraph) OWGUI.checkBox(box, self, 'graph.useAntialiasing', 'Use antialiasing', callback=self.updateGraph) wbox = OWGUI.widgetBox(box, orientation="horizontal") OWGUI.checkBox( wbox, self, 'graph.showProbabilities', 'Show probabilities' + ' ', callback=self.updateGraph, tooltip="Show a background image with class probabilities") smallWidget = OWGUI.SmallWidgetLabel(wbox, pixmap=1, box="Advanced settings", tooltip="Show advanced settings") OWGUI.rubber(wbox) box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation="horizontal") OWGUI.button( box, self, "Colors", self.setColors, tooltip= "Set the canvas background color and color palette for coloring variables", debuggingEnabled=0) box = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings") OWGUI.comboBox(box, self, "graph.tooltipKind", items=[ "Show line tooltips", "Show visible attributes", "Show all attributes" ], callback=self.updateGraph) OWGUI.comboBox( box, self, "graph.tooltipValue", items=["Tooltips show data values", "Tooltips show spring values"], callback=self.updateGraph, tooltip= "Do you wish that tooltips would show you original values of visualized attributes or the 'spring' values (values between 0 and 1). \nSpring values are scaled values that are used for determining the position of shown points. Observing these values will therefore enable you to \nunderstand why the points are placed where they are." ) 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" ) OWGUI.comboBox(box, self, "addProjectedPositions", items=[ "Do not modify the domain", "Append projection as attributes", "Append projection as meta attributes" ], callback=self.sendSelections) self.selectionChanged() box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal") OWGUI.widgetLabel(box, "Granularity: ") OWGUI.hSlider(box, self, 'graph.squareGranularity', minValue=1, maxValue=10, step=1, callback=self.updateGraph) box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal") OWGUI.checkBox(box, self, 'graph.spaceBetweenCells', 'Show space between cells', callback=self.updateGraph) self.SettingsTab.layout().addStretch(100) self.icons = self.createAttributeIconDict() self.debugSettings = ["hiddenAttributes", "shownAttributes"] 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( ) # update list boxes based on the check box value self.resize(900, 700)
def __init__(self, parent=None, signalManager=None, name="Linear Projection (qt)", graphClass=None): OWVisWidget.__init__(self, parent, signalManager, name, TRUE) self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes), ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults), ("VizRank Learner", orange.Learner, self.setVizRankLearner), ("Distances", orange.SymMatrix, self.setDistances)] self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable), ("Features", AttributeList), ("FreeViz Learner", orange.Learner)] name_lower = name.lower() self._name_lower = name_lower # local variables self.showAllAttributes = 0 self.valueScalingType = 0 self.autoSendSelection = 1 self.data = None self.subsetData = None self.distances = None self.toolbarSelection = 0 self.classificationResults = None self.outlierValues = None self.attributeSelectionList = None self.colorSettings = None self.selectedSchemaIndex = 0 self.addProjectedPositions = 0 self.resetAnchors = 0 #add a graph widget if graphClass: self.graph = graphClass(self, self.mainArea, name) else: self.graph = OWLinProjGraph(self, self.mainArea, name) self.mainArea.layout().addWidget(self.graph) # graph variables self.graph.manualPositioning = 0 self.graph.hideRadius = 0 self.graph.showAnchors = 1 self.graph.jitterContinuous = 0 self.graph.showProbabilities = 0 self.graph.useDifferentSymbols = 0 self.graph.useDifferentColors = 1 self.graph.tooltipKind = 0 self.graph.tooltipValue = 0 self.graph.scaleFactor = 1.0 self.graph.squareGranularity = 3 self.graph.spaceBetweenCells = 1 self.graph.showAxisScale = 0 self.graph.showValueLines = 0 self.graph.valueLineLength = 5 self.dark_theme = False if "3d" in name_lower: self.settingsList.append("graph.use_2d_symbols") self.settingsList.append("graph.mouse_sensitivity") self.settingsList.append("dark_theme") if "sphereviz" in name_lower: self.settingsList.append("graph.show_anchor_grid") #load settings self.loadSettings() ## # cluster dialog ## self.clusterDlg = ClusterOptimization(self, self.signalManager, self.graph, name) ## self.graph.clusterOptimization = self.clusterDlg # optimization dialog if "radviz" in name_lower: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.RADVIZ, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile) elif "polyviz" in name_lower: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.POLYVIZ, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) elif "sphereviz" in name_lower: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.SPHEREVIZ3D, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) elif "3d" in name_lower: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION3D, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) else: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile) self.optimizationDlg = self.vizrank # for backward compatibility # ignore settings!! if we have radviz then normalize, otherwise not. self.graph.normalizeExamples = ("radviz" in name_lower or "sphereviz" in name_lower) #GUI # add a settings dialog and initialize its values self.tabs = OWGUI.tabWidget(self.controlArea) self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings", canScroll=1) if not "3d" in name_lower: self.PerformanceTab = OWGUI.createTabPage(self.tabs, "Performance") #add controls to self.controlArea widget self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraphAndAnchors) self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization Dialogs", orientation="horizontal") self.vizrankButton = OWGUI.button( self.optimizationButtons, self, "VizRank", callback=self.vizrank.reshow, tooltip= "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.", debuggingEnabled=0) self.wdChildDialogs = [self.vizrank ] # used when running widget debugging # freeviz dialog if "radviz" in name_lower or "linear projection" in name_lower or "sphereviz" in name_lower: self.freeVizDlg = FreeVizOptimization(self, self.signalManager, self.graph, name) self.wdChildDialogs.append(self.freeVizDlg) self.freeVizDlgButton = OWGUI.button( self.optimizationButtons, self, "FreeViz", callback=self.freeVizDlg.reshow, tooltip= "Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved", debuggingEnabled=0) if "linear projection" in name_lower: self.freeVizLearner = FreeVizLearner(self.freeVizDlg) self.send("FreeViz Learner", self.freeVizLearner) if "3d" in name_lower: # Patch a method in Freeviz get_shown_attribute_list = lambda: [ anchor[3] for anchor in self.graph.anchorData ] self.freeVizDlg.get_shown_attribute_list = get_shown_attribute_list self.freeVizDlg.getShownAttributeList = get_shown_attribute_list self.freeVizDlg._use_3D = True ## self.clusterDetectionDlgButton = OWGUI.button(self.optimizationButtons, self, "Cluster", callback = self.clusterDlg.reshow, debuggingEnabled = 0) ## self.vizrankButton.setMaximumWidth(63) ## self.clusterDetectionDlgButton.setMaximumWidth(63) ## self.freeVizDlgButton.setMaximumWidth(63) ## self.connect(self.clusterDlg.startOptimizationButton , SIGNAL("clicked()"), self.optimizeClusters) ## self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster) gui = self.graph.gui if "3d" in name_lower: toolbar_buttons = [ gui.StateButtonsBegin, (gui.UserButton, 'Rotate', 'state', ROTATING, None, 'Dlg_undo'), gui.Select, gui.StateButtonsEnd, gui.Spacing, gui.SendSelection, gui.ClearSelection ] self.zoomSelectToolbar = gui.zoom_select_toolbar( self.GeneralTab, buttons=toolbar_buttons) self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.sendSelections) self.graph.set_selection_behavior(OWPlot.ReplaceSelection) else: # zooming / selection self.zoomSelectToolbar = gui.zoom_select_toolbar( self.GeneralTab, buttons=gui.default_zoom_select_buttons + [gui.Spacing, gui.ShufflePoints]) self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.sendSelections) # #################################### # SETTINGS TAB # ##### self.extraTopBox = OWGUI.widgetBox(self.SettingsTab, orientation="vertical") self.extraTopBox.hide() self.graph.gui.point_properties_box(self.SettingsTab) box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options") OWGUI.comboBoxWithCaption(box, self, "graph.jitterSize", 'Jittering size (% of range):', callback=self.resetGraphData, items=self.jitterSizeNums, sendSelectedValue=1, valueType=float) OWGUI.checkBox( box, self, 'graph.jitterContinuous', 'Jitter continuous attributes', callback=self.resetGraphData, tooltip="Does jittering apply also on continuous attributes?") if not "3d" in name_lower: box = OWGUI.widgetBox(self.SettingsTab, "Scaling Options") OWGUI.qwtHSlider( box, self, "graph.scaleFactor", label='Inflate points by: ', minValue=1.0, maxValue=10.0, step=0.1, callback=self.updateGraph, tooltip= "If points lie too much together you can expand their position to improve perception", maxWidth=90) box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings") #OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph) self.graph.gui.show_legend_check_box(box) bbox = OWGUI.widgetBox(box, orientation="horizontal") if "3d" in name_lower: OWGUI.checkBox(bbox, self, 'graph.showValueLines', 'Show value lines ', callback=self.graph.update) OWGUI.qwtHSlider(bbox, self, 'graph.valueLineLength', minValue=1, maxValue=10, step=1, callback=self.graph.update, showValueLabel=0) else: OWGUI.checkBox(bbox, self, 'graph.showValueLines', 'Show value lines ', callback=self.updateGraph) OWGUI.qwtHSlider(bbox, self, 'graph.valueLineLength', minValue=1, maxValue=10, step=1, callback=self.updateGraph, showValueLabel=0) OWGUI.checkBox( box, self, 'graph.useDifferentSymbols', 'Use different symbols', callback=self.updateGraph, tooltip="Show different class values using different symbols") OWGUI.checkBox( box, self, 'graph.useDifferentColors', 'Use different colors', callback=self.updateGraph, tooltip="Show different class values using different colors") if "3d" in name_lower: OWGUI.checkBox(box, self, 'dark_theme', 'Dark theme', callback=self.on_theme_change) OWGUI.checkBox(box, self, 'graph.use_2d_symbols', '2D symbols', callback=self.updateGraph, tooltip="Use 2D symbols") self.on_theme_change() if "sphereviz" in name_lower: OWGUI.checkBox(box, self, 'graph.show_anchor_grid', 'Anchor grid', callback=self.on_theme_change) box = OWGUI.widgetBox(self.SettingsTab, 'Camery type', orientation="horizontal") c = OWGUI.comboBox(box, self, 'graph.camera_type', callback=self.graph.update_camera_type, sendSelectedValue=0) c.addItem('Default') c.addItem('Center') c.addItem('Random attribute') OWGUI.hSlider(box, self, 'graph.camera_angle', label='FOV', minValue=45, maxValue=180, step=1, callback=self.graph.update, tooltip='Field of view angle') box = OWGUI.widgetBox(self.SettingsTab, 'Mouse', orientation="horizontal") OWGUI.hSlider(box, self, 'graph.mouse_sensitivity', label='Sensitivity', minValue=1, maxValue=10, step=1, callback=self.graph.update, tooltip='Change mouse sensitivity') else: self.graph.gui.filled_symbols_check_box(box) wbox = OWGUI.widgetBox(box, orientation="horizontal") OWGUI.checkBox( wbox, self, 'graph.showProbabilities', 'Show probabilities' + ' ', callback=self.updateGraph, tooltip="Show a background image with class probabilities") smallWidget = OWGUI.SmallWidgetLabel( wbox, pixmap=1, box="Advanced settings", tooltip="Show advanced settings") OWGUI.rubber(wbox) box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal") OWGUI.widgetLabel(box, "Granularity: ") OWGUI.hSlider(box, self, 'graph.squareGranularity', minValue=1, maxValue=10, step=1, callback=self.updateGraph) box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal") OWGUI.checkBox(box, self, 'graph.spaceBetweenCells', 'Show space between cells', callback=self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation="horizontal") OWGUI.button( box, self, "Colors", self.setColors, tooltip= "Set the canvas background color and color palette for coloring variables", debuggingEnabled=0) box = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings") callback = self.graph.update if "3d" in name_lower else self.updateGraph OWGUI.comboBox(box, self, "graph.tooltipKind", items=[ "Show line tooltips", "Show visible attributes", "Show all attributes" ], callback=callback) OWGUI.comboBox( box, self, "graph.tooltipValue", items=["Tooltips show data values", "Tooltips show spring values"], callback=callback, tooltip= "Do you wish that tooltips would show you original values of visualized attributes or the 'spring' values (values between 0 and 1). \nSpring values are scaled values that are used for determining the position of shown points. Observing these values will therefore enable you to \nunderstand why the points are placed where they are." ) 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" ) OWGUI.comboBox(box, self, "addProjectedPositions", items=[ "Do not modify the domain", "Append projection as attributes", "Append projection as meta attributes" ], callback=self.sendSelections) self.selectionChanged() self.SettingsTab.layout().addStretch(100) if not "3d" in name_lower: self.graph.gui.effects_box(self.PerformanceTab, ) self.PerformanceTab.layout().addStretch(100) self.icons = self.createAttributeIconDict() self.debugSettings = ["hiddenAttributes", "shownAttributes"] dlg = self.createColorDialog() self.graph.contPalette = dlg.getContinuousPalette("contPalette") self.graph.discPalette = dlg.getDiscretePalette("discPalette") p = self.graph.palette() p.setColor(OWPalette.Canvas, dlg.getColor("Canvas")) self.graph.set_palette(p) self.cbShowAllAttributes( ) # update list boxes based on the check box value self.resize(900, 700)
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Scatter Plot", TRUE) self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes), ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults), ("VizRank Learner", orange.Learner, self.setVizRankLearner)] self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable)] self.graph = OWScatterPlotGraph(self, self.mainArea, "ScatterPlot") self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.SCATTERPLOT, "ScatterPlot") self.optimizationDlg = self.vizrank # local variables self.showGridlines = 0 self.autoSendSelection = 1 self.toolbarSelection = 0 self.classificationResults = None self.outlierValues = None self.colorSettings = None self.selectedSchemaIndex = 0 self.graph.sendSelectionOnUpdate = 0 self.attributeSelectionList = None self.data = None self.subsetData = None #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", canScroll = True) #add a graph widget self.mainArea.layout().addWidget(self.graph) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) #x attribute self.attrX = "" self.attrXCombo = OWGUI.comboBox(self.GeneralTab, self, "attrX", "X-axis Attribute", callback = self.majorUpdateGraph, sendSelectedValue = 1, valueType = str) # y attribute self.attrY = "" self.attrYCombo = OWGUI.comboBox(self.GeneralTab, self, "attrY", "Y-axis Attribute", callback = self.majorUpdateGraph, sendSelectedValue = 1, valueType = str) # coloring self.attrColor = "" box = OWGUI.widgetBox(self.GeneralTab, "Point Color") self.attrColorCombo = OWGUI.comboBox(box, self, "attrColor", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same color)") box = OWGUI.widgetBox(self.GeneralTab, "Additional Point Properties") # labelling self.attrLabel = "" self.attrLabelCombo = OWGUI.comboBox(box, self, "attrLabel", label = "Point label:", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, emptyString = "(No labels)", indent = 10) # shaping self.attrShape = "" self.attrShapeCombo = OWGUI.comboBox(box, self, "attrShape", label = "Point shape:", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same shape)", indent = 10) # sizing self.attrSize = "" self.attrSizeCombo = OWGUI.comboBox(box, self, "attrSize", label = "Point size:", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same size)", indent = 10) self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization dialogs", orientation = "horizontal") OWGUI.button(self.optimizationButtons, self, "VizRank", callback = self.vizrank.reshow, tooltip = "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes", debuggingEnabled = 0) # zooming / selection self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection) self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections) # #################################### # SETTINGS TAB # point width pointBox = OWGUI.widgetBox(self.SettingsTab, "Point Properties") OWGUI.hSlider(pointBox, self, 'graph.pointWidth', label = "Symbol size: ", minValue=1, maxValue=20, step=1, callback = self.pointSizeChange) OWGUI.hSlider(pointBox, self, 'graph.alphaValue', label = "Transparency: ", minValue=0, maxValue=255, step=10, callback = self.alphaChange) # ##### # jittering options box2 = OWGUI.widgetBox(self.SettingsTab, "Jittering Options") self.jitterSizeCombo = OWGUI.comboBox(box2, self, "graph.jitterSize", label = 'Jittering size (% of size)'+' ', orientation = "horizontal", callback = self.resetGraphData, items = self.jitterSizeNums, sendSelectedValue = 1, valueType = float) OWGUI.checkBox(box2, self, 'graph.jitterContinuous', 'Jitter continuous attributes', callback = self.resetGraphData, tooltip = "Does jittering apply also on continuous attributes?") # general graph settings box4 = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings") OWGUI.checkBox(box4, self, 'graph.showXaxisTitle', 'X axis title', callback = self.graph.setShowXaxisTitle) OWGUI.checkBox(box4, self, 'graph.showYLaxisTitle', 'Y axis title', callback = self.graph.setShowYLaxisTitle) OWGUI.checkBox(box4, self, 'graph.showAxisScale', 'Show axis scale', callback = self.updateGraph) OWGUI.checkBox(box4, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph) OWGUI.checkBox(box4, self, 'graph.showFilledSymbols', 'Show filled symbols', callback = self.updateGraph) OWGUI.checkBox(box4, self, 'showGridlines', 'Show gridlines', callback = self.setShowGridlines) OWGUI.checkBox(box4, self, 'graph.useAntialiasing', 'Use antialiasing', callback = self.updateGraph) box5 = OWGUI.widgetBox(box4, orientation = "horizontal") OWGUI.checkBox(box5, self, 'graph.showProbabilities', 'Show probabilities'+' ', callback = self.updateGraph, tooltip = "Show a background image with class probabilities") smallWidget = OWGUI.SmallWidgetLabel(box5, pixmap = 1, box = "Advanced settings", tooltip = "Show advanced settings") #OWGUI.rubber(box5) box6 = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal") box7 = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal") OWGUI.widgetLabel(box6, "Granularity:"+" ") OWGUI.hSlider(box6, self, 'graph.squareGranularity', minValue=1, maxValue=10, step=1, callback = self.updateGraph) OWGUI.checkBox(box7, self, 'graph.spaceBetweenCells', 'Show space between cells', callback = self.updateGraph) self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation = "horizontal") OWGUI.button(self.colorButtonsBox, self, "Set Colors", self.setColors, tooltip = "Set the canvas background color, grid color and color palette for coloring continuous variables", debuggingEnabled = 0) box5 = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings") OWGUI.comboBox(box5, self, "graph.tooltipKind", items = ["Don't Show Tooltips", "Show Visible Attributes", "Show All Attributes"], callback = self.updateGraph) 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.GeneralTab.layout().addStretch(100) self.SettingsTab.layout().addStretch(100) self.icons = self.createAttributeIconDict() self.debugSettings = ["attrX", "attrY", "attrColor", "attrLabel", "attrShape", "attrSize"] self.wdChildDialogs = [self.vizrank] # used when running widget debugging dlg = self.createColorDialog() self.graph.contPalette = dlg.getContinuousPalette("contPalette") self.graph.discPalette = dlg.getDiscretePalette("discPalette") self.graph.setCanvasBackground(dlg.getColor("Canvas")) self.graph.gridCurve.setPen(QPen(dlg.getColor("Grid"))) self.graph.enableGridXB(self.showGridlines) self.graph.enableGridYL(self.showGridlines) apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection][self.toolbarSelection], []) #self.SettingsTab.resize(self.SettingsTab.sizeHint()) self.resize(700, 550)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Rank") self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [("Reduced Example Table", ExampleTable, Default + Single), ("ExampleTable Attributes", ExampleTable, NonDefault)] self.settingsList += self.measuresAttrs self.logORIdx = self.measuresShort.index("log OR") self.nDecimals = 3 self.reliefK = 10 self.reliefN = 20 self.nIntervals = 4 self.sortBy = 0 self.selectMethod = 3 self.nSelected = 5 self.autoApply = True self.showDistributions = 1 self.distColorRgb = (220, 220, 220, 255) self.distColor = QColor(*self.distColorRgb) self.minmax = {} self.data = None for meas in self.measuresAttrs: setattr(self, meas, True) self.loadSettings() labelWidth = 80 box = OWGUI.widgetBox(self.controlArea, "Measures", addSpace=True) for meas, valueName in zip(self.measures, self.measuresAttrs): if valueName == "computeReliefF": hbox = OWGUI.widgetBox(box, orientation="horizontal") OWGUI.checkBox(hbox, self, valueName, meas, callback=self.measuresChanged) hbox.layout().addSpacing(5) smallWidget = OWGUI.SmallWidgetLabel( hbox, pixmap=1, box="ReliefF Parameters", tooltip="Show ReliefF parameters") OWGUI.spin(smallWidget.widget, self, "reliefK", 1, 20, label="Neighbours", labelWidth=labelWidth, orientation=0, callback=self.reliefChanged, callbackOnReturn=True) OWGUI.spin(smallWidget.widget, self, "reliefN", 20, 100, label="Examples", labelWidth=labelWidth, orientation=0, callback=self.reliefChanged, callbackOnReturn=True) OWGUI.button(smallWidget.widget, self, "Load defaults", callback=self.loadReliefDefaults) OWGUI.rubber(hbox) else: OWGUI.checkBox(box, self, valueName, meas, callback=self.measuresChanged) OWGUI.separator(box) OWGUI.comboBox( box, self, "sortBy", label="Sort by" + " ", items=["No Sorting", "Attribute Name", "Number of Values"] + self.measures, orientation=0, valueType=int, callback=self.sortingChanged) box = OWGUI.widgetBox(self.controlArea, "Discretization") OWGUI.spin(box, self, "nIntervals", 2, 20, label="Intervals: ", orientation=0, callback=self.discretizationChanged, callbackOnReturn=True) box = OWGUI.widgetBox(self.controlArea, "Precision", addSpace=True) OWGUI.spin(box, self, "nDecimals", 1, 6, label="No. of decimals: ", orientation=0, callback=self.decimalsChanged) OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Distributions", addSpace=True) self.cbShowDistributions = OWGUI.checkBox( box, self, "showDistributions", 'Visualize values', callback=self.cbShowDistributions) colBox = OWGUI.indentedBox(box, orientation="horizontal") OWGUI.widgetLabel(colBox, "Color: ") self.colButton = OWGUI.toolButton(colBox, self, self.changeColor, width=20, height=20, debuggingEnabled=0) OWGUI.rubber(colBox) selMethBox = OWGUI.radioButtonsInBox( self.controlArea, self, "selectMethod", ["None", "All", "Manual", "Best ranked"], box="Select attributes", callback=self.selectMethodChanged) OWGUI.spin(OWGUI.indentedBox(selMethBox), self, "nSelected", 1, 100, label="No. selected" + " ", orientation=0, callback=self.nSelectedChanged) OWGUI.separator(selMethBox) applyButton = OWGUI.button(selMethBox, self, "Commit", callback=self.apply) autoApplyCB = OWGUI.checkBox(selMethBox, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.apply) self.table = QTableWidget() self.mainArea.layout().addWidget(self.table) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setSelectionMode(QAbstractItemView.MultiSelection) self.table.verticalHeader().setResizeMode(QHeaderView.ResizeToContents) self.table.setItemDelegate(RankItemDelegate(self, self.table)) self.topheader = self.table.horizontalHeader() self.topheader.setSortIndicatorShown(1) self.topheader.setHighlightSections(0) self.setMeasures() self.resetInternals() self.connect(self.table.horizontalHeader(), SIGNAL("sectionClicked(int)"), self.headerClick) self.connect(self.table, SIGNAL("clicked (const QModelIndex&)"), self.selectItem) self.resize(690, 500) self.updateColor()