2525#include " qgsvectorlayer.h"
2626
2727#include " qgsmaptoolselectutils.h"
28- #include " qgshighlight.h"
2928#include " qgsrubberband.h"
3029#include < qgslogger.h>
3130#include < QMouseEvent>
@@ -137,35 +136,22 @@ void QgsMapToolPinLabels::updatePinnedLabels()
137136 }
138137}
139138
140- void QgsMapToolPinLabels::highlightLabel ( QgsVectorLayer* vlayer,
141- const QgsLabelPosition& labelpos,
139+ void QgsMapToolPinLabels::highlightLabel ( const QgsLabelPosition& labelpos,
142140 const QString& id,
143141 const QColor& color )
144142{
145143 QgsRectangle rect = labelpos.labelRect ;
146-
147- const QgsMapSettings& ms = mCanvas ->mapSettings ();
148- if ( vlayer->crs ().isValid () && ms.destinationCrs ().isValid () )
149- {
150- // if label's layer is on-fly transformed, reverse-transform label rect
151- // QgsHighlight will convert it, yet again, to the correct map coords
152- if ( vlayer->crs () != ms.destinationCrs () )
153- {
154- rect = ms.mapToLayerCoordinates ( vlayer, rect );
155- QgsDebugMsg ( QString ( " Reverse transform needed for highlight rectangle" ) );
156- }
157- }
158-
159- QgsGeometry* highlightgeom = QgsGeometry::fromRect ( rect );
160-
161- QgsHighlight *h = new QgsHighlight ( mCanvas , highlightgeom, vlayer );
162- if ( h )
163- {
164- h->setWidth ( 0 );
165- h->setColor ( color );
166- h->show ();
167- mHighlights .insert ( id, h );
168- }
144+ QgsRubberBand *rb = new QgsRubberBand ( mCanvas , QGis::Polygon );
145+ rb->addPoint ( QgsPoint ( rect.xMinimum (), rect.yMinimum () ) );
146+ rb->addPoint ( QgsPoint ( rect.xMinimum (), rect.yMaximum () ) );
147+ rb->addPoint ( QgsPoint ( rect.xMaximum (), rect.yMaximum () ) );
148+ rb->addPoint ( QgsPoint ( rect.xMaximum (), rect.yMinimum () ) );
149+ rb->addPoint ( QgsPoint ( rect.xMinimum (), rect.yMinimum () ) );
150+ rb->setColor ( color );
151+ rb->setWidth ( 0 );
152+ rb->show ();
153+
154+ mHighlights .insert ( id, rb );
169155}
170156
171157// public slot to render highlight rectangles around pinned labels
@@ -209,7 +195,7 @@ void QgsMapToolPinLabels::highlightPinnedLabels()
209195 continue ;
210196 }
211197
212- QColor lblcolor = QColor ( 54 , 129 , 255 , 255 );
198+ QColor lblcolor = QColor ( 54 , 129 , 255 , 63 );
213199 QgsMapLayer* layer = QgsMapLayerRegistry::instance ()->mapLayer ( mCurrentLabelPos .layerID );
214200 if ( !layer )
215201 {
@@ -223,10 +209,10 @@ void QgsMapToolPinLabels::highlightPinnedLabels()
223209 }
224210 if ( vlayer->isEditable () )
225211 {
226- lblcolor = QColor ( 54 , 129 , 0 , 255 );
212+ lblcolor = QColor ( 54 , 129 , 0 , 63 );
227213 }
228214
229- highlightLabel ( vlayer, ( *it ), labelStringID, lblcolor );
215+ highlightLabel (( *it ), labelStringID, lblcolor );
230216 }
231217 }
232218 QApplication::restoreOverrideCursor ();
@@ -235,9 +221,9 @@ void QgsMapToolPinLabels::highlightPinnedLabels()
235221void QgsMapToolPinLabels::removePinnedHighlights ()
236222{
237223 QApplication::setOverrideCursor ( Qt::BusyCursor );
238- foreach ( QgsHighlight *h , mHighlights )
224+ foreach ( QgsRubberBand *rb , mHighlights )
239225 {
240- delete h ;
226+ delete rb ;
241227 }
242228 mHighlights .clear ();
243229 QApplication::restoreOverrideCursor ();
0 commit comments