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
52private:
53 void markerMoved(const int, const double, const bool);
54 QList<const Marker*> orderedMarkers(QList<const Marker*>) const;
55 void addTitleMarker(const Marker*);
56 QCPItemTracer* tracer() const { return findChild<QCPItemTracer*>(); }
57 void resetSelectedMarker() { selected_marker_idx_ = -1; }
58 void deleteMarkerDataPoint(const int marker_idx);
59 QCPItemText* markerTitle(const int markerIdx, const bool = false);
60 QCPItemText* markerDataPoint(const QString& idx, const bool = false);
61 QCPItemStraightLine* markerLine(const int mIdx, const int rectIdx, const bool = false);
62 void updateQCPItemText(QCPItemText* item, const QString& txt, const QPointF pos);
63 void updateDataPointMarker(QCPItemText* item, const double, QCPGraph*, bool visible);
64 QString dataPointMarker(const double) const;
65 inline QString itemIndex(int markerIdx, int graphIdx) const { return QString("%1_%2").arg(markerIdx).arg(graphIdx); }
66 void addDataPointsMarker(QCPGraph* graph, int graph_idx, const int marker_idx, const double x, bool visible);
67 bool canAddDataPoint(const QCPGraph* graph, const double x) const;
68 Marker* marker(const std::function<bool(const Marker&)>& predicate);
69 template <typename T>
70 typename std::enable_if<std::is_base_of<QCPAbstractItem, T>::value, T*>::type
71 getOrAddQCPItem(QCustomPlot* plot, const QString& objName, const bool create);
72
73 int selected_marker_idx_;
74 bool data_point_visible_;
75 bool marker_diff_visible_;
76 bool dragging_;
77 QVector<Marker*> markers_;
78};
79
80template <typename T>
81typename std::enable_if<std::is_base_of<QCPAbstractItem, T>::value, T*>::type
82inline CustomPlot::getOrAddQCPItem(QCustomPlot* plot, const QString& objName, const bool create)
83{
84 T* item = plot->findChild<T*>(objName);
85 if (create && item == nullptr) {
86 item = new T(plot);
87 item->setObjectName(objName);
88 }
89 return item;
90}
91#endif // CUSTOMPLOT_H
Definition customplot.h:20
Definition marker_dialog.h:18