void QgsMapToolOffsetCurve::canvasPressEvent( QMouseEvent* e )
{
  deleteRubberBandAndGeometry();
  mGeometryModified = false;
  mForceCopy = false;

  if ( !mCanvas )
  {
    return;
  }

  //get selected features or snap to nearest feature if no selection
  QgsVectorLayer* layer = currentVectorLayer();
  if ( !layer )
  {
    notifyNotVectorLayer();
    return;
  }

  QgsSnappingUtils* snapping = mCanvas->snappingUtils();

  // store previous settings
  int oldType;
  double oldSearchRadius;
  QgsTolerance::UnitType oldSearchRadiusUnit;
  QgsSnappingUtils::SnapToMapMode oldMode = snapping->snapToMapMode();
  snapping->defaultSettings( oldType, oldSearchRadius, oldSearchRadiusUnit );

  // setup new settings (temporary)
  QSettings settings;
  snapping->setSnapToMapMode( QgsSnappingUtils::SnapAllLayers );
  snapping->setDefaultSettings( QgsPointLocator::Edge,
                                settings.value( "/Qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble(),
                                ( QgsTolerance::UnitType ) settings.value( "/Qgis/digitizing/search_radius_vertex_edit_unit", QgsTolerance::Pixels ).toInt() );

  QgsPointLocator::Match match = snapping->snapToMap( e->pos() );

  // restore old settings
  snapping->setSnapToMapMode( oldMode );
  snapping->setDefaultSettings( oldType, oldSearchRadius, oldSearchRadiusUnit );

  if ( match.hasEdge() && match.layer() )
  {
    mSourceLayerId = match.layer()->id();
    QgsFeature fet;
    if ( match.layer()->getFeatures( QgsFeatureRequest( match.featureId() ) ).nextFeature( fet ) )
    {
      mForceCopy = ( e->modifiers() & Qt::ControlModifier ); //no geometry modification if ctrl is pressed
      mOriginalGeometry = createOriginGeometry( match.layer(), match, fet );
      mRubberBand = createRubberBand();
      if ( mRubberBand )
      {
        mRubberBand->setToGeometry( mOriginalGeometry, layer );
      }
      mModifiedFeature = fet.id();
      createDistanceItem();
    }
  }
}
void QgsMapToolOffsetCurve::canvasPressEvent( QMouseEvent* e )
{
  deleteRubberBandAndGeometry();
  mGeometryModified = false;
  mForceCopy = false;

  if ( !mCanvas )
  {
    return;
  }

  //get selected features or snap to nearest feature if no selection
  QgsVectorLayer* layer = currentVectorLayer();
  if ( !layer )
  {
    notifyNotVectorLayer();
    return;
  }


  QgsMapRenderer* renderer = mCanvas->mapRenderer();
  QgsSnapper snapper( renderer );
  configureSnapper( snapper );
  QList<QgsSnappingResult> snapResults;
  snapper.snapPoint( e->pos(), snapResults );
  if ( snapResults.size() > 0 )
  {
    QgsFeature fet;
    const QgsSnappingResult& snapResult = snapResults.at( 0 );
    if ( snapResult.layer )
    {
      mSourceLayerId = snapResult.layer->id();

      QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( mSourceLayerId ) );
      if ( vl && vl->getFeatures( QgsFeatureRequest().setFilterFid( snapResult.snappedAtGeometry ) ).nextFeature( fet ) )
      {
        mForceCopy = ( e->modifiers() & Qt::ControlModifier ); //no geometry modification if ctrl is pressed
        mOriginalGeometry = createOriginGeometry( vl, snapResult, fet );
        mRubberBand = createRubberBand();
        if ( mRubberBand )
        {
          mRubberBand->setToGeometry( mOriginalGeometry, layer );
        }
        mModifiedFeature = fet.id();
        createDistanceItem();
      }
    }
  }
}