All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UTMGridFrame.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 terralib/qt/widgets/canvas/TextFrame.h
22 
23  \brief The frame data....
24 */
25 
26 // TerraLib
27 #include "UTMGridFrame.h"
28 #include "DataFrame.h"
29 #include "LayoutEditor.h"
30 #include "../canvas/MultiThreadMapDisplay.h"
31 
32 #include <QtGui/QPainter>
33 #include <QtGui/QMouseEvent>
34 #include <QtCore/QRect>
35 
37  te::qt::widgets::GridFrame(df, f)
38 {
39  setWindowTitle("UTMGridFrame");
40  setMouseTracking(true);
41  show();
42 }
43 
45  GridFrame(rhs.m_dataFrame, rhs.windowFlags())
46 {
47  setWindowTitle("UTMGridFrame");
48  setMouseTracking(true);
49  show();
50 }
51 
53 {
54  hide();
55 }
56 
58 {
59  if(this != &rhs)
60  {
62  setWindowTitle("UTMGridFrame");
63  setMouseTracking(true);
64  show();
65  }
66 
67  return *this;
68 }
69 
71 {
73 }
74 
76 {
77  int i, n = 10;
78  QRect rr = m_dataFrame->getMapDisplay()->getDisplayPixmap()->rect();
79  double w = rr.width();
80  int dw = w / n;
81  double h = rr.height();
82  int dh = h / n;
83 
84  QPixmap p(w, h);
85  p.fill(Qt::transparent);
86  m_pixmap.fill(Qt::transparent);
87 
88  QPainter painter(&p);
89  painter.setBrush(Qt::NoBrush);
90  painter.setPen(Qt::blue);
91 
92  for(i = 0; i <= n; ++i) // linhas verticais
93  painter.drawLine(QPoint(i * dw, 0), QPoint(i * dw, h-1));
94  for(i = 0; i <= n; ++i) // linhas horizontais
95  painter.drawLine(QPoint(0, i * dh), QPoint(w-1, i * dh));
96 
97  painter.end();
98  painter.begin(&m_pixmap);
99  painter.setPen(Qt::blue);
100 
101  QRect r = m_pixmap.rect();
102  QPoint c = r.center();
103  rr.moveCenter(c);
104  painter.drawPixmap(rr, p, p.rect());
105 
106  for(i = 0; i <= n; ++i) // labels do x
107  {
108  painter.drawLine(QPoint(rr.left() + i * dw - 5, rr.top() - 3), QPoint(rr.left() + (i * dw) + 5, rr.top() - 3));
109  painter.drawLine(QPoint(rr.left() + i * dw - 5, rr.bottom() + 3), QPoint(rr.left() + (i * dw) + 5, rr.bottom() + 3));
110  }
111  for(i = 0; i <= n; ++i) // linhas do y
112  {
113  painter.drawLine(QPoint(rr.left() - 3, rr.top() + i * dh), QPoint(rr.left() - 13, rr.top() + i * dh));
114  painter.drawLine(QPoint(rr.right() + 3, rr.top() + i * dh), QPoint(rr.right() + 13, rr.top() + i * dh));
115  }
116  painter.end();
117 
118  copyToDraftMapDisplay();
119 
120  update();
121 }
122 
124 {
125  QPainter painter(this);
126  painter.drawPixmap(0, 0, m_pixmap);
127 }
128 
130 {
131  if(mouseEvent->buttons() == Qt::NoButton)
132  lower();
133 }
A UTMGridFrame ....
Definition: UTMGridFrame.h:50
A GridFrame ....
Definition: GridFrame.h:50
UTMGridFrame & operator=(const UTMGridFrame &rhs)
A DataFrame ....
Definition: DataFrame.h:59
UTMGridFrame(te::qt::widgets::DataFrame *df, Qt::WindowFlags f=Qt::Widget)
void paintEvent(QPaintEvent *)
void mouseMoveEvent(QMouseEvent *)
GridFrame & operator=(const GridFrame &rhs)
Definition: GridFrame.cpp:91