move LineItem to items

This commit is contained in:
Martin Baeuml
2011-05-13 14:47:34 +02:00
parent 537bad41be
commit 6a72d24f8d
2 changed files with 26 additions and 33 deletions
+26
View File
@@ -179,3 +179,29 @@ class PointItem(AnnotationGraphicsItem):
self.data_ = self.index().data(DataRole).toPyObject()
self.updatePoint()
class LineItem(AnnotationGraphicsItem):
def __init__(self, pos, endPoint, parent=None):
AnnotationGraphicsItem.__init__(self, False, parent)
self.setPos(pos)
self.endPoint_ = endPoint
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsMovable)
self.setPen(QColor('green'))
def resizeContents(self, rect):
pass
def boundingRect(self):
width = abs(self.endPoint_.x() - self.pos().x())
height = abs(self.endPoint_.y() - self.pos().y())
return QRectF(-10, -10, width, height)
def paint(self, painter, option, widget = None):
pen = self.pen()
if self.isSelected():
pen.setColor(QColor('red'))
painter.setPen(pen)
painter.drawLine(self.pos, self.endPoint_)
def itemChange(self, change, value):
return AnnotationGraphicsItem.itemChange(self, change, value)
-33
View File
@@ -1,33 +0,0 @@
from PyQt4.QtGui import *
from PyQt4.Qt import *
from annotationitem import *
class LineItem(AnnotationGraphicsItem):
def __init__(self, pos, endPoint, parent=None):
AnnotationGraphicsItem.__init__(self, False, parent)
self.setPos(pos)
self.endPoint_ = endPoint
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsMovable)
self.setPen(QColor('green'))
def resizeContents(self, rect):
pass
def boundingRect(self):
width = abs(self.endPoint_.x() - self.pos().x())
height = abs(self.endPoint_.y() - self.pos().y())
return QRectF(-10, -10, width, height)
def paint(self, painter, option, widget = None):
pen = self.pen()
if self.isSelected():
pen.setColor(QColor('red'))
painter.setPen(pen)
painter.drawLine(self.pos, self.endPoint_)
def itemChange(self, change, value):
return AnnotationGraphicsItem.itemChange(self, change, value)