Beispiel #1
0
    def rebuild(self):
        """
        Rebuilds the data for this scene to draw with.
        """
        global XChartWidgetItem
        if (XChartWidgetItem is None):
            from projexui.widgets.xchartwidget.xchartwidgetitem \
            import XChartWidgetItem

        self._buildData = {}

        # build the grid location
        x = 8
        y = 8
        w = self.sceneRect().width()
        h = self.sceneRect().height()
        hpad = self.horizontalPadding()
        vpad = self.verticalPadding()
        hmax = self.horizontalRuler().maxNotchSize(Qt.Horizontal)

        left_offset = hpad + self.verticalRuler().maxNotchSize(Qt.Vertical)
        right_offset = left_offset + hpad
        top_offset = vpad
        bottom_offset = top_offset + vpad + hmax

        left = x + left_offset
        right = w - right_offset
        top = y + top_offset
        bottom = h - bottom_offset

        rect = QRectF()
        rect.setLeft(left)
        rect.setRight(right)
        rect.setBottom(bottom)
        rect.setTop(top)

        self._buildData['grid_rect'] = rect

        # rebuild the ruler data
        self.rebuildGrid()
        self._dirty = False

        # rebuild all the items
        padding = self.horizontalPadding() + self.verticalPadding()
        grid = self.sceneRect()
        filt = lambda x: isinstance(x, XChartWidgetItem)
        items = filter(filt, self.items())
        height = float(grid.height())
        if height == 0:
            ratio = 1
        else:
            ratio = grid.width() / height
        count = len(items)

        if (not count):
            return

        if (ratio >= 1):
            radius = (grid.height() - padding * 2) / 2.0
            x = rect.center().x()
            y = rect.center().y()
            dx = radius * 2.5
            dy = 0
        else:
            radius = (grid.width() - padding * 2) / 2.0
            x = rect.center().x()
            y = rect.center().y()
            dx = 0
            dy = radius * 2.5

        for item in items:
            item.setPieCenter(QPointF(x, y))
            item.setRadius(radius)
            item.rebuild()

            x += dx
            y += dy

        if (self._trackerItem and self._trackerItem()):
            self._trackerItem().rebuild(self._buildData['grid_rect'])
Beispiel #2
0
 def rebuild( self ):
     """
     Rebuilds the data for this scene to draw with.
     """
     global XChartWidgetItem
     if ( XChartWidgetItem is None ):
         from projexui.widgets.xchartwidget.xchartwidgetitem \
         import XChartWidgetItem
     
     self._buildData = {}
     
     # build the grid location
     x      = 8
     y      = 8
     w      = self.sceneRect().width()
     h      = self.sceneRect().height()
     hpad   = self.horizontalPadding()
     vpad   = self.verticalPadding()
     hmax   = self.horizontalRuler().maxNotchSize(Qt.Horizontal)
     
     left_offset   = hpad + self.verticalRuler().maxNotchSize(Qt.Vertical)
     right_offset  = left_offset + hpad
     top_offset    = vpad
     bottom_offset = top_offset + vpad + hmax
     
     left    = x + left_offset
     right   = w - right_offset
     top     = y + top_offset
     bottom  = h - bottom_offset
     
     rect = QRectF()
     rect.setLeft(left)
     rect.setRight(right)
     rect.setBottom(bottom)
     rect.setTop(top)
     
     self._buildData['grid_rect'] = rect
     
     # rebuild the ruler data
     self.rebuildGrid()
     self._dirty = False
     
     # rebuild all the items
     padding  = self.horizontalPadding() + self.verticalPadding()
     grid     = self.sceneRect()
     filt     = lambda x: isinstance(x, XChartWidgetItem)
     items    = filter(filt, self.items())
     height   = float(grid.height())
     if height == 0:
         ratio = 1
     else:
         ratio = grid.width() / height
     count    = len(items)
     
     if ( not count ):
         return
     
     if ( ratio >= 1 ):
         radius   = (grid.height() - padding * 2) / 2.0
         x        = rect.center().x()
         y        = rect.center().y()
         dx       = radius * 2.5
         dy       = 0
     else:
         radius   = (grid.width() - padding * 2) / 2.0
         x        = rect.center().x()
         y        = rect.center().y()
         dx       = 0
         dy       = radius * 2.5
     
     for item in items:
         item.setPieCenter(QPointF(x, y))
         item.setRadius(radius)
         item.rebuild()
         
         x += dx
         y += dy
     
     if ( self._trackerItem and self._trackerItem() ):
         self._trackerItem().rebuild(self._buildData['grid_rect'])