Skip to content
Permalink
Browse files
Several WMS-related improvements:
* Better bounding-box checking on legacy WMS servers - JPL World Map Service works again.
* Providers can now expose the last error encountered by the provider.  Only WMS returns useful information though.
* Error display is now handled by the QgsMapCanvas not the QgsWmsProvider - this frees QgsWmsProvider from a dependency on the GUI being available.
* For map redraws, QApplication::setOverrideCursor and QApplication::restoreOverrideCursor are now handled by the QgsMapCanvas not the QgisApp - this helps stop error message popups (via QMessageBox) from suffering from the "hourglass" cursor appearing not the "pointer".
* Consective WMS operations do not fail any more - the "url" variable was being appended to, not cleared before each draw.



git-svn-id: http://svn.osgeo.org/qgis/trunk@4907 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Feb 25, 2006
1 parent dad3f6b commit 8fc79ce38345d0b6307f2f1ba9b70df9eacf449c
@@ -87,7 +87,23 @@ class QgsRasterDataProvider : public QgsDataProvider
*/
virtual QString getMetadata() = 0;


/**
* If an operation returns 0 (e.g. draw()), this function
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
virtual QString errorCaptionString() = 0;

/**
* If an operation returns 0 (e.g. draw()), this function
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
virtual QString errorString() = 0;


protected:

};
@@ -1692,7 +1692,8 @@ void QgisApp::addLayer()
bool QgisApp::addLayer(QFileInfo const & vectorFile)
{
// let the user know we're going to possibly be taking a while
QApplication::setOverrideCursor(Qt::WaitCursor);
// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);

mMapCanvas->freeze(); // XXX why do we do this?

@@ -1732,7 +1733,8 @@ bool QgisApp::addLayer(QFileInfo const & vectorFile)
if ( ! renderer )
{
mMapCanvas->freeze(false);
QApplication::restoreOverrideCursor();
// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

// XXX should we also delete the layer?

@@ -1784,7 +1786,9 @@ bool QgisApp::addLayer(QFileInfo const & vectorFile)
delete layer;

mMapCanvas->freeze(false);
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

return false;
}
@@ -1800,7 +1804,8 @@ bool QgisApp::addLayer(QFileInfo const & vectorFile)
// the layer is intially added
mMapCanvas->update();

QApplication::restoreOverrideCursor();
// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

statusBar()->message(mMapCanvas->extent().stringRep(2));

@@ -1822,8 +1827,8 @@ bool QgisApp::addLayer(QStringList const &theLayerQStringList, const QString& en
{
mMapCanvas->freeze();

QApplication::setOverrideCursor(Qt::WaitCursor);

// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);

for ( QStringList::ConstIterator it = theLayerQStringList.begin();
it != theLayerQStringList.end();
@@ -1846,7 +1851,9 @@ bool QgisApp::addLayer(QStringList const &theLayerQStringList, const QString& en
if ( ! layer )
{
mMapCanvas->freeze(false);
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

// XXX insert meaningful whine to the user here
return false;
@@ -1868,7 +1875,9 @@ bool QgisApp::addLayer(QStringList const &theLayerQStringList, const QString& en
if ( ! renderer )
{
mMapCanvas->freeze(false);
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

// XXX insert meaningful whine to the user here
return false;
@@ -1937,7 +1946,10 @@ bool QgisApp::addLayer(QStringList const &theLayerQStringList, const QString& en
// [gsherman]
mMapCanvas->render();
mMapCanvas->update();
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

statusBar()->message(mMapCanvas->extent().stringRep(2));


@@ -1975,7 +1987,8 @@ void QgisApp::addDatabaseLayer()

if (dbs->exec())
{
QApplication::setOverrideCursor(Qt::WaitCursor);
// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);


// repaint the canvas if it was covered by the dialog
@@ -2056,7 +2069,10 @@ void QgisApp::addDatabaseLayer()
// [gsherman]
mMapCanvas->render();
mMapCanvas->update();
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

} // QgisApp::addDatabaseLayer()
#endif

@@ -4719,7 +4735,10 @@ QString QgisApp::activeLayerSource()
void QgisApp::addVectorLayer(QString vectorLayerPath, QString baseName, QString providerKey)
{
mMapCanvas->freeze();
QApplication::setOverrideCursor(Qt::WaitCursor);

// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);

// create the layer
QgsVectorLayer *layer;
/* Eliminate the need to instantiate the layer based on provider type.
@@ -4796,7 +4815,9 @@ void QgisApp::addVectorLayer(QString vectorLayerPath, QString baseName, QString
// [gsherman]
mMapCanvas->render();
mMapCanvas->update();
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

} // QgisApp::addVectorLayer

@@ -4805,7 +4826,10 @@ void QgisApp::addVectorLayer(QString vectorLayerPath, QString baseName, QString
void QgisApp::addMapLayer(QgsMapLayer *theMapLayer)
{
mMapCanvas->freeze();
QApplication::setOverrideCursor(Qt::WaitCursor);

// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);

if(theMapLayer->isValid())
{
// Register this layer with the layers registry
@@ -4838,7 +4862,9 @@ void QgisApp::addMapLayer(QgsMapLayer *theMapLayer)
// [gsherman]
mMapCanvas->render();
mMapCanvas->update();
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

}

@@ -5476,7 +5502,10 @@ bool QgisApp::addRasterLayer(QFileInfo const & rasterFile, bool guiWarning)
if (!addRasterLayer(layer))
{
mMapCanvas->freeze(false);
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

if(guiWarning)
{
// don't show the gui warning (probably because we are loading from command line)
@@ -5491,7 +5520,10 @@ bool QgisApp::addRasterLayer(QFileInfo const & rasterFile, bool guiWarning)
statusBar()->message(mMapCanvas->extent().stringRep(2));
mMapCanvas->freeze(false);
mOverviewCanvas->freeze(false);
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

return true;
}

@@ -5522,7 +5554,10 @@ void QgisApp::addRasterLayer(QString const & rasterLayerPath,
#endif

mMapCanvas->freeze();
QApplication::setOverrideCursor(Qt::WaitCursor);

// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);

// create the layer
QgsRasterLayer *layer;
/* Eliminate the need to instantiate the layer based on provider type.
@@ -5605,7 +5640,9 @@ void QgisApp::addRasterLayer(QString const & rasterLayerPath,
// [gsherman]
mMapCanvas->render();
mMapCanvas->update();
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

} // QgisApp::addRasterLayer

@@ -5627,7 +5664,9 @@ bool QgisApp::addRasterLayer(QStringList const &theFileNameQStringList, bool gui
mMapCanvas->freeze(true);
mOverviewCanvas->freeze(true);

QApplication::setOverrideCursor(Qt::WaitCursor);
// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);

// this is messy since some files in the list may be rasters and others may
// be ogr layers. We'll set returnValue to false if one or more layers fail
// to load.
@@ -5682,7 +5721,9 @@ bool QgisApp::addRasterLayer(QStringList const &theFileNameQStringList, bool gui
statusBar()->message(mMapCanvas->extent().stringRep(2));
mMapCanvas->freeze(false);
mOverviewCanvas->freeze(false);
QApplication::restoreOverrideCursor();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

return returnValue;

@@ -80,7 +80,7 @@ email : sherman at mrcc.com
#include <qcursor.h>

#include <QRubberBand>

#include <QApplication>

#include "qgis.h"
#include "qgsrect.h"
@@ -558,6 +558,10 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
{
if (!mCanvasProperties->drawing)
{

// Tell the user we're going to be a while
QApplication::setOverrideCursor(Qt::WaitCursor);

mCanvasProperties->drawing = true;
QPainter *paint = new QPainter();

@@ -747,10 +751,16 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
// Now do the call to the layer that actually does
// the rendering work!
//
ml->draw(paint, &r1, mCanvasProperties->coordXForm, this);
if (!ml->draw(paint, &r1, mCanvasProperties->coordXForm, this))
{
showError(ml);
}
if (split)
{
ml->draw(paint, &r2,mCanvasProperties->coordXForm, this);
if (!ml->draw(paint, &r2, mCanvasProperties->coordXForm, this))
{
showError(ml);
}
}
}
#ifdef QGISDEBUG
@@ -922,6 +932,9 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
paint->end();
mCanvasProperties->drawing = false;
delete paint;

// Tell the user we've finished going to be a while
QApplication::restoreOverrideCursor();
}
mCanvasProperties->dirty = false;

@@ -3345,3 +3358,17 @@ QgsPoint QgsMapCanvas::maybeInversePoint(QgsPoint point, const char whenmsg[])
}
return point;
}


void QgsMapCanvas::showError(QgsMapLayer * mapLayer)
{
QMessageBox::warning(
this,
mapLayer->errorCaptionString(),
tr("Could not draw") + " " + mapLayer->name() + " " + tr("because") + ":\n" +
mapLayer->errorCaptionString()
);

}

// ENDS
@@ -339,6 +339,9 @@ public slots:
*/
QgsMapCanvas();

//! show whatever error is exposed by the QgsMapLayer.
void showError(QgsMapLayer * mapLayer);

/**
List to store the points of digitised lines and polygons
@@ -153,7 +153,7 @@ void QgsMapLayer::draw(QPainter *, QgsRect * viewExtent, int yTransform)
// std::cout << "In QgsMapLayer::draw" << std::endl;
}

void QgsMapLayer::draw(QPainter *, QgsRect *, QgsMapToPixel *,QPaintDevice * )
bool QgsMapLayer::draw(QPainter *, QgsRect *, QgsMapToPixel *,QPaintDevice * )
{
// std::cout << "In QgsMapLayer::draw" << std::endl;
}
@@ -499,6 +499,16 @@ std::vector<QgsField> const & QgsMapLayer::fields() const
return bogus;
} // QgsMapLayer::fields()

QString QgsMapLayer::errorCaptionString()
{
return QString();
}

QString QgsMapLayer::errorString()
{
return QString();
}

void QgsMapLayer::connectNotify( const char * signal )
{
#ifdef QGISDEBUG
@@ -99,7 +99,10 @@ class QgsMapLayer : public QObject


virtual void draw(QPainter *, QgsRect *, int);
virtual void draw(QPainter *, QgsRect *, QgsMapToPixel * ,QPaintDevice *);

//! Returns FALSE if an error occurred during drawing
virtual bool draw(QPainter *, QgsRect *, QgsMapToPixel *, QPaintDevice *);

virtual void drawLabels(QPainter *, QgsRect *, QgsMapToPixel * ,QPaintDevice *);
/*! Identify the feature(s) in this layer that are contained in the search rectangle
*/
@@ -284,6 +287,25 @@ class QgsMapLayer : public QObject

/** \brief accessor for transparency level. */
virtual unsigned int getTransparency()=0;


/**
* If an operation returns 0 (e.g. draw()), this function
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
QString errorCaptionString();

/**
* If an operation returns 0 (e.g. draw()), this function
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
QString errorString();


public slots:
/** \brief Mutator for transparency level. Should be between 0 and 255 */
virtual void setTransparency(int)=0; //

0 comments on commit 8fc79ce

Please sign in to comment.