Changeset 8623:a32efa97899a in orange


Ignore:
Timestamp:
08/06/11 10:37:40 (3 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
4c34157214a5b32a7d2220afb172b7fd47cc76cc
Message:

Added circular layout optimization functions.

Location:
orange/OrangeWidgets/Prototypes
Files:
2 edited

Legend:

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

    r8613 r8623  
    550550        OWPlot.use_animations(self) 
    551551        self.networkCurve.set_use_animations(True) 
    552                      
     552     
     553    def set_labels_on_marked_only(self, labelsOnMarkedOnly): 
     554        self.networkCurve.set_labels_on_marked_only(labelsOnMarkedOnly) 
     555        self.replot() 
     556     
    553557    def replot(self): 
    554558        self.set_dirty() 
  • orange/OrangeWidgets/Prototypes/OWNxExplorerQt.py

    r8610 r8623  
    137137        self.tabs = OWGUI.tabWidget(self.hcontroArea) 
    138138         
    139         self.verticesTab = OWGUI.createTabPage(self.tabs, "Vertices") 
     139        self.verticesTab = OWGUI.createTabPage(self.tabs, "Nodes") 
    140140        self.edgesTab = OWGUI.createTabPage(self.tabs, "Edges") 
    141141        self.markTab = OWGUI.createTabPage(self.tabs, "Mark") 
     
    157157        self.optCombo.addItem("Circular Original") 
    158158        self.optCombo.addItem("Circular Random") 
    159         self.optCombo.addItem("Pivot MDS") 
     159        #self.optCombo.addItem("Pivot MDS") 
    160160        self.optCombo.setCurrentIndex(self.optMethod) 
    161161        self.stepsSpin = OWGUI.spin(self.optimizeBox, self, "frSteps", 1, 100000, 1, label="Iterations: ") 
     
    164164        self.optButton = OWGUI.button(self.optimizeBox, self, "Optimize layout", callback=self.graph_layout, toggleButton=1) 
    165165         
    166         colorBox = OWGUI.widgetBox(self.verticesTab, "Vertex color attribute", orientation="horizontal", addSpace = False) 
     166        colorBox = OWGUI.widgetBox(self.verticesTab, "Node color attribute", orientation="horizontal", addSpace = False) 
    167167        self.colorCombo = OWGUI.comboBox(colorBox, self, "color", callback=self.setVertexColor) 
    168168        self.colorCombo.addItem("(same color)") 
    169         OWGUI.button(colorBox, self, "Set vertex color palette", self.setColors, tooltip = "Set vertex color palette", debuggingEnabled = 0) 
    170          
    171         ib = OWGUI.widgetBox(self.verticesTab, "Vertex size attribute", orientation="vertical", addSpace = False) 
     169        OWGUI.button(colorBox, self, "Set node color palette", self.setColors, tooltip = "Set node color palette", debuggingEnabled = 0) 
     170         
     171        ib = OWGUI.widgetBox(self.verticesTab, "Node size attribute", orientation="vertical", addSpace = False) 
    172172        hb = OWGUI.widgetBox(ib, orientation="horizontal", addSpace = False) 
    173173        OWGUI.checkBox(hb, self, "invertSize", "Invert size", callback = self.set_vertex_size) 
     
    177177        self.vertexSizeCombo.addItem("(none)") 
    178178         
    179         ib = OWGUI.widgetBox(self.verticesTab, "Vertex labels | tooltips", orientation="vertical", addSpace = False) 
     179        ib = OWGUI.widgetBox(self.verticesTab, "Node labels | tooltips", orientation="vertical", addSpace = False) 
    180180        OWGUI.spin(ib, self, "fontSize", 4, 30, 1, label="Set font size:", callback = self.setFontSize) 
    181181        hb = OWGUI.widgetBox(ib, orientation="horizontal", addSpace = False) 
     
    187187        OWGUI.checkBox(ib, self, 'showEdgeLabels', 'Show labels on edges', callback=(lambda: self._set_canvas_attr('showEdgeLabels', self.showEdgeLabels))) 
    188188        OWGUI.spin(ib, self, "maxLinkSize", 1, 50, 1, label="Max edge width:", callback = self.setMaxLinkSize) 
    189         self.showDistancesCheckBox = OWGUI.checkBox(ib, self, 'showDistances', 'Explore vertex distances', callback=(lambda: self._set_canvas_attr('showDistances', self.showDistances)), disabled=1) 
     189        self.showDistancesCheckBox = OWGUI.checkBox(ib, self, 'showDistances', 'Explore node distances', callback=(lambda: self._set_canvas_attr('showDistances', self.showDistances)), disabled=1) 
    190190         
    191191        colorBox = OWGUI.widgetBox(self.edgesTab, "Edge color attribute", orientation="horizontal", addSpace = False) 
     
    200200        ib = OWGUI.widgetBox(self.verticesTab, "General", orientation="vertical") 
    201201        OWGUI.checkBox(ib, self, 'networkCanvas.show_indices', 'Show indices', callback=self.networkCanvas.set_label_attributes) 
    202         OWGUI.checkBox(ib, self, 'labelsOnMarkedOnly', 'Show labels on marked vertices only', callback=(lambda: self.networkCanvas.networkCurve.set_labels_on_marked_only(self.labelsOnMarkedOnly))) 
     202        OWGUI.checkBox(ib, self, 'labelsOnMarkedOnly', 'Show labels on marked nodes only', callback=(lambda: self.networkCanvas.set_labels_on_marked_only(self.labelsOnMarkedOnly))) 
    203203        self.networkCanvas.gui.antialiasing_check_box(ib) 
    204204        self.networkCanvas.gui.animations_check_box(ib) 
    205205         
    206206        ib = OWGUI.widgetBox(self.markTab, "Info", orientation="vertical") 
    207         OWGUI.label(ib, self, "Vertices (shown/hidden): %(number_of_nodes_label)i (%(nShown)i/%(nHidden)i)") 
    208         OWGUI.label(ib, self, "Selected and marked vertices: %(nSelected)i - %(nMarked)i") 
    209          
    210         ribg = OWGUI.radioButtonsInBox(self.markTab, self, "hubs", [], "Method", callback = self.set_mark_mode) 
     207        OWGUI.label(ib, self, "Nodes (shown/hidden): %(number_of_nodes_label)i (%(nShown)i/%(nHidden)i)") 
     208        OWGUI.label(ib, self, "Selected: %(nSelected)i, marked: %(nMarked)i") 
     209         
     210        ribg = OWGUI.radioButtonsInBox(self.markTab, self, "hubs", [], "Mark", callback = self.set_mark_mode) 
    211211        OWGUI.appendRadioButton(ribg, self, "hubs", "None", callback = self.set_mark_mode) 
    212         OWGUI.appendRadioButton(ribg, self, "hubs", "Find vertices", callback = self.set_mark_mode) 
     212        OWGUI.appendRadioButton(ribg, self, "hubs", "Search", callback = self.set_mark_mode) 
    213213        self.ctrlMarkSearchString = OWGUI.lineEdit(OWGUI.indentedBox(ribg), self, "markSearchString", callback=self.setSearchStringTimer, callbackOnType=True) 
    214214        self.searchStringTimer = QTimer(self) 
    215215        self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.set_mark_mode) 
    216216         
    217         OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of focused vertices", callback = self.set_mark_mode) 
    218         OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of selected vertices", callback = self.set_mark_mode) 
     217        OWGUI.appendRadioButton(ribg, self, "hubs", "Neighbors of focused", callback = self.set_mark_mode) 
     218        OWGUI.appendRadioButton(ribg, self, "hubs", "Neighbours of selected", callback = self.set_mark_mode) 
    219219        ib = OWGUI.indentedBox(ribg, orientation = 0) 
    220220        self.ctrlMarkDistance = OWGUI.spin(ib, self, "markDistance", 0, 100, 1, label="Distance ", callback=(lambda h=2: self.set_mark_mode(h))) 
    221221        #self.ctrlMarkFreeze = OWGUI.button(ib, self, "&Freeze", value="graph.freezeNeighbours", toggleButton = True) 
    222         OWGUI.widgetLabel(ribg, "Mark  vertices with ...") 
     222        OWGUI.widgetLabel(ribg, "Mark nodes with ...") 
    223223        OWGUI.appendRadioButton(ribg, self, "hubs", "at least N connections", callback = self.set_mark_mode) 
    224224        OWGUI.appendRadioButton(ribg, self, "hubs", "at most N connections", callback = self.set_mark_mode) 
     
    228228        OWGUI.appendRadioButton(ribg, self, "hubs", "most connections", callback = self.set_mark_mode) 
    229229        ib = OWGUI.indentedBox(ribg) 
    230         self.ctrlMarkNumber = OWGUI.spin(ib, self, "markNumber", 0, 1000000, 1, label="Number of vertices" + ": ", callback=(lambda h=8: self.set_mark_mode(h))) 
    231         OWGUI.widgetLabel(ib, "(More vertices are marked in case of ties)") 
    232         self.markInputRadioButton = OWGUI.appendRadioButton(ribg, self, "hubs", "Mark vertices given in the input signal", callback = self.set_mark_mode) 
     230        self.ctrlMarkNumber = OWGUI.spin(ib, self, "markNumber", 0, 1000000, 1, label="Number of nodes:", callback=(lambda h=8: self.set_mark_mode(h))) 
     231        OWGUI.widgetLabel(ib, "(More nodes are marked in case of ties)") 
     232        self.markInputRadioButton = OWGUI.appendRadioButton(ribg, self, "hubs", "Mark nodes given in the input signal", callback = self.set_mark_mode) 
    233233        ib = OWGUI.indentedBox(ribg) 
    234234        self.markInput = 0 
     
    238238        ib = OWGUI.widgetBox(self.markTab, "General", orientation="vertical") 
    239239        self.checkSendMarkedNodes = 0 
    240         OWGUI.checkBox(ib, self, 'checkSendMarkedNodes', 'Send marked vertices', callback = self.send_marked_nodes, disabled=0) 
     240        OWGUI.checkBox(ib, self, 'checkSendMarkedNodes', 'Send marked nodes', callback = self.send_marked_nodes, disabled=0) 
    241241         
    242242        G = self.networkCanvas.gui 
     
    261261         
    262262        ib = OWGUI.widgetBox(self.infoTab, "General") 
    263         OWGUI.label(ib, self, "Number of vertices: %(number_of_nodes_label)i") 
     263        OWGUI.label(ib, self, "Number of nodes: %(number_of_nodes_label)i") 
    264264        OWGUI.label(ib, self, "Number of edges: %(number_of_edges_label)i") 
    265         OWGUI.label(ib, self, "Vertices per edge: %(verticesPerEdge).2f") 
    266         OWGUI.label(ib, self, "Edges per vertex: %(edgesPerVertex).2f") 
     265        OWGUI.label(ib, self, "Nodes per edge: %(verticesPerEdge).2f") 
     266        OWGUI.label(ib, self, "Edges per node: %(edgesPerVertex).2f") 
    267267        OWGUI.label(ib, self, "Diameter: %(diameter)i") 
    268268        OWGUI.label(ib, self, "Clustering Coefficient: %(clustering_coefficient).1f%%") 
     
    12281228        else: 
    12291229            self.diameter = Orange.network.nx.algorithms.distance_measures.diameter(self.graph) 
    1230         self.clustering_coefficient = Orange.network.nx.algorithms.cluster.average_clustering(undirected_graph) * 100 
     1230             
     1231        if self.graph.is_multigraph(): 
     1232            self.clustering_coefficient = -1 
     1233        else: 
     1234            self.clustering_coefficient = Orange.network.nx.algorithms.cluster.average_clustering(undirected_graph) * 100 
    12311235       
    12321236    def change_graph(self, newgraph): 
     
    13111315        self.networkCanvas.minComponentEdgeWidth = self.minComponentEdgeWidth 
    13121316        self.networkCanvas.maxComponentEdgeWidth = self.maxComponentEdgeWidth 
     1317        self.networkCanvas.set_labels_on_marked_only(self.labelsOnMarkedOnly) 
    13131318         
    13141319        self.compute_network_info() 
     
    15071512        if self.optMethod == 1: 
    15081513            self.networkCanvas.networkCurve.random() 
    1509             self.networkCanvas.update_canvas() 
    15101514        elif self.optMethod == 2: 
    15111515            self.graph_layout_fr(False) 
     
    15151519            self.graph_layout_fr_radial() 
    15161520        elif self.optMethod == 5: 
    1517 #            self.layout.circular_crossing_reduction() 
    1518             pass 
     1521            self.networkCanvas.networkCurve.circular(NetworkCurve.circular_crossing); 
    15191522        elif self.optMethod == 6: 
    1520 #            self.layout.circular_original() 
    1521             pass 
     1523            self.networkCanvas.networkCurve.circular(NetworkCurve.circular_original); 
    15221524        elif self.optMethod == 7: 
    1523 #            self.layout.circular_random() 
    1524             pass 
     1525            self.networkCanvas.networkCurve.circular(NetworkCurve.circular_random); 
    15251526        elif self.optMethod == 8: 
    15261527#            self.graph_layout_pivot_mds() 
     
    15301531#        self.networkCanvas.networkCurve.coors = self.layout.map_to_graph(self.graph)  
    15311532        #self.networkCanvas.updateCanvas() 
     1533        self.networkCanvas.networkCurve.update_properties() 
    15321534        self.networkCanvas.replot() 
    15331535        qApp.processEvents() 
     
    17141716            self.maxVertexSize = self.minVertexSize 
    17151717         
     1718        items = self.graph_base.items() 
     1719         
     1720        if items is None: 
     1721            self.networkCanvas.networkCurve.set_node_sizes({}, min_size=self.minVertexSize, max_size=self.maxVertexSize) 
     1722            return 
     1723         
    17161724        self.lastVertexSizeColumn = self.vertexSizeCombo.currentText() 
    1717          
    17181725        column = str(self.vertexSizeCombo.currentText()) 
    1719         items = self.graph_base.items() 
     1726         
    17201727        values = {} 
    17211728        if column in items.domain or (column.startswith("num of ") and column.replace("num of ", "") in items.domain): 
     
    17411748            return 
    17421749         
    1743         self.networkCanvas.fontSize = self.fontSize 
    1744 #        self.networkCanvas.drawPlotItems() 
     1750        font = self.networkCanvas.font() 
     1751        font.setPointSize(self.fontSize) 
     1752        self.networkCanvas.setFont(font)  
     1753         
    17451754                 
    17461755    def sendReport(self): 
Note: See TracChangeset for help on using the changeset viewer.