31 #include "../core/property/Property.h"
32 #include "../core/property/Properties.h"
33 #include "../core/property/SharedProperties.h"
34 #include "../../maptools/CanvasConfigurer.h"
35 #include "../../se/Symbolizer.h"
36 #include "../../se/Style.h"
37 #include "../../se/Rule.h"
38 #include "../../geometry/Polygon.h"
39 #include "../../geometry/Geometry.h"
40 #include "../../geometry/Envelope.h"
41 #include "../core/enum/Enums.h"
42 #include "../../maptools/GroupingItem.h"
43 #include "../../maptools/Enums.h"
54 m_borderDisplacement(1),
55 m_displacementBetweenSymbols(1),
56 m_displacementBetweenTitleAndSymbols(3),
57 m_displacementBetweenSymbolsAndText(2),
96 if((!canvas) || (!utils))
102 drawBackground(context);
104 childrenFreeMemory();
106 drawLegend(canvas, utils);
121 std::string layerName = m_layer->getTitle();
133 double x1 = m_box.getLowerLeftX() + m_borderDisplacement;
134 double y1 = m_box.getUpperRightY() - m_borderDisplacement - htxt;
135 canvas->
drawText(x1, y1, layerName, 0);
139 if (grouping != 0 && grouping->
isVisible() ==
true)
141 this->drawGroupingLegend(grouping, canvas, utils);
143 else if (m_layer->getStyle() != 0)
145 this->drawStyleLegend(m_layer->getStyle(), canvas, utils);
158 std::string layerName = m_layer->getTitle();
165 double x1 = m_box.getLowerLeftX() + m_borderDisplacement;
166 double y1 = m_box.getUpperRightY() - m_borderDisplacement - htxt;
168 for (
unsigned int i = 0; i < items.size(); ++i)
170 std::string label = propertyName;
190 te::gm::Envelope box(x1, y1 - m_displacementBetweenTitleAndSymbols - (m_displacementBetweenSymbols * i),
191 x1 + m_symbolsize, y1 - m_displacementBetweenTitleAndSymbols - (m_displacementBetweenSymbols * i) - m_symbolsize);
207 std::size_t nRules = m_layer->getStyle()->getRules().size();
213 std::string layerName = m_layer->getTitle();
225 double x1 = m_box.getLowerLeftX() + m_borderDisplacement;
226 double y1 = m_box.getUpperRightY() - m_borderDisplacement - htxt;
228 for(std::size_t i = 0; i < nRules; ++i)
235 const std::vector<te::se::Symbolizer*>& symbolizers = rule->
getSymbolizers();
237 if(symbolizers.empty())
242 std::size_t nSymbolizers = symbolizers.size();
244 for(std::size_t j = 0; j < nSymbolizers; ++j)
253 te::gm::Envelope box(x1, y1 - m_displacementBetweenTitleAndSymbols - (m_displacementBetweenSymbols * j),
254 x1 + m_symbolsize, y1 - m_displacementBetweenTitleAndSymbols - (m_displacementBetweenSymbols * j) - m_symbolsize);
261 std::string* nameRule =
const_cast<std::string*
>(rule->
getName());
262 std::string n = symb->
getName();
266 name = nameRule->c_str();
272 name =
"Legend_" + convert.str();
276 m_coordChildren[coord] = name;
292 pro_mapName.
setName(m_sharedProps->getMapName());
298 m_properties->addProperty(pro_mapName);
304 m_properties->addProperty(pro_font);
307 pro_fontcolor.
setName(
"font_color");
310 m_properties->addProperty(pro_fontcolor);
337 if(!pro_fontColor.
isNull())
351 this->updateBox(context);
359 m_borderDisplacement = value;
364 return m_borderDisplacement;
369 m_displacementBetweenSymbols = value;
374 return m_displacementBetweenSymbols;
379 m_displacementBetweenTitleAndSymbols = value;
384 return m_displacementBetweenTitleAndSymbols;
389 m_displacementBetweenSymbolsAndText = value;
394 return m_displacementBetweenSymbolsAndText;
399 return m_coordChildren;
404 std::map<te::gm::Point*, std::string>::iterator it;
405 for(it = m_coordChildren.begin() ; it != m_coordChildren.end() ; ++it)
414 m_coordChildren.clear();
445 std::string title = m_layer->getTitle();
454 double sumWidth = (double) (m_borderDisplacement + wtxt + m_borderDisplacement);
456 if (boxWidth < sumWidth)
463 double sumHeight = (double) (m_borderDisplacement + htxt + m_displacementBetweenTitleAndSymbols);
465 if (boxHeight < sumHeight)
469 boxHeight = sumHeight;
474 if (grouping != 0 && grouping->
isVisible() ==
true)
482 for (
unsigned int i = 0; i < items.size(); ++i)
484 std::string label = propertyName;
505 sumWidth = (double) (m_borderDisplacement + m_symbolsize + m_displacementBetweenSymbolsAndText + wtxt + m_borderDisplacement);
507 if (boxWidth < sumWidth)
514 sumHeight += (double) (htxt + m_displacementBetweenSymbols);
516 if (boxHeight < sumHeight)
520 boxHeight = sumHeight;
524 else if (m_layer->getStyle() != 0)
531 this->notifyAll(context);
542 m_symbolsize = value;
virtual double getDisplacementBetweenTitleAndSymbols()
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Class that represents a "Model" part of Legend MVC component. Its coordinate system is the same of sc...
virtual ~LegendModel()
Destructor.
virtual void setPixmap(te::color::RGBAColor **pixmap)
Stores pixmap generated after drawing.
Variant getValue()
Returns stored value.
virtual EnumDataType * getEnumDataType()
Returns data type enumeration.
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
void addOption(Variant variant)
virtual double getSymbolSize()
virtual void textBoundingBox(double &w, double &h, std::string txt)
A method that calculates the height and width of a text.
const std::string & getValue() const
It gets the value of the legend item.
A Symbolizer describes how a feature is to appear on a map.
bool isNull()
Returns true if no value has been set, false otherwise.
virtual void setDisplacementBetweenTitleAndSymbols(double value)
virtual void drawRectW(te::gm::Envelope box)
Draw a rectangle in world coordinates (mm).
te::color::RGBAColor m_fontColor
std::string getPropertyName() const
It gets the property name whose values will be grouped.
virtual void drawText(int x, int y, const std::string &txt, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)=0
It draws a text.
virtual te::map::AbstractLayerPtr getLayer()
Variant getOptionByCurrentChoice()
virtual te::color::RGBAColor getFontColor()
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
double getWidth() const
It returns the envelope width.
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
void setPointSize(int point)
Sets point size of the font.
virtual std::map< te::gm::Point *, std::string > getCoordChildren()
EnumType * m_type
type of the MVC component
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Font toFont()
Returns the value of te::layout::Font type. (The setValue method received a te::layout::Font). Complex type.
Rule * getRule(std::size_t i) const
This class contains the parameters needed for grouping the values of a Property.
virtual void setTextUnderline(bool b)=0
It sets the text underline flag.
virtual void setSymbolSize(const double &value)
static Enums & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
A GroupingItem contains information about a grouping item associated to a layer.
virtual Utils * getUtils()
const std::string & getName() const
virtual double getDisplacementBetweenSymbols()
Class to represent a data type enumeration. Ex.: int, double, bool, te::color::RGBAColor (color)...
te::gm::Envelope m_box
bounding rectangle
virtual te::map::AbstractLayerPtr getLayer()
virtual void drawGroupingLegend(te::map::Grouping *grouping, te::map::Canvas *canvas, Utils *utils)
Class that represents a "Model" part of Map MVC component. Its coordinate system is the same of scene...
virtual void setTextColor(const te::color::RGBAColor &color)=0
It sets the text drawing color.
virtual Properties * getProperties() const
Reimplemented from Observable.
Class acts like a union for some C++/TerraLib5 data types. Responsible for storing the value...
virtual EnumType * getDataTypeColor() const
Returns value that represents type te::color::RGBAColor** (color) belonging to enumeration.
virtual void visitDependent(ContextItem context)
visit and if necessary redraw
virtual te::map::Canvas * getCanvas()
Return canvas.
LegendModel()
Constructor.
virtual void setDisplacementBetweenSymbolAndText(double value)
Class that represents a "Model" part of Map MVC component. Its coordinate system is the same of scene...
const std::vector< Symbolizer * > & getSymbolizers() const
virtual void draw(ContextItem context)
Drawing method of the MVC component.
virtual void setTextStrikeOut(bool b)=0
It sets the text strike out flag.
virtual void setDisplacementBetweenSymbols(double value)
A canvas is an abstraction of a drawing area.
bool isVisible() const
It gets the grouping visibility.
virtual Properties * getProperties() const
Reimplemented from Observable.
const std::vector< te::map::GroupingItem * > & getGroupingItems() const
It gets the vector of grouping items.
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...
const std::string & getUpperLimit() const
It gets the upper limit value of the legend item.
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
virtual void drawLegend(te::map::Canvas *canvas, Utils *utils)
double m_ury
Upper right corner y-coordinate.
virtual double getBorderDisplacement()
virtual te::color::RGBAColor ** getImageW(te::gm::Envelope boxmm)
Returns a pointer RGBA colors that representing an image.
virtual void childrenFreeMemory()
virtual EnumType * getDataTypeFont() const
Returns value that represents type Font belonging to enumeration.
virtual EnumType * getDataTypeStringList() const
Returns value that represents type StringList (string) belonging to enumeration.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
const GroupingType getType() const
It gets the grouping type.
virtual void drawStyleLegend(te::se::Style *style, te::map::Canvas *canvas, Utils *utils)
std::string toString()
Returns the value of string type. (The setValue method received a string)
std::string convert(const path &v)
URI path to string.
virtual void configCanvas(te::gm::Envelope box, bool resize=true, bool applyZoom=true)
Sets the viewport and window of the canvas. The viewport is only changed if the resize parameter is t...
void setName(std::string name)
Sets the name of this property.
virtual void setMenu(bool menu)
Sets true if property will be used in a menu, false otherwise.
te::color::RGBAColor toColor()
Returns the value of te::color::RGBAColor type. (The setValue method received a te::color::RGBAColor)...
virtual EnumType * getDataTypeString() const
Returns value that represents type string belonging to enumeration.
const std::string & getLowerLimit() const
It gets the lower limit value of the legend item.
Utility class with functions to manipulate the canvas and conversion between projections.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
virtual bool isResizeCanvas()
Returns whether the canvas should or should not be resized.
double getHeight() const
It returns the envelope height.
virtual bool contains(Property property)
Checks if the property is contained within the set of properties.
A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object. Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
virtual double getDisplacementBetweenSymbolAndText()
virtual void setBorderDisplacement(double value)
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
virtual void updateBox(ContextItem context)
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
virtual void setTextPointSize(double size)=0
It sets the text point Size.
const std::string * getName() const