Don't crash while in the lobby when receiving an error IQ stanza without an error...
[0ad.git] / source / gui / CChart.h
blob0aa0ae88692be4fc2e122e477e67f0380b331578
1 /* Copyright (C) 2017 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
18 #ifndef INCLUDED_CCHART
19 #define INCLUDED_CCHART
21 #include "GUI.h"
22 #include "graphics/Color.h"
23 #include "maths/Vector2D.h"
24 #include <vector>
27 struct CChartData
29 CColor m_Color;
30 std::vector<CVector2D> m_Points;
33 /**
34 * Chart for a data visualization as lines or points
36 * @see IGUIObject
38 class CChart : public IGUIObject
40 GUI_OBJECT(CChart)
42 public:
43 CChart();
44 virtual ~CChart();
46 protected:
47 /**
48 * @see IGUIObject#HandleMessage()
50 virtual void HandleMessage(SGUIMessage& Message);
52 /**
53 * Draws the Chart
55 virtual void Draw();
57 virtual CRect GetChartRect() const;
59 void UpdateSeries();
61 std::vector<CChartData> m_Series;
63 private:
64 /**
65 * Helper function
67 void DrawLine(const CShaderProgramPtr& shader, const CColor& color, const std::vector<float>& vertices) const;
70 #endif // INCLUDED_CCHART