Hi Mailing List and Hi Chris,

I have a strange problem when scrolling/panning using the GUIMove Mode.

In my class, i have a FloatCanvas like this:

self.canvas = FloatCanvas.FloatCanvas(self, ProjectionFun = None,
 Debug = 0,BackgroundColor = "GREY",)

on which i'm scrolling using a modified GUIMove. Modified in the way
that i just mapped scrolling to the right button instead of the left.
So it's basically:

    def OnLeftDown(self, event):
        EventType = FloatCanvas.EVT_FC_LEFT_DOWN
        if not self.Canvas.HitTest(event, EventType):
            self.Canvas._RaiseMouseEvent(event, EventType)
    def OnLeftUp(self, event):
        EventType = FloatCanvas.EVT_FC_LEFT_UP
        if not self.Canvas.HitTest(event, EventType):
            self.Canvas._RaiseMouseEvent(event, EventType)
    def OnLeftDouble(self, event):
        EventType = FloatCanvas.EVT_FC_LEFT_DCLICK
        if not self.Canvas.HitTest(event, EventType):
                self.Canvas._RaiseMouseEvent(event, EventType)
    def OnRightUp(self, event):
        if self.StartMove is not None:
            StartMove = self.StartMove
            EndMove = N.array(event.GetPosition())
            DiffMove = StartMove-EndMove
            if N.sum(DiffMove**2) > 16:
                self.Canvas.MoveImage(DiffMove, 'Pixel')
            self.StartMove = None
        self.Canvas.SetCursor(self.Cursor)
    def OnRightDown(self, event):
        self.Canvas.CaptureMouse()
        self.StartMove = N.array( event.GetPosition() )
        self.PrevMoveXY = (0,0)
        EventType = FloatCanvas.EVT_FC_RIGHT_DOWN
        if not self.Canvas.HitTest(event, EventType):
            self.Canvas._RaiseMouseEvent(event, EventType)


I had the OnMove and MoveImage Methods defined like this:

   def OnMove(self, event):
        self.Canvas.MouseOverTest(event)
        self.Canvas._RaiseMouseEvent(event,FloatCanvas.EVT_FC_MOTION)
        self.Canvas.MouseOverTest(event)
        self.Canvas._RaiseMouseEvent(event,FloatCanvas.EVT_FC_MOTION)
        if event.Dragging() and event.RightIsDown() and not
self.StartMove is None:
            self.MoveImage(event)

    def MoveImage(self, event):
        xy1 = N.array( event.GetPosition() )
        wh = self.Canvas.PanelSize
        xy_tl = xy1 - self.StartMove
        dc = wx.ClientDC(self.Canvas)
        dc.BeginDrawing()
        x1,y1 = self.PrevMoveXY
        x2,y2 = xy_tl
        w,h = self.Canvas.PanelSize
        ##fixme: This sure could be cleaner!
        ##   This is all to fill in the background with the background color
        ##   without flashing as the image moves.
        if x2 > x1 and y2 > y1:
            xa = xb = x1
            ya = yb = y1
            wa = w
            ha = y2 - y1
            wb = x2-  x1
            hb = h
        elif x2 > x1 and y2 <= y1:
            xa = x1
            ya = y1
            wa = x2 - x1
            ha = h
            xb = x1
            yb = y2 + h
            wb = w
            hb = y1 - y2
        elif x2 <= x1 and y2 > y1:
            xa = x1
            ya = y1
            wa = w
            ha = y2 - y1
            xb = x2 + w
            yb = y1
            wb = x1 - x2
            hb = h - y2 + y1
        elif x2 <= x1 and y2 <= y1:
            xa = x2 + w
            ya = y1
            wa = x1 - x2
            ha = h
            xb = x1
            yb = y2 + h
            wb = w
            hb = y1 - y2

        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.SetBrush(self.Canvas.BackgroundBrush)
        dc.DrawRectangle(xa, ya, wa, ha)
        dc.DrawRectangle(xb, yb, wb, hb)
        self.PrevMoveXY = xy_tl
        if self.Canvas._ForeDrawList:
            dc.DrawBitmapPoint(self.Canvas._ForegroundBuffer,xy_tl)
        else:
            dc.DrawBitmapPoint(self.Canvas._Buffer,xy_tl)
        dc.EndDrawing()


This is basically just grabbed from an earlier version of Chris' GUIMode.py.
However, this gives me the bug that whenever a border of the canvas is
reached, the application just crashes (without giving an error or anything).

I tried replacing the methods with those from recent GUIMove in the
subversion, where OnMove is:
    def OnMove(self, event):
        # Allways raise the Move event.
        self.Canvas._RaiseMouseEvent(event,FloatCanvas.EVT_FC_MOTION)
        if event.Dragging() and event.LeftIsDown() and not
self.StartMove is None:
            self.MoveImage(event)

and MoveImage is basically exactly the same.
However, this gives me a HUGE Performance problem, as scrolling gets so
slow it basically doesn't happen anymore.
I can't see what's wrong. Anyone?

Thank you,
-- 
Niels Menke
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to