All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TimeSliderWidgetAction.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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/plugins/layout/TimeSliderWidgetAction.cpp
22 
23  \brief This file defines the TimeSliderWidgetAction class
24 */
25 
26 // Terralib
27 #include "../../../qt/widgets/st/TimeSliderWidget.h"
28 #include "../../../qt/widgets/canvas/MapDisplay.h"
29 #include "../../af/ApplicationController.h"
30 #include "../../af/BaseApplication.h"
31 #include "../../af/connectors/MapDisplay.h"
32 #include "../../af/Project.h"
33 #include "TimeSliderWidgetAction.h"
34 
36  : te::qt::plugins::slider::AbstractAction(menu),
37  m_timeSliderWidget(0)
38 {
39  createAction(tr("Time Slider...").toStdString());
40 }
41 
43 {
44  if(m_timeSliderWidget)
45  {
46  te::qt::af::ApplicationController::getInstance().removeListener(m_timeSliderWidget);
47  delete m_timeSliderWidget;
48  }
49 }
50 
52 {
53  if(m_timeSliderWidget == 0)
54  {
55  QWidget* parent = te::qt::af::ApplicationController::getInstance().getMainWindow();
58  if(display->getExtent().isValid() == false)
59  {
60  // WGS84
61  te::gm::Envelope e(-180, -180, 360, 360);
62  display->setExtent(e);
63  display->setSRID(4326);
64  }
65  te::qt::widgets::TimeSliderWidget* ts = new te::qt::widgets::TimeSliderWidget(display, parent, Qt::Window);
66  ts->show();
67  ts->move(200, 200);
68  connect(ts, SIGNAL(deleteTimeSliderWidget()), this, SLOT(onDeleteTimeSliderWidget()));
69  connect(ba, SIGNAL(applicationClose()), this, SLOT(onDeleteTimeSliderWidget()));
70  m_timeSliderWidget = new te::qt::af::TimeSliderWidget(ts);
71  }
72  else
73  {
74  if(m_timeSliderWidget->getTimeSliderWidget()->isMinimized())
75  m_timeSliderWidget->getTimeSliderWidget()->showNormal();
76  else
77  m_timeSliderWidget->getTimeSliderWidget()->show();
78  }
79 }
80 
82 {
83  if(m_timeSliderWidget)
84  delete m_timeSliderWidget;
85  m_timeSliderWidget = 0;
86 }
te::qt::widgets::MapDisplay * getDisplay()
Definition: MapDisplay.cpp:116
A widget to control the display of a set of layers.
Definition: MapDisplay.h:65
A QMainWindow to be used as the basis for TerraLib applications.
void createAction(std::string name, std::string pixmap="")
Create and set the actions parameters.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
This is an abstract class used to register actions into slider pluging.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
Definition: MapDisplay.cpp:63
A connector for the te::qt::widgets::TimeSliderWidget class to the Application Framework.
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:215
virtual void setExtent(te::gm::Envelope &e, bool doRefresh=true)
It sets the world visible area and refreshes the contents in the map display.
Definition: MapDisplay.cpp:154
bool isValid() const
It tells if the rectangle is valid or not.
Definition: Envelope.h:438
A wdiget used to control the visualization of temporal data.