All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChartDisplay.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2013 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/charts/ChartDisplay.h
22 
23  \brief A class to represent a chart display
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_CHARTDISPLAY_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_CHARTDISPLAY_H
28 
29 //TerraLib
30 #include "../Config.h"
31 
32 //QWT
33 #include <qwt_plot.h>
34 
35 //STL
36 #include <string>
37 
38 class QwtPlotGrid;
39 class QwtPlotPanner;
40 class QwtPlotPicker;
41 
42 namespace te
43 {
44  namespace color { class RGBAColor; }
45  namespace da { class ObjectIdSet; }
46  namespace se { class Stroke; class Fill; class Font; }
47 
48  namespace qt
49  {
50  namespace widgets
51  {
52 
53  //Forward declaration
54  class ChartStyle;
55 
56  /*!
57  \class ChartDisplay
58 
59  \brief A class to represent a chart display
60 
61  \ingroup widgets
62  */
63  class TEQTWIDGETSEXPORT ChartDisplay : public QwtPlot
64  {
65 
66  Q_OBJECT
67 
68  public:
69 
70  /*!
71  \brief Constructor
72 
73  It constructs a ChartDisplay with the given title and style.
74 
75  \param parent this widget's parent
76  \param title this widget's title.
77 
78  \note it will take the ownership of the pointer "style". If style is null, the display will be constructed with a default style.
79  */
80  ChartDisplay(QWidget* parent=NULL, QString title = "", ChartStyle* style = 0);
81 
82  /*!
83  \brief Destructor
84  */
85  ~ChartDisplay();
86 
87  /*!
88  \brief It sets the QwtPlotPicker's state machine (selection mode)
89 
90  \param chartType The type of the chart that the picker will be adjusted to funtion for.
91 
92  Although the selection function can work for any chart based on a single point (or click)
93  some charts can benefit from a different behavior, such as a drag & release selection.
94  This function will adjust the picker state machine to better suit the type of chart being displayed.
95 
96  The current chart types supported and their respective selection mode are as follow:
97 
98  te::qt::widgets::HISTOGRAM_CHART = Point selection;
99  te::qt::widgets::SCATTER_CHART = Rectangle selection;
100 
101  */
102  void setPickerStyle(int chartType);
103 
104  /*!
105  \brief Returns a pointer to the display's style
106 
107  \return A ChartStyle type pointer to the display's style.
108  \note The caller will not take ownership of the returned pointer.
109  */
110  te::qt::widgets::ChartStyle* getStyle();
111 
112  /*!
113  \brief It sets the display's style
114 
115  \param newStyle The new style.
116  \note It will take ownership of the given pointer
117  */
118  void setStyle(te::qt::widgets::ChartStyle* newStyle);
119 
120  /*!
121  \brief Highlights the objects identified by \a oids
122 
123  \param oids The identifiers of plotitems to be highlighted.
124  */
125  void highlightOIds(const te::da::ObjectIdSet* oids);
126 
127  /*!
128  \brief color used to hgihlight selected objects on this display.
129 
130  \param selColor The color used to hgihlight selected objects on this display.
131 
132  */
133  void setSelectionColor(QColor selColor);
134 
135  /*!
136  \brief Updates the general display settings according to the ChartStyle.
137  The adjusted properties are:
138  Title;
139  Axis titles (x and Y);
140  Weather to display the grid or not;
141  Background color;
142  */
143  void adjustDisplay();
144 
145  protected slots:
146 
147  /*!
148  \brief Called when the user clicks on the canvas area.
149  Will highlight the data, if possible, depending on the type of chart being displayed (f.e. histogram, scatter, etc).
150  */
151  void onPointPicked(const QPointF &pos);
152 
153  /*!
154  \brief Called when the user selects an area of the canvas.
155  Will highlight the data, if possible, depending on the type of chart being displayed (f.e. histogram, scatter, etc).
156  */
157  void onRectPicked(const QRectF &rect);
158 
159  signals:
160 
161  /*!
162  \brief Emmit when objects were selected.
163  */
164  void selected(te::da::ObjectIdSet*, const bool&);
165 
166  private:
167 
168  ChartStyle* m_chartStyle; //!< The display's style.
169  QwtPlotGrid* m_grid; //!< The display's grid
170  QwtPlotPanner* m_panner; //!< The display's panner.
171  QwtPlotPicker* m_leftPicker; //!< The display's left button picker.
172  QwtPlotPicker* m_ctrlPicker; //!< The display's control button picker.
173  QwtPlotPicker* m_shiftPicker; //!< The display's control button picker.
174  };
175  } // end namespace widgets
176  } // end namespace qt
177 } // end namespace te
178 
179 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_CHARTDISPLAY_H
180 
QwtPlotPicker * m_ctrlPicker
The display&#39;s control button picker.
Definition: ChartDisplay.h:172
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:101
ChartStyle * m_chartStyle
The display&#39;s style.
Definition: ChartDisplay.h:168
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
QwtPlotGrid * m_grid
The display&#39;s grid.
Definition: ChartDisplay.h:169
QwtPlotPicker * m_shiftPicker
The display&#39;s control button picker.
Definition: ChartDisplay.h:173
QwtPlotPanner * m_panner
The display&#39;s panner.
Definition: ChartDisplay.h:170
QwtPlotPicker * m_leftPicker
The display&#39;s left button picker.
Definition: ChartDisplay.h:171
A class to represent a chart display.
Definition: ChartDisplay.h:63