ShowValuesAction.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/mnt/SowValuesAction.cpp
22 
23 \brief This file defines the Show MNT Values Proccess
24 */
25 
26 // Terralib
27 #include "../../af/ApplicationController.h"
28 #include "../../af/BaseApplication.h"
29 #include "../../af/events/MapEvents.h"
30 #include "../../af/events/ApplicationEvents.h"
31 #include "../../widgets/canvas/MapDisplay.h"
32 #include "../../widgets/Utils.h"
33 
34 #include "ShowValuesAction.h"
35 
36 // STL
37 #include <memory>
38 
39 #include <QMessageBox>
40 
41 
43  : te::qt::plugins::mnt::AbstractAction(menu)
44 {
45  createAction(tr("Show Values").toUtf8().data(), "mnt-processing-show values");
46  m_action->setObjectName("Processing.DTM Processing.SHOW VALUES");
47  m_status = false;
48  m_readpixel = nullptr;
49 }
50 
52 {
53  if (m_readpixel)
54  delete m_readpixel;
55 }
56 
58 {
59  if (!status)
60  {
61  QFont f = m_action->font();
62  f.setBold(false);
63  m_action->setFont(f);
64  return;
65  }
66  QFont f = m_action->font();
67  f.setBold(true);
68  m_action->setFont(f);
69 
70 }
71 
73 {
74  m_status = !m_status;
76  std::list<te::map::AbstractLayerPtr> layers = te::qt::widgets::GetSelectedLayersOnly(m_app->getLayerExplorer());
77  if (!layers.size())
78  {
79  QMessageBox::information(nullptr, tr("Show Values"), tr("Select a layer!"));
80  m_status = false;
81  }
82 
83  if (!m_status)
84  {
85  m_action->setChecked(false);
86  QFont f = m_action->font();
87  f.setBold(false);
88  m_action->setFont(f);
89  if (m_readpixel)
90  {
91  m_app->getMapDisplay()->removeEventFilter(m_readpixel);
92  delete m_readpixel;
93  m_readpixel = nullptr;
94  }
95  return;
96  }
97  m_action->setChecked(true);
98  QFont f = m_action->font();
99  f.setBold(true);
100  m_action->setFont(f);
101 
102  try
103  {
106  m_app->getMapDisplay()->installEventFilter(m_readpixel);
107  }
108  catch (const std::exception& e)
109  {
110  QMessageBox::information(nullptr, tr("Show Values"), e.what());
111  return;
112  }
113 
114 }
115 
This is an abstract class used to register actions into mnt pluging.
te::qt::af::BaseApplication * m_app
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.
This file defines the Show MNT Values Proccess.
URI C++ Library.
Definition: Attributes.h:37
te::qt::widgets::LayerItemView * getLayerExplorer()
virtual void onActionActivated(bool checked)
QAction * m_action
Action used to call the process.
TEQTWIDGETSEXPORT std::list< te::map::AbstractLayerPtr > GetSelectedLayersOnly(te::qt::widgets::LayerItemView *view, const bool getFolder=false)
te::qt::widgets::MapDisplay * getMapDisplay()