All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 {
55 }
56 
58 {
59  symbolizer->accept(*this);
60 }
61 
63 {
64  if(layer->getStyle()
65  && !layer->getStyle()->getRules().empty()
66  && !layer->getStyle()->getRule(0)->getSymbolizers().empty())
67  config(layer->getStyle()->getRule(0)->getSymbolizer(0));
68 }
69 
71 {
72 }
73 
75 {
76 }
77 
79 {
80 }
81 
83 {
84 }
85 
87 {
88  const te::se::Stroke* stroke = visited.getStroke();
89  if(stroke)
90  config(stroke);
91 
92  const te::se::Fill* fill = visited.getFill();
93  if(fill)
94  config(fill);
95 }
96 
98 {
99  const te::se::Stroke* stroke = visited.getStroke();
100  if(stroke)
101  config(stroke);
102 }
103 
105 {
106  const te::se::Graphic* graphic = visited.getGraphic();
107  if(graphic)
108  config(graphic);
109 }
110 
112 {
113 }
114 
116 {
117 }
118 
120 {
121  int chartType = m_chart->getChart()->rtti();
122 
123  switch(chartType)
124  {
126  {
127  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
128  style->setStroke(stroke->clone());
129  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
130  break;
131  }
133  {
134  te::qt::widgets::HistogramStyle* style = static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->getHistogramStyle();
135  style->setStroke(stroke->clone());
136  static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->setHistogramStyle(style);
137  break;
138  }
139  }
140 }
141 
143 {
144  int chartType = m_chart->getChart()->rtti();
145 
146  switch(chartType)
147  {
149  {
150  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
151  style->setFill(fill->clone());
152  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
153  break;
154  }
156  {
157  te::qt::widgets::HistogramStyle* style = static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->getHistogramStyle();
158  style->setFill(fill->clone());
159  static_cast<te::qt::widgets::HistogramChart*>(m_chart->getChart())->setHistogramStyle(style);
160  break;
161  }
162  }
163 }
164 
166 {
167  int chartType = m_chart->getChart()->rtti();
168  if(chartType == te::qt::widgets::SCATTER_CHART)
169  {
170  te::qt::widgets::ScatterStyle* style = static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->getScatterStyle();
171  style->setGraphic(graphic->clone());
172  static_cast<te::qt::widgets::ScatterChart*>(m_chart->getChart())->setScatterStyle(style);
173  }
174 }
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's graphic.
This is the base class for layers.
Definition: AbstractLayer.h:76
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 ...
A class used to define the style of a scatter's chart.
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.
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's stroke.
A class used to define the style of a histogram'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'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's fill.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
void setFill(te::se::Fill *newFill)
It sets the scatter point'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's stroke.