Skip to content

Commit

Permalink
[needs-docs][composer] Remove Rectangle mode from composer maps
Browse files Browse the repository at this point in the history
No longer required - the Cache mode is now performant enough
that we don't have to rely on the old rectangle preview
when desiring responsive composers
  • Loading branch information
nyalldawson committed May 8, 2017
1 parent 3f595ee commit 5e3b903
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 50 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ and setAtlasScalingMode() instead.
associated project's annotationManager()
- setDrawCanvasItems() and drawCanvasItems() were renamed to setDrawAnnotations() and drawAnnotations()
- setCacheUpdated(), updateCachedImage() and cache() were removed. Use invalidateCache() instead.
- The Rectangle mode enum was removed. Use the reworked Cache mode instead.


QgsComposerMapGrid {#qgis_api_break_3_0_QgsComposerMapGrid}
Expand Down
1 change: 0 additions & 1 deletion python/core/composer/qgscomposermap.sip
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Return correct graphics item type.
{
Cache,
Render,
Rectangle
};

enum AtlasScalingMode
Expand Down
27 changes: 8 additions & 19 deletions src/app/composer/qgscomposermapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap *composerMap )
blockAllSignals( true );
mPreviewModeComboBox->insertItem( 0, tr( "Cache" ) );
mPreviewModeComboBox->insertItem( 1, tr( "Render" ) );
mPreviewModeComboBox->insertItem( 2, tr( "Rectangle" ) );

mCrsSelector->setOptionVisible( QgsProjectionSelectionWidget::CrsNotSet, true );
mCrsSelector->setNotSetText( tr( "Use project CRS" ) );
Expand Down Expand Up @@ -446,20 +445,15 @@ void QgsComposerMapWidget::on_mPreviewModeComboBox_activated( int i )
}

QString comboText = mPreviewModeComboBox->currentText();
if ( comboText == tr( "Cache" ) )
{
mComposerMap->setPreviewMode( QgsComposerMap::Cache );
mUpdatePreviewButton->setEnabled( true );
}
else if ( comboText == tr( "Render" ) )
if ( comboText == tr( "Render" ) )
{
mComposerMap->setPreviewMode( QgsComposerMap::Render );
mUpdatePreviewButton->setEnabled( true );
}
else if ( comboText == tr( "Rectangle" ) )
else
{
mComposerMap->setPreviewMode( QgsComposerMap::Rectangle );
mUpdatePreviewButton->setEnabled( false );
mComposerMap->setPreviewMode( QgsComposerMap::Cache );
mUpdatePreviewButton->setEnabled( true );
}

mComposerMap->invalidateCache();
Expand Down Expand Up @@ -630,20 +624,15 @@ void QgsComposerMapWidget::updateGuiElements()
//preview mode
QgsComposerMap::PreviewMode previewMode = mComposerMap->previewMode();
int index = -1;
if ( previewMode == QgsComposerMap::Cache )
{
index = mPreviewModeComboBox->findText( tr( "Cache" ) );
mUpdatePreviewButton->setEnabled( true );
}
else if ( previewMode == QgsComposerMap::Render )
if ( previewMode == QgsComposerMap::Render )
{
index = mPreviewModeComboBox->findText( tr( "Render" ) );
mUpdatePreviewButton->setEnabled( true );
}
else if ( previewMode == QgsComposerMap::Rectangle )
else
{
index = mPreviewModeComboBox->findText( tr( "Rectangle" ) );
mUpdatePreviewButton->setEnabled( false );
index = mPreviewModeComboBox->findText( tr( "Cache" ) );
mUpdatePreviewButton->setEnabled( true );
}
if ( index != -1 )
{
Expand Down
31 changes: 5 additions & 26 deletions src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,6 @@ QgsMapSettings QgsComposerMap::mapSettings( const QgsRectangle &extent, QSizeF s

void QgsComposerMap::recreateCachedImageInBackground()
{
if ( mPreviewMode == Rectangle )
{
return;
}

if ( mPainterJob )
{
disconnect( mPainterJob.get(), &QgsMapRendererCustomPainterJob::finished, this, &QgsComposerMap::painterJobFinished );
Expand Down Expand Up @@ -325,16 +320,7 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,
painter->save();
painter->setClipRect( thisPaintRect );

if ( mComposition->plotStyle() == QgsComposition::Preview && mPreviewMode == Rectangle )
{
// Fill with background color
drawBackground( painter );
QFont messageFont( QLatin1String( "" ), 12 );
painter->setFont( messageFont );
painter->setPen( QColor( 0, 0, 0, 125 ) );
painter->drawText( thisPaintRect, tr( "Map will be printed here" ) );
}
else if ( mComposition->plotStyle() == QgsComposition::Preview )
if ( mComposition->plotStyle() == QgsComposition::Preview )
{
if ( !mCacheFinalImage || mCacheFinalImage->isNull() )
{
Expand Down Expand Up @@ -416,13 +402,11 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,
}

painter->setClipRect( thisPaintRect, Qt::NoClip );
if ( shouldDrawPart( OverviewMapExtent ) &&
( mComposition->plotStyle() != QgsComposition::Preview || mPreviewMode != Rectangle ) )
if ( shouldDrawPart( OverviewMapExtent ) )
{
mOverviewStack->drawItems( painter );
}
if ( shouldDrawPart( Grid ) &&
( mComposition->plotStyle() != QgsComposition::Preview || mPreviewMode != Rectangle ) )
if ( shouldDrawPart( Grid ) )
{
mGridStack->drawItems( painter );
}
Expand Down Expand Up @@ -1304,21 +1288,16 @@ bool QgsComposerMap::readXml( const QDomElement &itemElem, const QDomDocument &d
mId = idRead.toInt();
updateToolTip();
}
mPreviewMode = Rectangle;

//previewMode
QString previewMode = itemElem.attribute( QStringLiteral( "previewMode" ) );
if ( previewMode == QLatin1String( "Cache" ) )
{
mPreviewMode = Cache;
}
else if ( previewMode == QLatin1String( "Render" ) )
if ( previewMode == QLatin1String( "Render" ) )
{
mPreviewMode = Render;
}
else
{
mPreviewMode = Rectangle;
mPreviewMode = Cache;
}

//extent
Expand Down
1 change: 0 additions & 1 deletion src/core/composer/qgscomposermap.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
{
Cache = 0, // Use raster cache
Render, // Render the map
Rectangle // Display only rectangle
};

/** Scaling modes used for the serial rendering (atlas)
Expand Down
3 changes: 0 additions & 3 deletions tests/src/core/testqgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ void TestQgsAtlasComposition::init()
// the atlas map
mAtlasMap = new QgsComposerMap( mComposition, 20, 20, 130, 130 );
mAtlasMap->setFrameEnabled( true );
// Make sure it doesn't try to render a map for caching onto a still 0-sized image
mAtlasMap->setPreviewMode( QgsComposerMap::Rectangle );
mComposition->addComposerMap( mAtlasMap );
mAtlasMap->setLayers( QList<QgsMapLayer *>() << mVectorLayer );

Expand All @@ -165,7 +163,6 @@ void TestQgsAtlasComposition::init()
mOverview = new QgsComposerMap( mComposition, 180, 20, 50, 50 );
mOverview->setFrameEnabled( true );
mOverview->overview()->setFrameMap( mAtlasMap->id() );
mOverview->setPreviewMode( QgsComposerMap::Rectangle );
mOverview->setLayers( QList<QgsMapLayer *>() << mVectorLayer );
mComposition->addComposerMap( mOverview );
mOverview->setNewExtent( QgsRectangle( 49670.718, 6415139.086, 699672.519, 7065140.887 ) );
Expand Down

0 comments on commit 5e3b903

Please sign in to comment.