All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataFrame.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/DataFrame.h
22 
23  \brief The data frame....
24 */
25 
26 // TerraLib
27 #include "DataFrame.h"
28 #include "LayoutEditor.h"
29 #include "GeographicGridFrame.h"
30 #include "UTMGridFrame.h"
31 #include "GraphicScaleFrame.h"
32 
33 #include <terralib/geometry.h>
34 #include <terralib/srs/Config.h>
35 #include <terralib/srs/Converter.h>
42 
43 
44 // Qt
45 #include <QtGui/QApplication>
46 #include <QtGui/QAction>
47 #include <QtGui/QMenu>
48 #include <QtGui/QToolTip>
49 #include <QtGui/QPainter>
50 #include <QtGui/QColor>
51 #include <QtGui/QWidget>
52 #include <QtGui/QFontDatabase>
53 #include <QtGui/QResizeEvent>
54 #include <QtGui/QBoxLayout>
55 #include <QtGui/QMessageBox>
56 #include <QtGui/QInputDialog>
57 
58 #include <QtCore/QRect>
59 #include <QtCore/QCoreApplication>
60 #include <QtCore/QEvent>
61 
62 te::qt::widgets::DataFrame::DataFrame(const QRectF& frameRect, te::qt::widgets::LayoutEditor* me, Qt::WindowFlags f) :
63  te::qt::widgets::Frame(me, f),
64  m_mapDisplay(0),
65  m_scale(-1),
66  m_dataUnitToMilimeter(-1),
67  m_geoGridFrame(0),
68  m_UTMGridFrame(0),
69  m_graphicScaleFrame(0)
70 {
71  setWindowTitle("DataFrame");
72  setMouseTracking(true);
73 
74  adjustWidgetToFrameRect(frameRect);
75  show();
76 
77  m_mapDisplay = new te::qt::widgets::MultiThreadMapDisplay(QSize(10, 10), true, this, f);
78  m_mapDisplay->setAcceptDrops(true);
81  m_mapDisplay->setMouseTracking(true);
82  m_mapDisplay->installEventFilter(this);
83  QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, this);
84  layout->addWidget(m_mapDisplay);
85  setLayout(layout);
86 
87  m_mapDisplay->show();
88  connect(m_mapDisplay, SIGNAL(drawLayersFinished(const QMap<QString, QString>&)), this, SLOT(onDrawLayersFinished(const QMap<QString, QString>&)));
89 
90  m_menu = new QMenu(this);
91  m_createUTMGridAction = m_menu->addAction("Create UTM Grid");
92  m_removeUTMGridAction = m_menu->addAction("Remove UTM Grid");
93  m_removeUTMGridAction->setEnabled(false);
94  m_createGeographicGridAction = m_menu->addAction("Create Geographic Grid");
95  m_removeGeographicGridAction = m_menu->addAction("Remove Geographic Grid");
96  m_removeGeographicGridAction->setEnabled(false);
97  m_createGraphicScaleAction = m_menu->addAction("Create Graphic Scale");
98  m_removeGraphicScaleAction = m_menu->addAction("Remove Graphic Scale");
99  m_removeGraphicScaleAction->setEnabled(false);
100  m_magneticDeclinationAction = m_menu->addAction("Magnetic Declination...");
101 }
102 
104  te::qt::widgets::Frame(rhs.m_layoutEditor, rhs.windowFlags()),
105  m_dataUnitToMilimeter(rhs.m_dataUnitToMilimeter)
106 {
108  setWindowTitle("DataFrame");
109  setMouseTracking(true);
110  m_dataRect = rhs.m_dataRect;
112  m_scale = rhs.m_scale;
113  m_mapDisplay = 0;
114  m_UTMGridFrame = 0;
115  m_geoGridFrame = 0;
117 
118  m_data = rhs.m_data;
120 
121  adjust();
122  show();
123  m_mapDisplay = new te::qt::widgets::MultiThreadMapDisplay(rect().size(), true, this, rhs.windowFlags());
124  m_mapDisplay->setBackgroundColor(Qt::gray);
125  m_mapDisplay->setAcceptDrops(true);
129  m_mapDisplay->setMouseTracking(true);
130  m_mapDisplay->installEventFilter(this);
131  QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, this);
132  layout->addWidget(m_mapDisplay);
133  setLayout(layout);
134 
135  m_mapDisplay->show();
136  connect(m_mapDisplay, SIGNAL(drawLayersFinished(const QMap<QString, QString>&)), this, SLOT(onDrawLayersFinished(const QMap<QString, QString>&)));
137 
139  m_mapDisplay->setExtent(env, false);
140 
141  if(rhs.m_UTMGridFrame)
142  {
145  }
146 
147  if(rhs.m_geoGridFrame)
148  {
151  }
152 
153  if(rhs.m_graphicScaleFrame)
154  {
157  }
158  show();
159 
160  m_menu = new QMenu(this);
161  m_createUTMGridAction = m_menu->addAction("Create UTM Grid");
162  m_removeUTMGridAction = m_menu->addAction("Remove UTM Grid");
163  m_createGeographicGridAction = m_menu->addAction("Create Geographic Grid");
164  m_removeGeographicGridAction = m_menu->addAction("Remove Geographic Grid");
165  m_createGraphicScaleAction = m_menu->addAction("Create Graphic Scale");
166  m_removeGraphicScaleAction = m_menu->addAction("Remove Graphic Scale");
167  m_magneticDeclinationAction = m_menu->addAction("Magnetic Declination...");
168 
169  m_createUTMGridAction->setEnabled(rhs.m_createUTMGridAction->isEnabled());
170  m_removeUTMGridAction->setEnabled(rhs.m_removeUTMGridAction->isEnabled());
171  m_createGeographicGridAction->setEnabled(rhs.m_createGeographicGridAction->isEnabled());
172  m_removeGeographicGridAction->setEnabled(rhs.m_removeGeographicGridAction->isEnabled());
173  m_createGraphicScaleAction->setEnabled(rhs.m_createGraphicScaleAction->isEnabled());
174  m_removeGraphicScaleAction->setEnabled(rhs.m_removeGraphicScaleAction->isEnabled());
175 }
176 
178 {
179  if(this != &rhs)
180  {
182  setWindowTitle("DataFrame");
183  setMouseTracking(true);
184  m_dataUnitToMilimeter = rhs.m_dataUnitToMilimeter;
185  m_dataRect = rhs.m_dataRect;
186  m_dataChanged = rhs.m_dataChanged;
187  m_scale = rhs.m_scale;
188  m_mapDisplay = 0;
189  m_UTMGridFrame = 0;
190  m_geoGridFrame = 0;
191  m_graphicScaleFrame = 0;
192 
193  m_data = rhs.m_data;
194  m_visibleLayers = rhs.m_visibleLayers;
195 
196  adjust();
197  show();
198  m_mapDisplay = new te::qt::widgets::MultiThreadMapDisplay(rect().size(), true, this, rhs.windowFlags());
199  m_mapDisplay->setBackgroundColor(Qt::gray);
200  m_mapDisplay->setAcceptDrops(true);
201  m_mapDisplay->setAlign(rhs.m_mapDisplay->getHAlign(), rhs.m_mapDisplay->getVAlign());
202  m_mapDisplay->setSRID(rhs.m_mapDisplay->getSRID());
203  m_mapDisplay->setResizeInterval(0);
204  m_mapDisplay->setMouseTracking(true);
205  m_mapDisplay->installEventFilter(this);
206  QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, this);
207  layout->addWidget(m_mapDisplay);
208  setLayout(layout);
209 
210  m_mapDisplay->show();
211  connect(m_mapDisplay, SIGNAL(drawLayersFinished(const QMap<QString, QString>&)), this, SLOT(onDrawLayersFinished(const QMap<QString, QString>&)));
212 
214  m_mapDisplay->setExtent(env, false);
215 
216  if(rhs.m_UTMGridFrame)
217  {
218  m_UTMGridFrame = new te::qt::widgets::UTMGridFrame(*rhs.m_UTMGridFrame);
219  m_UTMGridFrame->setDataFrame(this);
220  }
221 
222  if(rhs.m_geoGridFrame)
223  {
224  m_geoGridFrame = new te::qt::widgets::GeographicGridFrame(*rhs.m_geoGridFrame);
225  m_geoGridFrame->setDataFrame(this);
226  }
227 
228  if(rhs.m_graphicScaleFrame)
229  {
230  m_graphicScaleFrame = new te::qt::widgets::GraphicScaleFrame(*rhs.m_graphicScaleFrame);
231  m_graphicScaleFrame->setDataFrame(this);
232  }
233  show();
234 
235  m_menu = new QMenu(this);
236  m_createUTMGridAction = m_menu->addAction("Create UTM Grid");
237  m_removeUTMGridAction = m_menu->addAction("Remove UTM Grid");
238  m_createGeographicGridAction = m_menu->addAction("Create Geographic Grid");
239  m_removeGeographicGridAction = m_menu->addAction("Remove Geographic Grid");
240  m_createGraphicScaleAction = m_menu->addAction("Create Graphic Scale");
241  m_removeGraphicScaleAction = m_menu->addAction("Remove Graphic Scale");
242  m_magneticDeclinationAction = m_menu->addAction("Magnetic Declination...");
243 
244  m_createUTMGridAction->setEnabled(rhs.m_createUTMGridAction->isEnabled());
245  m_removeUTMGridAction->setEnabled(rhs.m_removeUTMGridAction->isEnabled());
246  m_createGeographicGridAction->setEnabled(rhs.m_createGeographicGridAction->isEnabled());
247  m_removeGeographicGridAction->setEnabled(rhs.m_removeGeographicGridAction->isEnabled());
248  m_createGraphicScaleAction->setEnabled(rhs.m_createGraphicScaleAction->isEnabled());
249  m_removeGraphicScaleAction->setEnabled(rhs.m_removeGraphicScaleAction->isEnabled());
250  }
251  return *this;
252 }
253 
255 {
256  hide();
257  removeEventFilter(this);
258  delete m_mapDisplay;
259  delete m_UTMGridFrame;
260  delete m_geoGridFrame;
261  delete m_graphicScaleFrame;
262 }
263 
265 {
266  return m_mapDisplay;
267 }
268 
270 {
271  if(r != m_dataRect)
272  {
273  m_dataRect = r;
274  te::gm::Envelope e(r.left(), r.top(), r.right(), r.bottom());
275  m_mapDisplay->setExtent(e);
276  }
277 }
278 
280 {
281  te::gm::Envelope e = m_mapDisplay->getExtent();
282  m_dataRect = QRectF(e.m_llx, e.m_lly, e.getWidth(), e.getHeight());
283  return m_dataRect;
284 }
285 
287 {
288  adjustWidgetToFrameRect(m_frameRect);
289  if(m_UTMGridFrame)
290  m_UTMGridFrame->adjust();
291  if(m_geoGridFrame)
292  m_geoGridFrame->adjust();
293  if(m_graphicScaleFrame)
294  m_graphicScaleFrame->adjust();
295 }
296 
298 {
299  //if(m_frameRect == r)
300  // return;
301  //setDataChanged(true);
302  m_frameRect = r;
303 
304  if(m_layoutEditor->getPaperViewRect().intersects(m_frameRect) == false)
305  {
306  hide();
307  return;
308  }
309  show();
310 
311  QMatrix matrix = m_layoutEditor->getMatrixPaperViewToVp();
312  QRect rec = matrix.mapRect(m_frameRect).toRect();
313 
314  QWidget::resize(rec.width()+19, rec.height()+19);
315  QWidget::move(rec.left()-9, rec.top()-9);
316  //QWidget::resize(rec.width()+18, rec.height()+18);
317  //QWidget::move(rec.left()-8, rec.top()-7);
318 
319  double pw = rec.width();
320  double ph = rec.height();
321  int ipw = qRound(pw);
322  int iph = qRound(ph);
323  int ipw2 = qRound(pw/2.);
324  int iph2 = qRound(ph/2.);
325  double w = 9;
326  double h = 9;
327 
328  if(pw < w*5)
329  w = pw / 5.;
330  if(ph < h*5)
331  h = ph / 5.;
332 
333  int iw = qRound(w);
334  int ih = qRound(h);
335  int iw2 = qRound(w/2.);
336  int ih2 = qRound(h/2.);
337 
338  m_recSel1 = QRect(0, 0, iw, ih);
339  m_recSel2 = QRect(ipw2 - iw2, 0, iw, ih);
340  m_recSel3 = QRect(ipw - iw, 0, iw, ih);
341  m_recSel4 = QRect(ipw - iw, iph2 - ih2, iw, ih);
342  m_recSel5 = QRect(ipw - iw, iph - ih, iw, ih);
343  m_recSel6 = QRect(ipw2 - iw2, iph - ih, iw, ih);
344  m_recSel7 = QRect(0, iph - ih, iw, ih);
345  m_recSel8 = QRect(0, iph2 - ih2, iw, ih);
346  //m_recSel9 = QRect(ipw2 - iw2, iph2 - ih2, iw, ih);
347  m_recSel10 = QRect(0, 0, ipw, iph);
348 }
349 
351 {
352  return m_scale;
353 }
354 
356 {
357  if(m_scale == v)
358  return;
359 
360  m_scale = v;
361  double toMeter = m_dataUnitToMilimeter / 1000;
362  te::gm::Envelope env = m_mapDisplay->getExtent();
363  double w = m_frameRect.width();
364  double h = m_frameRect.height();
365  double ew = env.getWidth() * toMeter;
366  double eh = env.getHeight() * toMeter;
367  double ecx = env.getLowerLeftX() * toMeter + ew / 2.;
368  double ecy = env.getLowerLeftY() * toMeter + eh / 2.;
369  double ww = w * m_scale / 1000;
370  double wh = h * m_scale / 1000;
371  double exi = (ecx - ww / 2.) / toMeter;
372  double eyi = (ecy - wh / 2.) / toMeter;
373  te::gm::Envelope env2(exi, eyi, exi + ww/toMeter, eyi + wh/toMeter);
374  m_dataRect = QRectF(QPointF(exi, eyi), QPointF(exi + ww/toMeter, eyi + wh/toMeter));
375  m_mapDisplay->setExtent(env2);
376  if(m_graphicScaleFrame)
377  m_graphicScaleFrame->setStep(0);
378  adjust();
379 }
380 
382 {
383  return m_data;
384 }
385 
386 void te::qt::widgets::DataFrame::getLayerList(te::map::AbstractLayerPtr al, std::list<te::map::AbstractLayerPtr>& layerList)
387 {
388  try
389  {
390  if(al->getType() == "DATASETLAYER" ||
391  al->getType() == "QUERYLAYER" ||
392  al->getType() == "RASTERLAYER")
393  {
394  if(al->getVisibility() == te::map::VISIBLE)
395  layerList.push_back(al);
396  //layerList.push_front(al);
397  }
398 
400  for(it = al.get()->begin(); it != al.get()->end(); ++it)
401  {
402  te::common::TreeItemPtr p = (*it);
403  te::common::TreeItem* tp = p.get();
404  te::map::AbstractLayer* l = dynamic_cast<te::map::AbstractLayer*>(tp);
406  getLayerList(t, layerList);
407  }
408  }
409  catch(te::common::Exception& e)
410  {
411  throw(te::common::Exception(e.what()));
412  }
413 }
414 
416 {
417  m_data = al.get();
418  if(m_data == 0)
419  {
420  QPixmap* pix = m_mapDisplay->getDisplayPixmap();
421  m_mapDisplay->setBackgroundColor(Qt::gray);
422  m_mapDisplay->update();
423  return;
424  }
425 
426  m_dataChanged = true;
427  m_mapDisplay->changeData(al, nsrid);
428  m_visibleLayers.clear();
429  getLayerList(al, m_visibleLayers);
430  if(m_visibleLayers.size() == 0)
431  {
432  QPixmap* pix = m_mapDisplay->getDisplayPixmap();
433  m_mapDisplay->setBackgroundColor(Qt::gray);
434  m_mapDisplay->update();
435  return;
436  }
437 
438  m_mapDisplay->setBackgroundColor(Qt::white);
439  te::gm::Envelope e = m_mapDisplay->getExtent();
440 
441  if(dr.isValid())
442  m_mapDisplay->refresh();
443  else
444  {
445  m_dataRect = QRectF();
446  QRectF r(e.getLowerLeftX(), e.getLowerLeftY(), e.getWidth(), e.getHeight());
447  setDataRect(r);
448  }
449 
450  findDataUnitToMilimeter(e, m_mapDisplay->getSRID());
451 
452  double w = m_frameRect.width();
453  double ww = m_dataUnitToMilimeter * e.getWidth();
454  m_scale = ww / w;
455 }
456 
458 {
459  m_dataChanged = b;
460 }
461 
463 {
464  // este codigo alem de converter ele mantem a escala inalterada.
465  if(oldsrid == newsrid)
466  return true;
467 
468  te::gm::Envelope oldEnv(e);
469 
470  try
471  {
472  double x, y, xmin, xmax, ymin, ymax;
473 
474  std::auto_ptr<te::srs::Converter> converter(new te::srs::Converter());
475 
476  converter->setSourceSRID(oldsrid);
477  converter->setTargetSRID(newsrid);
478 
479  x = e.m_llx;
480  y = e.m_lly;
481  converter->convert(x, y);
482  xmin = x;
483  ymin = y;
484  xmax = x;
485  ymax = y;
486 
487  x = e.m_llx;
488  y = e.m_ury;
489  converter->convert(x, y);
490  if(x < xmin)
491  xmin = x;
492  if(y < ymin)
493  ymin = y;
494  if(x > xmax)
495  xmax = x;
496  if(y > ymax)
497  ymax = y;
498 
499  x = e.m_urx;
500  y = e.m_ury;
501  converter->convert(x, y);
502  if(x < xmin)
503  xmin = x;
504  if(y < ymin)
505  ymin = y;
506  if(x > xmax)
507  xmax = x;
508  if(y > ymax)
509  ymax = y;
510 
511  x = e.m_urx;
512  y = e.m_lly;
513  converter->convert(x, y);
514  if(x < xmin)
515  xmin = x;
516  if(y < ymin)
517  ymin = y;
518  if(x > xmax)
519  xmax = x;
520  if(y > ymax)
521  ymax = y;
522 
523  // faca em funcao do centro do box... mantenha o centro do box inalterado
524 
525  double cx = e.m_llx + e.getWidth() / 2.;
526  double cy = e.m_lly + e.getHeight() / 2.;
527  converter->convert(cx, cy);
528 
529  if(std::numeric_limits<double>::has_infinity)
530  {
531  if(xmin == std::numeric_limits<double>::infinity() || ymin == std::numeric_limits<double>::infinity() ||
532  xmax == std::numeric_limits<double>::infinity() || ymax == std::numeric_limits<double>::infinity())
533  return false;
534  }
535 
536  double w = xmax - xmin;
537  double h = ymax - ymin;
538 
539  // faca a altura e a largura proporcional ao antigo box... oldEnv
540  double xScale = w / oldEnv.getWidth();
541  double yScale = h / oldEnv.getHeight();
542 
543  if(xScale > yScale)
544  h *= (xScale / yScale);
545  else
546  w *= (yScale / xScale);
547 
548  xmin = cx - w / 2.;
549  ymin = cy - h / 2.;
550  xmax = cx + w / 2.;
551  ymax = cy + h / 2.;
552 
553  e.init(xmin, ymin, xmax, ymax);
554  if(e.getWidth() == 0. || e.getHeight() == 0.)
555  return false;
556 
557  findDataUnitToMilimeter(e, newsrid);
558  return true;
559  }
560  catch(std::exception&)
561  {
562  return false;
563  }
564 }
565 
567 {
568  //m_dataUnitToMilimeter = 1000;
569  // OBS: quero manter a escala do mapa inalterada. Lembre que quando converte,
570  // o box, pode aumentar de tamanho e isto muda a escala do mapa.
571  // Vamos ver como podemos fazer isto...
572  // primeior vamos descobrir qual o fator de conversao para milimetros... m_dataUnitToMilimeter.
573  // Vou converter dataRect para um projetado que deve estar em metros.
574  // De preferencia deve ser escolhido uma projecao que mantem as distancias.
575  // Vou usar #define TE_SRS_SAD69_POLYCONIC 29101 (essa projecao tem que ter unidade em metros e manter distancias) Será que ele faz isto???.
576 
577  std::auto_ptr<te::srs::Converter> converter(new te::srs::Converter());
578  converter->setSourceSRID(srid);
579  converter->setTargetSRID(29101); // Brasil polyconic em metros
580 
581  double x1 = e.m_llx;
582  double y1 = e.m_lly;
583  double a1 = x1;
584  double b1 = y1;
585  converter->convert(a1, b1);
586  double x2 = e.m_urx;
587  double y2 = e.m_ury;
588  double a2 = x2;
589  double b2 = y2;
590  converter->convert(a2, b2);
591 
592  // a conversao pode causar um leve giro no box, portanto,
593  // vou usar a distancia entre os pontos da diagonal do box (ll e ur)
594  double dx = (x2 - x1);
595  double dy = (y2 - y1);
596  double da = (a2 - a1);
597  double db = (b2 - b1);
598 
599  double d = sqrt(dx * dx + dy * dy);
600  double dd = sqrt(da * da + db * db);
601  // Calcular o fator de conversao para milimetros
602  m_dataUnitToMilimeter = 1000 * dd / d;
603  // esta fator (m_dataUnitToMilimeter) eh usado da seguinte forma:
604  // multiplique a distancia do projetado, por este fator, para se obter a distancia em milimetros.
605 }
606 
608 {
609  return m_dataUnitToMilimeter;
610 }
611 
613 {
614  if(m_data == 0)
615  return;
616 
617  // verificar se mudou a lista de layers visiveis
618  m_dataChanged = false;
619  std::list<te::map::AbstractLayerPtr>::iterator it, mit;
620  std::list<te::map::AbstractLayerPtr> visibleLayers;
621  te::map::AbstractLayerPtr al(m_data);
622  getLayerList(al, visibleLayers);
623  if(m_visibleLayers.size())
624  {
625  if(visibleLayers.size() == 0)
626  {
627  m_dataChanged = true;
628  m_visibleLayers.clear();
629  }
630  else // verifique se nada mudou
631  {
632  if(visibleLayers.size() == m_visibleLayers.size())
633  {
634  for(it = visibleLayers.begin(), mit = m_visibleLayers.begin(); it != visibleLayers.end(); ++it, ++mit)
635  {
637  te::map::AbstractLayerPtr pp = *mit;
638  if(p != pp)
639  {
640  m_dataChanged = true; // houve mudancas
641  break;
642  }
643  }
644  if(it == visibleLayers.end()) // nada mudou
645  return;
646  }
647  }
648  }
649  else
650  {
651  if(visibleLayers.size())
652  {
653  m_dataChanged = true; // houve mudancas
654  m_visibleLayers = visibleLayers;
655  }
656  else // nada mudou
657  return;
658  }
659 
660  // houve mudancas
661  m_dataChanged = true;
662  if(m_dataChanged)
663  {
664  setData(0, m_mapDisplay->getSRID(), m_dataRect);
665  setData(al, m_mapDisplay->getSRID(), m_dataRect);
666  }
667 
668  draw();
669 }
670 
672 {
673  if(m_dataChanged)
674  m_mapDisplay->refresh();
675  else
676  m_mapDisplay->update();
677 
678  if(m_UTMGridFrame)
679  {
680  m_UTMGridFrame->draw();
681  m_UTMGridFrame->update();
682  }
683 
684  if(m_geoGridFrame)
685  {
686  m_geoGridFrame->draw();
687  m_geoGridFrame->update();
688  }
689 
690  if(m_graphicScaleFrame)
691  {
692  m_graphicScaleFrame->draw();
693  m_graphicScaleFrame->update();
694  }
695 
696  setDataChanged(false);
697 }
698 
700 {
701  // faz tudo em coordenadas do dispositivo
702 
703  QPixmap* pixmap = m_mapDisplay->getDraftPixmap();
704  pixmap->fill(Qt::transparent);
705 
706  if(m_UTMGridFrame)
707  m_UTMGridFrame->copyToDraftMapDisplay();
708  if(m_geoGridFrame)
709  m_geoGridFrame->copyToDraftMapDisplay();
710  //if(m_UTMGridFrame || m_geoGridFrame)
711  // m_mapDisplay->refresh();
712 
713  QPainter painter(pixmap);
714 
715  painter.setBrush(Qt::NoBrush);
716  painter.setPen(Qt::blue);
717  painter.setBrush(QColor(0, 0, 255, 120));
718  painter.drawRect(m_recSel1);
719  painter.drawRect(m_recSel2);
720  painter.drawRect(m_recSel3);
721  painter.drawRect(m_recSel4);
722  painter.drawRect(m_recSel5);
723  painter.drawRect(m_recSel6);
724  painter.drawRect(m_recSel7);
725  painter.drawRect(m_recSel8);
726  //painter.drawRect(m_recSel9);
727  painter.setBrush(QColor(0, 0, 255, 20));
728  painter.drawRect(m_recSel10);
729  painter.end();
730  m_mapDisplay->repaint();
731 }
732 
734 {
735  QPixmap* pixmap = m_mapDisplay->getDraftPixmap();
736  pixmap->fill(Qt::transparent);
737 
738  if(m_UTMGridFrame)
739  m_UTMGridFrame->copyToDraftMapDisplay();
740  if(m_geoGridFrame)
741  m_geoGridFrame->copyToDraftMapDisplay();
742  //if(m_UTMGridFrame || m_geoGridFrame)
743  // m_mapDisplay->refresh();
744 
745  m_mapDisplay->repaint();
746 }
748 {
749  // faz tudo em coordenadas do dispositivo
750 
751  m_selected = 0;
752  if(m_recSel1.contains(p))
753  m_selected = 1;
754  else if(m_recSel2.contains(p))
755  m_selected = 2;
756  else if(m_recSel3.contains(p))
757  m_selected = 3;
758  else if(m_recSel4.contains(p))
759  m_selected = 4;
760  else if(m_recSel5.contains(p))
761  m_selected = 5;
762  else if(m_recSel6.contains(p))
763  m_selected = 6;
764  else if(m_recSel7.contains(p))
765  m_selected = 7;
766  else if(m_recSel8.contains(p))
767  m_selected = 8;
768  //else if(m_recSel9.contains(p))
769  // m_selected = 9;
770  else if(m_recSel10.contains(p))
771  m_selected = 10;
772 }
773 
775 {
776  //QSize size = m_layoutEditor->getPaperSize();
777  //QRectF page(0, 0, size.width(), size.height());
778  //QMatrix matrix = m_layoutEditor->getMatrix();
779  //QRectF r(m_auxFrameRect.left(), m_auxFrameRect.top(), m_auxFrameRect.width(), m_auxFrameRect.height());
780  //r = matrix.inverted().mapRect(r);
781  //
782  //if(page.contains(r) == false)
783  //{
784  // if(m_selected == 10)
785  // {
786  // if(r.top() < page.top())
787  // r = QRectF(r.left(), page.top(), r.width(), r.height());
788  // if(r.bottom() > page.bottom())
789  // r = QRectF(r.left(), page.bottom() - r.height(), r.width(), r.height());
790  // if(r.left() < page.left())
791  // r = QRectF(page.left(), r.top(), r.width(), r.height());
792  // if(r.right() > page.right())
793  // r = QRectF(page.right() - r.width(), r.top(), r.width(), r.height());
794  // }
795  // else
796  // {
797  // if(r.top() < page.top())
798  // r.setTop(page.top());
799  // if(r.bottom() > page.bottom())
800  // r.setBottom(page.bottom());
801  // if(r.left() < page.left())
802  // r.setLeft(page.left());
803  // if(r.right() > page.right())
804  // r.setRight(page.right());
805  // }
806  // m_auxFrameRect = matrix.mapRect(r).toRect();
807  //}
808 }
809 
811 {
812  // faz tudo em coordenadas do dispositivo
813 
814  QPoint c;
815 
816  if(m_selected == 1)
817  c = m_recSel1.center();
818  else if(m_selected == 2)
819  c = m_recSel2.center();
820  else if(m_selected == 3)
821  c = m_recSel3.center();
822  else if(m_selected == 4)
823  c = m_recSel4.center();
824  else if(m_selected == 5)
825  c = m_recSel5.center();
826  else if(m_selected == 6)
827  c = m_recSel6.center();
828  else if(m_selected == 7)
829  c = m_recSel7.center();
830  else if(m_selected == 8)
831  c = m_recSel8.center();
832  else if(m_selected == 10)
833  c = m_recSel10.center();
834 
835  return c;
836 }
837 
839 {
840  // faz tudo em coordenadas do dispositivo
841 
842  QPixmap* pixmap = m_layoutEditor->getDraftPixmap();
843  QPainter painter(pixmap);
844  painter.translate(m_layoutEditor->getVerticalRulerWidth(), m_layoutEditor->getHorizontalRulerWidth());
845 
846  painter.setBrush(Qt::NoBrush);
847  painter.setPen(Qt::red);
848  if(m_copyAuxFrameRect.isValid())
849  {
850  painter.setCompositionMode(QPainter::CompositionMode_DestinationOut);
851  painter.drawRect(m_copyAuxFrameRect);
852  }
853  painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
854  painter.drawRect(m_auxFrameRect);
855 
856  m_copyAuxFrameRect = m_auxFrameRect;
857 
858  m_layoutEditor->update();
859 }
860 
862 {
863  if(b)
864  {
865  m_mapDisplay->installEventFilter(this);
866  raise();
867  }
868  else
869  m_mapDisplay->removeEventFilter(this);
870 
871  if(m_UTMGridFrame)
872  m_UTMGridFrame->sendEventToChildren(b);
873  if(m_geoGridFrame)
874  m_geoGridFrame->sendEventToChildren(b);
875  if(m_graphicScaleFrame)
876  m_graphicScaleFrame->sendEventToChildren(b);
877 }
878 
879 bool te::qt::widgets::DataFrame::eventFilter(QObject* obj, QEvent* e)
880 {
881  // return true to stop the event; otherwise return false.
882 
883  int type = e->type();
884 
885  if(obj == m_mapDisplay)
886  {
887  if(type == QEvent::DragEnter)
888  {
889  //QDragEnterEvent* dragEnterEvent = (QDragEnterEvent*)e;
890  //m_mapDisplay->dragEnterEvent(dragEnterEvent);
891  return false; // ´passe o evento para o map display
892  }
893  else if(type == QEvent::Drop)
894  {
895  QDropEvent* dropEvent = (QDropEvent*)e;
896  const QMimeData* mime = dropEvent->mimeData();
897  QString s = mime->data("application/x-terralib;value=\"DraggedItems\"").constData();
898  if(s.isEmpty() == false)
899  {
900  removeUTMGrid();
901  removeGeographicGrid();
902  removeGraphicScale(); // and remove others..............................
903 
904  unsigned long v = s.toULongLong();
905  std::vector<te::qt::widgets::AbstractTreeItem*>* draggedItems = reinterpret_cast<std::vector<AbstractTreeItem*>*>(v);
906  te::qt::widgets::AbstractTreeItem* item = draggedItems->operator[](0);
907  te::map::AbstractLayerPtr al = item->getLayer();
908  setData(al);
909  }
910  return true;
911  }
912  else if(type == QEvent::MouseButtonPress)
913  {
914  QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e);
915 
916  if(mouseEvent->buttons() == Qt::LeftButton)
917  {
918  QPoint p = mouseEvent->pos();
919  m_pressPoint = p;
920  m_undo = false;
921  m_copyAuxFrameRect = QRect();
922  m_layoutEditor->raiseDraftLayoutEditor();
923  }
924  else if(mouseEvent->buttons() == Qt::RightButton)
925  {
926  QPoint gp = mouseEvent->globalPos();
927  if(m_selected == 10)
928  {
929  QAction* action = m_menu->exec(gp);
930  if(action == m_createUTMGridAction)
931  createUTMGrid();
932  else if(action == m_removeUTMGridAction)
933  removeUTMGrid();
934  else if(action == m_createGeographicGridAction)
935  createGeographicGrid();
936  else if(action == m_removeGeographicGridAction)
937  removeGeographicGrid();
938  else if(action == m_createGraphicScaleAction)
939  createGraphicScale();
940  else if(action == m_removeGraphicScaleAction)
941  removeGraphicScale();
942  else if(action == m_magneticDeclinationAction)
943  magneticDeclination();
944  }
945  }
946  return false;
947  }
948  else if (type == QEvent::MouseMove)
949  {
950  QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e);
951  QPoint p = mouseEvent->pos();
952  QPoint gp = mouseEvent->globalPos();
953 
954  if(mouseEvent->buttons() == Qt::NoButton)
955  {
956  setCursor();
957 
958  m_dragging = false;
959  getSelectionPoint(p);
960  if(m_selected == 0)
961  return false;
962  else
963  {
964  showSelectionPoints();
965  toolTip(gp, "Selection");
966  if(m_selected == 10 && m_layoutEditor->getFrameSelected() != this)
967  m_layoutEditor->setFrameSelected(this);
968  }
969 
970  setCursor();
971  }
972  else if(mouseEvent->buttons() == Qt::LeftButton)
973  {
974  m_dragging = true;
975  QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e);
976  QPoint p = mouseEvent->pos();
977  QPoint d = m_pressPoint - p;
978  QMatrix matrix = m_layoutEditor->getMatrix();
979  m_auxFrameRect = matrix.mapRect(m_frameRect).toRect();
980 
981  // mouse drag with left buttom
982  if(m_selected != 0)
983  {
984  if(m_undo == false)
985  {
986  m_layoutEditor->insertCopy2Undo(this);
987  m_undo = true;
988  }
989 
990  if(m_selected == 1) // resize top left
991  m_auxFrameRect = QRect(m_auxFrameRect.left() - d.x(), m_auxFrameRect.top() - d.y(), m_auxFrameRect.width() + d.x(), m_auxFrameRect.height() + d.y());
992  else if(m_selected == 2) // resize top
993  m_auxFrameRect = QRect(m_auxFrameRect.left(), m_auxFrameRect.top() - d.y(), m_auxFrameRect.width(), m_auxFrameRect.height() + d.y());
994  else if(m_selected == 3) // resize top right
995  m_auxFrameRect = QRect(m_auxFrameRect.left(), m_auxFrameRect.top() - d.y(), m_auxFrameRect.width() - d.x(), m_auxFrameRect.height() + d.y());
996  else if(m_selected == 4) // resize right
997  m_auxFrameRect = QRect(m_auxFrameRect.left(), m_auxFrameRect.top(), m_auxFrameRect.width() - d.x(), m_auxFrameRect.height());
998  else if(m_selected == 5) // resize bottom right
999  m_auxFrameRect = QRect(m_auxFrameRect.left(), m_auxFrameRect.top(), m_auxFrameRect.width() - d.x(), m_auxFrameRect.height() - d.y());
1000  else if(m_selected == 6) // resize bottom
1001  m_auxFrameRect = QRect(m_auxFrameRect.left(), m_auxFrameRect.top(), m_auxFrameRect.width(), m_auxFrameRect.height() - d.y());
1002  else if(m_selected == 7) // resize bottom left
1003  m_auxFrameRect = QRect(m_auxFrameRect.left() - d.x(), m_auxFrameRect.top(), m_auxFrameRect.width() + d.x(), m_auxFrameRect.height() - d.y());
1004  else if(m_selected == 8) // resize left
1005  m_auxFrameRect = QRect(m_auxFrameRect.left() - d.x(), m_auxFrameRect.top(), m_auxFrameRect.width() + d.x(), m_auxFrameRect.height());
1006  else if(m_selected == 9) // rotate data frame by center
1007  {
1008  }
1009  else // move data frame
1010  m_auxFrameRect.moveCenter(m_auxFrameRect.center() - d);
1011 
1012  rubberBand();
1013  setCursor();
1014  }
1015  }
1016  return false;
1017  }
1018  else if(type == QEvent::MouseButtonRelease)
1019  {
1020  QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e);
1021  if(mouseEvent->button() == Qt::LeftButton)
1022  {
1023  QPoint p = mouseEvent->pos();
1024 
1025  if(m_pressPoint != p && m_selected != 0)
1026  {
1027  if(m_UTMGridFrame || m_geoGridFrame)
1028  {
1029  QPixmap* pix = m_mapDisplay->getDraftPixmap();
1030  pix->fill(Qt::transparent);
1031  }
1032  setCursor();
1033 
1034  QPixmap* pixmap = m_layoutEditor->getDraftPixmap();
1035  pixmap->fill(Qt::transparent);
1036  verifyConstraints();
1037  QMatrix matrix = m_layoutEditor->getMatrix();
1038  QRectF r(m_auxFrameRect.left(), m_auxFrameRect.top(), m_auxFrameRect.width(), m_auxFrameRect.height());
1039  adjustWidgetToFrameRect(matrix.inverted().mapRect(r));
1040  m_layoutEditor->lowerDraftLayoutEditor();
1041 
1042  if(m_UTMGridFrame)
1043  m_UTMGridFrame->adjust();
1044  if(m_geoGridFrame)
1045  m_geoGridFrame->adjust();
1046  if(m_graphicScaleFrame)
1047  m_graphicScaleFrame->adjust();
1048 
1049  m_layoutEditor->draw();
1050 
1051  //if(m_selected != 10)
1052  //{
1053  // QPoint c = getCenterSelected();
1054  // m_mapDisplay->cursor().setPos(m_mapDisplay->mapToGlobal(c));
1055  // QMouseEvent e1(QEvent::MouseButtonPress, c, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
1056  // QApplication::sendEvent(this, &e1);
1057  //}
1058  showSelectionPoints();
1059  }
1060  }
1061  return false;
1062  }
1063  else if(type == QEvent::Enter)
1064  {
1065  if(QApplication::overrideCursor() || m_dragging)
1066  return false;
1067 
1068  m_layoutEditor->setFrameSelected(this);
1069  raise();
1070  m_selected = 10;
1071  return false;
1072  }
1073  else if(type == QEvent::Leave)
1074  {
1075  m_mapDisplay->update();
1076  if(m_dragging)
1077  {
1078  if(m_selected != 0)
1079  {
1080  if(m_UTMGridFrame || m_geoGridFrame)
1081  raise();
1082  }
1083  return false;
1084  }
1085 
1086  m_selected = 0;
1087  m_layoutEditor->setFrameSelected(0);
1088  lower();
1089  setCursor();
1090  return false;
1091  }
1092  return false;
1093  }
1094 
1095  // pass the event on to the parent class
1096  return QWidget::eventFilter(obj, e);
1097 }
1098 
1100 {
1101  QCursor cursor;
1102 
1103  if(m_selected == 1 || m_selected == 5)
1104  cursor.setShape(Qt::SizeFDiagCursor);
1105  else if(m_selected == 2 || m_selected == 6)
1106  cursor.setShape(Qt::SizeVerCursor);
1107  else if(m_selected == 3 || m_selected == 7)
1108  cursor.setShape(Qt::SizeBDiagCursor);
1109  else if(m_selected == 4 || m_selected == 8)
1110  cursor.setShape(Qt::SizeHorCursor);
1111  else if(m_selected == 10)
1112  cursor.setShape(Qt::SizeAllCursor);
1113 
1114  if(QApplication::overrideCursor())
1115  {
1116  if(QApplication::overrideCursor()->shape() != cursor.shape())
1117  {
1118  while(QApplication::overrideCursor())
1119  QApplication::restoreOverrideCursor();
1120  if(cursor.shape() != Qt::ArrowCursor)
1121  QApplication::setOverrideCursor(cursor);
1122  }
1123  }
1124  else if(cursor.shape() != Qt::ArrowCursor)
1125  QApplication::setOverrideCursor(cursor);
1126 }
1127 
1128 void te::qt::widgets::DataFrame::toolTip(const QPoint& p, const QString& type)
1129 {
1130  if(m_showToolTip == false)
1131  {
1132  QToolTip::hideText();
1133  return;
1134  }
1135 
1136  if(type == "Selection")
1137  {
1138  if(m_selected >= 1 && m_selected <= 8)
1139  QToolTip::showText(p, "Drag To Resize", this);
1140  else if(m_selected == 10)
1141  QToolTip::showText(p, "Drag to Move", this);
1142  else
1143  QToolTip::hideText();
1144  }
1145 }
1146 
1148 {
1149  if(m_UTMGridFrame)
1150  delete m_UTMGridFrame;
1151  m_UTMGridFrame = new te::qt::widgets::UTMGridFrame(this);
1152 
1153  m_createUTMGridAction->setEnabled(false);
1154  m_removeUTMGridAction->setEnabled(true);
1155 
1156  draw();
1157 }
1158 
1160 {
1161  if(m_UTMGridFrame)
1162  delete m_UTMGridFrame;
1163  m_UTMGridFrame = 0;
1164 
1165  m_createUTMGridAction->setEnabled(true);
1166  m_removeUTMGridAction->setEnabled(false);
1167 }
1168 
1170 {
1171  if(m_geoGridFrame)
1172  delete m_geoGridFrame;
1173  m_geoGridFrame = new te::qt::widgets::GeographicGridFrame(this);
1174 
1175  m_createGeographicGridAction->setEnabled(false);
1176  m_removeGeographicGridAction->setEnabled(true);
1177 
1178  draw();
1179 }
1180 
1182 {
1183  if(m_geoGridFrame)
1184  delete m_geoGridFrame;
1185  m_geoGridFrame = 0;
1186 
1187  m_createGeographicGridAction->setEnabled(true);
1188  m_removeGeographicGridAction->setEnabled(false);
1189 }
1190 
1192 {
1193  if(m_graphicScaleFrame)
1194  delete m_graphicScaleFrame;
1195 
1196  m_graphicScaleFrame = new te::qt::widgets::GraphicScaleFrame(this);
1197 
1198  m_createGraphicScaleAction->setEnabled(false);
1199  m_removeGraphicScaleAction->setEnabled(true);
1200 
1201  draw();
1202 }
1203 
1205 {
1206  if(m_graphicScaleFrame)
1207  delete m_graphicScaleFrame;
1208  m_graphicScaleFrame = 0;
1209 
1210  m_createGraphicScaleAction->setEnabled(true);
1211  m_removeGraphicScaleAction->setEnabled(false);
1212 }
1213 
1215 {
1216  /*double magDecl = m_mapDisplay->getMagneticDeclination();
1217 
1218  bool ok;
1219  double v = QInputDialog::getDouble(this, tr("Set Magnetic Declination"),
1220  tr("Angle:"), magDecl, -70, +70, 1, &ok);
1221  if(ok)
1222  {
1223  m_mapDisplay->setMagneticDeclination(v);
1224  m_dataChanged = true;
1225  draw();
1226  }*/
1227 }
1228 
1230 {
1231  if(m_UTMGridFrame)
1232  m_UTMGridFrame->hide();
1233  if(m_geoGridFrame)
1234  m_geoGridFrame->hide();
1235  if(m_graphicScaleFrame)
1236  m_graphicScaleFrame->hide();
1237  if(m_mapDisplay)
1238  m_mapDisplay->hide();
1240 }
1241 
1243 {
1244  if(m_UTMGridFrame)
1245  m_UTMGridFrame->show();
1246  if(m_geoGridFrame)
1247  m_geoGridFrame->show();
1248  if(m_graphicScaleFrame)
1249  m_graphicScaleFrame->show();
1250  if(m_mapDisplay)
1251  m_mapDisplay->show();
1253 }
1254 
1256 {
1257  te::qt::widgets::Frame::lower();
1258  if(m_mapDisplay)
1259  m_mapDisplay->lower();
1260 
1261  if(m_UTMGridFrame)
1262  m_UTMGridFrame->lower();
1263  if(m_geoGridFrame)
1264  m_geoGridFrame->lower();
1265 }
1266 
1268 {
1269  return &m_lastDisplayContent;
1270 }
1271 
1273 {
1274  return &m_lastDisplayContent;
1275 }
1276 
1277 void te::qt::widgets::DataFrame::onDrawLayersFinished(const QMap<QString, QString>& /*errors*/)
1278 {
1279  // Stores the clean pixmap!
1280  m_lastDisplayContent = QPixmap(*m_mapDisplay->getDisplayPixmap());
1281 
1282  // TODO!!!
1283  if(m_data)
1284  drawLayerSelection();
1285 }
1286 
1288 {
1289  m_selectionColor = selColor;
1290 }
1291 
1293 {
1294  assert(m_data);
1295 
1296  std::list<te::map::AbstractLayerPtr>::iterator it;
1297  std::list<te::map::AbstractLayerPtr> layers;
1298  te::map::AbstractLayerPtr al(m_data);
1299  getLayerList(al, layers);
1300 
1301  for(it = layers.begin(); it != layers.end(); ++it)
1302  {
1303  te::map::AbstractLayer* layer = (*it).get();
1304  {
1305  if(layer->getVisibility() != te::map::VISIBLE)
1306  continue;
1307 
1308  const te::da::ObjectIdSet* oids = layer->getSelected();
1309  if(oids == 0 || oids->size() == 0)
1310  {
1311  m_mapDisplay->repaint();
1312  return;
1313  }
1314 
1315  bool needRemap = false;
1316 
1317  if((layer->getSRID() != TE_UNKNOWN_SRS) && (m_mapDisplay->getSRID() != TE_UNKNOWN_SRS) && (layer->getSRID() != m_mapDisplay->getSRID()))
1318  needRemap = true;
1319 
1320  // Try retrieves the layer selection
1321  std::auto_ptr<te::da::DataSet> selected;
1322  try
1323  {
1324  selected = layer->getData(oids);
1325  }
1326  catch(std::exception& e)
1327  {
1328  QMessageBox::critical(m_mapDisplay, tr("Error"), QString(tr("The layer selection cannot be drawn. Details:") + " %1.").arg(e.what()));
1329  return;
1330  }
1331 
1332  std::size_t gpos = te::da::GetFirstPropertyPos(selected.get(), te::dt::GEOMETRY_TYPE);
1333 
1334  QPixmap* content = m_mapDisplay->getDisplayPixmap();
1335 
1336  const te::gm::Envelope& displayExtent = m_mapDisplay->getExtent();
1337 
1338  te::qt::widgets::Canvas canvas(content);
1339  canvas.setWindow(displayExtent.m_llx, displayExtent.m_lly, displayExtent.m_urx, displayExtent.m_ury);
1340 
1342 
1343  while(selected->moveNext())
1344  {
1345  std::auto_ptr<te::gm::Geometry> g(selected->getGeometry(gpos));
1346 
1347  if(needRemap)
1348  {
1349  g->setSRID(layer->getSRID());
1350  g->transform(m_mapDisplay->getSRID());
1351  }
1352 
1353  if(currentGeomType != g->getGeomTypeId())
1354  {
1355  currentGeomType = g->getGeomTypeId();
1356  te::qt::widgets::Config2DrawLayerSelection(&canvas, m_selectionColor, currentGeomType);
1357  }
1358 
1359  canvas.draw(g.get());
1360  }
1361  }
1362  }
1363  m_mapDisplay->repaint();
1364 }
1365 
1367 {
1368  return m_geoGridFrame;
1369 }
1370 
1372 {
1373  return m_UTMGridFrame;
1374 }
1375 
1377 {
1378  return m_graphicScaleFrame;
1379 }
1380 
1382 {
1383  //m_mapDisplay->setMagneticDeclination(angle);
1384 }
1385 
1387 {
1388  return 0.0;
1389  //return m_mapDisplay->getMagneticDeclination();
1390 }
A UTMGridFrame ....
Definition: UTMGridFrame.h:50
virtual te::map::AbstractLayerPtr getLayer() const =0
QAction * m_removeGraphicScaleAction
Definition: DataFrame.h:153
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
te::qt::widgets::GraphicScaleFrame * getGraphicScaleFrame()
Definition: DataFrame.cpp:1376
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
void toolTip(const QPoint &, const QString &)
Definition: DataFrame.cpp:1128
void getSelectionPoint(const QPoint &p)
Definition: DataFrame.cpp:747
QPixmap * getLastDisplayContent()
Definition: DataFrame.cpp:1267
double getWidth() const
It returns the envelope width.
Definition: Envelope.h:443
This file contains include headers for the Vector Geometry model of TerraLib.
virtual te::map::AlignType getVAlign() const
It returns the MapDisplay current vertical align.
Definition: MapDisplay.cpp:52
This abstract class describes a basic item to be organized in a tree-oriented way.
Definition: TreeItem.h:62
This is the base class for layers.
Definition: AbstractLayer.h:76
virtual const te::da::ObjectIdSet * getSelected() const
It returns the selected group of this Layer.
void setDataFrame(te::qt::widgets::DataFrame *df)
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
Definition: Envelope.h:400
virtual void setBackgroundColor(const QColor &color)
Sets the map display background color.
Definition: MapDisplay.cpp:325
void setSelectionColor(QColor selColor)
Definition: DataFrame.cpp:1287
void onDrawLayersFinished(const QMap< QString, QString > &errors)
Definition: DataFrame.cpp:1277
void setMagneticDeclination(double angle)
Definition: DataFrame.cpp:1381
void getLayerList(te::map::AbstractLayerPtr, std::list< te::map::AbstractLayerPtr > &)
Definition: DataFrame.cpp:386
te::map::AbstractLayer * m_data
Definition: DataFrame.h:138
DataFrame(const QRectF &frameRect, te::qt::widgets::LayoutEditor *me, Qt::WindowFlags f=Qt::Window)
Definition: DataFrame.cpp:62
void setDataRect(QRectF &r)
Definition: DataFrame.cpp:269
te::map::AbstractLayer * getData()
Definition: DataFrame.cpp:381
te::qt::widgets::UTMGridFrame * m_UTMGridFrame
Definition: DataFrame.h:132
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:72
virtual const char * what() const
It outputs the exception message.
Definition: Exception.cpp:58
void setDataFrame(te::qt::widgets::DataFrame *df)
Definition: GridFrame.cpp:154
double getHeight() const
It returns the envelope height.
Definition: Envelope.h:448
virtual te::map::AlignType getHAlign() const
It returns the MapDisplay current horizontal align.
Definition: MapDisplay.cpp:47
te::qt::widgets::MultiThreadMapDisplay * m_mapDisplay
Definition: DataFrame.h:127
This file contains the support to convert coordinates from a SRS to another.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
Definition: Envelope.h:390
void draw(const te::gm::Geometry *geom)
It draws the geometry on canvas.
Definition: Canvas.cpp:296
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
Definition: MapDisplay.cpp:73
A canvas built on top of Qt.
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
bool transformEnvelope(te::gm::Envelope &e, int oldsrid, int newsrid)
Definition: DataFrame.cpp:462
std::size_t size() const
It returns the object id set size.
Utility functions for the data access module.
QAction * m_createGraphicScaleAction
Definition: DataFrame.h:152
te::qt::widgets::UTMGridFrame * getUTMGridFrame()
Definition: DataFrame.cpp:1371
void adjustWidgetToFrameRect(const QRectF &r)
Definition: DataFrame.cpp:297
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
A DataFrame ....
Definition: DataFrame.h:59
void init(const double &llx, const double &lly, const double &urx, const double &ury)
It initializes (sets) the envelope bounds.
Definition: Envelope.h:381
A canvas built on top of Qt.
Definition: Canvas.h:54
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Definition: Utils.cpp:428
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
virtual void setResizeInterval(int msec)
Sets the timeout interval in milliseconds to redraw on resize event.
Definition: MapDisplay.cpp:229
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
void findDataUnitToMilimeter(const te::gm::Envelope &e, int srid)
Definition: DataFrame.cpp:566
The class that represents an item in a LayerTreeModel.
A multi thread Qt4 widget to control the display of a set of layers.
QAction * m_removeGeographicGridAction
Definition: DataFrame.h:151
virtual void setSRID(const int &srid, bool doRefresh=true)
It sets a new Spatial Reference System to be used by the Map Display.
Definition: MapDisplay.cpp:78
QAction * m_removeUTMGridAction
Definition: DataFrame.h:149
Frame & operator=(const Frame &rhs)
Definition: Frame.cpp:70
boost::intrusive_ptr< TreeItem > TreeItemPtr
Definition: TreeItem.h:44
A multi thread Qt4 widget to control the display of a set of layers.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
Definition: Converter.h:53
DataFrame & operator=(const DataFrame &rhs)
Definition: DataFrame.cpp:177
void setExtent(te::gm::Envelope &e, bool doRefresh=true)
It sets the world visible area and refreshes the contents in the map display.
double m_llx
Lower left corner x-coordinate.
Definition: Envelope.h:344
std::list< te::map::AbstractLayerPtr > m_visibleLayers
Definition: DataFrame.h:139
TEQTWIDGETSEXPORT void Config2DrawLayerSelection(te::map::Canvas *canvas, const QColor &selectionColor, const te::gm::GeomType &type)
It configs (i.e. prepares) the given canvas to draw a layer selection.
Definition: Utils.cpp:264
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
virtual Visibility getVisibility() const
It returns the layer visibility.
te::qt::widgets::GraphicScaleFrame * m_graphicScaleFrame
Definition: DataFrame.h:133
std::list< TreeItemPtr >::iterator iterator
Definition: TreeItem.h:66
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
Definition: MapDisplay.cpp:63
QAction * m_createGeographicGridAction
Definition: DataFrame.h:150
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
Definition: Canvas.cpp:147
QAction * m_magneticDeclinationAction
Definition: DataFrame.h:154
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
virtual void setAlign(te::map::AlignType h, te::map::AlignType v)
It will set the align rendering of objects into the map display. Just successive drawings will be aff...
Definition: MapDisplay.cpp:57
te::qt::widgets::GeographicGridFrame * m_geoGridFrame
Definition: DataFrame.h:131
te::qt::widgets::GeographicGridFrame * getGeoGridFrame()
Definition: DataFrame.cpp:1366
bool eventFilter(QObject *, QEvent *)
Definition: DataFrame.cpp:879
virtual std::auto_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const =0
It gets the dataset identified by the layer name.
QAction * m_createUTMGridAction
Definition: DataFrame.h:148
void setData(te::map::AbstractLayerPtr d, int nsrid=TE_UNKNOWN_SRS, QRectF r=QRectF())
Definition: DataFrame.cpp:415
te::qt::widgets::MultiThreadMapDisplay * getMapDisplay()
Definition: DataFrame.cpp:264
The class that represents an item in a LayerTreeModel.