Skip to content

Commit

Permalink
Fix #10392 (ellipsoid for measurement keep getting reset)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jun 16, 2014
1 parent 42d14d7 commit aa09c8c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
3 changes: 3 additions & 0 deletions python/gui/qgsprojectionselector.sip
Expand Up @@ -102,4 +102,7 @@ class QgsProjectionSelector : QWidget
void refresh();
//! Let listeners know if find has focus so they can adjust the default button
void searchBoxHasFocus( bool );
//! Notify others that the widget is now fully initialized, including deferred selection of projection
//! @note added in 2.4
void initialized();
};
55 changes: 30 additions & 25 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -74,6 +74,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
connect( projectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( setMapUnitsToCurrentProjection() ) );
connect( projectionSelector, SIGNAL( initialized() ), this, SLOT( projectionSelectorInitialized() ) );

connect( cmbEllipsoid, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateEllipsoidUI( int ) ) );

Expand Down Expand Up @@ -123,33 +124,10 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
cbxAbsolutePath->setCurrentIndex( QgsProject::instance()->readBoolEntry( "Paths", "/Absolute", true ) ? 0 : 1 );

// populate combo box with ellipsoids

QgsDebugMsg( "Setting upp ellipsoid" );

// selection of the ellipsoid from settings is defferred to a later point, because it would
// be overridden in the meanwhile by the projection selector
populateEllipsoidList();

// Reading ellipsoid from setttings
QStringList mySplitEllipsoid = QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ).split( ':' );

int myIndex = 0;
for ( int i = 0; i < mEllipsoidList.length(); i++ )
{
if ( mEllipsoidList[ i ].acronym.startsWith( mySplitEllipsoid[ 0 ] ) )
{
myIndex = i;
break;
}
}

// Update paramaters if present.
if ( mySplitEllipsoid.length() >= 3 )
{
mEllipsoidList[ myIndex ].semiMajor = mySplitEllipsoid[ 1 ].toDouble();
mEllipsoidList[ myIndex ].semiMinor = mySplitEllipsoid[ 2 ].toDouble();
}

updateEllipsoidUI( myIndex );


int dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" );
spinBoxDP->setValue( dp );
Expand Down Expand Up @@ -1631,3 +1609,30 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex )
}
cmbEllipsoid->setCurrentIndex( mEllipsoidIndex ); // Not always necessary
}

void QgsProjectProperties::projectionSelectorInitialized()
{
QgsDebugMsg( "Setting up ellipsoid" );

// Reading ellipsoid from setttings
QStringList mySplitEllipsoid = QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ).split( ':' );

int myIndex = 0;
for ( int i = 0; i < mEllipsoidList.length(); i++ )
{
if ( mEllipsoidList[ i ].acronym.startsWith( mySplitEllipsoid[ 0 ] ) )
{
myIndex = i;
break;
}
}

// Update paramaters if present.
if ( mySplitEllipsoid.length() >= 3 )
{
mEllipsoidList[ myIndex ].semiMajor = mySplitEllipsoid[ 1 ].toDouble();
mEllipsoidList[ myIndex ].semiMinor = mySplitEllipsoid[ 2 ].toDouble();
}

updateEllipsoidUI( myIndex );
}
3 changes: 3 additions & 0 deletions src/app/qgsprojectproperties.h
Expand Up @@ -163,6 +163,9 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
*/
void updateEllipsoidUI( int newIndex );

//! sets the right ellipsoid for measuring (from settings)
void projectionSelectorInitialized();

signals:
//! Signal used to inform listeners that the mouse display precision may have changed
void displayPrecisionChanged();
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsprojectionselector.cpp
Expand Up @@ -171,6 +171,8 @@ void QgsProjectionSelector::showEvent( QShowEvent * theEvent )
// apply deferred selection
applySelection();

emit initialized();

// Pass up the inheritance hierarchy
QWidget::showEvent( theEvent );
}
Expand Down
3 changes: 3 additions & 0 deletions src/gui/qgsprojectionselector.h
Expand Up @@ -205,6 +205,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
void refresh();
//! Let listeners know if find has focus so they can adjust the default button
void searchBoxHasFocus( bool );
//! Notify others that the widget is now fully initialized, including deferred selection of projection
//! @note added in 2.4
void initialized();
};

#endif

0 comments on commit aa09c8c

Please sign in to comment.