Skip to content

Commit e9ae374

Browse files
committedNov 15, 2013
Merge remote-tracking branch 'upstream/master' into Issue_8725-OGR
2 parents dc078b8 + 836e1a8 commit e9ae374

File tree

15 files changed

+404
-161
lines changed

15 files changed

+404
-161
lines changed
 

‎CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ SET (HAVE_MSSQL TRUE)
221221
# search for Qt4
222222
SET(QT_MIN_VERSION 4.5.0)
223223
FIND_PACKAGE(Qt4 ${QT_MIN_VERSION} REQUIRED)
224+
MESSAGE(STATUS "Found Qt version: ${QTVERSION}")
224225
SET(QT_USE_QTXML 1)
225226
SET(QT_USE_QTNETWORK 1)
226227
SET(QT_USE_QTSVG 1)

‎i18n/qgis_fr.ts

Lines changed: 93 additions & 90 deletions
Large diffs are not rendered by default.

‎python/core/composer/qgscomposerattributetable.sip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class QgsComposerAttributeTable : QgsComposerTable
5757

5858
//void setSortAttributes( const QList<QPair<int, bool> > att );
5959
//QList<QPair<int, bool> > sortAttributes() const;
60-
60+
protected:
61+
virtual QMap<int, QString> getHeaderLabels() const;
6162

6263
signals:
6364
/**This signal is emitted if the maximum number of feature changes (interactively)*/

‎src/analysis/openstreetmap/qgsosmdatabase.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,10 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
489489
sqlite3_bind_null( stmtInsert, ++col );
490490
}
491491

492-
sqlite3_bind_blob( stmtInsert, ++col, geom->asWkb(), ( int ) geom->wkbSize(), SQLITE_STATIC );
492+
if ( geom )
493+
sqlite3_bind_blob( stmtInsert, ++col, geom->asWkb(), ( int ) geom->wkbSize(), SQLITE_STATIC );
494+
else
495+
sqlite3_bind_null( stmtInsert, ++col );
493496

494497
int insertRes = sqlite3_step( stmtInsert );
495498
if ( insertRes != SQLITE_DONE )

‎src/app/legend/qgslegend.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ QgsLegend::QgsLegend( QgsMapCanvas *canvas, QWidget * parent, const char *name )
114114

115115
connect( mMapCanvas, SIGNAL( layersChanged() ),
116116
this, SLOT( refreshCheckStates() ) );
117+
#if 0
118+
// too much
117119
connect( mMapCanvas, SIGNAL( extentsChanged() ),
118120
this, SLOT( updateLegendItemSymbologies() ) );
121+
#endif
119122

120123
// Initialise the line indicator widget.
121124
mInsertionLine = new QWidget( viewport() );

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )
20162016
{
20172017
//already in database, do update
20182018
QgsDebugMsg( "Trying datum transform update" );
2019-
sql = QString( "UPDATE tbl_datum_transform SET source_crs = %2, target_crs = %3, coord_op_method = %4, p1 = %5, p2 = %6, p3 = %7, p4 = %8, p5 = %9, p6 = %10, p7 = %11 WHERE coord_op = %1" )
2019+
sql = QString( "UPDATE tbl_datum_transform SET source_crs_code = %2, target_crs_code = %3, coord_op_method_code = %4, p1 = %5, p2 = %6, p3 = %7, p4 = %8, p5 = %9, p6 = %10, p7 = %11 WHERE coord_op_code = %1" )
20202020
.arg( coord_op ).arg( source_crs ).arg( target_crs ).arg( coord_op_method ).arg( p1 ).arg( p2 ).arg( p3 ).arg( p4 ).arg( p5 ).arg( p6 ).arg( p7 );
20212021
}
20222022
else
@@ -2030,7 +2030,7 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )
20302030

20312031
if ( sqlite3_exec( db, sql.toUtf8(), 0, 0, 0 ) != SQLITE_OK )
20322032
{
2033-
QgsDebugMsg( "Error" );
2033+
QgsDebugMsg( QString( "Error [%1]" ).arg( sqlite3_errmsg( db ) ) );
20342034
}
20352035
}
20362036

‎src/core/qgsexpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,8 +1618,8 @@ int QgsExpression::functionCount()
16181618
QgsExpression::QgsExpression( const QString& expr )
16191619
: mRowNumber( 0 )
16201620
, mScale( 0 )
1621-
, mCalc( 0 )
16221621
, mExp( expr )
1622+
, mCalc( 0 )
16231623
{
16241624
mRootNode = ::parseExpression( expr, mParserErrorString );
16251625

‎src/gui/attributetable/qgsattributetablemodel.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ bool QgsAttributeTableModel::loadFeatureAtId( QgsFeatureId fid ) const
7777

7878
void QgsAttributeTableModel::featureDeleted( QgsFeatureId fid )
7979
{
80-
QgsDebugMsg( QString( "(%2) fid: %1" ).arg( fid ).arg( mFeatureRequest.filterType() ) );
80+
QgsDebugMsgLevel( QString( "(%2) fid: %1" ).arg( fid ).arg( mFeatureRequest.filterType() ), 4 );
8181
mFieldCache.remove( fid );
8282

8383
int row = idToRow( fid );
@@ -132,8 +132,13 @@ bool QgsAttributeTableModel::removeRows( int row, int count, const QModelIndex &
132132

133133
void QgsAttributeTableModel::featureAdded( QgsFeatureId fid )
134134
{
135-
QgsDebugMsg( QString( "(%2) fid: %1" ).arg( fid ).arg( mFeatureRequest.filterType() ) );
136-
if ( loadFeatureAtId( fid ) && mFeatureRequest.acceptFeature( mFeat ) )
135+
QgsDebugMsgLevel( QString( "(%2) fid: %1" ).arg( fid ).arg( mFeatureRequest.filterType() ), 4 );
136+
bool featOk = true;
137+
138+
if ( mFeat.id() != fid )
139+
featOk = loadFeatureAtId( fid );
140+
141+
if ( featOk && mFeatureRequest.acceptFeature( mFeat ) )
137142
{
138143
mFieldCache[ fid ] = mFeat.attribute( mCachedField );
139144

@@ -351,6 +356,7 @@ void QgsAttributeTableModel::loadLayer()
351356

352357
t.restart();
353358
}
359+
mFeat = feat;
354360
featureAdded( feat.id() );
355361
}
356362

‎src/gui/qgsattributeeditor.cpp

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,41 +1392,48 @@ QWidget* QgsAttributeEditor::createWidgetFromDef( const QgsAttributeEditorElemen
13921392
{
13931393
const QgsAttributeEditorField* fieldDef = dynamic_cast<const QgsAttributeEditorField*>( widgetDef );
13941394
int fldIdx = fieldDef->idx();
1395-
newWidget = createAttributeEditor( parent, 0, vl, fldIdx, feat.attributes().value( fldIdx, QVariant() ), context );
1396-
1397-
if ( newWidget )
1395+
if ( fldIdx < vl->pendingFields().count() && fldIdx >= 0 )
13981396
{
1399-
if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
1397+
newWidget = createAttributeEditor( parent, 0, vl, fldIdx, feat.attributes().value( fldIdx, QVariant() ), context );
1398+
1399+
if ( newWidget )
14001400
{
1401-
if ( newWidget->isEnabled() && vl->isEditable() && vl->fieldEditable( fldIdx ) )
1401+
if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
14021402
{
1403-
newWidget->setEnabled( true );
1404-
}
1405-
else if ( vl->editType( fldIdx ) == QgsVectorLayer::Photo )
1406-
{
1407-
foreach ( QWidget *w, newWidget->findChildren<QWidget *>() )
1403+
if ( newWidget->isEnabled() && vl->isEditable() && vl->fieldEditable( fldIdx ) )
14081404
{
1409-
w->setEnabled( qobject_cast<QLabel *>( w ) ? true : false );
1405+
newWidget->setEnabled( true );
14101406
}
1411-
}
1412-
else if ( vl->editType( fldIdx ) == QgsVectorLayer::WebView )
1413-
{
1414-
foreach ( QWidget *w, newWidget->findChildren<QWidget *>() )
1407+
else if ( vl->editType( fldIdx ) == QgsVectorLayer::Photo )
14151408
{
1416-
if ( qobject_cast<QWebView *>( w ) )
1417-
w->setEnabled( true );
1418-
else if ( qobject_cast<QPushButton *>( w ) && w->objectName() == "openUrl" )
1419-
w->setEnabled( true );
1420-
else
1421-
w->setEnabled( false );
1409+
foreach ( QWidget *w, newWidget->findChildren<QWidget *>() )
1410+
{
1411+
w->setEnabled( qobject_cast<QLabel *>( w ) ? true : false );
1412+
}
1413+
}
1414+
else if ( vl->editType( fldIdx ) == QgsVectorLayer::WebView )
1415+
{
1416+
foreach ( QWidget *w, newWidget->findChildren<QWidget *>() )
1417+
{
1418+
if ( qobject_cast<QWebView *>( w ) )
1419+
w->setEnabled( true );
1420+
else if ( qobject_cast<QPushButton *>( w ) && w->objectName() == "openUrl" )
1421+
w->setEnabled( true );
1422+
else
1423+
w->setEnabled( false );
1424+
}
1425+
}
1426+
else
1427+
{
1428+
newWidget->setEnabled( false );
14221429
}
1423-
}
1424-
else
1425-
{
1426-
newWidget->setEnabled( false );
14271430
}
14281431
}
14291432
}
1433+
else
1434+
{
1435+
newWidget = new QLabel( tr( "<i>Error: Field does not exist in datasource</i>" ), parent );
1436+
}
14301437
labelOnTop = vl->labelOnTop( fieldDef->idx() );
14311438
labelText = vl->attributeDisplayName( fieldDef->idx() );
14321439
break;

‎src/plugins/globe/globe_plugin.cpp

Lines changed: 76 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
#include <osgEarthDrivers/gdal/GDALOptions>
6363
#include <osgEarthDrivers/tms/TMSOptions>
6464
#include <osgEarth/Version>
65-
65+
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 2, 0 )
66+
#include <osgEarthDrivers/cache_filesystem/FileSystemCache>
67+
#endif
6668
using namespace osgEarth::Drivers;
6769
using namespace osgEarth::Util;
6870

@@ -85,6 +87,7 @@ GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
8587
, mQActionSettingsPointer( NULL )
8688
, mOsgViewer( 0 )
8789
, mViewerWidget( 0 )
90+
, mBaseLayer( 0 )
8891
, mQgisMapLayer( 0 )
8992
, mTileSource( 0 )
9093
, mElevationManager( NULL )
@@ -117,7 +120,7 @@ GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
117120
}
118121
#endif
119122

120-
mSettingsDialog = new QgsGlobePluginDialog( theQgisInterface->mainWindow(), QgisGui::ModalDialogFlags );
123+
mSettingsDialog = new QgsGlobePluginDialog( theQgisInterface->mainWindow(), this, QgisGui::ModalDialogFlags );
121124
}
122125

123126
//destructor
@@ -281,17 +284,18 @@ void GlobePlugin::run()
281284
setupMap();
282285
}
283286

284-
if ( getenv( "GLOBE_SKY" ) )
285-
{
286-
SkyNode* sky = new SkyNode( mMapNode->getMap() );
287-
sky->setDateTime( 2011, 1, 6, 17.0 );
288-
//sky->setSunPosition( osg::Vec3(0,-1,0) );
289-
sky->attach( mOsgViewer );
290-
mRootNode->addChild( sky );
291-
}
287+
// Initialize the sky node if required
288+
setSkyParameters( settings.value( "/Plugin-Globe/skyEnabled", false ).toBool()
289+
, settings.value( "/Plugin-Globe/skyDateTime", QDateTime() ).toDateTime()
290+
, settings.value( "/Plugin-Globe/skyAutoAmbient", false ).toBool() );
292291

293292
// create a surface to house the controls
293+
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 1, 1 )
294294
mControlCanvas = ControlCanvas::get( mOsgViewer );
295+
#else
296+
mControlCanvas = new ControlCanvas( mOsgViewer );
297+
#endif
298+
295299
mRootNode->addChild( mControlCanvas );
296300

297301
mOsgViewer->setSceneData( mRootNode );
@@ -314,8 +318,6 @@ void GlobePlugin::run()
314318
// OSG, this activates OSG's IncrementalCompileOpeartion in order to avoid frame breaks.
315319
mOsgViewer->getDatabasePager()->setDoPreCompile( true );
316320

317-
mSettingsDialog->setViewer( mOsgViewer );
318-
319321
#ifdef GLOBE_OSG_STANDALONE_VIEWER
320322
mOsgViewer->run();
321323
#endif
@@ -374,14 +376,18 @@ void GlobePlugin::settings()
374376
void GlobePlugin::setupMap()
375377
{
376378
QSettings settings;
377-
/*
378379
QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
380+
381+
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 2, 0 )
382+
FileSystemCacheOptions cacheOptions;
383+
cacheOptions.rootPath() = cacheDirectory.toStdString();
384+
#else
379385
TMSCacheOptions cacheOptions;
380386
cacheOptions.setPath( cacheDirectory.toStdString() );
381-
*/
387+
#endif
382388

383389
MapOptions mapOptions;
384-
//mapOptions.cache() = cacheOptions;
390+
mapOptions.cache() = cacheOptions;
385391
osgEarth::Map *map = new osgEarth::Map( mapOptions );
386392

387393
//Default image layer
@@ -391,9 +397,6 @@ void GlobePlugin::setupMap()
391397
ImageLayerOptions layerOptions( "world", driverOptions );
392398
map->addImageLayer( new osgEarth::ImageLayer( layerOptions ) );
393399
*/
394-
TMSOptions imagery;
395-
imagery.url() = "http://readymap.org/readymap/tiles/1.0.0/7/";
396-
map->addImageLayer( new ImageLayer( "Imagery", imagery ) );
397400

398401
MapNodeOptions nodeOptions;
399402
//nodeOptions.proxySettings() =
@@ -409,6 +412,11 @@ void GlobePlugin::setupMap()
409412
// The MapNode will render the Map object in the scene graph.
410413
mMapNode = new osgEarth::MapNode( map, nodeOptions );
411414

415+
if ( settings.value( "/Plugin-Globe/baseLayerEnabled", true ).toBool() )
416+
{
417+
setBaseMap( settings.value( "/Plugin-Globe/baseLayerURL", "http://readymap.org/readymap/tiles/1.0.0/7/" ).toString() );
418+
}
419+
412420
mRootNode = new osg::Group();
413421
mRootNode->addChild( mMapNode );
414422

@@ -741,9 +749,11 @@ void GlobePlugin::imageLayersChanged()
741749
mTileSource = new QgsOsgEarthTileSource( mQGisIface );
742750
mTileSource->initialize( "", 0 );
743751
ImageLayerOptions options( "QGIS" );
752+
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 2, 0 )
753+
options.cachePolicy() = CachePolicy::NO_CACHE;
754+
#endif
744755
mQgisMapLayer = new ImageLayer( options, mTileSource );
745756
map->addImageLayer( mQgisMapLayer );
746-
//[layer->setCache is private in 1.3.0] mQgisMapLayer->setCache( 0 ); //disable caching
747757
}
748758
else
749759
{
@@ -808,6 +818,53 @@ void GlobePlugin::elevationLayersChanged()
808818
}
809819
}
810820

821+
void GlobePlugin::setBaseMap( QString url )
822+
{
823+
if ( mMapNode )
824+
{
825+
mMapNode->getMap()->removeImageLayer( mBaseLayer );
826+
if ( url.isNull() )
827+
{
828+
mBaseLayer = 0;
829+
}
830+
else
831+
{
832+
TMSOptions imagery;
833+
imagery.url() = url.toStdString();
834+
mBaseLayer = new ImageLayer( "Imagery", imagery );
835+
mMapNode->getMap()->insertImageLayer( mBaseLayer, 0 );
836+
}
837+
}
838+
}
839+
840+
void GlobePlugin::setSkyParameters( bool enabled, const QDateTime& dateTime, bool autoAmbience )
841+
{
842+
if ( mRootNode )
843+
{
844+
if ( enabled )
845+
{
846+
// Create if not yet done
847+
if ( !mSkyNode.get() )
848+
mSkyNode = new SkyNode( mMapNode->getMap() );
849+
850+
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 4, 0 )
851+
mSkyNode->setAutoAmbience( autoAmbience );
852+
#endif
853+
mSkyNode->setDateTime( dateTime.date().year()
854+
, dateTime.date().month()
855+
, dateTime.date().day()
856+
, dateTime.time().hour() + dateTime.time().minute() / 60.0 );
857+
//sky->setSunPosition( osg::Vec3(0,-1,0) );
858+
mSkyNode->attach( mOsgViewer );
859+
mRootNode->addChild( mSkyNode );
860+
}
861+
else
862+
{
863+
mRootNode->removeChild( mSkyNode );
864+
}
865+
}
866+
}
867+
811868
void GlobePlugin::reset()
812869
{
813870
if ( mViewerWidget )

‎src/plugins/globe/globe_plugin.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class QToolBar;
5151
class QgisInterface;
5252

5353
namespace osgEarth { namespace QtGui { class ViewerWidget; } }
54+
namespace osgEarth { namespace Util { class SkyNode; } }
5455

5556
class GlobePlugin : public QObject, public QgisPlugin
5657
{
@@ -74,10 +75,14 @@ class GlobePlugin : public QObject, public QgisPlugin
7475
//! show the help document
7576
void help();
7677

77-
//! Emitted when a new set of image layers has been received
78+
//! Called when a new set of image layers has been received
7879
void imageLayersChanged();
79-
//! Emitted when a new set of elevation layers has been received
80+
//! Called when a new set of elevation layers has been received
8081
void elevationLayersChanged();
82+
//! Set a different base map (QString::NULL will disable the base map)
83+
void setBaseMap( QString url );
84+
//! Called when the extents of the map change
85+
void setSkyParameters( bool enabled, const QDateTime& dateTime, bool autoAmbience );
8186
//! Called when the extents of the map change
8287
void extentsChanged();
8388
//! Sync globe extent to mapCanavas
@@ -107,6 +112,8 @@ class GlobePlugin : public QObject, public QgisPlugin
107112
//! Place an OSG model on the globe
108113
void placeNode( osg::Node* node, double lat, double lon, double alt = 0.0 );
109114

115+
osgViewer::Viewer* osgViewer() { return mOsgViewer; }
116+
110117
//! Recursive copy folder
111118
static void copyFolder( QString sourceFolder, QString destFolder );
112119

@@ -137,6 +144,10 @@ class GlobePlugin : public QObject, public QgisPlugin
137144
osg::Group* mRootNode;
138145
//! Map node
139146
osgEarth::MapNode* mMapNode;
147+
//! Base layer
148+
osg::ref_ptr<osgEarth::ImageLayer> mBaseLayer;
149+
//! Sky node
150+
osg::ref_ptr<osgEarth::Util::SkyNode> mSkyNode;
140151
//! QGIS maplayer
141152
osgEarth::ImageLayer* mQgisMapLayer;
142153
//! Tile source

0 commit comments

Comments
 (0)
Please sign in to comment.