All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PolygonSymbolizerProperty.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/PolygonSymbolizerProperty.cpp
22 
23  \brief A widget used to define the polygon symbolizer
24  properties, such as:
25  - basic fill
26  - basic stroke
27 */
28 
29 // Terralib
30 #include "../../../se/Fill.h"
31 #include "../../../se/PolygonSymbolizer.h"
32 #include "BasicFillPropertyItem.h"
34 #include "GraphicProperty.h"
36 
37 // Qt
38 #include <QGridLayout>
39 #include <QToolBox>
40 
41 // QtPropertyBrowser
42 #include <QtPropertyBrowser/QtTreePropertyBrowser>
43 #include <QtPropertyBrowser/QtVariantPropertyManager>
44 
45 // STL
46 #include <cassert>
47 
48 te::qt::widgets::PolygonSymbolizerProperty::PolygonSymbolizerProperty(QWidget* parent) : m_setLocalSymbol(false), m_symb(new te::se::PolygonSymbolizer)
49 {
50  QGridLayout* layout = new QGridLayout(this);
51  this->setLayout(layout);
52 
53  QToolBox* tb = new QToolBox(this);
54  layout->addWidget(tb);
55 
56  QtTreePropertyBrowser* basicPropBrowser = new QtTreePropertyBrowser(this);
57  basicPropBrowser->setIndentation(10);
58  basicPropBrowser->setPropertiesWithoutValueMarked(true);
59  basicPropBrowser->setRootIsDecorated(false);
60  basicPropBrowser->setResizeMode(QtTreePropertyBrowser::ResizeToContents);
61 
62  layout->addWidget(basicPropBrowser);
63 
64  m_bf = new te::qt::widgets::BasicFillPropertyItem(basicPropBrowser);
65  m_bs = new te::qt::widgets::BasicStrokePropertyItem(basicPropBrowser);
66 
67  tb->addItem(basicPropBrowser, "Basic Symbology");
68 
70 
71  tb->addItem(m_graph, "Graphic Symbology");
72 
73  connect(m_bf, SIGNAL(fillChanged()), this, SLOT(onFillChanged()));
74  connect(m_bs, SIGNAL(strokeChanged()), this, SLOT(onStrokeChanged()));
75  connect(m_graph, SIGNAL(graphicChanged()), this, SLOT(onPolyGraphicChanged()));
76 }
77 
79 {
80 }
81 
83 {
84  m_symb = symb;
85 
86  m_setLocalSymbol = true;
87 
88  if(m_symb->getFill())
89  {
90  if(m_symb->getFill()->getGraphicFill())
91  m_graph->setGraphic(m_symb->getFill()->getGraphicFill());
92  else
93  m_bf->setFill(m_symb->getFill());
94  }
95 
96  if(m_symb->getStroke())
97  m_bs->setStroke(m_symb->getStroke());
98 
99  m_setLocalSymbol = false;
100 }
101 
103 {
104  return m_symb;
105 }
106 
108 {
109  m_symb->setStroke(m_bs->getStroke());
110 
111  emit symbolizerChanged();
112 }
113 
115 {
116  m_symb->setFill(m_bf->getFill());
117 
118  emit symbolizerChanged();
119 }
120 
122 {
123  if(m_symb->getFill())
124  {
125  te::se::Fill* fill = m_symb->getFill()->clone();
126 
127  fill->setGraphicFill(m_graph->getGraphic());
128 
129  m_symb->setFill(fill);
130 
131  if(!m_setLocalSymbol)
132  emit symbolizerChanged();
133  }
134 }
void setSymbolizer(te::se::PolygonSymbolizer *symb)
Sets a polygon symbolizer element to this widget.
A PolygonSymbolizer is used to draw a polygon (or other area-type geometries), including filling its ...
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
A widget used to define the general properties of a se object.
A widget used to define the basic fill se object.
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
void setGraphicFill(Graphic *g)
Sets the GraphicFill element to this Fill. GraphicFill defines that the pixels of the area will be dr...
Definition: Fill.cpp:46
Fill * clone() const
It creates a new copy of this object.
Definition: Fill.cpp:86
te::qt::widgets::BasicFillPropertyItem * m_bf
A widget used to define the basic fill se object.
void setFill(Fill *f)
A Fill specifies the pattern for filling an area geometry.
te::se::Symbolizer * getSymbolizer() const
Gets the configured polygon symbolizer element.
A widget used to define the basic fill se object.
A widget used to define the polygon symbolizer properties, such as:
te::qt::widgets::BasicStrokePropertyItem * m_bs