plotwidget.h
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
7 #ifndef DragableWidget_H
8 #define DragableWidget_H
9 
10 #include <map>
11 #include <deque>
12 #include <QObject>
13 #include <QTextEdit>
14 #include <QDomDocument>
15 #include <QMessageBox>
16 #include <QTime>
17 
18 #include "qwt_plot.h"
19 #include "qwt_plot_curve.h"
20 #include "qwt_plot_grid.h"
21 #include "qwt_symbol.h"
22 #include "qwt_legend.h"
23 #include "qwt_plot_rescaler.h"
24 #include "qwt_plot_panner.h"
25 #include "qwt_plot_legenditem.h"
26 
28 #include "customtracker.h"
29 #include "colormap_editor.h"
30 
33 
34 #include "plot_background.h"
35 
36 class StatisticsDialog;
37 
38 class PlotWidget : public PlotWidgetBase
39 {
40  Q_OBJECT
41 
42 public:
43  PlotWidget(PlotDataMapRef& datamap, QWidget* parent);
44 
45  void setContextMenuEnabled(bool enabled);
46 
47  virtual ~PlotWidget() override;
48 
49  QDomElement xmlSaveState(QDomDocument& doc) const;
50 
51  bool xmlLoadState(QDomElement& element, bool autozoom = true);
52 
53  Range getVisualizationRangeY(Range range_X) const override;
54 
55  void setZoomRectangle(QRectF rect, bool emit_signal);
56 
57  void reloadPlotData();
58 
59  double timeOffset() const
60  {
61  return _time_offset;
62  }
63 
65  {
66  return _mapped_data;
67  }
68 
69  CurveInfo* addCurveXY(std::string name_x, std::string name_y, QString curve_name = "");
70 
71  CurveInfo* addCurve(const std::string& name, QColor color = Qt::transparent);
72 
73  void setCustomAxisLimits(Range range);
74 
75  Range customAxisLimit() const;
76 
77  void removeCurve(const QString& title) override;
78 
79  bool isZoomLinkEnabled() const;
80 
81  void setStatisticsTitle(QString title);
82 
83  void updateStatistics(bool forceUpdate = false);
84 
85 protected:
87 
88  bool eventFilter(QObject* obj, QEvent* event) override;
89  void onDragEnterEvent(QDragEnterEvent* event);
90  void onDragLeaveEvent(QDragLeaveEvent* event);
91  void onDropEvent(QDropEvent* event);
92 
93  bool canvasEventFilter(QEvent* event);
94 
95 signals:
96  void swapWidgetsRequested(PlotWidget* source, PlotWidget* destination);
97  void rectChanged(PlotWidget* self, QRectF rect);
98  void undoableChange();
99  void trackerMoved(QPointF pos);
100  void curveListChanged();
101  void curvesDropped();
102  void splitHorizontal();
103  void splitVertical();
104 
105 public slots:
106 
107  void updateCurves(bool reset_older_data);
108 
109  void onDataSourceRemoved(const std::string& src_name);
110 
111  void removeAllCurves() override;
112 
113  void on_panned(int dx, int dy);
114 
115  void zoomOut(bool emit_signal);
116 
117  void on_zoomOutHorizontal_triggered(bool emit_signal = true);
118 
119  void on_zoomOutVertical_triggered(bool emit_signal = true);
120 
121  void activateLegend(bool activate);
122 
123  void activateGrid(bool activate);
124 
126 
127  void enableTracker(bool enable);
128 
129  bool isTrackerEnabled() const;
130 
131  void setTrackerPosition(double abs_time);
132 
133  void on_changeTimeOffset(double offset);
134 
135  void on_changeDateTimeScale(bool enable);
136 
137  void on_changeCurveColor(const QString& curve_name, QColor new_color);
138 
139  void onFlipAxis();
140 
141  void onBackgroundColorRequest(QString name);
142 
143  void onShowDataStatistics();
144 
145 private slots:
146 
147  // void on_changeToBuiltinTransforms(QString new_transform);
148 
149  void setModeXY(bool enable) override;
150 
151  void on_savePlotToFile();
152 
153  void on_copyToClipboard();
154 
156 
158 
159 private slots:
160 
161  void canvasContextMenuTriggered(const QPoint& pos);
162 
163  void on_externallyResized(const QRectF& new_rect);
164 
165 private:
167  QAction* _action_edit;
168  QAction* _action_formula;
172 
177  QAction* _action_copy;
178  QAction* _action_paste;
180 
181  QAction* _flip_x;
182  QAction* _flip_y;
183 
186 
188 
189  std::unique_ptr<BackgroundColorItem> _background_item;
190 
192 
194 
195  struct DragInfo
196  {
197  enum
198  {
202  } mode;
203  std::vector<QString> curves;
204  QObject* source;
205  };
206 
208 
209  void buildActions();
210 
212 
213  void setDefaultRangeX();
214 
215  QwtSeriesWrapper* createCurveXY(const PlotData* data_x, const PlotData* data_y);
216 
218  const QString& transform_ID = {}) override;
219 
220  double _time_offset;
221 
223 
225 
227 
229 
230  // void updateMaximumZoomArea();
232  void overrideCursonMove();
233 
234  void setAxisScale(QwtAxisId axisId, double min, double max);
235 };
236 
237 #endif
PlotWidget::_action_zoomOutVertically
QAction * _action_zoomOutVertically
Definition: plotwidget.h:175
PlotWidget::_action_zoomOutMaximum
QAction * _action_zoomOutMaximum
Definition: plotwidget.h:173
PlotWidget::canvasEventFilter
bool canvasEventFilter(QEvent *event)
Definition: plotwidget.cpp:1608
color
color
Definition: color.h:16
PlotWidget::_action_image_to_clipboard
QAction * _action_image_to_clipboard
Definition: plotwidget.h:179
PlotWidget::on_zoomOutVertical_triggered
void on_zoomOutVertical_triggered(bool emit_signal=true)
Definition: plotwidget.cpp:1344
PlotWidget::_action_copy
QAction * _action_copy
Definition: plotwidget.h:177
PlotWidget::createCurveXY
QwtSeriesWrapper * createCurveXY(const PlotData *data_x, const PlotData *data_y)
Definition: plotwidget.cpp:1717
PlotWidget::_action_split_vertical
QAction * _action_split_vertical
Definition: plotwidget.h:170
PJ::TimeseriesBase
Definition: timeseries.h:16
PlotWidget::removeAllCurves
void removeAllCurves() override
Definition: plotwidget.cpp:461
QwtSeriesWrapper
Definition: timeseries_qwt.h:17
TransformSelector
Definition: transform_selector.h:11
PlotWidget::configureTracker
void configureTracker(CurveTracker::Parameter val)
Definition: plotwidget.cpp:1036
PlotWidget::_transform_select_dialog
TransformSelector * _transform_select_dialog
Definition: plotwidget.h:224
PlotWidget::_grid
QwtPlotGrid * _grid
Definition: plotwidget.h:185
PlotWidget::rescaleEqualAxisScaling
void rescaleEqualAxisScaling()
Definition: plotwidget.cpp:935
PlotWidget::onDropEvent
void onDropEvent(QDropEvent *event)
Definition: plotwidget.cpp:532
PlotWidget::on_copyToClipboard
void on_copyToClipboard()
Definition: plotwidget.cpp:1485
PlotWidget::curveListChanged
void curveListChanged()
PlotWidget::DragInfo::mode
enum PlotWidget::DragInfo::@33 mode
PlotWidget::customAxisLimit
Range customAxisLimit() const
Definition: plotwidget.cpp:1480
PlotWidget::eventFilter
bool eventFilter(QObject *obj, QEvent *event) override
Definition: plotwidget.cpp:1548
PlotWidget::on_zoomOutHorizontal_triggered
void on_zoomOutHorizontal_triggered(bool emit_signal=true)
Definition: plotwidget.cpp:1333
QwtPlotGrid
A class which draws a coordinate grid.
Definition: qwt_plot_grid.h:33
PlotWidget::setContextMenuEnabled
void setContextMenuEnabled(bool enabled)
Definition: plotwidget.cpp:139
PlotWidget::~PlotWidget
virtual ~PlotWidget() override
Definition: plotwidget.cpp:124
PlotWidget::setModeXY
void setModeXY(bool enable) override
Definition: plotwidget.cpp:1355
PlotWidget::buildActions
void buildActions()
Definition: plotwidget.cpp:144
PlotWidget::_action_paste
QAction * _action_paste
Definition: plotwidget.h:178
PlotWidget::splitHorizontal
void splitHorizontal()
PlotWidget::setDefaultRangeX
void setDefaultRangeX()
Definition: plotwidget.cpp:1692
PlotWidget::setTrackerPosition
void setTrackerPosition(double abs_time)
Definition: plotwidget.cpp:1051
PlotWidget::_action_saveToFile
QAction * _action_saveToFile
Definition: plotwidget.h:176
transform_selector.h
PlotWidget::on_changeTimeOffset
void on_changeTimeOffset(double offset)
Definition: plotwidget.cpp:1074
PlotWidget::onDataSourceRemoved
void onDataSourceRemoved(const std::string &src_name)
Definition: plotwidget.cpp:425
PlotWidget::onBackgroundColorRequest
void onBackgroundColorRequest(QString name)
Definition: plotwidget.cpp:1216
PlotWidget::updateAvailableTransformers
void updateAvailableTransformers()
Definition: plotwidget.cpp:1383
qwt_symbol.h
qwt_plot_legenditem.h
plotwidget_base.h
PlotWidget::activateGrid
void activateGrid(bool activate)
Definition: plotwidget.cpp:1027
PlotWidget
Definition: plotwidget.h:38
PlotWidget::on_copyAction_triggered
void on_copyAction_triggered()
Definition: plotwidget.cpp:1512
PlotWidget::DragInfo::CURVES
@ CURVES
Definition: plotwidget.h:200
PlotWidget::_statistics_dialog
StatisticsDialog * _statistics_dialog
Definition: plotwidget.h:193
PlotWidget::_action_zoomOutHorizontally
QAction * _action_zoomOutHorizontally
Definition: plotwidget.h:174
PlotWidget::_action_split_horizontal
QAction * _action_split_horizontal
Definition: plotwidget.h:169
colormap_editor.h
PlotWidget::setZoomRectangle
void setZoomRectangle(QRectF rect, bool emit_signal)
Definition: plotwidget.cpp:964
PlotWidget::updateCurves
void updateCurves(bool reset_older_data)
Definition: plotwidget.cpp:1150
PlotWidget::addCurve
CurveInfo * addCurve(const std::string &name, QColor color=Qt::transparent)
Definition: plotwidget.cpp:393
custom_function.h
PlotWidget::isZoomLinkEnabled
bool isZoomLinkEnabled() const
Definition: plotwidget.cpp:1595
PlotWidget::DragInfo
Definition: plotwidget.h:195
PlotWidget::on_changeCurveColor
void on_changeCurveColor(const QString &curve_name, QColor new_color)
Definition: plotwidget.cpp:1174
PlotWidget::datamap
PlotDataMapRef & datamap()
Definition: plotwidget.h:64
PlotWidget::onDragLeaveEvent
void onDragLeaveEvent(QDragLeaveEvent *event)
Definition: plotwidget.cpp:526
PlotWidget::enableTracker
void enableTracker(bool enable)
Definition: plotwidget.cpp:1041
PlotWidget::_tracker
CurveTracker * _tracker
Definition: plotwidget.h:184
PlotWidget::on_savePlotToFile
void on_savePlotToFile()
Definition: plotwidget.cpp:1394
StatisticsDialog
Definition: statistics_dialog.h:28
PlotWidget::on_panned
void on_panned(int dx, int dy)
Definition: plotwidget.cpp:632
PlotWidget::canvasContextMenuTriggered
void canvasContextMenuTriggered(const QPoint &pos)
Definition: plotwidget.cpp:230
PlotWidget::addCurveXY
CurveInfo * addCurveXY(std::string name_x, std::string name_y, QString curve_name="")
Definition: plotwidget.cpp:296
qwt_plot_rescaler.h
CurveTracker
Definition: customtracker.h:18
PlotWidget::updateStatistics
void updateStatistics(bool forceUpdate=false)
Definition: plotwidget.cpp:1162
PlotWidget::DragInfo::NONE
@ NONE
Definition: plotwidget.h:199
PlotWidget::_action_removeAllCurves
QAction * _action_removeAllCurves
Definition: plotwidget.h:166
plot_background.h
PlotWidget::onShowDataStatistics
void onShowDataStatistics()
Definition: plotwidget.cpp:1275
PlotWidget::DragInfo::source
QObject * source
Definition: plotwidget.h:204
sol::meta::enable
std::enable_if_t< all< Args... >::value, enable_t > enable
Definition: sol.hpp:2244
PlotWidget::xmlLoadState
bool xmlLoadState(QDomElement &element, bool autozoom=true)
Definition: plotwidget.cpp:731
PlotWidget::onDragEnterEvent
void onDragEnterEvent(QDragEnterEvent *event)
Definition: plotwidget.cpp:470
PlotWidget::_dragging
DragInfo _dragging
Definition: plotwidget.h:207
qwt_legend.h
source
const char * source
Definition: lz4.h:767
QwtAxisId
int QwtAxisId
Axis identifier.
Definition: qwt_axis_id.h:26
PlotWidget::PlotWidget
PlotWidget(PlotDataMapRef &datamap, QWidget *parent)
Definition: plotwidget.cpp:74
PlotWidget::onFlipAxis
void onFlipAxis()
Definition: plotwidget.cpp:1191
PJ::Range
Definition: plotdatabase.h:24
PlotWidget::on_changeDateTimeScale
void on_changeDateTimeScale(bool enable)
Definition: plotwidget.cpp:1099
PlotWidget::_mapped_data
PlotDataMapRef & _mapped_data
Definition: plotwidget.h:86
PlotWidget::on_externallyResized
void on_externallyResized(const QRectF &new_rect)
Definition: plotwidget.cpp:1305
PlotWidget::undoableChange
void undoableChange()
PlotWidget::_statistics_window_title
QString _statistics_window_title
Definition: plotwidget.h:187
PlotWidget::_snippets
SnippetsMap _snippets
Definition: plotwidget.h:226
PlotWidget::getVisualizationRangeY
Range getVisualizationRangeY(Range range_X) const override
Definition: plotwidget.cpp:1122
PlotWidget::_use_date_time_scale
bool _use_date_time_scale
Definition: plotwidget.h:191
PlotWidget::setAxisScale
void setAxisScale(QwtAxisId axisId, double min, double max)
Definition: plotwidget.cpp:1575
PlotWidget::rectChanged
void rectChanged(PlotWidget *self, QRectF rect)
PlotWidget::swapWidgetsRequested
void swapWidgetsRequested(PlotWidget *source, PlotWidget *destination)
PlotWidget::_flip_y
QAction * _flip_y
Definition: plotwidget.h:182
PlotWidget::on_pasteAction_triggered
void on_pasteAction_triggered()
Definition: plotwidget.cpp:1524
PlotWidgetBase
PlotWidget::_action_data_statistics
QAction * _action_data_statistics
Definition: plotwidget.h:171
PlotWidget::_time_offset
double _time_offset
Definition: plotwidget.h:220
PlotWidget::DragInfo::NEW_XY
@ NEW_XY
Definition: plotwidget.h:201
PlotWidget::activateLegend
void activateLegend(bool activate)
Definition: plotwidget.cpp:1022
PlotWidget::_flip_x
QAction * _flip_x
Definition: plotwidget.h:181
PlotWidget::createTimeSeries
QwtSeriesWrapper * createTimeSeries(const PlotData *data, const QString &transform_ID={}) override
Definition: plotwidget.cpp:1745
PlotWidget::_background_item
std::unique_ptr< BackgroundColorItem > _background_item
Definition: plotwidget.h:189
PlotWidget::DragInfo::curves
std::vector< QString > curves
Definition: plotwidget.h:203
customtracker.h
PlotWidget::xmlSaveState
QDomElement xmlSaveState(QDomDocument &doc) const
Definition: plotwidget.cpp:637
SnippetsMap
std::map< QString, SnippetData > SnippetsMap
Definition: custom_function.h:28
PlotWidget::isTrackerEnabled
bool isTrackerEnabled() const
Definition: plotwidget.cpp:1046
mqtt_test.data
dictionary data
Definition: mqtt_test.py:22
PlotWidget::_action_formula
QAction * _action_formula
Definition: plotwidget.h:168
qwt_plot_curve.h
qwt_plot_panner.h
PlotWidget::reloadPlotData
void reloadPlotData()
Definition: plotwidget.cpp:991
PJ::PlotDataMapRef
Definition: plotdata.h:34
PlotWidget::setStatisticsTitle
void setStatisticsTitle(QString title)
Definition: plotwidget.cpp:1265
CurveTracker::Parameter
Parameter
Definition: customtracker.h:28
PlotWidget::zoomOut
void zoomOut(bool emit_signal)
Definition: plotwidget.cpp:1319
PlotWidget::_action_edit
QAction * _action_edit
Definition: plotwidget.h:167
PlotWidget::curvesDropped
void curvesDropped()
qwt_plot_grid.h
PlotWidget::splitVertical
void splitVertical()
PlotWidget::trackerMoved
void trackerMoved(QPointF pos)
PlotWidget::overrideCursonMove
void overrideCursonMove()
Definition: plotwidget.cpp:1567
PlotWidget::removeCurve
void removeCurve(const QString &title) override
Definition: plotwidget.cpp:419
PlotWidget::_custom_Y_limits
Range _custom_Y_limits
Definition: plotwidget.h:222
qwt_plot.h
PlotWidget::timeOffset
double timeOffset() const
Definition: plotwidget.h:59
PlotWidget::setCustomAxisLimits
void setCustomAxisLimits(Range range)
Definition: plotwidget.cpp:1473
PlotWidget::_context_menu_enabled
bool _context_menu_enabled
Definition: plotwidget.h:228


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45