LinePlacementPropertyItem.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/LinePlacementPropertyItem.cpp
22 
23 \brief A widget used to define the LinePlacement se object.
24 */
25 
26 
27 #include "../../../common/StringUtils.h"
28 #include "../../../se/SvgParameter.h"
29 #include "../../../se/LinePlacement.h"
30 #include "../../../se/Utils.h"
31 #include "../propertybrowser/AbstractPropertyManager.h"
33 
34 // STL
35 #include <cassert>
36 
37 
38 te::qt::widgets::LinePlacementPropertyItem::LinePlacementPropertyItem(QtTreePropertyBrowser* pb, QColor c) : te::qt::widgets::AbstractPropertyItem(pb, c),
39 m_linePlacement(new te::se::LinePlacement)
40 {
41  //build property browser basic fill
42  QtProperty* linePlacementProperty = te::qt::widgets::AbstractPropertyManager::getInstance().m_groupManager->addProperty(tr("Line Placement"));
43 
44  //offset
45  m_perpendicularOffset = te::qt::widgets::AbstractPropertyManager::getInstance().m_doubleManager->addProperty(tr("Offset"));
47  linePlacementProperty->addSubProperty(m_perpendicularOffset);
48 
49  //isAligned
50  m_isAligned = te::qt::widgets::AbstractPropertyManager::getInstance().m_boolManager->addProperty(tr("Is Aligned"));
52  linePlacementProperty->addSubProperty(m_isAligned);
53 
54  addProperty(linePlacementProperty, tr("Line Placement"), QColor(241, 165, 61));
55 
56  m_update = true;
57 }
58 
60 {
61  delete m_linePlacement;
62 }
63 
65 {
66  if (!m_update)
67  return;
68 
69  if (p == m_perpendicularOffset)
70  {
71  m_update = false;
72 
73  m_linePlacement->setPerpendicularOffset(new te::se::ParameterValue(QString::number(value).toUtf8().data()));
74 
75  emit linePlacementChanged();
76  m_update = true;
77  }
78 }
79 
81 {
82  if (!m_update)
83  return;
84 
85  if (p == m_isAligned)
86  {
87  m_update = false;
88 
90 
91  emit linePlacementChanged();
92  m_update = true;
93  }
94 }
95 
97 {
98  assert(pp);
99 
100  // Verifying if this widget can deal with the given fill...
101  delete m_linePlacement;
102 
103  m_linePlacement = dynamic_cast<te::se::LinePlacement*>(pp->clone());
104 
105  updateUi();
106 
107  m_update = true;
108 }
109 
111 {
112  return dynamic_cast<te::se::LinePlacement*>(m_linePlacement->clone());
113 }
114 
116 {
118 
119  te::qt::widgets::AbstractPropertyManager::getInstance().m_boolManager->setValue(m_isAligned, false);
120 }
121 
123 {
124  m_update = true;
125 
126  //update offset
127  double offset = 10.;
128 
131 
133 
134  //update isAligned
135  bool isAligned = m_linePlacement->isAligned();
136 
137  te::qt::widgets::AbstractPropertyManager::getInstance().m_boolManager->setValue(m_isAligned, isAligned);
138 
139  m_update = false;
140 }
141 
void setIsAligned(bool i)
bool isAligned() const
A widget used to define the main property items that can be used to describe a se object...
A LinePlacement specifies how a text label should be rendered relative to a linear geometry...
Definition: LinePlacement.h:61
LinePlacementPropertyItem(QtTreePropertyBrowser *pb, QColor c=QColor())
Constructor.
TESEEXPORT double GetDouble(const te::se::ParameterValue *param)
It gets the parameter value as a double.
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
virtual void valueChanged(QtProperty *p, double value)
static AbstractPropertyManager & getInstance()
It returns a reference to the singleton instance.
URI C++ Library.
Definition: Attributes.h:37
void setLinePlacement(const te::se::LinePlacement *lp)
te::se::LinePlacement * m_linePlacement
Fill element that will be configured by this widget.
te::gm::Polygon * p
void updateUi()
Updates the widget form based on internal fill element.
A widget used to define the LinePlacement se object.
void addProperty(QtProperty *property, const QString &id, QColor c)
LinePlacement * clone() const
It creates a new copy of this object.
void setPerpendicularOffset(ParameterValue *p)
const ParameterValue * getPerpendicularOffset() const
Definition: LinePlacement.h:85