Results 1 to 3 of 3

Thread: access plot rectangle before QwtScaleDraw::label is called?

  1. #1
    Join Date
    Oct 2010
    Posts
    58
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default access plot rectangle before QwtScaleDraw::label is called?

    Hi,
    I've been searching for this all day, perhaps someone can point me in the right direction.

    What function do I need to overload to find the current rectangle of my canvas before
    QwtScaleDraw::label(double value) is called?

    I know the first time QwtScaleDraw::label(double value) is called 'value' is the minimum value of the axis, and the second time it is called 'value' is the max value of the axis. I want to be able to know the min and the max value before QwtScaleDraw::label is called (everytime it is called)

    The reason I want to know this is to make the dates on my x axis change depending on how big of a time frame is displayed on the plot. For example, if it is a 10 year span, I only want years as labels, but if it is 10 minutes I'd like minutes.

    I've been trying to do this a hacky way by getting the zoom rect's but nothing I have tried works in all cases, for example, if the user zooms out to a bigger area.

    I've also tried overloading QwtScaleWidget::layoutScale because it seems to have a rect() function. But my code never seems to get to it:

    Qt Code:
    1. class ScaleWidget : public QwtScaleWidget{
    2. public:
    3. ScaleWidget(){}
    4. void layoutScale(bool update_geometry){
    5. const QRectF r = rect(); // I think I want this rect!
    6. QwtScaleWidget::layoutScale();
    7. }
    8. };
    To copy to clipboard, switch view to plain text mode 

    Please, any ideas?
    Thanks a lot!

  2. #2
    Join Date
    Oct 2010
    Posts
    58
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: access plot rectangle before QwtScaleDraw::label is called?

    Ah ha! I think I finally found what I need. I just call this within QwtScaleDraw::label

    Qt Code:
    1. QwtScaleMap map = this->map();
    2. double xBegin = map.s1();
    3. double xEnd = map.s2();
    To copy to clipboard, switch view to plain text mode 

    This give me the min and max values of my xBottom axis!

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

    Default Re: access plot rectangle before QwtScaleDraw::label is called?

    Or do the following:

    Qt Code:
    1. double xBegin = scaleDiv().lowerBound();
    2. double xEnd = scaleDiv().upperBound();
    To copy to clipboard, switch view to plain text mode 
    Uwe

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

    kja (17th August 2011)

Similar Threads

  1. QwtScaleDraw align label to xaxis
    By kja in forum Qwt
    Replies: 1
    Last Post: 21st November 2010, 20:55
  2. Replies: 3
    Last Post: 27th August 2010, 07:00
  3. HOW TO DISPLAY A RECTANGLE ON AN IMAGE on a label
    By qt_user in forum Qt Programming
    Replies: 4
    Last Post: 6th August 2010, 16:19
  4. Replies: 3
    Last Post: 18th June 2010, 14:18
  5. Replies: 5
    Last Post: 17th June 2009, 15:01

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.