Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
graph.h
Go to the documentation of this file.
1
10#ifndef GRAPH_H
11#define GRAPH_H
12
13#include <config.h>
14
15#include "wireshark_dialog.h"
16
17class QCPAxis;
18class QCPBars;
19class QCPGraph;
20class QCustomPlot;
21
25class Graph : public QObject {
26 Q_OBJECT
27public:
29 static constexpr double default_y_axis_factor_ = 1;
30
32 const qreal graph_line_width_ = 1.0;
33
52
59 explicit Graph(QCustomPlot* parent, QCPAxis* keyAxis = nullptr, QCPAxis* valueAxis = nullptr);
60
64 ~Graph();
65
70 QString name() const { return name_; }
71
76 void setName(const QString& name);
77
82 QRgb color() const;
83
88 void setColor(const QRgb color);
89
94 bool visible() const { return visible_; }
95
100 void setVisible(bool visible);
101
106 double yAxisFactor() const { return y_axis_factor_; }
107
112 void setYAxisFactor(double y_axis_factor);
113
118 QCPGraph* graph() const { return graph_; }
119
124 QCPBars* bars() const { return bars_; }
125
130 bool addToLegend();
131
137 bool setPlotStyle(PlotStyles style);
138
139protected:
141 QCustomPlot* parent_;
142
144 QCPGraph* graph_;
145
147 QCPBars* bars_;
148
150 QString name_;
151
153 QBrush color_;
154
157
160
164 void applyCurrentColor();
165
170 bool removeFromLegend();
171
175 void clearAllData();
176};
177
178#endif // GRAPH_H
Represents a single data graph within a QCustomPlot, managing its data, visual style,...
Definition graph.h:25
void setName(const QString &name)
Sets the name of the graph.
Definition graph.cpp:36
QCPGraph * graph() const
Retrieves the underlying QCPGraph object.
Definition graph.h:118
QCPGraph * graph_
Definition graph.h:144
QRgb color() const
Retrieves the color of the graph.
Definition graph.cpp:47
QString name() const
Retrieves the name of the graph.
Definition graph.h:70
bool visible_
Definition graph.h:156
QCPBars * bars() const
Retrieves the underlying QCPBars object.
Definition graph.h:124
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
bool setPlotStyle(PlotStyles style)
Sets the visual style of the plot.
Definition graph.cpp:125
bool removeFromLegend()
Removes the graph from the parent plot's legend.
Definition graph.cpp:104
const qreal graph_line_width_
Definition graph.h:32
static constexpr double default_y_axis_factor_
Definition graph.h:29
QString name_
Definition graph.h:150
bool visible() const
Checks if the graph is currently visible.
Definition graph.h:94
QBrush color_
Definition graph.h:153
QCPBars * bars_
Definition graph.h:147
~Graph()
Destroys the Graph.
Definition graph.cpp:27
QCustomPlot * parent_
Definition graph.h:141
void setVisible(bool visible)
Sets the visibility of the graph.
Definition graph.cpp:77
double yAxisFactor() const
Retrieves the scaling factor for the Y-axis.
Definition graph.h:106
void applyCurrentColor()
Applies the currently set color to the underlying graphical elements.
Definition graph.cpp:58
void setYAxisFactor(double y_axis_factor)
Sets the scaling factor for the Y-axis.
Definition graph.cpp:88
double y_axis_factor_
Definition graph.h:159
void setColor(const QRgb color)
Sets the color of the graph.
Definition graph.cpp:52
void clearAllData()
Clears all data points currently loaded into the graph.
Definition graph.cpp:115
bool addToLegend()
Adds the graph to the parent plot's legend.
Definition graph.cpp:93