@@ -97,25 +97,21 @@ void QgsMeasureDialog::mouseMove( QgsPoint &point )
97
97
QSettings settings;
98
98
int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
99
99
100
- // Create QgsDistance Area for customization ProjectionEnabled setting
101
- QgsDistanceArea myDa;
102
- configureDistanceArea ( myDa );
103
-
104
100
// show current distance/area while moving the point
105
101
// by creating a temporary copy of point array
106
102
// and adding moving point at the end
107
103
if ( mMeasureArea && mTool ->points ().size () > 1 )
108
104
{
109
105
QList<QgsPoint> tmpPoints = mTool ->points ();
110
106
tmpPoints.append ( point );
111
- double area = myDa .measurePolygon ( tmpPoints );
107
+ double area = mDa .measurePolygon ( tmpPoints );
112
108
editTotal->setText ( formatArea ( area, decimalPlaces ) );
113
109
}
114
110
else if ( !mMeasureArea && mTool ->points ().size () > 0 )
115
111
{
116
112
QgsPoint p1 ( mTool ->points ().last () ), p2 ( point );
117
113
118
- double d = myDa .measureLine ( p1, p2 );
114
+ double d = mDa .measureLine ( p1, p2 );
119
115
editTotal->setText ( formatDistance ( mTotal + d, decimalPlaces ) );
120
116
QGis::UnitType myDisplayUnits;
121
117
// Ignore units
@@ -130,14 +126,10 @@ void QgsMeasureDialog::addPoint( QgsPoint &point )
130
126
QSettings settings;
131
127
int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
132
128
133
- // Create QgsDistance Area for customization ProjectionEnabled setting
134
- QgsDistanceArea myDa;
135
- configureDistanceArea ( myDa );
136
-
137
129
int numPoints = mTool ->points ().size ();
138
130
if ( mMeasureArea && numPoints > 2 )
139
131
{
140
- double area = myDa .measurePolygon ( mTool ->points () );
132
+ double area = mDa .measurePolygon ( mTool ->points () );
141
133
editTotal->setText ( formatArea ( area, decimalPlaces ) );
142
134
}
143
135
else if ( !mMeasureArea && numPoints > 1 )
@@ -146,7 +138,7 @@ void QgsMeasureDialog::addPoint( QgsPoint &point )
146
138
147
139
QgsPoint p1 = mTool ->points ()[last], p2 = mTool ->points ()[last+1 ];
148
140
149
- double d = myDa .measureLine ( p1, p2 );
141
+ double d = mDa .measureLine ( p1, p2 );
150
142
151
143
mTotal += d;
152
144
editTotal->setText ( formatDistance ( mTotal , decimalPlaces ) );
@@ -243,7 +235,7 @@ void QgsMeasureDialog::updateUi()
243
235
break ;
244
236
case QGis::UnknownUnit:
245
237
mTable ->setHeaderLabels ( QStringList ( tr ( " Segments" ) ) );
246
- };
238
+ }
247
239
248
240
if ( mMeasureArea )
249
241
{
@@ -256,6 +248,7 @@ void QgsMeasureDialog::updateUi()
256
248
editTotal->setText ( formatDistance ( 0 , decimalPlaces ) );
257
249
}
258
250
251
+ configureDistanceArea ();
259
252
}
260
253
261
254
void QgsMeasureDialog::convertMeasurement ( double &measure, QGis::UnitType &u, bool isArea )
@@ -322,16 +315,12 @@ void QgsMeasureDialog::changeProjectionEnabledState()
322
315
323
316
int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
324
317
325
- // create DistanceArea
326
- QgsDistanceArea myDa;
327
- configureDistanceArea ( myDa );
328
-
329
318
if ( mMeasureArea )
330
319
{
331
320
double area = 0.0 ;
332
321
if ( mTool ->points ().size () > 1 )
333
322
{
334
- area = myDa .measurePolygon ( mTool ->points () );
323
+ area = mDa .measurePolygon ( mTool ->points () );
335
324
}
336
325
editTotal->setText ( formatArea ( area, decimalPlaces ) );
337
326
}
@@ -347,7 +336,7 @@ void QgsMeasureDialog::changeProjectionEnabledState()
347
336
p2 = *it;
348
337
if ( !b )
349
338
{
350
- double d = myDa .measureLine ( p1, p2 );
339
+ double d = mDa .measureLine ( p1, p2 );
351
340
mTotal += d;
352
341
editTotal->setText ( formatDistance ( mTotal , decimalPlaces ) );
353
342
QGis::UnitType myDisplayUnits;
@@ -367,11 +356,11 @@ void QgsMeasureDialog::changeProjectionEnabledState()
367
356
}
368
357
}
369
358
370
- void QgsMeasureDialog::configureDistanceArea ( QgsDistanceArea& da )
359
+ void QgsMeasureDialog::configureDistanceArea ()
371
360
{
372
361
QSettings settings;
373
362
QString ellipsoidId = settings.value ( " /qgis/measure/ellipsoid" , " WGS84" ).toString ();
374
- da .setSourceCrs ( mTool ->canvas ()->mapRenderer ()->destinationCrs ().srsid () );
375
- da .setEllipsoid ( ellipsoidId );
376
- da .setProjectionsEnabled ( mcbProjectionEnabled->isChecked () );
363
+ mDa .setSourceCrs ( mTool ->canvas ()->mapRenderer ()->destinationCrs ().srsid () );
364
+ mDa .setEllipsoid ( ellipsoidId );
365
+ mDa .setProjectionsEnabled ( mcbProjectionEnabled->isChecked () );
377
366
}
0 commit comments