All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GridFrame.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 "GridFrame.h"
28 #include "DataFrame.h"
29 #include "LayoutEditor.h"
30 #include "../canvas/MultiThreadMapDisplay.h"
31 
32 // Qt
33 #include <QtGui/QPainter>
34 
36  Frame(df->getLayoutEditor(), f),
37  m_dataFrame(df),
38  m_hSpace(100),
39  m_vSpace(100),
40  m_verticalLabelSpace(2),
41  m_horizontalLabelSpace(2),
42  m_verticalLabelAngle(0),
43  m_horizontalLabelAngle(90)
44 {
45  adjust();
46 
47  m_font = QFont("Lucida Sans", 10);
48 
49  QRectF dr = m_dataFrame->getDataRect();
50  if(dr.isValid())
51  {
52  m_initialCoordX = dr.left();
53  m_deltaX = (dr.right() - dr.left()) / 5.;
54  m_initialCoordY = dr.top();
55  m_deltaY = (dr.bottom() - dr.top()) / 5.;
56  }
57  else // so para teste
58  {
59  m_initialCoordX = 10;
60  m_deltaX = 5;
61  m_initialCoordY = 100;
62  m_deltaY = 5;
63  }
64 }
65 
67  Frame(rhs.m_layoutEditor, rhs.windowFlags())
68 {
70  m_hSpace = rhs.m_hSpace;
71  m_vSpace = rhs.m_vSpace;
76 
77  adjust();
78 
79  m_font = rhs.m_font;
81  m_deltaX = rhs.m_deltaX;
83  m_deltaY = rhs.m_deltaY;
84 }
85 
87 {
88  hide();
89 }
90 
92 {
93  if(this != &rhs)
94  {
96  m_dataFrame = rhs.m_dataFrame;
97  m_hSpace = rhs.m_hSpace;
98  m_vSpace = rhs.m_vSpace;
99  m_verticalLabelSpace = rhs.m_verticalLabelSpace;
100  m_horizontalLabelSpace = rhs.m_horizontalLabelSpace;
101  m_verticalLabelAngle = rhs.m_verticalLabelAngle;
102  m_horizontalLabelAngle = rhs.m_horizontalLabelAngle;
103 
104  adjust();
105 
106  m_font = rhs.m_font;
107  m_initialCoordX = rhs.m_initialCoordX;
108  m_deltaX = rhs.m_deltaX;
109  m_initialCoordY = rhs.m_initialCoordY;
110  m_deltaY = rhs.m_deltaY;
111  }
112 
113  return *this;
114 }
115 
117 {
118  // centralize deixando espacos na horizontal e na vertical
119  // para poder colocar os labels.
120 
121  int w = m_dataFrame->getMapDisplay()->getDisplayPixmap()->width();
122  int h = m_dataFrame->getMapDisplay()->getDisplayPixmap()->height();
123 
124  double scale = (double)w / m_dataFrame->getFrameRect().width();
125 
126  int hs = (int)(m_hSpace * scale + .5);
127  int vs = (int)(m_vSpace * scale + .5);
128  int tw = 2 * hs + w;
129  int th = 2 * vs + h;
130  resize(tw, th);
131 
132  m_pixmap = QPixmap(tw, th);
133  m_pixmap.fill(Qt::transparent);
134 
135  //int x = m_dataFrame->x() + m_layoutEditor->getVerticalRulerWidth();
136  //int y = m_dataFrame->y() + m_layoutEditor->getHorizontalRulerWidth();
137  int x = m_dataFrame->x();
138  int y = m_dataFrame->y();
139 
140  move(x - hs + 9, y - vs + 9);
141 }
142 
144 {
145  // copie sobre o draft pixmap do map display
146  QPixmap* dPixmap = m_dataFrame->getMapDisplay()->getDraftPixmap();
147  QRect dr = dPixmap->rect();
148  dr.moveCenter(m_pixmap.rect().center());
149  QPainter painter(dPixmap);
150  painter.drawPixmap(dPixmap->rect(), m_pixmap, dr);
151  painter.end();
152 }
153 
155 {
156  m_dataFrame = df;
157 }
158 
160 {
161  return m_font;
162 }
163 
165 {
166  return m_verticalLabelSpace;
167 }
168 
170 {
171  m_verticalLabelSpace = s;
172 }
173 
175 {
176  return m_horizontalLabelSpace;
177 }
178 
180 {
181  m_horizontalLabelSpace = s;
182 }
183 
185 {
186  return m_verticalLabelAngle;
187 }
188 
190 {
191  m_verticalLabelAngle = a;
192 }
193 
195 {
196  return m_horizontalLabelAngle;
197 }
198 
200 {
201  m_horizontalLabelAngle = a;
202 }
203 
205 {
206  return m_initialCoordX;
207 }
208 
210 {
211  m_initialCoordX = x;
212 }
213 
215 {
216  return m_deltaX;
217 }
218 
220 {
221  m_deltaX = x;
222 }
223 
225 {
226  return m_initialCoordY;
227 }
228 
230 {
231  m_initialCoordY = y;
232 }
233 
235 {
236  return m_deltaY;
237 }
238 
240 {
241  m_deltaY = y;
242 }
243 
245 {
246  return m_hSpace;
247 }
248 
250 {
251  m_hSpace = h;
252 }
253 
255 {
256  return m_vSpace;
257 }
258 
260 {
261  m_vSpace = v;
262 }
A DataFrame ....
Definition: DataFrame.h:59
void setHSpace(unsigned int)
Definition: GridFrame.cpp:249
void setHorizontalLabelSpace(unsigned int)
Definition: GridFrame.cpp:179
void setVerticalLabelSpace(unsigned int)
Definition: GridFrame.cpp:169
GridFrame(te::qt::widgets::DataFrame *df, Qt::WindowFlags f=Qt::Window)
Definition: GridFrame.cpp:35
void setVSpace(unsigned int)
Definition: GridFrame.cpp:259
unsigned int getVerticalLabelSpace()
Definition: GridFrame.cpp:164
unsigned int getVSpace()
Definition: GridFrame.cpp:254
unsigned int m_verticalLabelSpace
Definition: GridFrame.h:101
GridFrame & operator=(const GridFrame &rhs)
Definition: GridFrame.cpp:91
te::qt::widgets::DataFrame * m_dataFrame
Definition: GridFrame.h:98
A GridFrame ....
Definition: GridFrame.h:50
unsigned int m_horizontalLabelSpace
Definition: GridFrame.h:102
void setInitialCoordY(double)
Definition: GridFrame.cpp:229
void setInitialCoordX(double)
Definition: GridFrame.cpp:209
void setDataFrame(te::qt::widgets::DataFrame *df)
Definition: GridFrame.cpp:154
unsigned int getHSpace()
Definition: GridFrame.cpp:244
Frame & operator=(const Frame &rhs)
Definition: Frame.cpp:70
unsigned int getHorizontalLabelSpace()
Definition: GridFrame.cpp:174