16 #include "labelposition.h"
20 QList<QgsLabelPosition*>* list =
static_cast< QList<QgsLabelPosition*>*
>( context );
21 list->push_back( pos );
36 double c_min[2]; c_min[0] = p.
x() - 0.1; c_min[1] = p.
y() - 0.1;
37 double c_max[2]; c_max[0] = p.
x() + 0.1; c_max[1] = p.
y() + 0.1;
39 QList<QgsLabelPosition*> searchResults;
44 QList<QgsLabelPosition*>::const_iterator resultIt = searchResults.constBegin();
45 for ( ; resultIt != searchResults.constEnd(); ++resultIt )
47 if (( *resultIt )->labelRect.contains( p ) )
49 posList.push_back( *resultIt );
59 QList<QgsLabelPosition*> searchResults;
63 QList<QgsLabelPosition*>::const_iterator resultIt = searchResults.constBegin();
64 for ( ; resultIt != searchResults.constEnd(); ++resultIt )
66 posList.push_back( *resultIt );
70 bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos,
int featureId,
const QString& layerName,
const QString& labeltext,
const QFont& labelfont,
bool diagram,
bool pinned )
79 labelPos->getBoundingBox( c_min, c_max );
81 QVector<QgsPoint> cornerPoints;
82 for (
int i = 0; i < 4; ++i )
84 cornerPoints.push_back(
QgsPoint( labelPos->getX( i ), labelPos->getY( i ) ) );
87 labelPos->getWidth(), labelPos->getHeight(), layerName, labeltext, labelfont, labelPos->getUpsideDown(), diagram, pinned );
94 RTree<QgsLabelPosition*, double, 2, double>::Iterator indexIt;
A rectangle specified with double values.
void label(const QgsPoint &p, QList< QgsLabelPosition * > &posList) const
Returns label position(s) at a given point.
double yMaximum() const
Get the y maximum value (top side of rectangle)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
bool searchCallback(QgsLabelPosition *pos, void *context)
A class to represent a point geometry.
bool insertLabel(LabelPosition *labelPos, int featureId, const QString &layerName, const QString &labeltext, const QFont &labelfont, bool diagram=false, bool pinned=false)
Inserts label position.
void clear()
Removes and deletes all the entries.
RTree< QgsLabelPosition *, double, 2, double > mSpatialIndex
void labelsInRect(const QgsRectangle &r, QList< QgsLabelPosition * > &posList) const
Returns label position(s) in given rectangle.
double xMinimum() const
Get the x minimum value (left side of rectangle)