Changeset 3860:0e9142a0d39d in orange
 Timestamp:
 05/16/08 12:05:54 (6 years ago)
 Branch:
 default
 Convert:
 1e865b91be20246d62185d95de85f7fe691f1395
 Location:
 orange/OrangeWidgets/Prototypes
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

orange/OrangeWidgets/Prototypes/OWNetwork.py
r3859 r3860 109 109 self.labelsOnMarkedOnly = 0 110 110 OWGUI.checkBox(self.displayTab, self, 'labelsOnMarkedOnly', 'Show labels on marked nodes only', callback = self.labelsOnMarked) 111 112 self.maxLinkSize = 10 113 self.stepsSpin = OWGUI.spin(self.displayTab, self, "maxLinkSize", 1, 50, 1, label="Max link size:", callback = self.setMaxLinkSize) 114 115 self.renderAntialiased = 1 116 OWGUI.checkBox(self.displayTab, self, 'renderAntialiased', 'Render antialiased:', callback = self.setRenderAntialiased) 111 117 112 118 OWGUI.separator(self.displayTab) … … 234 240 else: 235 241 print "One node must be selected!" 242 243 def setMaxLinkSize(self): 244 self.graph.maxEdgeSize = self.maxLinkSize 245 self.graph.setEdgesSize() 246 self.graph.replot() 247 248 def setRenderAntialiased(self): 249 self.graph.renderAntialiased = self.renderAntialiased 250 self.graph.updateData() 251 self.graph.replot() 236 252 237 253 def showWeightLabels(self): 
orange/OrangeWidgets/Prototypes/OWNetworkCanvas.py
r3859 r3860 13 13 from numpy import * 14 14 from orngScaleScatterPlotData import * 15 from OWGraphTools import UnconnectedLinesCurve16 15 17 16 class NetworkVertex(): … … 50 49 51 50 def moveSelectedVertices(self, dx, dy): 51 movedVertices = [] 52 52 for vertex in self.vertices: 53 53 if vertex.selected: 54 54 self.coors[0][vertex.index] = self.coors[0][vertex.index] + dx 55 55 self.coors[1][vertex.index] = self.coors[1][vertex.index] + dy 56 56 movedVertices.append(vertex.index) 57 57 58 self.setData(self.coors[0], self.coors[1]) 59 60 return movedVertices 58 61 59 62 def setVertexColor(self, v, color): … … 194 197 self.enableGridXB(False) 195 198 self.enableGridYL(False) 199 self.renderAntialiased = 1 196 200 197 201 self.showWeights = 0 … … 375 379 def getSelectedVertices(self): 376 380 return self.networkCurve.getSelectedVertices() 377 378 def moveVertex(self, pos):379 # ce ni nic izbrano380 if self.selectedCurve == None:381 return382 #curve = self.curve(self.vertices[self.selectedVertex]) #self.selectedCurve je key383 #newX = self.invTransform(curve.xAxis(), pos.x())384 #newY = self.invTransform(curve.yAxis(), pos.y())385 386 newX = self.invTransform(2, pos.x())387 newY = self.invTransform(0, pos.y())388 389 oldX = self.visualizer.coors[0][self.selectedVertex]390 oldY = self.visualizer.coors[1][self.selectedVertex]391 392 self.visualizer.coors[0][self.selectedVertex] = newX393 self.visualizer.coors[1][self.selectedVertex] = newY394 395 (key, neighbours) = self.vertices_old[self.selectedVertex]396 self.setCurveData(key, [newX], [newY])397 398 edgesCurve = self.curve(self.edgesKey)399 400 for e in neighbours:401 if (oldX == edgesCurve.xData[e*2]) and (oldY == edgesCurve.yData[e*2]):402 edgesCurve.xData[e*2] = newX403 edgesCurve.yData[e*2] = newY404 elif (oldX == edgesCurve.xData[e*2 + 1]) and (oldY == edgesCurve.yData[e*2 + 1]):405 edgesCurve.xData[e*2 + 1] = newX406 edgesCurve.yData[e*2 + 1] = newY407 408 self.setCurveData(self.edgesKey, edgesCurve.xData, edgesCurve.yData)409 410 if self.selectedVertex in self.markerKeys:411 mkey = self.markerKeys[self.selectedVertex]412 self.marker(mkey).setXValue(float(newX))413 self.marker(mkey).setYValue(float(newY))414 self.marker(mkey).setLabelAlignment(Qt.AlignCenter + Qt.AlignBottom)415 416 if self.selectedVertex in self.tooltipKeys:417 tkey = self.tooltipKeys[self.selectedVertex]418 self.tips.positions[tkey] = (newX, newY, 0, 0)419 381 420 382 def getNeighboursUpTo(self, ndx, dist): … … 448 410 def mouseMoveEvent(self, event): 449 411 if self.mouseCurrentlyPressed and self.state == MOVE_SELECTION: 450 dx = self.invTransform(2, event.pos().x())  self.invTransform(2, self.GMmouseStartEvent.x()) 451 dy = self.invTransform(0, event.pos().y())  self.invTransform(0, self.GMmouseStartEvent.y()) 452 self.networkCurve.moveSelectedVertices(dx, dy) 412 newX = self.invTransform(2, event.pos().x()) 413 newY = self.invTransform(0, event.pos().y()) 414 415 dx = newX  self.invTransform(2, self.GMmouseStartEvent.x()) 416 dy = newY  self.invTransform(0, self.GMmouseStartEvent.y()) 417 movedVertices = self.networkCurve.moveSelectedVertices(dx, dy) 418 419 for vertex in movedVertices: 420 if vertex in self.markerKeys: 421 mkey = self.markerKeys[vertex] 422 mkey.setValue(float(newX), float(newY)) 423 424 if vertex in self.tooltipKeys: 425 tkey = self.tooltipKeys[vertex] 426 self.tips.positions[tkey] = (newX, newY, 0, 0) 453 427 454 428 self.GMmouseStartEvent.setX(event.pos().x()) #zacetni dogodek postane trenutni … … 473 447 self.replot() 474 448 475 476 449 if self.smoothOptimization: 477 450 px = self.invTransform(2, event.x()) … … 556 529 else: 557 530 self.removeSelection() 558 559 def dist(self, s1, s2):560 return math.sqrt((s1[0]s2[0])**2 + (s1[1]s2[1])**2)561 531 562 532 def updateData(self): 533 if self.visualizer == None: 534 return 535 563 536 self.removeDrawingCurves(removeLegendItems = 0) 564 537 self.tips.removeAll() … … 588 561 self.addCurve("radius", Qt.white, Qt.green, 1, style = QwtPlotCurve.Lines, xData = x, yData = y, showFilledSymbols = False) 589 562 590 self.networkCurve.setRenderHint(QwtPlotItem.RenderAntialiased) 563 if self.renderAntialiased: 564 self.networkCurve.setRenderHint(QwtPlotItem.RenderAntialiased) 565 else: 566 self.networkCurve.setRenderHint(QwtPlotItem.RenderAntialiased, False) 567 591 568 self.networkCurve.attach(self) 592 569 self.drawLabels() 593 570 self.drawToolTips() 594 571 self.drawWeights() 595 self.zoomExtent()572 #self.zoomExtent() 596 573 597 574 def drawToolTips(self):
Note: See TracChangeset
for help on using the changeset viewer.