Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
io_graph_dialog.h
Go to the documentation of this file.
1
9
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 "graph_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
152 void initialize(QWidget &parent, uat_field_t *io_graph_fields,
153 QString displayFilter = QString(),
155 QString yfield = QString(),
156 bool is_sibling_dialog = false,
157 const QVector<QString> convFilters = QVector<QString>(),
158 const QVector<QString> convNames = QVector<QString>());
159
160
177 void addGraph(bool checked, bool asAOT, QString name, QString dfilter,
179 io_graph_item_unit_t value_units, QString yfield,
180 int moving_average, double yaxisfactor);
181
194 void addGraph(bool checked, bool asAOT, QString dfilter,
195 io_graph_item_unit_t value_units, QString yfield);
196
202 void addGraph(bool copy_from_current = false);
203
214 void syncGraphSettings(int row);
215
220 qsizetype graphCount() const;
221
222protected:
223
233 virtual void insertGraph(bool enabled);
234
235public slots:
246 void scheduleReplot(bool now = false);
247
256 void scheduleRecalc(bool now = false);
257
266 void scheduleRetap(bool now = false);
267
274 void reloadFields();
275
276
277protected:
284 void captureFileClosing() override;
285
294 void keyPressEvent(QKeyEvent *event) override;
295
301 void reject() override;
302
311 virtual QString getFilteredName() const;
312
317 virtual QString getXAxisName() const;
318
324 virtual const char *getYAxisName(io_graph_item_unit_t value_units) const;
325
335 virtual QString getYFieldName(io_graph_item_unit_t value_units, const QString &yfield) const;
336
346 virtual int getYAxisValue(const QString &data);
347
353 virtual QString getNoDataHint() const;
354
360 virtual QString getHintText(unsigned num_items) const;
361
362
363protected slots:
375 void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
376 const QVector<int> &roles);
377
384 void modelRowsReset();
385
396 void modelRowsInserted(const QModelIndex &parent, int first, int last);
397
408 void modelRowsRemoved(const QModelIndex &parent, int first, int last);
409
422 void modelRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
423 const QModelIndex &destinationParent, int destinationRow);
424
425
426signals:
431 void goToPacket(int packet_num);
432
438
443 void intervalChanged(int interval);
444
450
451
452protected:
453 static const int DEFAULT_MOVING_AVERAGE = 0;
454 static const int DEFAULT_Y_AXIS_FACTOR = 1;
455
456
457private:
458 Ui::IOGraphDialog *ui;
459 CopyFromProfileButton *copy_profile_bt_;
460
461 // Model and delegate chosen over UatFrame to allow custom button layout.
462 UatDelegate *uat_delegate_;
463
465 QVector<IOGraph *> ioGraphs_;
466
467 QString hint_err_;
468 QCPGraph *base_graph_;
469 QCPItemTracer *tracer_;
470 uint32_t packet_num_;
471 nstime_t start_time_;
472 bool mouse_drags_;
473 QRubberBand *rubber_band_;
474 QPoint rb_origin_;
475 QMenu ctx_menu_;
476 QTimer *stat_timer_;
477 bool need_replot_;
478 bool need_recalc_;
479 bool need_retap_;
480 bool auto_axes_;
481 int precision_;
482 const char *type_unit_name_;
483
484 QSharedPointer<QCPAxisTicker> number_ticker_;
485 QSharedPointer<QCPAxisTickerDateTime> datetime_ticker_;
486
487
489 void zoomAxes(bool in);
491 void zoomXAxis(bool in);
493 void zoomYAxis(bool in);
499 void panAxes(int x_pixels, int y_pixels);
504 void toggleTracerStyle(bool force_default = false);
506 void getGraphInfo();
508 void updateHint();
510 void updateLegend();
516 QRectF getZoomRanges(QRect zoom_rect);
521 void createIOGraph(int currentRow);
526 void loadProfileGraphs(uat_field_t *io_graph_fields);
531 void makeCsv(QTextStream &stream) const;
537 bool saveCsv(const QString &file_name) const;
542 IOGraph *currentActiveGraph() const;
548 bool graphIsEnabled(int row) const;
554 bool graphAsAOT(int row) const;
555
556
557private slots:
564 static void applyChanges();
565
570 void copyFromProfile(QString filename);
571
573 void updateWidgets() override;
574
579 void showContextMenu(const QPoint &pos);
580
589 void graphClicked(QMouseEvent *event);
590
599 void mouseMoved(QMouseEvent *event);
600
608 void mouseReleased(QMouseEvent *event);
609
617 void selectedFrameChanged(QList<int> frames);
618
620 void moveLegend();
621
623 void resetAxes();
624
629 void updateStatistics(void);
630
632 void copyAsCsvClicked();
633
643 void graphUatSelectionChanged(const QItemSelection &selected,
644 const QItemSelection &deselected);
645
653 void on_intervalComboBox_currentIndexChanged(int index);
654
664 void on_graphUat_currentItemChanged(const QModelIndex &current,
665 const QModelIndex &previous);
666
671 void on_automaticUpdateCheckBox_toggled(bool checked);
672
674 void on_newToolButton_clicked();
676 void on_deleteToolButton_clicked();
678 void on_copyToolButton_clicked();
680 void on_clearToolButton_clicked();
682 void on_moveUpwardsToolButton_clicked();
684 void on_moveDownwardsToolButton_clicked();
685
690 void on_dragRadioButton_toggled(bool checked);
691
696 void on_zoomRadioButton_toggled(bool checked);
697
699 void on_actionReset_triggered();
701 void on_actionZoomIn_triggered();
703 void on_actionZoomInX_triggered();
705 void on_actionZoomInY_triggered();
707 void on_actionZoomOut_triggered();
709 void on_actionZoomOutX_triggered();
711 void on_actionZoomOutY_triggered();
713 void on_actionMoveUp10_triggered();
715 void on_actionMoveLeft10_triggered();
717 void on_actionMoveRight10_triggered();
719 void on_actionMoveDown10_triggered();
721 void on_actionMoveUp1_triggered();
723 void on_actionMoveLeft1_triggered();
725 void on_actionMoveRight1_triggered();
727 void on_actionMoveDown1_triggered();
729 void on_actionMoveUp100_triggered();
731 void on_actionMoveLeft100_triggered();
733 void on_actionMoveRight100_triggered();
735 void on_actionMoveDown100_triggered();
736
740 void on_actionGoToPacket_triggered();
741
743 void on_actionDragZoom_triggered();
744
748 void on_actionToggleTimeOrigin_triggered();
749
751 void on_actionCrosshairs_triggered();
752
754 void on_buttonBox_helpRequested();
755
757 void on_buttonBox_accepted();
758
763 void buttonBoxClicked(QAbstractButton *button);
764
769 void actionLegendTriggered(bool checked);
770
775 void actionTimeOfDayTriggered(bool checked);
776
781 void actionLogScaleTriggered(bool checked);
782
787 void actionMATriggered(bool checked);
788};
789#endif // IO_GRAPH_DIALOG_H
struct _capture_file capture_file
Represents a capture file and its associated metadata.
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
GraphDialog(QWidget &parent, CaptureFile &cf, int colorColumn)
Constructs the dialog and follows theme changes.
Definition graph_dialog.cpp:14
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
virtual QString getFilteredName() const
Return the display-filter-qualified window/tab title suffix.
Definition io_graph_dialog.cpp:498
void goToPacket(int packet_num)
Emitted when the plot should navigate to a specific packet.
void syncGraphSettings(int row)
Synchronise the QCustomPlot graph object for row with its UAT model row data.
Definition io_graph_dialog.cpp:640
virtual void insertGraph(bool enabled)
Add a graph to this dialog type.
Definition io_graph_dialog.cpp:608
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:711
void scheduleRecalc(bool now=false)
Request a medium-weight value recalculation followed by replot.
Definition io_graph_dialog.cpp:705
static const int DEFAULT_Y_AXIS_FACTOR
Definition io_graph_dialog.h:454
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:508
virtual QString getXAxisName() const
Return the X-axis label for this graph type.
Definition io_graph_dialog.cpp:503
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 >(), const QVector< QString > convNames=QVector< QString >())
Finish initialising the dialog after construction.
Definition io_graph_dialog.cpp:369
void modelRowsRemoved(const QModelIndex &parent, int first, int last)
Respond to rows being removed from the UAT model.
Definition io_graph_dialog.cpp:1571
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:624
void scheduleReplot(bool now=false)
Request a lightweight replot of already-computed graph data.
Definition io_graph_dialog.cpp:699
void keyPressEvent(QKeyEvent *event) override
Handle key press events.
Definition io_graph_dialog.cpp:743
void captureFileClosing() override
Handle capture file closing.
Definition io_graph_dialog.cpp:722
void modelRowsInserted(const QModelIndex &parent, int first, int last)
Respond to new rows being inserted into the UAT model.
Definition io_graph_dialog.cpp:1563
virtual ~IOGraphDialog()
Destroy the dialog.
Definition io_graph_dialog.cpp:464
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:1642
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:513
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:1017
void reloadFields()
Reload the list of available Y-axis field names.
Definition io_graph_dialog.cpp:717
void addGraph(bool checked, bool asAOT, QString name, QString dfilter, 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:518
qsizetype graphCount() const
Return the number of graphs currently in the dialog.
Definition io_graph_dialog.cpp:689
void reject() override
Handle dialog rejection (Close button / Escape).
Definition io_graph_dialog.cpp:829
void modelRowsReset()
Respond to a full UAT model reset.
Definition io_graph_dialog.cpp:1548
static const int DEFAULT_MOVING_AVERAGE
Definition io_graph_dialog.h:453
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:1580
virtual QString getHintText(unsigned num_items) const
Return the status-bar hint text shown during normal operation.
Definition io_graph_dialog.cpp:1022
void reloadValueUnitFields()
Emitted to request that Y-axis field combo boxes reload their available field lists.
IOGraphDialog(QWidget &parent, CaptureFile &cf, const char *type_unit_name)
Construct an IOGraphDialog.
Definition io_graph_dialog.cpp:219
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
virtual void updateWidgets()
Updates the state and contents of the dialog's widgets.
Definition wireshark_dialog.cpp:92
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
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
Definition nstime.h:26
Definition stream.c:41
struct _uat_field_t uat_field_t
Describes a single editable field within a UAT (User Accessible Table).
struct _value_string value_string
Mapping between a 32-bit integer value and its string representation.