Changeset 3860:0e9142a0d39d in orange


Ignore:
Timestamp:
05/16/08 12:05:54 (6 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
1e865b91be20246d62185d95de85f7fe691f1395
Message:

labels now move with vertices
removed zoom-out on set labels / tooltips
added antialiased switch
added maxEdgeSize spin

Location:
orange/OrangeWidgets/Prototypes
Files:
2 edited

Legend:

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

    r3859 r3860  
    109109        self.labelsOnMarkedOnly = 0 
    110110        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) 
    111117         
    112118        OWGUI.separator(self.displayTab) 
     
    234240        else: 
    235241            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() 
    236252     
    237253    def showWeightLabels(self): 
  • orange/OrangeWidgets/Prototypes/OWNetworkCanvas.py

    r3859 r3860  
    1313from numpy import * 
    1414from orngScaleScatterPlotData import * 
    15 from OWGraphTools import UnconnectedLinesCurve 
    1615 
    1716class NetworkVertex(): 
     
    5049 
    5150  def moveSelectedVertices(self, dx, dy): 
     51    movedVertices = [] 
    5252    for vertex in self.vertices: 
    5353      if vertex.selected: 
    5454        self.coors[0][vertex.index] = self.coors[0][vertex.index] + dx 
    5555        self.coors[1][vertex.index] = self.coors[1][vertex.index] + dy   
    56        
     56        movedVertices.append(vertex.index) 
     57         
    5758    self.setData(self.coors[0], self.coors[1]) 
     59     
     60    return movedVertices 
    5861   
    5962  def setVertexColor(self, v, color): 
     
    194197      self.enableGridXB(False) 
    195198      self.enableGridYL(False) 
     199      self.renderAntialiased = 1 
    196200       
    197201      self.showWeights = 0 
     
    375379  def getSelectedVertices(self): 
    376380    return self.networkCurve.getSelectedVertices() 
    377   
    378   def moveVertex(self, pos): 
    379         # ce ni nic izbrano 
    380       if self.selectedCurve == None: 
    381           return 
    382       #curve = self.curve(self.vertices[self.selectedVertex])  #self.selectedCurve je key 
    383       #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] = newX 
    393       self.visualizer.coors[1][self.selectedVertex] = newY 
    394        
    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] = newX 
    403               edgesCurve.yData[e*2] = newY 
    404           elif (oldX == edgesCurve.xData[e*2 + 1]) and (oldY == edgesCurve.yData[e*2 + 1]): 
    405               edgesCurve.xData[e*2 + 1] = newX 
    406               edgesCurve.yData[e*2 + 1] = newY 
    407   
    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) 
    419381   
    420382  def getNeighboursUpTo(self, ndx, dist): 
     
    448410  def mouseMoveEvent(self, event): 
    449411      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) 
    453427 
    454428          self.GMmouseStartEvent.setX(event.pos().x())  #zacetni dogodek postane trenutni 
     
    473447              self.replot() 
    474448               
    475                       
    476449      if self.smoothOptimization: 
    477450          px = self.invTransform(2, event.x()) 
     
    556529      else: 
    557530          self.removeSelection() 
    558                
    559   def dist(self, s1, s2): 
    560       return math.sqrt((s1[0]-s2[0])**2 + (s1[1]-s2[1])**2) 
    561531   
    562532  def updateData(self): 
     533      if self.visualizer == None: 
     534          return 
     535       
    563536      self.removeDrawingCurves(removeLegendItems = 0) 
    564537      self.tips.removeAll() 
     
    588561          self.addCurve("radius", Qt.white, Qt.green, 1, style = QwtPlotCurve.Lines, xData = x, yData = y, showFilledSymbols = False) 
    589562       
    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           
    591568      self.networkCurve.attach(self) 
    592569      self.drawLabels() 
    593570      self.drawToolTips() 
    594571      self.drawWeights() 
    595       self.zoomExtent() 
     572      #self.zoomExtent() 
    596573  
    597574  def drawToolTips(self): 
Note: See TracChangeset for help on using the changeset viewer.