CompositionModeMenuWidget.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/widgets/layer/utils/CompositionModeMenuWidget.cpp
22 
23  \brief This file defines a class for a CompositionModeMenuWidget.
24 */
25 
26 // TerraLib
27 #include "../../../../maptools/Enums.h"
28 #include "CompositionModeDialog.h"
30 
31 // Qt
32 #include <QActionGroup>
33 
35 {
36  //create menu
37  m_menu = new QMenu(tr("Composition Mode"), this);
38 
39  //create actions
40  m_sourceOverAction = new QAction(tr("Default"), this);
41  m_sourceOverAction->setCheckable(true);
42  m_plusAction = new QAction(tr("Plus"), this);
43  m_plusAction->setCheckable(true);
44  m_compositionModeAction = new QAction(tr("Advanced..."), this);
45  m_compositionModeAction->setCheckable(true);
46 
47  //add actions to menu
48  m_menu->addAction(m_sourceOverAction);
49  m_menu->addAction(m_plusAction);
50  m_menu->addAction(m_compositionModeAction);
51 
52  //create action group
53  QActionGroup* actGroup = new QActionGroup(this);
54  actGroup->addAction(m_sourceOverAction);
55  actGroup->addAction(m_plusAction);
56  actGroup->addAction(m_compositionModeAction);
57 
58  //connections
59  connect(m_sourceOverAction, SIGNAL(triggered()), this, SLOT(onSourceOverClicked()));
60  connect(m_plusAction, SIGNAL(triggered()), this, SLOT(onPlusClicked()));
61  connect(m_compositionModeAction, SIGNAL(triggered()), this, SLOT(onCompositionModeClicked()));
62 }
63 
65  default;
66 
68 {
69  m_layer = layer;
70 
71  if(m_layer->getCompositionMode() == te::map::SourceOver)
72  {
73  m_sourceOverAction->setChecked(true);
74  }
75  else if(m_layer->getCompositionMode() == te::map::Plus)
76  {
77  m_plusAction->setChecked(true);
78  }
79  else
80  {
81  m_compositionModeAction->setChecked(true);
82  }
83 }
84 
86 {
87  return m_menu;
88 }
89 
91 {
92  assert(m_layer.get());
93 
94  m_layer->setCompositionMode(te::map::SourceOver);
95 }
96 
98 {
99  assert(m_layer.get());
100 
101  m_layer->setCompositionMode(te::map::Plus);
102 }
103 
105 {
106  assert(m_layer.get());
107 
109 
110  dlg.setLayer(m_layer);
111 
112  dlg.exec();
113 }
void setLayer(te::map::AbstractLayerPtr layer)
Set the layer that can be used.
CompositionModeMenuWidget(QWidget *parent=0, Qt::WindowFlags f=0)
This file defines a class for a CompositionModeMenuWidget.
This file defines a class for a CompositionModeDialog.
te::map::AbstractLayerPtr m_layer
Selected Layer.
This class is a dialog used to select the composition mode for a layer.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr