Skip to content

Commit

Permalink
Remove mDrawing from canvas - it is now transparent to the user
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Nov 1, 2013
1 parent 9fb6a1c commit fd10fae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 102 deletions.
99 changes: 1 addition & 98 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -96,7 +96,6 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
mMapTool = NULL;
mLastNonZoomMapTool = NULL;

mDrawing = false;
mFrozen = false;
mDirty = true;

Expand Down Expand Up @@ -230,7 +229,7 @@ bool QgsMapCanvas::isDirty() const

bool QgsMapCanvas::isDrawing()
{
return mDrawing;
return false;
} // isDrawing


Expand All @@ -243,12 +242,6 @@ const QgsMapToPixel * QgsMapCanvas::getCoordinateTransform()

void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
{
if ( mDrawing )
{
QgsDebugMsg( "NOT updating layer set while drawing" );
return;
}

// create layer set
QStringList layerSet, layerSetOverview;

Expand Down Expand Up @@ -564,11 +557,6 @@ void QgsMapCanvas::updateFullExtent()

void QgsMapCanvas::setExtent( QgsRectangle const & r )
{
if ( mDrawing )
{
return;
}

QgsRectangle current = extent();

if ( r.isEmpty() )
Expand Down Expand Up @@ -634,11 +622,6 @@ void QgsMapCanvas::clear()

void QgsMapCanvas::zoomToFullExtent()
{
if ( mDrawing )
{
return;
}

QgsRectangle extent = fullExtent();
// If the full extent is an empty set, don't do the zoom
if ( !extent.isEmpty() )
Expand All @@ -655,11 +638,6 @@ void QgsMapCanvas::zoomToFullExtent()

void QgsMapCanvas::zoomToPreviousExtent()
{
if ( mDrawing )
{
return;
}

if ( mLastExtentIndex > 0 )
{
mLastExtentIndex--;
Expand All @@ -681,10 +659,6 @@ void QgsMapCanvas::zoomToPreviousExtent()

void QgsMapCanvas::zoomToNextExtent()
{
if ( mDrawing )
{
return;
}
if ( mLastExtentIndex < mLastExtent.size() - 1 )
{
mLastExtentIndex++;
Expand Down Expand Up @@ -739,11 +713,6 @@ void QgsMapCanvas::mapUnitsChanged()

void QgsMapCanvas::zoomToSelected( QgsVectorLayer* layer )
{
if ( mDrawing )
{
return;
}

if ( layer == NULL )
{
// use current layer by default
Expand Down Expand Up @@ -786,11 +755,6 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer* layer )

void QgsMapCanvas::panToSelected( QgsVectorLayer* layer )
{
if ( mDrawing )
{
return;
}

if ( layer == NULL )
{
// use current layer by default
Expand All @@ -814,12 +778,6 @@ void QgsMapCanvas::panToSelected( QgsVectorLayer* layer )

void QgsMapCanvas::keyPressEvent( QKeyEvent * e )
{

if ( mDrawing )
{
e->ignore();
}

emit keyPressed( e );

if ( mCanvasProperties->mouseButtonDown || mCanvasProperties->panSelectorDown )
Expand Down Expand Up @@ -916,11 +874,6 @@ void QgsMapCanvas::keyReleaseEvent( QKeyEvent * e )
{
QgsDebugMsg( "keyRelease event" );

if ( mDrawing )
{
return;
}

switch ( e->key() )
{
case Qt::Key_Space:
Expand Down Expand Up @@ -952,11 +905,6 @@ void QgsMapCanvas::keyReleaseEvent( QKeyEvent * e )

void QgsMapCanvas::mouseDoubleClickEvent( QMouseEvent * e )
{
if ( mDrawing )
{
return;
}

// call handler of current map tool
if ( mMapTool )
mMapTool->canvasDoubleClickEvent( e );
Expand All @@ -965,11 +913,6 @@ void QgsMapCanvas::mouseDoubleClickEvent( QMouseEvent * e )

void QgsMapCanvas::mousePressEvent( QMouseEvent * e )
{
if ( mDrawing )
{
return;
}

//use middle mouse button for panning, map tools won't receive any events in that case
if ( e->button() == Qt::MidButton )
{
Expand Down Expand Up @@ -997,11 +940,6 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent * e )

void QgsMapCanvas::mouseReleaseEvent( QMouseEvent * e )
{
if ( mDrawing )
{
return;
}

//use middle mouse button for panning, map tools won't receive any events in that case
if ( e->button() == Qt::MidButton )
{
Expand Down Expand Up @@ -1112,11 +1050,6 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )

QgsDebugMsg( "Wheel event delta " + QString::number( e->delta() ) );

if ( mDrawing )
{
return;
}

if ( mMapTool )
{
mMapTool->wheelEvent( e );
Expand Down Expand Up @@ -1190,11 +1123,6 @@ void QgsMapCanvas::zoomScale( double newScale )

void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn )
{
if ( mDrawing )
{
return;
}

double scaleFactor = ( zoomIn ? 1 / mWheelZoomFactor : mWheelZoomFactor );

// transform the mouse pos to map coordinates
Expand All @@ -1207,11 +1135,6 @@ void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn )

void QgsMapCanvas::mouseMoveEvent( QMouseEvent * e )
{
if ( mDrawing )
{
return;
}

mCanvasProperties->mouseLastXY = e->pos();

if ( mCanvasProperties->panSelectorDown )
Expand Down Expand Up @@ -1406,11 +1329,6 @@ QgsMapTool* QgsMapCanvas::mapTool()

void QgsMapCanvas::panActionEnd( QPoint releasePoint )
{
if ( mDrawing )
{
return;
}

// move map image and other items to standard position
moveCanvasContents( true ); // true means reset

Expand Down Expand Up @@ -1467,11 +1385,6 @@ void QgsMapCanvas::panAction( QMouseEvent * e )
{
Q_UNUSED( e );

if ( mDrawing )
{
return;
}

// move all map canvas items
moveCanvasContents();

Expand All @@ -1481,11 +1394,6 @@ void QgsMapCanvas::panAction( QMouseEvent * e )

void QgsMapCanvas::moveCanvasContents( bool reset )
{
if ( mDrawing )
{
return;
}

QPoint pnt( 0, 0 );
if ( !reset )
pnt += mCanvasProperties->mouseLastXY - mCanvasProperties->rubberStartPoint;
Expand Down Expand Up @@ -1573,11 +1481,6 @@ void QgsMapCanvas::writeProject( QDomDocument & doc )

void QgsMapCanvas::zoomByFactor( double scaleFactor )
{
if ( mDrawing )
{
return;
}

QgsRectangle r = mapSettings().visibleExtent();
r.scale( scaleFactor );
setExtent( r );
Expand Down
5 changes: 1 addition & 4 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -237,7 +237,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! Get the current coordinate transform
const QgsMapToPixel* getCoordinateTransform();

//! true if canvas currently drawing
//! @deprecated in 2.1 - always returns false
bool isDrawing();

//! returns current layer (set by legend widget)
Expand Down Expand Up @@ -460,9 +460,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! map overview widget - it's controlled by QgsMapCanvas
QgsMapOverviewCanvas* mMapOverview;

//! Flag indicating a map refresh is in progress
bool mDrawing;

//! Flag indicating if the map canvas is frozen.
bool mFrozen;

Expand Down

0 comments on commit fd10fae

Please sign in to comment.