Skip to content
Permalink
Browse files
Revert last four accidental commits:
backport wmts support: 50ba992
WMTS/WMS updates: 84959cb
missed a dialog: 4b5d265.
[FEATURE] WMTS: 2130b02
  • Loading branch information
jef-n committed May 16, 2012
1 parent 50ba992 commit f503bc3eb8e649103f455be5cb27571cb45d74a8
@@ -33,11 +33,11 @@ fi

# save original changes
if [ -d .svn ]; then
REV=r$(svn info | sed -ne "s/Revision: //p")
svn diff >rev-$REV.diff
REV=$(svn info | sed -ne "s/Revision: //p")
svn diff >r$REV.diff
elif [ -d .git ]; then
REV=$(git log -n1 --pretty=%H)
git diff >sha-$REV.diff
REV=$(git svn info | sed -ne "s/Revision: //p")
git diff >r$REV.diff
fi

ASTYLEDIFF=astyle.r$REV.diff
@@ -80,10 +80,12 @@ SET(QGIS_APP_SRCS
qgsrastercalcdialog.cpp
qgsrasterlayerproperties.cpp
qgstextannotationdialog.cpp
qgswmssourceselect.cpp
qgsshortcutsmanager.cpp
qgssinglesymboldialog.cpp
qgssnappingdialog.cpp
qgsundowidget.cpp
qgstilescalewidget.cpp
qgstipgui.cpp
qgstipfactory.cpp
qgsuniquevaluedialog.cpp
@@ -210,11 +212,13 @@ SET (QGIS_APP_MOC_HDRS
qgssnappingdialog.h
qgssponsors.h
qgstextannotationdialog.h
qgstilescalewidget.h
qgstipgui.h
qgstipfactory.h
qgsundowidget.h
qgsuniquevaluedialog.h
qgsvectorlayerproperties.h
qgswmssourceselect.h
qgshandlebadlayers.h

composer/qgsattributeselectiondialog.h
@@ -155,6 +155,7 @@
#include "qgssnappingdialog.h"
#include "qgssponsors.h"
#include "qgstextannotationitem.h"
#include "qgstilescalewidget.h"
#include "qgstipgui.h"
#include "qgsundowidget.h"
#include "qgsvectordataprovider.h"
@@ -374,6 +375,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
, mSplash( splash )
, mShowProjectionTab( false )
, mPythonUtils( NULL )
, mpTileScaleWidget( NULL )
#ifdef Q_OS_WIN
, mSkipNextContextMenuEvent( 0 )
#endif
@@ -575,8 +577,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
QgsApplication::setFileOpenEventReceiver( this );

QgsProviderRegistry::instance()->registerGuis( this );

// update windows
qApp->processEvents();

@@ -694,6 +694,11 @@ void QgisApp::readSettings()
// Add the recently accessed project file paths to the File menu
mRecentProjectPaths = settings.value( "/UI/recentProjectsList" ).toStringList();

// Restore state of tile scale widget
if ( settings.value( "/UI/tileScaleEnabled", false ).toBool() )
{
showTileScale();
}
// Restore state of GPS Tracker
if ( settings.value( "/gps/widgetEnabled", false ).toBool() )
{
@@ -795,6 +800,7 @@ void QgisApp::createActions()
connect( mActionRemoveLayer, SIGNAL( triggered() ), this, SLOT( removeLayer() ) );
connect( mActionSetLayerCRS, SIGNAL( triggered() ), this, SLOT( setLayerCRS() ) );
connect( mActionSetProjectCRSFromLayer, SIGNAL( triggered() ), this, SLOT( setProjectCRSFromLayer() ) );
connect( mActionTileScale, SIGNAL( triggered() ), this, SLOT( showTileScale() ) );
connect( mActionGpsTool, SIGNAL( triggered() ), this, SLOT( showGpsTool() ) );
connect( mActionLayerProperties, SIGNAL( triggered() ), this, SLOT( layerProperties() ) );
connect( mActionLayerSubsetString, SIGNAL( triggered() ), this, SLOT( layerSubsetString() ) );
@@ -1844,6 +1850,17 @@ void QgisApp::saveWindowState()
// store window geometry
settings.setValue( "/UI/geometry", saveGeometry() );

// Persist state of tile scale slider
if ( mpTileScaleWidget )
{
settings.setValue( "/UI/tileScaleEnabled", true );
delete mpTileScaleWidget;
}
else
{
settings.setValue( "/UI/tileScaleEnabled", false );
}

// Persist state of GPS Tracker
if ( mpGpsWidget )
{
@@ -4486,6 +4503,32 @@ void QgisApp::showGpsTool()
}
}

void QgisApp::showTileScale()
{
if ( !mpTileScaleWidget )
{
mpTileScaleWidget = new QgsTileScaleWidget( mMapCanvas );
//create the dock widget
mpTileScaleDock = new QDockWidget( tr( "Tile scale" ), this );
mpTileScaleDock->setObjectName( "TileScale" );
mpTileScaleDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
addDockWidget( Qt::RightDockWidgetArea, mpTileScaleDock );
// add to the Panel submenu
mPanelMenu->addAction( mpTileScaleDock->toggleViewAction() );
// now add our widget to the dock - ownership of the widget is passed to the dock
mpTileScaleDock->setWidget( mpTileScaleWidget );
mpTileScaleDock->show();

connect( mMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
mpTileScaleWidget, SLOT( layerChanged( QgsMapLayer* ) ) );

}
else
{
mpTileScaleDock->setVisible( mpTileScaleDock->isHidden() );
}
}

void QgisApp::zoomToLayerExtent()
{
mMapLegend->legendLayerZoom();
@@ -59,6 +59,7 @@ class QgsRasterLayer;
class QgsRectangle;
class QgsUndoWidget;
class QgsVectorLayer;
class QgsTileScaleWidget;

class QDomDocument;
class QNetworkReply;
@@ -276,6 +277,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionRemoveLayer() { return mActionRemoveLayer; }
QAction *actionSetLayerCRS() { return mActionSetLayerCRS; }
QAction *actionSetProjectCRSFromLayer() { return mActionSetProjectCRSFromLayer; }
QAction *actionTileScale() { return mActionTileScale; }
QAction *actionGpsTool() { return mActionGpsTool; }
QAction *actionLayerProperties() { return mActionLayerProperties; }
QAction *actionLayerSubsetString() { return mActionLayerSubsetString; }
@@ -485,6 +487,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void setProjectCRSFromLayer();
//! Show GPS tool
void showGpsTool();
//! Show tile scale slider
void showTileScale();
//! zoom to extent of layer
void zoomToLayerExtent();
//! zoom to actual size of raster layer
@@ -900,6 +904,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
// docks ------------------------------------------
QDockWidget *mLegendDock;
QDockWidget *mOverviewDock;
QDockWidget *mpTileScaleDock;
QDockWidget *mpGpsDock;


@@ -1058,6 +1063,9 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

QgsSnappingDialog* mSnappingDialog;

//! Persistent tile scale slider
QgsTileScaleWidget * mpTileScaleWidget;

int mLastComposerId;

#ifdef Q_OS_WIN
@@ -19,14 +19,8 @@
#include "qgstilescalewidget.h"
#include "qgsmapcanvas.h"
#include "qgsrasterlayer.h"
#include "qgswmsprovider.h"
#include "qgslogger.h"

#include <QDockWidget>
#include <QMainWindow>
#include <QMenu>
#include <QGraphicsView>

QgsTileScaleWidget::QgsTileScaleWidget( QgsMapCanvas * mapCanvas, QWidget * parent, Qt::WindowFlags f )
: QWidget( parent, f )
, mMapCanvas( mapCanvas )
@@ -38,46 +32,54 @@ QgsTileScaleWidget::QgsTileScaleWidget( QgsMapCanvas * mapCanvas, QWidget * pare
layerChanged( mMapCanvas->currentLayer() );
}

QgsTileScaleWidget::~QgsTileScaleWidget()
{
QSettings settings;
settings.setValue( "/UI/tileScaleEnabled", isVisible() );
}

void QgsTileScaleWidget::layerChanged( QgsMapLayer *layer )
{
QgsRasterLayer *rl = qobject_cast<QgsRasterLayer *>( layer );
if ( !rl )
return;

QgsWmsProvider *wms = qobject_cast<QgsWmsProvider *>( rl->dataProvider() );
if ( !wms )
return;
mResolutions.clear();
mSlider->setDisabled( true );

QgsWmtsTileMatrixSet *tileMatrixSet = wms->tileMatrixSet();
if ( !tileMatrixSet )
if ( !rl || rl->providerKey() != "wms" )
return;

mSlider->setDisabled( true );

mResolutions = tileMatrixSet->tileMatrices.keys();
qSort( mResolutions );
QString uri = rl->source();
int tiledpos = uri.indexOf( "tiled=" );
int urlpos = uri.indexOf( "url=" );

for ( int i = 0; i < mResolutions.size(); i++ )
if ( tiledpos >= 0 && urlpos >= 0 && urlpos > tiledpos )
{
QgsDebugMsg( QString( "found resolution %1: %2" ).arg( i ).arg( mResolutions[i] ) );
uri = uri.mid( tiledpos + 6 );
int pos = uri.indexOf( "," );
if ( pos >= 0 )
uri = uri.left( pos );
QStringList params = uri.split( ";" );
if ( params.size() < 3 )
return;

params.takeFirst();
params.takeFirst();

mResolutions.clear();
foreach( QString r, params )
{
mResolutions << r.toDouble();
}
qSort( mResolutions );

for ( int i = 0; i < mResolutions.size(); i++ )
QgsDebugMsg( QString( "found resolution %1: %2" ).arg( i ).arg( mResolutions[i] ) );

mSlider->setRange( 0, mResolutions.size() - 1 );
mSlider->setTickInterval( 1 );
mSlider->setInvertedAppearance( true );
mSlider->setPageStep( 1 );
mSlider->setTracking( false );

scaleChanged( mMapCanvas->scale() );

mSlider->setEnabled( true );
show();
}

mSlider->setRange( 0, mResolutions.size() - 1 );
mSlider->setTickInterval( 1 );
mSlider->setInvertedAppearance( true );
mSlider->setPageStep( 1 );
mSlider->setTracking( false );

scaleChanged( mMapCanvas->scale() );

mSlider->setEnabled( true );
show();
}

void QgsTileScaleWidget::scaleChanged( double scale )
@@ -100,68 +102,11 @@ void QgsTileScaleWidget::scaleChanged( double scale )
}

QgsDebugMsg( QString( "selected resolution %1: %2" ).arg( i ).arg( mResolutions[i] ) );
mSlider->blockSignals( true );
mSlider->setValue( i );
mSlider->blockSignals( false );
}

void QgsTileScaleWidget::on_mSlider_valueChanged( int value )
{
QgsDebugMsg( QString( "slider released at %1: %2" ).arg( mSlider->value() ).arg( mResolutions[mSlider->value()] ) );
mMapCanvas->zoomByFactor( mResolutions[mSlider->value()] / mMapCanvas->mapUnitsPerPixel() );
}

void QgsTileScaleWidget::showTileScale( QMainWindow *mainWindow )
{
QDockWidget *dock = mainWindow->findChild<QDockWidget *>( "theTileScaleDock" );
if ( dock )
{
dock->setVisible( dock->isHidden() );
return;
}

QgsMapCanvas *canvas = mainWindow->findChild<QgsMapCanvas *>( "theMapCanvas" );
QgsDebugMsg( QString( "canvas:%1 [%2]" ).arg(( ulong ) canvas, 0, 16 ).arg( canvas ? canvas->objectName() : "" ) );
if ( !canvas )
{
QgsDebugMsg( "map canvas theMapCanvas not found" );
return;
}

QgsTileScaleWidget *tws = new QgsTileScaleWidget( canvas );
tws->setObjectName( "theTileScaleWidget" );

QObject *legend = mainWindow->findChild<QObject*>( "theMapLegend" );
if ( legend )
{
connect( legend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
tws, SLOT( layerChanged( QgsMapLayer* ) ) );
}
else
{
QgsDebugMsg( "legend not found" );
}

//create the dock widget
dock = new QDockWidget( tr( "Tile scale" ), mainWindow );
dock->setObjectName( "theTileScaleDock" );
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mainWindow->addDockWidget( Qt::RightDockWidgetArea, dock );

// add to the Panel submenu
QMenu *panelMenu = mainWindow->findChild<QMenu *>( "mPanelMenu" );
if ( panelMenu )
{
// add to the Panel submenu
panelMenu->addAction( dock->toggleViewAction() );
}
else
{
QgsDebugMsg( "panel menu not found" );
}

panelMenu->addAction( dock->toggleViewAction() );

dock->setWidget( tws );
dock->show();
}
@@ -23,24 +23,20 @@

class QgsMapCanvas;
class QgsMapLayer;
class QMainWindow;
class QwtSlider;

class QgsTileScaleWidget : public QWidget, private Ui::QgsTileScaleWidget
{
Q_OBJECT

public:
static void showTileScale( QMainWindow *mainWindow );
QgsTileScaleWidget( QgsMapCanvas *mapCanvas, QWidget * parent = 0, Qt::WindowFlags f = 0 );

public slots:
void layerChanged( QgsMapLayer *layer );
void scaleChanged( double );
void on_mSlider_valueChanged( int );

private:
QgsTileScaleWidget( QgsMapCanvas *mapCanvas, QWidget *parent = 0, Qt::WindowFlags f = 0 );
~QgsTileScaleWidget();

QgsMapCanvas *mMapCanvas;
QList<double> mResolutions;
};
Loading

0 comments on commit f503bc3

Please sign in to comment.