27 #include "../../../../color/RGBAColor.h"
28 #include "../../../../common/StringUtils.h"
29 #include "../../../../geometry/GeometryProperty.h"
30 #include "../../../../maptools/Enums.h"
31 #include "../../../../maptools/Grouping.h"
32 #include "../../../../maptools/GroupingItem.h"
33 #include "../../../../se/Categorize.h"
34 #include "../../../../se/ChannelSelection.h"
35 #include "../../../../se/ColorMap.h"
36 #include "../../../../se/ContrastEnhancement.h"
37 #include "../../../../se/CoverageStyle.h"
38 #include "../../../../se/FeatureTypeStyle.h"
39 #include "../../../../se/Fill.h"
40 #include "../../../../se/LineSymbolizer.h"
41 #include "../../../../se/ParameterValue.h"
42 #include "../../../../se/PolygonSymbolizer.h"
43 #include "../../../../se/PointSymbolizer.h"
44 #include "../../../../se/RasterSymbolizer.h"
45 #include "../../../../se/Rule.h"
46 #include "../../../../se/SelectedChannel.h"
47 #include "../../../../se/Style.h"
48 #include "../../../../se/Stroke.h"
49 #include "../../../../se/Utils.h"
50 #include "../../../../terralib4/Utils.h"
54 #include <terralib4/kernel/TeAbstractTheme.h>
55 #include <terralib4/kernel/TeDataTypes.h>
56 #include <terralib4/kernel/TeLegendEntry.h>
57 #include <terralib4/kernel/TeRaster.h>
58 #include <terralib4/kernel/TeRasterTransform.h>
59 #include <terralib4/kernel/TeTheme.h>
60 #include <terralib4/kernel/TeVisual.h>
63 #include <boost/lexical_cast.hpp>
66 #include <QtGui/QColor>
105 case TeLnTypeDashDot:
107 case TeLnTypeDashDotDot:
108 return "4 2 1 2 1 2";
111 case TeLnTypeContinuous:
126 case TePtTypeHollowCircle:
131 case TePtTypeHollowBox:
133 case TePtTypeDiamond:
134 case TePtTypeHollowDiamond:
145 case TePtTypeHollowCircle:
147 case TePtTypeHollowBox:
149 case TePtTypeHollowDiamond:
162 TeRasterVisual* vis = 0;
163 vis = theme->rasterVisual();
166 TeRaster* raster = theme->layer()->raster();
167 theme->createRasterVisual(raster);
168 vis = theme->rasterVisual();
176 TeLegendEntry legend = theme->defaultLegend();
178 TeGeomRepVisualMap visualMap = legend.getVisualMap();
180 TeVisual* visual = 0;
186 visual = visualMap[TePOLYGONS];
192 visual = visualMap[TeLINES];
198 visual = visualMap[TePOINTS];
246 TeColor tl4Color = visual->color();
250 std::string width = boost::lexical_cast<std::string>(visual->contourWidth());
254 std::string style =
GetLineStyle(visual->contourStyle());
261 stroke->setDashArray(style);
266 double numericOpacity = (100-visual->transparency())/100.0;
267 std::string opacity = boost::lexical_cast<std::string>(numericOpacity);
277 std::string width = boost::lexical_cast<std::string>(visual->width());
288 stroke->setDashArray(style);
307 std::string size = boost::lexical_cast<std::string>(visual->size());
316 TeLegendEntryVector leg = theme->legend();
317 TeGrouping group = theme->grouping();
319 TeAttributeRep attr = group.groupAttribute_;
320 std::string propertyName = attr.name_;
321 std::vector<std::string> tokens;
323 propertyName = tokens[1];
325 TeGroupingMode mode = group.groupMode_;
327 std::size_t precision =
static_cast<std::size_t
>(group.groupPrecision_);
328 int slices = group.groupNumSlices_;
329 double stdDeviation = group.groupStdDev_;
335 std::vector<te::map::GroupingItem*> items;
337 for(
int i = 0; i < slices; ++i)
341 TeLegendEntry le = leg[i];
343 std::string title = le.label();
347 std::string fromValue = le.from();
348 std::string toValue = le.to();
350 if(mode == TeUniqueValue)
360 std::vector<te::se::Symbolizer*> symbs;
362 TeGeomRepVisualMap map = le.getVisualMap();
364 TeGeomRep geomRep = map.begin()->first;
365 TeVisual* visual = map.begin()->second;
371 items.push_back(item);
381 TeLegendEntryVector leg = theme->legend();
382 TeGrouping group = theme->grouping();
384 int slices = group.groupNumSlices_;
391 QColor cWhite(Qt::white);
392 std::string colorWhiteStr = cWhite.name().toLatin1().data();
397 for(
int i = 0; i < slices; ++i)
399 TeLegendEntry le = leg[i];
401 std::string title = le.label();
403 TeGeomRepVisualMap map = le.getVisualMap();
405 TeGeomRep geomRep = map.begin()->first;
406 TeVisual* visual = map.begin()->second;
408 QColor color(visual->color().red_, visual->color().green_, visual->color().blue_, 0);
410 std::string rangeStr = le.from();
411 std::string colorStr = color.name().toStdString();
438 double opacity = ((visual->getTransparency()*100.0)/255)/100.0;
440 double gain = visual->getGain();
446 TeRasterTransform::TeRasterTransfFunctions func = visual->getTransfFunction();
455 if (func == TeRasterTransform::TeBand2Band)
469 else if (func == TeRasterTransform::TeExtractBand)
472 short db = visual->getDestBand();
474 if (db == TeRasterTransform::TeREDCHANNEL)
483 else if (db == TeRasterTransform::TeGREENCHANNEL)
492 else if (db == TeRasterTransform::TeBLUECHANNEL)
502 else if (func == TeRasterTransform::TeMono2Three)
511 else if (func == TeRasterTransform::TeExtractRGB)
513 std::map<TeRasterTransform::TeRGBChannels,short>& RGBmap = visual->getRGBMap();
516 scRed->
setSourceChannelName(boost::lexical_cast<std::string>(RGBmap[TeRasterTransform::TeREDCHANNEL]));
519 scGreen->
setSourceChannelName(boost::lexical_cast<std::string>(RGBmap[TeRasterTransform::TeGREENCHANNEL]));
522 scBlue->
setSourceChannelName(boost::lexical_cast<std::string>(RGBmap[TeRasterTransform::TeBLUECHANNEL]));
527 else if (func == TeRasterTransform::TeThreeBand2RGB)
541 else if (func == TeRasterTransform::TeExtractBands)
544 std::map<TeRasterTransform::TeRGBChannels,short>& RGBmap = visual->getRGBMap();
546 if (RGBmap[TeRasterTransform::TeREDCHANNEL] != -1)
547 scRed->
setSourceChannelName(boost::lexical_cast<std::string>(RGBmap[TeRasterTransform::TeREDCHANNEL]));
548 if (RGBmap[TeRasterTransform::TeGREENCHANNEL] != -1)
549 scGreen->
setSourceChannelName(boost::lexical_cast<std::string>(RGBmap[TeRasterTransform::TeGREENCHANNEL]));
550 if (RGBmap[TeRasterTransform::TeBLUECHANNEL] != -1)
551 scBlue->
setSourceChannelName(boost::lexical_cast<std::string>(RGBmap[TeRasterTransform::TeBLUECHANNEL]));
void setValue(const std::string &value)
It sets value of the legend item.
te::se::Symbolizer * GetSymbolizer(int geometryType, TeVisual *visual)
void setRedChannel(SelectedChannel *c)
A selected channel to be display.
te::color::RGBAColor Convert2TerraLib5(TeColor color)
The transformation of continuous values to distinct values (Categorize function). ...
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
A Mark specifies a geometric shape and applies coloring to it.
te::map::Grouping * GetGrouping(TeTheme *theme)
A PolygonSymbolizer is used to draw a polygon (or other area-type geometries), including filling its ...
void setGroupingItems(std::vector< te::map::GroupingItem * > &items)
It sets the vector of grouping items.
te::se::PointSymbolizer * GetPointSymbolizer(TeVisual *visual)
A Symbolizer describes how a feature is to appear on a map.
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
ParameterValue * getOffset() const
void setGain(ParameterValue *p)
void setLookupValue(ParameterValue *v)
A PointSymbolizer specifies the rendering of a graphic Symbolizer at a point.
void setCategorize(Categorize *c)
void push_back(const std::string &semanticTypeIdentifier)
void setGrayChannel(SelectedChannel *c)
void setStdDeviation(double stdDeviation)
It sets the standard deviation for the Standard Deviation grouping.
TESEEXPORT LineSymbolizer * CreateLineSymbolizer(Stroke *stroke)
Creates a line symbolizer.
void setTitle(const std::string &title)
It sets the title of the legend item.
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
TESEEXPORT PolygonSymbolizer * CreatePolygonSymbolizer(Stroke *stroke, Fill *fill)
Creates a polygon symbolizer.
void push_back(Symbolizer *s)
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
std::auto_ptr< te::dt::Property > Convert2T5(const TeAttributeRep &attRep)
It creates a valid TerraLib 5 property given a valid TerraLib 4.x attribute representation.
This class contains the parameters needed for grouping the values of a Property.
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
te::gm::GeomType Convert2T5GeomType(TeAttrDataType type)
A GroupingItem contains information about a grouping item associated to a layer.
The FeatureTypeStyle defines the styling that is to be applied to a dataset that can be viewed as a f...
void setColorCompositionType(ColorCompositionType cct)
void setChannelSelection(ChannelSelection *c)
te::se::PolygonSymbolizer * GetPolygonSymbolizer(TeVisual *visual)
void setPropertyType(const int &type)
It sets the property type whose values will be grouped.
TESEEXPORT Graphic * CreateGraphic(Mark *mark, const std::string &size, const std::string &rotation, const std::string &opacity)
Creates a graphic.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
A Fill specifies the pattern for filling an area geometry.
void setOpacity(ParameterValue *p)
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
TESEEXPORT Stroke * CreateStroke(const std::string &color, const std::string &width)
Creates a stroke.
te::map::GroupingType GetGroupingType(TeGroupingMode mode)
te::se::RasterSymbolizer * GetRasterSymbolizer(TeRasterTransform *visual)
GroupingType
The grouping type associated to the layer.
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
void setOffset(ParameterValue *p)
A Stroke specifies the appearance of a linear geometry.
te::se::LineSymbolizer * GetLineSymbolizer(TeVisual *visual)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
void setUpperLimit(const std::string &to)
It sets the upper limit value of the legend item.
void setSourceChannelName(const std::string &name)
std::string GetLineStyle(int type)
A LineSymbolizer is used to style a stroke along a linear geometry type, such as a string of line seg...
te::se::ColorMap * GetRasterGrouping(TeTheme *theme)
void setBlueChannel(SelectedChannel *c)
std::string GetPointStyle(int type)
void setThresholdsBelongTo(ThresholdsBelongToType t)
void addThreshold(ParameterValue *v)
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
void addValue(ParameterValue *v)
void setFallbackValue(const std::string &v)
TESEEXPORT PointSymbolizer * CreatePointSymbolizer(Graphic *graphic)
Creates a point symbolizer.
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.
void setGreenChannel(SelectedChannel *c)
void setSymbolizers(const std::vector< te::se::Symbolizer * > &symbolizers)
It sets the symbolizers of the legend item.
ChannelSelection specifies the false-color channel selection for a multi-spectral raster source (such...
void setLowerLimit(const std::string &from)
It sets the lower limit value of the legend item.