GroupingWidget.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/GroupingWidget.h
22 
23  \brief A widget used to build a grouping.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_SE_INTERNAL_GROUPINGWIDGET_H
27 #define __TERRALIB_QT_WIDGETS_SE_INTERNAL_GROUPINGWIDGET_H
28 
29 // TerraLib
30 #ifndef Q_MOC_RUN
31 #include "../../../maptools/AbstractLayer.h"
32 #endif
33 #include "../Config.h"
34 
35 // STL
36 #include <memory>
37 
38 // QT
39 #include <QTableWidgetItem>
40 #include <QWidget>
41 
42 // Forward declaraion
43 namespace Ui { class GroupingWidgetForm; }
44 
45 namespace te
46 {
47 // Forward declarations
48  namespace color { class ColorBar; }
49 
50  namespace da { class DataSetType; }
51 
52  namespace map { class Grouping; }
53 
54  namespace se
55  {
56  class Rule;
57  class Style;
58  }
59 
60  namespace qt
61  {
62  namespace widgets
63  {
64  // Forward declarations
65  class ColorCatalogWidget;
66 
67  /*!
68  \class GroupingWidget
69 
70  \brief A widget used to build a grouping.
71 
72  \sa
73  */
74  class TEQTWIDGETSEXPORT GroupingWidget : public QWidget
75  {
76  Q_OBJECT
77 
78  public:
79 
80  /** @name Initializer Methods
81  * Methods related to instantiation and destruction.
82  */
83  //@{
84 
85  /*! \brief Constructs a basic fill widget which is a child of parent, with widget flags set to f. */
86  GroupingWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
87 
88  /*! \brief Destructor. */
89  ~GroupingWidget();
90 
91  //@}
92 
93  public:
94 
95  void setLayers(te::map::AbstractLayerPtr selectedLayer, std::vector<te::map::AbstractLayerPtr> allLayers);
96 
97  std::unique_ptr<te::map::Grouping> getGrouping();
98 
99  void updateStyle();
100 
101  protected:
102 
103  /*! \brief Internal method to initialize the widget (e.g.: color, combos, icons, etc.) */
104  void initialize();
105 
106  /*! \brief Updates the widget form based on internal fill element. */
107  void updateUi(bool loadColorBar = false);
108 
109  void setDataSetType();
110 
111  void setGrouping();
112 
113  void setGrouping(te::map::Grouping* grouping, te::se::Style* style);
114 
115  void getDataAsDouble(std::vector<double>& vec, const std::string& attrName, const int& dataType, int& nullValues);
116 
117  void getLinkedDataAsDouble(std::vector<double>& vec, const std::string& attrName, const int& dataType, int& nullValues);
118 
119  void getDataAsString(std::vector<std::string>& vec, const std::string& attrName, int& nullValues);
120 
121  void getLinkedDataAsString(std::vector<std::string>& vec, const std::string& attrName, int& nullValues);
122 
123  void createDoubleNullGroupingItem(int count);
124 
125  void createStringNullGroupingItem(int count);
126 
127  int getGeometryType();
128 
129  void buildSymbolizer(std::string meanTitle = "");
130 
131  void listAttributes();
132 
133  void saveLegend(const std::string& path);
134 
135  public slots:
136 
137  void onApplyPushButtonClicked();
138 
139  void onTypeComboBoxActivated(int idx);
140 
141  void onAttrComboBoxActivated(int idx);
142 
143  void onColorBarChanged();
144 
145  void onTableWidgetItemChanged(QTableWidgetItem* item);
146 
147  void onTableWidgetItemDoubleClicked(QTableWidgetItem* item);
148 
149  void onImportPushButtonClicked();
150 
151  void onLoadPushButtonClicked();
152 
153  void onSavePushButtonClicked();
154 
155  signals:
156 
157  void applyPushButtonClicked();
158 
159 
160  private:
161 
162  std::unique_ptr<Ui::GroupingWidgetForm> m_ui; //!< Widget form.
163 
164  te::color::ColorBar* m_cb; //!< Terralib color bar objetc
165  te::map::AbstractLayerPtr m_layer; //!< TerraLib layer auto ptr
166  te::qt::widgets::ColorCatalogWidget* m_colorBar; //!< Widget used to pick a color.
167  std::vector<te::se::Rule*> m_rules; //!< Grouping items
168  te::se::Style* m_style; //!< Current style from input layer.
169 
170  bool m_manual;
171  };
172 
173  } // end namespace widgets
174  } // end namespace qt
175 } // end namespace te
176 
177 #endif // __TERRALIB_QT_WIDGETS_SE_INTERNAL_GROUPINGWIDGET_H
std::vector< te::se::Rule * > m_rules
Grouping items.
#define slots
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
te::se::Style * m_style
Current style from input layer.
This class contains the parameters needed for grouping the values of a Property.
Definition: Grouping.h:57
A widget used to build a grouping.
TerraLib.
te::map::AbstractLayerPtr m_layer
TerraLib layer auto ptr.
It models the concept of color bar.
Definition: ColorBar.h:49
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
std::unique_ptr< Ui::GroupingWidgetForm > m_ui
Widget form.
te::qt::widgets::ColorCatalogWidget * m_colorBar
Widget used to pick a color.
te::color::ColorBar * m_cb
Terralib color bar objetc.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr