All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MapItem.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 MapItem.h
22 
23  \brief This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene.
24  This object is of type QGraphicsProxyWidget. He have a directly interaction by user.
25  His transformation matrix is inverted, that is, the inverse of the matrix of the scene, so its coordinate system is screen (pixel),
26  but its position in the scene remains in millimeters.
27  This is also son of ItemObserver, so it can become observer of a model (Observable). "View" part of MVC component.
28 
29  \ingroup layout
30 */
31 
32 #ifndef __TERRALIB_LAYOUT_INTERNAL_MAP_ITEM_H
33 #define __TERRALIB_LAYOUT_INTERNAL_MAP_ITEM_H
34 
35 // Qt
36 #include <QGraphicsProxyWidget>
37 #include <QVariant>
38 #include <QPixmap>
39 
40 // TerraLib
41 #include "../../core/pattern/mvc/ItemObserver.h"
42 #include "../../../qt/widgets/canvas/MultiThreadMapDisplay.h"
43 #include "../../../qt/widgets/layer/explorer/AbstractTreeItem.h"
44 #include "../../../qt/widgets/tools/AbstractTool.h"
45 #include "../../../maptools/AbstractLayer.h"
46 #include "../../core/Config.h"
47 #include "ParentItem.h"
48 #include "../../../qt/widgets/tools/ZoomWheel.h"
49 
50 class QGraphicsSceneMouseEvent;
51 class QMimeData;
52 class QVariant;
53 
54 namespace te
55 {
56  namespace layout
57  {
58  class Observable;
59  class ItemController;
60  class EnumType;
61 
62  /*!
63  \brief This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene.
64  This object is of type QGraphicsProxyWidget. He have a directly interaction by user.
65  His transformation matrix is inverted, that is, the inverse of the matrix of the scene, so its coordinate system is screen (pixel),
66  but its position in the scene remains in millimeters.
67  Drawing starting point is llx, lly.
68  He is also the son of ItemObserver, so it can become observer of a model (Observable). "View" part of MVC component.
69 
70  \ingroup layout
71 
72  \sa te::layout::ItemObserver
73  */
74  class TELAYOUTEXPORT MapItem : public ParentItem<QGraphicsProxyWidget>
75  {
76  Q_OBJECT //for slots/signals
77 
78  public:
79 
80  /*!
81  \brief Constructor
82 
83  \param controller "Controller" part of MVC component
84  \param o "Model" part of MVC component
85  */
86  MapItem( ItemController* controller, Observable* o );
87 
88  /*!
89  \brief Destructor
90  */
91  virtual ~MapItem();
92 
93  /*!
94  \brief Reimplemented from ItemObserver
95  */
96  virtual void updateObserver(ContextItem context);
97 
98  void setPixmap( const QPixmap& pixmap );
99 
100  /*!
101  \brief Reimplemented from QGraphicsProxyWidget
102  */
103  virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem* option, QWidget * widget = 0 );
104 
105  virtual void changeCurrentTool(EnumType* mode);
106 
107  void clearCurrentTool();
108 
109  /*!
110  \brief Reimplemented from ItemObserver
111  */
112  virtual te::color::RGBAColor** getRGBAColorImage(int &w, int &h);
113 
114  /*!
115  \brief Reimplemented from ItemObserver
116  */
117  virtual void updateProperties(te::layout::Properties* properties);
118 
119  virtual void changeZoomFactor(double currentZoomFactor);
120 
121  /*!
122  \brief Reimplemented from ParentItem
123  */
124  virtual QRectF boundingRect() const;
125 
126  protected slots:
127 
128  void onDrawLayersFinished(const QMap<QString, QString>& errors);
129 
130  protected:
131 
132  /*!
133  \brief Reimplemented from QGraphicsProxyWidget
134  */
135  virtual void dropEvent ( QGraphicsSceneDragDropEvent * event );
136 
137  /*!
138  \brief Reimplemented from QGraphicsProxyWidget
139  */
140  virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
141 
142  /*!
143  \brief Reimplemented from QGraphicsProxyWidget
144  */
145  virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
146 
147  /*!
148  \brief Reimplemented from QGraphicsProxyWidget
149  */
150  virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
151 
152  /*!
153  \brief Reimplemented from QGraphicsProxyWidget
154  */
155  virtual void dragEnterEvent ( QGraphicsSceneDragDropEvent * event );
156 
157  /*!
158  \brief Reimplemented from QGraphicsProxyWidget
159  */
160  virtual void dragLeaveEvent ( QGraphicsSceneDragDropEvent * event );
161 
162  /*!
163  \brief Reimplemented from QGraphicsProxyWidget
164  */
165  virtual void dragMoveEvent ( QGraphicsSceneDragDropEvent * event );
166 
167  /*!
168  \brief Reimplemented from ItemObserver
169  */
170  virtual te::gm::Coord2D getPosition();
171 
172  virtual void getMimeData(const QMimeData* mime);
173 
174  std::list<te::map::AbstractLayerPtr> getVisibleLayers();
175 
176  te::map::AbstractLayerPtr getLayer();
177 
178  void setCurrentTool(te::qt::widgets::AbstractTool* tool);
179 
180  virtual QImage generateImage();
181 
182  virtual void calculateFrameMargin();
183 
184  virtual void generateMapPixmap();
185 
186  virtual void drawMap(QPainter * painter);
187 
188  virtual void recalculateBoundingRect();
189 
190  protected:
191 
192  QSize m_mapSize; //!< The size of the map display in a zoom of 100%. This size is in pixels and is calculated based on the size of the GraphicItem in millimeters.
193  QPixmap m_mapPixmap;
194  QMimeData* m_mime;
199  double m_wMargin;
200  double m_hMargin;
204  };
205  }
206 }
207 
208 #endif
209 
210 
Abstract class to represent an observable. "Model" part of MVC component.
Definition: Observable.h:56
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Definition: ContextItem.h:49
te::qt::widgets::ZoomWheel * m_zoomWheel
Definition: MapItem.h:202
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
The class that represents an item in a LayerTreeModel.
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Definition: Properties.h:52
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
This class defines an interface for objects that can receive application events and respond to them...
Definition: AbstractTool.h:62
te::map::AbstractLayerPtr m_layer
Definition: MapItem.h:201
bool m_grabbedByWidget
Definition: MapItem.h:196
QSize m_mapSize
The size of the map display in a zoom of 100%. This size is in pixels and is calculated based on the ...
Definition: MapItem.h:192
te::qt::widgets::AbstractTool * m_tool
Definition: MapItem.h:198
te::qt::widgets::AbstractTreeItem * m_treeItem
Definition: MapItem.h:197
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
QMimeData * m_mime
Definition: MapItem.h:194
This class implements a concrete tool to geographic zoom operation using the mouse wheel...
Definition: ZoomWheel.h:49
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
QPixmap m_mapPixmap
Definition: MapItem.h:193
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
Abstract class that represents a graphic item. Its coordinate system is the same of scene (millimeter...
Definition: ParentItem.h:86
Abstract class that represents a graphic item. Its coordinate system is the same of scene (millimeter...
A multi thread Qt4 widget to control the display of a set of layers.
This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene...
Definition: MapItem.h:74
te::qt::widgets::MultiThreadMapDisplay * m_mapDisplay
Definition: MapItem.h:195