All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ChartRenderer.h
Go to the documentation of this file.
1 /* Copyright (C) 2008-2011 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  protected:
66 
67  /** @name Internal methods of Qt4 Chart Renderer.
68  * Methods that manipulate Qt4 concepts like QPainter, QImage, QBrush, QPen, QPainterPath, etc.
69  */
70  //@{
71 
72  /*! \brief Setups the internal QPainter and associates it with the given paint device (QImage). */
73  void setup(QImage* img);
74 
75  /*! \brief Finalizes the internal QPainter resources. */
76  void end();
77 
78  //@}
79 
80  QImage* drawPies(const te::map::Chart* chart, const te::da::DataSet* dataset, std::size_t& width);
81 
82  QImage* drawBars(const te::map::Chart* chart, const te::da::DataSet* dataset, std::size_t& width);
83 
84  void getValues(const te::map::Chart* chart, const te::da::DataSet* dataset, std::vector<double>& values);
85 
86  double computeSum(const std::vector<double>& values);
87 
88  double getMaxValue(const std::vector<double>& values);
89 
90  //@}
91 
92  private:
93 
94  QPainter m_painter; //!< The painter used to draw the chart.
95  QPen m_pen; //!< The pen used to draw the chart.
96  QBrush m_brush; //!< The pen used to draw the chart.
97  };
98 
99  } // end namespace widgets
100  } // end namespace qt
101 } // end namespace te
102 
103 #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:94
QBrush m_brush
The pen used to draw the chart.
Definition: ChartRenderer.h:96
This class represents the informations needed to build map charts.
Definition: Chart.h:51
QPen m_pen
The pen used to draw the chart.
Definition: ChartRenderer.h:95
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:66
A concrete chart renderer based on Qt4.
Definition: ChartRenderer.h:53