Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
m-kuhn committed Feb 23, 2017
1 parent c4bc154 commit 86c0a16
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
16 changes: 2 additions & 14 deletions src/app/qgsmeasuredialog.cpp
Expand Up @@ -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();
Expand All @@ -107,7 +99,7 @@ void QgsMeasureDialog::unitsChanged( int index )
if ( !mTool->done() )
{
// re-add temporary mouse cursor position
addPoint( mLastMousePoint );
addPoint();
mouseMove( mLastMousePoint );
}
}
Expand Down Expand Up @@ -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 )
{
Expand All @@ -179,7 +168,6 @@ void QgsMeasureDialog::addPoint( const QgsPoint &p )
editTotal->setText( formatDistance( mTotal ) );
}
}
QgsDebugMsg( "Exiting" );
}

void QgsMeasureDialog::removeLastPoint()
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmeasuredialog.h
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmeasuretool.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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();
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/src/app/testqgsmeasuretool.cpp
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 86c0a16

Please sign in to comment.