RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
basicplot.h
Go to the documentation of this file.
1 /*
2  * BasicPlot, derived from QwtPlot, is the base plot that sets color, grid
3  * lines, and zoom functionality.
4  */
5 
6 #ifndef _BASICPLOT_H_
7 #define _BASICPLOT_H_ 1
8 
9 #include "scrollzoomer.h"
10 #include <qwt_compat.h>
11 #include <qwt_plot.h>
12 #include <qwt_plot_renderer.h>
13 #include <qwt_scale_draw.h>
14 #include <qwt_scale_widget.h>
15 
16 class Zoomer : public ScrollZoomer
17 {
18  Q_OBJECT
19 
20 public:
21  Zoomer(QWidget* canvas)
22  : ScrollZoomer(canvas){};
23 
24  virtual void rescale()
25  {
26  QwtScaleWidget* scaleWidget = plot()->axisWidget(yAxis());
27  QwtScaleDraw* sd = scaleWidget->scaleDraw();
28  int minExtent = 0;
29 
30  if (zoomRectIndex() > 0) {
31  minExtent = sd->spacing() + sd->maxTickLength() + 1;
32  minExtent += sd->labelSize(scaleWidget->font(), 1000).width();
33  }
34  sd->setMinimumExtent(minExtent);
36  };
37 
38 public slots:
39  void setNewBase(QwtScaleDiv* xscalediv, QwtScaleDiv* yscalediv)
40  {
41  setMaxStackDepth(-1);
42  double rleft = xscalediv->lowerBound();
43  double rtop = yscalediv->upperBound();
44  double rheight = yscalediv->lowerBound() - yscalediv->upperBound();
45  double rwidth = xscalediv->upperBound() - xscalediv->lowerBound();
46  QwtDoubleRect boundRect(rleft, rtop, rwidth, rheight);
47  setZoomBase(boundRect);
48  };
49 };
50 
51 class BasicPlot : public QwtPlot
52 {
53  Q_OBJECT
54 
55 public:
56  BasicPlot(QWidget* parent);
57  virtual ~BasicPlot(){};
58  virtual QSize sizeHint() const;
60 
61 signals:
62  void setNewBase(QwtScaleDiv* xscalediv, QwtScaleDiv* yscalediv);
63 
64 public slots:
65  void setAxes(double xmin, double xmax, double ymin, double ymax);
66 
67 private:
68 };
69 
70 #endif // _BasicPlot_H_
BasicPlot(QWidget *parent)
Definition: basicplot.cpp:7
void setNewBase(QwtScaleDiv *xscalediv, QwtScaleDiv *yscalediv)
Definition: basicplot.h:39
virtual void rescale()
Definition: basicplot.h:24
Zoomer * zoomer
Definition: basicplot.h:59
virtual QSize sizeHint() const
Definition: basicplot.cpp:44
virtual void rescale()
void setNewBase(QwtScaleDiv *xscalediv, QwtScaleDiv *yscalediv)
Zoomer(QWidget *canvas)
Definition: basicplot.h:21
virtual ~BasicPlot()
Definition: basicplot.h:57
void setAxes(double xmin, double xmax, double ymin, double ymax)
Definition: basicplot.cpp:28