All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChartConfigurer.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 {
55 }
56 
58 {
59  symbolizer->accept(*this);
60 }
61 
63 {
64  if(layer->getStyle())
65  config(layer->getStyle()->getRule(0)->getSymbolizer(0));
66 }
67 
69 {
70 }
71 
73 {
74 }
75 
77 {
78 }
79 
81 {
82 }
83 
85 {
86  const te::se::Stroke* stroke = visited.getStroke();
87  if(stroke)
88  config(stroke);
89 
90  const te::se::Fill* fill = visited.getFill();
91  if(fill)
92  config(fill);
93 }
94 
96 {
97  const te::se::Stroke* stroke = visited.getStroke();
98  if(stroke)
99  config(stroke);
100 }
101 
103 {
104  const te::se::Graphic* graphic = visited.getGraphic();
105  if(graphic)
106  config(graphic);
107 }
108 
110 {
111 }
112 
114 {
115 }
116 
118 {
119  int chartType = m_chart->getChart()->rtti();
120 
121  switch(chartType)
122  {
124  {
125  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
126  style->setStroke(stroke->clone());
127  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
128  break;
129  }
131  {
132  te::qt::widgets::HistogramStyle* style = static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->getHistogramStyle();
133  style->setStroke(stroke->clone());
134  static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->setHistogramStyle(style);
135  break;
136  }
137  }
138 }
139 
141 {
142  int chartType = m_chart->getChart()->rtti();
143 
144  switch(chartType)
145  {
147  {
148  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
149  style->setFill(fill->clone());
150  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
151  break;
152  }
154  {
155  te::qt::widgets::HistogramStyle* style = static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->getHistogramStyle();
156  style->setFill(fill->clone());
157  static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->setHistogramStyle(style);
158  break;
159  }
160  }
161 }
162 
164 {
165  int chartType = m_chart->getChart()->rtti();
166  if(chartType == te::qt::widgets::SCATTER_CHART)
167  {
168  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
169  style->setGraphic(graphic->clone());
170  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
171  }
172 }
A LineSymbolizer is used to style a stroke along a linear geometry type, such as a string of line seg...
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
A class to represent a scatter&#39;s chart.
void setStroke(te::se::Stroke *newStroke)
It sets the histogram bar&#39;s stroke.
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
const Symbolizer * getSymbolizer(std::size_t i) const
Definition: Rule.cpp:157
The FeatureTypeStyle defines the styling that is to be applied to a dataset that can be viewed as a f...
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
This is the base class for layers.
Definition: AbstractLayer.h:76
void setGraphic(te::se::Graphic *newGraphic)
It sets the he scatter&#39;s graphic.
A wdiget used to display a chart.
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
A PolygonSymbolizer is used to draw a polygon (or other area-type geometries), including filling its ...
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
A class used to define the style of a histogram&#39;s chart.
Stroke * clone() const
It creates a new copy of this object.
Definition: Stroke.cpp:158
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
Definition: CoverageStyle.h:45
void setStroke(te::se::Stroke *newStroke)
It sets the scatter point&#39;s stroke.
Fill * clone() const
It creates a new copy of this object.
Definition: Fill.cpp:86
const Stroke * getStroke() const
const Stroke * getStroke() const
Gets the Stroke associates with the PolygonSymbolizer.
A PointSymbolizer specifies the rendering of a graphic Symbolizer at a point.
Graphic * clone() const
It creates a new copy of this object.
Definition: Graphic.cpp:167
A Symbology Enconding visitor that configures a given chart based on symbolizer elements.
const Graphic * getGraphic() const
A TextSymbolizer is used to render text labels according to various graphical parameters.
ChartConfigurer(ChartDisplayWidget *chart)
Constructor.
void config(const te::se::Symbolizer *symbolizer)
It configs the chart based on given symbolizer.
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
void visit(const te::se::Style &visited)
ChartDisplayWidget * m_chart
A pointer to the chart that will be configured.
void setFill(te::se::Fill *newFill)
It sets the histogram bar&#39;s fill.
A class to represent a scatter chart.
Definition: ScatterChart.h:55
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
A class to represent a histogram chart.
void setFill(te::se::Fill *newFill)
It sets the scatter point&#39;s fill.
const Fill * getFill() const
Gets the Fill associates with the PolygonSymbolizer.
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