Changeset - 347335d8956f
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 9 years ago 2017-03-13 11:18:26
hy@ozderya.net
fixed wrong x axis scale at startup
2 files changed with 10 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/plot.cpp
Show inline comments
 
@@ -28,8 +28,6 @@
 
#include "plot.h"
 
#include "utils.h"
 

	
 
#include <QtDebug>
 

	
 
static const int SYMBOL_SHOW_AT_WIDTH = 5;
 
static const int SYMBOL_SIZE_MAX = 7;
 

	
 
@@ -96,7 +94,6 @@ void Plot::setYAxis(bool autoScaled, dou
 

	
 
void Plot::setXAxis(double xMin, double xMax)
 
{
 
    qDebug() << "setXAxis:" << xMin << xMax;
 
    _xMin = xMin;
 
    _xMax = xMax;
 

	
 
@@ -104,6 +101,7 @@ void Plot::setXAxis(double xMin, double 
 

	
 
    // set axis
 
    setAxisScale(QwtPlot::xBottom, xMin, xMax);
 
    replot(); // Note: if we don't replot here scale at startup isn't set correctly
 

	
 
    // reset zoom base
 
    auto base = zoomer.zoomBase();
 
@@ -111,10 +109,7 @@ void Plot::setXAxis(double xMin, double 
 
    base.setRight(xMax);
 
    zoomer.setZoomBase(base);
 

	
 
    qDebug() << "base:" << base;
 

	
 
    onXScaleChanged();
 
    replot();
 
}
 

	
 
void Plot::resetAxes()
src/plotmanager.cpp
Show inline comments
 
@@ -17,7 +17,6 @@
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <QtDebug>
 
#include "qwt_symbol.h"
 

	
 
#include "plot.h"
 
@@ -254,6 +253,15 @@ Plot* PlotManager::addPlotWidget()
 
    plot->showDemoIndicator(isDemoShown);
 
    plot->setYAxis(_autoScaled, _yMin, _yMax);
 

	
 
    if (_xAxisAsIndex)
 
    {
 
        plot->setXAxis(0, _numOfSamples);
 
    }
 
    else
 
    {
 
        plot->setXAxis(_xMin, _xMax);
 
    }
 

	
 
    return plot;
 
}
 

	
 
@@ -458,10 +466,8 @@ void PlotManager::onNumOfSamplesChanged(
 
    {
 
        for (auto plot : plotWidgets)
 
        {
 
            // plot->onNumOfSamplesChanged(value);
 
            plot->setXAxis(0, value);
 
        }
 
        qDebug() << "_xAxisAsIndex" << value;
 
    }
 
}
 

	
0 comments (0 inline, 0 general)