All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
View.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 View.h
22 
23  \brief Class representing the view. This view is child of QGraphicsView, part of Graphics View Framework.
24  The View object is a widget where the items in the scene are drawn.
25  It is responsible for presentation and interaction between the screen events and the scene.
26  Manages interactive functions and intercepts all mouse or keyboard events.
27  The coordinate system of this representation is pixel and your point 0.0 is in the top left(Screen coordinate system).
28  The default settings of the layout module are in the object Context (singleton).
29 
30  \ingroup layout
31 */
32 
33 #ifndef __TERRALIB_LAYOUT_INTERNAL_VIEW_H
34 #define __TERRALIB_LAYOUT_INTERNAL_VIEW_H
35 
36 // TerraLib
37 #include "../../core/AbstractView.h"
38 #include "../../../geometry/Envelope.h"
39 #include "../../../geometry/Coord2D.h"
40 #include "Scene.h"
41 #include "../outside/PageSetupOutside.h"
42 #include "../outside/SystematicScaleOutside.h"
43 #include "../item/MovingItemGroup.h"
45 
46 // STL
47 #include <string>
48 
49 // Qt
50 #include <QGraphicsView>
51 #include <QMenu>
52 #include <QImage>
53 #include <QCursor>
54 
55 class QMouseEvent;
56 class QWheelEvent;
57 class QKeyEvent;
58 class QString;
59 class QHideEvent;
60 class QCloseEvent;
61 class QGraphicsItemGroup;
62 class QLineF;
63 class QContextMenuEvent;
64 class QEvent;
65 
66 namespace te
67 {
68  namespace layout
69  {
70  class VisualizationArea;
71  class AbstractViewTool;
72  class HorizontalRuler;
73  class VerticalRuler;
74  class EnumType;
75  class WaitView;
76 
77  /*!
78  \brief Class representing the view. This view is child of QGraphicsView, part of Graphics View Framework.
79  The View object is a widget where the items in the scene are drawn.
80  It is responsible for presentation and interaction between the screen events and the scene.
81  Manages interactive functions and intercepts all mouse or keyboard events.
82  The coordinate system of this representation is pixel and your point 0.0 is in the top left(Screen coordinate system).
83  The default settings of the layout module are in the object Context (singleton).
84 
85  \ingroup layout
86 
87  \sa te::layout::AbstractView
88  */
89  class TELAYOUTEXPORT View : public QGraphicsView, public AbstractView
90  {
91  Q_OBJECT //for slots/signals
92 
93  public:
94 
95  /*!
96  \brief Constructor
97  */
98  View(QWidget* widget = (QWidget*)0);
99 
100  /*!
101  \brief Destructor
102  */
103  virtual ~View();
104 
105  /*!
106  \brief Initialization method that configures the View and sets the transformation matrix of the scene in the View object.
107  */
108  virtual void config();
109 
110  /*!
111  \brief Close all windows that have been instantiated by this View. Ex .: Page Settings
112  */
113  virtual void closeOutsideWindows();
114 
115  /*!
116  \brief Create snapshot of the View current state.
117 
118  \return image
119  */
120  virtual QImage createImage();
121 
122  /*!
123  \brief Reset to initial configuration made in the config() method.
124  */
125  virtual void resetView();
126 
127  /*!
128  \brief Method that sets View object for the Pan function.
129  */
130  virtual void pan();
131 
132  /*!
133  \brief Method that sets View object for the Zoom Area function.
134  */
135  virtual void zoomArea();
136 
137  /*!
138  \brief Method that sets View object for the Zoom Out function.
139  */
140  virtual void zoomOut();
141 
142  /*!
143  \brief Method that sets View object for the Print function.
144  */
145  virtual void print();
146 
147  /*!
148  \brief Reset to initial configuration made in the config() method. Reset to default zoom factor.
149  */
150  virtual void recompose();
151 
152  /*!
153  \brief Method that applies current zoom defined in the Context.
154  */
155  virtual void zoomPercentage();
156 
157  /*!
158  \brief Method that change rulers visibility state.
159 
160  \param visible visibility state
161  */
162  virtual void changeZoomFactor(double currentZoom);
163 
164  /*!
165  \brief Method that sets View object for the Print function.
166  */
167  virtual void exportToPDF();
168 
169  public slots:
170 
171  /*!
172  \brief Notifies View object that some action on the toolbar has been thrown.
173  */
174  virtual void onToolbarChangeContext(bool change);
175 
176  /*!
177  \brief Notifies View object that some action on the Menu has been thrown.
178  */
179  virtual void onMainMenuChangeContext(bool change);
180 
181  /*!
182  \brief Notifies View object that some configuration was modified in the Page Settings Window.
183  */
184  virtual void onChangeConfig();
185 
186  virtual void onSystematicApply(double scale, SystematicScaleType type);
187 
188  /*!
189  \brief Notifies View object that the selection of objects in the scene changed.
190  */
191  virtual void onSelectionChanged();
192 
193  virtual void onSelectionItem(std::string name);
194 
195  signals:
196 
197  /*!
198  \brief This signal is emitted when the mouse move changed.
199 
200  \param pos current position
201  */
202  void changeSceneCoordMouse(QPointF pos);
203 
204  /*!
205  \brief This signal is emitted when show View object.
206  */
207  void showView();
208 
209  /*!
210  \brief This signal is emitted when close View object.
211  */
212  void closeView();
213 
214  /*!
215  \brief This signal is emitted when hide View object.
216  */
217  void hideView();
218 
219  /*!
220  \brief This signal is emitted when selection change and mouse release.
221  */
222  void reloadProperties();
223 
224  /*!
225  \brief This signal is emitted when View object changes the zoom factor internally.
226  */
227  void changeZoom(double currentFactor);
228 
229  /*!
230  \brief This signal is emitted when context change.
231  */
232  void changeContext();
233 
234  protected:
235 
236  /*!
237  \brief Reimplemented from QGraphicsView. Call method createItem() of the scene.
238  */
239  virtual void mousePressEvent(QMouseEvent * event);
240 
241  /*!
242  \brief Reimplemented from QGraphicsView
243  */
244  virtual void mouseMoveEvent ( QMouseEvent * event );
245 
246  /*!
247  \brief Reimplemented from QGraphicsView
248  */
249  virtual void mouseReleaseEvent ( QMouseEvent * event );
250 
251  /*!
252  \brief Reimplemented from QGraphicsView
253  */
254  virtual void wheelEvent(QWheelEvent *event);
255 
256  /*!
257  \brief Reimplemented from QGraphicsView
258  */
259  virtual void keyPressEvent(QKeyEvent* keyEvent);
260 
261  /*!
262  \brief Reimplemented from QGraphicsView
263  */
264  virtual void resizeEvent(QResizeEvent * event);
265 
266  /*!
267  \brief Reimplemented from QGraphicsView
268  */
269  virtual void hideEvent ( QHideEvent * event );
270 
271  /*!
272  \brief Reimplemented from QGraphicsView
273  */
274  virtual void closeEvent ( QCloseEvent * event );
275 
276  /*!
277  \brief Reimplemented from QGraphicsView
278  */
279  virtual void showEvent ( QShowEvent * event );
280 
281  /*!
282  \brief Reimplemented from QGraphicsView
283  */
284  virtual void contextMenuEvent ( QContextMenuEvent * event );
285 
286  /*!
287  \brief Reimplemented from QGraphicsView
288  */
289  virtual void drawForeground ( QPainter * painter, const QRectF & rect );
290 
291  /*!
292  \brief Groups selected objects
293  */
294  virtual void createItemGroup();
295 
296  /*!
297  \brief Method that delete Grouping object selected, but the individual objects continue to exist.
298  */
299  virtual void destroyItemGroup();
300 
301  virtual void resetDefaultConfig();
302 
303  /*!
304  \brief Responsible method for verifying changes made in Context outside the View object and call corresponding actions.
305  Ex.: Action Pan called in toolbar changed Context to Pan mode, then View object call method to do it.
306  */
307  virtual void outsideAreaChangeContext(bool change);
308 
309  /*!
310  \brief Method that instantiates and shows the Page Setup window.
311  */
312  virtual void showPageSetup();
313 
314  virtual void showSystematicScale();
315 
316  virtual QCursor createCursor(std::string pathIcon);
317 
318  /*!
319  \brief Method that exports all the objects in the scene to a template. Ex.: JSON.
320 
321  \param type type of template. Ex .: JSON type
322 
323  \return true if exported, false otherwise
324  */
325  virtual bool exportProperties(EnumType* type);
326 
327  /*!
328  \brief Method that import a template and build all objects. Ex.: JSON.
329 
330  \return true if exported, false otherwise
331  */
332  virtual bool importTemplate(EnumType* type);
333 
334  /*!
335  \brief Saves each item in the scene as image. Ex .: .png
336  */
337  virtual void exportItemsToImage();
338 
339  virtual bool isExceededLimit(double currentScale, double factor, double oldFactor);
340 
341  protected:
342 
354  double m_width;
355  double m_height;
361  bool m_flag;
362  };
363  }
364 }
365 #endif
double m_minZoomLimit
Definition: View.h:353
Class responsible for creating the menu, right mouse button, and dynamically add menu options...
Definition: MenuBuilder.h:57
This is the abstract view for View.
Definition: AbstractView.h:49
double m_height
Definition: View.h:355
Class that represents a horizontal ruler with the coordinate system in mm.
double m_maxZoomLimit
Definition: View.h:352
EnumType * m_oldMode
Definition: View.h:359
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
Creates the viewing area. Ex.: creation of the sheet of paper.
SystematicScaleOutside * m_systematicOutside
Definition: View.h:346
WaitView * m_wait
Definition: View.h:360
bool m_isMoving
Definition: View.h:356
VerticalRuler * m_verticalRuler
Definition: View.h:351
Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework...
bool m_selectionChange
Definition: View.h:348
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
MenuBuilder * m_menuBuilder
Definition: View.h:349
te::gm::Coord2D m_coordSystematic
Definition: View.h:347
Class representing the view. This view is child of QGraphicsView, part of Graphics View Framework...
Definition: View.h:89
bool m_updateItemPos
Definition: View.h:358
VisualizationArea * m_visualizationArea
Definition: View.h:343
HorizontalRuler * m_horizontalRuler
Definition: View.h:350
bool m_flag
Definition: View.h:361
double m_width
Definition: View.h:354
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
Class that represents a vertical ruler with the coordinate system in mm.
Definition: VerticalRuler.h:44
AbstractViewTool * m_currentTool
Definition: View.h:344
PageSetupOutside * m_pageSetupOutside
Definition: View.h:345
te::layout::MovingItemGroup * m_movingItemGroup
Definition: View.h:357