Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
customplot.h
1
13#ifndef CUSTOMPLOT_H
14#define CUSTOMPLOT_H
15#include <ui/qt/widgets/qcustomplot.h>
16#include "ui/qt/marker_dialog.h"
17
18class QCustomPlot;
19
20class CustomPlot : public QCustomPlot {
21 Q_OBJECT
22public:
23 explicit CustomPlot(QWidget* widget);
25 void showMarkerDifferences();
26 void setDataPointVisibility(const bool visible);
27 QString currentValue() const { return QString::number(tracer()->position->value(), 'g', 4); }
28 void mouseReleased();
29 bool mousePressed(QPoint);
30 void clearMarkerDifferences();
31 inline int selectedMarker() const { return selected_marker_idx_; }
32 void markerVisibilityChanged(const Marker* m);
33 void showMarkersDifference(bool show) { marker_diff_visible_ = show; }
34 void addMarkerElements(const Marker*);
35 void deleteMarkersElements();
36 void deleteMarkerElements(const int);
37 void addDataPointsMarker(QCPGraph* graph);
38 QString selectedMarker(const int ignoreIdx);
39 QVector<Marker*> markers() const { return markers_; }
40 Marker* addMarker(double x, bool isPosMarker);
41 void deleteMarker(Marker* m);
42 void deleteAllMarkers();
43 QList<const Marker*> visibleMarkers() const;
44 Marker* marker(const QString&);
45 Marker* marker(const int);
46 Marker* posMarker();
47 void markerMoved(const Marker*);
48
49protected:
50 void mouseMoveEvent(QMouseEvent* event) override;
51 void axisRemoved(QCPAxis*) override;
52
53private:
54 void markerMoved(const int, const double, const bool);
55 QList<const Marker*> orderedMarkers(QList<const Marker*>) const;
56 void addTitleMarker(const Marker*);
57 QCPItemTracer* tracer() const { return findChild<QCPItemTracer*>(); }
58 void resetSelectedMarker() { selected_marker_idx_ = -1; }
59 void deleteMarkerDataPoint(const int marker_idx);
60 QCPItemText* markerTitle(const int markerIdx, const bool = false);
61 QCPItemText* markerDataPoint(const QString& idx, const bool = false);
62 QCPItemStraightLine* markerLine(const int mIdx, const int rectIdx, const bool = false);
63 void updateQCPItemText(QCPItemText* item, const QString& txt, const QPointF pos, QCPAxis* y_axis = Q_NULLPTR);
64 void updateDataPointMarker(QCPItemText* item, const double, QCPGraph*, bool visible);
65 QString dataPointMarker(const double) const;
66 inline QString itemIndex(int markerIdx, int graphIdx) const { return QString("%1_%2").arg(markerIdx).arg(graphIdx); }
67 void addDataPointsMarker(QCPGraph* graph, int graph_idx, const int marker_idx, const double x, bool visible);
68 bool canAddDataPoint(const QCPGraph* graph, const double x) const;
69 Marker* marker(const std::function<bool(const Marker&)>& predicate);
70 template <typename T>
71 typename std::enable_if<std::is_base_of<QCPAbstractItem, T>::value, T*>::type
72 getOrAddQCPItem(QCustomPlot* plot, const QString& objName, const bool create);
73
74 int selected_marker_idx_;
75 bool data_point_visible_;
76 bool marker_diff_visible_;
77 bool dragging_;
78 QVector<Marker*> markers_;
79};
80
81template <typename T>
82typename std::enable_if<std::is_base_of<QCPAbstractItem, T>::value, T*>::type
83inline CustomPlot::getOrAddQCPItem(QCustomPlot* plot, const QString& objName, const bool create)
84{
85 T* item = plot->findChild<T*>(objName);
86 if (create && item == nullptr) {
87 item = new T(plot);
88 item->setObjectName(objName);
89 }
90 return item;
91}
92#endif // CUSTOMPLOT_H
Definition customplot.h:20
Definition marker_dialog.h:18