StyleExplorer.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/StyleExplorer.h
22 
23  \brief A widget used to explore a style.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_SE_INTERNAL_STYLEEXPLORER_H
27 #define __TERRALIB_QT_WIDGETS_SE_INTERNAL_STYLEEXPLORER_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // Qt
33 #include <QtCore/QString>
34 #include <QTreeWidget>
35 
36 // STL
37 #include <map>
38 
39 namespace te
40 {
41 // Forward declarations
42  namespace se
43  {
44  class Rule;
45  class Style;
46  class Symbolizer;
47  }
48 
49  namespace qt
50  {
51  namespace widgets
52  {
53  /*!
54  \class StyleExplorer
55 
56  \brief A widget used to explore a style.
57 
58  \ingroup widgets
59  */
60  class TEQTWIDGETSEXPORT StyleExplorer : public QTreeWidget
61  {
62  Q_OBJECT
63 
64  private:
65 
66  /*!
67  \enum NodeType
68 
69  \brief Auxiliary internal enumeration to control the StyleExplorer tree nodes.
70  */
71  enum NodeType
72  {
73  STYLE = 0, /*!< Style root node. */
74  RULE = 1, /*!< Rule node. */
75  SYMBOLIZER = 2 /*!< Symbolizer node. */
76  };
77 
78  public:
79 
80  /** @name Initializer Methods
81  * Methods related to instantiation and destruction.
82  */
83  //@{
84 
85  /*! \brief Constructs a style explorer widget which is a child of parent. */
86  StyleExplorer(QWidget* parent = 0);
87 
88  /*! \brief Destructor. */
90 
91  //@}
92 
93  public:
94 
95  /*!
96  \brief Sets a style element to this widget.
97 
98  \param style A valid style element.
99 
100  \note The widget will NOT take the ownership of the given style.
101  \note The widget will be update based on given style parameters.
102  */
103  void setStyle(te::se::Style* style, te::se::Rule* currentRule = 0);
104 
105  /*! \brief This method updates the Style Explorer. */
106  void updateStyleTree(te::se::Rule* currentRule = 0);
107 
108  /*!
109  \brief Gets the current rule.
110 
111  \return The current rule on Style Explorer.
112 
113  \note If there is not a current rule a NULL point will be returned.
114  */
116 
117  /*!
118  \brief Gets the current symbolizer.
119 
120  \return The current symbolizer on Style Explorer.
121 
122  \note If there is not a current symbolizer a NULL point will be returned.
123  */
125 
127 
129 
130  void setLegendIconSize(int size);
131 
132  void importStyle(te::se::Style* style, bool isVisual);
133 
134  public slots:
135 
137 
138  private:
139 
140  /*! \brief Auxiliary internal method to retrieve a rule from a QTreeWidgetItem. */
141  te::se::Rule* getRule(QTreeWidgetItem* item);
142 
143  /*! \brief Auxiliary internal method to retrieve a symbolizer from a QTreeWidgetItem. */
144  te::se::Symbolizer* getSymbolizer(QTreeWidgetItem* item);
145 
146  /*!
147  \brief Auxiliary internal method to retrieve the selected item on Style Explorer.
148 
149  \return The selected QTreeWidgetItem on Style Explorer.
150 
151  \note If there is not a selected QTreeWidgetItem a NULL point will be returned.
152  */
153  QTreeWidgetItem* getSelectedItem() const;
154 
155  void swapSymbolizers(te::se::Rule* r, int indexFirst, int indexSecond);
156 
157  private slots:
158 
159  void onItemClicked(QTreeWidgetItem* item, int column);
160 
161  signals:
162 
163  /*! This signal is emitted when a rule is clicked. */
165 
166  /*! This signal is emitted when a symbolizer is clicked. */
168 
169  void styleImported(te::se::Style* style, bool isVisual);
170 
171  private:
172 
173  te::se::Style* m_style; //!< Style element that will be explored by this widget.
174  std::map<QString, QString> m_symbolizerNames; //!< A map of symbolizers names to user interface names.
175  };
176 
177  } // end namespace widgets
178  } // end namespace qt
179 } // end namespace te
180 
181 #endif // __TERRALIB_QT_WIDGETS_SE_INTERNAL_STYLEEXPLORER_H
te::qt::widgets::StyleExplorer::goDownSymbolizer
void goDownSymbolizer()
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::qt::widgets::StyleExplorer::onSymbolizerChanged
void onSymbolizerChanged(te::se::Symbolizer *symb)
te::qt::widgets::StyleExplorer::~StyleExplorer
~StyleExplorer()
Destructor.
te::qt::widgets::StyleExplorer
A widget used to explore a style.
Definition: StyleExplorer.h:61
te::qt::widgets::StyleExplorer::styleImported
void styleImported(te::se::Style *style, bool isVisual)
te::qt::widgets::StyleExplorer::updateStyleTree
void updateStyleTree(te::se::Rule *currentRule=0)
This method updates the Style Explorer.
te::qt::widgets::StyleExplorer::symbolizerClicked
void symbolizerClicked(te::se::Symbolizer *symb)
te::qt::widgets::StyleExplorer::setStyle
void setStyle(te::se::Style *style, te::se::Rule *currentRule=0)
Sets a style element to this widget.
te::qt::widgets::StyleExplorer::importStyle
void importStyle(te::se::Style *style, bool isVisual)
TEQTWIDGETSEXPORT
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
te::qt::widgets::StyleExplorer::ruleClicked
void ruleClicked(te::se::Rule *rule)
te::qt::widgets::StyleExplorer::getSymbolizer
te::se::Symbolizer * getSymbolizer(QTreeWidgetItem *item)
Auxiliary internal method to retrieve a symbolizer from a QTreeWidgetItem.
te::qt::widgets::StyleExplorer::getSelectedItem
QTreeWidgetItem * getSelectedItem() const
Auxiliary internal method to retrieve the selected item on Style Explorer.
te::qt::widgets::StyleExplorer::getCurrentSymbolizer
te::se::Symbolizer * getCurrentSymbolizer()
Gets the current symbolizer.
te::qt::widgets::StyleExplorer::onItemClicked
void onItemClicked(QTreeWidgetItem *item, int column)
te::qt::widgets::StyleExplorer::swapSymbolizers
void swapSymbolizers(te::se::Rule *r, int indexFirst, int indexSecond)
te::qt::widgets::StyleExplorer::getRule
te::se::Rule * getRule(QTreeWidgetItem *item)
Auxiliary internal method to retrieve a rule from a QTreeWidgetItem.
te::se::Rule
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
Definition: Rule.h:77
slots
#define slots
Definition: VirtualMachine.h:48
te::qt::widgets::StyleExplorer::m_symbolizerNames
std::map< QString, QString > m_symbolizerNames
A map of symbolizers names to user interface names.
Definition: StyleExplorer.h:174
te::qt::widgets::StyleExplorer::m_style
te::se::Style * m_style
Style element that will be explored by this widget.
Definition: StyleExplorer.h:173
te::qt::widgets::StyleExplorer::StyleExplorer
StyleExplorer(QWidget *parent=0)
Constructs a style explorer widget which is a child of parent.
te::se::Style
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:66
te::qt::widgets::StyleExplorer::getCurrentRule
te::se::Rule * getCurrentRule()
Gets the current rule.
te::qt::widgets::StyleExplorer::setLegendIconSize
void setLegendIconSize(int size)
te::qt::widgets::StyleExplorer::NodeType
NodeType
Auxiliary internal enumeration to control the StyleExplorer tree nodes.
Definition: StyleExplorer.h:72
te::se::Symbolizer
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:81
te::qt::widgets::StyleExplorer::goUpSymbolizer
void goUpSymbolizer()