Added functionality to lock a map canvas to prevent user interaction so that the overview canvas cant be misused,

e.g.:
  mOverviewCanvas->userInteractionAllowed(false);

This fixes bug: 977032

Fix "overview does not zoom to all when layer removed" bug [ 977034 ]

Fixed overview paints multiple times bug 977015


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@1686 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-06-26 23:14:35 +00:00
parent 1bd31fc49b
commit 6aea5c8564
3 changed files with 27 additions and 0 deletions

View File

@ -300,6 +300,8 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare
mMapLegend->setSorting(-1);
mOverviewCanvas = new QgsMapCanvas(legendOverviewSplit);
// lock the canvas to prevent user interaction
mOverviewCanvas->userInteractionAllowed(false);
// mL = new QScrollView(canvasLegendSplit);
//add a canvas
mMapCanvas = new QgsMapCanvas(canvasLegendSplit);
@ -1742,6 +1744,7 @@ void QgisApp::removeLayer()
mMapLayerRegistry->removeMapLayer(layer->getLayerID());
mOverviewCanvas->freeze(false);
// draw the map
mOverviewCanvas->zoomFullExtent();
mOverviewCanvas->clear();
mOverviewCanvas->render();
mMapCanvas->freeze(false);

View File

@ -207,6 +207,8 @@ QgsMapCanvas::QgsMapCanvas(QWidget * parent, const char *name)
: QWidget(parent, name), mCanvasProperties( new CanvasProperties(width(), height()) )
{
setEraseColor(mCanvasProperties->bgColor);
//by default we allow a user to interact with the canvas
mUserInteractionAllowed=true;
setMouseTracking(true);
setFocusPolicy(QWidget::StrongFocus);
QPaintDeviceMetrics *pdm = new QPaintDeviceMetrics(this);
@ -733,6 +735,7 @@ void QgsMapCanvas::zoomToSelected()
void QgsMapCanvas::mousePressEvent(QMouseEvent * e)
{
if (!mUserInteractionAllowed) return;
mCanvasProperties->mouseButtonDown = true;
mCanvasProperties->boxStartPoint = e->pos();
@ -752,6 +755,7 @@ void QgsMapCanvas::mousePressEvent(QMouseEvent * e)
void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
{
if (!mUserInteractionAllowed) return;
QPainter paint;
QPen pen(Qt::gray);
QgsPoint ll, ur;
@ -974,6 +978,7 @@ void QgsMapCanvas::resizeEvent(QResizeEvent * e)
void QgsMapCanvas::mouseMoveEvent(QMouseEvent * e)
{
if (!mUserInteractionAllowed) return;
// XXX magic numbers BAD -- 513?
if (e->state() == Qt::LeftButton || e->state() == 513)
{
@ -1266,6 +1271,17 @@ std::list < QString > & QgsMapCanvas::zOrders()
return mCanvasProperties->zOrder;
} // zOrders
//! determines whether the user can interact with the overview canvas.
void QgsMapCanvas::userInteractionAllowed(bool theFlag)
{
mUserInteractionAllowed = theFlag;
}
//! determines whether the user can interact with the overview canvas.
bool QgsMapCanvas::isUserInteractionAllowed()
{
return mUserInteractionAllowed;
}
double QgsMapCanvas::mupp() const
{

View File

@ -185,6 +185,11 @@ public slots:
//! sets z order based on order of layers in the legend
void setZOrderFromLegend(QgsLegend *lv);
//! determines whether the user can interact with the overview canvas.
void userInteractionAllowed(bool);
//! accessor to flag indicating whether the user can interact with the canvase
bool isUserInteractionAllowed();
signals:
/** Let the owner know how far we are with render operations */
void setProgress(int,int);
@ -261,6 +266,9 @@ private:
//! true if canvas currently drawing
bool isDrawing();
//! detrmines whether the user can interact with the canvas using a mouse
//(useful for locking the overview canvas)
bool mUserInteractionAllowed;
}; // class QgsMapCanvas
#endif