@@ -97,25 +97,21 @@ void QgsMeasureDialog::mouseMove( QgsPoint &point )
9797 QSettings settings;
9898 int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
9999
100- // Create QgsDistance Area for customization ProjectionEnabled setting
101- QgsDistanceArea myDa;
102- configureDistanceArea ( myDa );
103-
104100 // show current distance/area while moving the point
105101 // by creating a temporary copy of point array
106102 // and adding moving point at the end
107103 if ( mMeasureArea && mTool ->points ().size () > 1 )
108104 {
109105 QList<QgsPoint> tmpPoints = mTool ->points ();
110106 tmpPoints.append ( point );
111- double area = myDa .measurePolygon ( tmpPoints );
107+ double area = mDa .measurePolygon ( tmpPoints );
112108 editTotal->setText ( formatArea ( area, decimalPlaces ) );
113109 }
114110 else if ( !mMeasureArea && mTool ->points ().size () > 0 )
115111 {
116112 QgsPoint p1 ( mTool ->points ().last () ), p2 ( point );
117113
118- double d = myDa .measureLine ( p1, p2 );
114+ double d = mDa .measureLine ( p1, p2 );
119115 editTotal->setText ( formatDistance ( mTotal + d, decimalPlaces ) );
120116 QGis::UnitType myDisplayUnits;
121117 // Ignore units
@@ -130,14 +126,10 @@ void QgsMeasureDialog::addPoint( QgsPoint &point )
130126 QSettings settings;
131127 int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
132128
133- // Create QgsDistance Area for customization ProjectionEnabled setting
134- QgsDistanceArea myDa;
135- configureDistanceArea ( myDa );
136-
137129 int numPoints = mTool ->points ().size ();
138130 if ( mMeasureArea && numPoints > 2 )
139131 {
140- double area = myDa .measurePolygon ( mTool ->points () );
132+ double area = mDa .measurePolygon ( mTool ->points () );
141133 editTotal->setText ( formatArea ( area, decimalPlaces ) );
142134 }
143135 else if ( !mMeasureArea && numPoints > 1 )
@@ -146,7 +138,7 @@ void QgsMeasureDialog::addPoint( QgsPoint &point )
146138
147139 QgsPoint p1 = mTool ->points ()[last], p2 = mTool ->points ()[last+1 ];
148140
149- double d = myDa .measureLine ( p1, p2 );
141+ double d = mDa .measureLine ( p1, p2 );
150142
151143 mTotal += d;
152144 editTotal->setText ( formatDistance ( mTotal , decimalPlaces ) );
@@ -243,7 +235,7 @@ void QgsMeasureDialog::updateUi()
243235 break ;
244236 case QGis::UnknownUnit:
245237 mTable ->setHeaderLabels ( QStringList ( tr ( " Segments" ) ) );
246- };
238+ }
247239
248240 if ( mMeasureArea )
249241 {
@@ -256,6 +248,7 @@ void QgsMeasureDialog::updateUi()
256248 editTotal->setText ( formatDistance ( 0 , decimalPlaces ) );
257249 }
258250
251+ configureDistanceArea ();
259252}
260253
261254void QgsMeasureDialog::convertMeasurement ( double &measure, QGis::UnitType &u, bool isArea )
@@ -322,16 +315,12 @@ void QgsMeasureDialog::changeProjectionEnabledState()
322315
323316 int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
324317
325- // create DistanceArea
326- QgsDistanceArea myDa;
327- configureDistanceArea ( myDa );
328-
329318 if ( mMeasureArea )
330319 {
331320 double area = 0.0 ;
332321 if ( mTool ->points ().size () > 1 )
333322 {
334- area = myDa .measurePolygon ( mTool ->points () );
323+ area = mDa .measurePolygon ( mTool ->points () );
335324 }
336325 editTotal->setText ( formatArea ( area, decimalPlaces ) );
337326 }
@@ -347,7 +336,7 @@ void QgsMeasureDialog::changeProjectionEnabledState()
347336 p2 = *it;
348337 if ( !b )
349338 {
350- double d = myDa .measureLine ( p1, p2 );
339+ double d = mDa .measureLine ( p1, p2 );
351340 mTotal += d;
352341 editTotal->setText ( formatDistance ( mTotal , decimalPlaces ) );
353342 QGis::UnitType myDisplayUnits;
@@ -367,11 +356,11 @@ void QgsMeasureDialog::changeProjectionEnabledState()
367356 }
368357}
369358
370- void QgsMeasureDialog::configureDistanceArea ( QgsDistanceArea& da )
359+ void QgsMeasureDialog::configureDistanceArea ()
371360{
372361 QSettings settings;
373362 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 () );
377366}
0 commit comments