LCOV - code coverage report
Current view: top level - source/gui/ObjectTypes - CChart.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 4 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 4 0.0 %

          Line data    Source code
       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           0 : struct CChartData
      32             : {
      33             :     // Avoid copying the container.
      34             :     NONCOPYABLE(CChartData);
      35           0 :     MOVABLE(CChartData);
      36           0 :     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           0 :     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

Generated by: LCOV version 1.13