Skip to content
Permalink
Browse files

fix a544133 - update measurement settings only on crs and options change

  • Loading branch information
jef-n committed Sep 17, 2012
1 parent 98a18ef commit ca752eedb0d8be1294665f9265695bdb3fa556b7
@@ -5671,6 +5671,10 @@ void QgisApp::options()
{
mScaleEdit->updateScales();
}

qobject_cast<QgsMeasureTool*>( mMapTools.mMeasureDist )->updateSettings();
qobject_cast<QgsMeasureTool*>( mMapTools.mMeasureArea )->updateSettings();
qobject_cast<QgsMapToolMeasureAngle*>( mMapTools.mMeasureAngle )->updateSettings();
}

delete optionsDialog;
@@ -6824,6 +6828,10 @@ void QgisApp::projectProperties()
QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt );
mMapCanvas->setCanvasColor( myColor ); // this is fill color before rendering onto canvas

qobject_cast<QgsMeasureTool*>( mMapTools.mMeasureDist )->updateSettings();
qobject_cast<QgsMeasureTool*>( mMapTools.mMeasureArea )->updateSettings();
qobject_cast<QgsMapToolMeasureAngle*>( mMapTools.mMeasureAngle )->updateSettings();

// Set the window title.
setTitleBarText_( *this );

@@ -24,36 +24,20 @@ QgsDisplayAngle::QgsDisplayAngle( QgsMapToolMeasureAngle * tool, Qt::WFlags f )
: QDialog( tool->canvas()->topLevelWidget(), f ), mTool( tool )
{
setupUi( this );
QSettings settings;

// Update whenever the canvas has refreshed. Maybe more often than needed,
// but at least every time any canvas related settings changes
connect( mTool->canvas(), SIGNAL( mapCanvasRefreshed() ),
this, SLOT( updateSettings() ) );

updateSettings();
}

QgsDisplayAngle::~QgsDisplayAngle()
{

}


void QgsDisplayAngle::setValueInRadians( double value )
{
mValue = value;
updateUi();
}

void QgsDisplayAngle::updateSettings()
{
emit changeProjectionEnabledState();
}

void QgsDisplayAngle::updateUi()
{

QSettings settings;
QString unitString = settings.value( "/qgis/measure/angleunits", "degrees" ).toString();
int decimals = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();
@@ -31,14 +31,6 @@ class QgsDisplayAngle: public QDialog, private Ui::QgsDisplayAngleBase
be converted to degrees / gon automatically if necessary*/
void setValueInRadians( double value );

signals:
void changeProjectionEnabledState();

private slots:

//! When any external settings change
void updateSettings();

private:
//! pointer to tool which owns this dialog
QgsMapToolMeasureAngle * mTool;
@@ -27,6 +27,9 @@
QgsMapToolMeasureAngle::QgsMapToolMeasureAngle( QgsMapCanvas* canvas ): QgsMapTool( canvas ), mRubberBand( 0 ), mResultDisplay( 0 )
{
mSnapper.setMapCanvas( canvas );

connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ),
this, SLOT( updateSettings() ) );
}

QgsMapToolMeasureAngle::~QgsMapToolMeasureAngle()
@@ -87,8 +90,6 @@ void QgsMapToolMeasureAngle::canvasReleaseEvent( QMouseEvent * e )
{
mResultDisplay = new QgsDisplayAngle( this );
QObject::connect( mResultDisplay, SIGNAL( rejected() ), this, SLOT( stopMeasuring() ) );
QObject::connect( mResultDisplay, SIGNAL( changeProjectionEnabledState() ),
this, SLOT( changeProjectionEnabledState() ) );
}
configureDistanceArea();
createRubberBand();
@@ -147,10 +148,11 @@ QgsPoint QgsMapToolMeasureAngle::snapPoint( const QPoint& p )
}
}

void QgsMapToolMeasureAngle::changeProjectionEnabledState()
void QgsMapToolMeasureAngle::updateSettings()
{
if ( mAnglePoints.size() != 3 )
return;

if ( !mResultDisplay )
return;

@@ -173,8 +175,8 @@ void QgsMapToolMeasureAngle::changeProjectionEnabledState()
resultAngle = -M_PI + ( resultAngle - M_PI );
}
}
mResultDisplay->setValueInRadians( resultAngle );

mResultDisplay->setValueInRadians( resultAngle );
}

void QgsMapToolMeasureAngle::configureDistanceArea()
@@ -193,6 +195,3 @@ void QgsMapToolMeasureAngle::configureDistanceArea()
mDa.setEllipsoidalMode( false );
}
}



@@ -59,14 +59,15 @@ class QgsMapToolMeasureAngle: public QgsMapTool
/** tool for measuring */
QgsDistanceArea mDa;

public slots:
/** recalculate angle if projection state changed*/
void updateSettings();

private slots:
/**Deletes the rubber band and the dialog*/
void stopMeasuring();

/** recalculate angle if projection state changed*/
void changeProjectionEnabledState();

//! Configures distance area objects with ellipsoid / output crs
/** Configures distance area objects with ellipsoid / output crs*/
void configureDistanceArea();

};
@@ -48,19 +48,11 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
item->setTextAlignment( 0, Qt::AlignRight );
mTable->addTopLevelItem( item );

// Update whenever the canvas has refreshed. Maybe more often than needed,
// but at least every time any canvas related settings changes
connect( mTool->canvas(), SIGNAL( mapCanvasRefreshed() ),
this, SLOT( updateSettings() ) );

updateSettings();
}

void QgsMeasureDialog::updateSettings()
{
if ( !isVisible() )
return;

QSettings settings;

mDecimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();
@@ -46,6 +46,9 @@ QgsMeasureTool::QgsMeasureTool( QgsMapCanvas* canvas, bool measureArea )

mDialog = new QgsMeasureDialog( this );
mSnapper.setMapCanvas( canvas );

connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ),
this, SLOT( updateSettings() ) );
}

QgsMeasureTool::~QgsMeasureTool()
@@ -120,7 +123,7 @@ void QgsMeasureTool::updateSettings()
int myGreen = settings.value( "/qgis/default_measure_color_green", 180 ).toInt();
int myBlue = settings.value( "/qgis/default_measure_color_blue", 180 ).toInt();
mRubberBand->setColor( QColor( myRed, myGreen, myBlue ) );

mDialog->updateSettings();
}

//////////////////////////

0 comments on commit ca752ee

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