ChartRenderer.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/charts/ChartRenderer.h
22 
23  \brief A concrete chart renderer based on Qt4.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_CHARTRENDERER_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_CHARTRENDERER_H
28 
29 // TerraLib
30 #include "../../../maptools/AbstractChartRenderer.h"
31 #include "../Config.h"
32 
33 // Qt
34 #include <QImage>
35 #include <QPainter>
36 
37 // STL
38 #include <vector>
39 
40 namespace te
41 {
42  namespace qt
43  {
44  namespace widgets
45  {
46  /*!
47  \class ChartRenderer
48 
49  \brief A concrete chart renderer based on Qt4.
50 
51  \sa AbstractChartRenderer
52  */
54  {
55  public:
56 
57  /*! \brief Default constructor. */
58  ChartRenderer();
59 
60  /*! \brief Destructor. */
61  ~ChartRenderer();
62 
63  te::color::RGBAColor** render(const te::map::Chart* chart, const te::da::DataSet* dataset, std::size_t& width);
64 
65  te::color::RGBAColor** render(const te::map::Chart* chart, const std::map<std::string, double>& chartValue, std::size_t& width);
66 
67  protected:
68 
69  /** @name Internal methods of Qt4 Chart Renderer.
70  * Methods that manipulate Qt4 concepts like QPainter, QImage, QBrush, QPen, QPainterPath, etc.
71  */
72  //@{
73 
74  /*! \brief Setups the internal QPainter and associates it with the given paint device (QImage). */
75  void setup(QImage* img);
76 
77  /*! \brief Finalizes the internal QPainter resources. */
78  void end();
79 
80  //@}
81 
82  QImage* drawPies(const te::map::Chart* chart, const te::da::DataSet* dataset, std::size_t& width);
83  QImage* drawPies(const te::map::Chart* chart, const std::map<std::string, double>& chartValue, std::size_t& width);
84 
85  QImage* drawBars(const te::map::Chart* chart, const te::da::DataSet* dataset, std::size_t& width);
86  QImage* drawBars(const te::map::Chart* chart, const std::map<std::string, double>& chartValue, std::size_t& width);
87 
88  void getValues(const te::map::Chart* chart, const te::da::DataSet* dataset, std::vector<double>& values);
89  void getValues(const te::map::Chart* chart, const std::map<std::string, double>& chartValue, std::vector<double>& values);
90 
91  double computeSum(const std::vector<double>& values);
92 
93  double getMaxValue(const std::vector<double>& values);
94 
95  //@}
96 
97  private:
98 
99  QPainter m_painter; //!< The painter used to draw the chart.
100  QPen m_pen; //!< The pen used to draw the chart.
101  QBrush m_brush; //!< The pen used to draw the chart.
102  };
103 
104  } // end namespace widgets
105  } // end namespace qt
106 } // end namespace te
107 
108 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_CHARTRENDERER_H
This is the base class for chart renderers.
QPainter m_painter
The painter used to draw the chart.
Definition: ChartRenderer.h:99
QBrush m_brush
The pen used to draw the chart.
This class represents the informations needed to build map charts.
Definition: Chart.h:51
URI C++ Library.
QPen m_pen
The pen used to draw the chart.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
A concrete chart renderer based on Qt4.
Definition: ChartRenderer.h:53