Changeset - 4eb864cd3280
[Not reviewed]
scalezoomer
0 5 2
Hasan Yavuz ÖZDERYA - 10 years ago 2015-08-26 09:57:36
hy@ozderya.net
implemented bottom scale zooming
7 files changed with 115 insertions and 6 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -64,6 +64,7 @@ add_executable(${PROGRAM_NAME} WIN32
 
  hidabletabwidget.cpp
 
  framebuffer.cpp
 
  scalepicker.cpp
 
  scalezoomer.cpp
 
  ${UI_FILES}
 
  misc/windows_icon.rc
 
  )
plot.cpp
Show inline comments
 
@@ -22,7 +22,7 @@
 
Plot::Plot(QWidget* parent) :
 
    QwtPlot(parent),
 
    zoomer(this->canvas(), false),
 
    scalePicker(this->axisWidget(QwtPlot::xBottom))
 
    sZoomer(this, &zoomer)
 
{
 
    isAutoScaled = false;
 

	
plot.h
Show inline comments
 
@@ -23,7 +23,7 @@
 
#include <qwt_plot.h>
 
#include <qwt_plot_grid.h>
 
#include "zoomer.h"
 
#include "scalepicker.h"
 
#include "scalezoomer.h"
 

	
 
class Plot : public QwtPlot
 
{
 
@@ -37,8 +37,8 @@ private:
 
    bool isAutoScaled;
 
    double yMin, yMax;
 
    Zoomer zoomer;
 
    ScaleZoomer sZoomer;
 
    QwtPlotGrid grid;
 
    ScalePicker scalePicker;
 

	
 
    void resetAxes();
 

	
scalepicker.cpp
Show inline comments
 
@@ -53,7 +53,6 @@ bool ScalePicker::eventFilter(QObject* o
 
        {
 
            if (started)
 
            {
 
                qDebug() << "Picking:" << firstPos << pos;
 
                emit picking(firstPos, pos);
 
            }
 
        }
scalezoomer.cpp
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <QRectF>
 
#include <QtDebug>
 
#include "scalezoomer.h"
 

	
 
ScaleZoomer::ScaleZoomer(QwtPlot* plot, QwtPlotZoomer* zoomer) :
 
    QObject(plot),
 
    bottomPicker(plot->axisWidget(QwtPlot::xBottom)),
 
    leftPicker(plot->axisWidget(QwtPlot::yLeft))
 
{
 
    _plot = plot;
 
    _zoomer = zoomer;
 
    connect(&bottomPicker, &ScalePicker::picked, this, &ScaleZoomer::bottomPicked);
 
    connect(&leftPicker, &ScalePicker::picked, this, &ScaleZoomer::leftPicked);
 
}
 

	
 
void ScaleZoomer::bottomPicked(double firstPos, double lastPos)
 
{
 
    QRectF zRect;
 
    if (lastPos > firstPos)
 
    {
 
        zRect.setLeft(firstPos);
 
        zRect.setRight(lastPos);
 
    }
 
    else
 
    {
 
        zRect.setLeft(lastPos);
 
        zRect.setRight(firstPos);
 
    }
 

	
 
    zRect.setBottom(_plot->axisScaleDiv(QwtPlot::yLeft).lowerBound());
 
    zRect.setTop(_plot->axisScaleDiv(QwtPlot::yLeft).upperBound());
 
    _zoomer->zoom(zRect);
 
}
 

	
 
void ScaleZoomer::leftPicked(double firstPos, double lastPos)
 
{
 

	
 
}
scalezoomer.h
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef SCALEZOOMER_H
 
#define SCALEZOOMER_H
 

	
 
#include <QObject>
 
#include <qwt_plot.h>
 
#include <qwt_plot_zoomer.h>
 

	
 
#include "scalepicker.h"
 

	
 
class ScaleZoomer : public QObject
 
{
 
    Q_OBJECT
 

	
 
public:
 
    ScaleZoomer(QwtPlot*, QwtPlotZoomer*);
 

	
 
private:
 
    QwtPlot* _plot;
 
    QwtPlotZoomer* _zoomer;
 
    ScalePicker bottomPicker;
 
    ScalePicker leftPicker;
 

	
 

	
 
private slots:
 
    void bottomPicked(double firstPos, double lastPos);
 
    void leftPicked(double firstPos, double lastPos);
 
};
 

	
 
#endif /* SCALEZOOMER_H */
serialplot.pro
Show inline comments
 
@@ -40,7 +40,9 @@ SOURCES += main.cpp\
 
    plot.cpp \
 
    zoomer.cpp \
 
    hidabletabwidget.cpp \
 
    framebuffer.cpp
 
    framebuffer.cpp \
 
    scalepicker.cpp \
 
    scalezoomer.cpp
 

	
 
HEADERS  += mainwindow.h \
 
    utils.h \
 
@@ -50,7 +52,9 @@ HEADERS  += mainwindow.h \
 
    plot.h \
 
    zoomer.h \
 
    hidabletabwidget.h \
 
    framebuffer.h
 
    framebuffer.h \
 
    scalepicker.h \
 
    scalezoomer.h
 

	
 
FORMS    += mainwindow.ui \
 
    about_dialog.ui \
0 comments (0 inline, 0 general)