@@ -45,22 +45,15 @@ void QgsMapToolMeasureAngle::canvasMoveEvent( QMouseEvent * e )
45
45
mRubberBand ->movePoint ( point );
46
46
if ( mAnglePoints .size () == 2 )
47
47
{
48
- if ( !mResultDisplay )
48
+ if ( !mResultDisplay -> isVisible () )
49
49
{
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 () ) );
54
50
mResultDisplay ->move ( e->pos () - QPoint ( 100 , 100 ) );
51
+ mResultDisplay ->show ();
55
52
}
56
- mResultDisplay ->show ();
57
-
58
- QgsDistanceArea myDa;
59
- configureDistanceArea ( myDa );
60
53
61
54
// 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 );
64
57
double resultAngle = azimuthTwo - azimuthOne;
65
58
QgsDebugMsg ( QString::number ( qAbs ( resultAngle ) ) );
66
59
QgsDebugMsg ( QString::number ( M_PI ) );
@@ -90,6 +83,14 @@ void QgsMapToolMeasureAngle::canvasReleaseEvent( QMouseEvent * e )
90
83
91
84
if ( mAnglePoints .size () < 1 )
92
85
{
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 ();
93
94
createRubberBand ();
94
95
}
95
96
@@ -153,12 +154,11 @@ void QgsMapToolMeasureAngle::changeProjectionEnabledState()
153
154
if ( !mResultDisplay )
154
155
return ;
155
156
156
- QgsDistanceArea myDa;
157
- configureDistanceArea ( myDa );
157
+ configureDistanceArea ();
158
158
159
159
// 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 ) );
162
162
double resultAngle = azimuthTwo - azimuthOne;
163
163
QgsDebugMsg ( QString::number ( fabs ( resultAngle ) ) );
164
164
QgsDebugMsg ( QString::number ( M_PI ) );
@@ -177,13 +177,13 @@ void QgsMapToolMeasureAngle::changeProjectionEnabledState()
177
177
178
178
}
179
179
180
- void QgsMapToolMeasureAngle::configureDistanceArea ( QgsDistanceArea& da )
180
+ void QgsMapToolMeasureAngle::configureDistanceArea ()
181
181
{
182
182
QSettings settings;
183
183
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 () );
187
187
}
188
188
189
189
0 commit comments