All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MultiThreadMapDisplay.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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/canvas/MultiThreadMapDisplay.h
22 
23  \brief A multi thread Qt4 widget to control the display of a set of layers.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_MULTITHREAD_MAPDISPLAY_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_MULTITHREAD_MAPDISPLAY_H
28 
29 // TerraLib
30 #include "MapDisplay.h"
31 
32 // Qt
33 #include <QtCore/QMap>
34 #include <QtCore/QString>
35 #include <QImage>
36 
37 // STL
38 #include <vector>
39 
40 namespace te
41 {
42  namespace qt
43  {
44  namespace widgets
45  {
46 // Forward declarations
47  class DrawLayerThread;
48 
49  /*!
50  \class MultiThreadMapDisplay
51 
52  \brief A multi thread Qt4 widget to control the display of a set of layers.
53 
54  \ingroup widgets
55 
56  \sa MapDisplay, te::map::AbstractMapDisplay, te::map::MapDisplay
57  */
59  {
60  Q_OBJECT
61 
62  public:
63 
64  /** @name Initializer Methods
65  * Methods related to instantiation and destruction.
66  */
67  //@{
68 
69  /*!
70  \brief It constructs an empty multi thread map display with the given dimensions which is a child of parent, with widget flags set to f.
71 
72  \param size The map display size.
73  \param showFeedback A flag that indicates if the map display will show drawing feedback.
74  \param parent The widget's parent.
75  \param f Widget window flags.
76  */
77  MultiThreadMapDisplay(const QSize& size, const bool& showFeedback = true, QWidget* parent = 0, Qt::WindowFlags f = 0);
78 
79  /*! \brief Destructor. */
81 
82  //@}
83 
84  /** @name AbstractMapDisplay Methods
85  */
86  //@{
87 
88  void setExtent(te::gm::Envelope& e, bool doRefresh = true);
89 
90  void refresh();
91 
92  //@}
93 
94  /*!
95  \brief Transforms the given point, in screen coordinates, to a point in world coordinates.
96 
97  \param p A point in screen coordinates.
98 
99  \return The point in world coordinates.
100 
101  \note This method will return a null point if the transform can not be done.
102  */
103  virtual QPointF transform(const QPointF& p);
104 
105  private:
106 
107  void updateTransform();
108 
109  protected slots:
110 
111  void showFeedback(const QImage& image);
112 
113  void onDrawLayerFinished(const int& index, const QImage& image);
114 
115  signals:
116 
117  /*!
118  \brief This signal is emitted when the draw process ends. i.e. when all layers have been drawn.
119 
120  \param errors A map that indicates the errors that could be occurred during the draw process. i.e layer id -> error message
121 
122  \note The signal parameter maps the layer id (that generated the error) to an error message.
123 
124  \note The signal parameter can be empty. It indicates that no error occurred.
125  */
126  void drawLayersFinished(const QMap<QString, QString>& errors);
127 
128  private:
129 
130  /** @name Copy Constructor and Assignment Operator
131  * Copy constructor and assignment operator not allowed.
132  */
133  //@{
134 
135  /*!
136  \brief Copy constructor not allowed.
137 
138  \param rhs The right-hand-side copy that would be used to copy from.
139  */
141 
142  /*!
143  \brief Assignment operator not allowed.
144 
145  \param rhs The right-hand-side copy that would be used to copy from.
146 
147  \return A reference to this object.
148  */
149  MultiThreadMapDisplay& operator=(const MultiThreadMapDisplay& rhs);
150 
151  //@}
152 
153  protected:
154 
155  std::list<te::map::AbstractLayerPtr> m_visibleLayers; //!< The set of visible layers.
156  std::vector<DrawLayerThread*> m_threads; //!< The set of threads used to draw the layer list.
157  std::map<int, QImage> m_images; //!< The set of images built by each thread. It will be used to compose the final result, keeping the layer list order.
158  bool m_showFeedback; //!< A flag that indicates if the map display will show drawing feedback.
159  QMatrix m_matrix; //!< Used to convert screen coordinates to world coordinates.
160  };
161 
162  } // end namespace widgets
163  } // end namespace qt
164 } // end namespace te
165 
166 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_MULTITHREAD_MAPDISPLAY_H
A widget to control the display of a set of layers.
Definition: MapDisplay.h:65
A Qt4 widget to control the display of a set of layers.
bool m_showFeedback
A flag that indicates if the map display will show drawing feedback.
QMatrix m_matrix
Used to convert screen coordinates to world coordinates.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
std::vector< DrawLayerThread * > m_threads
The set of threads used to draw the layer list.
std::map< int, QImage > m_images
The set of images built by each thread. It will be used to compose the final result, keeping the layer list order.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:66
std::list< te::map::AbstractLayerPtr > m_visibleLayers
The set of visible layers.
A multi thread Qt4 widget to control the display of a set of layers.