Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
io_graph_dialog.h
Go to the documentation of this file.
1
10#ifndef IO_GRAPH_DIALOG_H
11#define IO_GRAPH_DIALOG_H
12
13#include <config.h>
14#include "io_graph.h"
15
16#include <epan/epan_dissect.h>
17#include <epan/prefs.h>
18#include <epan/uat.h>
19
20#include <wsutil/str_util.h>
21
22#include <ui/preference_utils.h>
23#include <ui/io_graph_item.h>
26
27#include "wireshark_dialog.h"
28
29#include <QPointer>
30#include <QMenu>
31#include <QTextStream>
32#include <QItemSelection>
33
34#include <vector>
35
36class QRubberBand;
37class QTimer;
38class QAbstractButton;
40
41class QCPGraph;
42class QCPItemTracer;
43class QCPAxisTicker;
44class QCPAxisTickerDateTime;
45
46// Saved graph settings
47typedef struct _io_graph_settings_t {
48 bool enabled;
49 bool asAOT;
50 char* name;
51 char* dfilter;
52 unsigned color;
53 uint32_t style;
54 uint32_t yaxis;
55 char* yfield;
56 uint32_t sma_period;
57 double y_axis_factor;
59
60
61extern const value_string moving_avg_vs[];
62
63/* define I/O Graph specific UAT columns */
64enum UatColumnsIOG {colEnabled = 0, colName, colDFilter, colColor, colStyle, colYAxis, colYField, colSMAPeriod, colYAxisFactor, colAOT, colMaxNum};
65
66namespace Ui {
67class IOGraphDialog;
68}
69
70static const value_string io_graph_style_vs[] = {
71 { IOGraph::psLine, "Line" },
72 { IOGraph::psDotLine, "Dot Line" },
73 { IOGraph::psStepLine, "Step Line" },
74 { IOGraph::psDotStepLine, "Dot Step Line" },
75 { IOGraph::psImpulse, "Impulse" },
76 { IOGraph::psBar, "Bar" },
77 { IOGraph::psStackedBar, "Stacked Bar" },
78 { IOGraph::psDot, "Dot" },
79 { IOGraph::psSquare, "Square" },
80 { IOGraph::psDiamond, "Diamond" },
81 { IOGraph::psCross, "Cross" },
82 { IOGraph::psCircle, "Circle" },
83 { IOGraph::psPlus, "Plus" },
84 { 0, NULL }
85};
86
88{
89 Q_OBJECT
90
91public:
92 explicit IOGraphDialog(QWidget &parent, CaptureFile &cf, const char* type_unit_name);
93 virtual ~IOGraphDialog();
94 // Initialize the dialog after construction to allow polymorphic behavior.
95 void initialize(QWidget& parent, uat_field_t* io_graph_fields, QString displayFilter = QString(),
96 io_graph_item_unit_t value_units = IOG_ITEM_UNIT_PACKETS,
97 QString yfield = QString(),
98 bool is_sibling_dialog = false,
99 const QVector<QString> convFilters = QVector<QString>());
100
101 void addGraph(bool checked, bool asAOT, QString name, QString dfilter, QRgb color_idx, IOGraph::PlotStyles style,
102 io_graph_item_unit_t value_units, QString yfield, int moving_average, double yaxisfactor);
103 void addGraph(bool checked, bool asAOT, QString dfilter, io_graph_item_unit_t value_units, QString yfield);
104 void addGraph(bool copy_from_current = false);
105 virtual void addDefaultGraph(bool enabled, int idx = 0);
106 void syncGraphSettings(int row);
107 qsizetype graphCount() const;
108
109public slots:
110 void scheduleReplot(bool now = false);
111 void scheduleRecalc(bool now = false);
112 void scheduleRetap(bool now = false);
113 void reloadFields();
114
115protected:
116 void captureFileClosing();
117 void keyPressEvent(QKeyEvent *event);
118 void reject();
119 virtual QString getFilteredName() const;
120 virtual QString getXAxisName() const;
121 virtual const char* getYAxisName(io_graph_item_unit_t value_units) const;
122 virtual QString getYFieldName(io_graph_item_unit_t value_units, const QString& yfield) const;
123 virtual int getYAxisValue(const QString& data);
124 virtual QString getNoDataHint() const;
125 virtual QString getHintText(unsigned num_items) const;
126
127protected slots:
128 void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
129 void modelRowsReset();
130 void modelRowsInserted(const QModelIndex &parent, int first, int last);
131 void modelRowsRemoved(const QModelIndex &parent, int first, int last);
132 void modelRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow);
133
134signals:
135 void goToPacket(int packet_num);
136 void recalcGraphData(capture_file *cap_file);
137 void intervalChanged(int interval);
138 void reloadValueUnitFields();
139
140protected:
141 static const int DEFAULT_MOVING_AVERAGE = 0;
142 static const int DEFAULT_Y_AXIS_FACTOR = 1;
143
144private:
145 Ui::IOGraphDialog *ui;
146 CopyFromProfileButton *copy_profile_bt_;
147
148 //Model and delegate were chosen over UatFrame because add/remove/copy
149 //buttons would need realignment (UatFrame has its own)
150 QPointer<UatModel> uat_model_;
151 UatDelegate *uat_delegate_;
152
153 // XXX - This needs to stay synced with UAT index
154 QVector<IOGraph*> ioGraphs_;
155
156 QString hint_err_;
157 QCPGraph *base_graph_;
158 QCPItemTracer *tracer_;
159 uint32_t packet_num_;
160 nstime_t start_time_;
161 bool mouse_drags_;
162 QRubberBand *rubber_band_;
163 QPoint rb_origin_;
164 QMenu ctx_menu_;
165 QTimer *stat_timer_;
166 bool need_replot_; // Light weight: tell QCP to replot existing data
167 bool need_recalc_; // Medium weight: recalculate values, then replot
168 bool need_retap_; // Heavy weight: re-read packet data
169 bool auto_axes_;
170 int precision_;
171 const char* type_unit_name_;
172
173 QSharedPointer<QCPAxisTicker> number_ticker_;
174 QSharedPointer<QCPAxisTickerDateTime> datetime_ticker_;
175
176
177// void fillGraph();
178 void zoomAxes(bool in);
179 void zoomXAxis(bool in);
180 void zoomYAxis(bool in);
181 void panAxes(int x_pixels, int y_pixels);
182 void toggleTracerStyle(bool force_default = false);
183 void getGraphInfo();
184 void updateHint();
185 void updateLegend();
186 QRectF getZoomRanges(QRect zoom_rect);
187 void createIOGraph(int currentRow);
188 void loadProfileGraphs(uat_field_t* io_graph_fields);
189 void makeCsv(QTextStream &stream) const;
190 bool saveCsv(const QString &file_name) const;
191 IOGraph *currentActiveGraph() const;
192 bool graphIsEnabled(int row) const;
193 bool graphAsAOT(int row) const;
194
195private slots:
196 static void applyChanges();
197
198 void copyFromProfile(QString filename);
199 void updateWidgets();
200 void showContextMenu(const QPoint &pos);
201 void graphClicked(QMouseEvent *event);
202 void mouseMoved(QMouseEvent *event);
203 void mouseReleased(QMouseEvent *event);
204 void selectedFrameChanged(QList<int> frames);
205 void moveLegend();
206
207 void resetAxes();
208 void updateStatistics(void);
209 void copyAsCsvClicked();
210
211 void graphUatSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
212 void on_intervalComboBox_currentIndexChanged(int index);
213 void on_graphUat_currentItemChanged(const QModelIndex &current, const QModelIndex &previous);
214
215 void on_automaticUpdateCheckBox_toggled(bool checked);
216 void on_newToolButton_clicked();
217 void on_deleteToolButton_clicked();
218 void on_copyToolButton_clicked();
219 void on_clearToolButton_clicked();
220 void on_moveUpwardsToolButton_clicked();
221 void on_moveDownwardsToolButton_clicked();
222 void on_dragRadioButton_toggled(bool checked);
223 void on_zoomRadioButton_toggled(bool checked);
224 void on_actionReset_triggered();
225 void on_actionZoomIn_triggered();
226 void on_actionZoomInX_triggered();
227 void on_actionZoomInY_triggered();
228 void on_actionZoomOut_triggered();
229 void on_actionZoomOutX_triggered();
230 void on_actionZoomOutY_triggered();
231 void on_actionMoveUp10_triggered();
232 void on_actionMoveLeft10_triggered();
233 void on_actionMoveRight10_triggered();
234 void on_actionMoveDown10_triggered();
235 void on_actionMoveUp1_triggered();
236 void on_actionMoveLeft1_triggered();
237 void on_actionMoveRight1_triggered();
238 void on_actionMoveDown1_triggered();
239 void on_actionGoToPacket_triggered();
240 void on_actionDragZoom_triggered();
241 void on_actionToggleTimeOrigin_triggered();
242 void on_actionCrosshairs_triggered();
243 void on_buttonBox_helpRequested();
244 void on_buttonBox_accepted();
245 void buttonBoxClicked(QAbstractButton *button);
246 void actionLegendTriggered(bool checked);
247 void actionTimeOfDayTriggered(bool checked);
248 void actionLogScaleTriggered(bool checked);
249};
250
251#endif // IO_GRAPH_DIALOG_H
Definition capture_file.h:21
Definition copy_from_profile_button.h:21
Definition io_graph_dialog.h:88
void captureFileClosing()
Called when the capture file is about to close. This can be used to disconnect taps and similar actio...
Definition io_graph_dialog.cpp:708
Definition io_graph.h:63
Definition uat_delegate.h:24
Definition wireshark_dialog.h:35
Definition cfile.h:67
Definition io_graph_dialog.h:47
Definition uat.h:235
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
Definition nstime.h:26
Definition stream.c:41