mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
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
This commit is contained in:
parent
8520ec52c8
commit
5a27e1b042
@ -212,13 +212,6 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
|
|||||||
/**Etablishes the signal slot connection for the class*/
|
/**Etablishes the signal slot connection for the class*/
|
||||||
void connectSlots();
|
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
|
//! Set buttons up
|
||||||
void setToolActionsOff( void );
|
void setToolActionsOff( void );
|
||||||
|
|
||||||
|
|||||||
@ -98,6 +98,11 @@ void QgsComposerMapWidget::on_mPreviewModeComboBox_activated( int i )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mComposerMap->isDrawing())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString comboText = mPreviewModeComboBox->currentText();
|
QString comboText = mPreviewModeComboBox->currentText();
|
||||||
if ( comboText == tr( "Cache" ) )
|
if ( comboText == tr( "Cache" ) )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -100,6 +100,13 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRect& extent, const QSize
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( mDrawing )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDrawing = true;
|
||||||
|
|
||||||
QgsMapRenderer theMapRenderer;
|
QgsMapRenderer theMapRenderer;
|
||||||
theMapRenderer.setExtent( extent );
|
theMapRenderer.setExtent( extent );
|
||||||
theMapRenderer.setOutputSize( size, dpi );
|
theMapRenderer.setOutputSize( size, dpi );
|
||||||
@ -119,6 +126,8 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRect& extent, const QSize
|
|||||||
theMapRenderer.setScale( scale() );
|
theMapRenderer.setScale( scale() );
|
||||||
theMapRenderer.render( painter );
|
theMapRenderer.render( painter );
|
||||||
theMapRenderer.setScale( bk_scale );
|
theMapRenderer.setScale( bk_scale );
|
||||||
|
|
||||||
|
mDrawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsComposerMap::cache( void )
|
void QgsComposerMap::cache( void )
|
||||||
@ -158,18 +167,11 @@ void QgsComposerMap::cache( void )
|
|||||||
|
|
||||||
void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
|
void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
|
||||||
{
|
{
|
||||||
if ( mDrawing )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !mComposition || !painter )
|
if ( !mComposition || !painter )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDrawing = true;
|
|
||||||
|
|
||||||
QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
|
QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setClipRect( thisPaintRect );
|
painter->setClipRect( thisPaintRect );
|
||||||
@ -218,7 +220,6 @@ void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* i
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
||||||
mLastScaleFactorX = currentScaleFactorX;
|
mLastScaleFactorX = currentScaleFactorX;
|
||||||
mDrawing = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsComposerMap::mapCanvasChanged( void )
|
void QgsComposerMap::mapCanvasChanged( void )
|
||||||
@ -251,20 +252,23 @@ void QgsComposerMap::resize( double dx, double dy )
|
|||||||
|
|
||||||
void QgsComposerMap::moveContent( double dx, double dy )
|
void QgsComposerMap::moveContent( double dx, double dy )
|
||||||
{
|
{
|
||||||
QRectF itemRect = rect();
|
if(!mDrawing)
|
||||||
double xRatio = dx / itemRect.width();
|
{
|
||||||
double yRatio = dy / itemRect.height();
|
QRectF itemRect = rect();
|
||||||
|
double xRatio = dx / itemRect.width();
|
||||||
double xMoveMapCoord = mExtent.width() * xRatio;
|
double yRatio = dy / itemRect.height();
|
||||||
double yMoveMapCoord = -( mExtent.height() * yRatio );
|
|
||||||
|
double xMoveMapCoord = mExtent.width() * xRatio;
|
||||||
mExtent.setXMinimum( mExtent.xMin() + xMoveMapCoord );
|
double yMoveMapCoord = -( mExtent.height() * yRatio );
|
||||||
mExtent.setXMaximum( mExtent.xMax() + xMoveMapCoord );
|
|
||||||
mExtent.setYmin( mExtent.yMin() + yMoveMapCoord );
|
mExtent.setXMinimum( mExtent.xMin() + xMoveMapCoord );
|
||||||
mExtent.setYmax( mExtent.yMax() + yMoveMapCoord );
|
mExtent.setXMaximum( mExtent.xMax() + xMoveMapCoord );
|
||||||
emit extentChanged();
|
mExtent.setYmin( mExtent.yMin() + yMoveMapCoord );
|
||||||
cache();
|
mExtent.setYmax( mExtent.yMax() + yMoveMapCoord );
|
||||||
update();
|
emit extentChanged();
|
||||||
|
cache();
|
||||||
|
update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsComposerMap::setSceneRect( const QRectF& rectangle )
|
void QgsComposerMap::setSceneRect( const QRectF& rectangle )
|
||||||
|
|||||||
@ -189,7 +189,6 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
|
|||||||
double moveX = scenePoint.x() - mMoveContentStartPos.x();
|
double moveX = scenePoint.x() - mMoveContentStartPos.x();
|
||||||
double moveY = scenePoint.y() - mMoveContentStartPos.y();
|
double moveY = scenePoint.y() - mMoveContentStartPos.y();
|
||||||
mMoveContentItem->moveContent( -moveX, -moveY );
|
mMoveContentItem->moveContent( -moveX, -moveY );
|
||||||
mMoveContentItem->update();
|
|
||||||
mMoveContentItem = 0;
|
mMoveContentItem = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user