Skip to content

Commit

Permalink
Remove option to show label shadow rectangles from GUI
Browse files Browse the repository at this point in the history
...and instead just make it #ifdef out
  • Loading branch information
nyalldawson committed Oct 24, 2016
1 parent 4d5e753 commit aac2622
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 90 deletions.
4 changes: 0 additions & 4 deletions python/core/qgspallabeling.sip
Expand Up @@ -638,7 +638,6 @@ class QgsPalLayerSettings
int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels

bool showingShadowRects; // whether to show debug rectangles for drop shadows
};

class QgsLabelCandidate
Expand Down Expand Up @@ -764,9 +763,6 @@ class QgsPalLabeling : QgsLabelingEngineInterface
bool isShowingCandidates() const;
void setShowingCandidates( bool showing );

bool isShowingShadowRectangles() const;
void setShowingShadowRectangles( bool showing );

bool isShowingAllLabels() const;
void setShowingAllLabels( bool showing );

Expand Down
3 changes: 0 additions & 3 deletions src/app/qgslabelengineconfigdialog.cpp
Expand Up @@ -43,7 +43,6 @@ QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QWidget* parent )

chkShowCandidates->setChecked( lbl.isShowingCandidates() );
chkShowAllLabels->setChecked( lbl.isShowingAllLabels() );
mShadowDebugRectChkBox->setChecked( lbl.isShowingShadowRectangles() );

chkShowPartialsLabels->setChecked( lbl.isShowingPartialsLabels() );
mDrawOutlinesChkBox->setChecked( lbl.isDrawingOutlineLabels() );
Expand All @@ -62,7 +61,6 @@ void QgsLabelEngineConfigDialog::onOK()
spinCandPolygon->value() );

lbl.setShowingCandidates( chkShowCandidates->isChecked() );
lbl.setShowingShadowRectangles( mShadowDebugRectChkBox->isChecked() );
lbl.setShowingAllLabels( chkShowAllLabels->isChecked() );
lbl.setShowingPartialsLabels( chkShowPartialsLabels->isChecked() );
lbl.setDrawingOutlineLabels( mDrawOutlinesChkBox->isChecked() );
Expand All @@ -81,7 +79,6 @@ void QgsLabelEngineConfigDialog::setDefaults()
spinCandPolygon->setValue( p.getPolyP() );
chkShowCandidates->setChecked( false );
chkShowAllLabels->setChecked( false );
mShadowDebugRectChkBox->setChecked( false );
chkShowPartialsLabels->setChecked( p.getShowPartial() );
mDrawOutlinesChkBox->setChecked( true );
}
2 changes: 0 additions & 2 deletions src/core/qgslabelingengine.cpp
Expand Up @@ -349,7 +349,6 @@ void QgsLabelingEngine::readSettingsFromProject()
mFlags = 0;
if ( prj->readBoolEntry( "PAL", "/ShowingCandidates", false, &saved ) ) mFlags |= DrawCandidates;
if ( prj->readBoolEntry( "PAL", "/DrawRectOnly", false, &saved ) ) mFlags |= DrawLabelRectOnly;
if ( prj->readBoolEntry( "PAL", "/ShowingShadowRects", false, &saved ) ) mFlags |= DrawShadowRects;
if ( prj->readBoolEntry( "PAL", "/ShowingAllLabels", false, &saved ) ) mFlags |= UseAllLabels;
if ( prj->readBoolEntry( "PAL", "/ShowingPartialsLabels", true, &saved ) ) mFlags |= UsePartialCandidates;
if ( prj->readBoolEntry( "PAL", "/DrawOutlineLabels", true, &saved ) ) mFlags |= RenderOutlineLabels;
Expand All @@ -364,7 +363,6 @@ void QgsLabelingEngine::writeSettingsToProject()

QgsProject::instance()->writeEntry( "PAL", "/ShowingCandidates", mFlags.testFlag( DrawCandidates ) );
QgsProject::instance()->writeEntry( "PAL", "/DrawRectOnly", mFlags.testFlag( DrawLabelRectOnly ) );
QgsProject::instance()->writeEntry( "PAL", "/ShowingShadowRects", mFlags.testFlag( DrawShadowRects ) );
QgsProject::instance()->writeEntry( "PAL", "/ShowingAllLabels", mFlags.testFlag( UseAllLabels ) );
QgsProject::instance()->writeEntry( "PAL", "/ShowingPartialsLabels", mFlags.testFlag( UsePartialCandidates ) );
QgsProject::instance()->writeEntry( "PAL", "/DrawOutlineLabels", mFlags.testFlag( RenderOutlineLabels ) );
Expand Down
1 change: 0 additions & 1 deletion src/core/qgslabelingengine.h
Expand Up @@ -172,7 +172,6 @@ class CORE_EXPORT QgsLabelingEngine
RenderOutlineLabels = 1 << 3, //!< Whether to render labels as text or outlines
DrawLabelRectOnly = 1 << 4, //!< Whether to only draw the label rect and not the actual label text (used for unit tests)
DrawCandidates = 1 << 5, //!< Whether to draw rectangles of generated candidates (good for debugging)
DrawShadowRects = 1 << 6, //!< Whether to show debugging rectangles for drop shadows
};
Q_DECLARE_FLAGS( Flags, Flag )

Expand Down
99 changes: 41 additions & 58 deletions src/core/qgspallabeling.cpp
Expand Up @@ -290,8 +290,6 @@ QgsPalLayerSettings::QgsPalLayerSettings()
mDataDefinedNames.insert( Show, QPair<QString, int>( "Show", 15 ) );
mDataDefinedNames.insert( AlwaysShow, QPair<QString, int>( "AlwaysShow", 20 ) );

// temp stuff for when drawing label components (don't copy)
showingShadowRects = false;
}

QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
Expand All @@ -302,7 +300,6 @@ QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
, mFeaturesToLabel( 0 )
, mFeatsSendingToPal( 0 )
, mFeatsRegPal( 0 )
, showingShadowRects( false )
, expression( nullptr )
{
*this = s;
Expand Down Expand Up @@ -3983,16 +3980,6 @@ void QgsPalLabeling::setShowingCandidates( bool showing )
mEngine->setFlag( QgsLabelingEngine::DrawCandidates, showing );
}

bool QgsPalLabeling::isShowingShadowRectangles() const
{
return mEngine->testFlag( QgsLabelingEngine::DrawShadowRects );
}

void QgsPalLabeling::setShowingShadowRectangles( bool showing )
{
mEngine->setFlag( QgsLabelingEngine::DrawShadowRects, showing );
}

bool QgsPalLabeling::isShowingAllLabels() const
{
return mEngine->testFlag( QgsLabelingEngine::UseAllLabels );
Expand Down Expand Up @@ -4510,19 +4497,18 @@ void QgsPalLabeling::drawLabelShadow( QgsRenderContext& context,
QgsSymbolLayerUtils::blurImageInPlace( blurImg, blurImg.rect(), radius, shadow.blurAlphaOnly() );
}

if ( tmpLyr.showingShadowRects ) // engine setting, not per layer
{
// debug rect for QImage shadow registration and clipping visualization
QPainter picti;
picti.begin( &blurImg );
picti.setBrush( Qt::Dense7Pattern );
QPen imgPen( QColor( 0, 0, 255, 255 ) );
imgPen.setWidth( 1 );
picti.setPen( imgPen );
picti.setOpacity( 0.1 );
picti.drawRect( 0, 0, blurImg.width(), blurImg.height() );
picti.end();
}
#if 0
// debug rect for QImage shadow registration and clipping visualization
QPainter picti;
picti.begin( &blurImg );
picti.setBrush( Qt::Dense7Pattern );
QPen imgPen( QColor( 0, 0, 255, 255 ) );
imgPen.setWidth( 1 );
picti.setPen( imgPen );
picti.setOpacity( 0.1 );
picti.drawRect( 0, 0, blurImg.width(), blurImg.height() );
picti.end();
#endif

double offsetDist = QgsTextRenderer::scaleToPixelContext( shadow.offsetDistance(), context,
shadow.offsetUnit(), true, shadow.offsetMapUnitScale() );
Expand Down Expand Up @@ -4562,39 +4548,38 @@ void QgsPalLabeling::drawLabelShadow( QgsRenderContext& context,
p->restore();

// debug rects
if ( tmpLyr.showingShadowRects ) // engine setting, not per layer
#if 0
// draw debug rect for QImage painting registration
p->save();
p->setBrush( Qt::NoBrush );
QPen imgPen( QColor( 255, 0, 0, 10 ) );
imgPen.setWidth( 2 );
imgPen.setStyle( Qt::DashLine );
p->setPen( imgPen );
p->scale( scale, scale );
if ( component.useOrigin() )
{
// draw debug rect for QImage painting registration
p->save();
p->setBrush( Qt::NoBrush );
QPen imgPen( QColor( 255, 0, 0, 10 ) );
imgPen.setWidth( 2 );
imgPen.setStyle( Qt::DashLine );
p->setPen( imgPen );
p->scale( scale, scale );
if ( component.useOrigin() )
{
p->translate( component.origin().x(), component.origin().y() );
}
p->translate( transPt );
p->translate( -imgOffset.x(),
-imgOffset.y() );
p->drawRect( 0, 0, blurImg.width(), blurImg.height() );
p->restore();
p->translate( component.origin().x(), component.origin().y() );
}
p->translate( transPt );
p->translate( -imgOffset.x(),
-imgOffset.y() );
p->drawRect( 0, 0, blurImg.width(), blurImg.height() );
p->restore();

// draw debug rect for passed in component dimensions
p->save();
p->setBrush( Qt::NoBrush );
QPen componentRectPen( QColor( 0, 255, 0, 70 ) );
componentRectPen.setWidth( 1 );
if ( component.useOrigin() )
{
p->translate( component.origin().x(), component.origin().y() );
}
p->setPen( componentRectPen );
p->drawRect( QRect( -xOffset, -componentHeight - yOffset, componentWidth, componentHeight ) );
p->restore();
// draw debug rect for passed in component dimensions
p->save();
p->setBrush( Qt::NoBrush );
QPen componentRectPen( QColor( 0, 255, 0, 70 ) );
componentRectPen.setWidth( 1 );
if ( component.useOrigin() )
{
p->translate( component.origin().x(), component.origin().y() );
}
p->setPen( componentRectPen );
p->drawRect( QRect( -xOffset, -componentHeight - yOffset, componentWidth, componentHeight ) );
p->restore();
#endif
}

void QgsPalLabeling::loadEngineSettings()
Expand All @@ -4614,7 +4599,6 @@ void QgsPalLabeling::clearEngineSettings()
QgsProject::instance()->removeEntry( "PAL", "/CandidatesLine" );
QgsProject::instance()->removeEntry( "PAL", "/CandidatesPolygon" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingCandidates" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingShadowRects" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingAllLabels" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingPartialsLabels" );
QgsProject::instance()->removeEntry( "PAL", "/DrawOutlineLabels" );
Expand All @@ -4626,7 +4610,6 @@ QgsPalLabeling* QgsPalLabeling::clone()
lbl->setShowingAllLabels( isShowingAllLabels() );
lbl->setShowingCandidates( isShowingCandidates() );
lbl->setDrawLabelRectOnly( drawLabelRectOnly() );
lbl->setShowingShadowRectangles( isShowingShadowRectangles() );
lbl->setShowingPartialsLabels( isShowingPartialsLabels() );
lbl->setDrawingOutlineLabels( isDrawingOutlineLabels() );
return lbl;
Expand Down
5 changes: 0 additions & 5 deletions src/core/qgspallabeling.h
Expand Up @@ -658,8 +658,6 @@ class CORE_EXPORT QgsPalLayerSettings
int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels

bool showingShadowRects; // whether to show debug rectangles for drop shadows

private:

void readDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
Expand Down Expand Up @@ -890,9 +888,6 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
bool isShowingCandidates() const;
void setShowingCandidates( bool showing );

bool isShowingShadowRectangles() const;
void setShowingShadowRectangles( bool showing );

bool isShowingAllLabels() const;
void setShowingAllLabels( bool showing );

Expand Down
2 changes: 0 additions & 2 deletions src/core/qgsvectorlayerlabelprovider.cpp
Expand Up @@ -456,8 +456,6 @@ void QgsVectorLayerLabelProvider::drawLabel( QgsRenderContext& context, pal::Lab
// update tmpLyr with any data defined drop shadow values
QgsPalLabeling::dataDefinedDropShadow( tmpLyr, ddValues );

tmpLyr.showingShadowRects = mEngine->testFlag( QgsLabelingEngine::DrawShadowRects );

// Render the components of a label in reverse order
// (backgrounds -> text)

Expand Down
22 changes: 7 additions & 15 deletions src/ui/qgsengineconfigdialog.ui
Expand Up @@ -215,20 +215,6 @@
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="chkShowPartialsLabels">
<property name="text">
<string>Show partials labels</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="mShadowDebugRectChkBox">
<property name="text">
<string>Show shadow rectangles (for debugging)</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
Expand Down Expand Up @@ -298,6 +284,13 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="chkShowPartialsLabels">
<property name="text">
<string>Show partials labels</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -334,7 +327,6 @@
<tabstop>chkShowPartialsLabels</tabstop>
<tabstop>chkShowAllLabels</tabstop>
<tabstop>chkShowCandidates</tabstop>
<tabstop>mShadowDebugRectChkBox</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
Expand Down

0 comments on commit aac2622

Please sign in to comment.