Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
plot.h
Go to the documentation of this file.
1
12
13#ifndef PLOT_H
14#define PLOT_H
15
16#include <config.h>
17
18#include "graph.h"
19
20#include <vector>
21
25typedef struct _plot_item_t {
26 double frame_ts;
27 double rel_cap_ts;
28 uint32_t frame_num;
29 unsigned idx;
30 double value;
32
33class QCPRange;
34
38class Plot : public Graph {
39 Q_OBJECT
40
41public:
48 explicit Plot(QCustomPlot *parent, QCPAxis *keyAxis = nullptr, QCPAxis *valueAxis = nullptr);
49
53 ~Plot();
54
60 void setFilterField(const QString &filter, const QString &field);
61
66 void setPlotStyle(PlotStyles style);
67
73 void setVisible(bool visible);
74
79 QString configError() const { return config_err_; }
80
86 double startTime() const;
87
92 void setPlotStartTime(double start_time);
93
98 bool absoluteTime() const { return abs_time_; }
99
105 void setAbsoluteTime(bool abs_time);
106
111 void setYAxisFactor(double y_axis_factor);
112
118 int hfIndex() const { return hf_index_; }
119
125 const std::vector<plot_item_t> &getItems() const { return items_; }
126
130 void removeTapListener();
131
138 static bool itemCompare(const plot_item_t &a, const plot_item_t &b);
139
146 static bool itemRelCapCompare(const plot_item_t &a, const plot_item_t &b);
147
153 static void setAxisColor(QCPAxis *axis, const QPen &pen);
154
161 uint32_t packetFromTime(double ts) const;
162
167 void makeCsv(QTextStream &stream) const;
168
175 QCPRange recentDrawnDataRange(int count) const;
176
177public slots:
182 void captureEvent(const CaptureEvent &e);
183
184
185signals:
188
191
194
195private:
196 // Static trampoline callbacks passed to register_tap_listener.
198 static void tap_reset(void *plot_ptr);
200 static tap_packet_status tap_packet(void *plot_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *data, tap_flags_t flags);
202 static void tap_draw(void *plot_ptr);
203
205 void tapReset();
215 tap_packet_status tapPacket(packet_info *pinfo, epan_dissect_t *edt, const void *data _U_, tap_flags_t flags _U_);
217 void tapDraw();
218
219 nstime_t first_packet_;
220 double plot_start_time_;
221 bool abs_time_;
222 bool tap_registered_;
223 bool retap_needed_;
224 int hf_index_;
225 QString full_filter_;
226 QString config_err_;
227
228 std::vector<plot_item_t> items_;
229};
230
231#endif // PLOT_H
Represents an event occurring during a capture or file operation.
Definition capture_event.h:24
PlotStyles
Defines the available visual styles for plotting data.
Definition graph.h:37
bool visible() const
Checks if the graph is currently visible.
Definition graph.h:94
Graph(QCustomPlot *parent, QCPAxis *keyAxis=nullptr, QCPAxis *valueAxis=nullptr)
Constructs a new Graph.
Definition graph.cpp:15
void requestReplot()
Emitted to request a lightweight QCustomPlot replot without recalculation.
void captureEvent(const CaptureEvent &e)
React to a capture lifecycle event.
Definition plot.cpp:51
~Plot()
Destroy the Plot.
Definition plot.cpp:47
Plot(QCustomPlot *parent, QCPAxis *keyAxis=nullptr, QCPAxis *valueAxis=nullptr)
Construct a Plot.
Definition plot.cpp:19
void setYAxisFactor(double y_axis_factor)
Set a multiplier applied to all Y-axis values before plotting.
Definition plot.cpp:220
static void setAxisColor(QCPAxis *axis, const QPen &pen)
Set the pen colour of all visual components of a QCPAxis.
Definition plot.cpp:269
static bool itemRelCapCompare(const plot_item_t &a, const plot_item_t &b)
Compare two plot items by relative capture timestamp.
Definition plot.cpp:240
void makeCsv(QTextStream &stream) const
Write all plot items as CSV rows to stream.
Definition plot.cpp:368
void removeTapListener()
Remove this plot's tap listener, if one is registered.
Definition plot.cpp:60
void requestRecalc()
Emitted to request a medium-weight value recalculation followed by replot.
double startTime() const
Return the capture timestamp of the first packet seen by this plot.
Definition plot.cpp:189
void setVisible(bool visible)
Show or hide this plot on the graph.
Definition plot.cpp:173
void setPlotStartTime(double start_time)
Set the shared plot start time used for relative-time calculations.
Definition plot.cpp:204
int hfIndex() const
Return the resolved header field index for the Y-axis field.
Definition plot.h:118
void setPlotStyle(PlotStyles style)
Set the visual plot style for this series.
Definition plot.cpp:148
QString configError() const
Return any configuration error set by setFilterField().
Definition plot.h:79
bool absoluteTime() const
Return whether this plot uses absolute (wall-clock) time on the X axis.
Definition plot.h:98
uint32_t packetFromTime(double ts) const
Return the frame number of the packet closest to a given timestamp.
Definition plot.cpp:252
void requestRetap()
Emitted to request a full retap of the capture file.
static bool itemCompare(const plot_item_t &a, const plot_item_t &b)
Compare two plot items by absolute capture timestamp.
Definition plot.cpp:228
void setFilterField(const QString &filter, const QString &field)
Set the display filter and Y-axis field for this plot.
Definition plot.cpp:68
const std::vector< plot_item_t > & getItems() const
Return read-only access to the collected plot items.
Definition plot.h:125
void setAbsoluteTime(bool abs_time)
Set the X-axis time display mode.
Definition plot.cpp:212
QCPRange recentDrawnDataRange(int count) const
Return the key (X-axis) range covering the most recent count items.
Definition plot.cpp:387
struct epan_dissect epan_dissect_t
Opaque type representing a single packet dissection context.
Definition epan.h:62
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
struct _plot_item_t plot_item_t
Represents a single data point sampled from a packet field for plotting.
Represents a single data point sampled from a packet field for plotting.
Definition plot.h:25
unsigned idx
Definition plot.h:29
double rel_cap_ts
Definition plot.h:27
double frame_ts
Definition plot.h:26
double value
Definition plot.h:30
uint32_t frame_num
Definition plot.h:28
Definition nstime.h:26
Definition stream.c:41
tap_packet_status
Definition tap.h:22