af/connectors/StyleExplorer.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 // TerraLib
21 #include "../../../maptools/AbstractLayer.h"
22 #include "../../../maptools/DataSetLayer.h"
23 #include "../../../maptools/RasterLayer.h"
24 #include "../../../qt/widgets/layer/explorer/LayerItemView.h"
25 #include "../../../qt/widgets/se/StyleDockWidget.h"
26 #include "../events/ApplicationEvents.h"
27 #include "../events/LayerEvents.h"
28 #include "../ApplicationController.h"
29 #include "StyleExplorer.h"
30 
31 // STL
32 #include <cassert>
33 
35  : QObject(parent),
36  m_app(app),
37  m_explorer(explorer),
38  m_internalEvent(false)
39 {
40  assert(explorer);
41 
42  connect(m_explorer, SIGNAL(symbolChanged(te::map::AbstractLayer*)), SLOT(styleChanged(te::map::AbstractLayer*)));
43 }
44 
46 
48 {
49  return m_explorer;
50 }
51 
53 {
54  switch(evt->m_id)
55  {
57  {
59 
61  assert(layer);
62 
63  if (layer->isValid() && layer->getStyle())
64  m_explorer->setLayer(layer.get(), m_app->getSelectionColor().name().toStdString(), nullptr); // default name: #RRGGBB HexRgb
65  }
66  break;
67 
69  {
70  if (!m_internalEvent)
71  {
73 
75  assert(layer);
76 
77  if (layer->isValid() && layer->getStyle())
78  m_explorer->setLayer(layer.get(), m_app->getSelectionColor().name().toStdString(), nullptr); // default name: #RRGGBB HexRgb
79  }
80  }
81  break;
82 
84  {
86 
88  assert(layer);
89 
90  QColor color = m_app->getSelectionColor();
91  // name: #AARRGGBB HexArgb
92  QString hexColor;
93  hexColor.sprintf("#%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue());
94 
95  m_explorer->setLayer(layer.get(), hexColor.toStdString(), e->m_rule);
96 
97  m_explorer->setVisible(true);
98  }
99  break;
100 
102  {
104 
105  for (std::list<te::map::AbstractLayerPtr>::iterator it = ev->m_layers.begin(); it != ev->m_layers.end(); ++it)
106  {
107  te::map::AbstractLayerPtr layer = *it;
108 
109  if (m_explorer->getLayer() && layer->getId() == m_explorer->getLayer()->getId())
110  m_explorer->clear();
111  }
112  }
113  break;
114 
115  default:
116  return;
117  }
118 }
119 
121 {
123  emit triggered(&e);
124 
126 
127  m_internalEvent = true;
128 
130  emit triggered(&e2);
131 
132  m_internalEvent = false;
133 }
virtual const std::string & getId() const
It returns the layer id.
bool m_internalEvent
Flag used for internal sent events.
This is the base class for layers.
Definition: AbstractLayer.h:77
A base class for application events.
void updateLegend(te::map::AbstractLayer *l)
updateLegend
te::qt::widgets::LayerItemView * m_layerExplorer
StyleExplorer(te::qt::widgets::StyleDockWidget *explorer, te::qt::af::ApplicationController *app, QObject *parent=0)
Constructor.
The base API for TerraLib applications.
te::map::AbstractLayerPtr m_layer
Pointer to the selected layer.
Definition: LayerEvents.h:196
A connector for the te::qt::widgets::StyleDockWidget class to the Application Framework.
te::qt::widgets::StyleDockWidget * getExplorer() const
This event indicates that the layer style was selected on the layer explorer.
Definition: LayerEvents.h:254
void triggered(te::qt::af::evt::Event *e)
This event indicates that the layer has been selected.
Definition: LayerEvents.h:183
void styleChanged(te::map::AbstractLayer *l)
QColor getSelectionColor() const
Returns the application selection color.
void setLayer(te::map::AbstractLayer *layer, std::string selColor, te::se::Rule *currentRule)
Sets a style element to this widget.
~StyleExplorer()
Destructor.
te::qt::widgets::StyleDockWidget * m_explorer
Pointer to a component te::qt::widgets::StyleDockWidget.
void onApplicationTriggered(te::qt::af::evt::Event *evt)
Listener to the application framewrork events.
te::se::Rule * m_rule
Rule whose style was selected.
Definition: LayerEvents.h:269
A dock widget used control the geographic data style using SE elements and a property browser to show...
te::map::AbstractLayer * m_layer
Layer selected.
Definition: LayerEvents.h:367
te::qt::af::ApplicationController * m_app
Pointer to applicatin controller;.
te::map::AbstractLayer * getLayer()
std::list< te::map::AbstractLayerPtr > m_layers
Layer removed.
Definition: LayerEvents.h:154
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
te::map::AbstractLayerPtr m_layer
Layer whose style was selected.
Definition: LayerEvents.h:268