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
void onShowDataStatistics()
CurveTracker * _tracker
Definition: plotwidget.h:184
void on_savePlotToFile()
PlotWidget(PlotDataMapRef &datamap, QWidget *parent)
Definition: plotwidget.cpp:74
void on_panned(int dx, int dy)
Definition: plotwidget.cpp:629
CurveInfo * addCurveXY(std::string name_x, std::string name_y, QString curve_name="")
Definition: plotwidget.cpp:296
void updateStatistics(bool forceUpdate=false)
QAction * _action_removeAllCurves
Definition: plotwidget.h:166
void onDragEnterEvent(QDragEnterEvent *event)
Definition: plotwidget.cpp:470
void rectChanged(PlotWidget *self, QRectF rect)
bool xmlLoadState(QDomElement &element, bool autozoom=true)
Definition: plotwidget.cpp:720
std::map< QString, SnippetData > SnippetsMap
QAction * _flip_y
Definition: plotwidget.h:182
DragInfo _dragging
Definition: plotwidget.h:207
void on_pasteAction_triggered()
void on_changeDateTimeScale(bool enable)
QAction * _action_data_statistics
Definition: plotwidget.h:171
void onFlipAxis()
PlotDataMapRef & _mapped_data
Definition: plotwidget.h:86
void on_externallyResized(const QRectF &new_rect)
void undoableChange()
QAction * _flip_x
Definition: plotwidget.h:181
SnippetsMap _snippets
Definition: plotwidget.h:226
QString _statistics_window_title
Definition: plotwidget.h:187
Range getVisualizationRangeY(Range range_X) const override
void setAxisScale(QwtAxisId axisId, double min, double max)
bool _use_date_time_scale
Definition: plotwidget.h:191
std::unique_ptr< BackgroundColorItem > _background_item
Definition: plotwidget.h:189
void swapWidgetsRequested(PlotWidget *source, PlotWidget *destination)
double _time_offset
Definition: plotwidget.h:220
QwtSeriesWrapper * createTimeSeries(const PlotData *data, const QString &transform_ID={}) override
void activateLegend(bool activate)
QDomElement xmlSaveState(QDomDocument &doc) const
Definition: plotwidget.cpp:634
bool isTrackerEnabled() const
void setStatisticsTitle(QString title)
QAction * _action_edit
Definition: plotwidget.h:167
QAction * _action_formula
Definition: plotwidget.h:168
void splitVertical()
void trackerMoved(QPointF pos)
void reloadPlotData()
Definition: plotwidget.cpp:972
Range _custom_Y_limits
Definition: plotwidget.h:222
void zoomOut(bool emit_signal)
void curvesDropped()
QAction * _action_zoomOutVertically
Definition: plotwidget.h:175
QAction * _action_zoomOutMaximum
Definition: plotwidget.h:173
QAction * _action_copy
Definition: plotwidget.h:177
QwtSeriesWrapper * createCurveXY(const PlotData *data_x, const PlotData *data_y)
void overrideCursonMove()
QAction * _action_split_vertical
Definition: plotwidget.h:170
void removeCurve(const QString &title) override
Definition: plotwidget.cpp:419
void setCustomAxisLimits(Range range)
double timeOffset() const
Definition: plotwidget.h:59
A class which draws a coordinate grid.
Definition: qwt_plot_grid.h:33
bool _context_menu_enabled
Definition: plotwidget.h:228
bool canvasEventFilter(QEvent *event)
QAction * _action_image_to_clipboard
Definition: plotwidget.h:179
void configureTracker(CurveTracker::Parameter val)
void on_zoomOutVertical_triggered(bool emit_signal=true)
QwtPlotGrid * _grid
Definition: plotwidget.h:185
void rescaleEqualAxisScaling()
Definition: plotwidget.cpp:916
const char * source
Definition: lz4.h:699
void on_copyToClipboard()
void removeAllCurves() override
Definition: plotwidget.cpp:461
void curveListChanged()
void on_zoomOutHorizontal_triggered(bool emit_signal=true)
bool eventFilter(QObject *obj, QEvent *event) override
int QwtAxisId
Axis identifier.
Definition: qwt_axis_id.h:26
color
Definition: color.h:23
TransformSelector * _transform_select_dialog
Definition: plotwidget.h:224
void setModeXY(bool enable) override
void onDropEvent(QDropEvent *event)
Definition: plotwidget.cpp:531
void buildActions()
Definition: plotwidget.cpp:144
virtual ~PlotWidget() override
Definition: plotwidget.cpp:124
void splitHorizontal()
void setTrackerPosition(double abs_time)
QAction * _action_saveToFile
Definition: plotwidget.h:176
void on_changeTimeOffset(double offset)
std::enable_if_t< all< Args... >::value, enable_t > enable
Definition: sol.hpp:2244
void onBackgroundColorRequest(QString name)
Range customAxisLimit() const
void setContextMenuEnabled(bool enabled)
Definition: plotwidget.cpp:139
std::vector< QString > curves
Definition: plotwidget.h:203
QAction * _action_paste
Definition: plotwidget.h:178
void setDefaultRangeX()
void on_copyAction_triggered()
void onDataSourceRemoved(const std::string &src_name)
Definition: plotwidget.cpp:425
bool isZoomLinkEnabled() const
void setZoomRectangle(QRectF rect, bool emit_signal)
Definition: plotwidget.cpp:945
void updateAvailableTransformers()
void activateGrid(bool activate)
enum PlotWidget::DragInfo::@32 mode
PlotDataMapRef & datamap()
Definition: plotwidget.h:64
StatisticsDialog * _statistics_dialog
Definition: plotwidget.h:193
QAction * _action_zoomOutHorizontally
Definition: plotwidget.h:174
void enableTracker(bool enable)
void onDragLeaveEvent(QDragLeaveEvent *event)
Definition: plotwidget.cpp:526
QAction * _action_split_horizontal
Definition: plotwidget.h:169
void updateCurves(bool reset_older_data)
Definition: format.h:895
CurveInfo * addCurve(const std::string &name, QColor color=Qt::transparent)
Definition: plotwidget.cpp:393
void canvasContextMenuTriggered(const QPoint &pos)
Definition: plotwidget.cpp:230
void on_changeCurveColor(const QString &curve_name, QColor new_color)


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:01:38