Example #1
0
    def __init__(self,
                 parentWidget=None,
                 signalManager=None,
                 graph=None,
                 parentName="Visualization widget"):
        OWWidget.__init__(self,
                          None,
                          signalManager,
                          "FreeViz Dialog",
                          savePosition=True,
                          wantMainArea=0,
                          wantStatusBar=1)
        FreeViz.__init__(self, graph)

        self.parentWidget = parentWidget
        self.parentName = parentName
        self.setCaption("FreeViz Optimization Dialog")
        self.cancelOptimization = 0
        self.forceRelation = 5
        self.disableAttractive = 0
        self.disableRepulsive = 0
        self.touringSpeed = 4
        self.graph = graph

        if self.graph:
            self.graph.hideRadius = 0
            self.graph.showAnchors = 1

        # differential evolution
        self.differentialEvolutionPopSize = 100
        self.DERadvizSolver = None

        self.loadSettings()

        self.layout().setMargin(0)
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.MainTab = OWGUI.createTabPage(self.tabs, "Main")
        self.ProjectionsTab = OWGUI.createTabPage(self.tabs, "Projections")

        # ###########################
        # MAIN TAB
        OWGUI.comboBox(self.MainTab,
                       self,
                       "implementation",
                       box="FreeViz implementation",
                       items=[
                           "Fast (C) implementation",
                           "Slow (Python) implementation", "LDA"
                       ])

        box = OWGUI.widgetBox(self.MainTab, "Optimization")

        self.optimizeButton = OWGUI.button(box,
                                           self,
                                           "Optimize Separation",
                                           callback=self.optimizeSeparation)
        self.stopButton = OWGUI.button(box,
                                       self,
                                       "Stop Optimization",
                                       callback=self.stopOptimization)
        self.singleStepButton = OWGUI.button(
            box, self, "Single Step", callback=self.singleStepOptimization)
        f = self.optimizeButton.font()
        f.setBold(1)
        self.optimizeButton.setFont(f)
        self.stopButton.setFont(f)
        self.stopButton.hide()
        self.attrKNeighboursCombo = OWGUI.comboBoxWithCaption(
            box,
            self,
            "stepsBeforeUpdate",
            "Number of steps before updating graph: ",
            tooltip=
            "Set the number of optimization steps that will be executed before the updated anchor positions will be visualized",
            items=[1, 3, 5, 10, 15, 20, 30, 50, 75, 100, 150, 200, 300],
            sendSelectedValue=1,
            valueType=int)
        OWGUI.checkBox(box,
                       self,
                       "mirrorSymmetry",
                       "Keep mirror symmetry",
                       tooltip="'Rotational' keeps the second anchor upside")

        vbox = OWGUI.widgetBox(self.MainTab, "Set anchor positions")
        hbox1 = OWGUI.widgetBox(vbox, orientation="horizontal")
        OWGUI.button(hbox1, self, "Circle", callback=self.radialAnchors)
        OWGUI.button(hbox1, self, "Random", callback=self.randomAnchors)
        self.manualPositioningButton = OWGUI.button(
            hbox1, self, "Manual", callback=self.setManualPosition)
        self.manualPositioningButton.setCheckable(1)
        OWGUI.comboBox(vbox,
                       self,
                       "restrain",
                       label="Restrain anchors:",
                       orientation="horizontal",
                       items=["Unrestrained", "Fixed Length", "Fixed Angle"],
                       callback=self.setRestraints)

        box2 = OWGUI.widgetBox(self.MainTab, "Forces", orientation="vertical")

        self.cbLaw = OWGUI.comboBox(
            box2,
            self,
            "law",
            label="Law",
            labelWidth=40,
            orientation="horizontal",
            items=["Linear", "Square", "Gaussian", "KNN", "Variance"],
            callback=self.forceLawChanged)

        hbox2 = OWGUI.widgetBox(box2, orientation="horizontal")
        hbox2.layout().addSpacing(10)

        validSigma = QDoubleValidator(self)
        validSigma.setBottom(0.01)
        self.spinSigma = OWGUI.lineEdit(hbox2,
                                        self,
                                        "forceSigma",
                                        label="Kernel width (sigma) ",
                                        labelWidth=110,
                                        orientation="horizontal",
                                        valueType=float)
        self.spinSigma.setFixedSize(60, self.spinSigma.sizeHint().height())
        self.spinSigma.setSizePolicy(
            QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed))

        box2.layout().addSpacing(20)

        self.cbforcerel = OWGUI.comboBox(box2,
                                         self,
                                         "forceRelation",
                                         label="Attractive : Repulsive  ",
                                         orientation="horizontal",
                                         items=self.forceRelValues,
                                         callback=self.updateForces)
        self.cbforcebal = OWGUI.checkBox(
            box2,
            self,
            "forceBalancing",
            "Dynamic force balancing",
            tooltip=
            "Normalize the forces so that the total sums of the\nrepulsive and attractive are in the above proportion."
        )

        box2.layout().addSpacing(20)

        self.cbDisableAttractive = OWGUI.checkBox(
            box2,
            self,
            "disableAttractive",
            "Disable attractive forces",
            callback=self.setDisableAttractive)
        self.cbDisableRepulsive = OWGUI.checkBox(
            box2,
            self,
            "disableRepulsive",
            "Disable repulsive forces",
            callback=self.setDisableRepulsive)

        box = OWGUI.widgetBox(self.MainTab, "Show anchors")
        OWGUI.checkBox(box,
                       self,
                       'graph.showAnchors',
                       'Show attribute anchors',
                       callback=self.parentWidget.updateGraph)
        OWGUI.qwtHSlider(box,
                         self,
                         "graph.hideRadius",
                         label="Hide radius",
                         minValue=0,
                         maxValue=9,
                         step=1,
                         ticks=0,
                         callback=self.parentWidget.updateGraph)
        self.freeAttributesButton = OWGUI.button(box,
                                                 self,
                                                 "Remove hidden attributes",
                                                 callback=self.removeHidden)

        if parentName.lower() != "radviz":
            pcaBox = OWGUI.widgetBox(self.ProjectionsTab,
                                     "Principal Component Analysis")
            OWGUI.button(pcaBox,
                         self,
                         "Principal component analysis",
                         callback=self.findPCAProjection)
            OWGUI.button(pcaBox,
                         self,
                         "Supervised principal component analysis",
                         callback=self.findSPCAProjection)
            OWGUI.checkBox(pcaBox, self, "useGeneralizedEigenvectors",
                           "Merge examples with same class value")
            plsBox = OWGUI.widgetBox(self.ProjectionsTab,
                                     "Partial Least Squares")
            OWGUI.button(plsBox,
                         self,
                         "Partial least squares",
                         callback=self.findPLSProjection)

        box = OWGUI.widgetBox(self.ProjectionsTab, "Projection Tours")
        self.startTourButton = OWGUI.button(box,
                                            self,
                                            "Start Random Touring",
                                            callback=self.startRandomTouring)
        self.stopTourButton = OWGUI.button(box,
                                           self,
                                           "Stop Touring",
                                           callback=self.stopRandomTouring)
        self.stopTourButton.hide()
        OWGUI.hSlider(box,
                      self,
                      'touringSpeed',
                      label="Speed:  ",
                      minValue=1,
                      maxValue=10,
                      step=1)
        OWGUI.rubber(self.ProjectionsTab)

        box = OWGUI.widgetBox(self.ProjectionsTab, "Signal to Noise Heuristic")
        #OWGUI.comboBoxWithCaption(box, self, "s2nSpread", "Anchor spread: ", tooltip = "Are the anchors for each class value placed together or are they distributed along the circle", items = range(11), callback = self.s2nMixAnchors)
        box2 = OWGUI.widgetBox(box, 0, orientation="horizontal")
        OWGUI.widgetLabel(box2, "Anchor spread:           ")
        OWGUI.hSlider(box2,
                      self,
                      's2nSpread',
                      minValue=0,
                      maxValue=10,
                      step=1,
                      callback=self.s2nMixAnchors,
                      labelFormat="  %d",
                      ticks=0)
        OWGUI.comboBoxWithCaption(
            box,
            self,
            "s2nPlaceAttributes",
            "Attributes to place: ",
            tooltip=
            "Set the number of top ranked attributes to place. You can select a higher value than the actual number of attributes",
            items=self.attrsNum,
            callback=self.s2nMixAnchors,
            sendSelectedValue=1,
            valueType=int)
        OWGUI.checkBox(box, self, 'autoSetParameters',
                       'Automatically find optimal parameters')
        self.s2nMixButton = OWGUI.button(box,
                                         self,
                                         "Place anchors",
                                         callback=self.s2nMixAnchorsAutoSet)

        self.forceLawChanged()
        self.updateForces()
        self.cbforcebal.setDisabled(self.cbDisableAttractive.isChecked()
                                    or self.cbDisableRepulsive.isChecked())
        self.resize(320, 650)
Example #2
0
    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)
Example #3
0
    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,
                 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)
Example #5
0
    def __init__(self, canvasDlg, *args):
        apply(QDialog.__init__, (self, ) + args)
        self.canvasDlg = canvasDlg
        self.settings = dict(
            canvasDlg.settings
        )  # create a copy of the settings dict. in case we accept the dialog, we update the canvasDlg.settings with this dict
        if sys.platform == "darwin":
            self.setWindowTitle("Preferences")
        else:
            self.setWindowTitle("Canvas Options")
        self.topLayout = QVBoxLayout(self)
        self.topLayout.setSpacing(0)
        self.resize(300, 300)
        self.toAdd = []
        self.toRemove = []

        self.tabs = QTabWidget(self)
        GeneralTab = OWGUI.widgetBox(self.tabs, margin=4)
        ExceptionsTab = OWGUI.widgetBox(self.tabs, margin=4)
        TabOrderTab = OWGUI.widgetBox(self.tabs, margin=4)

        self.tabs.addTab(GeneralTab, "General")
        self.tabs.addTab(ExceptionsTab, "Exception handling")
        self.tabs.addTab(TabOrderTab, "Widget tab order")

        # #################################################################
        # GENERAL TAB
        generalBox = OWGUI.widgetBox(GeneralTab, "General Options")
        self.snapToGridCB = OWGUI.checkBox(generalBox,
                                           self.settings,
                                           "snapToGrid",
                                           "Snap widgets to grid",
                                           debuggingEnabled=0)
        self.writeLogFileCB = OWGUI.checkBox(
            generalBox,
            self.settings,
            "writeLogFile",
            "Save content of the Output window to a log file",
            debuggingEnabled=0)
        self.showSignalNamesCB = OWGUI.checkBox(
            generalBox,
            self.settings,
            "showSignalNames",
            "Show signal names between widgets",
            debuggingEnabled=0)
        self.dontAskBeforeCloseCB = OWGUI.checkBox(
            generalBox,
            self.settings,
            "dontAskBeforeClose",
            "Don't ask to save schema before closing",
            debuggingEnabled=0)
        self.saveWidgetsPositionCB = OWGUI.checkBox(
            generalBox,
            self.settings,
            "saveWidgetsPosition",
            "Save size and position of widgets",
            debuggingEnabled=0)
        self.useContextsCB = OWGUI.checkBox(generalBox, self.settings,
                                            "useContexts",
                                            "Use context settings")

        validator = QIntValidator(self)
        validator.setRange(0, 10000)

        hbox1 = OWGUI.widgetBox(GeneralTab, orientation="horizontal")
        hbox2 = OWGUI.widgetBox(GeneralTab, orientation="horizontal")
        canvasDlgSettings = OWGUI.widgetBox(hbox1, "Canvas Dialog Settings")
        #        schemeSettings = OWGUI.widgetBox(hbox1, "Scheme Settings")

        self.widthSlider = OWGUI.qwtHSlider(canvasDlgSettings,
                                            self.settings,
                                            "canvasWidth",
                                            minValue=300,
                                            maxValue=1200,
                                            label="Canvas width:  ",
                                            step=50,
                                            precision=" %.0f px",
                                            debuggingEnabled=0)
        self.heightSlider = OWGUI.qwtHSlider(canvasDlgSettings,
                                             self.settings,
                                             "canvasHeight",
                                             minValue=300,
                                             maxValue=1200,
                                             label="Canvas height:  ",
                                             step=50,
                                             precision=" %.0f px",
                                             debuggingEnabled=0)
        OWGUI.separator(canvasDlgSettings)

        items = [str(n) for n in QStyleFactory.keys()]
        ind = items.index(self.settings.get("style", "WindowsXP"))
        OWGUI.comboBox(canvasDlgSettings,
                       self.settings,
                       "style",
                       label="Window style:",
                       orientation="horizontal",
                       items=[str(n) for n in QStyleFactory.keys()],
                       sendSelectedValue=1,
                       debuggingEnabled=0)
        OWGUI.checkBox(canvasDlgSettings,
                       self.settings,
                       "useDefaultPalette",
                       "Use style's standard palette",
                       debuggingEnabled=0)

        #        if canvasDlg:
        #            selectedWidgetBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        #            self.selectedWidgetIcon = ColorIcon(selectedWidgetBox, canvasDlg.widgetSelectedColor)
        #            selectedWidgetBox.layout().addWidget(self.selectedWidgetIcon)
        #            selectedWidgetLabel = OWGUI.widgetLabel(selectedWidgetBox, " Selected widget")
        #
        #            activeWidgetBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        #            self.activeWidgetIcon = ColorIcon(activeWidgetBox, canvasDlg.widgetActiveColor)
        #            activeWidgetBox.layout().addWidget(self.activeWidgetIcon)
        #            selectedWidgetLabel = OWGUI.widgetLabel(activeWidgetBox, " Active widget")
        #
        #            lineBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        #            self.lineIcon = ColorIcon(lineBox, canvasDlg.lineColor)
        #            lineBox.layout().addWidget(self.lineIcon)
        #            selectedWidgetLabel = OWGUI.widgetLabel(lineBox, " Lines")
        #
        #        OWGUI.separator(schemeSettings)
        #        items = ["%d x %d" % (v,v) for v in self.canvasDlg.schemeIconSizeList]
        #        val = min(len(items)-1, self.settings['schemeIconSize'])
        #        self.schemeIconSizeCombo = OWGUI.comboBoxWithCaption(schemeSettings, self.settings, 'schemeIconSize', "Scheme icon size:", items = items, tooltip = "Set the size of the widget icons on the scheme", debuggingEnabled = 0)

        GeneralTab.layout().addStretch(1)

        # #################################################################
        # EXCEPTION TAB
        exceptions = OWGUI.widgetBox(ExceptionsTab, "Exceptions")
        #self.catchExceptionCB = QCheckBox('Catch exceptions', exceptions)
        self.focusOnCatchExceptionCB = OWGUI.checkBox(
            exceptions, self.settings, "focusOnCatchException",
            'Show output window on exception')
        self.printExceptionInStatusBarCB = OWGUI.checkBox(
            exceptions, self.settings, "printExceptionInStatusBar",
            'Print last exception in status bar')

        output = OWGUI.widgetBox(ExceptionsTab, "System output")
        #self.catchOutputCB = QCheckBox('Catch system output', output)
        self.focusOnCatchOutputCB = OWGUI.checkBox(
            output, self.settings, "focusOnCatchOutput",
            'Focus output window on system output')
        self.printOutputInStatusBarCB = OWGUI.checkBox(
            output, self.settings, "printOutputInStatusBar",
            'Print last system output in status bar')

        hboxExc = OWGUI.widgetBox(ExceptionsTab, orientation="horizontal")
        outputCanvas = OWGUI.widgetBox(hboxExc, "Canvas Info Handling")
        outputWidgets = OWGUI.widgetBox(hboxExc, "Widget Info Handling")
        self.ocShow = OWGUI.checkBox(outputCanvas, self.settings, "ocShow",
                                     'Show icon above widget for...')
        self.ocInfo = OWGUI.checkBox(OWGUI.indentedBox(outputCanvas, 10),
                                     self.settings, "ocInfo", 'Information')
        self.ocWarning = OWGUI.checkBox(OWGUI.indentedBox(outputCanvas, 10),
                                        self.settings, "ocWarning", 'Warnings')
        self.ocError = OWGUI.checkBox(OWGUI.indentedBox(outputCanvas, 10),
                                      self.settings, "ocError", 'Errors')

        self.owShow = OWGUI.checkBox(outputWidgets, self.settings, "owShow",
                                     'Show statusbar info for...')
        self.owInfo = OWGUI.checkBox(OWGUI.indentedBox(outputWidgets, 10),
                                     self.settings, "owInfo", 'Information')
        self.owWarning = OWGUI.checkBox(OWGUI.indentedBox(outputWidgets, 10),
                                        self.settings, "owWarning", 'Warnings')
        self.owError = OWGUI.checkBox(OWGUI.indentedBox(outputWidgets, 10),
                                      self.settings, "owError", 'Errors')

        verbosityBox = OWGUI.widgetBox(ExceptionsTab,
                                       "Verbosity",
                                       orientation="horizontal")
        verbosityBox.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum))
        self.verbosityCombo = OWGUI.comboBox(
            verbosityBox,
            self.settings,
            "outputVerbosity",
            label="Set level of widget output: ",
            orientation='horizontal',
            items=["Small", "Medium", "High"])
        ExceptionsTab.layout().addStretch(1)

        # #################################################################
        # TAB ORDER TAB
        tabOrderBox = OWGUI.widgetBox(TabOrderTab,
                                      "Set Order of Widget Categories",
                                      orientation="horizontal",
                                      sizePolicy=QSizePolicy(
                                          QSizePolicy.Minimum,
                                          QSizePolicy.Minimum))
        self.tabOrderList = QListWidget(tabOrderBox)
        self.tabOrderList.setAcceptDrops(True)

        tabOrderBox.layout().addWidget(self.tabOrderList)
        self.tabOrderList.setSelectionMode(QListWidget.SingleSelection)

        ind = 0
        for (name, show) in self.settings["WidgetTabs"]:
            if self.canvasDlg.widgetRegistry.has_key(name):
                self.tabOrderList.addItem(name)
                self.tabOrderList.item(ind).setCheckState(show and Qt.Checked
                                                          or Qt.Unchecked)
                ind += 1

        w = OWGUI.widgetBox(tabOrderBox,
                            sizePolicy=QSizePolicy(QSizePolicy.Minimum,
                                                   QSizePolicy.Expanding))
        self.upButton = OWGUI.button(w, self, "Up", callback=self.moveUp)
        self.downButton = OWGUI.button(w, self, "Down", callback=self.moveDown)
        w.layout().addSpacing(20)
        self.addButton = OWGUI.button(w,
                                      self,
                                      "Add",
                                      callback=self.addCategory)
        self.removeButton = OWGUI.button(w,
                                         self,
                                         "Remove",
                                         callback=self.removeCategory)
        self.removeButton.setEnabled(0)
        w.layout().addStretch(1)

        # OK, Cancel buttons
        hbox = OWGUI.widgetBox(self,
                               orientation="horizontal",
                               sizePolicy=QSizePolicy(QSizePolicy.Minimum,
                                                      QSizePolicy.Fixed))
        hbox.layout().addStretch(1)
        self.okButton = OWGUI.button(hbox, self, "OK", callback=self.accept)
        self.cancelButton = OWGUI.button(hbox,
                                         self,
                                         "Cancel",
                                         callback=self.reject)
        self.connect(self.tabOrderList, SIGNAL("currentRowChanged(int)"),
                     self.enableDisableButtons)

        self.topLayout.addWidget(self.tabs)
        self.topLayout.addWidget(hbox)
Example #6
0
    def __init__(self, parent=None, signalManager=None, name="Multi Dimensional Scaling"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
        self.inputs=[("Distances", orange.SymMatrix, self.cmatrix), ("Example Subset", ExampleTable, self.cselected)]
        self.outputs=[("Example Table", ExampleTable), ("Structured Data Files", DataFiles)]

        self.StressFunc=3
        self.minStressDelta=1e-5
        self.maxIterations=5000
        self.maxImprovment=10
        self.autoSendSelection=0
        self.toolbarSelection=0
        self.selectionOptions=0
        self.computeStress=1
        self.ReDraw=1
        self.NumIter=1
        self.RefreshMode=0
        self.applyLSMT = 0

        self.stressFunc=[("Kruskal stress", orngMDS.KruskalStress),
                              ("Sammon stress", orngMDS.SammonStress),
                              ("Signed Sammon stress", orngMDS.SgnSammonStress),
                              ("Signed relative stress", orngMDS.SgnRelStress)]
        
        self.graph=MDSGraph(self.mainArea)
        self.mainArea.layout().addWidget(self.graph)
        
        self.loadSettings()

        tabs=OWGUI.tabWidget(self.controlArea)
        
        mds=OWGUI.createTabPage(tabs, "MDS")
        graph=OWGUI.createTabPage(tabs, "Graph")

        ##MDS Tab        
        init=OWGUI.widgetBox(mds, "Initialization")
        OWGUI.button(init, self, "Randomize", self.randomize)
        OWGUI.button(init, self, "Jitter", self.jitter)
        OWGUI.button(init, self, "Torgerson", self.torgerson)
        opt=OWGUI.widgetBox(mds, "Optimization")

        self.startButton=OWGUI.button(opt, self, "Optimize", self.testStart)
        OWGUI.button(opt, self, "Single Step", self.smacofStep)
        box = OWGUI.widgetBox(opt, "Stress Function")
        OWGUI.comboBox(box, self, "StressFunc", items=[a[0] for a in self.stressFunc], callback=self.updateStress)        
        OWGUI.radioButtonsInBox(opt, self, "RefreshMode", ["Every step", "Every 10 steps", "Every 100 steps"], "Refresh During Optimization", callback=lambda :1)
        
        self.stopping=OWGUI.widgetBox(opt, "Stopping Conditions")
        OWGUI.qwtHSlider(self.stopping, self, "minStressDelta", label="Min. stress change", minValue=0, maxValue=1e-2, step=1e-5, precision=6)
        OWGUI.qwtHSlider(self.stopping, self, "maxIterations", label="Max. number of steps", minValue=10, maxValue=5000, step=10, precision=0)

        ##Graph Tab        
        OWGUI.hSlider(graph, self, "graph.PointSize", box="Point Size", minValue=1, maxValue=20, callback=self.graph.updateData)
        self.colorCombo=OWGUI.comboBox(graph, self, "graph.ColorAttr", box="Color", callback=self.graph.updateData)
        self.sizeCombo=OWGUI.comboBox(graph, self, "graph.SizeAttr", box="Size", callback=self.graph.updateData)
        self.shapeCombo=OWGUI.comboBox(graph, self, "graph.ShapeAttr", box="Shape", callback=self.graph.updateData)
        self.nameCombo=OWGUI.comboBox(graph, self, "graph.NameAttr", box="Label", callback=self.graph.updateData)
        
        box = OWGUI.widgetBox(graph, "Distances & Stress")
        OWGUI.checkBox(box, self, "graph.ShowStress", "Show similar pairs", callback = self.graph.updateLinesRepaint)
        b2 = OWGUI.widgetBox(box)
        OWGUI.widgetLabel(b2, "Proportion of connected pairs")
        OWGUI.separator(b2, height=3)
        sl = OWGUI.hSlider(b2, self, "graph.proportionGraphed", minValue=0, maxValue=20, callback=self.graph.updateLinesRepaint, tooltip="Proportion of connected pairs (Maximum of 1000 lines will be drawn")
        OWGUI.checkBox(box, self, "graph.differentWidths", "Show distance by line width", callback = self.graph.updateLinesRepaint)
        OWGUI.checkBox(box, self, "graph.stressByTransparency", "Show stress by transparency", callback = self.graph.updateLinesRepaint)
        OWGUI.checkBox(box, self, "graph.stressBySize", "Show stress by symbol size", callback = self.updateStressBySize)
        self.updateStressBySize(True)
        
        OWGUI.checkBox(graph, self, "graph.useAntialiasing", label="Use antialiasing", box="Antialiasing", tooltip="Use antialiasing for beter quality graphics", callback=self.graph.updateData)

        self.zoomToolbar=OWToolbars.ZoomSelectToolbar(self, graph, self.graph, self.autoSendSelection)
        self.connect(self.zoomToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)
        self.graph.autoSendSelectionCallback = lambda :self.autoSendSelection and self.sendSelections()

        OWGUI.checkBox(graph, self, "autoSendSelection", "Auto send selected")
        OWGUI.radioButtonsInBox(graph, self, "selectionOptions", ["Don't append", "Append coordinates", "Append coordinates as meta"], box="Append coordinates", callback=self.sendIf)

        mds.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum))
        graph.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum))
        self.controlArea.setMinimumWidth(250)
        OWGUI.rubber(mds)
        infoBox=OWGUI.widgetBox(mds, "Info")
        self.infoA=OWGUI.widgetLabel(infoBox, "Avg. stress:")
        self.infoB=OWGUI.widgetLabel(infoBox, "Num. steps")
#        OWGUI.button(self.controlArea, self, "Save", self.graph.saveToFile, debuggingEnabled = 0)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        self.resize(900,630)

        self.done=True
        self.data=None
        self.selectedInputExamples=[]
        self.selectedInput=[]
    def __init__(self, parentWidget = None, signalManager = None, graph = None, parentName = "Visualization widget"):
        OWWidget.__init__(self, None, signalManager, "FreeViz Dialog", savePosition = True, wantMainArea = 0, wantStatusBar = 1)
        FreeViz.__init__(self, graph)

        self.parentWidget = parentWidget
        self.parentName = parentName
        self.setCaption("FreeViz Optimization Dialog")
        self.cancelOptimization = 0
        self.forceRelation = 5
        self.disableAttractive = 0
        self.disableRepulsive = 0
        self.touringSpeed = 4
        self.graph = graph

        if self.graph:
            self.graph.hideRadius = 0
            self.graph.showAnchors = 1

        # differential evolution
        self.differentialEvolutionPopSize = 100
        self.DERadvizSolver = None

        self.loadSettings()

        self.layout().setMargin(0)
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.MainTab = OWGUI.createTabPage(self.tabs, "Main")
        self.ProjectionsTab = OWGUI.createTabPage(self.tabs, "Projections")

        # ###########################
        # MAIN TAB
        OWGUI.comboBox(self.MainTab, self, "implementation", box = "FreeViz implementation", items = ["Fast (C) implementation", "Slow (Python) implementation", "LDA"])

        box = OWGUI.widgetBox(self.MainTab, "Optimization")

        self.optimizeButton = OWGUI.button(box, self, "Optimize Separation", callback = self.optimizeSeparation)
        self.stopButton = OWGUI.button(box, self, "Stop Optimization", callback = self.stopOptimization)
        self.singleStepButton = OWGUI.button(box, self, "Single Step", callback = self.singleStepOptimization)
        f = self.optimizeButton.font(); f.setBold(1)
        self.optimizeButton.setFont(f)
        self.stopButton.setFont(f); self.stopButton.hide()
        self.attrKNeighboursCombo = OWGUI.comboBoxWithCaption(box, self, "stepsBeforeUpdate", "Number of steps before updating graph: ", tooltip = "Set the number of optimization steps that will be executed before the updated anchor positions will be visualized", items = [1, 3, 5, 10, 15, 20, 30, 50, 75, 100, 150, 200, 300], sendSelectedValue = 1, valueType = int)
        OWGUI.checkBox(box, self, "mirrorSymmetry", "Keep mirror symmetry", tooltip = "'Rotational' keeps the second anchor upside")

        vbox = OWGUI.widgetBox(self.MainTab, "Set anchor positions")
        hbox1 = OWGUI.widgetBox(vbox, orientation = "horizontal")
        OWGUI.button(hbox1, self, "Sphere" if "3d" in self.parentName.lower() else "Circle", callback = self.radialAnchors)
        OWGUI.button(hbox1, self, "Random", callback = self.randomAnchors)
        self.manualPositioningButton = OWGUI.button(hbox1, self, "Manual", callback = self.setManualPosition)
        self.manualPositioningButton.setCheckable(1)
        OWGUI.comboBox(vbox, self, "restrain", label="Restrain anchors:", orientation = "horizontal", items = ["Unrestrained", "Fixed Length", "Fixed Angle"], callback = self.setRestraints)

        box2 = OWGUI.widgetBox(self.MainTab, "Forces", orientation = "vertical")

        self.cbLaw = OWGUI.comboBox(box2, self, "law", label="Law", labelWidth = 40, orientation="horizontal", items=["Linear", "Square", "Gaussian", "KNN", "Variance"], callback = self.forceLawChanged)

        hbox2 = OWGUI.widgetBox(box2, orientation = "horizontal")
        hbox2.layout().addSpacing(10)

        validSigma = QDoubleValidator(self); validSigma.setBottom(0.01)
        self.spinSigma = OWGUI.lineEdit(hbox2, self, "forceSigma", label = "Kernel width (sigma) ", labelWidth = 110, orientation = "horizontal", valueType = float)
        self.spinSigma.setFixedSize(60, self.spinSigma.sizeHint().height())
        self.spinSigma.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed))

        box2.layout().addSpacing(20)

        self.cbforcerel = OWGUI.comboBox(box2, self, "forceRelation", label= "Attractive : Repulsive  ",orientation = "horizontal", items=self.forceRelValues, callback = self.updateForces)
        self.cbforcebal = OWGUI.checkBox(box2, self, "forceBalancing", "Dynamic force balancing", tooltip="Normalize the forces so that the total sums of the\nrepulsive and attractive are in the above proportion.")

        box2.layout().addSpacing(20)

        self.cbDisableAttractive = OWGUI.checkBox(box2, self, "disableAttractive", "Disable attractive forces", callback = self.setDisableAttractive)
        self.cbDisableRepulsive = OWGUI.checkBox(box2, self, "disableRepulsive", "Disable repulsive forces", callback = self.setDisableRepulsive)

        box = OWGUI.widgetBox(self.MainTab, "Show anchors")
        OWGUI.checkBox(box, self, 'graph.showAnchors', 'Show attribute anchors', callback = self.parentWidget.updateGraph)
        OWGUI.qwtHSlider(box, self, "graph.hideRadius", label="Hide radius", minValue=0, maxValue=9, step=1, ticks=0, callback = self.parentWidget.updateGraph)
        self.freeAttributesButton = OWGUI.button(box, self, "Remove hidden attributes", callback = self.removeHidden)

        if parentName.lower() != "radviz" and parentName.lower() != "sphereviz":
            pcaBox = OWGUI.widgetBox(self.ProjectionsTab, "Principal Component Analysis")
            OWGUI.button(pcaBox, self, "Principal component analysis", callback = self.findPCAProjection)
            OWGUI.button(pcaBox, self, "Supervised principal component analysis", callback = self.findSPCAProjection)
            OWGUI.checkBox(pcaBox, self, "useGeneralizedEigenvectors", "Merge examples with same class value")
            plsBox = OWGUI.widgetBox(self.ProjectionsTab, "Partial Least Squares")
            OWGUI.button(plsBox, self, "Partial least squares", callback = self.findPLSProjection)
        
        box = OWGUI.widgetBox(self.ProjectionsTab, "Projection Tours")
        self.startTourButton = OWGUI.button(box, self, "Start Random Touring", callback = self.startRandomTouring)
        self.stopTourButton = OWGUI.button(box, self, "Stop Touring", callback = self.stopRandomTouring)
        self.stopTourButton.hide()
        OWGUI.hSlider(box, self, 'touringSpeed', label = "Speed:  ", minValue=1, maxValue=10, step=1)
        OWGUI.rubber(self.ProjectionsTab)
        
        box = OWGUI.widgetBox(self.ProjectionsTab, "Signal to Noise Heuristic")
        #OWGUI.comboBoxWithCaption(box, self, "s2nSpread", "Anchor spread: ", tooltip = "Are the anchors for each class value placed together or are they distributed along the circle", items = range(11), callback = self.s2nMixAnchors)
        box2 = OWGUI.widgetBox(box, 0, orientation = "horizontal")
        OWGUI.widgetLabel(box2, "Anchor spread:           ")
        OWGUI.hSlider(box2, self, 's2nSpread', minValue=0, maxValue=10, step=1, callback = self.s2nMixAnchors, labelFormat="  %d", ticks=0)
        OWGUI.comboBoxWithCaption(box, self, "s2nPlaceAttributes", "Attributes to place: ", tooltip = "Set the number of top ranked attributes to place. You can select a higher value than the actual number of attributes", items = self.attrsNum, callback = self.s2nMixAnchors, sendSelectedValue = 1, valueType = int)
        OWGUI.checkBox(box, self, 'autoSetParameters', 'Automatically find optimal parameters')
        self.s2nMixButton = OWGUI.button(box, self, "Place anchors", callback = self.s2nMixAnchorsAutoSet)


        self.forceLawChanged()
        self.updateForces()
        self.cbforcebal.setDisabled(self.cbDisableAttractive.isChecked() or self.cbDisableRepulsive.isChecked())
        self.resize(320,650)
Example #8
0
    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)
Example #9
0
    def __init__(self, parent=None, signalManager=None):
        #        self.callbackDeposit = [] # deposit for OWGUI callback function
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          'Distance Map',
                          wantGraph=True)

        self.inputs = [("Distance Matrix", orange.SymMatrix, self.setMatrix)]
        self.outputs = [("Examples", ExampleTable),
                        ("Attribute List", orange.VarList)]

        self.clicked = False
        self.offsetX = 5
        self.offsetY = 5
        self.imageWidth = 0
        self.imageHeight = 0
        self.distanceImage = None
        self.legendImage = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.palette = None

        self.shiftPressed = False

        #set default settings
        self.CellWidth = 15
        self.CellHeight = 15
        self.Merge = 1
        self.savedMerge = self.Merge
        self.Gamma = 1
        self.Grid = 1
        self.savedGrid = 1
        self.CutLow = 0
        self.CutHigh = 0
        self.CutEnabled = 0
        self.Sort = 0
        self.SquareCells = 0
        self.ShowLegend = 1
        self.ShowLabels = 1
        self.ShowBalloon = 1
        self.ShowItemsInBalloon = 1
        self.SendOnRelease = 1

        self.loadSettings()

        self.maxHSize = 30
        self.maxVSize = 30
        self.sorting = [("No sorting", self.sortNone),
                        ("Adjacent distance", self.sortAdjDist),
                        ("Random order", self.sortRandom),
                        ("Clustering", self.sortClustering),
                        ("Clustering with ordered leafs",
                         self.sortClusteringOrdered)]

        self.matrix = self.order = None
        self.rootCluster = None

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

        # SETTINGS TAB
        tab = OWGUI.createTabPage(self.tabs, "Settings")
        box = OWGUI.widgetBox(tab, "Cell Size (Pixels)")
        OWGUI.qwtHSlider(box,
                         self,
                         "CellWidth",
                         label='Width: ',
                         labelWidth=38,
                         minValue=1,
                         maxValue=self.maxHSize,
                         step=1,
                         precision=0,
                         callback=[
                             lambda f="CellWidth", t="CellHeight": self.
                             adjustCellSize(f, t), self.drawDistanceMap,
                             self.manageGrid
                         ])
        OWGUI.qwtHSlider(box,
                         self,
                         "CellHeight",
                         label='Height: ',
                         labelWidth=38,
                         minValue=1,
                         maxValue=self.maxVSize,
                         step=1,
                         precision=0,
                         callback=[
                             lambda f="CellHeight", t="CellWidth": self.
                             adjustCellSize(f, t), self.drawDistanceMap,
                             self.manageGrid
                         ])
        OWGUI.checkBox(box,
                       self,
                       "SquareCells",
                       "Cells as squares",
                       callback=[self.setSquares, self.drawDistanceMap])
        self.gridChkBox = OWGUI.checkBox(
            box,
            self,
            "Grid",
            "Show grid",
            callback=self.createDistanceMap,
            disabled=lambda: min(self.CellWidth, self.CellHeight
                                 ) <= c_smallcell)

        OWGUI.separator(tab)
        OWGUI.qwtHSlider(tab,
                         self,
                         "Merge",
                         box="Merge",
                         label='Elements:',
                         labelWidth=50,
                         minValue=1,
                         maxValue=100,
                         step=1,
                         callback=self.createDistanceMap,
                         ticks=0)

        OWGUI.separator(tab)
        self.labelCombo = OWGUI.comboBox(
            tab,
            self,
            "Sort",
            box="Sort",
            items=[x[0] for x in self.sorting],
            tooltip="Sorting method for items in distance matrix.",
            callback=self.sortItems)
        OWGUI.rubber(tab)

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

        # FILTER TAB
        tab = OWGUI.createTabPage(self.tabs, "Colors")
        box = OWGUI.widgetBox(tab, "Color settings", addSpace=True)
        OWGUI.widgetLabel(box, "Gamma")
        OWGUI.qwtHSlider(box,
                         self,
                         "Gamma",
                         minValue=0.1,
                         maxValue=1,
                         step=0.1,
                         maxWidth=100,
                         callback=self.drawDistanceMap)

        OWGUI.separator(box)

        OWGUI.checkBox(box,
                       self,
                       'CutEnabled',
                       "Enable thresholds",
                       callback=self.setCutEnabled)
        self.sliderCutLow = OWGUI.qwtHSlider(box,
                                             self,
                                             'CutLow',
                                             label='Low:',
                                             labelWidth=33,
                                             minValue=-100,
                                             maxValue=0,
                                             step=0.1,
                                             precision=1,
                                             ticks=0,
                                             maxWidth=80,
                                             callback=self.drawDistanceMap)
        self.sliderCutHigh = OWGUI.qwtHSlider(box,
                                              self,
                                              'CutHigh',
                                              label='High:',
                                              labelWidth=33,
                                              minValue=0,
                                              maxValue=100,
                                              step=0.1,
                                              precision=1,
                                              ticks=0,
                                              maxWidth=80,
                                              callback=self.drawDistanceMap)
        if not self.CutEnabled:
            self.sliderCutLow.box.setDisabled(1)
            self.sliderCutHigh.box.setDisabled(1)

##        self.colorPalette = ColorPalette(box, self, "",
##                         additionalColors =["Cell outline", "Selected cells"],
##                         callback = self.setColor)
##        box.layout().addWidget(self.colorPalette)
        box = OWGUI.widgetBox(box, "Colors", orientation="horizontal")
        self.colorCombo = OWColorPalette.PaletteSelectorComboBox(self)
        try:
            self.colorCombo.setPalettes("palette", self.createColorDialog())
        except Exception as ex:
            print(
                ex,
                "Error loading saved color palettes!\nCreating new default palette!",
                file=sys.stderr)
            self.colorSettings = None
            self.colorCombo.setPalettes("palette", self.createColorDialog())
        self.colorCombo.setCurrentIndex(self.selectedSchemaIndex)
        self.connect(self.colorCombo, SIGNAL("activated(int)"), self.setColor)
        box.layout().addWidget(self.colorCombo, 2)
        OWGUI.button(box,
                     self,
                     "Edit colors",
                     callback=self.openColorDialog,
                     debuggingEnabled=0)
        OWGUI.rubber(tab)

        self.setColor(self.selectedSchemaIndex)

        ##        self.tabs.insertTab(tab, "Colors")

        # INFO TAB
        tab = OWGUI.createTabPage(self.tabs, "Info")
        box = OWGUI.widgetBox(tab, "Annotation && Legends")
        OWGUI.checkBox(box,
                       self,
                       'ShowLegend',
                       'Show legend',
                       callback=self.drawDistanceMap)
        OWGUI.checkBox(box,
                       self,
                       'ShowLabels',
                       'Show labels',
                       callback=self.drawDistanceMap)

        box = OWGUI.widgetBox(tab, "Balloon")
        OWGUI.checkBox(box, self, 'ShowBalloon', "Show balloon")
        OWGUI.checkBox(box, self, 'ShowItemsInBalloon', "Display item names")

        box = OWGUI.widgetBox(tab, "Select")
        box2 = OWGUI.widgetBox(box, orientation="horizontal")
        self.box2 = box2
        self.buttonUndo = OWToolbars.createButton(box2,
                                                  'Undo',
                                                  self.actionUndo,
                                                  QIcon(OWToolbars.dlg_undo),
                                                  toggle=0)
        self.buttonRemoveAllSelections = OWToolbars.createButton(
            box2,
            'Remove all selections',
            self.actionRemoveAllSelections,
            QIcon(OWToolbars.dlg_clear),
            toggle=0)

        self.buttonSendSelections = OWToolbars.createButton(
            box2,
            'Send selections',
            self.sendOutput,
            QIcon(OWToolbars.dlg_send),
            toggle=0)
        OWGUI.checkBox(box, self, 'SendOnRelease', "Send after mouse release")
        OWGUI.rubber(tab)
        ##        self.tabs.insertTab(tab, "Info")

        self.resize(700, 400)

        self.scene = EventfulGraphicsScene(self)
        self.sceneView = EventfulGraphicsView(self.scene, self.mainArea, self)
        self.mainArea.layout().addWidget(self.sceneView)

        #construct selector
        self.selector = QGraphicsRectItem(0, 0, self.CellWidth,
                                          self.CellHeight, None, self.scene)
        ##        color = self.colorPalette.getCurrentColorSchema().getAdditionalColors()["Cell outline"]
        color = self.cellOutlineColor
        self.selector.setPen(QPen(self.qrgbToQColor(color), v_sel_width))
        self.selector.setZValue(20)

        ##        self.bubble = BubbleInfo(self.scene)
        self.selection = SelectionManager()

        self.selectionLines = []
        self.annotationText = []
        self.clusterItems = []
        self.selectionRects = []

        self.legendText1 = QGraphicsSimpleTextItem(None, self.scene)
        self.legendText2 = QGraphicsSimpleTextItem(None, self.scene)

        self.errorText = QGraphicsSimpleTextItem("Bitmap is too large.", None,
                                                 self.scene)
        self.errorText.setPos(10, 10)

        #        OWGUI.button(self.controlArea, self, "&Save Graph", lambda:OWChooseImageSizeDlg(self.scene).exec_(), debuggingEnabled = 0)
        self.connect(
            self.graphButton, SIGNAL("clicked()"),
            lambda: OWChooseImageSizeDlg(self.scene, parent=self).exec_())