plotwidget.h
Go to the documentation of this file.
1 #ifndef DragableWidget_H
2 #define DragableWidget_H
3 
4 #include <map>
5 #include <deque>
6 #include <QObject>
7 #include <QTextEdit>
8 #include <QDomDocument>
9 #include <QMessageBox>
10 #include <QTime>
11 #include "plotmagnifier.h"
12 #include "plotzoomer.h"
13 #include "qwt_plot.h"
14 #include "qwt_plot_curve.h"
15 #include "qwt_plot_grid.h"
16 #include "qwt_symbol.h"
17 #include "qwt_legend.h"
18 #include "qwt_plot_rescaler.h"
19 #include "qwt_plot_panner.h"
20 #include "qwt_plot_legenditem.h"
21 #include "timeseries_qwt.h"
22 #include "customtracker.h"
23 #include "axis_limits_dialog.h"
26 #include "plotlegend.h"
27 
28 class PlotWidget : public QwtPlot
29 {
30  Q_OBJECT
31 
32 public:
33 
34  PlotWidget(PlotDataMapRef& datamap, QWidget *parent=nullptr);
35 
36  virtual ~PlotWidget() override;
37 
38  bool isEmpty() const;
39 
40  const std::map<std::string, QwtPlotCurve*> &curveList() const;
41 
42  QDomElement xmlSaveState(QDomDocument &doc) const;
43 
44  bool xmlLoadState(QDomElement &element);
45 
46  PlotData::RangeTime getMaximumRangeX() const;
47 
48  PlotData::RangeValue getMaximumRangeY(PlotData::RangeTime range_X) const;
49 
50  void setZoomRectangle( QRectF rect, bool emit_signal );
51 
52  void reloadPlotData( );
53 
54  void changeAxisX(QString curve_name);
55 
56  bool isXYPlot() const;
57 
58  void changeBackgroundColor(QColor color);
59 
60  const PlotLegend* legend() const { return _legend; }
61 
62  void setLegendSize(int size);
63 
64  bool isLegendVisible() const;
65 
66  void setLegendAlignment( Qt::Alignment alignment );
67 
68  void setZoomEnabled(bool enabled);
69 
70  bool isZoomEnabled() const;
71 
72  QRectF canvasBoundingRect() const;
73 
74  virtual void resizeEvent( QResizeEvent *ev ) override;
75 
76  virtual void updateLayout() override;
77 
78  void setConstantRatioXY(bool active);
79 
80 protected:
81  void dragEnterEvent(QDragEnterEvent *event) override;
82  void dropEvent(QDropEvent *event) override;
83  bool eventFilter(QObject *obj, QEvent *event) override;
84  void dragLeaveEvent(QDragLeaveEvent *event) override;
85 
86  bool canvasEventFilter(QEvent *event);
87 
88 signals:
89  void swapWidgetsRequested(PlotWidget* source, PlotWidget* destination);
90  void rectChanged(PlotWidget* self, QRectF rect );
91  void undoableChange();
92  void trackerMoved(QPointF pos);
93  void curveListChanged();
94  void curvesDropped();
95  void legendSizeChanged(int new_size);
96 
97 public slots:
98 
99  void replot() override;
100 
101  void updateCurves();
102 
103  void detachAllCurves();
104 
105  void on_panned(int dx, int dy);
106 
107  void zoomOut(bool emit_signal);
108 
109  void on_zoomOutHorizontal_triggered(bool emit_signal = true);
110 
111  void on_zoomOutVertical_triggered(bool emit_signal = true);
112 
113  void removeCurve(const std::string &name);
114 
115  void activateLegend(bool activate);
116 
117  void activateGrid(bool activate);
118 
120 
121  void enableTracker(bool enable);
122 
123  void setTrackerPosition(double abs_time);
124 
125  void on_changeTimeOffset(double offset);
126 
127  void on_changeDateTimeScale(bool enable);
128 
129 private slots:
130 
131  void on_changeToBuiltinTransforms(QString new_transform);
132 
133  void on_convertToXY_triggered(bool checked);
134 
136 
137  void on_savePlotToFile();
138 
140 
141 private slots:
143 
144  void canvasContextMenuTriggered(const QPoint &pos);
145 
147 
148  void on_changeColor(QString curve_name, QColor new_color);
149 
151 
152  void on_externallyResized(const QRectF &new_rect);
153 
154 private:
155 
156  std::map<std::string, QwtPlotCurve* > _curve_list;
157  std::map<std::string, QwtPlotMarker*> _point_marker;
158 
169  QAction *_action_phaseXY;
173 
178 
182 
184 
187  std::map<std::string, QString> _curves_transform;
188 
189  struct DragInfo{
191  std::vector<QString> curves;
192  QObject* source;
193  };
194 
196 
197  bool addCurve(const std::string &name);
198 
199  void buildActions();
200 
201  void buildLegend();
202 
204 
206 
207  void setDefaultRangeX();
208 
209  DataSeriesBase* createSeriesData(const QString& ID, const PlotData *data);
210 
211  double _time_offset;
212 
213  const PlotData* _axisX = nullptr;
214 
216 
218 
220 
222 
224 
226 
228 
229  void transformCustomCurves();
230  void updateMaximumZoomArea();
232 };
233 
234 #endif
void setConstantRatioXY(bool active)
Definition: plotwidget.cpp:936
void launchRemoveCurveDialog()
CurveTracker * _tracker
Definition: plotwidget.h:179
std::map< std::string, QwtPlotMarker * > _point_marker
Definition: plotwidget.h:157
PlotData::RangeValue _custom_Y_limits
Definition: plotwidget.h:215
void on_savePlotToFile()
void on_panned(int dx, int dy)
Definition: plotwidget.cpp:614
void on_changeToBuiltinTransforms(QString new_transform)
void updateMaximumZoomArea()
Definition: plotwidget.cpp:831
void replot() override
QAction * _action_changeColorsDialog
Definition: plotwidget.h:161
void setLegendSize(int size)
QDomElement xmlSaveState(QDomDocument &doc) const
Definition: plotwidget.cpp:619
void on_convertToXY_triggered(bool checked)
QAction * _action_removeAllCurves
Definition: plotwidget.h:160
PlotLegend * _legend
Definition: plotwidget.h:180
PlotData::RangeTime getMaximumRangeX() const
const std::map< std::string, QwtPlotCurve * > & curveList() const
Definition: plotwidget.cpp:478
void rectChanged(PlotWidget *self, QRectF rect)
std::map< std::string, QwtPlotCurve * > _curve_list
Definition: plotwidget.h:156
std::map< QString, SnippetData > SnippetsMap
DragInfo _dragging
Definition: plotwidget.h:195
void on_changeDateTimeScale(bool enable)
bool isXYPlot() const
QAction * _action_showPoints
Definition: plotwidget.h:162
PlotDataMapRef & _mapped_data
Definition: plotwidget.h:185
void on_externallyResized(const QRectF &new_rect)
void undoableChange()
void legendSizeChanged(int new_size)
void detachAllCurves()
Definition: plotwidget.cpp:593
QRectF canvasBoundingRect() const
Definition: plotwidget.cpp:821
SnippetsMap _snippets
Definition: plotwidget.h:221
bool _use_date_time_scale
Definition: plotwidget.h:183
QwtPlotPanner * _panner2
Definition: plotwidget.h:177
void swapWidgetsRequested(PlotWidget *source, PlotWidget *destination)
PlotMagnifier * _magnifier
Definition: plotwidget.h:175
PlotWidget(PlotDataMapRef &datamap, QWidget *parent=nullptr)
Definition: plotwidget.cpp:64
void on_customTransformsDialog()
double _time_offset
Definition: plotwidget.h:211
bool isLegendVisible() const
void activateLegend(bool activate)
PlotZoomer * _zoomer
Definition: plotwidget.h:174
bool isEmpty() const
Definition: plotwidget.cpp:473
A 2-D plotting widget.
Definition: qwt_plot.h:74
AxisLimitsDialog * _axis_limits_dialog
Definition: plotwidget.h:217
virtual bool event(QEvent *)
Adds handling of layout requests.
Definition: qwt_plot.cpp:241
DataSeriesBase * createSeriesData(const QString &ID, const PlotData *data)
void trackerMoved(QPointF pos)
enum PlotWidget::DragInfo::@3 mode
bool isZoomEnabled() const
void reloadPlotData()
Definition: plotwidget.cpp:980
const PlotData * _axisX
Definition: plotwidget.h:213
QwtPlotPanner * _panner1
Definition: plotwidget.h:176
void updateCurves()
void zoomOut(bool emit_signal)
QAction * _action_custom_transform
Definition: plotwidget.h:170
const PlotLegend * legend() const
Definition: plotwidget.h:60
void on_showPoints_triggered()
void curvesDropped()
QAction * _action_zoomOutVertically
Definition: plotwidget.h:165
QAction * _action_zoomOutMaximum
Definition: plotwidget.h:163
QAction * _action_2ndDerivativeTransform
Definition: plotwidget.h:168
QRectF _max_zoom_rect
Definition: plotwidget.h:227
void dropEvent(QDropEvent *event) override
Definition: plotwidget.cpp:543
QAction * _action_removeCurve
Definition: plotwidget.h:159
A class which draws a coordinate grid.
Definition: qwt_plot_grid.h:34
bool canvasEventFilter(QEvent *event)
virtual void updateLayout() override
Adjust plot content to its current size.
Definition: plotwidget.cpp:930
void changeAxisX(QString curve_name)
void configureTracker(CurveTracker::Parameter val)
QString _default_transform
Definition: plotwidget.h:186
void on_zoomOutVertical_triggered(bool emit_signal=true)
QAction * _action_phaseXY
Definition: plotwidget.h:169
virtual void resizeEvent(QResizeEvent *ev) override
Definition: plotwidget.cpp:919
QwtPlotGrid * _grid
Definition: plotwidget.h:181
void rescaleEqualAxisScaling()
Definition: plotwidget.cpp:874
bool addCurve(const std::string &name)
Definition: plotwidget.cpp:366
char name[1]
QAction * _action_editLimits
Definition: plotwidget.h:172
void curveListChanged()
QwtPlotCurve::CurveStyle _curve_style
Definition: plotwidget.h:205
void on_changeColor(QString curve_name, QColor new_color)
bool xmlLoadState(QDomElement &element)
Definition: plotwidget.cpp:674
void changeBackgroundColor(QColor color)
void on_zoomOutHorizontal_triggered(bool emit_signal=true)
bool eventFilter(QObject *obj, QEvent *event) override
Event filter.
QAction * _action_1stDerivativeTransform
Definition: plotwidget.h:167
uintptr_t size
PlotData::RangeValue getMaximumRangeY(PlotData::RangeTime range_X) const
TransformSelector * _transform_select_dialog
Definition: plotwidget.h:219
void buildActions()
Definition: plotwidget.cpp:164
virtual ~PlotWidget() override
Definition: plotwidget.cpp:361
bool _zoom_enabled
Definition: plotwidget.h:223
void setTrackerPosition(double abs_time)
void setZoomEnabled(bool enabled)
QAction * _action_saveToFile
Definition: plotwidget.h:171
QwtPlotPanner provides panning of a plot canvas.
bool _keep_aspect_ratio
Definition: plotwidget.h:225
void on_changeTimeOffset(double offset)
void setLegendAlignment(Qt::Alignment alignment)
void on_changeColorsDialog_triggered()
std::map< std::string, QString > _curves_transform
Definition: plotwidget.h:187
std::vector< QString > curves
Definition: plotwidget.h:191
void setDefaultRangeX()
void transformCustomCurves()
void on_editAxisLimits_triggered()
void setZoomRectangle(QRectF rect, bool emit_signal)
Definition: plotwidget.cpp:949
void updateAvailableTransformers()
void activateGrid(bool activate)
void removeCurve(const std::string &name)
Definition: plotwidget.cpp:426
void buildLegend()
Definition: plotwidget.cpp:330
QAction * _action_zoomOutHorizontally
Definition: plotwidget.h:164
void enableTracker(bool enable)
void dragEnterEvent(QDragEnterEvent *event) override
Definition: plotwidget.cpp:483
QAction * _action_noTransform
Definition: plotwidget.h:166
void dragLeaveEvent(QDragLeaveEvent *event) override
Definition: plotwidget.cpp:528
void canvasContextMenuTriggered(const QPoint &pos)
Definition: plotwidget.cpp:286


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17