TextSymbolizerProperty.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/TextSymbolizerProperty.cpp
22 
23  \brief A widget used to define the text symbolizer
24  properties, such as:
25  - basic fill
26  - font
27  - halo
28 */
29 
30 // Terralib
31 #include "../../../se/Halo.h"
32 #include "../../../se/Fill.h"
33 #include "../../../se/Font.h"
34 #include "../../../se/LabelPlacement.h"
35 #include "../../../se/LinePlacement.h"
36 #include "../../../se/ParameterValue.h"
37 #include "../../../se/PointPlacement.h"
38 #include "../../../se/TextSymbolizer.h"
39 #include "HaloPropertyItem.h"
42 #include "TextPropertyItem.h"
43 #include "TextSymbolizerProperty.h"
44 
45 // Qt
46 #include <QGridLayout>
47 #include <QToolBox>
48 
49 // QtPropertyBrowser
50 #include <QtPropertyBrowser/QtTreePropertyBrowser>
51 #include <QtPropertyBrowser/QtVariantPropertyManager>
52 
53 // STL
54 #include <cassert>
55 
57  QWidget* /*parent*/)
58  : m_setLocalSymbol(false), m_symb(new te::se::TextSymbolizer)
59 {
60  QGridLayout* layout = new QGridLayout(this);
61  this->setLayout(layout);
62 
63  QToolBox* tb = new QToolBox(this);
64  layout->addWidget(tb);
65 
66  QtTreePropertyBrowser* basicPropBrowser = new QtTreePropertyBrowser(this);
67  basicPropBrowser->setIndentation(10);
68  basicPropBrowser->setPropertiesWithoutValueMarked(true);
69  basicPropBrowser->setRootIsDecorated(false);
70  basicPropBrowser->setResizeMode(QtTreePropertyBrowser::ResizeToContents);
71 
72  layout->addWidget(basicPropBrowser);
73 
74  m_text = new te::qt::widgets::TextPropertyItem(basicPropBrowser);
75 
76  m_pp = new te::qt::widgets::PointPlacementPropertyItem(basicPropBrowser);
77 
78  m_lp = new te::qt::widgets::LinePlacementPropertyItem(basicPropBrowser);
79 
80  m_halo = new te::qt::widgets::HaloPropertyItem(basicPropBrowser);
81 
82  tb->addItem(basicPropBrowser, "Text Symbology");
83 
84  connect(m_text, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
85  connect(m_pp, SIGNAL(pointPlacementChanged()), this, SLOT(onPointPlacementChanged()));
86  connect(m_lp, SIGNAL(linePlacementChanged()), this, SLOT(onLinePlacementChanged()));
87  connect(m_halo, SIGNAL(haloChanged()), this, SLOT(onHaloChanged()));
88 }
89 
91 
93 {
94  m_symb = symb;
95 
96  m_setLocalSymbol = true;
97 
99 
102  else
104 
107  else
109 
110  if (m_symb->getHalo())
112  else
113  m_halo->resetHalo();
114 
115  m_setLocalSymbol = false;
116 }
117 
119 {
120  return m_symb;
121 }
122 
123 void te::qt::widgets::TextSymbolizerProperty::setLabels(std::vector<std::string> names)
124 {
125  m_text->setLabels(names);
126 }
127 
129 {
131 
132  m_symb->setLabel(ts->getLabel()->clone());
133  m_symb->setFont(ts->getFont()->clone());
134  m_symb->setFill(ts->getFill()->clone());
135 
136  delete ts;
137 
138  emit symbolizerChanged();
139 }
140 
142 {
144 
146 
149 
151 
152  emit symbolizerChanged();
153 }
154 
156 {
158 
160 
163 
165 
166  emit symbolizerChanged();
167 }
168 
170 {
172 
173  emit symbolizerChanged();
174 }
A TextSymbolizer is used to render text labels according to various graphical parameters.
te::se::Symbolizer * getSymbolizer() const
Gets the configured polygon symbolizer element.
void setLabels(std::vector< std::string > labels)
void setSymbolizer(te::se::TextSymbolizer *symb)
Sets a text symbolizer element to this widget.
const LabelPlacement * getLabelPlacement() const
The LabelPlacement specifies where and how a text label should be rendered relative to a geometry...
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
void setPointPlacement(const te::se::PointPlacement *pp)
void setTextSymbolizer(const te::se::TextSymbolizer *ts)
A widget used to define the PointPlacement se object.
PointPlacement * clone() const
It creates a new copy of this object.
te::qt::widgets::HaloPropertyItem * m_halo
A widget used to define the halo se object.
A widget used to define the PointPlacement se object.
void setLabels(std::vector< std::string > names)
Used to set all properties names to use as label.
te::qt::widgets::TextPropertyItem * m_text
A widget used to define the halo se object.
URI C++ Library.
Definition: Attributes.h:37
void setLinePlacement(const te::se::LinePlacement *lp)
A widget used to define the text se object.
void setPointPlacement(PointPlacement *p)
const Font * getFont() const
TextSymbolizerProperty(QWidget *parent)
Constructor.
ParameterValue * clone() const
It creates a new copy of this object.
A widget used to define the LinePlacement se object.
Fill * clone() const
It creates a new copy of this object.
Definition: Fill.cpp:86
LinePlacement * clone() const
It creates a new copy of this object.
void setLabel(ParameterValue *l)
A widget used to define the LinePlacement se object.
const LinePlacement * getLinePlacement() const
te::qt::widgets::PointPlacementPropertyItem * m_pp
A widget used to define the text symbolizer properties, such as:
te::qt::widgets::LinePlacementPropertyItem * m_lp
const ParameterValue * getLabel() const
te::se::TextSymbolizer * m_symb
Text symbolizer element that will be configured by this widget.
void setHalo(const te::se::Halo *halo)
const Fill * getFill() const
void setLinePlacement(LinePlacement *l)
const PointPlacement * getPointPlacement() const
const Halo * getHalo() const
Font * clone() const
It creates a new copy of this object.
Definition: Font.cpp:108
te::se::TextSymbolizer * getTextSymbolizer() const
void setLabelPlacement(LabelPlacement *l)
A widget used to define the text se object.