Results 1 to 6 of 6

Thread: Hiding intervals on axis scales

  1. #1
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Hiding intervals on axis scales

    Hey hey,

    I have a plot, with yLeft and xBottom axis. Now let's assume i have the xBottom-axis in a way like that:

    ..... |---|---|---|---|---|---|---|---|---|---|---|---|---|---| ...
    ...10 11 12 13 14 15 16 17 18 19 20 21 22 23 24...

    Is it possible to tell qwt to hide some intervals of this scale? For example to get an output like that:

    ..... |---|---|---|---|---|---|---|---|---|---|---| ...
    ...10 11 12 13 17 18 19 20 27 28 29 30 ...

    In the end nothing between those hidden intervals should be displayed, as like you cut the whole interval out of the plot.
    Is there a cool way to solve this problem? My idea was to derive from QwtPlot, QwtScaleDraw and eventually QwtScaleEngine. Is there an easier way? If not, what methods should I reimplement best?

    Thank you in advance!

  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: Hiding intervals on axis scales

    QwtScaleEngine is what you need to derive from. It is responsible for calculating the ticks and most important: the transformation, that needs to be aware of the intervals.

    If you want to indicate the gaps on the axis somehow ( f.e with dots at the backbone of the scale ) you have to reimplement some virtual methods of QwtScaleDraw, but this has no effect on the plot canvas and how plot items are displayed on the canvas.

    Let me know if you have some code - such a scale engine is on my todo list for quite some time.
    Maybe it helps to have a look at this code: http://qwt.svn.sourceforge.net/viewv...94&view=markup

    Uwe

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

    cradle (20th January 2012)

  4. #3
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hiding intervals on axis scales

    Thanks for your quick reply Uwe. Helps a lot!
    I'll inform you if I have something useful.

    Best regards.

  5. #4
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hiding intervals on axis scales

    Hello again,

    I have a question on the example code above.
    I want to hide/unhide the intervals during runtime, so I have to put the intervals in a container (let it be a QVector or so..). Now MyTransformation should have access to this container. My idea is a new attribute of MyTransformation (a pointer to the container). If I do it that way, I need a pointer to the instance of MyTransformation as attribute of MyScaleEngine (ftuTransformation *trans).
    In this case, it's not quite good, that QwtScaleTransformation *transformation() always creates new instances of MyTransformation.
    If I do something like:
    Qt Code:
    1. QwtScaleTransformation *ftuScaleEngine::transformation() const
    2. {
    3. return this->trans;
    4. }
    To copy to clipboard, switch view to plain text mode 
    and trans is a pointer to MyTransformation (instantiated in constructor of ftuScaleEngine), I get a seg-fault:
    Qt Code:
    1. (gdb) bt
    2. #0 0x00007f6ad6535020 in QwtScaleDraw::getBorderDistHint(QFont const&, int&, int&) const () from /usr/lib/libqwt.so.6
    3. #1 0x00007f6ad65747d6 in QwtScaleWidget::getBorderDistHint(int&, int&) const () from /usr/lib/libqwt.so.6
    4. #2 0x00007f6ad654fd21 in QwtPlot::updateAxes() () from /usr/lib/libqwt.so.6
    5. #3 0x00007f6ad654a90a in QwtPlot::replot() () from /usr/lib/libqwt.so.6
    6. #4 0x0000000000416f70 in ScrollZoomer::updateScrollBars() ()
    7. #5 0x000000000041d162 in ftuPlot::ftuPlot(QwtText, QWidget*) ()
    8. #6 0x0000000000416099 in waveform::waveform(QWidget*) ()
    9. #7 0x000000000040f280 in ftuGui::ftuGui(QWidget*) ()
    10. #8 0x000000000040ed9e in main ()
    To copy to clipboard, switch view to plain text mode 
    If I do it like the example
    Qt Code:
    1. QwtScaleTransformation *ftuScaleEngine::transformation() const
    2. {
    3. return new ftuTransformation();
    4. }
    To copy to clipboard, switch view to plain text mode 
    it works without problems.

    Well... is there a reason for always returning a new Transformation?
    ...and on the other hand, is it a good or bad idea, to make the pointer to the container an attribute of MyTransformation?

    Thank you and best regards

  6. #5
    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: Hiding intervals on axis scales

    Quote Originally Posted by cradle View Post
    I have a question on the example code above.
    I want to hide/unhide the intervals during runtime, so I have to put the intervals in a container (let it be a QVector or so..). Now MyTransformation should have access to this container. My idea is a new attribute of MyTransformation (a pointer to the container).
    Qt containers are implicitly shared - you can copy them around without wasting memory. There is no reason to make your life difficult with taking care about pointers like this one.

    And always create and assign a new scale engine, when you want to modify the vector - instead of modifying existing transformation objects !

    Uwe

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

    cradle (8th February 2012)

  8. #6
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hiding intervals on axis scales

    Ok that makes sense. Thanks Uwe!

Similar Threads

  1. Replies: 9
    Last Post: 3rd May 2011, 21:21
  2. Replies: 6
    Last Post: 26th October 2010, 09:02
  3. fixed axis scales
    By oskarmellow in forum Qwt
    Replies: 1
    Last Post: 17th December 2008, 06:20
  4. Replies: 1
    Last Post: 2nd December 2008, 22:22
  5. Replies: 10
    Last Post: 18th September 2008, 15:14

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.