Skip to content
Permalink
Browse files
Better protection agains multiple map drawings with move content tool
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 5a27e1b042be56a269a3ac06bbcc49b0e64538d5
@@ -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 );

@@ -98,6 +98,11 @@ void QgsComposerMapWidget::on_mPreviewModeComboBox_activated( int i )
return;
}

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

QString comboText = mPreviewModeComboBox->currentText();
if ( comboText == tr( "Cache" ) )
{
@@ -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 );
@@ -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 )
@@ -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 );
@@ -218,7 +220,6 @@ void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* i
painter->restore();

mLastScaleFactorX = currentScaleFactorX;
mDrawing = false;
}

void QgsComposerMap::mapCanvasChanged( void )
@@ -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 )
@@ -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;

0 comments on commit 5a27e1b

Please sign in to comment.