Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into Issue_8725-OGR
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuarte47 committed Nov 15, 2013
2 parents dc078b8 + 836e1a8 commit e9ae374
Show file tree
Hide file tree
Showing 15 changed files with 404 additions and 161 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -221,6 +221,7 @@ SET (HAVE_MSSQL TRUE)
# search for Qt4
SET(QT_MIN_VERSION 4.5.0)
FIND_PACKAGE(Qt4 ${QT_MIN_VERSION} REQUIRED)
MESSAGE(STATUS "Found Qt version: ${QTVERSION}")
SET(QT_USE_QTXML 1)
SET(QT_USE_QTNETWORK 1)
SET(QT_USE_QTSVG 1)
Expand Down
183 changes: 93 additions & 90 deletions i18n/qgis_fr.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion python/core/composer/qgscomposerattributetable.sip
Expand Up @@ -57,7 +57,8 @@ class QgsComposerAttributeTable : QgsComposerTable

//void setSortAttributes( const QList<QPair<int, bool> > att );
//QList<QPair<int, bool> > sortAttributes() const;

protected:
virtual QMap<int, QString> getHeaderLabels() const;

signals:
/**This signal is emitted if the maximum number of feature changes (interactively)*/
Expand Down
5 changes: 4 additions & 1 deletion src/analysis/openstreetmap/qgsosmdatabase.cpp
Expand Up @@ -489,7 +489,10 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
sqlite3_bind_null( stmtInsert, ++col );
}

sqlite3_bind_blob( stmtInsert, ++col, geom->asWkb(), ( int ) geom->wkbSize(), SQLITE_STATIC );
if ( geom )
sqlite3_bind_blob( stmtInsert, ++col, geom->asWkb(), ( int ) geom->wkbSize(), SQLITE_STATIC );
else
sqlite3_bind_null( stmtInsert, ++col );

int insertRes = sqlite3_step( stmtInsert );
if ( insertRes != SQLITE_DONE )
Expand Down
3 changes: 3 additions & 0 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -114,8 +114,11 @@ QgsLegend::QgsLegend( QgsMapCanvas *canvas, QWidget * parent, const char *name )

connect( mMapCanvas, SIGNAL( layersChanged() ),
this, SLOT( refreshCheckStates() ) );
#if 0
// too much
connect( mMapCanvas, SIGNAL( extentsChanged() ),
this, SLOT( updateLegendItemSymbologies() ) );
#endif

// Initialise the line indicator widget.
mInsertionLine = new QWidget( viewport() );
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -2016,7 +2016,7 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )
{
//already in database, do update
QgsDebugMsg( "Trying datum transform update" );
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" )
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" )
.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 );
}
else
Expand All @@ -2030,7 +2030,7 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )

if ( sqlite3_exec( db, sql.toUtf8(), 0, 0, 0 ) != SQLITE_OK )
{
QgsDebugMsg( "Error" );
QgsDebugMsg( QString( "Error [%1]" ).arg( sqlite3_errmsg( db ) ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpression.cpp
Expand Up @@ -1618,8 +1618,8 @@ int QgsExpression::functionCount()
QgsExpression::QgsExpression( const QString& expr )
: mRowNumber( 0 )
, mScale( 0 )
, mCalc( 0 )
, mExp( expr )
, mCalc( 0 )
{
mRootNode = ::parseExpression( expr, mParserErrorString );

Expand Down
12 changes: 9 additions & 3 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Expand Up @@ -77,7 +77,7 @@ bool QgsAttributeTableModel::loadFeatureAtId( QgsFeatureId fid ) const

void QgsAttributeTableModel::featureDeleted( QgsFeatureId fid )
{
QgsDebugMsg( QString( "(%2) fid: %1" ).arg( fid ).arg( mFeatureRequest.filterType() ) );
QgsDebugMsgLevel( QString( "(%2) fid: %1" ).arg( fid ).arg( mFeatureRequest.filterType() ), 4 );
mFieldCache.remove( fid );

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

void QgsAttributeTableModel::featureAdded( QgsFeatureId fid )
{
QgsDebugMsg( QString( "(%2) fid: %1" ).arg( fid ).arg( mFeatureRequest.filterType() ) );
if ( loadFeatureAtId( fid ) && mFeatureRequest.acceptFeature( mFeat ) )
QgsDebugMsgLevel( QString( "(%2) fid: %1" ).arg( fid ).arg( mFeatureRequest.filterType() ), 4 );
bool featOk = true;

if ( mFeat.id() != fid )
featOk = loadFeatureAtId( fid );

if ( featOk && mFeatureRequest.acceptFeature( mFeat ) )
{
mFieldCache[ fid ] = mFeat.attribute( mCachedField );

Expand Down Expand Up @@ -351,6 +356,7 @@ void QgsAttributeTableModel::loadLayer()

t.restart();
}
mFeat = feat;
featureAdded( feat.id() );
}

Expand Down
57 changes: 32 additions & 25 deletions src/gui/qgsattributeeditor.cpp
Expand Up @@ -1392,41 +1392,48 @@ QWidget* QgsAttributeEditor::createWidgetFromDef( const QgsAttributeEditorElemen
{
const QgsAttributeEditorField* fieldDef = dynamic_cast<const QgsAttributeEditorField*>( widgetDef );
int fldIdx = fieldDef->idx();
newWidget = createAttributeEditor( parent, 0, vl, fldIdx, feat.attributes().value( fldIdx, QVariant() ), context );

if ( newWidget )
if ( fldIdx < vl->pendingFields().count() && fldIdx >= 0 )
{
if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
newWidget = createAttributeEditor( parent, 0, vl, fldIdx, feat.attributes().value( fldIdx, QVariant() ), context );

if ( newWidget )
{
if ( newWidget->isEnabled() && vl->isEditable() && vl->fieldEditable( fldIdx ) )
if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
{
newWidget->setEnabled( true );
}
else if ( vl->editType( fldIdx ) == QgsVectorLayer::Photo )
{
foreach ( QWidget *w, newWidget->findChildren<QWidget *>() )
if ( newWidget->isEnabled() && vl->isEditable() && vl->fieldEditable( fldIdx ) )
{
w->setEnabled( qobject_cast<QLabel *>( w ) ? true : false );
newWidget->setEnabled( true );
}
}
else if ( vl->editType( fldIdx ) == QgsVectorLayer::WebView )
{
foreach ( QWidget *w, newWidget->findChildren<QWidget *>() )
else if ( vl->editType( fldIdx ) == QgsVectorLayer::Photo )
{
if ( qobject_cast<QWebView *>( w ) )
w->setEnabled( true );
else if ( qobject_cast<QPushButton *>( w ) && w->objectName() == "openUrl" )
w->setEnabled( true );
else
w->setEnabled( false );
foreach ( QWidget *w, newWidget->findChildren<QWidget *>() )
{
w->setEnabled( qobject_cast<QLabel *>( w ) ? true : false );
}
}
else if ( vl->editType( fldIdx ) == QgsVectorLayer::WebView )
{
foreach ( QWidget *w, newWidget->findChildren<QWidget *>() )
{
if ( qobject_cast<QWebView *>( w ) )
w->setEnabled( true );
else if ( qobject_cast<QPushButton *>( w ) && w->objectName() == "openUrl" )
w->setEnabled( true );
else
w->setEnabled( false );
}
}
else
{
newWidget->setEnabled( false );
}
}
else
{
newWidget->setEnabled( false );
}
}
}
else
{
newWidget = new QLabel( tr( "<i>Error: Field does not exist in datasource</i>" ), parent );
}
labelOnTop = vl->labelOnTop( fieldDef->idx() );
labelText = vl->attributeDisplayName( fieldDef->idx() );
break;
Expand Down
95 changes: 76 additions & 19 deletions src/plugins/globe/globe_plugin.cpp
Expand Up @@ -62,7 +62,9 @@
#include <osgEarthDrivers/gdal/GDALOptions>
#include <osgEarthDrivers/tms/TMSOptions>
#include <osgEarth/Version>

#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 2, 0 )
#include <osgEarthDrivers/cache_filesystem/FileSystemCache>
#endif
using namespace osgEarth::Drivers;
using namespace osgEarth::Util;

Expand All @@ -85,6 +87,7 @@ GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
, mQActionSettingsPointer( NULL )
, mOsgViewer( 0 )
, mViewerWidget( 0 )
, mBaseLayer( 0 )
, mQgisMapLayer( 0 )
, mTileSource( 0 )
, mElevationManager( NULL )
Expand Down Expand Up @@ -117,7 +120,7 @@ GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
}
#endif

mSettingsDialog = new QgsGlobePluginDialog( theQgisInterface->mainWindow(), QgisGui::ModalDialogFlags );
mSettingsDialog = new QgsGlobePluginDialog( theQgisInterface->mainWindow(), this, QgisGui::ModalDialogFlags );
}

//destructor
Expand Down Expand Up @@ -281,17 +284,18 @@ void GlobePlugin::run()
setupMap();
}

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

// create a surface to house the controls
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 1, 1 )
mControlCanvas = ControlCanvas::get( mOsgViewer );
#else
mControlCanvas = new ControlCanvas( mOsgViewer );
#endif

mRootNode->addChild( mControlCanvas );

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

mSettingsDialog->setViewer( mOsgViewer );

#ifdef GLOBE_OSG_STANDALONE_VIEWER
mOsgViewer->run();
#endif
Expand Down Expand Up @@ -374,14 +376,18 @@ void GlobePlugin::settings()
void GlobePlugin::setupMap()
{
QSettings settings;
/*
QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();

#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 2, 0 )
FileSystemCacheOptions cacheOptions;
cacheOptions.rootPath() = cacheDirectory.toStdString();
#else
TMSCacheOptions cacheOptions;
cacheOptions.setPath( cacheDirectory.toStdString() );
*/
#endif

MapOptions mapOptions;
//mapOptions.cache() = cacheOptions;
mapOptions.cache() = cacheOptions;
osgEarth::Map *map = new osgEarth::Map( mapOptions );

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

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

if ( settings.value( "/Plugin-Globe/baseLayerEnabled", true ).toBool() )
{
setBaseMap( settings.value( "/Plugin-Globe/baseLayerURL", "http://readymap.org/readymap/tiles/1.0.0/7/" ).toString() );
}

mRootNode = new osg::Group();
mRootNode->addChild( mMapNode );

Expand Down Expand Up @@ -741,9 +749,11 @@ void GlobePlugin::imageLayersChanged()
mTileSource = new QgsOsgEarthTileSource( mQGisIface );
mTileSource->initialize( "", 0 );
ImageLayerOptions options( "QGIS" );
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 2, 0 )
options.cachePolicy() = CachePolicy::NO_CACHE;
#endif
mQgisMapLayer = new ImageLayer( options, mTileSource );
map->addImageLayer( mQgisMapLayer );
//[layer->setCache is private in 1.3.0] mQgisMapLayer->setCache( 0 ); //disable caching
}
else
{
Expand Down Expand Up @@ -808,6 +818,53 @@ void GlobePlugin::elevationLayersChanged()
}
}

void GlobePlugin::setBaseMap( QString url )
{
if ( mMapNode )
{
mMapNode->getMap()->removeImageLayer( mBaseLayer );
if ( url.isNull() )
{
mBaseLayer = 0;
}
else
{
TMSOptions imagery;
imagery.url() = url.toStdString();
mBaseLayer = new ImageLayer( "Imagery", imagery );
mMapNode->getMap()->insertImageLayer( mBaseLayer, 0 );
}
}
}

void GlobePlugin::setSkyParameters( bool enabled, const QDateTime& dateTime, bool autoAmbience )
{
if ( mRootNode )
{
if ( enabled )
{
// Create if not yet done
if ( !mSkyNode.get() )
mSkyNode = new SkyNode( mMapNode->getMap() );

#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 4, 0 )
mSkyNode->setAutoAmbience( autoAmbience );
#endif
mSkyNode->setDateTime( dateTime.date().year()
, dateTime.date().month()
, dateTime.date().day()
, dateTime.time().hour() + dateTime.time().minute() / 60.0 );
//sky->setSunPosition( osg::Vec3(0,-1,0) );
mSkyNode->attach( mOsgViewer );
mRootNode->addChild( mSkyNode );
}
else
{
mRootNode->removeChild( mSkyNode );
}
}
}

void GlobePlugin::reset()
{
if ( mViewerWidget )
Expand Down
15 changes: 13 additions & 2 deletions src/plugins/globe/globe_plugin.h
Expand Up @@ -51,6 +51,7 @@ class QToolBar;
class QgisInterface;

namespace osgEarth { namespace QtGui { class ViewerWidget; } }
namespace osgEarth { namespace Util { class SkyNode; } }

class GlobePlugin : public QObject, public QgisPlugin
{
Expand All @@ -74,10 +75,14 @@ class GlobePlugin : public QObject, public QgisPlugin
//! show the help document
void help();

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

osgViewer::Viewer* osgViewer() { return mOsgViewer; }

//! Recursive copy folder
static void copyFolder( QString sourceFolder, QString destFolder );

Expand Down Expand Up @@ -137,6 +144,10 @@ class GlobePlugin : public QObject, public QgisPlugin
osg::Group* mRootNode;
//! Map node
osgEarth::MapNode* mMapNode;
//! Base layer
osg::ref_ptr<osgEarth::ImageLayer> mBaseLayer;
//! Sky node
osg::ref_ptr<osgEarth::Util::SkyNode> mSkyNode;
//! QGIS maplayer
osgEarth::ImageLayer* mQgisMapLayer;
//! Tile source
Expand Down

0 comments on commit e9ae374

Please sign in to comment.