Skip to content
Permalink
Browse files

Fix #3866 for measure angle tool

  • Loading branch information
Sergey Yakushev authored and timlinux committed Jun 6, 2011
1 parent fc986f0 commit 1a761e96c06c6a67129fa5cc714ed4348f56448c
Showing with 24 additions and 20 deletions.
  1. +19 −19 src/app/qgsmaptoolmeasureangle.cpp
  2. +5 −1 src/app/qgsmaptoolmeasureangle.h
@@ -45,22 +45,15 @@ void QgsMapToolMeasureAngle::canvasMoveEvent( QMouseEvent * e )
mRubberBand->movePoint( point );
if ( mAnglePoints.size() == 2 )
{
if ( !mResultDisplay )
if ( !mResultDisplay->isVisible() )
{
mResultDisplay = new QgsDisplayAngle( mCanvas->topLevelWidget() );
QObject::connect( mResultDisplay, SIGNAL( rejected() ), this, SLOT( stopMeasuring() ) );
QObject::connect( mResultDisplay, SIGNAL( changeProjectionEnabledState() ),
this, SLOT( changeProjectionEnabledState() ) );
mResultDisplay->move( e->pos() - QPoint( 100, 100 ) );
mResultDisplay->show();
}
mResultDisplay->show();

QgsDistanceArea myDa;
configureDistanceArea( myDa );

//angle calculation
double azimuthOne = myDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
double azimuthTwo = myDa.bearing( mAnglePoints.at( 1 ), point );
double azimuthOne = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
double azimuthTwo = mDa.bearing( mAnglePoints.at( 1 ), point );
double resultAngle = azimuthTwo - azimuthOne;
QgsDebugMsg( QString::number( qAbs( resultAngle ) ) );
QgsDebugMsg( QString::number( M_PI ) );
@@ -90,6 +83,14 @@ void QgsMapToolMeasureAngle::canvasReleaseEvent( QMouseEvent * e )

if ( mAnglePoints.size() < 1 )
{
if ( mResultDisplay == NULL )
{
mResultDisplay = new QgsDisplayAngle( mCanvas->topLevelWidget() );
QObject::connect( mResultDisplay, SIGNAL( rejected() ), this, SLOT( stopMeasuring() ) );
QObject::connect( mResultDisplay, SIGNAL( changeProjectionEnabledState() ),
this, SLOT( changeProjectionEnabledState() ) );
}
configureDistanceArea();
createRubberBand();
}

@@ -153,12 +154,11 @@ void QgsMapToolMeasureAngle::changeProjectionEnabledState()
if ( !mResultDisplay )
return;

QgsDistanceArea myDa;
configureDistanceArea( myDa );
configureDistanceArea();

//angle calculation
double azimuthOne = myDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
double azimuthTwo = myDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 2 ) );
double azimuthOne = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
double azimuthTwo = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 2 ) );
double resultAngle = azimuthTwo - azimuthOne;
QgsDebugMsg( QString::number( fabs( resultAngle ) ) );
QgsDebugMsg( QString::number( M_PI ) );
@@ -177,13 +177,13 @@ void QgsMapToolMeasureAngle::changeProjectionEnabledState()

}

void QgsMapToolMeasureAngle::configureDistanceArea( QgsDistanceArea& da )
void QgsMapToolMeasureAngle::configureDistanceArea()
{
QSettings settings;
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
da.setSourceCrs( mCanvas->mapRenderer()->destinationCrs().srsid() );
da.setEllipsoid( ellipsoidId );
da.setProjectionsEnabled( mResultDisplay->projectionEnabled() );
mDa.setSourceCrs( mCanvas->mapRenderer()->destinationCrs().srsid() );
mDa.setEllipsoid( ellipsoidId );
mDa.setProjectionsEnabled( mResultDisplay->projectionEnabled() );
}


@@ -19,6 +19,7 @@
#include "qgsmaptool.h"
#include "qgsmapcanvassnapper.h"
#include "qgspoint.h"
#include "qgsdistancearea.h"

class QgsDisplayAngle;
class QgsRubberBand;
@@ -55,6 +56,9 @@ class QgsMapToolMeasureAngle: public QgsMapTool
/**Snaps point to background layers*/
QgsPoint snapPoint( const QPoint& p );

/** tool for measuring */
QgsDistanceArea mDa;

private slots:
/**Deletes the rubber band and the dialog*/
void stopMeasuring();
@@ -63,7 +67,7 @@ class QgsMapToolMeasureAngle: public QgsMapTool
void changeProjectionEnabledState();

//! Configures distance area objects with ellipsoid / output crs
void configureDistanceArea( QgsDistanceArea& da );
void configureDistanceArea();

};

0 comments on commit 1a761e9

Please sign in to comment.
You can’t perform that action at this time.