Skip to content
Permalink
Browse files
Consider rotation in pre-rendering display of map items
  • Loading branch information
Sandro Santilli committed Jan 3, 2015
1 parent 4d449f1 commit 888a9f0bfce881bc479250b0d76a52b7371c92d8
Showing with 13 additions and 4 deletions.
  1. +1 −1 python/gui/qgsmapcanvasitem.sip
  2. +9 −2 src/gui/qgsmapcanvasitem.cpp
  3. +3 −1 src/gui/qgsmapcanvasitem.h
@@ -45,7 +45,7 @@ class QgsMapCanvasItem : QGraphicsItem
QgsRectangle rect() const;

//! sets canvas item rectangle in map units
void setRect( const QgsRectangle& r );
void setRect( const QgsRectangle& r, bool resetRotation = true );

//! transformation from screen coordinates to map coordinates
QgsPoint toMapCoordinates( const QPoint& point ) const;
@@ -73,7 +73,7 @@ QgsRectangle QgsMapCanvasItem::rect() const
}


void QgsMapCanvasItem::setRect( const QgsRectangle& rect )
void QgsMapCanvasItem::setRect( const QgsRectangle& rect, bool resetRotation )
{
mRect = rect;
//updatePosition();
@@ -94,6 +94,12 @@ void QgsMapCanvasItem::setRect( const QgsRectangle& rect )
setPos( r.topLeft() );
mItemSize = QSizeF( r.width() + 2, r.height() + 2 );

if ( resetRotation )
{
mRectRotation = mMapCanvas->rotation();
setRotation( 0 );
}

// QgsDebugMsg(QString("[%1,%2]-[%3x%4]").arg((int) r.left()).arg((int) r.top()).arg((int) r.width()).arg((int) r.height()));

update();
@@ -132,7 +138,8 @@ bool QgsMapCanvasItem::setRenderContextVariables( QPainter* p, QgsRenderContext&
void QgsMapCanvasItem::updatePosition()
{
// default implementation: recalculate position of the item
setRect( mRect );
setRect( mRect, false );
setRotation( mMapCanvas->rotation() - mRectRotation );
}


@@ -69,7 +69,7 @@ class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem
QgsRectangle rect() const;

//! sets canvas item rectangle in map units
void setRect( const QgsRectangle& r );
void setRect( const QgsRectangle& r, bool resetRotation = true );

//! transformation from screen coordinates to map coordinates
QgsPoint toMapCoordinates( const QPoint& point ) const;
@@ -92,6 +92,8 @@ class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem
//! on rotation change
QgsRectangle mRect;

double mRectRotation;

//! offset from normal position due current panning operation,
//! used when converting map coordinates to move map canvas items
//! @deprecated since v2.4

0 comments on commit 888a9f0

Please sign in to comment.