Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
Graph.h
Go to the documentation of this file.
1#pragma once
2#include <QPainter>
3#include <QPalette>
4#include <misc/gen/pointer.h>
5#include <misc/global.h>
6#include <misc/qt/Draw.h>
7
8namespace sf
9{
10
17{
18 public:
22 explicit Graph(const QPalette& palette = {});
23
32 void setRuler(Draw::ERulerOrientation ro, double start, double stop, int digits, const QString& unit);
33
42
49 void setBounds(const QFontMetrics& fontMetrics, const QRect& bounds);
50
59 const QRect& paint(QPainter& painter, const QRect& bounds, const QRegion& region = null_ref<QRegion>());
60
67 void paintPlotCross(QPainter& painter, const QString& text);
68
73 [[nodiscard]] const QRect& getPlotArea() const;
74
94
100 void setColor(EColor index, QColor color);
101
105 bool _debug{false};
106
107 protected:
111 QVector<QColor> _colors;
112
118 {
122 bool enabled{false};
126 double start{0};
130 double stop{0};
134 int digits{3};
138 QString unit;
142 QRect bounds;
146 QRect rect;
150 int size{100};
151
152 } _top, _left, _right, _bottom;
153
158
165
170};
171
172}// namespace sf
ERulerOrientation
Orientation for drawing a graph ruler.
Definition Draw.h:26
@ roNone
Definition Draw.h:28
EGridOrientation
Orientation for drawing grid lines in a graph.
Definition Draw.h:62
EColor
Colors enumeration of colors in the graph. Used by setColor function.
Definition Graph.h:80
@ cRulerLine
Definition Graph.h:84
@ cGridLines
Definition Graph.h:86
@ cGraphBackground
Definition Graph.h:90
@ cGraphForeground
Definition Graph.h:92
@ cRulerText
Definition Graph.h:82
@ cRulerBackground
Definition Graph.h:88
bool _debug
Draws only area bounds contours when enabled.
Definition Graph.h:105
QVector< QColor > _colors
Holds the colors for painting the rulers en grid.
Definition Graph.h:111
Draw::ERulerOrientation _horizontal
Holds which ruler information is responsible.
Definition Graph.h:157
void paintPlotCross(QPainter &painter, const QString &text)
Paints a cross with text in the plot area. Used when a plot can not be painted.
void setRuler(Draw::ERulerOrientation ro, double start, double stop, int digits, const QString &unit)
Sets and thus enabling the ruler for the passed orientation.
const QRect & paint(QPainter &painter, const QRect &bounds, const QRegion &region=null_ref< QRegion >())
Paints the graph. Paints the graph passing the passed boundaries and the optional region when handlin...
QRect _plotArea
Holds the last calculated graph area rectangle.
Definition Graph.h:169
void setColor(EColor index, QColor color)
Allows setting of individual indexed colors for the graph.
RulerInfo * getRulerInfo(Draw::ERulerOrientation ro)
Gets the ruler information by orientation.
const QRect & getPlotArea() const
Gets the remaining area to plot the graph after rulers and grid have been painted.
Graph(const QPalette &palette={})
Constructor passing a palette.
void setGrid(Draw::EGridOrientation go, Draw::ERulerOrientation ro)
Enables grid painting in the graph. When painting this enables drawing grid for the passed orientatio...
void setBounds(const QFontMetrics &fontMetrics, const QRect &bounds)
Sets the bounding rectangle for the graph for painting in. Paints the graph passing the passed bounda...
#define _MISC_CLASS
Definition misc/global.h:40
Definition Application.h:10
_MISC_FUNC int digits(double value)
Returns the amount of digits which are significant for the value. When the value is 12300....
T & null_ref()
Definition pointer.h:123
Holds information on the rulers. Holds set and calculated information.
Definition Graph.h:118
int digits
Precision digits.
Definition Graph.h:134
QRect rect
Rectangle for the ticks.
Definition Graph.h:146
QString unit
unit text.
Definition Graph.h:138
bool enabled
Ruler enabled flag.
Definition Graph.h:122
QRect bounds
Bounds of the ruler area for painting value texts i.e.
Definition Graph.h:142
int size
Calculated ruler size (width/height).
Definition Graph.h:150
double start
Ruler start value.
Definition Graph.h:126
double stop
Ruler stop value.
Definition Graph.h:130