Results 1 to 6 of 6

Thread: axisAutoScale problem in QwtPlot

  1. #1
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    1

    Default axisAutoScale problem in QwtPlot

    I have a custom scaling for the x-axis, and want to have an automatic scaling for the y-axis. It seems like a customized x-axis scale disables the axisAutoScale(QwtPlot::yLeft) somehow. Is there an easy fix to this problem?

    best regards

  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: axisAutoScale problem in QwtPlot

    There is nothing to fix - setting a scale for one axis doesn't disable autoscaling for other axes.

    Uwe

  3. #3
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    1

    Default Re: axisAutoScale problem in QwtPlot

    The autoscaling works in the very beginning of the simulation, but after that it just keeps the new fixed scale. I've tried to run the autoscale in a loop, but it doesnt seem to be working. Is it in theory enough to set the autoscaling options in the constructor, or is it necessary to manually run the autoscaling function in a loop?

  4. #4
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    1

    Default Re: axisAutoScale problem in QwtPlot

    Why does line 71 only work on the first iteration? The autoscaling is performed just once in the beginning, and then it stays frozen in that position.


    Qt Code:
    1. #ifndef NEWPLOT_H
    2. #define NEWPLOT_H
    3.  
    4. #include <cmath>
    5. #include <QtGui/QDialog>
    6. #include "qwt_plot.h"
    7. #include <qwt_plot_curve.h>
    8. #include <QTimer>
    9. #include <qwt_plot_grid.h>
    10. #include <qwt_plot_panner.h>
    11. #include <QString>
    12.  
    13.  
    14. class newplot : public QwtPlot
    15. {
    16. Q_OBJECT
    17.  
    18. public:
    19. newplot(QWidget *parent = 0):m_curve(NULL)
    20.  
    21. {
    22. m_time = 0;
    23. for (int i = 0; i < 1000; i++)
    24. {
    25. m_x[i] = 0;
    26. m_y[i] = 0.0;
    27.  
    28. }
    29. this->setTitle("Winch 1");
    30. this->setAxisTitle(QwtPlot::xBottom, "Time/seconds");
    31. this->setAxisTitle(QwtPlot::yLeft, "Force [N]");
    32. //this->axisAutoScale(QwtPlot::yLeft);
    33.  
    34. this->setAutoReplot(true);
    35. timeFrame = 10;
    36. }
    37.  
    38. void appendData( double x, double y){
    39.  
    40. memmove(m_y, &m_y[1], 999 * sizeof(double));
    41. memmove(m_x, &m_x[1], 999 * sizeof(double));
    42.  
    43. m_y[999] = y;
    44. m_x[999] = x;
    45. }
    46.  
    47.  
    48. private slots:
    49.  
    50.  
    51. void TimeFrame( const QString &mystring)
    52. {
    53. timeFrame =mystring.toDouble();
    54.  
    55. }
    56.  
    57.  
    58. void draw()
    59. {
    60.  
    61. if (!m_curve)
    62. {
    63. m_curve = new QwtPlotCurve();
    64. m_curve->setPen(QPen(QColor::fromRgb(255, 0, 0), 3));
    65. m_curve->setRawSamples(m_x, m_y, 1000);
    66. m_curve->attach(this);
    67. }
    68.  
    69. //this->setAxisScale(QwtPlot::yLeft, -100, 100);
    70. this->setAxisScale(QwtPlot::xBottom, m_x[999]-timeFrame, m_x[999]); // auto replots
    71. this->axisAutoScale(QwtPlot::yLeft);
    72. this->replot();
    73.  
    74.  
    75. // Grid
    76.  
    77. //QwtPlotGrid *grid = new QwtPlotGrid;
    78. //grid->enableXMin(true);
    79. //grid->enableYMin(true);
    80. //grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
    81. //grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
    82. //grid->attach(this);
    83.  
    84. //QwtPlotPanner* megaPanner = new QwtPlotPanner(this->canvas());
    85. //megaPanner->setMouseButton(Qt::RightButton);
    86. //megaPanner->setAxisEnabled(QwtPlot::xBottom, false);
    87.  
    88. }
    89.  
    90. private:
    91. QwtPlotCurve *m_curve;
    92. int m_time;
    93. double m_x[1000];
    94. double m_y[1000];
    95. double timeFrame;
    96. };
    97.  
    98. #endif // NEWPLOT_H
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    1

    Default Re: axisAutoScale problem in QwtPlot

    Bump. I could really use some help here. See something fishy in my code?

  6. #6
    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: axisAutoScale problem in QwtPlot

    Quote Originally Posted by abraxas View Post
    Why does line 71 only work on the first iteration?
    Line 71 does nothing beside calling a getter. Call QwtPlot::setAxisAutoScale() instead.

    Uwe

Similar Threads

  1. QwtPlot + UI problem
    By petromp in forum Qwt
    Replies: 3
    Last Post: 5th April 2012, 21:35
  2. AxisAutoScale is not working
    By P@u1 in forum Qwt
    Replies: 4
    Last Post: 6th July 2011, 11:13
  3. QWTPLOT problem
    By umulingu in forum Qwt
    Replies: 5
    Last Post: 25th August 2009, 16:34
  4. Problem regarding QWTPLOT
    By sudheer168 in forum Qwt
    Replies: 1
    Last Post: 6th January 2009, 14:18
  5. Problem with QwtPlot
    By sudheer168 in forum Qwt
    Replies: 1
    Last Post: 11th September 2008, 09:04

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.