RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
basicplot.cpp
Go to the documentation of this file.
1 #include "basicplot.h"
2 #include <qwt_plot_canvas.h>
3 #include <qwt_plot_grid.h>
4 #include <qwt_plot_layout.h>
5 #include <stdlib.h>
6 
7 BasicPlot::BasicPlot(QWidget* parent)
8  : QwtPlot(parent)
9 {
10  setFrameStyle(QFrame::NoFrame);
11  setLineWidth(0);
12  QFrame(canvas()).setLineWidth(2);
13  plotLayout()->setAlignCanvasToScales(true);
14  QwtPlotGrid* grid = new QwtPlotGrid;
15  grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
16  grid->attach(this);
17  setCanvasBackground(QColor(29, 100, 141)); // nice blue
18 
19  // enable zooming
20  Zoomer* zoomer = new Zoomer(canvas());
21  zoomer->setRubberBandPen(QPen(Qt::white, 2, Qt::DotLine));
22  zoomer->setTrackerPen(QPen(Qt::white));
23  QObject::connect(this, SIGNAL(setNewBase(QwtScaleDiv*, QwtScaleDiv*)), zoomer,
24  SLOT(setNewBase(QwtScaleDiv*, QwtScaleDiv*)));
25 }
26 
27 void
28 BasicPlot::setAxes(double xmin, double xmax, double ymin, double ymax)
29 {
30  setAxisScale(xBottom, xmin, xmax);
31  setAxisScale(yLeft, ymin, ymax);
32  replot();
33  // set zoomer to new axes limits
34  QwtScaleDiv* bottom = new QwtScaleDiv;
35  *bottom = axisScaleDiv(QwtPlot::xBottom);
36  QwtScaleDiv* left = new QwtScaleDiv;
37  *left = axisScaleDiv(QwtPlot::yLeft);
38  // emit setNewBase(&axisScaleDiv(QwtPlot::xBottom),
39  // &axisScaleDiv(QwtPlot::yLeft));
40  setNewBase(bottom, left);
41 }
42 
43 QSize
45 {
46  return QSize(540, 400);
47 }
BasicPlot(QWidget *parent)
Definition: basicplot.cpp:7
Zoomer * zoomer
Definition: basicplot.h:59
virtual QSize sizeHint() const
Definition: basicplot.cpp:44
void setNewBase(QwtScaleDiv *xscalediv, QwtScaleDiv *yscalediv)
void setAxes(double xmin, double xmax, double ymin, double ymax)
Definition: basicplot.cpp:28