Global Mapper v26.0

Speed up PAN

Qiao
Qiao Global Mapper UserTrusted User
edited June 2012 in SDK
Hi Mike,

I have been trying to implement something similar to Global Mapper's PAN tool using SDK. What I did was in OnMouseMove handler, I re-center the mMapWindow each time the mouse moves. This is very slow. Do you have any other suggestions?

Thanks,

Qiao

Comments

  • global_mapper
    global_mapper Administrator
    edited June 2009
    Qiao,

    What I would suggest (and is what the GM application does) is to save your map window to an offscreen bitmap, then just BitBlt that to different locations as you move the map around in your OnMouseMove handler. When the user releases the mouse button, then do a new draw of the map window to your offscreen bitmap and draw that to your main map window.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Qiao
    Qiao Global Mapper User Trusted User
    edited June 2009
    Thanks Mike.

    I will try your idea and will let you know how that goes.

    Qiao
  • Qiao
    Qiao Global Mapper User Trusted User
    edited June 2009
    Hi Mike,

    Following your suggestions, in panning, I copy the screen to a bitmap when a mouse is down and then bitblt it when the mouse is moving.

    It seems working except the background is not erased correctly at each move and this creats a bit of mess.

    Here is the line for the first time bitblt (when a mouse is down):
    m_MemDC->bitblt(0, 0, view_width, view_height,pDC, 0,0,SRCCOPY);

    Here is the line for the second time bitblt (when a mouse is moving):
    pDC->bitblt(x0_new, y0_new, view_width, view_height,&m_MemDC, 0,0,SRCCOPY);

    Could you help me on this?

    Thanks,

    Qiao
  • global_mapper
    global_mapper Administrator
    edited June 2009
    Qiao,

    Just erase the background of the entire window before you BitBlt using a PatBlt with a brush. To avoid flicker you might want to create a second offscreen bitmap for what you will draw to the screen and erase it then BitBlt the other offscreen map to that, then finally BitBlt the entire second offscreen map to the screen.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • yeshu
    yeshu Global Mapper User
    edited June 2012
    Can you provide me Sample code for the same for Mouse Move and DOWN in C#, i am not able to do PANNING as per your suggestion.
  • global_mapper
    global_mapper Administrator
    edited June 2012
    We don't have any sample C# code for doing the flicker-free panning, but the C++ sample application has a lot of relevant sample code. Are you having trouble with the offscreen bitmap part or just handling mouse events in general in C#? We are more of a C++ shop so don't have as much experience in C# for more complex things, but the offscreen bitmap handling is more of a general C# Windows programming issue rather than something specific to the Global Mapper SDK.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com