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;
40 mSpatialIndex.Search( c_min, c_max,
searchCallback, &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;
60 mSpatialIndex.Search( c_min, c_max,
searchCallback, &searchResults );
63 QList<QgsLabelPosition*>::const_iterator resultIt = searchResults.constBegin();
64 for ( ; resultIt != searchResults.constEnd(); ++resultIt )
66 posList.push_back( *resultIt );
81 QVector<QgsPoint> cornerPoints;
82 for (
int i = 0; i < 4; ++i )
84 cornerPoints.push_back(
QgsPoint( labelPos->
getX( i ), labelPos->
getY( i ) ) );
88 mSpatialIndex.Insert( c_min, c_max, newEntry );
95 mSpatialIndex.GetFirst( indexIt );
96 while ( !mSpatialIndex.IsNull( indexIt ) )
98 delete mSpatialIndex.GetAt( indexIt );
99 mSpatialIndex.GetNext( indexIt );
101 mSpatialIndex.RemoveAll();
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)
void getBoundingBox(double amin[2], double amax[2]) const
return bounding box - amin: xmin,ymin - amax: xmax,ymax
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double getY(int i=0) const
get the down-left y coordinate
double xMaximum() const
Get the x maximum value (right side of rectangle)
double getAlpha() const
get alpha
bool searchCallback(QgsLabelPosition *pos, void *context)
A class to represent a point.
bool insertLabel(LabelPosition *labelPos, int featureId, const QString &layerName, const QString &labeltext, const QFont &labelfont, bool diagram=false, bool pinned=false)
Inserts label position.
bool getUpsideDown() const
void clear()
Removes and deletes all the entries.
LabelPositon is a candidate feature label position.
double getX(int i=0) const
get the down-left x coordinate
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)