//mainwindow.cpp
#include "mainwindow.h"
#include <QToolBar>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_marker.h>
#include <qwt_symbol.h>
#include <qwt_plot_zoomer.h>
MainWindow
::MainWindow(QWidget *parent
){
tb->addAction("Zoom1", this, SLOT(zoom1()));
tb->addAction("Zoom2", this, SLOT(zoom2()));
tb->addAction("Zoom3", this, SLOT(zoom3()));
tb->addAction("Zoom4", this, SLOT(zoom4()));
tb->addAction("Zoom5", this, SLOT(zoom5()));
tb->addAction("Zoom6", this, SLOT(zoom6()));
plot->setFixedSize(800, 600);
this->addCurve();
this->addMarkers();
this->zoomer->setZoomBase();;
this->setCentralWidget(this->plot);
}
MainWindow::~MainWindow()
{
}
void MainWindow::zoom1( void )
{
}
void MainWindow::zoom2( void )
{
}
void MainWindow::zoom3( void )
{
}
void MainWindow::zoom4( void )
{
}
void MainWindow::zoom5( void )
{
}
void MainWindow::zoom6( void )
{
}
void MainWindow::addCurve( void )
{
int count = 20000;
for(int i = 0; i < count; ++i)
{
this->x.append(i);
this->y.append(i);
}
curve->setData(this->x.constBegin(), this->y.constBegin(), this->x.size());
curve->attach(this->plot);
}
void MainWindow::addMarkers( void )
{
int count = 5000;
int step = this->x.size()/count;
for(int i = 0; i < count; ++i)
{
int x = i*step;
int y = this->y[x];
m->setValue(x, y);
m
->setLabel
(QString("%1x%2").
arg(x
).
arg(y
));
m->attach(this->plot);
}
}
//mainwindow.cpp
#include "mainwindow.h"
#include <QToolBar>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_marker.h>
#include <qwt_symbol.h>
#include <qwt_plot_zoomer.h>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QToolBar* tb = this->addToolBar("");
tb->addAction("Zoom1", this, SLOT(zoom1()));
tb->addAction("Zoom2", this, SLOT(zoom2()));
tb->addAction("Zoom3", this, SLOT(zoom3()));
tb->addAction("Zoom4", this, SLOT(zoom4()));
tb->addAction("Zoom5", this, SLOT(zoom5()));
tb->addAction("Zoom6", this, SLOT(zoom6()));
this->plot = new QwtPlot(this);
plot->setFixedSize(800, 600);
this->zoomer = new QwtPlotZoomer(this->plot->canvas());
this->addCurve();
this->addMarkers();
this->zoomer->setZoomBase();;
this->setCentralWidget(this->plot);
}
MainWindow::~MainWindow()
{
}
void MainWindow::zoom1( void )
{
this->zoomer->zoom(QRectF(QPointF(7262.49, 7256.79), QSizeF(15.8157, 29.976)));
}
void MainWindow::zoom2( void )
{
this->zoomer->zoom(QRectF(QPointF(11794, 11794.6), QSizeF(12.9803, 12.4409)));
}
void MainWindow::zoom3( void )
{
this->zoomer->zoom(QRectF(QPointF(9975.49, 9973.82), QSizeF(1.379,4.97203)));
}
void MainWindow::zoom4( void )
{
this->zoomer->zoom(QRectF(QPointF(9555.91, 9556.03), QSizeF(0.2, 0.3525673)));
}
void MainWindow::zoom5( void )
{
this->zoomer->zoom(QRectF(QPointF(7931.51, 7931.44), QSizeF(0.951209, 0.998621)));
}
void MainWindow::zoom6( void )
{
this->zoomer->zoom(QRectF(QPointF(3357.88, 15976.8), QSizeF(142.687, 550.418)));
}
void MainWindow::addCurve( void )
{
int count = 20000;
for(int i = 0; i < count; ++i)
{
this->x.append(i);
this->y.append(i);
}
QwtPlotCurve* curve = new QwtPlotCurve();
curve->setData(this->x.constBegin(), this->y.constBegin(), this->x.size());
curve->attach(this->plot);
}
void MainWindow::addMarkers( void )
{
int count = 5000;
int step = this->x.size()/count;
for(int i = 0; i < count; ++i)
{
int x = i*step;
int y = this->y[x];
QwtPlotMarker* m = new QwtPlotMarker();
m->setSymbol(QwtSymbol(QwtSymbol::Ellipse, QBrush(Qt::red), QPen(Qt::red), QSize(5,5)));
m->setValue(x, y);
m->setLabel(QString("%1x%2").arg(x).arg(y));
m->attach(this->plot);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks