58
58
#include < cpl_conv.h> // for setting gdal options
59
59
60
60
#include " qgsconfig.h"
61
- const char * QgsOptions::GEO_NONE_DESC = QT_TRANSLATE_NOOP( " QgsOptions" , " None / Planimetric" );
62
61
63
62
/* *
64
63
* \class QgsOptions - Set user options and preferences
@@ -82,8 +81,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
82
81
connect ( mFontFamilyRadioCustom , SIGNAL ( released () ), this , SLOT ( updateAppStyleSheet () ) );
83
82
connect ( mFontFamilyComboBox , SIGNAL ( currentFontChanged ( const QFont& ) ), this , SLOT ( updateAppStyleSheet () ) );
84
83
85
- connect ( cmbEllipsoid, SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( updateEllipsoidUI ( int ) ) );
86
-
87
84
#ifdef Q_WS_X11
88
85
connect ( chkEnableBackbuffer, SIGNAL ( stateChanged ( int ) ), this , SLOT ( toggleEnableBackbuffer ( int ) ) );
89
86
#endif
@@ -286,34 +283,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
286
283
// display the crs as friendly text rather than in wkt
287
284
leProjectGlobalCrs->setText ( mDefaultCrs .authid () + " - " + mDefaultCrs .description () );
288
285
289
- // populate combo box with ellipsoids
290
-
291
- QgsDebugMsg ( " Setting upp ellipsoid" );
292
-
293
- mEllipsoidIndex = 0 ;
294
- populateEllipsoidList ();
295
-
296
- // Reading ellipsoid from setttings
297
- QStringList mySplitEllipsoid = settings.value ( " /qgis/measure/ellipsoid" , GEO_NONE ).toString ().split ( ' :' );
298
-
299
- int myIndex = 0 ;
300
- int i;
301
- for ( i = 0 ; i < mEllipsoidList .length (); i++ )
302
- {
303
- if ( mEllipsoidList [ i ].acronym .startsWith ( mySplitEllipsoid[ 0 ] ) )
304
- {
305
- myIndex = i;
306
- break ;
307
- }
308
- }
309
- // Update paramaters if present.
310
- if ( mySplitEllipsoid.length () >= 3 )
311
- {
312
- mEllipsoidList [ myIndex ].semiMajor = mySplitEllipsoid[ 1 ].toDouble ();
313
- mEllipsoidList [ myIndex ].semiMinor = mySplitEllipsoid[ 2 ].toDouble ();
314
- }
315
-
316
- updateEllipsoidUI ( myIndex );
317
286
318
287
// Set the units for measuring
319
288
QGis::UnitType myDisplayUnits = QGis::fromLiteral ( settings.value ( " /qgis/measure/displayunits" , QGis::toLiteral ( QGis::Meters ) ).toString () );
@@ -1000,26 +969,6 @@ void QgsOptions::saveOptions()
1000
969
settings.setValue ( " /Projections/otfTransformEnabled" , chkOtfTransform->isChecked () );
1001
970
settings.setValue ( " /Projections/projectDefaultCrs" , mDefaultCrs .authid () );
1002
971
1003
- if ( mEllipsoidList [ mEllipsoidIndex ].acronym .startsWith ( " PARAMETER" ) )
1004
- {
1005
- double major = mEllipsoidList [ mEllipsoidIndex ].semiMajor ;
1006
- double minor = mEllipsoidList [ mEllipsoidIndex ].semiMinor ;
1007
- // If the user fields have changed, use them instead.
1008
- if ( leSemiMajor->isModified () || leSemiMinor->isModified () )
1009
- {
1010
- QgsDebugMsg ( " Using paramteric major/minor" );
1011
- major = QLocale::system ().toDouble ( leSemiMajor->text () );
1012
- minor = QLocale::system ().toDouble ( leSemiMinor->text () );
1013
- }
1014
- settings.setValue ( " /qgis/measure/ellipsoid" , QString ( " PARAMETER:%1:%2" )
1015
- .arg ( major, 0 , ' g' , 17 )
1016
- .arg ( minor, 0 , ' g' , 17 ) );
1017
- }
1018
- else
1019
- {
1020
- settings.setValue ( " /qgis/measure/ellipsoid" , mEllipsoidList [ mEllipsoidIndex ].acronym );
1021
- }
1022
-
1023
972
if ( radFeet->isChecked () )
1024
973
{
1025
974
settings.setValue ( " /qgis/measure/displayunits" , QGis::toLiteral ( QGis::Feet ) );
@@ -1245,88 +1194,6 @@ bool QgsOptions::newVisible()
1245
1194
{
1246
1195
return chkAddedVisibility->isChecked ();
1247
1196
}
1248
- void QgsOptions::populateEllipsoidList ()
1249
- {
1250
- //
1251
- // Populate the ellipsoid list
1252
- //
1253
- sqlite3 *myDatabase;
1254
- const char *myTail;
1255
- sqlite3_stmt *myPreparedStatement;
1256
- int myResult;
1257
- EllipsoidDefs myItem, i;
1258
-
1259
- myItem.acronym = GEO_NONE;
1260
- myItem.description = tr ( GEO_NONE_DESC );
1261
- myItem.semiMajor = 0.0 ;
1262
- myItem.semiMinor = 0.0 ;
1263
- mEllipsoidList .append ( myItem );
1264
-
1265
- myItem.acronym = QString ( " PARAMETER:6370997:6370997" );
1266
- myItem.description = tr ( " Parameters :" );
1267
- myItem.semiMajor = 6370997.0 ;
1268
- myItem.semiMinor = 6370997.0 ;
1269
- mEllipsoidList .append ( myItem );
1270
-
1271
- // check the db is available
1272
- myResult = sqlite3_open_v2 ( QgsApplication::srsDbFilePath ().toUtf8 ().data (), &myDatabase, SQLITE_OPEN_READONLY, NULL );
1273
- if ( myResult )
1274
- {
1275
- QgsDebugMsg ( QString ( " Can't open database: %1" ).arg ( sqlite3_errmsg ( myDatabase ) ) );
1276
- // XXX This will likely never happen since on open, sqlite creates the
1277
- // database if it does not exist.
1278
- Q_ASSERT ( myResult == 0 );
1279
- }
1280
-
1281
- // Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
1282
- QString mySql = " select acronym, name, radius, parameter2 from tbl_ellipsoid order by name" ;
1283
- myResult = sqlite3_prepare ( myDatabase, mySql.toUtf8 (), mySql.toUtf8 ().length (), &myPreparedStatement, &myTail );
1284
- // XXX Need to free memory from the error msg if one is set
1285
- if ( myResult == SQLITE_OK )
1286
- {
1287
- while ( sqlite3_step ( myPreparedStatement ) == SQLITE_ROW )
1288
- {
1289
- QString para1, para2;
1290
- myItem.acronym = ( const char * )sqlite3_column_text ( myPreparedStatement, 0 );
1291
- myItem.description = ( const char * )sqlite3_column_text ( myPreparedStatement, 1 );
1292
-
1293
- // Copied from QgsDistanecArea. Should perhaps be moved there somehow?
1294
- // No error checking, this values are for show only, never used in calculations.
1295
-
1296
- // Fall-back values
1297
- myItem.semiMajor = 0.0 ;
1298
- myItem.semiMinor = 0.0 ;
1299
- // Crash if no column?
1300
- para1 = ( const char * )sqlite3_column_text ( myPreparedStatement, 2 );
1301
- para2 = ( const char * )sqlite3_column_text ( myPreparedStatement, 3 );
1302
- myItem.semiMajor = para1.mid ( 2 ).toDouble ();
1303
- if ( para2.left ( 2 ) == " b=" )
1304
- {
1305
- myItem.semiMinor = para2.mid ( 2 ).toDouble ();
1306
- }
1307
- else if ( para2.left ( 3 ) == " rf=" )
1308
- {
1309
- double invFlattening = para2.mid ( 3 ).toDouble ();
1310
- if ( invFlattening != 0.0 )
1311
- {
1312
- myItem.semiMinor = myItem.semiMajor - ( myItem.semiMajor / invFlattening );
1313
- }
1314
- }
1315
- mEllipsoidList .append ( myItem );
1316
- }
1317
- }
1318
-
1319
- // close the sqlite3 statement
1320
- sqlite3_finalize ( myPreparedStatement );
1321
- sqlite3_close ( myDatabase );
1322
-
1323
- // Add all items to selector
1324
-
1325
- foreach ( i, mEllipsoidList )
1326
- {
1327
- cmbEllipsoid->addItem ( i.description );
1328
- }
1329
- }
1330
1197
1331
1198
QStringList QgsOptions::i18nList ()
1332
1199
{
@@ -1736,53 +1603,3 @@ void QgsOptions::saveContrastEnhancement( QComboBox *cbox, QString name )
1736
1603
settings.setValue ( " /Raster/defaultContrastEnhancementAlgorithm/" + name, value );
1737
1604
}
1738
1605
1739
- void QgsOptions::updateEllipsoidUI ( int newIndex )
1740
- {
1741
- // Called whenever settings change, adjusts the UI accordingly
1742
- // Pre-select current ellipsoid
1743
-
1744
- // Check if CRS transformation is on, or else turn everything off
1745
- double myMajor = mEllipsoidList [ newIndex ].semiMajor ;
1746
- double myMinor = mEllipsoidList [ newIndex ].semiMinor ;
1747
-
1748
- // If user has modified the radii (only possible if parametric!), before
1749
- // changing ellipsoid, save the modified coordinates
1750
- if ( leSemiMajor->isModified () || leSemiMinor->isModified () )
1751
- {
1752
- QgsDebugMsg ( " Saving major/minor" );
1753
- mEllipsoidList [ mEllipsoidIndex ].semiMajor = QLocale::system ().toDouble ( leSemiMajor->text () );
1754
- mEllipsoidList [ mEllipsoidIndex ].semiMinor = QLocale::system ().toDouble ( leSemiMinor->text () );
1755
- }
1756
-
1757
- mEllipsoidIndex = newIndex;
1758
- leSemiMajor->setEnabled ( false );
1759
- leSemiMinor->setEnabled ( false );
1760
- leSemiMajor->setText ( " " );
1761
- leSemiMinor->setText ( " " );
1762
- if ( QgisApp::instance ()->mapCanvas ()->mapRenderer ()->hasCrsTransformEnabled () )
1763
- {
1764
- cmbEllipsoid->setEnabled ( true );
1765
- cmbEllipsoid->setToolTip ( " " );
1766
- if ( mEllipsoidList [ mEllipsoidIndex ].acronym .startsWith ( " PARAMETER:" ) )
1767
- {
1768
- leSemiMajor->setEnabled ( true );
1769
- leSemiMinor->setEnabled ( true );
1770
- }
1771
- else
1772
- {
1773
- leSemiMajor->setToolTip ( QString ( " Select %1 from pull-down menu to adjust radii" ).arg ( tr ( " Parameters:" ) ) );
1774
- leSemiMinor->setToolTip ( QString ( " Select %1 from pull-down menu to adjust radii" ).arg ( tr ( " Parameters:" ) ) );
1775
- }
1776
- cmbEllipsoid->setCurrentIndex ( mEllipsoidIndex ); // Not always necessary
1777
- if ( mEllipsoidList [ mEllipsoidIndex ].acronym != GEO_NONE )
1778
- {
1779
- leSemiMajor->setText ( QLocale::system ().toString ( myMajor, ' f' , 3 ) );
1780
- leSemiMinor->setText ( QLocale::system ().toString ( myMinor, ' f' , 3 ) );
1781
- }
1782
- }
1783
- else
1784
- {
1785
- cmbEllipsoid->setEnabled ( false );
1786
- cmbEllipsoid->setToolTip ( tr ( " Can only use ellipsoidal calculations when CRS transformation is enabled" ) );
1787
- }
1788
- }
0 commit comments