Version: 8.3.0
gui.CItems.LineItem Class Reference
Inheritance diagram for gui.CItems.LineItem:
Collaboration diagram for gui.CItems.LineItem:

Public Member Functions

def __init__
 
def setFromPoint
 
def setToPoint
 
def moveBy
 
def setArrow
 
def getObj
 
def handleDoubleClick
 
def clear
 
def selected
 

Public Attributes

 obj
 
 item
 
 fromPoint
 
 toPoint
 
 arrow
 

Detailed Description

A line between 2 points

Definition at line 110 of file CItems.py.

Constructor & Destructor Documentation

def gui.CItems.LineItem.__init__ (   self,
  obj,
  fromPoint,
  toPoint,
  canvas 
)
A line between 2 points

Definition at line 112 of file CItems.py.

113  def __init__(self,obj,fromPoint, toPoint,canvas):
114  QCanvasLine.__init__(self,canvas)
115  self.obj=obj
116  self.item=None
117  self.fromPoint=fromPoint
118  self.toPoint=toPoint
119  self.setPen(QPen(Qt.black))
120  self.setBrush(QBrush(Qt.red))
121  self.setPoints(int(fromPoint.x()),int(fromPoint.y()), int(toPoint.x()), int(toPoint.y()))
122  self.setZ(min(fromPoint.z(),toPoint.z())-1)
123  self.setVisible(True)
124  self.arrow = QCanvasPolygon(self.canvas())
125  self.arrow.setBrush(QBrush(Qt.black))
126  self.setArrow()
127  self.arrow.show()

Member Function Documentation

def gui.CItems.LineItem.clear (   self)
To remove from canvas

Definition at line 163 of file CItems.py.

References gui.CItems.LineItem.arrow, gui.CItems.LineItem.fromPoint, Solution.obj, gui.CItems.TextItem.obj, gui.CItems.PointItem.obj, gui.CItems.LineItem.obj, and gui.CItems.LineItem.toPoint.

164  def clear(self):
165  """To remove from canvas"""
166  self.setCanvas(None)
167  self.fromPoint=None
168  self.toPoint=None
169  self.obj=None
170  self.arrow.setCanvas(None)
171  self.arrow=None
def gui.CItems.LineItem.getObj (   self)
The object which contains the line

Definition at line 153 of file CItems.py.

References Solution.obj, gui.CItems.TextItem.obj, gui.CItems.PointItem.obj, and gui.CItems.LineItem.obj.

154  def getObj(self):
155  """The object which contains the line"""
return self.obj
def gui.CItems.LineItem.handleDoubleClick (   self,
  pos 
)

Definition at line 156 of file CItems.py.

157  def handleDoubleClick(self,pos):
158  #split the line
159  self.obj.splitline(self,pos)
def gui.CItems.LineItem.moveBy (   self,
  dx,
  dy 
)
Disable line move

Definition at line 134 of file CItems.py.

135  def moveBy(self,dx,dy):
136  """Disable line move"""
137  pass
def gui.CItems.LineItem.selected (   self)
The canvas item has been selected

Definition at line 172 of file CItems.py.

173  def selected(self):
174  """The canvas item has been selected"""
def gui.CItems.LineItem.setArrow (   self)

Definition at line 138 of file CItems.py.

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

139  def setArrow(self):
140  x1,y1=self.startPoint().x(),self.startPoint().y()
141  x2,y2=self.endPoint().x(),self.endPoint().y()
142  d=math.hypot(x2-x1,y2-y1)
143  sina=(y2-y1)/d
144  cosa=(x2-x1)/d
145  x=(x1+x2)/2.
146  y=(y1+y2)/2.
147  l,e=6,3
148  pa=QPointArray(3)
149  pa.setPoint(0, QPoint(x+l*cosa,y+l*sina))
150  pa.setPoint(1, QPoint(x-e*sina,y+e*cosa))
151  pa.setPoint(2, QPoint(x+e*sina,y-e*cosa))
152  self.arrow.setPoints(pa)
def gui.CItems.LineItem.setFromPoint (   self,
  x,
  y 
)

Definition at line 128 of file CItems.py.

References gui.CItems.LineItem.setArrow().

129  def setFromPoint(self,x,y):
130  self.setPoints(x,y,self.endPoint().x(),self.endPoint().y())
self.setArrow()
def gui.CItems.LineItem.setToPoint (   self,
  x,
  y 
)

Definition at line 131 of file CItems.py.

References gui.CItems.LineItem.setArrow().

132  def setToPoint(self,x,y):
133  self.setPoints(self.startPoint().x(), self.startPoint().y(),x,y)
self.setArrow()

Member Data Documentation

gui.CItems.LineItem.arrow

Definition at line 123 of file CItems.py.

Referenced by gui.CItems.LineItem.clear().

gui.CItems.LineItem.fromPoint
To remove from canvas

Definition at line 116 of file CItems.py.

Referenced by gui.CItems.LineItem.clear().

gui.CItems.LineItem.item

Definition at line 115 of file CItems.py.

gui.CItems.LineItem.obj

Definition at line 114 of file CItems.py.

Referenced by gui.CItems.LineItem.clear(), and gui.CItems.LineItem.getObj().

gui.CItems.LineItem.toPoint

Definition at line 117 of file CItems.py.

Referenced by gui.CItems.LineItem.clear().


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