ChartConfigurer.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/charts/ChartConfigurer.cpp
22 
23  \brief A Symbology Enconding visitor that configures a given chart based on symbolizer elements.
24 */
25 
26 // TerraLib
27 
28 #include "../../../maptools/AbstractLayer.h"
29 #include "../../../se/Fill.h"
30 #include "../../../se/Graphic.h"
31 #include "../../../se/LineSymbolizer.h"
32 #include "../../../se/Mark.h"
33 #include "../../../se/PointSymbolizer.h"
34 #include "../../../se/PolygonSymbolizer.h"
35 #include "../../../se/Stroke.h"
36 #include "../../../se/Symbolizer.h"
37 #include "../../../se/Style.h"
38 #include "../../../se/Rule.h"
39 #include "ChartConfigurer.h"
40 #include "HistogramChart.h"
41 #include "HistogramStyle.h"
42 #include "ScatterChart.h"
43 #include "ScatterStyle.h"
44 
45 //QWT
46 #include <qwt_plot_seriesitem.h>
47 
49 {
50  m_chart = chart;
51 }
52 
54 
56 {
57  symbolizer->accept(*this);
58 }
59 
61 {
62  if(layer->getStyle()
63  && !layer->getStyle()->getRules().empty()
64  && !layer->getStyle()->getRule(0)->getSymbolizers().empty())
65  config(layer->getStyle()->getRule(0)->getSymbolizer(0));
66 }
67 
69 {
70 }
71 
73  const te::se::FeatureTypeStyle& /*visited*/)
74 {
75 }
76 
78  const te::se::CoverageStyle& /*visited*/)
79 {
80 }
81 
83  const te::se::Symbolizer& /*visited*/)
84 {
85 }
86 
88 {
89  const te::se::Stroke* stroke = visited.getStroke();
90  if(stroke)
91  config(stroke);
92 
93  const te::se::Fill* fill = visited.getFill();
94  if(fill)
95  config(fill);
96 }
97 
99 {
100  const te::se::Stroke* stroke = visited.getStroke();
101  if(stroke)
102  config(stroke);
103 }
104 
106 {
107  const te::se::Graphic* graphic = visited.getGraphic();
108  if(graphic)
109  config(graphic);
110 }
111 
113  const te::se::TextSymbolizer& /*visited*/)
114 {
115 }
116 
118  const te::se::RasterSymbolizer& /*visited*/)
119 {
120 }
121 
123 {
124  int chartType = m_chart->getChart()->rtti();
125 
126  switch(chartType)
127  {
129  {
130  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
131  style->setStroke(stroke->clone());
132  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
133  break;
134  }
136  {
137  te::qt::widgets::HistogramStyle* style = static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->getHistogramStyle();
138  style->setStroke(stroke->clone());
139  static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->setHistogramStyle(style);
140  break;
141  }
142  }
143 }
144 
146 {
147  int chartType = m_chart->getChart()->rtti();
148 
149  switch(chartType)
150  {
152  {
153  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
154  style->setFill(fill->clone());
155  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
156  break;
157  }
159  {
160  te::qt::widgets::HistogramStyle* style = static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->getHistogramStyle();
161  style->setFill(fill->clone());
162  static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->setHistogramStyle(style);
163  break;
164  }
165  }
166 }
167 
169 {
170  int chartType = m_chart->getChart()->rtti();
171  if(chartType == te::qt::widgets::SCATTER_CHART)
172  {
173  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
174  style->setGraphic(graphic->clone());
175  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
176  }
177 }
A TextSymbolizer is used to render text labels according to various graphical parameters.
Stroke * clone() const
It creates a new copy of this object.
Definition: Stroke.cpp:158
A Symbology Enconding visitor that configures a given chart based on symbolizer elements.
const Fill * getFill() const
Gets the Fill associates with the PolygonSymbolizer.
const Graphic * getGraphic() const
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
void setGraphic(te::se::Graphic *newGraphic)
It sets the he scatter&#39;s graphic.
This is the base class for layers.
Definition: AbstractLayer.h:77
ChartDisplayWidget * m_chart
A pointer to the chart that will be configured.
A PolygonSymbolizer is used to draw a polygon (or other area-type geometries), including filling its ...
QwtPlotSeriesItem * getChart()
Returns a pointer to the chart being displayed.
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
Definition: CoverageStyle.h:45
A PointSymbolizer specifies the rendering of a graphic Symbolizer at a point.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66
void setStroke(te::se::Stroke *newStroke)
It sets the scatter point&#39;s stroke.
A class used to define the style of a histogram&#39;s chart.
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
const std::vector< Rule * > & getRules() const
Definition: Style.cpp:94
Graphic * clone() const
It creates a new copy of this object.
Definition: Graphic.cpp:167
ChartConfigurer(ChartDisplayWidget *chart)
Constructor.
The FeatureTypeStyle defines the styling that is to be applied to a dataset that can be viewed as a f...
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
const Stroke * getStroke() const
Gets the Stroke associates with the PolygonSymbolizer.
A class to represent a histogram chart.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
A class to represent a scatter chart.
Definition: ScatterChart.h:55
A class to represent a scatter&#39;s chart.
const std::vector< Symbolizer * > & getSymbolizers() const
Definition: Rule.cpp:158
void visit(const te::se::Style &visited)
const Stroke * getStroke() const
void config(const te::se::Symbolizer *symbolizer)
It configs the chart based on given symbolizer.
Fill * clone() const
It creates a new copy of this object.
Definition: Fill.cpp:86
A wdiget used to display a chart.
void setFill(te::se::Fill *newFill)
It sets the histogram bar&#39;s fill.
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
void setFill(te::se::Fill *newFill)
It sets the scatter point&#39;s fill.
A LineSymbolizer is used to style a stroke along a linear geometry type, such as a string of line seg...
const Symbolizer * getSymbolizer(std::size_t i) const
Definition: Rule.cpp:163
void setStroke(te::se::Stroke *newStroke)
It sets the histogram bar&#39;s stroke.