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
56
57namespace Ui {
58 class PlotDialog;
59}
60
64typedef struct _plot_settings_t {
65 bool enabled;
66 unsigned group;
67 char *name;
68 char *dfilter;
69 unsigned color;
70 uint32_t style;
71 char *yfield;
74
75static const value_string plot_graph_style_vs[] = {
76 { Graph::psLine, "Line" },
77 { Graph::psDotLine, "Dot Line" },
78 { Graph::psStepLine, "Step Line" },
79 { Graph::psDotStepLine, "Dot Step Line" },
80 { Graph::psImpulse, "Impulse" },
81 //{ Graph::psBar, "Bar" },
82 //{ Graph::psStackedBar, "Stacked Bar" },
83 { Graph::psDot, "Dot" },
84 { Graph::psSquare, "Square" },
85 { Graph::psDiamond, "Diamond" },
86 { Graph::psCross, "Cross" },
87 { Graph::psCircle, "Circle" },
88 { Graph::psPlus, "Plus" },
89 { 0, NULL }
90};
91
96{
97 Q_OBJECT
98
99public:
105 explicit PlotDialog(QWidget &parent, CaptureFile &cf);
106
108 virtual ~PlotDialog();
109
118 void initialize(QWidget &parent, uat_field_t *plot_fields, bool show_default = true);
119
127 void addPlot(bool checked, const QString &dfilter, const QString &yfield);
128
129public slots:
131 void scheduleReplot() { need_replot_ = true; }
133 void scheduleRecalc() { need_recalc_ = true; }
135 void scheduleRetap() { need_retap_ = true; }
136
137
138protected:
142 void captureFileClosing() override;
143
148 void keyPressEvent(QKeyEvent *event) override;
149
153 void reject() override;
154
159 virtual QString getFilteredName() const;
160
165 virtual QString getYAxisName() const;
166
172 virtual QString getHintText(unsigned num_items) const;
173
179 virtual void addDefaultPlot(bool enabled, bool filtered);
180
193 void addPlot(bool checked, const QString& name, const QString& dfilter, QColor color_idx,
194 Graph::PlotStyles style, const QString &yfield,
195 double y_axis_factor = Graph::default_y_axis_factor_);
196
197protected slots:
205 void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
206 const QVector<int> &roles);
207
211 void modelRowsReset();
212
219 void modelRowsInserted(const QModelIndex &parent, int first, int last);
220
227 void modelRowsRemoved(const QModelIndex &parent, int first, int last);
228
237 void modelRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
238 const QModelIndex &destinationParent, int destinationRow);
239
240signals:
247 void goToPacket(int packet, int hf_id);
248
254 void updateMarker(const int size, const double xCoord, const int);
255
262 void setPosMarker(const double xCoord, const int selectMPos, const int posMPos);
263
264private:
269 void loadProfileGraphs(uat_field_t *plot_fields);
270
275 void createPlot(int currentRow);
276
281 void syncPlotSettings(int row);
282
287 int getLastPlotIdx();
288
294 bool graphIsEnabled(int row) const;
295
300 Plot *currentActiveGraph() const;
301
303 void getGraphInfo();
304
306 void updateHint();
307
309 void updateLegendPos();
310
312 void resetAxes();
313
319 void doZoom(bool in, bool y);
320
322 void zoomAxes(bool in);
324 void zoomXAxis(bool in);
326 void zoomYAxis(bool in);
327
333 void panAxes(int x_pixels, int y_pixels);
334
336 void updateXAxisLabel();
337
344 QRectF getZoomRanges(QRect zoom_rect, QCPAxisRect **matchedAxisRect = nullptr);
345
351 bool makeCsv(QTextStream &stream) const;
352
358 QCPAxisRect *getAxisRect(int idx);
359
364 void removeExcessPlots();
365
367 void setTracerColor();
368
374 QCPAxisRect *axisRectFromPos(const QPoint &pos);
375
379 void addMarkerDifference();
380
386 int visibleMarker(const bool first = true) const;
387
394 Marker *addMarker(const bool isPosMarker);
395
400 void drawMarker(const Marker *marker);
401
403 void drawMarkers();
404
406 void addDataPointsMarkers();
407
409 void updateFirstAxisRectHeight();
410
414 void recreateMultiValueAxes();
415
420 QList<QCPAxisRect *> axisRects() const;
421
423 void autoScroll() const;
424
425 Ui::PlotDialog *ui;
426 QPushButton *copy_bt_;
427 CopyFromProfileButton *copy_profile_bt_;
429 // Model and delegate chosen over UatFrame to allow custom button layout.
430 QPointer<UatModel> uat_model_;
431 UatDelegate *uat_delegate_;
434 QVector<Plot *> plots_;
435
436 QString hint_err_;
437 QCPGraph *base_graph_;
438 QCPItemTracer *tracer_;
439 uint32_t packet_num_;
440 double start_time_;
441 QRubberBand *rubber_band_;
442 QPoint rb_origin_;
443 QMenu ctx_menu_;
444 QTimer *stat_timer_;
445 QCPMarginGroup *margin_group_;
446 Qt::Alignment legend_alignment_;
447 bool need_replot_;
448 bool need_recalc_;
449 bool need_retap_;
450 bool auto_axes_;
451 bool abs_time_;
452 double last_right_clicked_pos_;
463 QHash<int, QColor> themeDefaultColors_;
464
465private slots:
474 void onThemeChanged();
475
479 static void applyChanges();
480
485 void updateStatistics();
486
488 void updateLegend();
489
494 void copyFromProfile(const QString &filename);
495
497 void copyAsCsvClicked();
498
503 void showContextMenu(const QPoint &pos);
504
506 void moveLegend();
507
513 void graphClicked(QMouseEvent *event);
514
519 void mouseMoved(QMouseEvent *event);
520
525 void mouseReleased(QMouseEvent *event);
526
531 void selectedFrameChanged(const QList<int> &frames);
532
538 void plotUatSelectionChanged(const QItemSelection &selected,
539 const QItemSelection &deselected);
540
545 void on_leftButtonBox_clicked(QAbstractButton *button);
546
551 void on_actionLegend_triggered(bool checked);
552
557 void on_actionLogScale_triggered(bool checked);
558
563 void on_actionCrosshairs_triggered(bool checked);
564
569 void on_actionTopAxis_triggered(bool checked);
570
575 void on_automaticUpdateCheckBox_toggled(bool checked);
576
582 void on_plotUat_currentItemChanged(const QModelIndex &current,
583 const QModelIndex &previous);
584
586 void on_actionGoToPacket_triggered();
587
589 void on_newToolButton_clicked();
591 void on_deleteToolButton_clicked();
593 void on_copyToolButton_clicked();
595 void on_clearToolButton_clicked();
597 void on_moveUpwardsToolButton_clicked();
599 void on_moveDownwardsToolButton_clicked();
600
602 void on_rightButtonBox_helpRequested();
603
605 void on_actionReset_triggered() { resetAxes(); }
607 void on_actionZoomIn_triggered() { zoomAxes(true); }
609 void on_actionZoomInX_triggered() { zoomXAxis(true); }
611 void on_actionZoomInY_triggered() { zoomYAxis(true); }
613 void on_actionZoomOut_triggered() { zoomAxes(false); }
615 void on_actionZoomOutX_triggered() { zoomXAxis(false); }
617 void on_actionZoomOutY_triggered() { zoomYAxis(false); }
619 void on_actionMoveUp10_triggered() { panAxes(0, 10); }
621 void on_actionMoveLeft10_triggered() { panAxes(-10, 0); }
623 void on_actionMoveRight10_triggered() { panAxes(10, 0); }
625 void on_actionMoveDown10_triggered() { panAxes(0, -10); }
627 void on_actionMoveUp1_triggered() { panAxes(0, 1); }
629 void on_actionMoveLeft1_triggered() { panAxes(-1, 0); }
631 void on_actionMoveRight1_triggered() { panAxes(1, 0); }
633 void on_actionMoveDown1_triggered() { panAxes(0, -1); }
635 void on_actionMoveUp100_triggered() { panAxes(0, 100); }
637 void on_actionMoveLeft100_triggered() { panAxes(-100, 0); }
639 void on_actionMoveRight100_triggered() { panAxes(100, 0); }
641 void on_actionMoveDown100_triggered() { panAxes(0, -100); }
642
646 void on_actionToggleTimeOrigin_triggered();
647
649 void on_rightButtonBox_accepted();
650
655 void on_actionAutoScroll_triggered(bool checked);
656
661 void on_actionEnableMultiYAxes_triggered(bool checked);
662
664 void on_actionAddMarker_triggered();
666 void on_actionMoveMarker_triggered();
668 void on_actionShowPosMarker_triggered();
670 void on_actionShowMarkersDifference_triggered();
672 void on_actionDeleteMarker_triggered();
674 void on_actionDeleteAllMarkers_triggered();
676 void on_actionShowDataPointMarker_triggered();
677};
678
679#endif // PLOT_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
@ psCircle
Definition graph.h:50
@ 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
static constexpr double default_y_axis_factor_
Definition graph.h:29
A widget representing a marker on a graph or timeline.
Definition marker_dialog.h:21
Dialog for configuring and displaying packet field value plots.
Definition plot_dialog.h:96
void addPlot(bool checked, const QString &dfilter, const QString &yfield)
Add a plot with default name, style, colour, and Y-axis factor.
Definition plot_dialog.cpp:632
virtual void addDefaultPlot(bool enabled, bool filtered)
Add one of the two (or four) default plots.
Definition plot_dialog.cpp:652
void scheduleRecalc()
Request a medium-weight value recalculation then replot.
Definition plot_dialog.h:133
void initialize(QWidget &parent, uat_field_t *plot_fields, bool show_default=true)
Finish initialising the dialog after construction.
Definition plot_dialog.cpp:281
void captureFileClosing() override
Handle capture file closing.
Definition plot_dialog.cpp:661
void modelRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
Respond to rows being reordered within the UAT model.
Definition plot_dialog.cpp:791
void goToPacket(int packet, int hf_id)
Emitted when the packet list should navigate to a specific packet.
void modelRowsReset()
Respond to a full UAT model reset.
Definition plot_dialog.cpp:746
virtual QString getHintText(unsigned num_items) const
Return the status-bar hint text for normal operation.
Definition plot_dialog.cpp:949
void setPosMarker(const double xCoord, const int selectMPos, const int posMPos)
Emitted to set the position of a position or difference marker.
virtual QString getYAxisName() const
Return the default Y-axis label for this dialog type.
Definition plot_dialog.cpp:627
void scheduleRetap()
Request a full retap of the capture file.
Definition plot_dialog.h:135
void keyPressEvent(QKeyEvent *event) override
Handle key press events.
Definition plot_dialog.cpp:1538
virtual ~PlotDialog()
Destroy the dialog and its associated resources.
Definition plot_dialog.cpp:324
void reject() override
Handle dialog rejection (Close button / Escape).
Definition plot_dialog.cpp:429
void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
Respond to data changes in the UAT model.
Definition plot_dialog.cpp:709
void modelRowsInserted(const QModelIndex &parent, int first, int last)
Respond to new rows being inserted into the UAT model.
Definition plot_dialog.cpp:767
void scheduleReplot()
Request a lightweight QCustomPlot replot of existing data.
Definition plot_dialog.h:131
void updateMarker(const int size, const double xCoord, const int)
Emitted to update the size and position of a measurement marker.
virtual QString getFilteredName() const
Return the display-filter-qualified window/tab title suffix.
Definition plot_dialog.cpp:622
void modelRowsRemoved(const QModelIndex &parent, int first, int last)
Respond to rows being removed from the UAT model.
Definition plot_dialog.cpp:777
A single tap-driven data series rendered on a QCustomPlot axis pair.
Definition plot.h:35
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
UatColumnsPlot
Column indices for the Plot UAT (User Accessible Table) configuration table.
Definition plot_dialog.h:45
@ plotColName
Definition plot_dialog.h:48
@ plotColIdx
Definition plot_dialog.h:47
@ plotColMaxNum
Definition plot_dialog.h:54
@ plotColColor
Definition plot_dialog.h:50
@ plotColDFilter
Definition plot_dialog.h:49
@ plotColEnabled
Definition plot_dialog.h:46
@ plotColYAxisFactor
Definition plot_dialog.h:53
@ plotColYField
Definition plot_dialog.h:52
@ plotColStyle
Definition plot_dialog.h:51
struct _plot_settings_t plot_settings_t
Persisted configuration for a single plot, corresponding to one UAT row.
Persisted configuration for a single plot, corresponding to one UAT row.
Definition plot_dialog.h:64
unsigned group
Definition plot_dialog.h:66
char * name
Definition plot_dialog.h:67
char * dfilter
Definition plot_dialog.h:68
double y_axis_factor
Definition plot_dialog.h:72
char * yfield
Definition plot_dialog.h:71
unsigned color
Definition plot_dialog.h:69
bool enabled
Definition plot_dialog.h:65
uint32_t style
Definition plot_dialog.h:70
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 stream.c:41