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 double y_axis_factor;
59
60static const value_string plot_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);
83 virtual ~PlotDialog();
84 // Initialize the dialog after construction to allow polymorphic behavior.
85 void initialize(QWidget& parent, uat_field_t* plot_fields, bool show_default = true);
86
87 /* Add plot with default name, style, color and scale. */
88 void addPlot(bool checked, const QString& dfilter, const QString& yfield);
89
90public slots:
91 void scheduleReplot() { need_replot_ = true; }
92 void scheduleRecalc() { need_recalc_ = true; }
93 void scheduleRetap() { need_retap_ = true; }
94
95protected:
96 void captureFileClosing() override;
97 void keyPressEvent(QKeyEvent* event) override;
98 void reject() override;
99 virtual QString getFilteredName() const;
100 virtual QString getYAxisName() const;
101 virtual QString getHintText(unsigned num_items) const;
102 /* Add one of the two (four) default plots. */
103 virtual void addDefaultPlot(bool enabled, bool filtered);
104 /* Add plot with all defined parameters. */
105 void addPlot(bool checked, const QString& name, const QString& dfilter, QRgb color_idx,
106 Graph::PlotStyles style, const QString& yfield, double y_axis_factor = Graph::default_y_axis_factor_);
107
108protected slots:
109 void modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles);
110 void modelRowsReset();
111 void modelRowsInserted(const QModelIndex& parent, int first, int last);
112 void modelRowsRemoved(const QModelIndex& parent, int first, int last);
113 void modelRowsMoved(const QModelIndex& sourceParent, int sourceStart, int sourceEnd, const QModelIndex& destinationParent, int destinationRow);
114
115signals:
116 void goToPacket(int packet, int hf_id);
117 void updateMarker(const int size, const double xCoord, const int);
118 void setPosMarker(const double xCoord, const int selectMPos, const int posMPos);
119private:
120 void loadProfileGraphs(uat_field_t* plot_fields);
121 void createPlot(int currentRow);
122 void syncPlotSettings(int row);
123 int getLastPlotIdx();
124
125 bool graphIsEnabled(int row) const;
126 Plot* currentActiveGraph() const;
127 void getGraphInfo();
128 void updateHint();
129 void updateLegendPos();
130 void resetAxes();
131 void doZoom(bool in, bool y);
132 void zoomAxes(bool in);
133 void zoomXAxis(bool in);
134 void zoomYAxis(bool in);
135 void panAxes(int x_pixels, int y_pixels);
136 void updateXAxisLabel();
137 QRectF getZoomRanges(QRect zoom_rect, QCPAxisRect** matchedAxisRect = nullptr);
138 bool makeCsv(QTextStream& stream) const;
139 QCPAxisRect* getAxisRect(int idx);
140 void removeExcessPlots();
141 void setTracerColor();
142 QCPAxisRect* axisRectFromPos(const QPoint& pos);
143 void addMarkerDifference();
144 int visibleMarker(const bool first = true) const;
145 Marker* addMarker(const bool isPosMarker);
146 void drawMarker(const Marker*);
147 void drawMarkers();
148 void addDataPointsMarkers();
149 void updateFirstAxisRectHeight();
150 void recreateMultiValueAxes();
151 QList<QCPAxisRect*> axisRects() const;
152 void autoScroll() const;
153 Ui::PlotDialog* ui;
154 QPushButton* copy_bt_;
155 CopyFromProfileButton* copy_profile_bt_;
156
157 //Model and delegate were chosen over UatFrame because add/remove/copy
158 //buttons would need realignment (UatFrame has its own)
159 QPointer<UatModel> uat_model_;
160 UatDelegate* uat_delegate_;
161
162 // XXX - This needs to stay synced with UAT index
163 QVector<Plot*> plots_;
164
165 QString hint_err_;
166 QCPGraph* base_graph_;
167 QCPItemTracer* tracer_;
168 uint32_t packet_num_;
169 double start_time_;
170 QRubberBand* rubber_band_;
171 QPoint rb_origin_;
172 QMenu ctx_menu_;
173 QTimer* stat_timer_;
174 QCPMarginGroup* margin_group_;
175 Qt::Alignment legend_alignment_;
176 bool need_replot_; // Light weight: tell QCP to replot existing data
177 bool need_recalc_; // Medium weight: recalculate values, then replot
178 bool need_retap_; // Heavy weight: re-read packet data
179 bool auto_axes_;
180 bool abs_time_;
181 double last_right_clicked_pos_;
182private slots:
183 static void applyChanges();
184 /* This function will take care of retapping and redrawing. */
185 void updateStatistics();
186 void updateLegend();
187 void copyFromProfile(const QString& filename);
188 void copyAsCsvClicked();
189
190 void showContextMenu(const QPoint& pos);
191 void moveLegend();
192 void graphClicked(QMouseEvent* event);
193 void mouseMoved(QMouseEvent* event);
194 void mouseReleased(QMouseEvent* event);
195
196 void selectedFrameChanged(const QList<int>& frames);
197 void plotUatSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
198 void on_leftButtonBox_clicked(QAbstractButton* button);
199 void on_actionLegend_triggered(bool checked);
200 void on_actionLogScale_triggered(bool checked);
201 void on_actionCrosshairs_triggered(bool checked);
202 void on_actionTopAxis_triggered(bool checked);
203 void on_automaticUpdateCheckBox_toggled(bool checked);
204 void on_plotUat_currentItemChanged(const QModelIndex& current, const QModelIndex& previous);
205 void on_actionGoToPacket_triggered();
206 void on_newToolButton_clicked();
207 void on_deleteToolButton_clicked();
208 void on_copyToolButton_clicked();
209 void on_clearToolButton_clicked();
210 void on_moveUpwardsToolButton_clicked();
211 void on_moveDownwardsToolButton_clicked();
212 void on_rightButtonBox_helpRequested();
213 void on_actionReset_triggered() { resetAxes(); }
214 void on_actionZoomIn_triggered() { zoomAxes(true); }
215 void on_actionZoomInX_triggered() { zoomXAxis(true); }
216 void on_actionZoomInY_triggered() { zoomYAxis(true); }
217 void on_actionZoomOut_triggered() { zoomAxes(false); }
218 void on_actionZoomOutX_triggered() { zoomXAxis(false); }
219 void on_actionZoomOutY_triggered() { zoomYAxis(false); }
220 void on_actionMoveUp10_triggered() { panAxes(0, 10); }
221 void on_actionMoveLeft10_triggered() { panAxes(-10, 0); }
222 void on_actionMoveRight10_triggered() { panAxes(10, 0); }
223 void on_actionMoveDown10_triggered() { panAxes(0, -10); }
224 void on_actionMoveUp1_triggered() { panAxes(0, 1); }
225 void on_actionMoveLeft1_triggered() { panAxes(-1, 0); }
226 void on_actionMoveRight1_triggered() { panAxes(1, 0); }
227 void on_actionMoveDown1_triggered() { panAxes(0, -1); }
228 void on_actionToggleTimeOrigin_triggered();
229 void on_rightButtonBox_accepted();
230 void on_actionAutoScroll_triggered(bool checked);
231 void on_actionEnableMultiYAxes_triggered(bool checked);
232
233 void on_actionAddMarker_triggered();
234 void on_actionMoveMarker_triggered();
235 void on_actionShowPosMarker_triggered();
236 void on_actionShowMarkersDifference_triggered();
237 void on_actionDeleteMarker_triggered();
238 void on_actionDeleteAllMarkers_triggered();
239 void on_actionShowDataPointMarker_triggered();
240
241};
242
243#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:621
Definition plot.h:32
Definition uat_delegate.h:24
Definition wireshark_dialog.h:35
Definition plot_dialog.h:49
Definition uat.h:235
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
Definition stream.c:41