All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EyeBirdMapDisplayWidget.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 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/EyeBirdMapDisplayWidget.cpp
22 
23  \brief This file has the EyeBirdMapDisplayWidget class.
24 */
25 
26 // TerraLib
27 #include "../../../geometry/Envelope.h"
28 #include "../../../maptools/Utils.h"
29 #include "../canvas/MultiThreadMapDisplay.h"
30 #include "../tools/PanExtent.h"
32 
33 // Qt
34 #include <QGridLayout>
35 
36 
37 #define PATTERN_SIZE 14
38 
40  : QWidget(parent, f), m_parentMapDisplay(mapParent), m_itsMe(false), m_isEnabled(true)
41 {
42 //build form
43  QGridLayout* displayLayout = new QGridLayout(this);
44 
45  m_mapDisplay = new te::qt::widgets::MultiThreadMapDisplay(parent->size(), this);
47 
48  displayLayout->addWidget(m_mapDisplay);
49  displayLayout->setContentsMargins(0,0,0,0);
50 
51  m_panExtent = new te::qt::widgets::PanExtent(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
52 
53  connect(m_panExtent, SIGNAL(extentMoved(te::gm::Envelope)), this, SLOT(onExtentMoved(te::gm::Envelope)));
54  connect(m_parentMapDisplay, SIGNAL(extentChanged()), this, SLOT(onParentMapDisplayExtentChanged()));
55 
56  m_mapDisplay->installEventFilter(m_panExtent);
57 }
58 
60 {
61  delete m_panExtent;
62 }
63 
64 void te::qt::widgets::EyeBirdMapDisplayWidget::setList(std::list<te::map::AbstractLayerPtr>& layerList, int srid)
65 {
66  te::gm::Envelope inputExt = te::map::GetExtent(layerList, srid, true);
67 
68  m_inputExt = inputExt;
69 
70  m_mapDisplay->setMouseTracking(true);
71  m_mapDisplay->setLayerList(layerList);
72  m_mapDisplay->setSRID(srid, false);
73 
74  //m_itsMe = true;
75  m_mapDisplay->setExtent(m_inputExt, false);
76  //m_itsMe = false;
77 }
78 
80 {
81  if(!m_isEnabled)
82  return;
83 
84  m_itsMe = true;
85  m_mapDisplay->setExtent(e, true);
86  m_itsMe = false;
87 
88  m_panExtent->setCurrentExtent(e);
89 }
90 
92 {
93  m_isEnabled = status;
94 
95  recompose(m_inputExt);
96 }
97 
99 {
100  if(!m_isEnabled)
101  return;
102 
103  if(m_itsMe)
104  return;
105 
106  m_itsMe = true;
107  m_parentMapDisplay->setExtent(e);
108  m_itsMe = false;
109 }
110 
112 {
113  if(!m_isEnabled)
114  return;
115 
116  if(!m_itsMe)
117  {
118  te::gm::Envelope e = m_parentMapDisplay->getExtent();
119 
120  if(e.isValid())
121  m_panExtent->setCurrentExtent(e);
122  }
123 }
TEMAPEXPORT te::gm::Envelope GetExtent(const std::list< te::map::AbstractLayerPtr > &layers, int srid, bool onlyVisibles)
It calculates the extent of the given layers in the given SRID.
Definition: Utils.cpp:254
A widget to control the display of a set of layers.
Definition: MapDisplay.h:66
te::qt::widgets::MapDisplay * m_parentMapDisplay
virtual void setResizePolicy(const ResizePolicy &policy)
Sets the resize policy to this map display.
Definition: MapDisplay.cpp:227
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
This file has the EyeBirdMapDisplayWidget class.
This class implements a concrete tool to pan a user defined extent.
Definition: PanExtent.h:52
EyeBirdMapDisplayWidget(te::qt::widgets::MapDisplay *mapParent, QWidget *parent=0, Qt::WindowFlags f=0)
void setList(std::list< te::map::AbstractLayerPtr > &layerList, int srid)
This method is used to set the selected layer for mixture model operation.
bool isValid() const
It tells if the rectangle is valid or not.
Definition: Envelope.h:438
A multi thread Qt4 widget to control the display of a set of layers.