Version: 8.3.0
gui.GraphViewer.LinkItem Class Reference
Inheritance diagram for gui.GraphViewer.LinkItem:
Collaboration diagram for gui.GraphViewer.LinkItem:

Public Member Functions

def __init__
 
def setFromPoint
 
def setToPoint
 
def moveBy
 
def setArrow
 
def popup
 
def delete
 
def tooltip
 

Public Attributes

 arrow
 

Detailed Description

Definition at line 224 of file GraphViewer.py.

Constructor & Destructor Documentation

def gui.GraphViewer.LinkItem.__init__ (   self,
  fromPort,
  toPort,
  canvas 
)

Definition at line 225 of file GraphViewer.py.

226  def __init__(self,fromPort, toPort,canvas):
227  QCanvasLine.__init__(self,canvas)
228  self.setPen(QPen(Qt.black))
229  self.setBrush(QBrush(Qt.red))
230  fromPort.addOutLink(self)
231  toPort.addInLink(self)
232  self.setPoints(int(fromPort.x()),int(fromPort.y()), int(toPort.x()), int(toPort.y()))
233  self.setZ(min(fromPort.z(),toPort.z())-1)
234  self.setVisible(True)
235  self.arrow = QCanvasPolygon(self.canvas())
236  self.arrow.setBrush(QBrush(Qt.black))
237  self.setArrow()
238  self.arrow.show()

Member Function Documentation

def gui.GraphViewer.LinkItem.delete (   self)

Definition at line 272 of file GraphViewer.py.

Referenced by gui.GraphViewer.LinkItem.popup().

273  def delete(self):
274  print "delete link"
def gui.GraphViewer.LinkItem.moveBy (   self,
  dx,
  dy 
)

Definition at line 247 of file GraphViewer.py.

248  def moveBy(self,dx,dy):
249  pass
def gui.GraphViewer.LinkItem.popup (   self,
  canvasView 
)

Definition at line 264 of file GraphViewer.py.

References gui.CItems.LinkItem.delete(), and gui.GraphViewer.LinkItem.delete().

265  def popup(self,canvasView):
266  menu=QPopupMenu()
267  caption = QLabel( "<font color=darkblue><u><b>Node Menu</b></u></font>",menu )
268  caption.setAlignment( Qt.AlignCenter )
269  menu.insertItem( caption )
270  menu.insertItem("Delete", self.delete)
271  return menu
def gui.GraphViewer.LinkItem.setArrow (   self)

Definition at line 250 of file GraphViewer.py.

Referenced by gui.GraphViewer.LinkItem.setFromPoint(), and gui.GraphViewer.LinkItem.setToPoint().

251  def setArrow(self):
252  x1,y1=self.startPoint().x(),self.startPoint().y()
253  x2,y2=self.endPoint().x(),self.endPoint().y()
254  d=math.hypot(x2-x1,y2-y1)
255  sina=(y2-y1)/d
256  cosa=(x2-x1)/d
257  x=(x1+x2)/2.
258  y=(y1+y2)/2.
259  pa=QPointArray(3)
260  pa.setPoint(0, QPoint(x+10*cosa,y+10*sina))
261  pa.setPoint(1, QPoint(x-5*sina,y+5*cosa))
262  pa.setPoint(2, QPoint(x+5*sina,y-5*cosa))
263  self.arrow.setPoints(pa)
def gui.GraphViewer.LinkItem.setFromPoint (   self,
  x,
  y 
)

Definition at line 239 of file GraphViewer.py.

References gui.CItems.LineItem.setArrow(), and gui.GraphViewer.LinkItem.setArrow().

240  def setFromPoint(self,x,y):
241  self.setPoints(x,y,self.endPoint().x(),self.endPoint().y())
242  self.setArrow()
def gui.GraphViewer.LinkItem.setToPoint (   self,
  x,
  y 
)

Definition at line 243 of file GraphViewer.py.

References gui.CItems.LineItem.setArrow(), and gui.GraphViewer.LinkItem.setArrow().

244  def setToPoint(self,x,y):
245  self.setPoints(self.startPoint().x(), self.startPoint().y(),x,y)
246  self.setArrow()
def gui.GraphViewer.LinkItem.tooltip (   self,
  view,
  pos 
)

Definition at line 275 of file GraphViewer.py.

276  def tooltip(self,view,pos):
277  r = QRect(pos.x(), pos.y(), pos.x()+10, pos.y()+10)
278  s = QString( "link: %d,%d" % (r.center().x(), r.center().y()) )
279  view.tip( r, s )

Member Data Documentation

gui.GraphViewer.LinkItem.arrow

Definition at line 234 of file GraphViewer.py.


The documentation for this class was generated from the following file: