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 
9 #include <QVTKWidget.h>
10 #include <vtkSmartPointer.h>
11 
12 #include <iostream>
13 #include <vector>
14 
15 #include <vtkXYPlotActor.h>
16 #include <vtkDoubleArray.h>
17 #include <vtkFieldData.h>
18 #include <vtkTextActor.h>
19 #include <vtkRenderer.h>
20 
21 typedef vtkSmartPointer<vtkDoubleArray> array_t;
22 typedef vtkSmartPointer<vtkFieldData> field_t;
23 
24 class QDESIGNER_WIDGET_EXPORT Plot2d : public QVTKWidget
25 {
26  Q_OBJECT
27  Q_CLASSINFO("Author", "Alexander Duda")
28 
29 public:
30  Plot2d(QWidget *parent = NULL);
31  virtual ~Plot2d();
32 
33 public slots:
34  void setTitle(QString title);
35  void setXTitle(QString label);
36  void setYTitle(QString label);
37 
38  void setStyle(int id, QString style);
39  void setColor(int id, int r, int g,int b);
40  void setPlotLabel(int id, QString label);
41  void setNumberOfXLabels(int i);
42  void setNumberOfYLabels(int i);
43  void showLegend(bool on);
44  void autoScroll(bool on);
45 
46  void showPlotPoints(bool on);
47  void showPlotLines(bool on);
48 
49  //not supported by vtk 5.2
50  //void showReferenceXLine(bool on);
51  //void showReferenceYLine(bool on);
52  //void setReferenceXValue(double val);
53  //void setReferenceYValue(double val);
54 
55  void setXValues(int id);
56  void setXRange(double min,double max);
57  void setYRange(double min,double max);
58 
59  void addPoint(int id, double x,double y);
60  void addPoints(int id, const QList<double> &x, const QList<double> &y);
61 
62  void clear(int id);
63 
64  void render();
65 
66  bool isIdValid(int id);
67  void scrollTo(double x, double y);
68 
69 protected:
70  virtual void mouseMoveEvent(QMouseEvent *event);
71 
72 protected:
73  void addPlot(int id);
74  field_t getField(int id);
75 
76 private:
77  vtkSmartPointer<vtkXYPlotActor> plot;
78  std::vector<field_t> field_data;
79  bool auto_scroll;
80  vtkSmartPointer<vtkTextActor> text;
81  vtkSmartPointer<vtkRenderer> renderer;
82 };
83 
84 #endif
85 
vtkSmartPointer< vtkFieldData > field_t
Definition: Plot2d.h:22
Definition: Plot2d.h:14
vtkSmartPointer< vtkDoubleArray > array_t
Definition: Plot2d.h:21