Skip to content
Permalink
Browse files
[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 d7eec444a2f193ecd9ae7fb0eba0c8a445c59809
@@ -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;
@@ -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() ) );

@@ -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() )
@@ -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();
@@ -34,6 +34,7 @@ QgsDiagramLayerSettings::QgsDiagramLayerSettings()
, xform( 0 )
, xPosColumn( -1 )
, yPosColumn( -1 )
, showAll( true )
{
}

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

@@ -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;
@@ -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;
@@ -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;
}
@@ -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">
@@ -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">
@@ -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>
@@ -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>

0 comments on commit d7eec44

Please sign in to comment.