Skip to content
Permalink
Browse files

Code cleanup

  • Loading branch information
m-kuhn committed Feb 23, 2017
1 parent c4bc154 commit 86c0a16e9e54724ba5f9c93ed1941fccec37d51f
Showing with 9 additions and 21 deletions.
  1. +2 −14 src/app/qgsmeasuredialog.cpp
  2. +1 −1 src/app/qgsmeasuredialog.h
  3. +2 −2 src/app/qgsmeasuretool.cpp
  4. +4 −4 tests/src/app/testqgsmeasuretool.cpp
@@ -81,14 +81,6 @@ void QgsMeasureDialog::updateSettings()
mDa.setEllipsoid( QgsProject::instance()->ellipsoid() );
mDa.setEllipsoidalMode( true );

QgsDebugMsg( "****************" );
QgsDebugMsg( QString( "Ellipsoid ID : %1" ).arg( mDa.ellipsoid() ) );
QgsDebugMsg( QString( "Ellipsoidal : %1" ).arg( mDa.ellipsoidalEnabled() ? "true" : "false" ) );
QgsDebugMsg( QString( "Decimalplaces: %1" ).arg( mDecimalPlaces ) );
QgsDebugMsg( QString( "Distance units: %1" ).arg( QgsUnitTypes::encodeUnit( mDistanceUnits ) ) );
QgsDebugMsg( QString( "Area units: %1" ).arg( QgsUnitTypes::encodeUnit( mAreaUnits ) ) );
QgsDebugMsg( QString( "Canvas units : %1" ).arg( QgsUnitTypes::encodeUnit( mCanvasUnits ) ) );

mTable->clear();
mTotal = 0;
updateUi();
@@ -107,7 +99,7 @@ void QgsMeasureDialog::unitsChanged( int index )
if ( !mTool->done() )
{
// re-add temporary mouse cursor position
addPoint( mLastMousePoint );
addPoint();
mouseMove( mLastMousePoint );
}
}
@@ -149,15 +141,12 @@ void QgsMeasureDialog::mouseMove( const QgsPoint &point )
if ( item )
{
item->setText( 0, QLocale::system().toString( d, 'f', mDecimalPlaces ) );
QgsDebugMsg( QString( "Final result is %1" ).arg( item->text( 0 ) ) );
}
}
}

void QgsMeasureDialog::addPoint( const QgsPoint &p )
void QgsMeasureDialog::addPoint()
{
Q_UNUSED( p );

int numPoints = mTool->points().size();
if ( mMeasureArea && numPoints > 2 )
{
@@ -179,7 +168,6 @@ void QgsMeasureDialog::addPoint( const QgsPoint &p )
editTotal->setText( formatDistance( mTotal ) );
}
}
QgsDebugMsg( "Exiting" );
}

void QgsMeasureDialog::removeLastPoint()
@@ -43,7 +43,7 @@ class APP_EXPORT QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase
void restorePosition();

//! Add new point
void addPoint( const QgsPoint &point );
void addPoint();

//! Mose move
void mouseMove( const QgsPoint &point );
@@ -166,7 +166,7 @@ void QgsMeasureTool::updateSettings()
if ( !mDone && mRubberBand->size() > 0 )
{
mRubberBand->addPoint( mPoints.last() );
mDialog->addPoint( mPoints.last() );
mDialog->addPoint();
}
if ( mRubberBand->size() > 0 )
{
@@ -280,7 +280,7 @@ void QgsMeasureTool::addPoint( const QgsPoint &point )
mRubberBandPoints->addPoint( point );
if ( ! mDone ) // Prevent the insertion of a new item in segments measure table
{
mDialog->addPoint( point );
mDialog->addPoint();
}
}

@@ -106,7 +106,7 @@ void TestQgsMeasureTool::testLengthCalculation()
tool->addPoint( QgsPoint( 2484588, 2425722 ) );
tool->addPoint( QgsPoint( 2482767, 2398853 ) );
//force dialog recalculation
dlg->addPoint( QgsPoint( 0, 0 ) );
dlg->addPoint();

// check result
QString measureString = dlg->editTotal->text();
@@ -123,7 +123,7 @@ void TestQgsMeasureTool::testLengthCalculation()
tool2->addPoint( QgsPoint( 2484588, 2425722 ) );
tool2->addPoint( QgsPoint( 2482767, 2398853 ) );
//force dialog recalculation
dlg2->addPoint( QgsPoint( 0, 0 ) );
dlg2->addPoint();

// check result
measureString = dlg2->editTotal->text();
@@ -175,7 +175,7 @@ void TestQgsMeasureTool::testAreaCalculation()
tool->addPoint( QgsPoint( 2520109, 2397715 ) );
tool->addPoint( QgsPoint( 2520792, 2425494 ) );
//force dialog recalculation
dlg->addPoint( QgsPoint( 0, 0 ) );
dlg->addPoint();

// check result
QString measureString = dlg->editTotal->text();
@@ -194,7 +194,7 @@ void TestQgsMeasureTool::testAreaCalculation()
tool2->addPoint( QgsPoint( 2520109, 2397715 ) );
tool2->addPoint( QgsPoint( 2520792, 2425494 ) );
//force dialog recalculation
dlg2->addPoint( QgsPoint( 0, 0 ) );
dlg2->addPoint();

// check result
measureString = dlg2->editTotal->text();

0 comments on commit 86c0a16

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