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