26 QList<QgsLabelPosition *> searchResults;
29 searchResults.push_back( const_cast< QgsLabelPosition * >( pos ) );
35 QList<QgsLabelPosition *>::const_iterator resultIt = searchResults.constBegin();
36 for ( ; resultIt != searchResults.constEnd(); ++resultIt )
38 if ( ( *resultIt )->labelGeometry.contains( &p ) )
40 posList.push_back( *resultIt );
47 QList<QgsLabelPosition> res;
48 res.reserve( mOwnedPositions.size() );
49 for (
const std::unique_ptr< QgsLabelPosition > &pos : mOwnedPositions )
58 QList<QgsLabelPosition *> searchResults;
66 QList<QgsLabelPosition *>::const_iterator resultIt = searchResults.constBegin();
67 for ( ; resultIt != searchResults.constEnd(); ++resultIt )
69 if ( ( *resultIt )->labelGeometry.intersects( r ) )
71 posList.push_back( *resultIt );
83 QVector<QgsPointXY> cornerPoints;
84 cornerPoints.reserve( 4 );
85 double xMin = std::numeric_limits< double >::max();
86 double yMin = std::numeric_limits< double >::max();
87 double xMax = std::numeric_limits< double >::lowest();
88 double yMax = std::numeric_limits< double >::lowest();
89 for (
int i = 0; i < 4; ++i )
92 const QPointF res = mTransform.map( QPointF( labelPos->
getX( i ), labelPos->
getY( i ) ) );
94 xMin = std::min( xMin, res.x() );
95 xMax = std::max( xMax, res.x() );
96 yMin = std::min( yMin, res.y() );
97 yMax = std::max( yMax, res.y() );
101 long long uniqueLinkedId = 0;
103 uniqueLinkedId = linkedId;
105 uniqueLinkedId = mNextFeatureId++;
109 std::unique_ptr< QgsLabelPosition > newEntry = std::make_unique< QgsLabelPosition >( featureId, labelPos->
getAlpha() + mMapSettings.
rotation(), cornerPoints, bounds,
110 labelPos->
getWidth(), labelPos->
getHeight(), layerName, labeltext, labelfont, labelPos->
getUpsideDown(), diagram, pinned, providerId, labelGeometry, isUnplaced );
111 newEntry->groupedLabelId = uniqueLinkedId;
112 mSpatialIndex.
insert( newEntry.get(), bounds );
114 if ( uniqueLinkedId != 0 )
116 mLinkedLabelHash[ uniqueLinkedId ].append( newEntry.get() );
119 mOwnedPositions.emplace_back( std::move( newEntry ) );
123 return insertLabel( next, featureId, layerName, labeltext, labelfont, diagram, pinned, providerId, isUnplaced, uniqueLinkedId );
130 const QPointF origin = position.
origin();
131 const QPointF destination = position.
destination();
133 std::unique_ptr< QgsCalloutPosition > newEntry = std::make_unique< QgsCalloutPosition >( position );
135 mCalloutIndex.
insert( newEntry.get(),
QgsRectangle( origin.x(), origin.y(), origin.x(), origin.y() ) );
136 mCalloutIndex.
insert( newEntry.get(),
QgsRectangle( destination.x(), destination.y(), destination.x(), destination.y() ) );
138 mOwnedCalloutPositions.emplace_back( std::move( newEntry ) );
145 QList<const QgsCalloutPosition *> searchResults;
148 searchResults.push_back( pos );
152 std::sort( searchResults.begin(), searchResults.end() );
153 searchResults.erase( std::unique( searchResults.begin(), searchResults.end() ), searchResults.end() );
155 return searchResults;
160 return mLinkedLabelHash.value( groupId );
165 mMapSettings = settings;
171 mTransform = QTransform::fromTranslate( center.
x(), center.
y() );
172 mTransform.rotate( mMapSettings.
rotation() );
173 mTransform.translate( -center.
x(), -center.
y() );
177 mTransform = QTransform();