Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
plot.h
Go to the documentation of this file.
1
13#ifndef PLOT_H
14#define PLOT_H
15
16#include <config.h>
17
18#include "graph.h"
19
20#include <vector>
21
22typedef struct _plot_item_t {
23 double frame_ts; /* Absolute timestamp of the packet */
24 double rel_cap_ts; /* Time relative from capture start */
25 uint32_t frame_num; /* Packet number */
26 unsigned idx; /* Istance of the field in the packet */
27 double value; /* Value of the field (always converted to double) */
29
30class QCPRange;
31
35class Plot : public Graph {
36 Q_OBJECT
37
38public:
45 explicit Plot(QCustomPlot *parent, QCPAxis *keyAxis = nullptr, QCPAxis *valueAxis = nullptr);
46
50 ~Plot();
51
57 void setFilterField(const QString &filter, const QString &field);
58
63 void setPlotStyle(PlotStyles style);
64
70 void setVisible(bool visible);
71
76 QString configError() const { return config_err_; }
77
83 double startTime() const;
84
89 void setPlotStartTime(double start_time);
90
95 bool absoluteTime() const { return abs_time_; }
96
102 void setAbsoluteTime(bool abs_time);
103
108 void setYAxisFactor(double y_axis_factor);
109
115 int hfIndex() const { return hf_index_; }
116
122 const std::vector<plot_item_t> &getItems() const { return items_; }
123
127 void removeTapListener();
128
135 static bool itemCompare(const plot_item_t &a, const plot_item_t &b);
136
143 static bool itemRelCapCompare(const plot_item_t &a, const plot_item_t &b);
144
150 static void setAxisColor(QCPAxis *axis, const QPen &pen);
151
158 uint32_t packetFromTime(double ts) const;
159
164 void makeCsv(QTextStream &stream) const;
165
172 QCPRange recentDrawnDataRange(int count) const;
173
174public slots:
179 void captureEvent(const CaptureEvent &e);
180
181
182signals:
185
188
191
192private:
193 // Static trampoline callbacks passed to register_tap_listener.
195 static void tap_reset(void *plot_ptr);
197 static tap_packet_status tap_packet(void *plot_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *data, tap_flags_t flags);
199 static void tap_draw(void *plot_ptr);
200
202 void tapReset();
212 tap_packet_status tapPacket(packet_info *pinfo, epan_dissect_t *edt, const void *data _U_, tap_flags_t flags _U_);
214 void tapDraw();
215
216 nstime_t first_packet_;
217 double plot_start_time_;
218 bool abs_time_;
219 bool tap_registered_;
220 bool retap_needed_;
221 int hf_index_;
222 QString full_filter_;
223 QString config_err_;
225 std::vector<plot_item_t> items_;
226};
227
228#endif // PLOT_H
Represents an event occurring during a capture or file operation.
Definition capture_event.h:24
Represents a single data graph within a QCustomPlot, managing its data, visual style,...
Definition graph.h:25
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
A single tap-driven data series rendered on a QCustomPlot axis pair.
Definition plot.h:35
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
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:115
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:76
bool absoluteTime() const
Return whether this plot uses absolute (wall-clock) time on the X axis.
Definition plot.h:95
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:122
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
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
Definition plot.h:22
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
Definition nstime.h:26
Definition stream.c:41
tap_packet_status
Definition tap.h:22