@@ -151,10 +151,30 @@ void QgsMapToolOffsetCurve::canvasMoveEvent( QMouseEvent * e )
151
151
152
152
// get offset from current position rectangular to feature
153
153
QgsPoint layerCoords = toLayerCoordinates ( layer, e->pos () );
154
+
155
+ // snap cursor to background layers
156
+ QList<QgsSnappingResult> results;
157
+ QList<QgsPoint> snapExcludePoints;
158
+ if ( mSnapper .snapToBackgroundLayers ( e->pos (), results ) == 0 )
159
+ {
160
+ if ( results.size () > 0 )
161
+ {
162
+ QgsSnappingResult snap = results.at ( 0 );
163
+ if ( snap.layer && snap.layer ->id () != mSourceLayerId && snap.snappedAtGeometry != mModifiedFeature )
164
+ {
165
+ layerCoords = results.at ( 0 ).snappedVertex ;
166
+ }
167
+ }
168
+ }
169
+
154
170
QgsPoint minDistPoint;
155
171
int beforeVertex;
156
172
double leftOf;
157
173
double offset = sqrt ( mOriginalGeometry ->closestSegmentWithContext ( layerCoords, minDistPoint, beforeVertex, &leftOf ) );
174
+ if ( !offset > 0 )
175
+ {
176
+ return ;
177
+ }
158
178
159
179
// create offset geometry using geos
160
180
setOffsetForRubberBand ( offset, leftOf < 0 );
@@ -239,7 +259,7 @@ void QgsMapToolOffsetCurve::createDistanceItem()
239
259
mDistanceItem = 0 ;
240
260
QgisApp::instance ()->statusBar ()->addWidget ( mDistanceSpinBox );
241
261
#endif
242
- mDistanceSpinBox ->grabKeyboard ();
262
+ // mDistanceSpinBox->grabKeyboard();
243
263
mDistanceSpinBox ->setFocus ( Qt::TabFocusReason );
244
264
245
265
QObject::connect ( mDistanceSpinBox , SIGNAL ( editingFinished () ), this , SLOT ( placeOffsetCurveToValue () ) );
0 commit comments