Changeset 8449:2d741461ea38 in orange
 Timestamp:
 07/25/11 15:09:26 (3 years ago)
 Branch:
 default
 Convert:
 71a0bec0db385e426e90e7c41b2b39d037cc9758
 Location:
 orange/OrangeWidgets/Prototypes
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

orange/OrangeWidgets/Prototypes/OWNxCanvasQt.py
r8425 r8449 44 44 self.coors[1][selected][1] = self.coors[1][selected] + dy 45 45 46 self.update Properties()46 self.update_properties() 47 47 return selected 48 48 … … 270 270 271 271 self.setFocusPolicy(Qt.StrongFocus) 272 273 def update_canvas(self): 274 self.networkCurve.update_properties() 275 #rect = self.networkCurve.dataRect() 276 #self.set_axis_scale(xBottom, min, max) 277 #self.set_axis_scale(yLeft, min, max) 278 self.set_dirty() 279 self.replot() 272 280 273 281 def getSelection(self): … … 708 716 # span_weights = max_weight  min_weight 709 717 # 710 # self.networkCurve.update Properties()718 # self.networkCurve.update_properties() 711 719 712 720 if self.insideview == 1: … … 938 946 return 939 947 940 colorIndices, colorIndex, minValue, maxValue = self.getColorIndeces(self.links, attribute, self.discEdgePalette)941 942 for index in range(len(self.networkCurve.edges)):943 if colorIndex != None:944 links_index = self.networkCurve.edges[index].links_index945 if links_index == None:946 continue947 948 if self.links.domain[colorIndex].varType == orange.VarTypes.Continuous:949 newColor = self.discEdgePalette[0]950 if str(self.links[links_index][colorIndex]) != "?":951 if maxValue == minValue:952 newColor = self.discEdgePalette[0]953 else:954 value = (float(self.links[links_index][colorIndex].value)  minValue) / (maxValue  minValue)955 newColor = self.contEdgePalette[value]956 957 self.networkCurve.set_edge_color(index, newColor)958 959 elif self.links.domain[colorIndex].varType == orange.VarTypes.Discrete:960 newColor = self.discEdgePalette[colorIndices[self.links[links_index][colorIndex].value]]961 if self.links[links_index][colorIndex].value == "0":962 self.networkCurve.set_edge_color(index, newColor, nocolor=1)963 else:964 self.networkCurve.set_edge_color(index, newColor)965 966 else:967 newColor = self.discEdgePalette[0]968 self.networkCurve.set_edge_color(index, newColor)969 970 self.replot()948 # colorIndices, colorIndex, minValue, maxValue = self.getColorIndeces(self.links, attribute, self.discEdgePalette) 949 # 950 # for index in range(len(self.networkCurve.edges)): 951 # if colorIndex != None: 952 # links_index = self.networkCurve.edges[index].links_index 953 # if links_index == None: 954 # continue 955 # 956 # if self.links.domain[colorIndex].varType == orange.VarTypes.Continuous: 957 # newColor = self.discEdgePalette[0] 958 # if str(self.links[links_index][colorIndex]) != "?": 959 # if maxValue == minValue: 960 # newColor = self.discEdgePalette[0] 961 # else: 962 # value = (float(self.links[links_index][colorIndex].value)  minValue) / (maxValue  minValue) 963 # newColor = self.contEdgePalette[value] 964 # 965 # self.networkCurve.set_edge_color(index, newColor) 966 # 967 # elif self.links.domain[colorIndex].varType == orange.VarTypes.Discrete: 968 # newColor = self.discEdgePalette[colorIndices[self.links[links_index][colorIndex].value]] 969 # if self.links[links_index][colorIndex].value == "0": 970 # self.networkCurve.set_edge_color(index, newColor, nocolor=1) 971 # else: 972 # self.networkCurve.set_edge_color(index, newColor) 973 # 974 # else: 975 # newColor = self.discEdgePalette[0] 976 # self.networkCurve.set_edge_color(index, newColor) 977 # 978 # self.replot() 971 979 972 980 def set_node_color(self, attribute, nodes=None): … … 1135 1143 #add nodes 1136 1144 #self.vertices_old = [(None, []) for v in self.graph] 1137 vertices = dict((v, NodeItem(v)) for v in self.graph) 1138 1139 self.networkCurve.nodes.clear() 1140 self.networkCurve.nodes.update(vertices) 1145 vertices = dict((v, NodeItem(v, random.random(), random.random(), parent=self.networkCurve)) for v in self.graph) 1146 self.networkCurve.set_nodes(vertices) 1141 1147 1142 1148 #build edge index … … 1162 1168 if self.graph.is_directed(): 1163 1169 edges = [EdgeItem(vertices[i], vertices[j], 1164 graph[i][j].get('weight', 1), 0, 1, links_index, label ) for \1170 graph[i][j].get('weight', 1), 0, 1, links_index, label, parent=self.networkCurve) for \ 1165 1171 ((i, j), links_index, label) in zip(self.graph.edges(), \ 1166 1172 links_indices, labels)] … … 1169 1175 graph[i][j].get('weight', 1), links_index, label) for \ 1170 1176 ((i, j), links_index, label) in zip(self.graph.edges(), \ 1171 links_indices, labels )]1177 links_indices, labels, parent=self.networkCurve)] 1172 1178 elif self.graph.is_directed(): 1173 1179 edges = [EdgeItem(vertices[i], vertices[j], 1174 graph[i][j].get('weight', 1), 0, 1 ) for (i, j) in self.graph.edges()]1180 graph[i][j].get('weight', 1), 0, 1, parent=self.networkCurve) for (i, j) in self.graph.edges()] 1175 1181 else: 1176 1182 edges = [EdgeItem(vertices[i], vertices[j], 1177 graph[i][j].get('weight', 1) ) for (i, j) in self.graph.edges()]1178 1179 self.networkCurve. edges = edges1180 self.networkCurve.update Properties()1183 graph[i][j].get('weight', 1), parent=self.networkCurve) for (i, j) in self.graph.edges()] 1184 1185 self.networkCurve.set_edges(edges) 1186 self.networkCurve.update_properties() 1181 1187 self.replot() 1182 1188 # … … 1292 1298 1293 1299 def setEdgesSize(self): 1294 if self.maxEdgeWeight > self.minEdgeWeight:1295 #print 'maxEdgeSize',self.maxEdgeSize1296 #print 'maxEdgeWeight',self.maxEdgeWeight1297 #print 'minEdgeWeight',self.minEdgeWeight1298 k = (self.maxEdgeSize  1) / (self.maxEdgeWeight  self.minEdgeWeight)1299 for edge in self.networkCurve.edges:1300 if edge.weight == None:1301 size = 11302 edge.pen = QPen(edge.pen.color(), size)1303 edge.pen.setCapStyle(Qt.RoundCap)1304 else:1305 if self.invertEdgeSize:1306 size = (self.maxEdgeWeight  edge.weight  self.minEdgeWeight) * k + 11307 else:1308 size = (edge.weight  self.minEdgeWeight) * k + 11309 edge.pen = QPen(edge.pen.color(), size)1310 edge.pen.setCapStyle(Qt.RoundCap)1311 else:1312 for edge in self.networkCurve.edges:1313 edge.pen = QPen(edge.pen.color(), 1)1314 edge.pen.setCapStyle(Qt.RoundCap)1315 1300 # if self.maxEdgeWeight > self.minEdgeWeight: 1301 # #print 'maxEdgeSize',self.maxEdgeSize 1302 # #print 'maxEdgeWeight',self.maxEdgeWeight 1303 # #print 'minEdgeWeight',self.minEdgeWeight 1304 # k = (self.maxEdgeSize  1) / (self.maxEdgeWeight  self.minEdgeWeight) 1305 # for edge in self.networkCurve.edges: 1306 # if edge.weight == None: 1307 # size = 1 1308 # edge.pen = QPen(edge.pen.color(), size) 1309 # edge.pen.setCapStyle(Qt.RoundCap) 1310 # else: 1311 # if self.invertEdgeSize: 1312 # size = (self.maxEdgeWeight  edge.weight  self.minEdgeWeight) * k + 1 1313 # else: 1314 # size = (edge.weight  self.minEdgeWeight) * k + 1 1315 # edge.pen = QPen(edge.pen.color(), size) 1316 # edge.pen.setCapStyle(Qt.RoundCap) 1317 # else: 1318 # for edge in self.networkCurve.edges: 1319 # edge.pen = QPen(edge.pen.color(), 1) 1320 # edge.pen.setCapStyle(Qt.RoundCap) 1321 pass 1316 1322 def setVerticesSize(self, column=None, inverted=0): 1317 1323 if self.layout is None or self.graph is None or self.items is None: 
orange/OrangeWidgets/Prototypes/OWNxExplorerQt.py
r8420 r8449 1264 1264 nodes = self.graph.number_of_nodes() 1265 1265 t = k * nodes * nodes 1266 self.frSteps = int(5.0 / t)1266 self.frSteps = 10 #int(5.0 / t) 1267 1267 if self.frSteps < 1: self.frSteps = 1; 1268 1268 if self.frSteps > 3000: self.frSteps = 3000; … … 1375 1375 nodes = self.graph.number_of_nodes() 1376 1376 t = k * nodes * nodes 1377 self.frSteps = int(5.0 / t)1377 self.frSteps = 10 #int(5.0 / t) 1378 1378 if self.frSteps < 1: self.frSteps = 1; 1379 1379 if self.frSteps > 3000: self.frSteps = 3000; … … 1560 1560 1561 1561 if self.optMethod == 1: 1562 self.layout.random() 1562 self.networkCanvas.networkCurve.random() 1563 self.networkCanvas.update_canvas() 1563 1564 elif self.optMethod == 2: 1564 1565 self.graph_layout_fr(False) … … 1627 1628 qApp.processEvents() 1628 1629 self.stopOptimization = 0 1629 cooling = math.exp(math.log(10.0/10000.0) / self.frSteps)1630 self.networkCanvas.networkCurve.fr(10, False, 1000, cooling)1631 self.networkCanvas.networkCurve. updateProperties()1632 self.networkCanvas. replot()1630 temperature = 1000 1631 cooling = math.exp(math.log(1. / temperature) / self.frSteps) 1632 self.networkCanvas.networkCurve.fr(self.frSteps, False, temperature, cooling) 1633 self.networkCanvas.update_canvas() 1633 1634 # tolerance = 5 1634 1635 # initTemp = 1000
Note: See TracChangeset
for help on using the changeset viewer.