Skip to content

Commit

Permalink
Better protection agains multiple map drawings with move content tool
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@9174 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Aug 26, 2008
1 parent 8520ec5 commit 5a27e1b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 30 deletions.
7 changes: 0 additions & 7 deletions src/app/composer/qgscomposer.h
Expand Up @@ -212,13 +212,6 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
/**Etablishes the signal slot connection for the class*/
void connectSlots();

/** \brief move up the content of the file
\param file file
\param from starting position
\param shift shift in bytes
*/
bool shiftFileContent( QFile *file, qint64 start, int shift );

//! Set buttons up
void setToolActionsOff( void );

Expand Down
5 changes: 5 additions & 0 deletions src/app/composer/qgscomposermapwidget.cpp
Expand Up @@ -98,6 +98,11 @@ void QgsComposerMapWidget::on_mPreviewModeComboBox_activated( int i )
return;
}

if(mComposerMap->isDrawing())
{
return;
}

QString comboText = mPreviewModeComboBox->currentText();
if ( comboText == tr( "Cache" ) )
{
Expand Down
48 changes: 26 additions & 22 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -100,6 +100,13 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRect& extent, const QSize
return;
}

if ( mDrawing )
{
return;
}

mDrawing = true;

QgsMapRenderer theMapRenderer;
theMapRenderer.setExtent( extent );
theMapRenderer.setOutputSize( size, dpi );
Expand All @@ -119,6 +126,8 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRect& extent, const QSize
theMapRenderer.setScale( scale() );
theMapRenderer.render( painter );
theMapRenderer.setScale( bk_scale );

mDrawing = false;
}

void QgsComposerMap::cache( void )
Expand Down Expand Up @@ -158,18 +167,11 @@ void QgsComposerMap::cache( void )

void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
if ( mDrawing )
{
return;
}

if ( !mComposition || !painter )
{
return;
}

mDrawing = true;

QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
painter->save();
painter->setClipRect( thisPaintRect );
Expand Down Expand Up @@ -218,7 +220,6 @@ void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* i
painter->restore();

mLastScaleFactorX = currentScaleFactorX;
mDrawing = false;
}

void QgsComposerMap::mapCanvasChanged( void )
Expand Down Expand Up @@ -251,20 +252,23 @@ void QgsComposerMap::resize( double dx, double dy )

void QgsComposerMap::moveContent( double dx, double dy )
{
QRectF itemRect = rect();
double xRatio = dx / itemRect.width();
double yRatio = dy / itemRect.height();

double xMoveMapCoord = mExtent.width() * xRatio;
double yMoveMapCoord = -( mExtent.height() * yRatio );

mExtent.setXMinimum( mExtent.xMin() + xMoveMapCoord );
mExtent.setXMaximum( mExtent.xMax() + xMoveMapCoord );
mExtent.setYmin( mExtent.yMin() + yMoveMapCoord );
mExtent.setYmax( mExtent.yMax() + yMoveMapCoord );
emit extentChanged();
cache();
update();
if(!mDrawing)
{
QRectF itemRect = rect();
double xRatio = dx / itemRect.width();
double yRatio = dy / itemRect.height();

double xMoveMapCoord = mExtent.width() * xRatio;
double yMoveMapCoord = -( mExtent.height() * yRatio );

mExtent.setXMinimum( mExtent.xMin() + xMoveMapCoord );
mExtent.setXMaximum( mExtent.xMax() + xMoveMapCoord );
mExtent.setYmin( mExtent.yMin() + yMoveMapCoord );
mExtent.setYmax( mExtent.yMax() + yMoveMapCoord );
emit extentChanged();
cache();
update();
}
}

void QgsComposerMap::setSceneRect( const QRectF& rectangle )
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgscomposerview.cpp
Expand Up @@ -189,7 +189,6 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
double moveX = scenePoint.x() - mMoveContentStartPos.x();
double moveY = scenePoint.y() - mMoveContentStartPos.y();
mMoveContentItem->moveContent( -moveX, -moveY );
mMoveContentItem->update();
mMoveContentItem = 0;
}
break;
Expand Down

0 comments on commit 5a27e1b

Please sign in to comment.