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
49typedef struct _io_graph_settings_t {
50 bool enabled;
51 bool asAOT;
52 char *name;
53 char *dfilter;
54 unsigned color;
55 uint32_t style;
56 uint32_t yaxis;
57 char *yfield;
58 uint32_t sma_period;
61
62
63extern const value_string moving_avg_vs[];
64
81
82namespace Ui {
83class IOGraphDialog;
84}
85
86static const value_string io_graph_style_vs[] = {
87 { IOGraph::psLine, "Line" },
88 { IOGraph::psDotLine, "Dot Line" },
89 { IOGraph::psStepLine, "Step Line" },
90 { IOGraph::psDotStepLine, "Dot Step Line" },
91 { IOGraph::psImpulse, "Impulse" },
92 { IOGraph::psBar, "Bar" },
93 { IOGraph::psStackedBar, "Stacked Bar" },
94 { IOGraph::psDot, "Dot" },
95 { IOGraph::psSquare, "Square" },
96 { IOGraph::psDiamond, "Diamond" },
97 { IOGraph::psCross, "Cross" },
98 { IOGraph::psCircle, "Circle" },
99 { IOGraph::psPlus, "Plus" },
100 { 0, NULL }
101};
102
116{
117 Q_OBJECT
118
119public:
127 explicit IOGraphDialog(QWidget &parent, CaptureFile &cf, const char *type_unit_name);
128
130 virtual ~IOGraphDialog();
131
150 void initialize(QWidget &parent, uat_field_t *io_graph_fields,
151 QString displayFilter = QString(),
153 QString yfield = QString(),
154 bool is_sibling_dialog = false,
155 const QVector<QString> convFilters = QVector<QString>());
156
157
172 void addGraph(bool checked, bool asAOT, QString name, QString dfilter,
173 QColor color_idx, IOGraph::PlotStyles style,
174 io_graph_item_unit_t value_units, QString yfield,
175 int moving_average, double yaxisfactor);
176
189 void addGraph(bool checked, bool asAOT, QString dfilter,
190 io_graph_item_unit_t value_units, QString yfield);
191
197 void addGraph(bool copy_from_current = false);
198
208 virtual void addDefaultGraph(bool enabled, int idx = 0);
209
220 void syncGraphSettings(int row);
221
226 qsizetype graphCount() const;
227
228
229public slots:
240 void scheduleReplot(bool now = false);
241
250 void scheduleRecalc(bool now = false);
251
260 void scheduleRetap(bool now = false);
261
268 void reloadFields();
269
270
271protected:
278 void captureFileClosing();
279
288 void keyPressEvent(QKeyEvent *event);
289
295 void reject();
296
305 virtual QString getFilteredName() const;
306
311 virtual QString getXAxisName() const;
312
318 virtual const char *getYAxisName(io_graph_item_unit_t value_units) const;
319
329 virtual QString getYFieldName(io_graph_item_unit_t value_units, const QString &yfield) const;
330
340 virtual int getYAxisValue(const QString &data);
341
347 virtual QString getNoDataHint() const;
348
354 virtual QString getHintText(unsigned num_items) const;
355
356
357protected slots:
369 void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
370 const QVector<int> &roles);
371
378 void modelRowsReset();
379
390 void modelRowsInserted(const QModelIndex &parent, int first, int last);
391
402 void modelRowsRemoved(const QModelIndex &parent, int first, int last);
403
416 void modelRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
417 const QModelIndex &destinationParent, int destinationRow);
418
419
420signals:
425 void goToPacket(int packet_num);
426
432
437 void intervalChanged(int interval);
438
444
445
446protected:
447 static const int DEFAULT_MOVING_AVERAGE = 0;
448 static const int DEFAULT_Y_AXIS_FACTOR = 1;
451private:
452 Ui::IOGraphDialog *ui;
453 CopyFromProfileButton *copy_profile_bt_;
455 // Model and delegate chosen over UatFrame to allow custom button layout.
456 QPointer<UatModel> uat_model_;
457 UatDelegate *uat_delegate_;
460 QVector<IOGraph *> ioGraphs_;
461
462 QString hint_err_;
463 QCPGraph *base_graph_;
464 QCPItemTracer *tracer_;
465 uint32_t packet_num_;
466 nstime_t start_time_;
467 bool mouse_drags_;
468 QRubberBand *rubber_band_;
469 QPoint rb_origin_;
470 QMenu ctx_menu_;
471 QTimer *stat_timer_;
472 bool need_replot_;
473 bool need_recalc_;
474 bool need_retap_;
475 bool auto_axes_;
476 int precision_;
477 const char *type_unit_name_;
479 QSharedPointer<QCPAxisTicker> number_ticker_;
480 QSharedPointer<QCPAxisTickerDateTime> datetime_ticker_;
491 QHash<int, QColor> themeDefaultColors_;
492
493
495 void zoomAxes(bool in);
497 void zoomXAxis(bool in);
499 void zoomYAxis(bool in);
505 void panAxes(int x_pixels, int y_pixels);
510 void toggleTracerStyle(bool force_default = false);
512 void getGraphInfo();
514 void updateHint();
516 void updateLegend();
522 QRectF getZoomRanges(QRect zoom_rect);
527 void createIOGraph(int currentRow);
532 void loadProfileGraphs(uat_field_t *io_graph_fields);
537 void makeCsv(QTextStream &stream) const;
543 bool saveCsv(const QString &file_name) const;
548 IOGraph *currentActiveGraph() const;
554 bool graphIsEnabled(int row) const;
560 bool graphAsAOT(int row) const;
561
562
563private slots:
573 void onThemeChanged();
574
581 static void applyChanges();
582
587 void copyFromProfile(QString filename);
588
590 void updateWidgets();
591
596 void showContextMenu(const QPoint &pos);
597
606 void graphClicked(QMouseEvent *event);
607
616 void mouseMoved(QMouseEvent *event);
617
625 void mouseReleased(QMouseEvent *event);
626
634 void selectedFrameChanged(QList<int> frames);
635
637 void moveLegend();
638
640 void resetAxes();
641
646 void updateStatistics(void);
647
649 void copyAsCsvClicked();
650
660 void graphUatSelectionChanged(const QItemSelection &selected,
661 const QItemSelection &deselected);
662
670 void on_intervalComboBox_currentIndexChanged(int index);
671
681 void on_graphUat_currentItemChanged(const QModelIndex &current,
682 const QModelIndex &previous);
683
688 void on_automaticUpdateCheckBox_toggled(bool checked);
689
691 void on_newToolButton_clicked();
693 void on_deleteToolButton_clicked();
695 void on_copyToolButton_clicked();
697 void on_clearToolButton_clicked();
699 void on_moveUpwardsToolButton_clicked();
701 void on_moveDownwardsToolButton_clicked();
702
707 void on_dragRadioButton_toggled(bool checked);
708
713 void on_zoomRadioButton_toggled(bool checked);
714
716 void on_actionReset_triggered();
718 void on_actionZoomIn_triggered();
720 void on_actionZoomInX_triggered();
722 void on_actionZoomInY_triggered();
724 void on_actionZoomOut_triggered();
726 void on_actionZoomOutX_triggered();
728 void on_actionZoomOutY_triggered();
730 void on_actionMoveUp10_triggered();
732 void on_actionMoveLeft10_triggered();
734 void on_actionMoveRight10_triggered();
736 void on_actionMoveDown10_triggered();
738 void on_actionMoveUp1_triggered();
740 void on_actionMoveLeft1_triggered();
742 void on_actionMoveRight1_triggered();
744 void on_actionMoveDown1_triggered();
746 void on_actionMoveUp100_triggered();
748 void on_actionMoveLeft100_triggered();
750 void on_actionMoveRight100_triggered();
752 void on_actionMoveDown100_triggered();
753
757 void on_actionGoToPacket_triggered();
758
760 void on_actionDragZoom_triggered();
761
765 void on_actionToggleTimeOrigin_triggered();
766
768 void on_actionCrosshairs_triggered();
769
771 void on_buttonBox_helpRequested();
772
774 void on_buttonBox_accepted();
775
780 void buttonBoxClicked(QAbstractButton *button);
781
786 void actionLegendTriggered(bool checked);
787
792 void actionTimeOfDayTriggered(bool checked);
793
798 void actionLogScaleTriggered(bool checked);
799};
800#endif // IO_GRAPH_DIALOG_H
Manages a capture file and its associated state and operations.
Definition capture_file.h:27
A button that presents a menu to copy settings from existing profiles.
Definition copy_from_profile_button.h:24
PlotStyles
Defines the available visual styles for plotting data.
Definition graph.h:37
@ psDot
Definition graph.h:45
@ psStepLine
Definition graph.h:40
@ psStackedBar
Definition graph.h:44
@ psCircle
Definition graph.h:50
@ psBar
Definition graph.h:43
@ psLine
Definition graph.h:38
@ psImpulse
Definition graph.h:42
@ psDotLine
Definition graph.h:39
@ psPlus
Definition graph.h:49
@ psDotStepLine
Definition graph.h:41
@ psCross
Definition graph.h:48
@ psSquare
Definition graph.h:46
@ psDiamond
Definition graph.h:47
Dialog for configuring and displaying I/O throughput graphs.
Definition io_graph_dialog.h:116
virtual QString getFilteredName() const
Return the display-filter-qualified window/tab title suffix.
Definition io_graph_dialog.cpp:495
void goToPacket(int packet_num)
Emitted when the plot should navigate to a specific packet.
void keyPressEvent(QKeyEvent *event)
Handle key press events.
Definition io_graph_dialog.cpp:767
void syncGraphSettings(int row)
Synchronise the QCustomPlot graph object for row with its UAT model row data.
Definition io_graph_dialog.cpp:632
void intervalChanged(int interval)
Emitted when the time interval selection changes.
void scheduleRetap(bool now=false)
Request a heavy-weight retap of all packet data.
Definition io_graph_dialog.cpp:703
void scheduleRecalc(bool now=false)
Request a medium-weight value recalculation followed by replot.
Definition io_graph_dialog.cpp:697
static const int DEFAULT_Y_AXIS_FACTOR
Definition io_graph_dialog.h:448
void reject()
Handle dialog rejection (Close button / Escape).
Definition io_graph_dialog.cpp:853
virtual const char * getYAxisName(io_graph_item_unit_t value_units) const
Return the Y-axis label for a given unit.
Definition io_graph_dialog.cpp:505
virtual QString getXAxisName() const
Return the X-axis label for this graph type.
Definition io_graph_dialog.cpp:500
void modelRowsRemoved(const QModelIndex &parent, int first, int last)
Respond to rows being removed from the UAT model.
Definition io_graph_dialog.cpp:1607
virtual int getYAxisValue(const QString &data)
Parse a Y-axis value string from the UAT and return its int value.
Definition io_graph_dialog.cpp:616
void scheduleReplot(bool now=false)
Request a lightweight replot of already-computed graph data.
Definition io_graph_dialog.cpp:691
void captureFileClosing()
Handle capture file closing.
Definition io_graph_dialog.cpp:746
void initialize(QWidget &parent, uat_field_t *io_graph_fields, QString displayFilter=QString(), io_graph_item_unit_t value_units=IOG_ITEM_UNIT_PACKETS, QString yfield=QString(), bool is_sibling_dialog=false, const QVector< QString > convFilters=QVector< QString >())
Finish initialising the dialog after construction.
Definition io_graph_dialog.cpp:371
void modelRowsInserted(const QModelIndex &parent, int first, int last)
Respond to new rows being inserted into the UAT model.
Definition io_graph_dialog.cpp:1599
virtual ~IOGraphDialog()
Destroy the dialog.
Definition io_graph_dialog.cpp:461
void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
Respond to data changes in the UAT model.
Definition io_graph_dialog.cpp:1691
void addGraph(bool checked, bool asAOT, QString name, QString dfilter, QColor color_idx, IOGraph::PlotStyles style, io_graph_item_unit_t value_units, QString yfield, int moving_average, double yaxisfactor)
Add a fully-specified graph to the dialog.
Definition io_graph_dialog.cpp:515
virtual QString getYFieldName(io_graph_item_unit_t value_units, const QString &yfield) const
Return the effective Y-axis field expression to use.
Definition io_graph_dialog.cpp:510
void recalcGraphData(capture_file *cap_file)
Emitted to trigger a full recalculation of all graph data.
virtual QString getNoDataHint() const
Return the hint text shown when no data is available.
Definition io_graph_dialog.cpp:1041
void reloadFields()
Reload the list of available Y-axis field names.
Definition io_graph_dialog.cpp:741
qsizetype graphCount() const
Return the number of graphs currently in the dialog.
Definition io_graph_dialog.cpp:681
void modelRowsReset()
Respond to a full UAT model reset.
Definition io_graph_dialog.cpp:1584
static const int DEFAULT_MOVING_AVERAGE
Definition io_graph_dialog.h:447
void modelRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
Respond to rows being moved within the UAT model.
Definition io_graph_dialog.cpp:1616
virtual QString getHintText(unsigned num_items) const
Return the status-bar hint text shown during normal operation.
Definition io_graph_dialog.cpp:1046
void reloadValueUnitFields()
Emitted to request that Y-axis field combo boxes reload their available field lists.
virtual void addDefaultGraph(bool enabled, int idx=0)
Add the default graph(s) for this dialog type.
Definition io_graph_dialog.cpp:608
Represents an individual input/output graph, handling tapping, packet processing, and data scaling.
Definition io_graph.h:66
A delegate for rendering and editing fields in User Accessible Tables (UAT).
Definition uat_delegate.h:27
Base class for Wireshark specific dialogs that require interaction with a CaptureFile.
Definition wireshark_dialog.h:38
struct _io_graph_settings_t io_graph_settings_t
Persisted configuration for a single I/O Graph plot, corresponding to one UAT row.
UatColumnsIOG
Column indices for the I/O Graph UAT (User Accessible Table) configuration table.
Definition io_graph_dialog.h:68
@ colYAxis
Definition io_graph_dialog.h:74
@ colYField
Definition io_graph_dialog.h:75
@ colColor
Definition io_graph_dialog.h:72
@ colAOT
Definition io_graph_dialog.h:78
@ colStyle
Definition io_graph_dialog.h:73
@ colName
Definition io_graph_dialog.h:70
@ colMaxNum
Definition io_graph_dialog.h:79
@ colDFilter
Definition io_graph_dialog.h:71
@ colYAxisFactor
Definition io_graph_dialog.h:77
@ colSMAPeriod
Definition io_graph_dialog.h:76
@ colEnabled
Definition io_graph_dialog.h:69
io_graph_item_unit_t
Selects the Y-axis value unit or aggregate calculation mode for an I/O graph plot.
Definition io_graph_item.h:29
@ IOG_ITEM_UNIT_PACKETS
Definition io_graph_item.h:31
Represents a capture file and its associated metadata.
Definition cfile.h:84
Persisted configuration for a single I/O Graph plot, corresponding to one UAT row.
Definition io_graph_dialog.h:49
uint32_t style
Definition io_graph_dialog.h:55
char * name
Definition io_graph_dialog.h:52
char * dfilter
Definition io_graph_dialog.h:53
char * yfield
Definition io_graph_dialog.h:57
unsigned color
Definition io_graph_dialog.h:54
bool asAOT
Definition io_graph_dialog.h:51
bool enabled
Definition io_graph_dialog.h:50
uint32_t sma_period
Definition io_graph_dialog.h:58
double y_axis_factor
Definition io_graph_dialog.h:59
uint32_t yaxis
Definition io_graph_dialog.h:56
Describes a single editable field within a UAT (User Accessible Table).
Definition uat.h:234
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
Definition nstime.h:26
Definition stream.c:41