ObservationAction.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/plugins/st/ObservationAction.cpp
22 
23  \brief This file defines the Observation Action class
24 */
25 
26 //Terralib
27 #include "../../../qt/af/events/LayerEvents.h"
28 #include "../../../qt/widgets/dataset/selector/DataSetSelectorWizardPage.h"
29 #include "../../../qt/widgets/datasource/selector/DataSourceSelectorWizardPage.h"
30 //#include "../../../qt/widgets/layer/explorer/AbstractTreeItemFactory.h"
31 #include "../../../qt/widgets/st/ObservationWizard.h"
32 #include "../../../st/loader/STDataLoader.h"
33 #include "../../af/ApplicationController.h"
34 #include "ObservationAction.h"
35 
36 // Qt
37 #include <QMessageBox>
38 
39 //STL
40 #include <memory>
41 
42 // Boost
43 #include <boost/functional/factory.hpp>
44 #include <boost/bind.hpp>
45 
47 : te::qt::plugins::st::AbstractAction(menu)
48 {
49  createAction(tr("Observation...").toUtf8().data(), "observation-layer");
50  //te::qt::widgets::AbstractTreeItemFactory::reg("OBSERVATIONDATASETLAYER", boost::bind(boost::factory<ObservationLayerItem*>(),_1, _2));
51 }
52 
54 
56 {
57  QWidget* parent = te::qt::af::AppCtrlSingleton::getInstance().getMainWindow();
58 
59  std::auto_ptr<te::qt::widgets::ObservationWizard> obsWiz;
60  obsWiz.reset( new te::qt::widgets::ObservationWizard(parent));
61 
62  int res = obsWiz->exec();
63  if (res == QDialog::Accepted)
64  {
65  //Initialize STDataLoader support
67 
68  std::list<te::st::ObservationDataSetLayerPtr> layers = obsWiz->getObservationLayers();
69  std::list<te::st::ObservationDataSetLayerPtr>::const_iterator layerItB = layers.begin();
70  std::list<te::st::ObservationDataSetLayerPtr>::const_iterator layerItE = layers.end();
71 
72  while(layerItB != layerItE)
73  {
74  te::qt::af::evt::LayerAdded evt(*layerItB, 0);
75  emit triggered(&evt);
76 
77  layerItB++;
78  }
79  }
80 }
This event signals that a new layer was created.
Definition: LayerEvents.h:71
virtual void onActionActivated(bool checked)
This is an abstract class used to register actions into st pluging.
void triggered(te::qt::af::evt::Event *e)
static void initialize()
It returns the spatial extent of the observations of a coverage series.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
URI C++ Library.
Definition: Attributes.h:37
void createAction(std::string name, std::string pixmap="")
Create and set the actions parameters.