Results 1 to 2 of 2

Thread: axes don't readjust when add new qwtplotcurves

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

    Default axes don't readjust when add new qwtplotcurves

    Hi,

    I have a gui that plots curves that a user inputs. The user can also change the dates so the curves go farther back in time. My problem comes when the user changes the dates. For the first curve the plot looks correct and is set to whatever dates were entered, but when the dates are edited the plot does not resize to the new dates, but rather stays over the dates of the first curve. This problem only happens if I zoom in or out at all on the first plot which leads me to believe it has something to do with the zoomer. I think using the zoom on the first curve is breaking something about my qwtplot axes but I don't know where. I tried to setZoomBase but that hasn't changed anything about the scales of the x axis.

    Here is some of the code, maybe someone can spot my error :

    Qt Code:
    1. class MyZoomer : public QwtPlotZoomer{
    2. public:
    3. MyZoomer(QwtPlotCanvas *canvas) : QwtPlotZoomer(canvas)
    4. {
    5. setTrackerMode(AlwaysOn);
    6. }
    7. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "MyZoomer.h"
    2.  
    3. class MyPlot : public QwtPlot
    4. {
    5. QwtPlotCurve *Curve;
    6. public:
    7. MyPlot(){
    8. zoomer = new MyZoomer(canvas());
    9. const QColor c(Qt::darkBlue);
    10. zoomer->setRubberBandPen(c);
    11. zoomer->setTrackerPen(c);
    12.  
    13. setAxisScaleDraw(QwtPlot::xBottom, new XaxisDates);
    14. }
    15. QwtPlotZoomer *zoomer;
    16. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. MyWidget::MyWidget(QWidget * parent):QWidget(parent){
    2. myPlot = new MyPlot;
    3. }
    4. void MyWidger::plotCurves(){
    5. getDates(); ///this gets the start and end dates that the user entered
    6. getInstructionsANDplot();
    7. }
    8. void MyWidget::getInstructionsANDplot{
    9. ///gets file name from user
    10. myPlot->addFile(filename, start, end);
    11. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "MyPlot.h"
    2. void MyPlot::addFile( const char * fn, double st, double end ){
    3. Curve = new QwtPlotCurve(fn);
    4.  
    5. //load the data with the user inputed start and end times
    6.  
    7. Curve->setRawSamples(time, values, newNumbPts);
    8. Curve->attach(this);
    9. zoomer->setZoomBase();
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

    Like I said, I'm pretty sure it is the zoomer. Whatever size I was zoomed in on the first curve when I load more dates is where the x and y axes stay no matter what. However, if I load a curve and never zoom, I can change the dates and the view adjusts to hold all the information like it should.

    I hope this makes sense, thanks for any insight.

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

    Default Re: axes don't readjust when add new qwtplotcurves

    The zoomer sets the axis scales using QwtPlot::setAxisScale(), what disables autoscaling. You can reenable it by QwtPlot::setAxisAutoScale(...).

    Uwe

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

    kja (26th November 2010)

Similar Threads

  1. Zoom and pan with two y-axes
    By mjfj in forum Qwt
    Replies: 1
    Last Post: 19th October 2010, 10:39
  2. is it posible to invert the axes?
    By jbca in forum Qwt
    Replies: 2
    Last Post: 18th January 2010, 15:34
  3. Plot Axes
    By mcarter in forum Qwt
    Replies: 0
    Last Post: 4th December 2009, 23:47
  4. Fixed size axes
    By wim12 in forum Qwt
    Replies: 4
    Last Post: 15th May 2009, 12:37
  5. remove of all QwtPlotCurves
    By gyre in forum Qwt
    Replies: 3
    Last Post: 21st December 2007, 07:58

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.