MapDisplay.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 TerraView - A GIS Application.
4 
5  TerraView is free software: you can redistribute it and/or modify
6  it under the terms of the GNU 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  TerraView 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 General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with TerraLib Code Editor. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@dpi.inpe.br>.
18  */
19 
20 /*!
21  \file terralib/qt/af/connectors/MapDisplay.h
22 
23  \brief A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
24 */
25 
26 #ifndef __TERRALIB_QT_AF_CONNECTORS_INTERNAL_MAPDISPLAY_H
27 #define __TERRALIB_QT_AF_CONNECTORS_INTERNAL_MAPDISPLAY_H
28 
29 // Terralib
30 #ifndef Q_MOC_RUN
31 #include "../../../maptools/AbstractLayer.h"
32 #endif
33 #include "../Config.h"
34 
35 // Qt
36 #include <QObject>
37 #include <QPoint>
38 #include <QString>
39 #include <QMap>
40 #include <QColor>
41 #include <QMenu>
42 #include <QPixmap>
43 
44 class QAction;
45 
46 namespace te
47 {
48  namespace da
49  {
50  class DataSet;
51  }
52 
53  namespace qt
54  {
55  namespace widgets
56  {
57  class AbstractTool;
58  class EyeBirdMapDisplayWidget;
59  class MapDisplay;
60  class ZoomInMapDisplayWidget;
61  }
62 
63  namespace af
64  {
65  class ApplicationController;
66 
67  namespace evt
68  {
69  // Forward declaration
70  struct Event;
71  }
72 
73  /*!
74  \class MapDisplay
75 
76  \brief A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
77 
78  It is used to listen events sent by the application framework.
79  It is a proxy for the te::qt::widgets::MapDisplay.
80  */
81  class TEQTAFEXPORT MapDisplay : public QObject
82  {
83  Q_OBJECT
84 
85  public:
86 
87  /*!
88  \brief Constructor.
89 
90  \param display te::qt::widgets::MapDisplay to be listened.
91  */
93 
94  /*! \brief destructor. */
95  ~MapDisplay();
96 
97  te::qt::widgets::MapDisplay* getDisplay();
98 
99  void setZoomInDisplay(te::qt::widgets::ZoomInMapDisplayWidget* display);
100 
101  void setEyeBirdDisplay(te::qt::widgets::EyeBirdMapDisplayWidget* display);
102 
103  bool eventFilter(QObject* watched, QEvent* e);
104 
105  /*!
106  \brief It draws the given layer list.
107 
108  \param layers The layer list.
109  */
110  void draw(const std::list<te::map::AbstractLayerPtr>& layers);
111 
112  /*! \brief It clears the map display. */
113  void clear();
114 
115  /*!
116  \brief Updates the current tool being used on te::qt::widgets::MapDisplay.
117 
118  \param tool The new te::qt::widgets::AbstractTool.
119 
120  \param delPrevious True for delete the old tool.
121 
122  \note The class will take the ownership of the given pointer.
123  */
124  void setCurrentTool(te::qt::widgets::AbstractTool* tool, const bool& delPrevious = true);
125 
126  void nextExtent();
127 
128  void previousExtent();
129 
130  void fit(const std::list<te::map::AbstractLayerPtr>& layers);
131 
132  protected slots:
133 
134  void onCoordTracked(QPointF& coordinate);
135 
136  void onDrawLayersFinished(const QMap<QString, QString>& errors);
137 
138  void onExtentChanged();
139 
140  /*!
141  \brief Listener to the application framewrork events.
142 
143  \param e An event sent by framework.
144  */
145  void onApplicationTriggered(te::qt::af::evt::Event* e);
146 
147  /*!
148  \brief Returns the pan selected flag;
149 
150  \return Flag of the pan to selected operation.
151  */
152  bool isPanToSelectedEnabled();
153 
154  protected:
155 
156  void drawLayersSelection(const std::list<te::map::AbstractLayerPtr>& layers);
157 
158  void drawLayerSelection(te::map::AbstractLayerPtr layer);
159 
160  void drawDataSet(te::da::DataSet* dataset, const std::string& geomPropertyName, int srid, const QColor& color, bool isLinked = false);
161 
162  void configSRS(const std::list<te::map::AbstractLayerPtr>& layers);
163 
164  std::list<te::map::AbstractLayerPtr> getSelectedLayer();
165 
166  signals:
167 
168  void hasNextExtent(bool value);
169 
170  void hasPreviousExtent(bool value);
171 
172  void triggered(te::qt::af::evt::Event* e);
173 
174  protected:
175 
176  std::list<te::map::AbstractLayerPtr> getVisibleLayers();
177 
178 
179  te::qt::af::ApplicationController* m_app; //!< Pointer to applicatin controller;
180  te::qt::widgets::MapDisplay* m_display; //!< Pointer to a component te::qt::widgets::MapDisplay.
181  te::qt::widgets::AbstractTool* m_tool; //!< Pointer to the current tool being used.
182  QMenu* m_menu; //!< The map display popup menu.
183  QPixmap m_lastDisplayContent; //!< The last map display content. i.e. a "clean" pixmap.
184  std::vector<te::gm::Envelope> m_extentStack; //!< The stack of MapDisplay extents.
185  int m_currentExtentIndex; //!< The current extent index.
186  int m_extentStackMaxSize; //!< The max size of the extent stack. Used on previousExtent and nextExtent.
187 
188  te::qt::widgets::ZoomInMapDisplayWidget* m_zoomInDisplay; //!< Pointer to a component that represents a zoom in display.
189  te::qt::widgets::EyeBirdMapDisplayWidget* m_eyeBirdDisplay; //!< Pointer to a component that represents a eye bird display.
190 
191  QAction* m_pantoSelectedAction; //!< Action to enable / disable pan to selected operation.
192  };
193  }
194  }
195 }
196 
197 #endif // __TERRALIB_QT_AF_CONNECTORS_INTERNAL_MAPDISPLAY_H
QPixmap m_lastDisplayContent
The last map display content. i.e. a "clean" pixmap.
Definition: MapDisplay.h:183
This class defines the map display EyeBird, this component is only a specific map that shows the orig...
This class defines the map display ZoomIn, this component is only a specific map that shows the curre...
te::qt::widgets::EyeBirdMapDisplayWidget * m_eyeBirdDisplay
Pointer to a component that represents a eye bird display.
Definition: MapDisplay.h:189
int m_extentStackMaxSize
The max size of the extent stack. Used on previousExtent and nextExtent.
Definition: MapDisplay.h:186
A base class for application events.
Definition: Event.h:59
QMenu * m_menu
The map display popup menu.
Definition: MapDisplay.h:182
std::vector< te::gm::Envelope > m_extentStack
The stack of MapDisplay extents.
Definition: MapDisplay.h:184
The base API for TerraLib applications.
A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
Definition: MapDisplay.h:81
A widget to control the display of a set of layers.
Definition: MapDisplay.h:68
This class defines an interface for objects that can receive application events and respond to them...
Definition: AbstractTool.h:62
te::qt::widgets::ZoomInMapDisplayWidget * m_zoomInDisplay
Pointer to a component that represents a zoom in display.
Definition: MapDisplay.h:188
QAction * m_pantoSelectedAction
Action to enable / disable pan to selected operation.
Definition: MapDisplay.h:191
te::qt::widgets::AbstractTool * m_tool
Pointer to the current tool being used.
Definition: MapDisplay.h:181
te::qt::af::ApplicationController * m_app
Pointer to applicatin controller;.
Definition: MapDisplay.h:179
URI C++ Library.
int m_currentExtentIndex
The current extent index.
Definition: MapDisplay.h:185
#define TEQTAFEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:71
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
te::qt::widgets::MapDisplay * m_display
Pointer to a component te::qt::widgets::MapDisplay.
Definition: MapDisplay.h:180