from PyQt4 import QtGui
from PyQt4 import QtCore
import pyqtgraph as pg
import webcolors
class LineSegmentItem(pg.GraphicsObject):
def __init__(self, p1, p2,color):
pg.GraphicsObject.__init__(self)
self.p1 = p1
self.p2 = p2
self.color=color
self.generatePicture()
def generatePicture(self):
self.p.setPen(pg.mkPen(self.color))
self.
p.
drawLine(QtCore.
QPoint(self.
p1[0], self.
p1[1]), QtCore.
QPoint(self.
p2[0], self.
p2[1])) self.p.end()
def paint(self, p, *args):
p.drawPicture(0, 0, self.picture)
def boundingRect(self):
return QtCore.
QRectF(self.
picture.
boundingRect())
def modifyColor(self,color):
self.color=color
self.generatePicture()
def stretchLine(self,toSecondCoordinate):
self.p2[0]=toSecondCoordinate
self.update()
def getToSecondCoordinate(self):
return self.p2[0]
class CircleItem(pg.GraphicsObject):
def __init__(self, center, radius):
pg.GraphicsObject.__init__(self)
self.center = center
self.radius = radius
self.generatePicture()
def generatePicture(self):
p.setPen(pg.mkPen('w'))
p.drawEllipse(self.center[0], self.center[1], self.radius * 2, self.radius * 2)
p.end()
def paint(self, p, *args):
p.drawPicture(0, 0, self.picture)
def boundingRect(self):
return QtCore.
QRectF(self.
picture.
boundingRect())
class RectangleItem(pg.GraphicsObject):
def __init__(self, p1,p2,color,tickSize):
pg.GraphicsObject.__init__(self)
self.topLeft = p1
self.size = [abs(p2[0]-p1[0]),tickSize]
self.color=color
self.generatePicture()
def generatePicture(self):
p.setPen(pg.mkPen(self.color))
r,g,b=self.color
p.
setBrush(QtGui.
QColor(r,g,b
)) tl
= QtCore.
QPointF(self.
topLeft[0], self.
topLeft[1]) size
= QtCore.
QSizeF(self.
size[0], self.
size[1]) p.
drawRect(QtCore.
QRectF(tl, size
)) p.end()
def paint(self, p, *args):
p.drawPicture(0, 0, self.picture)
def boundingRect(self):
return QtCore.
QRectF(self.
picture.
boundingRect())
def modifyColor(self,color):
self.color=color
self.generatePicture()
def stretchLine(self,toSecondCoordinate):
self.size[0]=toSecondCoordinate-self.topLeft[0]
self.update()
def getToSecondCoordinate(self):
return self.size[0]
from PyQt4 import QtGui
from PyQt4 import QtCore
import pyqtgraph as pg
import webcolors
class LineSegmentItem(pg.GraphicsObject):
def __init__(self, p1, p2,color):
pg.GraphicsObject.__init__(self)
self.p1 = p1
self.p2 = p2
self.color=color
self.generatePicture()
def generatePicture(self):
self.picture = QtGui.QPicture()
self.p = QtGui.QPainter(self.picture)
self.p.setPen(pg.mkPen(self.color))
self.p.drawLine(QtCore.QPoint(self.p1[0], self.p1[1]), QtCore.QPoint(self.p2[0], self.p2[1]))
self.p.end()
def paint(self, p, *args):
p.drawPicture(0, 0, self.picture)
def boundingRect(self):
return QtCore.QRectF(self.picture.boundingRect())
def modifyColor(self,color):
self.color=color
self.generatePicture()
def stretchLine(self,toSecondCoordinate):
self.p2[0]=toSecondCoordinate
self.update()
def getToSecondCoordinate(self):
return self.p2[0]
class CircleItem(pg.GraphicsObject):
def __init__(self, center, radius):
pg.GraphicsObject.__init__(self)
self.center = center
self.radius = radius
self.generatePicture()
def generatePicture(self):
self.picture = QtGui.QPicture()
p = QtGui.QPainter(self.picture)
p.setPen(pg.mkPen('w'))
p.drawEllipse(self.center[0], self.center[1], self.radius * 2, self.radius * 2)
p.end()
def paint(self, p, *args):
p.drawPicture(0, 0, self.picture)
def boundingRect(self):
return QtCore.QRectF(self.picture.boundingRect())
class RectangleItem(pg.GraphicsObject):
def __init__(self, p1,p2,color,tickSize):
pg.GraphicsObject.__init__(self)
self.topLeft = p1
self.size = [abs(p2[0]-p1[0]),tickSize]
self.color=color
self.generatePicture()
def generatePicture(self):
self.picture = QtGui.QPicture()
p = QtGui.QPainter(self.picture)
p.setPen(pg.mkPen(self.color))
r,g,b=self.color
p.setBrush(QtGui.QColor(r,g,b))
tl = QtCore.QPointF(self.topLeft[0], self.topLeft[1])
size = QtCore.QSizeF(self.size[0], self.size[1])
p.drawRect(QtCore.QRectF(tl, size))
p.end()
def paint(self, p, *args):
p.drawPicture(0, 0, self.picture)
def boundingRect(self):
return QtCore.QRectF(self.picture.boundingRect())
def modifyColor(self,color):
self.color=color
self.generatePicture()
def stretchLine(self,toSecondCoordinate):
self.size[0]=toSecondCoordinate-self.topLeft[0]
self.update()
def getToSecondCoordinate(self):
return self.size[0]
To copy to clipboard, switch view to plain text mode
Bookmarks