Skip to content
Permalink
Browse files

fix #3866

  • Loading branch information
jef-n authored and mhugent committed Jun 10, 2011
1 parent db20ac2 commit e22e5d6f5834f536080d04a48fce901503ec633d
Showing with 15 additions and 24 deletions.
  1. +12 −23 src/app/qgsmeasuredialog.cpp
  2. +3 −1 src/app/qgsmeasuredialog.h
@@ -97,25 +97,21 @@ void QgsMeasureDialog::mouseMove( QgsPoint &point )
QSettings settings;
int decimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();

// Create QgsDistance Area for customization ProjectionEnabled setting
QgsDistanceArea myDa;
configureDistanceArea( myDa );

// show current distance/area while moving the point
// by creating a temporary copy of point array
// and adding moving point at the end
if ( mMeasureArea && mTool->points().size() > 1 )
{
QList<QgsPoint> tmpPoints = mTool->points();
tmpPoints.append( point );
double area = myDa.measurePolygon( tmpPoints );
double area = mDa.measurePolygon( tmpPoints );
editTotal->setText( formatArea( area, decimalPlaces ) );
}
else if ( !mMeasureArea && mTool->points().size() > 0 )
{
QgsPoint p1( mTool->points().last() ), p2( point );

double d = myDa.measureLine( p1, p2 );
double d = mDa.measureLine( p1, p2 );
editTotal->setText( formatDistance( mTotal + d, decimalPlaces ) );
QGis::UnitType myDisplayUnits;
// Ignore units
@@ -130,14 +126,10 @@ void QgsMeasureDialog::addPoint( QgsPoint &point )
QSettings settings;
int decimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();

// Create QgsDistance Area for customization ProjectionEnabled setting
QgsDistanceArea myDa;
configureDistanceArea( myDa );

int numPoints = mTool->points().size();
if ( mMeasureArea && numPoints > 2 )
{
double area = myDa.measurePolygon( mTool->points() );
double area = mDa.measurePolygon( mTool->points() );
editTotal->setText( formatArea( area, decimalPlaces ) );
}
else if ( !mMeasureArea && numPoints > 1 )
@@ -146,7 +138,7 @@ void QgsMeasureDialog::addPoint( QgsPoint &point )

QgsPoint p1 = mTool->points()[last], p2 = mTool->points()[last+1];

double d = myDa.measureLine( p1, p2 );
double d = mDa.measureLine( p1, p2 );

mTotal += d;
editTotal->setText( formatDistance( mTotal, decimalPlaces ) );
@@ -243,7 +235,7 @@ void QgsMeasureDialog::updateUi()
break;
case QGis::UnknownUnit:
mTable->setHeaderLabels( QStringList( tr( "Segments" ) ) );
};
}

if ( mMeasureArea )
{
@@ -256,6 +248,7 @@ void QgsMeasureDialog::updateUi()
editTotal->setText( formatDistance( 0, decimalPlaces ) );
}

configureDistanceArea();
}

void QgsMeasureDialog::convertMeasurement( double &measure, QGis::UnitType &u, bool isArea )
@@ -322,16 +315,12 @@ void QgsMeasureDialog::changeProjectionEnabledState()

int decimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();

// create DistanceArea
QgsDistanceArea myDa;
configureDistanceArea( myDa );

if ( mMeasureArea )
{
double area = 0.0;
if ( mTool->points().size() > 1 )
{
area = myDa.measurePolygon( mTool->points() );
area = mDa.measurePolygon( mTool->points() );
}
editTotal->setText( formatArea( area, decimalPlaces ) );
}
@@ -347,7 +336,7 @@ void QgsMeasureDialog::changeProjectionEnabledState()
p2 = *it;
if ( !b )
{
double d = myDa.measureLine( p1, p2 );
double d = mDa.measureLine( p1, p2 );
mTotal += d;
editTotal->setText( formatDistance( mTotal, decimalPlaces ) );
QGis::UnitType myDisplayUnits;
@@ -367,11 +356,11 @@ void QgsMeasureDialog::changeProjectionEnabledState()
}
}

void QgsMeasureDialog::configureDistanceArea( QgsDistanceArea& da )
void QgsMeasureDialog::configureDistanceArea()
{
QSettings settings;
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
da.setSourceCrs( mTool->canvas()->mapRenderer()->destinationCrs().srsid() );
da.setEllipsoid( ellipsoidId );
da.setProjectionsEnabled( mcbProjectionEnabled->isChecked() );
mDa.setSourceCrs( mTool->canvas()->mapRenderer()->destinationCrs().srsid() );
mDa.setEllipsoid( ellipsoidId );
mDa.setProjectionsEnabled( mcbProjectionEnabled->isChecked() );
}
@@ -81,13 +81,15 @@ class QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase
void convertMeasurement( double &measure, QGis::UnitType &u, bool isArea );

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

double mTotal;

//! indicates whether we're measuring distances or areas
bool mMeasureArea;

QgsDistanceArea mDa;

//! pointer to measure tool which owns this dialog
QgsMeasureTool* mTool;
};

0 comments on commit e22e5d6

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