All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GraphicFillWidget.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/GraphicFillWidget.cpp
22 
23  \brief A widget used to build a fill element associated with a graphic.
24 */
25 
26 // TerraLib
27 #include "../../../se/Fill.h"
28 #include "GraphicDialog.h"
29 #include "GraphicFillWidget.h"
30 #include "ui_GraphicFillWidgetForm.h"
31 
32 // STL
33 #include <cassert>
34 
35 te::qt::widgets::GraphicFillWidget::GraphicFillWidget(QWidget* parent, Qt::WindowFlags f)
36  : AbstractFillWidget(parent, f),
37  m_ui(new Ui::GraphicFillWidgetForm),
38  m_graphicDialog(new GraphicDialog),
39  m_fill(new te::se::Fill)
40 {
41  m_ui->setupUi(this);
42 
43  // Setups initial fill
44  m_fill->setGraphicFill(m_graphicDialog->getGraphic());
45 
46  updateUi();
47 
48  // Signals & slots
49  connect(m_ui->m_graphicToolButton, SIGNAL(pressed()), SLOT(onGraphicToolButtonPressed()));
50 }
51 
53 {
54  delete m_fill;
55 }
56 
58 {
59  assert(fill);
60 
61  // Verifying if this widget can deal with the given fill...
62  const te::se::Graphic* g = fill->getGraphicFill();
63  if(g == 0)
64  return false;
65 
66  delete m_fill;
67 
68  m_fill = fill->clone();
69 
70  m_graphicDialog->setGraphic(g);
71 
72  updateUi();
73 
74  return true;
75 }
76 
78 {
79  return m_fill->clone();
80 }
81 
83 {
84  return tr("Graphic Fill");
85 }
86 
88 {
89  // Updating graphic icon
90  QSize size = m_ui->m_graphicToolButton->iconSize();
91  m_ui->m_graphicToolButton->setIcon(m_graphicDialog->getGraphicIcon(size));
92 }
93 
95 {
96  if(m_graphicDialog->exec() == QDialog::Rejected)
97  return;
98 
99  // Updating fill
100  m_fill->setGraphicFill(m_graphicDialog->getGraphic());
101  emit fillChanged();
102 
103  updateUi();
104 }
std::auto_ptr< Ui::GraphicFillWidgetForm > m_ui
Widget form.
te::se::Fill * m_fill
Fill element that will be configured by this widget.
void updateUi()
Updates the widget form based on internal fill element.
Abstract class that represents a widget that can be used to build a fill element. ...
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66
GraphicFillWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a graphic fill widget which is a child of parent, with widget flags set to f...
A widget used to build a fill element associated with a graphic.
te::se::Fill * getFill() const
Gets the configured fill element.
const Graphic * getGraphicFill() const
Gets the GraphicFill element associate to this Fill.
Definition: Fill.cpp:52
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
QString getFillType() const
Pure virtual method that should return a "user friendly" string that informs the fill type that can b...
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 dialog used to build a graphic element.
Fill * clone() const
It creates a new copy of this object.
Definition: Fill.cpp:86
bool setFill(const te::se::Fill *fill)
Sets a fill element to this widget.
A dialog used to build a graphic element. If you want to use this dialog, you can use commands like: ...
Definition: GraphicDialog.h:69
std::auto_ptr< GraphicDialog > m_graphicDialog
Graphic dialog used to build the graphic element.