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