All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
InterfaceController.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 TerraView - A GIS Application.
4 
5  TerraView is free software: you can redistribute it and/or modify
6  it under the terms of the GNU 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  TerraView 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 General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with TerraLib Code Editor. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@dpi.inpe.br>.
18  */
19 
20 /*!
21  \file terralib/qt/af/connectors/InterfaceController.cpp
22 
23  \brief A connector to controll all non modal interfaces.
24 */
25 
26 // TerraLib
27 #include "../../widgets/InterfaceController.h"
28 #include "../events/Event.h"
29 #include "../events/LayerEvents.h"
30 #include "../ApplicationController.h"
31 #include "InterfaceController.h"
32 
34  : QObject(parent)
35 {
36 }
37 
39 {
40  m_interfaces.clear();
41 }
42 
44 {
45  std::set<te::qt::widgets::InterfaceController*>::iterator it = m_interfaces.find(i);
46 
47  if(it == m_interfaces.end())
48  m_interfaces.insert(i);
49 }
50 
52 {
53  std::set<te::qt::widgets::InterfaceController*>::iterator it = m_interfaces.find(i);
54 
55  if(it != m_interfaces.end())
56  m_interfaces.erase(it);
57 }
58 
60 {
61  switch(evt->m_id)
62  {
64  {
66 
67  layerSelected( ev->m_layer);
68  }
69  break;
70 
72  {
74 
75  layerAdded( ev->m_layer);
76  }
77  break;
78 
80  {
82 
83  layerRemoved( ev->m_layer);
84  }
85  break;
86 
87  default:
88  return;
89  }
90 }
91 
93 {
94  assert(layer);
95 
96  std::set<te::qt::widgets::InterfaceController*>::iterator it = m_interfaces.begin();
97 
98  while(it != m_interfaces.end())
99  {
100  (*it)->layerSelected(layer);
101  ++it;
102  }
103 }
104 
106 {
107  assert(layer);
108 
109  std::set<te::qt::widgets::InterfaceController*>::iterator it = m_interfaces.begin();
110 
111  while(it != m_interfaces.end())
112  {
113  (*it)->layerAdded(layer);
114  ++it;
115  }
116 }
117 
119 {
120  assert(layer);
121 
122  std::set<te::qt::widgets::InterfaceController*>::iterator it = m_interfaces.begin();
123 
124  while(it != m_interfaces.end())
125  {
126  (*it)->layerRemoved(layer);
127  ++it;
128  }
129 }
void layerRemoved(te::map::AbstractLayerPtr layer)
This method is used to remove a layer.
This event signals that a new layer was created.
Definition: LayerEvents.h:66
void layerSelected(te::map::AbstractLayerPtr layer)
This method is used to set current layer.
A base class for application events.
Definition: Event.h:59
void addInterface(te::qt::widgets::InterfaceController *i)
te::map::AbstractLayerPtr m_layer
Pointer to the selected layer.
Definition: LayerEvents.h:170
A virtual class for non modal interfaces.
void layerAdded(te::map::AbstractLayerPtr layer)
This method is used to add a new layer.
This event indicates that the layer has been selected.
Definition: LayerEvents.h:157
int m_id
Identifier.
Definition: Event.h:70
void removeInteface(te::qt::widgets::InterfaceController *i)
te::map::AbstractLayerPtr m_layer
Layer removed.
Definition: LayerEvents.h:124
This event signals that a layer is to be removed from the layer explorer.
Definition: LayerEvents.h:111
te::map::AbstractLayerPtr m_layer
Tha layer to be added.
Definition: LayerEvents.h:81
void onApplicationTriggered(te::qt::af::evt::Event *evt)
Listener to the application framewrork events.
InterfaceController(QObject *parent=0)
Constructor.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
A connector to controll all non modal interfaces.