@@ -45,22 +45,15 @@ void QgsMapToolMeasureAngle::canvasMoveEvent( QMouseEvent * e )
4545 mRubberBand ->movePoint ( point );
4646 if ( mAnglePoints .size () == 2 )
4747 {
48- if ( !mResultDisplay )
48+ if ( !mResultDisplay -> isVisible () )
4949 {
50- mResultDisplay = new QgsDisplayAngle ( mCanvas ->topLevelWidget () );
51- QObject::connect ( mResultDisplay , SIGNAL ( rejected () ), this , SLOT ( stopMeasuring () ) );
52- QObject::connect ( mResultDisplay , SIGNAL ( changeProjectionEnabledState () ),
53- this , SLOT ( changeProjectionEnabledState () ) );
5450 mResultDisplay ->move ( e->pos () - QPoint ( 100 , 100 ) );
51+ mResultDisplay ->show ();
5552 }
56- mResultDisplay ->show ();
57-
58- QgsDistanceArea myDa;
59- configureDistanceArea ( myDa );
6053
6154 // angle calculation
62- double azimuthOne = myDa .bearing ( mAnglePoints .at ( 1 ), mAnglePoints .at ( 0 ) );
63- double azimuthTwo = myDa .bearing ( mAnglePoints .at ( 1 ), point );
55+ double azimuthOne = mDa .bearing ( mAnglePoints .at ( 1 ), mAnglePoints .at ( 0 ) );
56+ double azimuthTwo = mDa .bearing ( mAnglePoints .at ( 1 ), point );
6457 double resultAngle = azimuthTwo - azimuthOne;
6558 QgsDebugMsg ( QString::number ( qAbs ( resultAngle ) ) );
6659 QgsDebugMsg ( QString::number ( M_PI ) );
@@ -90,6 +83,14 @@ void QgsMapToolMeasureAngle::canvasReleaseEvent( QMouseEvent * e )
9083
9184 if ( mAnglePoints .size () < 1 )
9285 {
86+ if ( mResultDisplay == NULL )
87+ {
88+ mResultDisplay = new QgsDisplayAngle ( mCanvas ->topLevelWidget () );
89+ QObject::connect ( mResultDisplay , SIGNAL ( rejected () ), this , SLOT ( stopMeasuring () ) );
90+ QObject::connect ( mResultDisplay , SIGNAL ( changeProjectionEnabledState () ),
91+ this , SLOT ( changeProjectionEnabledState () ) );
92+ }
93+ configureDistanceArea ();
9394 createRubberBand ();
9495 }
9596
@@ -153,12 +154,11 @@ void QgsMapToolMeasureAngle::changeProjectionEnabledState()
153154 if ( !mResultDisplay )
154155 return ;
155156
156- QgsDistanceArea myDa;
157- configureDistanceArea ( myDa );
157+ configureDistanceArea ();
158158
159159 // angle calculation
160- double azimuthOne = myDa .bearing ( mAnglePoints .at ( 1 ), mAnglePoints .at ( 0 ) );
161- double azimuthTwo = myDa .bearing ( mAnglePoints .at ( 1 ), mAnglePoints .at ( 2 ) );
160+ double azimuthOne = mDa .bearing ( mAnglePoints .at ( 1 ), mAnglePoints .at ( 0 ) );
161+ double azimuthTwo = mDa .bearing ( mAnglePoints .at ( 1 ), mAnglePoints .at ( 2 ) );
162162 double resultAngle = azimuthTwo - azimuthOne;
163163 QgsDebugMsg ( QString::number ( fabs ( resultAngle ) ) );
164164 QgsDebugMsg ( QString::number ( M_PI ) );
@@ -177,13 +177,13 @@ void QgsMapToolMeasureAngle::changeProjectionEnabledState()
177177
178178}
179179
180- void QgsMapToolMeasureAngle::configureDistanceArea ( QgsDistanceArea& da )
180+ void QgsMapToolMeasureAngle::configureDistanceArea ()
181181{
182182 QSettings settings;
183183 QString ellipsoidId = settings.value ( " /qgis/measure/ellipsoid" , " WGS84" ).toString ();
184- da .setSourceCrs ( mCanvas ->mapRenderer ()->destinationCrs ().srsid () );
185- da .setEllipsoid ( ellipsoidId );
186- da .setProjectionsEnabled ( mResultDisplay ->projectionEnabled () );
184+ mDa .setSourceCrs ( mCanvas ->mapRenderer ()->destinationCrs ().srsid () );
185+ mDa .setEllipsoid ( ellipsoidId );
186+ mDa .setProjectionsEnabled ( mResultDisplay ->projectionEnabled () );
187187}
188188
189189
0 commit comments