All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GeographicGridFrame.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 "GeographicGridFrame.h"
28 #include "DataFrame.h"
29 #include "../canvas/MultiThreadMapDisplay.h"
30 
31 #include <QtGui/QPainter>
32 #include <QtGui/QMouseEvent>
33 #include <QtCore/QRect>
34 
36  te::qt::widgets::GridFrame(df, f)
37 {
38  setWindowTitle("GeographicGridFrame");
39  setMouseTracking(true);
40  show();
41 }
42 
44  GridFrame(rhs.m_dataFrame, rhs.windowFlags())
45 {
46  setWindowTitle("GeographicGridFrame");
47  setMouseTracking(true);
48  show();
49 }
50 
52 {
53  hide();
54 }
55 
57 {
58  if(this != &rhs)
59  {
61  setWindowTitle("GeographicGridFrame");
62  setMouseTracking(true);
63  show();
64  }
65 
66  return *this;
67 }
68 
70 {
72  draw();
73 }
74 
76 {
77  int i, n = 4;
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::red);
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::red);
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() - 6), QPoint(rr.left() + (i * dw) + 5, rr.top() - 6));
109  painter.drawLine(QPoint(rr.left() + i * dw - 5, rr.bottom() + 6), QPoint(rr.left() + (i * dw) + 5, rr.bottom() + 6));
110  }
111  for(i = 0; i <= n; ++i) // linhas do y
112  {
113  painter.drawLine(QPoint(rr.left() - 6, rr.top() + i * dh), QPoint(rr.left() - 16, rr.top() + i * dh));
114  painter.drawLine(QPoint(rr.right() + 6, rr.top() + i * dh), QPoint(rr.right() + 16, rr.top() + i * dh));
115  }
116  painter.end();
117 
118  copyToDraftMapDisplay();
119 
120  update();
121  //raise();
122 }
123 
125 {
126  QPainter painter(this);
127  painter.drawPixmap(0, 0, m_pixmap);
128 }
129 
131 {
132  if(mouseEvent->buttons() == Qt::NoButton)
133  lower();
134 }
A DataFrame ....
Definition: DataFrame.h:59
GeographicGridFrame(te::qt::widgets::DataFrame *df, Qt::WindowFlags f=Qt::Widget)
GeographicGridFrame & operator=(const GeographicGridFrame &rhs)
GridFrame & operator=(const GridFrame &rhs)
Definition: GridFrame.cpp:91
A GridFrame ....
Definition: GridFrame.h:50