Pyrogenesis
trunk
source
gui
ObjectTypes
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
21
#include "
gui/ObjectBases/IGUIObject.h
"
22
#include "
gui/ObjectBases/IGUITextOwner.h
"
23
#include "
gui/SettingTypes/CGUIColor.h
"
24
#include "
gui/SettingTypes/CGUIList.h
"
25
#include "
gui/SettingTypes/CGUISeries.h
"
26
#include "
maths/Size2D.h
"
27
#include "
maths/Vector2D.h
"
28
29
#include <vector>
30
31
struct
CChartData
32
{
33
// Avoid copying the container.
34
NONCOPYABLE
(
CChartData
);
35
MOVABLE
(
CChartData
);
36
CChartData
() =
default
;
37
38
CGUIColor
m_Color
;
39
std::vector<CVector2D>
m_Points
;
40
};
41
42
/**
43
* Chart for a data visualization as lines or points
44
*/
45
class
CChart
:
public
IGUIObject
,
public
IGUITextOwner
46
{
47
GUI_OBJECT
(
CChart
)
48
49
public
:
50
CChart
(
CGUI
& pGUI);
51
virtual
~
CChart
();
52
53
protected
:
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
77
CVector2D
m_LeftBottom,
m_RightTop
;
78
79
std::vector<CVector2D>
m_TextPositions
;
80
81
bool
m_EqualX,
m_EqualY
;
82
83
// Settings
84
CGUISimpleSetting<CGUIColor>
m_AxisColor
;
85
CGUISimpleSetting<float>
m_AxisWidth
;
86
CGUISimpleSetting<float>
m_BufferZone
;
87
CGUISimpleSetting<CStrW>
m_Font
;
88
CGUISimpleSetting<CStrW>
m_FormatX
;
89
CGUISimpleSetting<CStrW>
m_FormatY
;
90
CGUISimpleSetting<CGUIList>
m_SeriesColor
;
91
CGUISimpleSetting<CGUISeries>
m_SeriesSetting
;
92
93
private
:
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
CChart::m_AxisColor
CGUISimpleSetting< CGUIColor > m_AxisColor
Definition:
CChart.h:84
CChartData::NONCOPYABLE
NONCOPYABLE(CChartData)
CGUIColor
Same as the CColor class, but this one can also parse colors predefined in the GUI page (such as "yel...
Definition:
CGUIColor.h:29
GUIRenderer::Draw
void Draw(DrawCalls &Calls, CCanvas2D &canvas)
Definition:
GUIRenderer.cpp:314
Vector2D.h
Size2D.h
CChartData::m_Points
std::vector< CVector2D > m_Points
Definition:
CChart.h:39
IGUIObject
GUI object such as a button or an input-box.
Definition:
IGUIObject.h:59
IGUITextOwner.h
CChart::m_FormatX
CGUISimpleSetting< CStrW > m_FormatX
Definition:
CChart.h:88
CGUISimpleSetting< CGUIColor >
CGUI
The main object that represents a whole GUI page.
Definition:
CGUI.h:60
CSize2D
Definition:
Size2D.h:24
CChart::m_EqualY
bool m_EqualY
Definition:
CChart.h:81
CGUISeries.h
CChartData::MOVABLE
MOVABLE(CChartData)
IGUITextOwner
Framework for handling Output text.
Definition:
IGUITextOwner.h:52
CGUIList.h
CChart::m_SeriesColor
CGUISimpleSetting< CGUIList > m_SeriesColor
Definition:
CChart.h:90
CChart::m_SeriesSetting
CGUISimpleSetting< CGUISeries > m_SeriesSetting
Definition:
CChart.h:91
IGUIObject.h
CCanvas2D
Definition:
Canvas2D.h:35
CGUIColor.h
CChart::m_Series
std::vector< CChartData > m_Series
Definition:
CChart.h:75
CChart::m_TextPositions
std::vector< CVector2D > m_TextPositions
Definition:
CChart.h:79
CVector2D
Definition:
Vector2D.h:31
CChart::m_RightTop
CVector2D m_RightTop
Definition:
CChart.h:77
CChart
Chart for a data visualization as lines or points.
Definition:
CChart.h:45
CChart::m_AxisWidth
CGUISimpleSetting< float > m_AxisWidth
Definition:
CChart.h:85
CChart::m_BufferZone
CGUISimpleSetting< float > m_BufferZone
Definition:
CChart.h:86
CChartData::m_Color
CGUIColor m_Color
Definition:
CChart.h:38
CChartData
Definition:
CChart.h:31
GUI_OBJECT
#define GUI_OBJECT(obj)
Definition:
IGUIObject.h:50
CChart::m_FormatY
CGUISimpleSetting< CStrW > m_FormatY
Definition:
CChart.h:89
SGUIMessage
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition:
SGUIMessage.h:67
CChart::m_Font
CGUISimpleSetting< CStrW > m_Font
Definition:
CChart.h:87
CChartData::CChartData
CChartData()=default
CRect
Rectangle class used for screen rectangles.
Definition:
Rect.h:30
Generated by
1.8.13