Esempio n. 1
0
    def Redraw(self,
               dc: DC = None,
               full: bool = True,
               saveBackground: bool = False,
               useBackground: bool = False):
        """
        Refresh the diagram.
        If a DC is given, use it. Otherwise, use a double buffered DC.

        Args:
            dc:     If None, a default dc is created
            full:   If False, only draw the shape borders.
            saveBackground: If True, save the background
            useBackground:  If True, use the background
        """
        needBlit = False
        w, h = self.GetSize()

        if dc is None:
            dc = self.CreateDC(useBackground, w, h)
            needBlit = True

        dc.SetFont(self._defaultFont)

        shapes = self._diagram.GetShapes()
        if full:
            # first time, need to create the background
            if saveBackground:
                # first, draw every non-moving shapes
                for shape in shapes:
                    if not shape.IsMoving():
                        shape.Draw(dc)
                # save the background
                self.SaveBackground(dc)
                # draw every moving shape
                for shape in shapes:
                    if shape.IsMoving():
                        shape.Draw(dc)

            # x, y = self.CalcUnScrolledPosition(0, 0)
            if useBackground:
                # draw every moving shapes
                for shape in shapes:
                    if shape.IsMoving():
                        shape.Draw(dc)
                # TODO: This code belongs in OnPaint
                # if self._prefs.backgroundGridEnabled is True:
                #     self._drawGrid(memDC=dc, width=w, height=h, startX=x, startY=y)
            else:  # don't use background
                # draw all shapes
                for shape in shapes:
                    shape.Draw(dc)
                # TODO: This code belongs in OnPaint
                # if self._prefs.backgroundGridEnabled is True:
                #     self._drawGrid(memDC=dc, width=w, height=h, startX=x, startY=y)
        else:  # not full
            for shape in shapes:
                shape.DrawBorder(dc)
                shape.DrawAnchors(dc)

        if needBlit:
            client = ClientDC(self)

            x, y = self.CalcUnscrolledPosition(0, 0)
            client.Blit(0, 0, w, h, dc, x, y)
Esempio n. 2
0
    def Redraw(self,
               dc=None,
               full=True,
               saveBackground=False,
               useBackground=False):
        """
        Refresh the diagram graphically.
        If a dc is given, use it. Otherwise, a double buffered dc is used.

        @param DC dc : if None, a default dc will be created
        @param bool full : if 0, only draws the borders of shapes
        @param bool saveBackground : if True, the background will be saved
        @param bool useBackground : if True, the background will be used
        """
        needBlit = False
        w, h = self.GetSize()

        if dc is None:
            dc = self.CreateDC(useBackground, w, h)
            needBlit = True

        dc.SetFont(self._defaultFont)

        shapes = self._diagram.GetShapes()

        if full:
            # first time, need to create the background
            if saveBackground:
                # first, draw every non moving shapes
                for shape in shapes:
                    if not shape.IsMoving():
                        shape.Draw(dc)
                # save the background
                self.SaveBackground(dc)
                # draw every moving shapes
                for shape in shapes:
                    if shape.IsMoving():
                        shape.Draw(dc)
            if useBackground:
                # draw every moving shapes
                for shape in shapes:
                    if shape.IsMoving():
                        shape.Draw(dc)
            else:  # don't use background
                # draw all shapes
                for shape in shapes:
                    shape.Draw(dc)
        else:  # not full
            for shape in shapes:
                shape.DrawBorder(dc)
                shape.DrawAnchors(dc)

        if needBlit:
            #  MODIFIED BY C.DUTOIT : Added Python test
            client = ClientDC(self)

            if __version__ > "2.3.2":
                x, y = self.CalcUnscrolledPosition(0, 0)
                client.Blit(0, 0, w, h, dc, x, y)
            else:
                client.Blit(0, 0, w, h, dc, 0, 0)