Skip to content

Commit

Permalink
Fix overview autocentering: always center, not only when the overview…
Browse files Browse the repository at this point in the history
… is not visible.

Work funded by Tuscany Region - SITA. Contract "Support to the use
of GFOSS (Geographic Free and Open Source Software) Desktop tools"
(CIG Z3B06FA6D7).
  • Loading branch information
Hugo Mercier committed Jun 19, 2013
1 parent f0f72ca commit 5c4f2ed
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion python/core/composer/qgscomposermap.sip
Expand Up @@ -302,7 +302,7 @@ class QgsComposerMap : QgsComposerItem
void setOverviewInverted( bool inverted );
bool overviewInverted() const;

/** Returns true if the extent is forced to center on the overview when the overview is outside the extent */
/** Returns true if the extent is forced to center on the overview */
bool overviewCentered() const;
/** Set the overview's centering mode */
void setOverviewCentered( bool centered );
Expand Down
14 changes: 6 additions & 8 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -129,14 +129,12 @@ void QgsComposerMap::extentCenteredOnOverview( QgsRectangle& extent ) const
const QgsComposerMap* overviewFrameMap = mComposition->getComposerMapById( mOverviewFrameMapId );
QgsRectangle otherExtent = overviewFrameMap->extent();

if ( ! mExtent.contains( otherExtent ) ) {
QgsPoint center = otherExtent.center();
QgsRectangle movedExtent( center.x() - mExtent.width() / 2,
center.y() - mExtent.height() / 2,
center.x() - mExtent.width() / 2 + mExtent.width(),
center.y() - mExtent.height() / 2 + mExtent.height() );
extent = movedExtent;
}
QgsPoint center = otherExtent.center();
QgsRectangle movedExtent( center.x() - mExtent.width() / 2,
center.y() - mExtent.height() / 2,
center.x() - mExtent.width() / 2 + mExtent.width(),
center.y() - mExtent.height() / 2 + mExtent.height() );
extent = movedExtent;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposermap.h
Expand Up @@ -332,7 +332,7 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
/** Sets the overview's inversion mode*/
void setOverviewInverted( bool inverted );

/** Returns true if the extent is forced to center on the overview when the overview is outside the extent */
/** Returns true if the extent is forced to center on the overview */
bool overviewCentered() const { return mOverviewCentered; }
/** Set the overview's centering mode */
void setOverviewCentered( bool centered );
Expand Down Expand Up @@ -537,7 +537,7 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
void initGridAnnotationFormatFromProject();

/**
* Returns the extent, centered on the overview frame, if needed (when the overview frame is not visible)
* Returns the extent, centered on the overview frame
*/
void extentCenteredOnOverview( QgsRectangle& extent ) const;
};
Expand Down
8 changes: 4 additions & 4 deletions src/ui/qgscomposermapwidgetbase.ui
Expand Up @@ -54,9 +54,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>438</width>
<height>1454</height>
<y>-376</y>
<width>439</width>
<height>1439</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -700,7 +700,7 @@
<item row="4" column="0">
<widget class="QCheckBox" name="mOverviewCenterCheckbox">
<property name="text">
<string>Center on overview when needed</string>
<string>Center on overview</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 5c4f2ed

Please sign in to comment.