plotwidget_base.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 PLOTWIDGET_BASE_H
8 #define PLOTWIDGET_BASE_H
9 
10 #include <QWidget>
11 #include "plotdata.h"
12 #include "timeseries_qwt.h"
13 
14 class QwtPlot;
15 class QwtPlotCurve;
16 class QwtPlotMarker;
17 
18 class PlotPanner;
19 class PlotZoomer;
20 class PlotMagnifier;
21 class PlotLegend;
22 
23 namespace PJ
24 {
25 class PlotWidgetBase : public QWidget
26 {
27  Q_OBJECT
28 
29 public:
31  {
36  };
37 
38  struct CurveInfo
39  {
40  std::string src_name;
43  };
44 
45  PlotWidgetBase(QWidget* parent);
46 
47  virtual ~PlotWidgetBase();
48 
49  virtual CurveInfo* addCurve(const std::string& name, PlotDataXY& src_data,
50  QColor color = Qt::transparent);
51 
52  virtual void removeCurve(const QString& title);
53 
54  const std::list<CurveInfo>& curveList() const;
55  std::list<CurveInfo>& curveList();
56 
57  bool isEmpty() const;
58 
59  QColor getColorHint(PlotDataXY* data);
60 
61  std::map<QString, QColor> getCurveColors() const;
62 
63  CurveInfo* curveFromTitle(const QString& title);
64 
66  const QString& transform_ID = {});
67 
68  virtual void resetZoom();
69 
70  virtual PJ::Range getVisualizationRangeX() const;
71 
72  virtual PJ::Range getVisualizationRangeY(PJ::Range range_X) const;
73 
74  virtual void setModeXY(bool enable);
75 
76  void setLegendSize(int size);
77 
78  void setLegendAlignment(Qt::Alignment alignment);
79 
80  void setZoomEnabled(bool enabled);
81 
82  bool isZoomEnabled() const;
83 
84  void changeCurvesStyle(CurveStyle style);
85 
86  bool isXYPlot() const;
87 
88  QRectF currentBoundingRect() const;
89 
90  QRectF maxZoomRect() const;
91 
92  CurveStyle curveStyle() const;
93 
94  bool keepRatioXY() const;
95 
96  void setKeepRatioXY(bool active);
97 
98  void setAcceptDrops(bool accept);
99 
100 public slots:
101 
102  void replot();
103 
104  virtual void removeAllCurves();
105 
106 signals:
107 
108  void curveListChanged();
109 
110  void viewResized(const QRectF&);
111 
112  void dragEnterSignal(QDragEnterEvent* event);
113  void dragLeaveSignal(QDragLeaveEvent* event);
114 
115  void dropSignal(QDropEvent* event);
116 
117  void legendSizeChanged(int new_size);
118 
119  void widgetResized();
120 
121 protected:
122  class QwtPlotPimpl;
123  QwtPlotPimpl* p = nullptr;
124 
125  static void setStyle(QwtPlotCurve* curve, CurveStyle style);
126 
127  QwtPlot* qwtPlot();
128  const QwtPlot* qwtPlot() const;
129 
130  PlotLegend* legend();
131  PlotZoomer* zoomer();
133 
134  void updateMaximumZoomArea();
135 
136  bool eventFilter(QObject* obj, QEvent* event);
137 
138 private:
139  bool _xy_mode;
140 
142 
144 };
145 
146 } // namespace PJ
147 
148 #endif // PLOTWIDGET_PROXY_H
bool isZoomEnabled() const
PlotLegend * legend()
PlotZoomer * zoomer()
A plot item, that represents a series of points.
QwtPlotPimpl * p
void setAcceptDrops(bool accept)
virtual void removeCurve(const QString &title)
virtual PJ::Range getVisualizationRangeY(PJ::Range range_X) const
virtual PJ::Range getVisualizationRangeX() const
void setZoomEnabled(bool enabled)
virtual void setModeXY(bool enable)
A 2-D plotting widget.
Definition: qwt_plot.h:78
virtual void removeAllCurves()
void dragLeaveSignal(QDragLeaveEvent *event)
QRectF maxZoomRect() const
void changeCurvesStyle(CurveStyle style)
void viewResized(const QRectF &)
bool eventFilter(QObject *obj, QEvent *event)
PlotMagnifier * magnifier()
const std::list< CurveInfo > & curveList() const
void dragEnterSignal(QDragEnterEvent *event)
void setLegendAlignment(Qt::Alignment alignment)
static void setStyle(QwtPlotCurve *curve, CurveStyle style)
virtual CurveInfo * addCurve(const std::string &name, PlotDataXY &src_data, QColor color=Qt::transparent)
virtual QwtSeriesWrapper * createTimeSeries(const PlotData *data, const QString &transform_ID={})
void legendSizeChanged(int new_size)
CurveStyle curveStyle() const
color
Definition: color.h:23
bool keepRatioXY() const
QRectF currentBoundingRect() const
CurveInfo * curveFromTitle(const QString &title)
PlotWidgetBase(QWidget *parent)
std::enable_if_t< all< Args... >::value, enable_t > enable
Definition: sol.hpp:2244
void setLegendSize(int size)
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1485
void setKeepRatioXY(bool active)
QColor getColorHint(PlotDataXY *data)
virtual void resetZoom()
void dropSignal(QDropEvent *event)
std::map< QString, QColor > getCurveColors() const
Definition: format.h:895
A class for drawing markers.


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