All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LineSymbolizerWidget.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/LineSymbolizerWidget.cpp
22 
23  \brief A widget used to build a line symbolizer element.
24 */
25 
26 // TerraLib
27 #include "../../../se/LineSymbolizer.h"
28 #include "BasicStrokeWidget.h"
29 #include "LineSymbolizerWidget.h"
30 #include "ui_LineSymbolizerWidgetForm.h"
31 
32 // STL
33 #include <cassert>
34 #include <string>
35 #include <vector>
36 
38  : QWidget(parent, f),
39  m_ui(new Ui::LineSymbolizerWidgetForm),
40  m_symb(new te::se::LineSymbolizer)
41 {
42  m_ui->setupUi(this);
43 
44  // Allowed types
45  m_ui->m_lkineSymbolizerTypeComboBox->addItem(tr("Basic Line"));
46 
47  // Stroke Widget
49 
50  // Adjusting...
51  QGridLayout* layout = new QGridLayout(m_ui->m_strokeGroupBox);
52  layout->addWidget(m_strokeWidget);
53  layout->setAlignment(Qt::AlignTop);
54 
55  // Setups initial line symbolizer
57 
58  // Signals & slots
59  connect(m_strokeWidget, SIGNAL(strokeChanged()), SLOT(onStrokeChanged()));
60  connect(m_ui->m_strokeGroupBox, SIGNAL(toggled(bool)), this, SLOT(onStrokeGroupBoxToggled(bool)));
61 }
62 
64 {
65  delete m_symb;
66 }
67 
69 {
70  assert(symb);
71 
72  delete m_symb;
73 
74  m_symb = static_cast<te::se::LineSymbolizer*>(symb->clone());
75 
76  updateUi();
77 }
78 
80 {
81  return m_symb->clone();
82 }
83 
85 {
86  const te::se::Stroke* stroke = m_symb->getStroke();
87  if(stroke)
88  {
89  m_strokeWidget->setStroke(stroke);
90  m_ui->m_strokeGroupBox->setChecked(true);
91  }
92  else
93  m_ui->m_strokeGroupBox->setChecked(false);
94 }
95 
97 {
98  m_symb->setStroke(m_strokeWidget->getStroke());
99  emit symbolizerChanged();
100 }
101 
103 {
104  if(on == false)
105  m_symb->setStroke(0);
106  else
107  m_symb->setStroke(m_strokeWidget->getStroke());
108 
109  emit symbolizerChanged();
110 }
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
void updateUi()
Updates the widget form based on internal line symbolizer element.
LineSymbolizerWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a line symbolizer widget which is a child of parent, with widget flags set to f...
A widget used to build a basic stroke element.
A widget used to build a line symbolizer element.
te::se::LineSymbolizer * m_symb
Line symbolizer element that will be configured by this widget.
Symbolizer * clone() const
It creates a new copy of this object.
void setStroke(Stroke *stroke)
A Stroke specifies the appearance of a linear geometry. The Stroke element is optional inside of Line...
te::se::Symbolizer * getSymbolizer() const
Gets the configured line symbolizer element.
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
A LineSymbolizer is used to style a stroke along a linear geometry type, such as a string of line seg...
A widget used to build a basic stroke element.
std::auto_ptr< Ui::LineSymbolizerWidgetForm > m_ui
Widget form.
virtual Symbolizer * clone() const =0
It creates a new copy of this object.
te::se::Stroke * getStroke() const
Gets the configured stroke element.
te::qt::widgets::BasicStrokeWidget * m_strokeWidget
Basic Stroke Widget used to configure the line symbolizer stroke element.
void setSymbolizer(const te::se::LineSymbolizer *symb)
Sets a line symbolizer element to this widget.