All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LayoutEditor.h
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of TerraView - A Free and Open Source 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 terraview/LayoutEditor.h
22 
23  \brief The main class of LayoutEditor.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_MAP_EDITOR_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_MAP_EDITOR_H
28 
29 
30 // TerraLib
31 #include <terralib/geometry.h>
32 #include <terralib/maptools.h>
33 #include <terralib/srs.h>
34 #include "../Config.h"
35 
36 // Qt
37 #include <QAction>
38 #include <QMenu>
39 
40 #include <QRect>
41 #include <QMatrix>
42 #include <QWidget>
43 #include <QPaintEvent>
44 #include <QResizeEvent>
45 
46 namespace te
47 {
48  namespace qt
49  {
50  namespace widgets
51  {
52  class LayoutObject;
53  class DataFrame;
54  class EditorInfo;
55  class DraftLayoutEditor;
56  /*!
57  \class LayoutEditor
58 
59  \brief A map editor ....
60 
61  \sa
62  */
63  class TEQTWIDGETSEXPORT LayoutEditor : public QWidget
64  //class TEQTWIDGETSEXPORT LayoutEditor : public QWidget, public te::common::Singleton<LayoutEditor>
65  {
66 // friend class te::common::Singleton<LayoutEditor>;
67 
68  public:
69  LayoutEditor(QWidget* parent = 0, Qt::WindowFlags f = Qt::Window );
70  LayoutEditor(const QSize& paperSize, QWidget* parent = 0, Qt::WindowFlags f = Qt::Window );
71  virtual ~LayoutEditor();
72 
73  void createWorkingArea(bool undo = true);
74  void insertRulers();
75  void createRulerGrid();
76  void showRulerGrid();
77  void hideRulerGrid();
79  void remove(te::qt::widgets::LayoutObject*);
80  void insertCopy2Undo(te::qt::widgets::LayoutObject*);
81  void removeUndo(te::qt::widgets::LayoutObject*);
82  te::qt::widgets::LayoutObject* find(unsigned int);
83  void paintEvent(QPaintEvent* event);
84  void resizeEvent(QResizeEvent* event);
85  void moveEvent(QMoveEvent* event);
86  void setPaperSize(const QSize& size);
87  QSize getPaperSize();
88  QRectF getPaperViewRect();
89  int getHorizontalRulerWidth();
90  int getVerticalRulerWidth();
91  QWidget* getAuxWidget();
92  void setUndoBufferSize(const int& size);
93  int getUndoBufferSize();
94  void appendToUndo();
95  void copyState();
96  void pan(const QPointF& p);
97  void draw();
98  void drawButtonClicked();
99  void drawLayersSelection();
100  void setSelectionColor(QColor selColor);
101  void setDisplayBackgroundColor(QColor);
102  void resetPaperView();
103  QMatrix getMatrixPaperViewToVp();
104  QMatrix getMatrix();
105  QPixmap* getDraftPixmap();
106  void raiseDraftLayoutEditor();
107  void lowerDraftLayoutEditor();
108  void drawRectArea();
109  void adjustAspectRatio(QRectF& r, const QRectF& ref); // faz a relacao de aspecto de r igual a do ref
110  void setMouseMode(int); // 0=none, 1=zoomin, 2=zoomout, 3=pan (sobre a area do papel/dado)
111  void hideAllObjects();
112  void showAllObjects();
113 
114  void mousePressEvent(QMouseEvent* e);
115  void mouseMoveEvent(QMouseEvent* e);
116  void mouseReleaseEvent(QMouseEvent* e);
117  void wheelEvent(QWheelEvent* e);
118  void keyPressEvent(QKeyEvent* e);
119  void sendEventToChildren(bool b); // true para os layers objects receberem eventos.
120  bool eventFilter(QObject*, QEvent*); // deixa passar apenas o event de paint quando o filtro é instalado.
121 
122  void setFrameSelected(te::qt::widgets::LayoutObject*);
123  te::qt::widgets::LayoutObject* getFrameSelected();
124 
125  private:
126  unsigned int m_idCount;
127  QSize m_paperSize;
131  bool m_dataPan; // flag for datab pan execution
133  int m_rulerGridLines; // grid options: 1 = all, 2 = only medium and large, 3 = only large
136  bool m_resize; // true indica resize operation
137  bool m_move; // true indica move operation
138 
139 
140  // IMPORTANTE IMPORTANTE IMPORTANTE IMPORTANTE IMPORTANTE ////////////////////
141  QWidget* m_auxWidget; // support to view port area. Area interna do LayoutEditor que exclui as reguas. Ele é necessario
142  // para que os widgets de frame nao escondam as reguas.
143  // Todos os frames sao inicializados com LayoutEditor*, mas, a classe base (LayoutObject) é iniciada com m_auxWidget
144  ////////////////////////////////////////////////////////////////////////
145  DraftLayoutEditor* m_draftLayoutEditor; // to edition. É composta da parte interna (sem as reguas).
147  QMatrix m_matrix;
149  QRect m_rect; // used for resize operation
150  QPointF m_pos; // used for resize operation
151  QPointF m_difTopLeft; // offset used to resize operation
152  QPointF m_difBottomRight; // offset used to resize operation
154  QPixmap m_totalPixmap;
155  QPixmap m_viewPixmap;
156  std::vector<te::qt::widgets::LayoutObject*> m_layoutObjects;
157  std::vector<te::qt::widgets::LayoutObject*> m_undoLayoutObjects;
158  bool m_putUndo;
159  QPointF m_pressPoint;
160  QPointF m_startPan; // for pan operation (viewport coordenate) - paper pan and data pan
165 
166  int m_zmouseMode; // 0=none, 1=zoomin, 2=zoomout, 3=pan (sobre a area do papel/dado)
168  QPoint m_zpoint;
169  QRect m_zrect;
170  bool m_zpanEnd;
171  QPixmap m_zpixmap;
173  QPixmap* m_zoomInPixmap;
174  QPixmap* m_zoomOutPixmap;
175  QPixmap* m_panPixmap;
176 
177  };
178  } // end namespace widgets
179  } // end namespace qt
180 } // end namespace te
181 
182 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_MAP_EDITOR_H
A DataFrame ....
Definition: DataFrame.h:59
This file contains include headers for TerraLib Spatial Reference System module.
std::vector< te::qt::widgets::LayoutObject * > m_undoLayoutObjects
Definition: LayoutEditor.h:157
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
te::qt::widgets::EditorInfo * m_editorState
Definition: LayoutEditor.h:135
te::qt::widgets::DataFrame * m_zdataFrame
Definition: LayoutEditor.h:172
te::qt::widgets::LayoutObject * m_layoutObjectSelected
Definition: LayoutEditor.h:130
A connector of the te::qt::widgets::MultiThreadMapDisplay used in te::qt::widgets::DataFrame class to...
DraftLayoutEditor * m_draftLayoutEditor
Definition: LayoutEditor.h:145
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:66
std::vector< te::qt::widgets::LayoutObject * > m_layoutObjects
Definition: LayoutEditor.h:156
This file contains include headers for the Map Tools module of TerraLib.