Results 1 to 5 of 5

Thread: How to manually pan canvas

  1. #1
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to manually pan canvas

    I've create a QwtPlotPanner and connected it to the Right mouse button. The panning functionality works perfectly.

    I allow the user to select a data point in the canvas using a QwtPlotPicker. The data gets updated every N seconds. The selected point (referenced via an ID) therefore moves every N seconds. The point stays selected, but I'd like to manually pan the canvas so the selected point is always at the center.

    I found a couple methods in QwtPlotPanner that looked promising: moveCanvas(), moved(), panned(), etc. But those aren't accessible.

    Any suggestions?

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to manually pan canvas

    This has nothing to do with panning: simply use QwtPlot::setAxisScale().

    Uwe

  3. #3
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to manually pan canvas

    Is there a way to get what the current axis scale is on the QwtPlot? I've also got a zoomer and magnifier on this plot so the axis scale is always changing based on the user interaction. So when I get a data update I need to get the current axis scale and adjust them based on where the selected point is now located.

    Thanks!

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to manually pan canvas

    • QwtPlot::axisScaleDiv( ... ) gives you get all information about the current scale.
    • connect( axisWidget(...), SIGNAL( scaleDivChanged() ), ... ) tells you about any changes ( f.e. by zooming panning ) of a scale
    • plot->canvas()->contentsRect() returns the geometry of the plot in paint coordinates.
    • With QwtPlot::canvasMap() you have the transformation between both coordinate systems.


    QwtPlotZoomer also has a method scaleRect() ( derived from its base class ). You can check the implementation of QwtPlotPicker::scaleRect() - Qwt is open source.

    Uwe

  5. The following user says thank you to Uwe for this useful post:

    novackb (18th February 2011)

  6. #5
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to manually pan canvas

    Thanks for your help.

    QwtPlot::axisScaleDiv(..) contains the information I was looking for.

Similar Threads

  1. how to show an app if it manually hide
    By jthacker in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2010, 13:02
  2. Creating event manually and using them
    By vajindarladdad in forum Newbie
    Replies: 4
    Last Post: 28th August 2009, 08:02
  3. help for compile manually the Qt with Phonon
    By villa in forum Installation and Deployment
    Replies: 1
    Last Post: 3rd May 2009, 12:34
  4. QList resize manually
    By nina1983 in forum Qt Programming
    Replies: 4
    Last Post: 12th August 2008, 16:42
  5. Manually using RCC compiler?
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 18th May 2007, 07:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.