rock_widget_collection  0.1
Plot2d.h
Go to the documentation of this file.
1 
2 #ifndef PLOT2D_H
3 #define PLOT2D_H
4 
5 #include <QtCore/QString>
6 #include <QtCore/QList>
7 #include <QtDesigner/QDesignerExportWidget>
8 #include <QtGui/QWidget>
9 
10 #include <iostream>
11 #include <vector>
12 #include "qcustomplot.h"
13 
14 class QDESIGNER_WIDGET_EXPORT Plot2d : public QCustomPlot
15 {
16  Q_OBJECT
17  Q_CLASSINFO("Author", "Alexander Duda")
18 
19 public:
20  Plot2d(QWidget *parent = NULL);
21  virtual ~Plot2d();
22 
23 public slots:
24  QObject *getGraph(int index)const{return graph(index);}
25  QObject *getLegend()const{return legend;}
26  QObject *addGraph(QObject *key_axis,QObject* value_axis)
27  {return QCustomPlot::addGraph(dynamic_cast<QCPAxis*>(key_axis),dynamic_cast<QCPAxis*>(value_axis));}
28  void removeGraph(int index);
29  QObject *getXAxis()const{return xAxis;}
30  QObject *getXAxis2()const{return xAxis2;}
31  QObject *getYAxis()const{return yAxis;}
32  QObject *getYAxis2()const{return yAxis2;}
33 
34  void setZoomAble(bool enabled, int yAxisIndex = 0)
35  {
36  if(yAxisIndex == 0)
37  setRangeDragAxes(xAxis, yAxis);
38  else
39  setRangeDragAxes(xAxis, yAxis2);
40 
41  if(enabled)
42  setRangeDrag(Qt::Horizontal | Qt::Vertical);
43  else setRangeDrag(0);
44  }
45  void setRangeAble(bool enabled, int yAxisIndex = 0)
46  {
47  if(yAxisIndex == 0)
48  setRangeZoomAxes(xAxis, yAxis);
49  else
50  setRangeZoomAxes(xAxis, yAxis2);
51 
52  if(enabled)
53  setRangeZoom(Qt::Horizontal | Qt::Vertical);
54  else setRangeZoom(0);
55  }
56 
57 private:
58  bool auto_scroll;
59 };
60 
61 #endif
62 
QCPGraph * addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0)
void setZoomAble(bool enabled, int yAxisIndex=0)
Definition: Plot2d.h:34
void setRangeAble(bool enabled, int yAxisIndex=0)
Definition: Plot2d.h:45
void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical)
void setRangeDrag(Qt::Orientations orientations)
bool removeGraph(QCPGraph *graph)
QObject * getXAxis() const
Definition: Plot2d.h:29
void setRangeZoom(Qt::Orientations orientations)
QObject * getYAxis2() const
Definition: Plot2d.h:32
The central class which is also the QWidget which displays the plot and interacts with the user...
Definition: qcustomplot.h:895
QObject * addGraph(QObject *key_axis, QObject *value_axis)
Definition: Plot2d.h:26
QObject * getGraph(int index) const
Definition: Plot2d.h:24
QCPAxis * yAxis2
Definition: qcustomplot.h:1006
QCPAxis * xAxis2
Definition: qcustomplot.h:1006
QCPGraph * graph() const
QObject * getLegend() const
Definition: Plot2d.h:25
Definition: Plot2d.h:14
QObject * getXAxis2() const
Definition: Plot2d.h:30
QCPLegend * legend
Definition: qcustomplot.h:1007
QObject * getYAxis() const
Definition: Plot2d.h:31
QCPAxis * xAxis
Definition: qcustomplot.h:1006
QCPAxis * yAxis
Definition: qcustomplot.h:1006
void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical)