Ejemplo n.º 1
0
 def layoutLegend(self, options, rect):
     """
     Find the geometry for the legend
     
     :param options: Options how to layout the legend
     :param QRectF rect: Rectangle where to place the legend
     :return: Geometry for the legend
     """
     hint = self.__data.layoutData.legend.hint
     if self.__data.legendPos in (QwtPlot.LeftLegend, QwtPlot.RightLegend):
         dim = min([hint.width(), int(rect.width()*self.__data.legendRatio)])
         if not (options & self.IgnoreScrollbars):
             if hint.height() > rect.height():
                 dim += self.__data.layoutData.legend.hScrollExtent
     else:
         dim = min([hint.height(), int(rect.height()*self.__data.legendRatio)])
         dim = max([dim, self.__data.layoutData.legend.vScrollExtent])
     legendRect = QRectF(rect)
     if self.__data.legendPos == QwtPlot.LeftLegend:
         legendRect.setWidth(dim)
     elif self.__data.legendPos == QwtPlot.RightLegend:
         legendRect.setX(rect.right()-dim)
         legendRect.setWidth(dim)
     elif self.__data.legendPos == QwtPlot.TopLegend:
         legendRect.setHeight(dim)
     elif self.__data.legendPos == QwtPlot.BottomLegend:
         legendRect.setY(rect.bottom()-dim)
         legendRect.setHeight(dim)
     return legendRect
Ejemplo n.º 2
0
 def layoutLegend(self, options, rect):
     hint = self.__data.layoutData.legend.hint
     if self.__data.legendPos in (QwtPlot.LeftLegend, QwtPlot.RightLegend):
         dim = min(
             [hint.width(),
              int(rect.width() * self.__data.legendRatio)])
         if not (options & self.IgnoreScrollbars):
             if hint.height() > rect.height():
                 dim += self.__data.layoutData.legend.hScrollExtent
     else:
         dim = min(
             [hint.height(),
              int(rect.height() * self.__data.legendRatio)])
         dim = max([dim, self.__data.layoutData.legend.vScrollExtent])
     legendRect = QRectF(rect)
     if self.__data.legendPos == QwtPlot.LeftLegend:
         legendRect.setWidth(dim)
     elif self.__data.legendPos == QwtPlot.RightLegend:
         legendRect.setX(rect.right() - dim)
         legendRect.setWidth(dim)
     elif self.__data.legendPos == QwtPlot.TopLegend:
         legendRect.setHeight(dim)
     elif self.__data.legendPos == QwtPlot.BottomLegend:
         legendRect.setY(rect.bottom() - dim)
         legendRect.setHeight(dim)
     return legendRect
Ejemplo n.º 3
0
    def renderTo(self, plot, dest):
        """
        Render a plot to a file

        Supported formats are:

          - pdf: Portable Document Format PDF
          - ps: Postcript
          - svg: Scalable Vector Graphics SVG
          - all image formats supported by Qt, see QImageWriter.supportedImageFormats()

        Scalable vector graphic formats like PDF or SVG are superior to
        raster graphics formats.

        :param qwt.plot.QwtPlot plot: Plot widget
        :param str fileName: Path of the file, where the document will be stored
        :param str format: Format for the document
        :param QSizeF sizeMM: Size for the document in millimeters.
        :param int resolution: Resolution in dots per Inch (dpi)
        
        .. seealso::
        
            :py:meth:`renderTo()`, :py:meth:`render()`, 
            :py:meth:`qwt.painter.QwtPainter.setRoundingAlignment()`
        """
        if isinstance(dest, QPaintDevice):
            w = dest.width()
            h = dest.height()
            rect = QRectF(0, 0, w, h)
        elif isinstance(dest, QPrinter):
            w = dest.width()
            h = dest.height()
            rect = QRectF(0, 0, w, h)
            aspect = rect.width() / rect.height()
            if aspect < 1.:
                rect.setHeight(aspect * rect.width())
        elif isinstance(dest, QSvgGenerator):
            rect = dest.viewBoxF()
            if rect.isEmpty():
                rect.setRect(0, 0, dest.width(), dest.height())
            if rect.isEmpty():
                rect.setRect(0, 0, 800, 600)
        p = QPainter(dest)
        self.render(plot, p, rect)
Ejemplo n.º 4
0
    def renderTo(self, plot, dest):
        """
        Render a plot to a file

        Supported formats are:

          - pdf: Portable Document Format PDF
          - ps: Postcript
          - svg: Scalable Vector Graphics SVG
          - all image formats supported by Qt, see QImageWriter.supportedImageFormats()

        Scalable vector graphic formats like PDF or SVG are superior to
        raster graphics formats.

        :param qwt.plot.QwtPlot plot: Plot widget
        :param str fileName: Path of the file, where the document will be stored
        :param str format: Format for the document
        :param QSizeF sizeMM: Size for the document in millimeters.
        :param int resolution: Resolution in dots per Inch (dpi)
        
        .. seealso::
        
            :py:meth:`renderTo()`, :py:meth:`render()`, 
            :py:meth:`qwt.painter.QwtPainter.setRoundingAlignment()`
        """
        if isinstance(dest, QPaintDevice):
            w = dest.width()
            h = dest.height()
            rect = QRectF(0, 0, w, h)
        elif isinstance(dest, QPrinter):
            w = dest.width()
            h = dest.height()
            rect = QRectF(0, 0, w, h)
            aspect = rect.width()/rect.height()
            if aspect < 1.:
                rect.setHeight(aspect*rect.width())
        elif isinstance(dest, QSvgGenerator):
            rect = dest.viewBoxF()
            if rect.isEmpty():
                rect.setRect(0, 0, dest.width(), dest.height())
            if rect.isEmpty():
                rect.setRect(0, 0, 800, 600)
        p = QPainter(dest)
        self.render(plot, p, rect)
Ejemplo n.º 5
0
 def renderTo(self, plot, dest):
     if isinstance(dest, QPaintDevice):
         w = dest.width()
         h = dest.height()
         rect = QRectF(0, 0, w, h)
     elif isinstance(dest, QPrinter):
         w = dest.width()
         h = dest.height()
         rect = QRectF(0, 0, w, h)
         aspect = rect.width()/rect.height()
         if aspect < 1.:
             rect.setHeight(aspect*rect.width())
     elif isinstance(dest, QSvgGenerator):
         rect = dest.viewBoxF()
         if rect.isEmpty():
             rect.setRect(0, 0, dest.width(), dest.height())
         if rect.isEmpty():
             rect.setRect(0, 0, 800, 600)
     p = QPainter(dest)
     self.render(plot, p, rect)
Ejemplo n.º 6
0
 def renderTo(self, plot, dest):
     if isinstance(dest, QPaintDevice):
         w = dest.width()
         h = dest.height()
         rect = QRectF(0, 0, w, h)
     elif isinstance(dest, QPrinter):
         w = dest.width()
         h = dest.height()
         rect = QRectF(0, 0, w, h)
         aspect = rect.width() / rect.height()
         if aspect < 1.:
             rect.setHeight(aspect * rect.width())
     elif isinstance(dest, QSvgGenerator):
         rect = dest.viewBoxF()
         if rect.isEmpty():
             rect.setRect(0, 0, dest.width(), dest.height())
         if rect.isEmpty():
             rect.setRect(0, 0, 800, 600)
     p = QPainter(dest)
     self.render(plot, p, rect)
Ejemplo n.º 7
0
    def colorBarRect(self, rect):
        """
        Calculate the the rectangle for the color bar

        :param QRectF rect: Bounding rectangle for all components of the scale
        :return: Rectangle for the color bar
        """
        cr = QRectF(rect)
        if self.__data.scaleDraw.orientation() == Qt.Horizontal:
            cr.setLeft(cr.left() + self.__data.borderDist[0])
            cr.setWidth(cr.width() - self.__data.borderDist[1] + 1)
        else:
            cr.setTop(cr.top() + self.__data.borderDist[0])
            cr.setHeight(cr.height() - self.__data.borderDist[1] + 1)
        sda = self.__data.scaleDraw.alignment()
        if sda == QwtScaleDraw.LeftScale:
            cr.setLeft(cr.right() - self.__data.margin -
                       self.__data.colorBar.width)
            cr.setWidth(self.__data.colorBar.width)
        elif sda == QwtScaleDraw.RightScale:
            cr.setLeft(cr.left() + self.__data.margin)
            cr.setWidth(self.__data.colorBar.width)
        elif sda == QwtScaleDraw.BottomScale:
            cr.setTop(cr.top() + self.__data.margin)
            cr.setHeight(self.__data.colorBar.width)
        elif sda == QwtScaleDraw.TopScale:
            cr.setTop(cr.bottom() - self.__data.margin -
                      self.__data.colorBar.width)
            cr.setHeight(self.__data.colorBar.width)
        return cr
Ejemplo n.º 8
0
    def colorBarRect(self, rect):
        """
        Calculate the the rectangle for the color bar

        :param QRectF rect: Bounding rectangle for all components of the scale
        :return: Rectangle for the color bar
        """
        cr = QRectF(rect)
        if self.__data.scaleDraw.orientation() == Qt.Horizontal:
            cr.setLeft(cr.left() + self.__data.borderDist[0])
            cr.setWidth(cr.width() - self.__data.borderDist[1] + 1)
        else:
            cr.setTop(cr.top() + self.__data.borderDist[0])
            cr.setHeight(cr.height() - self.__data.borderDist[1] + 1)
        sda = self.__data.scaleDraw.alignment()
        if sda == QwtScaleDraw.LeftScale:
            cr.setLeft(cr.right()-self.__data.margin-self.__data.colorBar.width)
            cr.setWidth(self.__data.colorBar.width)
        elif sda == QwtScaleDraw.RightScale:
            cr.setLeft(cr.left()+self.__data.margin)
            cr.setWidth(self.__data.colorBar.width)
        elif sda == QwtScaleDraw.BottomScale:
            cr.setTop(cr.top()+self.__data.margin)
            cr.setHeight(self.__data.colorBar.width)
        elif sda == QwtScaleDraw.TopScale:
            cr.setTop(cr.bottom()-self.__data.margin-self.__data.colorBar.width)
            cr.setHeight(self.__data.colorBar.width)
        return cr
Ejemplo n.º 9
0
 def layoutLegend(self, options, rect):
     hint = self.__data.layoutData.legend.hint
     if self.__data.legendPos in (QwtPlot.LeftLegend, QwtPlot.RightLegend):
         dim = min([hint.width(), int(rect.width()*self.__data.legendRatio)])
         if not (options & self.IgnoreScrollbars):
             if hint.height() > rect.height():
                 dim += self.__data.layoutData.legend.hScrollExtent
     else:
         dim = min([hint.height(), int(rect.height()*self.__data.legendRatio)])
         dim = max([dim, self.__data.layoutData.legend.vScrollExtent])
     legendRect = QRectF(rect)
     if self.__data.legendPos == QwtPlot.LeftLegend:
         legendRect.setWidth(dim)
     elif self.__data.legendPos == QwtPlot.RightLegend:
         legendRect.setX(rect.right()-dim)
         legendRect.setWidth(dim)
     elif self.__data.legendPos == QwtPlot.TopLegend:
         legendRect.setHeight(dim)
     elif self.__data.legendPos == QwtPlot.BottomLegend:
         legendRect.setY(rect.bottom()-dim)
         legendRect.setHeight(dim)
     return legendRect
Ejemplo n.º 10
0
 def colorBarRect(self, rect):
     cr = QRectF(rect)
     if self.__data.scaleDraw.orientation() == Qt.Horizontal:
         cr.setLeft(cr.left() + self.__data.borderDist[0])
         cr.setWidth(cr.width() - self.__data.borderDist[1] + 1)
     else:
         cr.setTop(cr.top() + self.__data.borderDist[0])
         cr.setHeight(cr.height() - self.__data.borderDist[1] + 1)
     sda = self.__data.scaleDraw.alignment()
     if sda == QwtScaleDraw.LeftScale:
         cr.setLeft(cr.right()-self.__data.margin-self.__data.colorBar.width)
         cr.setWidth(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.RightScale:
         cr.setLeft(cr.left()+self.__data.margin)
         cr.setWidth(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.BottomScale:
         cr.setTop(cr.top()+self.__data.margin)
         cr.setHeight(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.TopScale:
         cr.setTop(cr.bottom()-self.__data.margin-self.__data.colorBar.width)
         cr.setHeight(self.__data.colorBar.width)
     return cr
Ejemplo n.º 11
0
 def colorBarRect(self, rect):
     cr = QRectF(rect)
     if self.__data.scaleDraw.orientation() == Qt.Horizontal:
         cr.setLeft(cr.left() + self.__data.borderDist[0])
         cr.setWidth(cr.width() - self.__data.borderDist[1] + 1)
     else:
         cr.setTop(cr.top() + self.__data.borderDist[0])
         cr.setHeight(cr.height() - self.__data.borderDist[1] + 1)
     sda = self.__data.scaleDraw.alignment()
     if sda == QwtScaleDraw.LeftScale:
         cr.setLeft(cr.right() - self.__data.margin -
                    self.__data.colorBar.width)
         cr.setWidth(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.RightScale:
         cr.setLeft(cr.left() + self.__data.margin)
         cr.setWidth(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.BottomScale:
         cr.setTop(cr.top() + self.__data.margin)
         cr.setHeight(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.TopScale:
         cr.setTop(cr.bottom() - self.__data.margin -
                   self.__data.colorBar.width)
         cr.setHeight(self.__data.colorBar.width)
     return cr