Results 1 to 8 of 8

Thread: Put plot axis out of the plot

  1. #1
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Put plot axis out of the plot

    Hi everyone.

    Overall size of my plot can be very big so I decided to put it in QScrollView, but then user scrolls it in the middle of the plot it's scales not visible. So I tried to place QwtScaleWidgets around scrollview and pick parameters (Divs,Draw etc) of plot's scales. Problem is that then I make plot's scales disabled plot is recalculating so actual scales not equal to widget's scales around scrollview. I tried to reparent scaleWidgets of plot outside plot but plan didn't work.

    Can anyone suggest how can I solve this problem? Very big thanks beforehand =)

  2. #2
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Put plot axis out of the plot

    I will glad if I could get even main idea how to solve this

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,253
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Put plot axis out of the plot

    Before you continue with your idea: the realtime example includes a class ScrollZoomer, that displays scrollbars ( when you zoom in ) on the plot canvas. Another solution is the wheel, that is implemented in the event_filter example.

    Of course you can try to follow your idea, but you will have a hard time to synchronize the scales with the viewport of your scrollview + printing won't work anymore.

    Uwe

  4. #4
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Put plot axis out of the plot

    As far as I know both ScrollZoomer and wheel in event_filter just use signals to setAxisScale and then replot the plot.

    So we can have 2 types of disatvanteges here:
    1) If we will replot only on mousebtn release event (in reason to evade huge amount of calculations) new part of a plot (which was invisible) will be drawn only after mousebtn release. So user will have not so great visible experience while using my app
    2) If plot has huge amount of plotItems on it whole app can be veeeery slow during scrolling if we will setScale and replot on every scrollbar value's change.

    If I will find a way to equal scalewidgets and actual scales, plot will be drawn on pixmap only ones, and replot will be needed only than user will set new Scale values + connect scrollview contents moving on both scales. I've done something like this in my previous app, but in this app I tried to equal one scale to one scalewidget.

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,253
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Put plot axis out of the plot

    Ok, this is what you need to do: implement a method, that calculates the rectangle ( plot coordinates ) that is currently displayed. For this you need to translate the current view ( pixel coordinates ) using the canvasMaps of the plot.

    Whenever the current view changes you need to call this calculation and emit the translated rectangle. Then implement a slot, where you update the scale widgets according to the rectangle.

    When you succeeded so far let me know and we can continue to align the ticks of the scales to the content of the canvas.

    Uwe

  6. #6
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Put plot axis out of the plot

    Sorry, I should told that Scale widgets will have same size as plot and will be placed in diffrent scrollviews, this scrollviews will be placed around scrollview of a plot and plot's scrollview's contents changed signal (or h/v scrollbars value changed signal) will be connected to scalwidgets scrollviews slots. So aligning of scalwidget ticks to canvas values should be performed only in the begining and then user will change plot scale

  7. #7
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,253
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Put plot axis out of the plot

    Well then something like this:

    Qt Code:
    1. void XXX::syncScale(int axis)
    2. {
    3. ...
    4.  
    5. yourScale->setScaleDiv(
    6. plot->axisScaleEngine(axis)->transformation(),
    7. plot->axisWidget(axis)->scaleDiv() );
    8.  
    9. int startDist, endDist;
    10. yourScale->getBorderDistHint(startDist, endDist);
    11. yourScale->setBorderDist(startDist, endDist);
    12.  
    13. }
    14.  
    15. connect(plot->axisWidget(...), SIGNAL(scaleDivChanged(),
    16. ..., SLOT(syncScale() );
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Put plot axis out of the plot

    this thread may work on qwt of earlier version, but how to achieve this on 6.1?

Similar Threads

  1. Detecting changes in the qwt plot axis
    By mrcolin in forum Qwt
    Replies: 2
    Last Post: 27th January 2009, 13:53
  2. Replies: 7
    Last Post: 22nd September 2008, 23:05

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.