Skip to content
Permalink
Browse files

Looks good, but an extra line when finished is not so pretty. The tot…

…al is constant, though
  • Loading branch information
homann committed Sep 4, 2012
1 parent c523511 commit 35cf2d68ea2825243a253c00f857e53ac4bcd117
Showing with 41 additions and 19 deletions.
  1. +19 −11 src/app/qgsmeasuredialog.cpp
  2. +17 −7 src/app/qgsmeasuretool.cpp
  3. +5 −1 src/app/qgsmeasuretool.h
@@ -68,16 +68,21 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
void QgsMeasureDialog::ellipsoidalButton()
{
QSettings settings;

if ( mcbProjectionEnabled->isChecked() )
{
settings.setValue( "/qgis/measure/projectionEnabled", 2 );
}
else

// We set check state to Unchecked and button to Disabled when disabling CRS,
// which generates an call here. Ignore that event!
if ( mcbProjectionEnabled->isEnabled() )
{
settings.setValue( "/qgis/measure/projectionEnabled", 0 );
if ( mcbProjectionEnabled->isChecked() )
{
settings.setValue( "/qgis/measure/projectionEnabled", 2 );
}
else
{
settings.setValue( "/qgis/measure/projectionEnabled", 0 );
}
updateSettings();
}
updateSettings();
}

void QgsMeasureDialog::updateSettings()
@@ -139,8 +144,10 @@ void QgsMeasureDialog::mousePress( QgsPoint &point )
show();
}
raise();

mouseMove( point );
if ( ! mTool->done() )
{
mouseMove( point );
}
}

void QgsMeasureDialog::mouseMove( QgsPoint &point )
@@ -263,6 +270,7 @@ void QgsMeasureDialog::updateUi()
// If project wide transformation is off, disbale checkbox and unmark it.
// When on, enable checbox and mark with saved value.
mcbProjectionEnabled->setEnabled( mTool->canvas()->hasCrsTransformEnabled() );
mcbProjectionEnabled->setCheckState( mTool->canvas()->hasCrsTransformEnabled() && mEllipsoidal ? Qt::Checked : Qt::Unchecked );

// Set tooltip to indicate how we calculate measurments
QString toolTip = tr( "The calculations are based on:" );
@@ -325,7 +333,7 @@ void QgsMeasureDialog::updateUi()
convertMeasurement( d, myDisplayUnits, false );

QTreeWidgetItem *item = mTable->topLevelItem( mTable->topLevelItemCount() - 1 );
item->setText( 0, QLocale::system().toString( d, 'f' ) );
item->setText( 0, QLocale::system().toString( d, 'f', mDecimalPlaces ) );
item = new QTreeWidgetItem( QStringList( QLocale::system().toString( 0.0, 'f', mDecimalPlaces ) ) );
item->setTextAlignment( 0, Qt::AlignRight );
mTable->addTopLevelItem( item );
@@ -40,7 +40,7 @@ QgsMeasureTool::QgsMeasureTool( QgsMapCanvas* canvas, bool measureArea )
QPixmap myCrossHairQPixmap = QPixmap(( const char ** ) cross_hair_cursor );
mCursor = QCursor( myCrossHairQPixmap, 8, 8 );

mRightMouseClicked = false;
mDone = false;

mDialog = new QgsMeasureDialog( this );
mSnapper.setMapCanvas( canvas );
@@ -101,7 +101,7 @@ void QgsMeasureTool::restart()
// re-read settings
updateSettings();

mRightMouseClicked = false;
mDone = false;
mWrongProjectProjection = false;

}
@@ -127,7 +127,7 @@ void QgsMeasureTool::canvasPressEvent( QMouseEvent * e )
{
if ( e->button() == Qt::LeftButton )
{
if ( mRightMouseClicked )
if ( mDone )
mDialog->restart();

QgsPoint idPoint = snapPoint( e->pos() );
@@ -137,7 +137,7 @@ void QgsMeasureTool::canvasPressEvent( QMouseEvent * e )

void QgsMeasureTool::canvasMoveEvent( QMouseEvent * e )
{
if ( !mRightMouseClicked )
if ( ! mDone )
{
QgsPoint point = snapPoint( e->pos() );

@@ -153,10 +153,17 @@ void QgsMeasureTool::canvasReleaseEvent( QMouseEvent * e )

if ( e->button() == Qt::RightButton && ( e->buttons() & Qt::LeftButton ) == 0 ) // restart
{
if ( mRightMouseClicked )
if ( mDone )
{
mDialog->restart();
}
else
mRightMouseClicked = true;
{
// The figure is finished, store last point.
mDone = true;
addPoint( point );
mDialog->show();
}
}
else if ( e->button() == Qt::LeftButton )
{
@@ -180,7 +187,10 @@ void QgsMeasureTool::addPoint( QgsPoint &point )


mRubberBand->addPoint( point );
mDialog->addPoint( point );
if ( ! mDone )
{
mDialog->addPoint( point );
}
}

QgsPoint QgsMeasureTool::snapPoint( const QPoint& p )
@@ -40,6 +40,10 @@ class QgsMeasureTool : public QgsMapTool
//! returns whether measuring distance or area
bool measureArea() { return mMeasureArea; }

//! When we hvae added our last point, and not following
// Added in 2.0
bool done() { return mDone; }

//! Reset and start new
void restart();

@@ -83,7 +87,7 @@ class QgsMeasureTool : public QgsMapTool
bool mMeasureArea;

//! indicates whether we've just done a right mouse click
bool mRightMouseClicked;
bool mDone;

//! indicates whether we've recently warned the user about having the wrong
// project projection

0 comments on commit 35cf2d6

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