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 #include "../../../maptools/AbstractLayer.h"
31 #include "../Config.h"
32 
33 // Qt
34 #include <QObject>
35 #include <QPoint>
36 #include <QString>
37 #include <QMap>
38 #include <QColor>
39 #include <QMenu>
40 #include <QPixmap>
41 
42 class QAction;
43 
44 namespace te
45 {
46  namespace da
47  {
48  class DataSet;
49  }
50 
51  namespace qt
52  {
53  namespace widgets
54  {
55  class AbstractTool;
56  class EyeBirdMapDisplayWidget;
57  class MapDisplay;
58  class ZoomInMapDisplayWidget;
59  }
60 
61  namespace af
62  {
63  class ApplicationController;
64 
65  namespace evt
66  {
67  // Forward declaration
68  struct Event;
69  }
70 
71  /*!
72  \class MapDisplay
73 
74  \brief A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
75 
76  It is used to listen events sent by the application framework.
77  It is a proxy for the te::qt::widgets::MapDisplay.
78  */
79  class TEQTAFEXPORT MapDisplay : public QObject
80  {
81  Q_OBJECT
82 
83  public:
84 
85  /*!
86  \brief Constructor.
87 
88  \param display te::qt::widgets::MapDisplay to be listened.
89  */
91 
92  /*! \brief destructor. */
93  ~MapDisplay();
94 
95  te::qt::widgets::MapDisplay* getDisplay();
96 
97  void setZoomInDisplay(te::qt::widgets::ZoomInMapDisplayWidget* display);
98 
99  void setEyeBirdDisplay(te::qt::widgets::EyeBirdMapDisplayWidget* display);
100 
101  bool eventFilter(QObject* watched, QEvent* e);
102 
103  /*!
104  \brief It draws the given layer list.
105 
106  \param layers The layer list.
107  */
108  void draw(const std::list<te::map::AbstractLayerPtr>& layers);
109 
110  /*! \brief It clears the map display. */
111  void clear();
112 
113  /*!
114  \brief Updates the current tool being used on te::qt::widgets::MapDisplay.
115 
116  \param tool The new te::qt::widgets::AbstractTool.
117 
118  \param delPrevious True for delete the old tool.
119 
120  \note The class will take the ownership of the given pointer.
121  */
122  void setCurrentTool(te::qt::widgets::AbstractTool* tool, const bool& delPrevious = true);
123 
124  void nextExtent();
125 
126  void previousExtent();
127 
128  void fit(const std::list<te::map::AbstractLayerPtr>& layers);
129 
130  protected slots:
131 
132  void onCoordTracked(QPointF& coordinate);
133 
134  void onDrawLayersFinished(const QMap<QString, QString>& errors);
135 
136  void onExtentChanged();
137 
138  /*!
139  \brief Listener to the application framewrork events.
140 
141  \param e An event sent by framework.
142  */
143  void onApplicationTriggered(te::qt::af::evt::Event* e);
144 
145  /*!
146  \brief Returns the pan selected flag;
147 
148  \return Flag of the pan to selected operation.
149  */
150  bool isPanToSelectedEnabled();
151 
152  protected:
153 
154  void drawLayersSelection(const std::list<te::map::AbstractLayerPtr>& layers);
155 
156  void drawLayerSelection(te::map::AbstractLayerPtr layer);
157 
158  void drawDataSet(te::da::DataSet* dataset, const std::string& geomPropertyName, int srid, const QColor& color, bool isLinked = false);
159 
160  void configSRS(const std::list<te::map::AbstractLayerPtr>& layers);
161 
162  std::list<te::map::AbstractLayerPtr> getSelectedLayer();
163 
164  signals:
165 
166  void hasNextExtent(bool value);
167 
168  void hasPreviousExtent(bool value);
169 
170  void triggered(te::qt::af::evt::Event* e);
171 
172  protected:
173 
174  std::list<te::map::AbstractLayerPtr> getVisibleLayers();
175 
176 
177  te::qt::af::ApplicationController* m_app; //!< Pointer to applicatin controller;
178  te::qt::widgets::MapDisplay* m_display; //!< Pointer to a component te::qt::widgets::MapDisplay.
179  te::qt::widgets::AbstractTool* m_tool; //!< Pointer to the current tool being used.
180  QMenu* m_menu; //!< The map display popup menu.
181  QPixmap m_lastDisplayContent; //!< The last map display content. i.e. a "clean" pixmap.
182  std::vector<te::gm::Envelope> m_extentStack; //!< The stack of MapDisplay extents.
183  int m_currentExtentIndex; //!< The current extent index.
184  int m_extentStackMaxSize; //!< The max size of the extent stack. Used on previousExtent and nextExtent.
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  }
192  }
193 }
194 
195 #endif // __TERRALIB_QT_AF_CONNECTORS_INTERNAL_MAPDISPLAY_H
QPixmap m_lastDisplayContent
The last map display content. i.e. a "clean" pixmap.
Definition: MapDisplay.h:181
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:187
int m_extentStackMaxSize
The max size of the extent stack. Used on previousExtent and nextExtent.
Definition: MapDisplay.h:184
A base class for application events.
Definition: Event.h:59
QMenu * m_menu
The map display popup menu.
Definition: MapDisplay.h:180
std::vector< te::gm::Envelope > m_extentStack
The stack of MapDisplay extents.
Definition: MapDisplay.h:182
The base API for TerraLib applications.
A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
Definition: MapDisplay.h:79
A widget to control the display of a set of layers.
Definition: MapDisplay.h:66
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:186
QAction * m_pantoSelectedAction
Action to enable / disable pan to selected operation.
Definition: MapDisplay.h:189
te::qt::widgets::AbstractTool * m_tool
Pointer to the current tool being used.
Definition: MapDisplay.h:179
te::qt::af::ApplicationController * m_app
Pointer to applicatin controller;.
Definition: MapDisplay.h:177
URI C++ Library.
int m_currentExtentIndex
The current extent index.
Definition: MapDisplay.h:183
#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:178