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 CoordTracking;
58  class EyeBirdMapDisplayWidget;
59  class MapDisplay;
60  class PanMiddleClick;
61  class ZoomInMapDisplayWidget;
62  class ZoomWheel;
63  }
64 
65  namespace af
66  {
67  class ApplicationController;
68 
69  namespace evt
70  {
71  // Forward declaration
72  struct Event;
73  }
74 
75  /*!
76  \class MapDisplay
77 
78  \brief A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
79 
80  It is used to listen events sent by the application framework.
81  It is a proxy for the te::qt::widgets::MapDisplay.
82  */
83  class TEQTAFEXPORT MapDisplay : public QObject
84  {
85  Q_OBJECT
86 
87  public:
88 
89  /*!
90  \brief Constructor.
91 
92  \param display te::qt::widgets::MapDisplay to be listened.
93  */
95 
96  /*! \brief destructor. */
97  ~MapDisplay();
98 
99  te::qt::widgets::MapDisplay* getDisplay();
100 
101  void setZoomInDisplay(te::qt::widgets::ZoomInMapDisplayWidget* display);
102 
103  void setEyeBirdDisplay(te::qt::widgets::EyeBirdMapDisplayWidget* display);
104 
105  bool eventFilter(QObject* watched, QEvent* e);
106 
107  /*!
108  \brief It draws the given layer list.
109 
110  \param layers The layer list.
111  */
112  void draw(const std::list<te::map::AbstractLayerPtr>& layers);
113 
114  /*! \brief It clears the map display. */
115  void clear();
116 
117  void nextExtent();
118 
119  void previousExtent();
120 
121  void fit(const std::list<te::map::AbstractLayerPtr>& layers);
122 
123  void pan(const std::list<te::map::AbstractLayerPtr>& layers);
124 
125  protected slots:
126 
127  void onCoordTracked(QPointF& coordinate);
128 
129  void onDrawLayersFinished(const QMap<QString, QString>& errors);
130 
131  void onExtentChanged();
132 
133  /*!
134  \brief Listener to the application framewrork events.
135 
136  \param e An event sent by framework.
137  */
138  void onApplicationTriggered(te::qt::af::evt::Event* e);
139 
140  /*!
141  \brief Returns the pan selected flag;
142 
143  \return Flag of the pan to selected operation.
144  */
145  bool isPanToSelectedEnabled();
146 
147  protected:
148 
149  void drawLayersSelection(const std::list<te::map::AbstractLayerPtr>& layers);
150 
151  void drawLayerSelection(te::map::AbstractLayerPtr layer);
152 
153  void drawDataSet(te::da::DataSet* dataset, const std::string& geomPropertyName, int srid, const QColor& color, bool isLinked = false);
154 
155  void drawDataSet(te::da::DataSet* dataset, const std::string& geomPropertyName, int srid, te::se::Style* style, bool isLinked = false);
156 
157  void configSRS(const std::list<te::map::AbstractLayerPtr>& layers);
158 
159  std::list<te::map::AbstractLayerPtr> getSelectedLayer();
160 
161  signals:
162 
163  void hasNextExtent(bool value);
164 
165  void hasPreviousExtent(bool value);
166 
167  void triggered(te::qt::af::evt::Event* e);
168 
169  protected:
170 
171  std::list<te::map::AbstractLayerPtr> getVisibleLayers();
172 
173 
174  te::qt::af::ApplicationController* m_app; //!< Pointer to applicatin controller;
175  te::qt::widgets::MapDisplay* m_display; //!< Pointer to a component te::qt::widgets::MapDisplay.
176  QMenu* m_menu; //!< The map display popup menu.
177  QPixmap m_lastDisplayContent; //!< The last map display content. i.e. a "clean" pixmap.
178  std::vector<te::gm::Envelope> m_extentStack; //!< The stack of MapDisplay extents.
179  int m_currentExtentIndex; //!< The current extent index.
180  int m_extentStackMaxSize; //!< The max size of the extent stack. Used on previousExtent and nextExtent.
181 
182  te::qt::widgets::CoordTracking* m_coordTracking; //!< Tool for tracking mouse position
183  te::qt::widgets::ZoomWheel* m_zoomWheel; //!< Tool for zoom using the wheel mouse button
184  te::qt::widgets::PanMiddleClick* m_pan; //!< Tool for pan using the middle mouse button
185 
186  te::qt::widgets::ZoomInMapDisplayWidget* m_zoomInDisplay; //!< Pointer to a component that represents a zoom in display.
187  te::qt::widgets::EyeBirdMapDisplayWidget* m_eyeBirdDisplay; //!< Pointer to a component that represents a eye bird display.
188 
189  QAction* m_pantoSelectedAction; //!< Action to enable / disable pan to selected operation.
190 
191  bool m_autoPanEnabled; //!< Define if auto pan is enabled.
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:177
#define slots
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...
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
This class implements a concrete tool to geographic pan operation with mouse middle click...
te::qt::widgets::ZoomWheel * m_zoomWheel
Tool for zoom using the wheel mouse button.
Definition: MapDisplay.h:183
te::qt::widgets::EyeBirdMapDisplayWidget * m_eyeBirdDisplay
Pointer to a component that represents a eye bird display.
Definition: MapDisplay.h:187
int m_extentStackMaxSize
The max size of the extent stack. Used on previousExtent and nextExtent.
Definition: MapDisplay.h:180
A base class for application events.
Definition: Event.h:59
QMenu * m_menu
The map display popup menu.
Definition: MapDisplay.h:176
std::vector< te::gm::Envelope > m_extentStack
The stack of MapDisplay extents.
Definition: MapDisplay.h:178
The base API for TerraLib applications.
A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
Definition: MapDisplay.h:83
A widget to control the display of a set of layers.
Definition: MapDisplay.h:71
te::qt::widgets::ZoomInMapDisplayWidget * m_zoomInDisplay
Pointer to a component that represents a zoom in display.
Definition: MapDisplay.h:186
QAction * m_pantoSelectedAction
Action to enable / disable pan to selected operation.
Definition: MapDisplay.h:189
te::qt::widgets::CoordTracking * m_coordTracking
Tool for tracking mouse position.
Definition: MapDisplay.h:182
te::qt::af::ApplicationController * m_app
Pointer to applicatin controller;.
Definition: MapDisplay.h:174
URI C++ Library.
int m_currentExtentIndex
The current extent index.
Definition: MapDisplay.h:179
This class implements a concrete tool to geographic coordinate tracking on mouse move operation...
Definition: CoordTracking.h:52
#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
bool m_autoPanEnabled
Define if auto pan is enabled.
Definition: MapDisplay.h:191
This class implements a concrete tool to geographic zoom operation using the mouse wheel...
Definition: ZoomWheel.h:49
te::qt::widgets::PanMiddleClick * m_pan
Tool for pan using the middle mouse button.
Definition: MapDisplay.h:184
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
te::qt::widgets::MapDisplay * m_display
Pointer to a component te::qt::widgets::MapDisplay.
Definition: MapDisplay.h:175