ChartRendererManager.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/maptools/ChartRendererManager.h
22 
23  \brief This is a singleton for managing chart renderer instance available in the system.
24 */
25 
26 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_CHARTRENDERERMANAGER_H
27 #define __TERRALIB_MAPTOOLS_INTERNAL_CHARTRENDERERMANAGER_H
28 
29 // TerraLib
30 #include "../color/RGBAColor.h"
31 #include "../common/Singleton.h"
32 #include "../common/ThreadingPolicies.h"
33 #include "Config.h"
34 
35 namespace te
36 {
37 // Forward declaration
38  namespace da
39  {
40  class DataSet;
41  }
42 
43  namespace map
44  {
45 // Forward declarations
46  class AbstractChartRenderer;
47  class Chart;
48 
49  /*!
50  \class ChartRendererManager
51 
52  \brief This is a singleton for managing chart renderer instance available in the system.
53 
54  If you want to render a chart, use commands like:
55  <code>
56  te::color::RBGA** image = te::map::ChartRendererManager::getInstance().render(chart, dataset);
57  </code>
58 
59  \sa AbstractChartRenderer, Chart
60  */
62  ::boost::recursive_mutex,
63  ::boost::lock_guard< ::boost::recursive_mutex>,
64  ::boost::lock_guard< ::boost::recursive_mutex> >,
65  public te::common::Singleton<ChartRendererManager>
66  {
68 
69  public:
70 
71  /*!
72  \brief It generates the image pattern from the given chart and dataset.
73 
74  \param chart The chart informations that will be used.
75  \param dataset The dataset that will be used.
76  \param width An output parameter that will be filled with the width of generated image pattern.
77 
78  \return The RGBA image that represents the chart.
79 
80  \note The caller will take the ownership of the returned pointer.
81 
82  \exception Exception It will throws an exception if the image pattern can not be generated.
83  */
84  te::color::RGBAColor** render(const Chart* chart, const te::da::DataSet* dataset, std::size_t& width);
85 
86  te::color::RGBAColor** render(const Chart* chart, const std::map<std::string, double>& chartValue, std::size_t& width);
87 
88  /*!
89  \brief It sets the chart renderer to the manager.
90 
91  \param renderer The renderer that will be set.
92 
93  \note The manager will take the owership of the given chart renderer.
94  */
95  void set(AbstractChartRenderer* renderer);
96 
97  protected:
98 
99  /*! \brief It initializes the singleton instance of the chart renderer manager. */
101 
102  /*! \brief Singleton destructor. */
104 
105  private:
106 
107  AbstractChartRenderer* m_renderer; //!< The chart renderer in the manager.
108  };
109 
110  } // end namespace map
111 } // end namespace te
112 
113 #endif // __TERRALIB_MAPTOOLS_INTERNAL_CHARTRENDERERMANAGER_H
This is the base class for chart renderers.
A wdiget used to customize a chart's style parameters.
AbstractChartRenderer * m_renderer
The chart renderer in the manager.
This class represents the informations needed to build map charts.
Definition: Chart.h:51
URI C++ Library.
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
This policy assures a class-level locking scheme for a derived class.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
This is a singleton for managing chart renderer instance available in the system. ...
Template support for singleton pattern.
Definition: Singleton.h:100