Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] Add checkbox to always show diagrams for a layer
Unlike the global labeling setting this applies only to diagrams,
and only for a single layer. Defaults to on. (fix #8706)
  • Loading branch information
nyalldawson committed Apr 9, 2015
1 parent 60526f4 commit d7eec44
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions python/core/qgsdiagramrendererv2.sip
Expand Up @@ -36,6 +36,7 @@ struct QgsDiagramLayerSettings
QgsDiagramRendererV2* renderer; // if any renderer is assigned, it is owned by this class
int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)
bool showAll;

void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsdiagramproperties.cpp
Expand Up @@ -160,6 +160,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
mDiagramSizeSpinBox->setValue( 30 );
mBarWidthSpinBox->setValue( 5 );
mVisibilityGroupBox->setChecked( layer->hasScaleBasedVisibility() );
mShowAllCheckBox->setChecked( true );
mMaximumDiagramScaleLineEdit->setText( QString::number( layer->maximumScale() ) );
mMinimumDiagramScaleLineEdit->setText( QString::number( layer->minimumScale() ) );

Expand Down Expand Up @@ -308,6 +309,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
}
mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( dls->placement ) );
mLineOptionsComboBox->setCurrentIndex( mLineOptionsComboBox->findData( dls->placementFlags ) );
mShowAllCheckBox->setChecked( dls->showAll );
}

if ( dr->diagram() )
Expand Down Expand Up @@ -675,6 +677,7 @@ void QgsDiagramProperties::apply()
QgsDiagramLayerSettings dls;
dls.dist = mDiagramDistanceSpinBox->value();
dls.priority = mPrioritySlider->value();
dls.showAll = mShowAllCheckBox->isChecked();
if ( mDataDefinedPositionGroupBox->isChecked() )
{
dls.xPosColumn = mDataDefinedXComboBox->itemData( mDataDefinedXComboBox->currentIndex() ).toInt();
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsdiagramrendererv2.cpp
Expand Up @@ -34,6 +34,7 @@ QgsDiagramLayerSettings::QgsDiagramLayerSettings()
, xform( 0 )
, xPosColumn( -1 )
, yPosColumn( -1 )
, showAll( true )
{
}

Expand All @@ -53,6 +54,7 @@ void QgsDiagramLayerSettings::readXML( const QDomElement& elem, const QgsVectorL
dist = elem.attribute( "dist" ).toDouble();
xPosColumn = elem.attribute( "xPosColumn" ).toInt();
yPosColumn = elem.attribute( "yPosColumn" ).toInt();
showAll = ( elem.attribute( "showAll", "0" ) != "0" );
}

void QgsDiagramLayerSettings::writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const
Expand All @@ -67,6 +69,7 @@ void QgsDiagramLayerSettings::writeXML( QDomElement& layerElem, QDomDocument& do
diagramLayerElem.setAttribute( "dist", QString::number( dist ) );
diagramLayerElem.setAttribute( "xPosColumn", xPosColumn );
diagramLayerElem.setAttribute( "yPosColumn", yPosColumn );
diagramLayerElem.setAttribute( "showAll", showAll );
layerElem.appendChild( diagramLayerElem );
}

Expand Down
1 change: 1 addition & 0 deletions src/core/qgsdiagramrendererv2.h
Expand Up @@ -79,6 +79,7 @@ class CORE_EXPORT QgsDiagramLayerSettings

int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)
bool showAll;

void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgspallabeling.cpp
Expand Up @@ -3476,6 +3476,7 @@ void QgsPalLabeling::registerDiagramFeature( const QString& layerID, QgsFeature&
}

// feature to the layer
bool alwaysShow = layerIt.value().showAll;
int ddColX = layerIt.value().xPosColumn;
int ddColY = layerIt.value().yPosColumn;
double ddPosX = 0.0;
Expand Down Expand Up @@ -3506,7 +3507,7 @@ void QgsPalLabeling::registerDiagramFeature( const QString& layerID, QgsFeature&

try
{
if ( !layerIt.value().palLayer->registerFeature( lbl->strId(), lbl, diagramWidth, diagramHeight, "", ddPosX, ddPosY, ddPos ) )
if ( !layerIt.value().palLayer->registerFeature( lbl->strId(), lbl, diagramWidth, diagramHeight, "", ddPosX, ddPosY, ddPos, 0.0, false, 0, 0, 0, 0, alwaysShow ) )
{
return;
}
Expand Down
36 changes: 23 additions & 13 deletions src/ui/qgsdiagrampropertiesbase.ui
Expand Up @@ -39,8 +39,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>756</width>
<height>627</height>
<width>740</width>
<height>640</height>
</rect>
</property>
<layout class="QVBoxLayout" name="scrollAreaLayout">
Expand Down Expand Up @@ -127,6 +127,19 @@
<string>Appearance</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" rowspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="2">
Expand Down Expand Up @@ -269,7 +282,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QGroupBox" name="mVisibilityGroupBox">
<property name="toolTip">
<string>Only show diagrams with a size inside the specified range.</string>
Expand Down Expand Up @@ -319,18 +332,15 @@
</layout>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="2" column="0">
<widget class="QCheckBox" name="mShowAllCheckBox">
<property name="text">
<string>Show all diagrams</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
<property name="checked">
<bool>true</bool>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
Expand Down

0 comments on commit d7eec44

Please sign in to comment.