Ejemplo n.º 1
0
    def draw(self, parentposn, phelper, outerbounds=None):
        '''Update the margins before drawing.'''

        s = self.settings

        margins = ( s.get('leftMargin').convert(phelper),
                    s.get('topMargin').convert(phelper),
                    s.get('rightMargin').convert(phelper),
                    s.get('bottomMargin').convert(phelper) )
        bounds = self.computeBounds(parentposn, phelper, margins=margins)
        maxbounds = self.computeBounds(parentposn, phelper)

        painter = phelper.painter(self, bounds)

        # controls for adjusting margins
        phelper.setControlGraph(self, [
                controlgraph.ControlMarginBox(self, bounds, maxbounds, phelper)])

        # do no painting if hidden
        if s.hide:
            return bounds

        # plot graph
        datarange = self.getDataRange()
        self.drawGraph(painter, bounds, datarange, outerbounds=outerbounds)
        self.drawAxes(painter, bounds, datarange, outerbounds=outerbounds)

        # paint children
        for c in reversed(self.children):
            c.draw(bounds, phelper, outerbounds=outerbounds)

        return bounds
Ejemplo n.º 2
0
    def draw(self, parentposn, painthelper, outerbounds=None):
        '''Update the margins before drawing.'''

        s = self.settings

        margins = (s.get('leftMargin').convert(painthelper),
                   s.get('topMargin').convert(painthelper),
                   s.get('rightMargin').convert(painthelper),
                   s.get('bottomMargin').convert(painthelper))

        bounds = self.computeBounds(parentposn, painthelper, margins=margins)
        maxbounds = self.computeBounds(parentposn, painthelper)

        # controls for adjusting graph margins
        painter = painthelper.painter(self, bounds)
        painthelper.setControlGraph(self, [
            controlgraph.ControlMarginBox(self, bounds, maxbounds, painthelper)
        ])

        # do no painting if hidden
        if s.hide:
            return bounds

        # set graph rectangle attributes
        path = qt4.QPainterPath()
        path.addRect(
            qt4.QRectF(qt4.QPointF(bounds[0], bounds[1]),
                       qt4.QPointF(bounds[2], bounds[3])))
        utils.brushExtFillPath(painter,
                               s.Background,
                               path,
                               stroke=s.Border.makeQPenWHide(painter))

        # do normal drawing of children
        # iterate over children in reverse order
        for c in reversed(self.children):
            c.draw(bounds, painthelper, outerbounds=outerbounds)

        # now need to find axes which aren't children, and draw those again
        axestodraw = set()
        childrennames = set()
        for c in self.children:
            childrennames.add(c.name)
            try:
                for axis in c.getAxesNames():
                    axestodraw.add(axis)
            except AttributeError:
                pass

        axestodraw = axestodraw - childrennames
        if axestodraw:
            # now redraw all these axes if they aren't children of us
            axeswidgets = self.getAxes(axestodraw)
            for w in axeswidgets:
                if w is not None:
                    w.draw(bounds, painthelper, outerbounds=outerbounds)

        return bounds
Ejemplo n.º 3
0
    def draw(self, painthelper, pagenum):
        """Draw the page requested on the painter."""

        xw, yw = painthelper.pagesize
        posn = [0, 0, xw, yw]
        painter = painthelper.painter(self, posn)
        page = self.children[pagenum]
        page.draw(posn, painthelper)

        # w and h are non integer
        w = self.settings.get('width').convert(painter)
        h = self.settings.get('height').convert(painter)
        painthelper.setControlGraph(self, [
            controlgraph.ControlMarginBox(self, [0, 0, w, h],
                                          [-10000, -10000, 10000, 10000],
                                          painthelper,
                                          ismovable=False)
        ])
Ejemplo n.º 4
0
    def draw(self, parentposn, phelper, outerbounds=None):
        """Draws the widget's children."""

        s = self.settings

        # if the contents have been modified, recalculate the positions
        dimensions = (s.columns, s.rows)
        scalings = (s.scaleRows, s.scaleCols)
        if (self.children != self.lastchildren
                or self.lastdimensions != dimensions
                or self.lastscalings != scalings):

            self._recalcPositions()
            self.lastchildren = list(self.children)
            self.lastdimensions = dimensions
            self.lastscalings = scalings

        margins = (s.get('leftMargin').convert(phelper),
                   s.get('topMargin').convert(phelper),
                   s.get('rightMargin').convert(phelper),
                   s.get('bottomMargin').convert(phelper))

        bounds = self.computeBounds(parentposn, phelper, margins=margins)
        maxbounds = self.computeBounds(parentposn, phelper)

        phelper.painter(self, bounds)

        # controls for adjusting grid margins
        phelper.setControlGraph(
            self,
            [controlgraph.ControlMarginBox(self, bounds, maxbounds, phelper)])

        for child in self.children:
            if child.typename != 'axis':
                self._drawChild(phelper, child, bounds, parentposn)

        # do not call widget.Widget.draw, do not collect 200 pounds
        pass
Ejemplo n.º 5
0
    def draw(self, parentposn, painthelper, outerbounds=None):
        """Draw the plotter. Clip graph inside bounds."""

        # document should pass us the page bounds
        x1, y1, x2, y2 = parentposn

        # find ranges of axes
        axisdependhelper = _AxisDependHelper(self)
        axisdependhelper.findPlotters()
        axisdependhelper.findAxisRanges()

        # store axis->plotter mappings in painter too (is this nasty?)
        painthelper.axisplottermap.update(axisdependhelper.axis_plotter_map)

        if self.settings.hide:
            bounds = self.computeBounds(parentposn, painthelper)
            return bounds

        clip = qt4.QRectF(qt4.QPointF(parentposn[0], parentposn[1]),
                          qt4.QPointF(parentposn[2], parentposn[3]))
        painter = painthelper.painter(self, parentposn, clip=clip)

        # clip to page
        bounds = widget.Widget.draw(self, parentposn, painthelper, parentposn)

        # w and h are non integer
        w = self.settings.get('width').convert(painter)
        h = self.settings.get('height').convert(painter)
        painthelper.setControlGraph(self, [
            controlgraph.ControlMarginBox(self, [0, 0, w, h],
                                          [-10000, -10000, 10000, 10000],
                                          painthelper,
                                          ismovable=False)
        ])

        return bounds