HaloPropertyItem.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/se/HaloPropertyItem.cpp
22 
23  \brief A widget used to define the halo se object.
24 */
25 
26 
27 #include "../../../common/StringUtils.h"
28 #include "../../../se/SvgParameter.h"
29 #include "../../../se/Fill.h"
30 #include "../../../se/Halo.h"
31 #include "../../../se/Utils.h"
32 #include "../propertybrowser/AbstractPropertyManager.h"
33 #include "BasicFillPropertyItem.h"
34 #include "HaloPropertyItem.h"
35 
36 // STL
37 #include <cassert>
38 
39 // QtPropertyBrowser
40 
41 
42 te::qt::widgets::HaloPropertyItem::HaloPropertyItem(QtTreePropertyBrowser* pb, QColor c) : te::qt::widgets::AbstractPropertyItem(pb, c),
43  m_halo(new te::se::Halo)
44 {
45  //build property browser basic fill
46  QtProperty* haloProperty = te::qt::widgets::AbstractPropertyManager::getInstance().m_groupManager->addProperty(tr("Halo Properties"));
47 
48  //label
49  QStringList emptyList;
50  m_radiusProperty = te::qt::widgets::AbstractPropertyManager::getInstance().m_intManager->addProperty(tr("Radius"));
54  haloProperty->addSubProperty(m_radiusProperty);
55 
56  addProperty(haloProperty, tr("Halo Properties"), QColor(152, 252, 36));
57 
59 
60  connect(m_bf, SIGNAL(fillChanged()), SLOT(onFillChanged()));
61 
62  // Setups initial fill
64 
65  m_update = true;
66 }
67 
69 {
70  delete m_halo;
71 }
72 
74 {
75  if (!m_update)
76  return;
77 
78  if (p == m_radiusProperty)
79  {
80  m_update = false;
81 
82  m_halo->setRadius(new te::se::ParameterValue(QString::number(value).toUtf8().data()));
83 
84  emit haloChanged();
85  m_update = true;
86  }
87 }
88 
90 {
92 
93  emit haloChanged();
94 }
95 
97 {
98  assert(halo);
99 
100  // Verifying if this widget can deal with the given fill...
101  delete m_halo;
102 
103  m_halo = dynamic_cast<te::se::Halo*>(halo->clone());
104 
105  updateUi();
106  m_update = true;
107 }
108 
110 {
111  return dynamic_cast<te::se::Halo*>(m_halo->clone());
112 }
113 
115 {
117 }
118 
120 {
121  m_update = true;
122 
123  //update radius
124  int radius = te::se::GetInt(m_halo->getRadius());
126 
127  //update fill
128  if (m_halo->getFill())
129  m_bf->setFill(m_halo->getFill());
130 
131  m_update = false;
132 }
133 
void setFill(Fill *fill)
Definition: Halo.cpp:54
A widget used to define the main property items that can be used to describe a se object...
const ParameterValue * getRadius() const
Definition: Halo.cpp:49
void updateUi()
Updates the widget form based on internal fill element.
HaloPropertyItem(QtTreePropertyBrowser *pb, QColor c=QColor())
Constructor.
te::qt::widgets::BasicFillPropertyItem * m_bf
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
static AbstractPropertyManager & getInstance()
It returns a reference to the singleton instance.
A widget used to define the halo se object.
URI C++ Library.
Definition: Attributes.h:37
virtual void valueChanged(QtProperty *p, int value)
te::gm::Polygon * p
Halo * clone() const
It creates a new copy of this object.
Definition: Halo.cpp:65
void addProperty(QtProperty *property, const QString &id, QColor c)
void setRadius(ParameterValue *radius)
Definition: Halo.cpp:43
te::se::Halo * m_halo
halo element that will be configured by this widget.
TESEEXPORT int GetInt(const te::se::ParameterValue *param)
It gets the parameter value as an integer.
const Fill * getFill() const
Definition: Halo.cpp:60
void setHalo(const te::se::Halo *halo)
A widget used to define the basic fill se object.
A widget used to define the basic fill se object.
A Halo is a type of Fill that is applied to the backgrounds of font glyphs.
Definition: Halo.h:64