BasicStrokeWidget.h
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/BasicStrokeWidget.h
22 
23  \brief A widget used to build a basic stroke element.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_SE_INTERNAL_BASICSTROKEWIDGET_H
27 #define __TERRALIB_QT_WIDGETS_SE_INTERNAL_BASICSTROKEWIDGET_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // Qt
33 #include <QWidget>
34 
35 // STL
36 #include <memory>
37 #include <vector>
38 #include <string>
39 
40 // Forward declaraion
41 class QButtonGroup;
42 namespace Ui { class BasicStrokeWidgetForm; }
43 
44 namespace te
45 {
46 // Forward declarations
47  namespace se
48  {
49  class Stroke;
50  }
51 
52  namespace qt
53  {
54  namespace widgets
55  {
56 // Forward declarations
57  class ColorPickerToolButton;
58 
59  /*!
60  \class BasicStrokeWidget
61 
62  \brief A widget used to build a basic stroke element.
63  */
64  class TEQTWIDGETSEXPORT BasicStrokeWidget : public QWidget
65  {
66  Q_OBJECT
67 
68  public:
69 
70  /** @name Initializer Methods
71  * Methods related to instantiation and destruction.
72  */
73  //@{
74 
75  /*! \brief Constructs a basic stroke widget which is a child of parent, with widget flags set to f. */
76  BasicStrokeWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
77 
78  /*! \brief Destructor. */
80 
81  //@}
82 
83  public:
84 
85  /*!
86  \brief Sets a stroke element to this widget.
87 
88  \param stroke A valid stroke element.
89 
90  \note The widget will NOT take the ownership of the given stroke.
91  \note The widget form will be update based on given stroke parameters.
92  */
93  void setStroke(const te::se::Stroke* stroke);
94 
95  /*!
96  \brief Gets the configured stroke element.
97 
98  \return The configured stroke element.
99 
100  \note The caller will take the ownership of the returned stroke.
101  */
102  te::se::Stroke* getStroke() const;
103 
104  protected:
105 
106  /*! \brief Internal method to initialize the widget (e.g.: color, combos, icons, etc.) */
107  void initialize();
108 
109  /*! \brief Updates the widget form based on internal stroke element. */
110  void updateUi();
111 
112  /*! \brief Updates the widget form element used to visualize the stroke color. */
113  void updateUiStrokeColor();
114 
115  /*!
116  \brief Updates the widget form element used to visualize the stroke dash style.
117 
118  \param pattern The stroke dash style pattern.
119  */
120  void updateUiDashStyle(const std::string& pattern);
121 
122  /*!
123  \brief Updates the widget form element used to visualize the stroke join style.
124 
125  \param style The stroke join style type.
126  */
127  void updateUiJoinStyle(const std::string& style);
128 
129  /*!
130  \brief Updates the widget form element used to visualize the stroke cap style.
131 
132  \param style The stroke cap style type.
133  */
134  void updateUiCapStyle(const std::string& style);
135 
136  /*! \brief Fills the widget form element used to visualize the stroke cap style. */
137  void fillStrokeDashStyleComboBox();
138 
139  protected slots:
140 
141  void onColorChanged(const QColor& color);
142 
143  void onStrokeOpacitySliderValueChanged(int value);
144 
145  void onStrokeWidthDoubleSpinBoxValueChanged(const QString& text);
146 
147  void onStrokeDashComboBoxCurrentIndexChanged(int index);
148 
149  void onStrokeJoinStyleChanged(int style);
150 
151  void onStrokeCapStyleChanged(int style);
152 
153  signals:
154 
155  /*! This signal is emitted when the internal stroke element is changed. */
156  void strokeChanged();
157 
158  private:
159 
160  std::auto_ptr<Ui::BasicStrokeWidgetForm> m_ui; //!< Widget form.
161  ColorPickerToolButton* m_colorPicker; //!< Widget used to pick a color.
162  QButtonGroup* m_strokeJoinStyleButtonGroup; //!< Button group used to control the join styles.
163  QButtonGroup* m_strokeCapStyleButtonGroup; //!< Button group used to control the cap styles.
164  QColor m_color; //!< Auxiliary color attribute.
165  te::se::Stroke* m_stroke; //!< Stroke element that will be configured by this widget.
166  std::vector<std::string> m_dashes; //!< Predefined dash styles. TODO: it can be filled out, based on a file, etc (?)
167  };
168 
169  } // end namespace widgets
170  } // end namespace qt
171 } // end namespace te
172 
173 #endif // __TERRALIB_QT_WIDGETS_SE_INTERNAL_BASICSTROKEWIDGET_H
ColorPickerToolButton * m_colorPicker
Widget used to pick a color.
QButtonGroup * m_strokeCapStyleButtonGroup
Button group used to control the cap styles.
std::vector< std::string > m_dashes
Predefined dash styles. TODO: it can be filled out, based on a file, etc (?)
std::auto_ptr< Ui::BasicStrokeWidgetForm > m_ui
Widget form.
A widget used to build a basic stroke element.
Custom tool button used to pick a color.
QButtonGroup * m_strokeJoinStyleButtonGroup
Button group used to control the join styles.
te::se::Stroke * m_stroke
Stroke element that will be configured by this widget.
URI C++ Library.
QColor m_color
Auxiliary color attribute.
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63