Skip to content

Commit

Permalink
Offset curve: snap to background layers in mouse move
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Feb 20, 2012
1 parent 68b251f commit d7941b1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/app/qgsmaptooloffsetcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,30 @@ void QgsMapToolOffsetCurve::canvasMoveEvent( QMouseEvent * e )

//get offset from current position rectangular to feature
QgsPoint layerCoords = toLayerCoordinates( layer, e->pos() );

//snap cursor to background layers
QList<QgsSnappingResult> results;
QList<QgsPoint> snapExcludePoints;
if ( mSnapper.snapToBackgroundLayers( e->pos(), results ) == 0 )
{
if ( results.size() > 0 )
{
QgsSnappingResult snap = results.at( 0 );
if ( snap.layer && snap.layer->id() != mSourceLayerId && snap.snappedAtGeometry != mModifiedFeature )
{
layerCoords = results.at( 0 ).snappedVertex;
}
}
}

QgsPoint minDistPoint;
int beforeVertex;
double leftOf;
double offset = sqrt( mOriginalGeometry->closestSegmentWithContext( layerCoords, minDistPoint, beforeVertex, &leftOf ) );
if ( !offset > 0 )
{
return;
}

//create offset geometry using geos
setOffsetForRubberBand( offset, leftOf < 0 );
Expand Down Expand Up @@ -239,7 +259,7 @@ void QgsMapToolOffsetCurve::createDistanceItem()
mDistanceItem = 0;
QgisApp::instance()->statusBar()->addWidget( mDistanceSpinBox );
#endif
mDistanceSpinBox->grabKeyboard();
//mDistanceSpinBox->grabKeyboard();
mDistanceSpinBox->setFocus( Qt::TabFocusReason );

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

0 comments on commit d7941b1

Please sign in to comment.