Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
plot_dialog.h
Go to the documentation of this file.
1
13#ifndef PLOT_DIALOG_H
14#define PLOT_DIALOG_H
15
16#include <config.h>
17#include "plot.h"
18
21#include <ui/qt/widgets/customplot.h>
22#include "wireshark_dialog.h"
23
24#include <QPointer>
25#include <QMenu>
26#include <QTextStream>
27#include <QItemSelection>
28
29#include <vector>
30
32class QAbstractButton;
33class QCPAxisRect;
34class QCPGraph;
35class QCPItemTracer;
36class QCPMarginGroup;
37class QPushButton;
38class QRubberBand;
39class QTimer;
40class QCustomPlot;
41/* define Plot specific UAT columns */
42enum UatColumnsPlot { plotColEnabled = 0, plotColIdx, plotColName, plotColDFilter, plotColColor, plotColStyle, plotColYField, plotColYAxisFactor, plotColMaxNum };
43
44namespace Ui {
45 class PlotDialog;
46}
47
48// Saved plot settings
49typedef struct _plot_settings_t {
50 bool enabled;
51 unsigned group;
52 char* name;
53 char* dfilter;
54 unsigned color;
55 uint32_t style;
56 char* yfield;
57 uint32_t y_axis_factor;
59
60static const value_string graph_style_vs[] = {
61 { Graph::psLine, "Line" },
62 { Graph::psDotLine, "Dot Line" },
63 { Graph::psStepLine, "Step Line" },
64 { Graph::psDotStepLine, "Dot Step Line" },
65 { Graph::psImpulse, "Impulse" },
66 //{ Graph::psBar, "Bar" },
67 //{ Graph::psStackedBar, "Stacked Bar" },
68 { Graph::psDot, "Dot" },
69 { Graph::psSquare, "Square" },
70 { Graph::psDiamond, "Diamond" },
71 { Graph::psCross, "Cross" },
72 { Graph::psCircle, "Circle" },
73 { Graph::psPlus, "Plus" },
74 { 0, NULL }
75};
76
78{
79 Q_OBJECT
80
81public:
82 explicit PlotDialog(QWidget& parent, CaptureFile& cf, bool show_default = true);
84 /* Add plot with default name, style, color and scale. */
85 void addPlot(bool checked, const QString& dfilter, const QString& yfield);
86
87public slots:
88 void scheduleReplot() { need_replot_ = true; }
89 void scheduleRecalc() { need_recalc_ = true; }
90 void scheduleRetap() { need_retap_ = true; }
91
92protected:
93 void captureFileClosing() override;
94 void keyPressEvent(QKeyEvent* event) override;
95 void reject() override;
96
97protected slots:
98 void modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles);
99 void modelRowsReset();
100 void modelRowsInserted(const QModelIndex& parent, int first, int last);
101 void modelRowsRemoved(const QModelIndex& parent, int first, int last);
102 void modelRowsMoved(const QModelIndex& sourceParent, int sourceStart, int sourceEnd, const QModelIndex& destinationParent, int destinationRow);
103
104signals:
105 void goToPacket(int packet, int hf_id);
106 void updateMarker(const int size, const double xCoord, const int);
107 void setPosMarker(const double xCoord, const int selectMPos, const int posMPos);
108private:
109 void loadProfileGraphs();
110 void createPlot(int currentRow);
111 void syncPlotSettings(int row);
112 int getLastPlotIdx();
113 /* Add plot with all defined parameters. */
114 void addPlot(bool checked, const QString& name, const QString& dfilter, QRgb color_idx,
115 Graph::PlotStyles style, const QString& yfield, int y_axis_factor = Graph::default_y_axis_factor_);
116 /* Add one of the two (four) default plots. */
117 void addDefaultPlot(bool enabled, bool filtered);
118
119 bool graphIsEnabled(int row) const;
120 Plot* currentActiveGraph() const;
121 void getGraphInfo();
122 void updateHint();
123 void updateLegendPos();
124 void resetAxes();
125 void doZoom(bool in, bool y);
126 void zoomAxes(bool in);
127 void zoomXAxis(bool in);
128 void zoomYAxis(bool in);
129 void panAxes(int x_pixels, int y_pixels);
130 void updateXAxisLabel();
131 QRectF getZoomRanges(QRect zoom_rect, QCPAxisRect** matchedAxisRect = nullptr);
132 bool makeCsv(QTextStream& stream) const;
133 QCPAxisRect* getAxisRect(int idx);
134 void removeExcessPlots();
135 void setTracerColor();
136 QCPAxisRect* axisRectFromPos(const QPoint& pos);
137 void addMarkerDifference();
138 int visibleMarker(const bool first = true) const;
139 Marker* addMarker(const bool isPosMarker);
140 void drawMarker(const Marker*);
141 void drawMarkers();
142 void addDataPointsMarkers();
143 void updateFirstAxisRectHeight();
144 QList<QCPAxisRect*> axisRects() const;
145 void autoScroll() const;
146 Ui::PlotDialog* ui;
147 QPushButton* copy_bt_;
148 CopyFromProfileButton* copy_profile_bt_;
149
150 //Model and delegate were chosen over UatFrame because add/remove/copy
151 //buttons would need realignment (UatFrame has its own)
152 QPointer<UatModel> uat_model_;
153 UatDelegate* uat_delegate_;
154
155 // XXX - This needs to stay synced with UAT index
156 QVector<Plot*> plots_;
157
158 QString hint_err_;
159 QCPGraph* base_graph_;
160 QCPItemTracer* tracer_;
161 uint32_t packet_num_;
162 double start_time_;
163 QRubberBand* rubber_band_;
164 QPoint rb_origin_;
165 QMenu ctx_menu_;
166 QTimer* stat_timer_;
167 QCPMarginGroup* margin_group_;
168 Qt::Alignment legend_alignment_;
169 bool need_replot_; // Light weight: tell QCP to replot existing data
170 bool need_recalc_; // Medium weight: recalculate values, then replot
171 bool need_retap_; // Heavy weight: re-read packet data
172 bool auto_axes_;
173 bool abs_time_;
174 double last_right_clicked_pos_;
175private slots:
176 static void applyChanges();
177 /* This function will take care of retapping and redrawing. */
178 void updateStatistics();
179 void updateLegend();
180 void copyFromProfile(const QString& filename);
181 void copyAsCsvClicked();
182
183 void showContextMenu(const QPoint& pos);
184 void moveLegend();
185 void graphClicked(QMouseEvent* event);
186 void mouseMoved(QMouseEvent* event);
187 void mouseReleased(QMouseEvent* event);
188
189 void selectedFrameChanged(const QList<int>& frames);
190 void plotUatSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
191 void on_leftButtonBox_clicked(QAbstractButton* button);
192 void on_actionLegend_triggered(bool checked);
193 void on_actionLogScale_triggered(bool checked);
194 void on_actionCrosshairs_triggered(bool checked);
195 void on_actionTopAxis_triggered(bool checked);
196 void on_automaticUpdateCheckBox_toggled(bool checked);
197 void on_plotUat_currentItemChanged(const QModelIndex& current, const QModelIndex& previous);
198 void on_actionGoToPacket_triggered();
199 void on_newToolButton_clicked();
200 void on_deleteToolButton_clicked();
201 void on_copyToolButton_clicked();
202 void on_clearToolButton_clicked();
203 void on_moveUpwardsToolButton_clicked();
204 void on_moveDownwardsToolButton_clicked();
205 void on_rightButtonBox_helpRequested();
206 void on_actionReset_triggered() { resetAxes(); }
207 void on_actionZoomIn_triggered() { zoomAxes(true); }
208 void on_actionZoomInX_triggered() { zoomXAxis(true); }
209 void on_actionZoomInY_triggered() { zoomYAxis(true); }
210 void on_actionZoomOut_triggered() { zoomAxes(false); }
211 void on_actionZoomOutX_triggered() { zoomXAxis(false); }
212 void on_actionZoomOutY_triggered() { zoomYAxis(false); }
213 void on_actionMoveUp10_triggered() { panAxes(0, 10); }
214 void on_actionMoveLeft10_triggered() { panAxes(-10, 0); }
215 void on_actionMoveRight10_triggered() { panAxes(10, 0); }
216 void on_actionMoveDown10_triggered() { panAxes(0, -10); }
217 void on_actionMoveUp1_triggered() { panAxes(0, 1); }
218 void on_actionMoveLeft1_triggered() { panAxes(-1, 0); }
219 void on_actionMoveRight1_triggered() { panAxes(1, 0); }
220 void on_actionMoveDown1_triggered() { panAxes(0, -1); }
221 void on_actionToggleTimeOrigin_triggered();
222 void on_rightButtonBox_accepted();
223 void on_actionAutoScroll_triggered(bool checked);
224
225 void on_actionAddMarker_triggered();
226 void on_actionMoveMarker_triggered();
227 void on_actionShowPosMarker_triggered();
228 void on_actionShowMarkersDifference_triggered();
229 void on_actionDeleteMarker_triggered();
230 void on_actionDeleteAllMarkers_triggered();
231 void on_actionShowDataPointMarker_triggered();
232
233};
234
235#endif // PLOT_DIALOG_H
Definition capture_file.h:21
Definition copy_from_profile_button.h:21
Definition marker_dialog.h:18
Definition plot_dialog.h:78
void captureFileClosing() override
Called when the capture file is about to close. This can be used to disconnect taps and similar actio...
Definition plot_dialog.cpp:632
Definition plot.h:32
Definition uat_delegate.h:24
Definition wireshark_dialog.h:35
Definition plot_dialog.h:49
Definition value_string.h:26
Definition stream.c:41