Esempio n. 1
0
    def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.xMap = QwtScaleMap()
        self.xMap.setScaleInterval(-0.5, 10.5)
        self.yMap = QwtScaleMap()
        self.yMap.setScaleInterval(-1.1, 1.1)

        # frame style
        self.setFrameStyle(QFrame.Box | QFrame.Raised)
        self.setLineWidth(2)
        self.setMidLineWidth(3)

        # calculate values
        self.x = np.arange(0, 10.0, 10.0/27)
        self.y = np.sin(self.x)*np.cos(2*self.x)

        # make curves with different styles
        self.curves = []
        self.titles = []

        # curve 2
        self.titles.append('Style: Lines, Symbol: None')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkBlue))
        curve.setStyle(QwtPlotCurve.Lines)
        self.curves.append(curve)

        # attach data, using Numeric
        for curve in self.curves:
            curve.setData(self.x, self.y)
Esempio n. 2
0
    def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.xMap = QwtScaleMap()
        self.xMap.setScaleInterval(-0.5, 10.5)
        self.yMap = QwtScaleMap()
        self.yMap.setScaleInterval(-1.1, 1.1)

        # frame style
        self.setFrameStyle(QFrame.Box | QFrame.Raised)
        self.setLineWidth(2)
        self.setMidLineWidth(3)

        # calculate values
        self.x = np.arange(0, 10.0, 10.0 / 27)
        self.y = np.sin(self.x) * np.cos(2 * self.x)

        # make curves with different styles
        self.curves = []
        self.titles = []
        # curve 1
        self.titles.append('Style: Sticks, Symbol: Ellipse')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.red))
        curve.setStyle(QwtPlotCurve.Sticks)
        curve.setSymbol(
            QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.yellow), QPen(Qt.blue),
                      QSize(5, 5)))
        self.curves.append(curve)
        # curve 2
        self.titles.append('Style: Lines, Symbol: None')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkBlue))
        curve.setStyle(QwtPlotCurve.Lines)
        self.curves.append(curve)
        # curve 3
        self.titles.append('Style: Lines, Symbol: None, Antialiased')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkBlue))
        curve.setStyle(QwtPlotCurve.Lines)
        curve.setRenderHint(QwtPlotItem.RenderAntialiased)
        self.curves.append(curve)
        # curve 4
        self.titles.append('Style: Steps, Symbol: None')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkCyan))
        curve.setStyle(QwtPlotCurve.Steps)
        self.curves.append(curve)
        # curve 5
        self.titles.append('Style: NoCurve, Symbol: XCross')
        curve = QwtPlotCurve()
        curve.setStyle(QwtPlotCurve.NoCurve)
        curve.setSymbol(
            QwtSymbol(QwtSymbol.XCross, QBrush(), QPen(Qt.darkMagenta),
                      QSize(5, 5)))
        self.curves.append(curve)

        # attach data, using Numeric
        for curve in self.curves:
            curve.setData(self.x, self.y)
Esempio n. 3
0
    def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.setFrameStyle(QFrame.Box | QFrame.Raised)
        self.setLineWidth(2)
        self.setMidLineWidth(3)

        p = QPalette()
        p.setColor(self.backgroundRole(), QColor(30, 30, 50))
        self.setPalette(p)
        # make curves and maps
        self.tuples = []
        # curve 1
        curve = QwtPlotCurve()
        curve.setPen(QPen(QColor(150, 150, 200), 2))
        curve.setStyle(QwtPlotCurve.Lines)
        curve.setSymbol(QwtSymbol(QwtSymbol.XCross,
                                      QBrush(),
                                      QPen(Qt.yellow, 2),
                                      QSize(7, 7)))
        self.tuples.append((curve,
                            QwtScaleMap(0, 100, -1.5, 1.5),
                            QwtScaleMap(0, 100, 0.0, 2*np.pi)))
        # curve 2
        curve = QwtPlotCurve()
        curve.setPen(QPen(QColor(200, 150, 50),
                                1,
                                Qt.DashDotDotLine))
        curve.setStyle(QwtPlotCurve.Sticks)
        curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse,
                                      QBrush(Qt.blue),
                                      QPen(Qt.yellow),
                                      QSize(5, 5)))
        self.tuples.append((curve,
                            QwtScaleMap(0, 100, 0.0, 2*np.pi),
                            QwtScaleMap(0, 100, -3.0, 1.1)))
        # curve 3
        curve = QwtPlotCurve()
        curve.setPen(QPen(QColor(100, 200, 150)))
        curve.setStyle(QwtPlotCurve.Lines)
        self.tuples.append((curve,
                            QwtScaleMap(0, 100, -1.1, 3.0),
                            QwtScaleMap(0, 100, -1.1, 3.0)))
        # curve 4
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.red))
        curve.setStyle(QwtPlotCurve.Lines)
        self.tuples.append((curve,
                            QwtScaleMap(0, 100, -5.0, 1.1),
                            QwtScaleMap(0, 100, -1.1, 5.0)))
        # data
        self.phase = 0.0
        self.base = np.arange(0.0, 2.01*np.pi, 2*np.pi/(USize-1))
        self.uval = np.cos(self.base)
        self.vval = np.sin(self.base)
        self.uval[1::2] *= 0.5
        self.vval[1::2] *= 0.5
        self.newValues()
        # start timer
        self.tid = self.startTimer(250)
Esempio n. 4
0
 def event(self, event):
     if event.type() == QEvent.PolishRequest:
         if self.testPaintAttribute(self.Opaque):
             self.setAttribute(Qt.WA_OpaquePaintEvent, True)
     if event.type() in (QEvent.PolishRequest, QEvent.StyleChange):
         self.updateStyleSheetInfo()
     return QFrame.event(self, event)
Esempio n. 5
0
 def drawBorder(self, painter):
     if self.__data.borderRadius > 0:
         if self.frameWidth() > 0:
             QwtPainter.drawRoundedFrame(painter, QRectF(self.frameRect()),
                                         self.__data.borderRadius,
                                         self.__data.borderRadius,
                                         self.palette(), self.frameWidth(),
                                         self.frameStyle())
     else:
         if QT_VERSION >= 0x040500:
             if PYQT5:
                 from qwt.qt.QtGui import QStyleOptionFrame
             else:
                 from qwt.qt.QtGui import QStyleOptionFrameV3 as\
                                          QStyleOptionFrame
             opt = QStyleOptionFrame()
             opt.initFrom(self)
             frameShape = self.frameStyle() & QFrame.Shape_Mask
             frameShadow = self.frameStyle() & QFrame.Shadow_Mask
             opt.frameShape = QFrame.Shape(int(opt.frameShape) | frameShape)
             if frameShape in (QFrame.Box, QFrame.HLine, QFrame.VLine,
                               QFrame.StyledPanel, QFrame.Panel):
                 opt.lineWidth = self.lineWidth()
                 opt.midLineWidth = self.midLineWidth()
             else:
                 opt.lineWidth = self.frameWidth()
             if frameShadow == self.Sunken:
                 opt.state |= QStyle.State_Sunken
             elif frameShadow == self.Raised:
                 opt.state |= QStyle.State_Raised
             self.style().drawControl(QStyle.CE_ShapedFrame, opt, painter,
                                      self)
         else:
             self.drawFrame(painter)
Esempio n. 6
0
 def event(self, event):
     if event.type() == QEvent.PolishRequest:
         if self.testPaintAttribute(self.Opaque):
             self.setAttribute(Qt.WA_OpaquePaintEvent, True)
     if event.type() in (QEvent.PolishRequest, QEvent.StyleChange):
         self.updateStyleSheetInfo()
     return QFrame.event(self, event)
Esempio n. 7
0
 def eventFilter(self, obj, event):
     if obj is self.__data.canvas:
         if event.type() == QEvent.Resize:
             self.updateCanvasMargins()
         elif event.type() == 178:#QEvent.ContentsRectChange:
             self.updateLayout()
     return QFrame.eventFilter(self, obj, event)
Esempio n. 8
0
 def event(self, event):
     ok = QFrame.event(self, event)
     if event.type() == QEvent.LayoutRequest:
         self.updateLayout()
     elif event.type() == QEvent.PolishRequest:
         self.replot()
     return ok
Esempio n. 9
0
 def resizeEvent(self, event):
     QFrame.resizeEvent(self, event)
     self.updateStyleSheetInfo()
Esempio n. 10
0
 def paintEvent(self, event):
     QFrame.paintEvent(self, event)
     painter = QPainter(self)
     painter.setClipRect(self.contentsRect())
     self.drawContents(painter)
Esempio n. 11
0
 def resizeEvent(self, event):
     QFrame.resizeEvent(self, event)
     self.updateStyleSheetInfo()
Esempio n. 12
0
 def __init__(self, parent):
     QFrame.__init__(self, parent)
Esempio n. 13
0
 def paintEvent(self, event):
     QFrame.paintEvent(self,event)
     painter = QPainter(self)
     painter.setClipRect(self.contentsRect())
     self.drawContents(painter)
Esempio n. 14
0
    def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.xMap = QwtScaleMap()
        self.xMap.setScaleInterval(-0.5, 10.5)
        self.yMap = QwtScaleMap()
        self.yMap.setScaleInterval(-1.1, 1.1)

        # frame style
        self.setFrameStyle(QFrame.Box | QFrame.Raised)
        self.setLineWidth(2)
        self.setMidLineWidth(3)

        # calculate values
        self.x = np.arange(0, 10.0, 10.0/27)
        self.y = np.sin(self.x)*np.cos(2*self.x)
        
        # make curves with different styles
        self.curves = []
        self.titles = []
        # curve 1
        self.titles.append('Style: Sticks, Symbol: Ellipse')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.red))
        curve.setStyle(QwtPlotCurve.Sticks)
        curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse,
                                      QBrush(Qt.yellow),
                                      QPen(Qt.blue),
                                      QSize(5, 5)))
        self.curves.append(curve)
        # curve 2
        self.titles.append('Style: Lines, Symbol: None')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkBlue))
        curve.setStyle(QwtPlotCurve.Lines)
        self.curves.append(curve)
        # curve 3
        self.titles.append('Style: Lines, Symbol: None, Antialiased')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkBlue))
        curve.setStyle(QwtPlotCurve.Lines)
        curve.setRenderHint(QwtPlotItem.RenderAntialiased)
        self.curves.append(curve)
        # curve 4
        self.titles.append('Style: Steps, Symbol: None')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkCyan))
        curve.setStyle(QwtPlotCurve.Steps)
        self.curves.append(curve)        
        # curve 5
        self.titles.append('Style: NoCurve, Symbol: XCross')
        curve = QwtPlotCurve()
        curve.setStyle(QwtPlotCurve.NoCurve)
        curve.setSymbol(QwtSymbol(QwtSymbol.XCross,
                                      QBrush(),
                                      QPen(Qt.darkMagenta),
                                      QSize(5, 5)))
        self.curves.append(curve)

        # attach data, using Numeric
        for curve in self.curves:
            curve.setData(self.x, self.y)
Esempio n. 15
0
 def resizeEvent(self, e):
     QFrame.resizeEvent(self, e)
     self.updateLayout()
Esempio n. 16
0
    def __init__(self, *args):
        if len(args) == 0:
            title, parent = "", None
        elif len(args) == 1:
            if isinstance(args[0], QWidget) or args[0] is None:
                title = ""
                parent, = args
            else:
                title, = args
                parent = None
        elif len(args) == 2:
            title, parent = args
        else:
            raise TypeError("%s() takes 0, 1 or 2 argument(s) (%s given)"\
                            % (self.__class__.__name__, len(args)))
        QwtPlotDict.__init__(self)
        QFrame.__init__(self, parent)
        
        self.__layout_state = None
        
        self.__data = QwtPlot_PrivateData()
        from qwt.plot_layout import QwtPlotLayout
        self.__data.layout = QwtPlotLayout()
        self.__data.autoReplot = False
                
        self.setAutoReplot(True)
#        self.setPlotLayout(self.__data.layout)
        
        # title
        self.__data.titleLabel = QwtTextLabel(self)
        self.__data.titleLabel.setObjectName("QwtPlotTitle")
        self.__data.titleLabel.setFont(QFont(self.fontInfo().family(), 14,
                                             QFont.Bold))
        text = QwtText(title)
        text.setRenderFlags(Qt.AlignCenter|Qt.TextWordWrap)
        self.__data.titleLabel.setText(text)
        
        # footer
        self.__data.footerLabel = QwtTextLabel(self)
        self.__data.footerLabel.setObjectName("QwtPlotFooter")
        footer = QwtText()
        footer.setRenderFlags(Qt.AlignCenter|Qt.TextWordWrap)
        self.__data.footerLabel.setText(footer)
        
        # legend
        self.__data.legend = None
        
        # axis
        self.__axisData = []
        self.initAxesData()
        
        # canvas
        self.__data.canvas = QwtPlotCanvas(self)
        self.__data.canvas.setObjectName("QwtPlotCanvas")
        self.__data.canvas.installEventFilter(self)
        
        self.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)
        
        self.resize(200, 200)
        
        focusChain = [self, self.__data.titleLabel, self.axisWidget(self.xTop),
                      self.axisWidget(self.yLeft), self.__data.canvas,
                      self.axisWidget(self.yRight),
                      self.axisWidget(self.xBottom), self.__data.footerLabel]
        
        for idx in range(len(focusChain)-1):
            qwtSetTabOrder(focusChain[idx], focusChain[idx+1], False)
        
        qwtEnableLegendItems(self, True)