Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CChart.h
Go to the documentation of this file.
1/* Copyright (C) 2021 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_CCHART
19#define INCLUDED_CCHART
20
26#include "maths/Size2D.h"
27#include "maths/Vector2D.h"
28
29#include <vector>
30
32{
33 // Avoid copying the container.
36 CChartData() = default;
37
39 std::vector<CVector2D> m_Points;
40};
41
42/**
43 * Chart for a data visualization as lines or points
44 */
45class CChart : public IGUIObject, public IGUITextOwner
46{
48
49public:
50 CChart(CGUI& pGUI);
51 virtual ~CChart();
52
53protected:
54 /**
55 * @see IGUIObject#UpdateCachedSize()
56 */
57 void UpdateCachedSize();
58
59 /**
60 * @see IGUIObject#HandleMessage()
61 */
62 virtual void HandleMessage(SGUIMessage& Message);
63
64 /**
65 * Draws the Chart
66 */
67 virtual void Draw(CCanvas2D& canvas);
68
69 virtual CRect GetChartRect() const;
70
71 void UpdateSeries();
72
73 void SetupText();
74
75 std::vector<CChartData> m_Series;
76
78
79 std::vector<CVector2D> m_TextPositions;
80
82
83 // Settings
92
93private:
94 void DrawAxes(CCanvas2D& canvas) const;
95
96 CSize2D AddFormattedValue(const CStrW& format, const float value, const CStrW& font, const float buffer_zone);
97
98 void UpdateBounds();
99};
100
101#endif // INCLUDED_CCHART
#define GUI_OBJECT(obj)
Definition: IGUIObject.h:50
Definition: Canvas2D.h:36
Chart for a data visualization as lines or points.
Definition: CChart.h:46
std::vector< CVector2D > m_TextPositions
Definition: CChart.h:79
CGUISimpleSetting< CGUISeries > m_SeriesSetting
Definition: CChart.h:91
CGUISimpleSetting< CStrW > m_FormatX
Definition: CChart.h:88
void DrawAxes(CCanvas2D &canvas) const
Definition: CChart.cpp:66
CVector2D m_LeftBottom
Definition: CChart.h:77
CGUISimpleSetting< float > m_BufferZone
Definition: CChart.h:86
virtual ~CChart()
Definition: CChart.cpp:46
CVector2D m_RightTop
Definition: CChart.h:77
virtual void Draw(CCanvas2D &canvas)
Draws the Chart.
Definition: CChart.cpp:76
CGUISimpleSetting< float > m_AxisWidth
Definition: CChart.h:85
std::vector< CChartData > m_Series
Definition: CChart.h:75
bool m_EqualY
Definition: CChart.h:81
CGUISimpleSetting< CStrW > m_Font
Definition: CChart.h:87
CGUISimpleSetting< CStrW > m_FormatY
Definition: CChart.h:89
void UpdateBounds()
Definition: CChart.cpp:224
bool m_EqualX
Definition: CChart.h:81
void UpdateCachedSize()
Definition: CChart.cpp:50
void UpdateSeries()
Definition: CChart.cpp:128
CSize2D AddFormattedValue(const CStrW &format, const float value, const CStrW &font, const float buffer_zone)
Definition: CChart.cpp:186
virtual void HandleMessage(SGUIMessage &Message)
Definition: CChart.cpp:56
CChart(CGUI &pGUI)
Definition: CChart.cpp:32
void SetupText()
Setup texts.
Definition: CChart.cpp:147
virtual CRect GetChartRect() const
Definition: CChart.cpp:120
CGUISimpleSetting< CGUIColor > m_AxisColor
Definition: CChart.h:84
CGUISimpleSetting< CGUIList > m_SeriesColor
Definition: CChart.h:90
The main object that represents a whole GUI page.
Definition: CGUI.h:61
Rectangle class used for screen rectangles.
Definition: Rect.h:31
Definition: Size2D.h:25
Definition: Vector2D.h:32
GUI object such as a button or an input-box.
Definition: IGUIObject.h:60
Framework for handling Output text.
Definition: IGUITextOwner.h:53
Definition: CChart.h:32
NONCOPYABLE(CChartData)
MOVABLE(CChartData)
std::vector< CVector2D > m_Points
Definition: CChart.h:39
CChartData()=default
CGUIColor m_Color
Definition: CChart.h:38
Same as the CColor class, but this one can also parse colors predefined in the GUI page (such as "yel...
Definition: CGUIColor.h:30
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: SGUIMessage.h:68