Skip to content
Permalink
Browse files
[needs-docs][composer] Remove Rectangle mode from composer maps
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 5e3b903955edf94e2fd7eb0c02c11805be427bb4
@@ -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}
@@ -40,7 +40,6 @@ Return correct graphics item type.
{
Cache,
Render,
Rectangle
};

enum AtlasScalingMode
@@ -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" ) );
@@ -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();
@@ -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 )
{
@@ -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 );
@@ -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() )
{
@@ -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 );
}
@@ -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
@@ -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)
@@ -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 );

@@ -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 ) );

0 comments on commit 5e3b903

Please sign in to comment.