All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
34 te::qt::widgets::CompositionModeMenuWidget::CompositionModeMenuWidget(QWidget* parent, Qt::WindowFlags f):QWidget(parent, f)
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 {
66 }
67 
69 {
70  m_layer = layer;
71 
72  if(m_layer->getCompositionMode() == te::map::SourceOver)
73  {
74  m_sourceOverAction->setChecked(true);
75  }
76  else if(m_layer->getCompositionMode() == te::map::Plus)
77  {
78  m_plusAction->setChecked(true);
79  }
80  else
81  {
82  m_compositionModeAction->setChecked(true);
83  }
84 }
85 
87 {
88  return m_menu;
89 }
90 
92 {
93  assert(m_layer.get());
94 
95  m_layer->setCompositionMode(te::map::SourceOver);
96 }
97 
99 {
100  assert(m_layer.get());
101 
102  m_layer->setCompositionMode(te::map::Plus);
103 }
104 
106 {
107  assert(m_layer.get());
108 
110 
111  dlg.setLayer(m_layer);
112 
113  dlg.exec();
114 }
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.
This class is a dialog used to select the composition mode for a layer.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr