Skip to content

Commit d7941b1

Browse files
committedFeb 20, 2012
Offset curve: snap to background layers in mouse move
1 parent 68b251f commit d7941b1

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed
 

‎src/app/qgsmaptooloffsetcurve.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,30 @@ void QgsMapToolOffsetCurve::canvasMoveEvent( QMouseEvent * e )
151151

152152
//get offset from current position rectangular to feature
153153
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+
154170
QgsPoint minDistPoint;
155171
int beforeVertex;
156172
double leftOf;
157173
double offset = sqrt( mOriginalGeometry->closestSegmentWithContext( layerCoords, minDistPoint, beforeVertex, &leftOf ) );
174+
if ( !offset > 0 )
175+
{
176+
return;
177+
}
158178

159179
//create offset geometry using geos
160180
setOffsetForRubberBand( offset, leftOf < 0 );
@@ -239,7 +259,7 @@ void QgsMapToolOffsetCurve::createDistanceItem()
239259
mDistanceItem = 0;
240260
QgisApp::instance()->statusBar()->addWidget( mDistanceSpinBox );
241261
#endif
242-
mDistanceSpinBox->grabKeyboard();
262+
//mDistanceSpinBox->grabKeyboard();
243263
mDistanceSpinBox->setFocus( Qt::TabFocusReason );
244264

245265
QObject::connect( mDistanceSpinBox, SIGNAL( editingFinished() ), this, SLOT( placeOffsetCurveToValue() ) );

0 commit comments

Comments
 (0)
Please sign in to comment.