30 #include "../../core/pattern/singleton/Context.h" 
   31 #include "../../core/pattern/mvc/ItemController.h" 
   32 #include "../core/Scene.h" 
   33 #include "../../core/pattern/mvc/Observable.h" 
   34 #include "../../../color/RGBAColor.h" 
   35 #include "../../../qt/widgets/Utils.h" 
   36 #include "../../../geometry/Envelope.h" 
   37 #include "../../../geometry/Geometry.h" 
   38 #include "../../../geometry/Polygon.h" 
   39 #include "../../../geometry/LinearRing.h" 
   40 #include "../../../common/STLUtils.h" 
   41 #include "../../item/LegendModel.h" 
   42 #include "../../../maptools/AbstractLayer.h" 
   43 #include "../../../maptools/GroupingItem.h" 
   44 #include "../../../maptools/Canvas.h" 
   45 #include "../../../maptools/CanvasConfigurer.h" 
   46 #include "../../../qt/widgets/canvas/Canvas.h" 
   47 #include "../../../se/Symbolizer.h" 
   48 #include "../../../se/PolygonSymbolizer.h" 
   49 #include "../../../se/Fill.h" 
   50 #include "../../../se/Utils.h" 
   51 #include "../../../color/RGBAColor.h" 
   57 #include <QStyleOption> 
   59 #include <QPaintDevice> 
   67   this->setFlags(QGraphicsItem::ItemIsMovable
 
   68     | QGraphicsItem::ItemIsSelectable
 
   69     | QGraphicsItem::ItemSendsGeometryChanges
 
   70     | QGraphicsItem::ItemIsFocusable);
 
   72   m_nameClass = std::string(this->metaObject()->className());
 
   98   this->setRect(QRectF(0, 0, widthInPixels, heightInPixels));
 
  110   if (legendModel == 0)
 
  115   drawBackground(painter);
 
  124     if (option->state & QStyle::State_Selected)
 
  126       drawSelection(painter);
 
  132   std::string title = layer->getTitle();
 
  134   QString qTitle (title.c_str());
 
  136   QRectF boundRect = this->boundingRect();
 
  137   QMatrix matrix = painter->matrix();
 
  152   double x1 = boundRect.x() + borderDisplacementInPixels;
 
  153   double y1 = boundRect.y() + borderDisplacementInPixels;
 
  160   double wtxtInPixels = 0.;
 
  161   double htxtInPixels = 0.;
 
  165   wtxtInPixels = utils->
mm2pixel(wtxtInPixels);
 
  166   htxtInPixels = utils->
mm2pixel(htxtInPixels);
 
  168   QRectF rectTitle (x1, y1, wtxtInPixels, htxtInPixels);
 
  170   painter->setFont(qfont);
 
  171   painter->setBrush(qFontColor);
 
  172   painter->drawText(rectTitle, qTitle);
 
  175   y1 += htxtInPixels + dispBetweenTitleAndSymbolsInPixels;
 
  179   if (grouping != 0 && grouping->
isVisible() == 
true)
 
  187     double labelX1 = x1 + symbolSizeInPixels + dispBetweenSymbolAndTextInPixels;
 
  189     for (
unsigned int i = 0; i < items.size(); ++i)
 
  191       std::string label = propertyName;
 
  210       QRectF labelRect (labelX1, y1, boundRect.width(), boundRect.height());
 
  211       QString qLabel (label.c_str());
 
  212       painter->setFont(qfont);
 
  213       painter->setBrush(qFontColor);
 
  214       painter->drawText(labelRect, qLabel);
 
  217       const std::vector<te::se::Symbolizer*>& symbolizers = item->
getSymbolizers();
 
  225         QRectF geomRect (x1, y1, symbolSizeInPixels, symbolSizeInPixels);
 
  228         if (symbol->
getType() == 
"PolygonSymbolizer")
 
  232           ring->
setPoint(0, x1 + offset, y1 + offset);
 
  233           ring->
setPoint(1, x1 + geomRect.width() - offset, y1 + offset);
 
  234           ring->
setPoint(2, x1 + geomRect.width() - offset, y1 + geomRect.height() - offset);
 
  235           ring->
setPoint(3, x1 + offset, y1 + geomRect.height() - offset);
 
  236           ring->
setPoint(4, x1 + offset, y1 + offset);
 
  240         else if (symbol->
getType() == 
"LineSymbolizer")
 
  243           line->
setPoint(0, x1 + offset, y1 + geomRect.height() * 0.5);
 
  244           line->
setPoint(1, x1 + geomRect.width() - offset, y1 + geomRect.height() * 0.5);
 
  247         else if (symbol->
getType() == 
"PointSymbolizer")
 
  249           geom = 
new te::gm::Point( x1 +geomRect.width() * 0.5, y1 +geomRect.height() * 0.5);
 
  257         geomCanvas.draw(geom);
 
  261       y1 += htxtInPixels + dispBetweenSymbolsInPixels;
 
  266   if (option->state & QStyle::State_Selected)
 
  268     drawSelection(painter);
 
  276   if(change == QGraphicsItem::ItemPositionChange && !m_move)
 
  279     QPointF newPos = value.toPointF();
 
  282     newPos.setX(newPos.x() - transform().dx());
 
  283     newPos.setY(newPos.y() - transform().dy() + h);
 
  286   else if(change == QGraphicsItem::ItemPositionHasChanged)
 
  292   return QGraphicsItem::itemChange(change, value);
 
  299   QGraphicsItem::mouseMoveEvent(event);
 
virtual double getDisplacementBetweenTitleAndSymbols()
 
Abstract class to represent an observable. "Model" part of MVC component. 
 
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...
 
bool isStrikeout()
Returns true if font use strikeout, false otherwise. 
 
int getRed() const 
It returns the red component color value (a value from 0 to 255). 
 
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. 
 
virtual void updateObserver(ContextItem context)
Reimplemented from ObjectItem. 
 
std::string getPropertyName() const 
It gets the property name whose values will be grouped. 
 
int getPointSize()
Returns point size of the font. 
 
virtual te::map::AbstractLayerPtr getLayer()
 
int getBlue() const 
It returns the blue component color value (a value from 0 to 255). 
 
virtual te::color::RGBAColor getFontColor()
 
int getGreen() const 
It returns the green component color value (a value from 0 to 255). 
 
double getWidth() const 
It returns the envelope width. 
 
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
 
virtual ~LegendItem()
Destructor. 
 
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Mandatory implementation from QGraphicsObject. 
 
This class contains the parameters needed for grouping the values of a Property. 
 
A LinearRing is a LineString that is both closed and simple. 
 
virtual void setTextUnderline(bool b)=0
It sets the text underline flag. 
 
virtual int mm2pixel(double mm)
Millimeter to pixel. 
 
LineString is a curve with linear interpolation between points. 
 
Abstract class that represents a graphic item. This object is of type QGraphicsObject. 
 
static Context & getInstance()
It returns a reference to the singleton instance. 
 
A point with x and y coordinate values. 
 
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point. 
 
An Envelope defines a 2D rectangular region. 
 
A GroupingItem contains information about a grouping item associated to a layer. 
 
virtual Utils * getUtils()
 
virtual double getDisplacementBetweenSymbols()
 
virtual void setTextColor(const te::color::RGBAColor &color)=0
It sets the text drawing color. 
 
Utils * getUtils()
Returns pointer with functions to manipulate the canvas and conversion between projections. 
 
int getAlpha() const 
It returns the alpha component color value (a value from 0 to 255). 
 
std::string m_nameClass
Class name. 
 
bool isUnderline()
Returns true if font use underline, false otherwise. 
 
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards. 
 
LegendItem(ItemController *controller, Observable *o)
Constructor. 
 
virtual void setTextStrikeOut(bool b)=0
It sets the text strike out flag. 
 
A canvas is an abstraction of a drawing area. 
 
bool isVisible() const 
It gets the grouping visibility. 
 
const std::vector< te::map::GroupingItem * > & getGroupingItems() const 
It gets the vector of grouping items. 
 
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings. 
 
GroupingType
The grouping type associated to the layer. 
 
const std::string & getUpperLimit() const 
It gets the upper limit value of the legend item. 
 
virtual double getBorderDisplacement()
 
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsItem. 
 
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Reimplemented from QGraphicsItem. 
 
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color. 
 
const GroupingType getType() const 
It gets the grouping type. 
 
std::string getFamily()
Sets font family name. 
 
const std::string & getLowerLimit() const 
It gets the lower limit value of the legend item. 
 
const std::vector< te::se::Symbolizer * > & getSymbolizers() const 
It gets the symbolizer of the legend item. 
 
virtual const std::string & getType() const =0
It returns the symbolizer type. 
 
Utility class with functions to manipulate the canvas and conversion between projections. 
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
double getHeight() const 
It returns the envelope height. 
 
bool isValid() const 
It tells if the rectangle is valid or not. 
 
virtual double getDisplacementBetweenSymbolAndText()
 
te::map::Canvas * getCanvas()
Returns abstraction of a drawing area. 
 
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one. 
 
virtual void setTextPointSize(double size)=0
It sets the text point Size.