51 #include <QMessageBox>
52 #include <QStyledItemDelegate>
53 #include <QRandomGenerator>
63 : QStyledItemDelegate( parent )
66 QWidget *
createEditor( QWidget *,
const QStyleOptionViewItem &,
const QModelIndex & )
const override
87 , mMapCanvas( canvas )
106 mDiagramOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
108 mBarSpacingSpinBox->setClearValue( 0 );
114 mDiagramTypeComboBox->blockSignals(
true );
116 mDiagramTypeComboBox->addItem( icon, tr(
"No Diagrams" ),
"None" );
125 mDiagramTypeComboBox->blockSignals(
false );
128 mAxisLineStyleButton->setDialogTitle( tr(
"Axis Line Symbol" ) );
130 mScaleRangeWidget->setMapCanvas( mMapCanvas );
131 mSizeFieldExpressionWidget->registerExpressionContextGenerator(
this );
133 mBackgroundColorButton->setColorDialogTitle( tr(
"Select Background Color" ) );
134 mBackgroundColorButton->setAllowOpacity(
true );
135 mBackgroundColorButton->setContext( QStringLiteral(
"symbology" ) );
136 mBackgroundColorButton->setShowNoColor(
true );
137 mBackgroundColorButton->setNoColorString( tr(
"Transparent Background" ) );
138 mDiagramPenColorButton->setColorDialogTitle( tr(
"Select Pen Color" ) );
139 mDiagramPenColorButton->setAllowOpacity(
true );
140 mDiagramPenColorButton->setContext( QStringLiteral(
"symbology" ) );
141 mDiagramPenColorButton->setShowNoColor(
true );
142 mDiagramPenColorButton->setNoColorString( tr(
"Transparent Stroke" ) );
144 mMaxValueSpinBox->setShowClearButton(
false );
145 mSizeSpinBox->setClearValue( 5 );
147 mDiagramAttributesTreeWidget->setItemDelegateForColumn( ColumnAttributeExpression,
new EditBlockerDelegate(
this ) );
148 mDiagramAttributesTreeWidget->setItemDelegateForColumn( ColumnColor,
new QgsColorSwatchDelegate(
this ) );
150 mDiagramAttributesTreeWidget->setColumnWidth( ColumnColor,
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 6.6 );
163 mDiagramTypeComboBox->setEnabled(
false );
164 mDiagramFrame->setEnabled(
false );
172 stackedPlacement->setCurrentWidget( pagePoint );
173 mLinePlacementFrame->setVisible(
false );
176 stackedPlacement->setCurrentWidget( pageLine );
177 mLinePlacementFrame->setVisible(
true );
180 stackedPlacement->setCurrentWidget( pagePolygon );
181 mLinePlacementFrame->setVisible(
false );
190 mPlacePointBtnGrp =
new QButtonGroup(
this );
191 mPlacePointBtnGrp->addButton( radAroundPoint );
192 mPlacePointBtnGrp->addButton( radOverPoint );
193 mPlacePointBtnGrp->setExclusive(
true );
197 mPlaceLineBtnGrp =
new QButtonGroup(
this );
198 mPlaceLineBtnGrp->addButton( radAroundLine );
199 mPlaceLineBtnGrp->addButton( radOverLine );
200 mPlaceLineBtnGrp->setExclusive(
true );
204 mPlacePolygonBtnGrp =
new QButtonGroup(
this );
205 mPlacePolygonBtnGrp->addButton( radAroundCentroid );
206 mPlacePolygonBtnGrp->addButton( radOverCentroid );
207 mPlacePolygonBtnGrp->addButton( radPolygonPerimeter );
208 mPlacePolygonBtnGrp->addButton( radInsidePolygon );
209 mPlacePolygonBtnGrp->setExclusive(
true );
215 mScaleDependencyComboBox->addItem( tr(
"Area" ),
true );
216 mScaleDependencyComboBox->addItem( tr(
"Diameter" ),
false );
218 mAngleOffsetComboBox->addItem( tr(
"Top" ), 270 );
219 mAngleOffsetComboBox->addItem( tr(
"Right" ), 0 );
220 mAngleOffsetComboBox->addItem( tr(
"Bottom" ), 90 );
221 mAngleOffsetComboBox->addItem( tr(
"Left" ), 180 );
229 QSizePolicy policy( mDiagramOptionsListFrame->sizePolicy() );
230 policy.setHorizontalStretch( 0 );
231 mDiagramOptionsListFrame->setSizePolicy( policy );
232 if ( !settings.
contains( QStringLiteral(
"/Windows/Diagrams/OptionsSplitState" ) ) )
235 QList<int> splitsizes;
237 mDiagramOptionsSplitter->setSizes( splitsizes );
241 mDiagramOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Diagrams/OptionsSplitState" ) ).toByteArray() );
242 mDiagramOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Diagrams/Tab" ), 0 ).toInt() );
245 mSizeFieldExpressionWidget->setLayer( mLayer );
249 mSizeFieldExpressionWidget->setGeomCalculator( myDa );
253 for (
int idx = 0; idx < layerFields.
count(); ++idx )
255 QTreeWidgetItem *newItem =
new QTreeWidgetItem( mAttributesTreeWidget );
256 const QString name = QStringLiteral(
"\"%1\"" ).arg( layerFields.
at( idx ).
name() );
257 newItem->setText( 0, name );
258 newItem->setData( 0, RoleAttributeExpression, name );
259 newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );
263 mPaintEffect->setEnabled(
false );
286 mDiagramAttributesTreeWidget->clear();
291 mDiagramTypeComboBox->blockSignals(
true );
292 mDiagramTypeComboBox->setCurrentIndex( 0 );
293 mDiagramTypeComboBox->blockSignals(
false );
294 mFixedSizeRadio->setChecked(
true );
297 mLabelPlacementComboBox->setCurrentIndex( mLabelPlacementComboBox->findText( tr(
"x-height" ) ) );
298 mDiagramSizeSpinBox->setEnabled(
true );
299 mDiagramSizeSpinBox->setValue( 15 );
300 mLinearScaleFrame->setEnabled(
false );
301 mIncreaseMinimumSizeSpinBox->setEnabled(
false );
302 mIncreaseMinimumSizeLabel->setEnabled(
false );
303 mBarWidthSpinBox->setValue( 5 );
306 mShowAllCheckBox->setChecked(
true );
307 mCheckBoxAttributeLegend->setChecked(
true );
312 radAroundPoint->setChecked(
true );
316 radAroundLine->setChecked(
true );
317 chkLineAbove->setChecked(
true );
318 chkLineBelow->setChecked(
false );
319 chkLineOn->setChecked(
false );
320 chkLineOrientationDependent->setChecked(
false );
324 radOverCentroid->setChecked(
true );
325 mDiagramDistanceLabel->setEnabled(
false );
326 mDiagramDistanceSpinBox->setEnabled(
false );
327 mDistanceDDBtn->setEnabled(
false );
334 mBackgroundColorButton->setColor( QColor( 255, 255, 255, 255 ) );
342 if ( dr->
rendererName() == QLatin1String(
"SingleCategory" ) )
344 mFixedSizeRadio->setChecked(
true );
348 mAttributeBasedScalingRadio->setChecked(
true );
350 mDiagramSizeSpinBox->setEnabled( mFixedSizeRadio->isChecked() );
351 mLinearScaleFrame->setEnabled( mAttributeBasedScalingRadio->isChecked() );
356 if ( !settingList.isEmpty() )
358 mDiagramFrame->setEnabled( settingList.at( 0 ).enabled );
359 mDiagramFontButton->setCurrentFont( settingList.at( 0 ).font );
360 const QSizeF size = settingList.at( 0 ).size;
361 mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor );
362 mOpacityWidget->setOpacity( settingList.at( 0 ).opacity );
363 mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor );
364 mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
365 mDiagramSizeSpinBox->setValue( ( size.width() + size.height() ) / 2.0 );
366 mScaleRangeWidget->setScaleRange( ( settingList.at( 0 ).minimumScale > 0 ? settingList.at( 0 ).minimumScale : mLayer->
minimumScale() ),
367 ( settingList.at( 0 ).maximumScale > 0 ? settingList.at( 0 ).maximumScale : mLayer->
maximumScale() ) );
368 mScaleVisibilityGroupBox->setChecked( settingList.at( 0 ).scaleBasedVisibility );
369 mDiagramUnitComboBox->setUnit( settingList.at( 0 ).sizeType );
370 mDiagramUnitComboBox->setMapUnitScale( settingList.at( 0 ).sizeScale );
371 mDiagramLineUnitComboBox->setUnit( settingList.at( 0 ).lineSizeUnit );
372 mDiagramLineUnitComboBox->setMapUnitScale( settingList.at( 0 ).lineSizeScale );
376 mLabelPlacementComboBox->setCurrentIndex( 0 );
380 mLabelPlacementComboBox->setCurrentIndex( 1 );
383 if ( settingList.at( 0 ).paintEffect() )
384 mPaintEffect.reset( settingList.at( 0 ).paintEffect()->clone() );
386 mAngleOffsetComboBox->setCurrentIndex( mAngleOffsetComboBox->findData( settingList.at( 0 ).rotationOffset ) );
387 mAngleDirectionComboBox->setCurrentIndex( mAngleDirectionComboBox->findData( settingList.at( 0 ).direction() ) );
393 switch ( settingList.at( 0 ).diagramOrientation )
396 mOrientationLeftButton->setChecked(
true );
400 mOrientationRightButton->setChecked(
true );
404 mOrientationUpButton->setChecked(
true );
408 mOrientationDownButton->setChecked(
true );
412 mBarWidthSpinBox->setValue( settingList.at( 0 ).barWidth );
413 mBarSpacingSpinBox->setValue( settingList.at( 0 ).spacing() );
414 mBarSpacingUnitComboBox->setUnit( settingList.at( 0 ).spacingUnit() );
415 mBarSpacingUnitComboBox->setMapUnitScale( settingList.at( 0 ).spacingMapUnitScale() );
417 mShowAxisGroupBox->setChecked( settingList.at( 0 ).showAxis() );
418 if ( settingList.at( 0 ).axisLineSymbol() )
419 mAxisLineStyleButton->setSymbol( settingList.at( 0 ).axisLineSymbol()->clone() );
421 mIncreaseSmallDiagramsCheck->setChecked( settingList.at( 0 ).minimumSize != 0 );
422 mIncreaseMinimumSizeSpinBox->setEnabled( mIncreaseSmallDiagramsCheck->isChecked() );
423 mIncreaseMinimumSizeLabel->setEnabled( mIncreaseSmallDiagramsCheck->isChecked() );
425 mIncreaseMinimumSizeSpinBox->setValue( settingList.at( 0 ).minimumSize );
427 if ( settingList.at( 0 ).scaleByArea )
429 mScaleDependencyComboBox->setCurrentIndex( 0 );
433 mScaleDependencyComboBox->setCurrentIndex( 1 );
436 const QList< QColor > categoryColors = settingList.at( 0 ).categoryColors;
437 const QList< QString > categoryAttributes = settingList.at( 0 ).categoryAttributes;
438 const QList< QString > categoryLabels = settingList.at( 0 ).categoryLabels;
439 QList< QString >::const_iterator catIt = categoryAttributes.constBegin();
440 QList< QColor >::const_iterator coIt = categoryColors.constBegin();
441 QList< QString >::const_iterator labIt = categoryLabels.constBegin();
442 for ( ; catIt != categoryAttributes.constEnd(); ++catIt, ++coIt, ++labIt )
444 QTreeWidgetItem *newItem =
new QTreeWidgetItem( mDiagramAttributesTreeWidget );
445 newItem->setText( 0, *catIt );
446 newItem->setData( 0, RoleAttributeExpression, *catIt );
447 newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );
448 newItem->setData( ColumnColor, Qt::EditRole, *coIt );
449 newItem->setText( 2, *labIt );
450 newItem->setFlags( newItem->flags() | Qt::ItemIsEditable );
454 if ( dr->
rendererName() == QLatin1String(
"LinearlyInterpolated" ) )
459 mDiagramSizeSpinBox->setEnabled(
false );
460 mLinearScaleFrame->setEnabled(
true );
461 mMaxValueSpinBox->setValue( lidr->
upperValue() );
462 mSizeSpinBox->setValue( ( lidr->
upperSize().width() + lidr->
upperSize().height() ) / 2 );
479 mDiagramDistanceSpinBox->setValue( dls->
distance() );
480 mPrioritySlider->setValue( dls->
priority() );
481 mZIndexSpinBox->setValue( dls->
zIndex() );
486 radAroundPoint->setChecked(
true );
487 radAroundCentroid->setChecked(
true );
491 radOverPoint->setChecked(
true );
492 radOverCentroid->setChecked(
true );
496 radAroundLine->setChecked(
true );
497 radPolygonPerimeter->setChecked(
true );
501 radOverLine->setChecked(
true );
502 radInsidePolygon->setChecked(
true );
513 chkLineOrientationDependent->setChecked(
true );
525 mDiagramTypeComboBox->blockSignals(
true );
526 mDiagramTypeComboBox->setCurrentIndex( settingList.at( 0 ).enabled ? mDiagramTypeComboBox->findData( mDiagramType ) : 0 );
527 mDiagramTypeComboBox->blockSignals(
false );
530 if ( mDiagramTypeComboBox->currentIndex() == -1 )
532 QMessageBox::warning(
this, tr(
"Diagram Properties" ),
533 tr(
"The diagram type '%1' is unknown. A default type is selected for you." ).arg( mDiagramType ), QMessageBox::Ok );
534 mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findData(
DIAGRAM_NAME_PIE ) );
538 mPaintEffectWidget->setPaintEffect( mPaintEffect.get() );
544 settings.
setValue( QStringLiteral(
"Windows/Diagrams/OptionsSplitState" ), mDiagramOptionsSplitter->saveState() );
545 settings.
setValue( QStringLiteral(
"Windows/Diagrams/Tab" ), mDiagramOptionsListWidget->currentRow() );
556 void QgsDiagramProperties::updateProperty()
567 mDiagramFrame->setEnabled(
false );
571 mDiagramFrame->setEnabled(
true );
573 mDiagramType = mDiagramTypeComboBox->itemData( index ).toString();
577 mTextOptionsFrame->show();
578 mBackgroundColorLabel->show();
579 mBackgroundColorButton->show();
580 mBackgroundColorDDBtn->show();
581 mDiagramFontButton->show();
585 mTextOptionsFrame->hide();
586 mBackgroundColorLabel->hide();
587 mBackgroundColorButton->hide();
588 mBackgroundColorDDBtn->hide();
589 mDiagramFontButton->hide();
594 mBarWidthLabel->show();
595 mBarWidthSpinBox->show();
596 mBarSpacingLabel->show();
597 mBarSpacingSpinBox->show();
598 mBarSpacingUnitComboBox->show();
599 mBarOptionsFrame->show();
600 mShowAxisGroupBox->show();
602 mAttributeBasedScalingRadio->setChecked(
true );
605 mLinearlyScalingLabel->setText( tr(
"Bar length: Scale linearly, so that the following value matches the specified bar length:" ) );
606 mSizeLabel->setText( tr(
"Bar length" ) );
607 mFrameIncreaseSize->setVisible(
false );
611 mBarWidthLabel->hide();
612 mBarWidthSpinBox->hide();
613 mBarSpacingLabel->hide();
614 mBarSpacingSpinBox->hide();
615 mBarSpacingUnitComboBox->hide();
616 mShowAxisGroupBox->hide();
617 mBarOptionsFrame->hide();
618 mLinearlyScalingLabel->setText( tr(
"Scale linearly between 0 and the following attribute value / diagram size:" ) );
619 mSizeLabel->setText( tr(
"Size" ) );
620 mAttributeBasedScalingRadio->setEnabled(
true );
621 mFixedSizeRadio->setEnabled(
true );
622 mDiagramSizeSpinBox->setEnabled( mFixedSizeRadio->isChecked() );
623 mFrameIncreaseSize->setVisible(
true );
628 mScaleDependencyComboBox->show();
629 mScaleDependencyLabel->show();
633 mScaleDependencyComboBox->hide();
634 mScaleDependencyLabel->hide();
639 mAngleOffsetComboBox->show();
640 mAngleDirectionComboBox->show();
641 mAngleDirectionLabel->show();
642 mAngleOffsetLabel->show();
643 mStartAngleDDBtn->show();
647 mAngleOffsetComboBox->hide();
648 mAngleDirectionComboBox->hide();
649 mAngleDirectionLabel->hide();
650 mAngleOffsetLabel->hide();
651 mStartAngleDDBtn->hide();
655 QString QgsDiagramProperties::guessLegendText(
const QString &expression )
658 QString text = expression.mid( expression.startsWith(
'\"' ) ? 1 : 0 );
659 if ( text.endsWith(
'\"' ) )
666 QTreeWidgetItem *newItem =
new QTreeWidgetItem( mDiagramAttributesTreeWidget );
668 newItem->setText( 0, item->text( 0 ) );
669 newItem->setText( 2, guessLegendText( item->text( 0 ) ) );
670 newItem->setData( 0, RoleAttributeExpression, item->data( 0, RoleAttributeExpression ) );
671 newItem->setFlags( ( newItem->flags() | Qt::ItemIsEditable ) & ~Qt::ItemIsDropEnabled );
674 QRandomGenerator colorGenerator;
675 const int red = colorGenerator.bounded( 1, 256 );
676 const int green = colorGenerator.bounded( 1, 256 );
677 const int blue = colorGenerator.bounded( 1, 256 );
678 const QColor randomColor( red, green, blue );
679 newItem->setData( ColumnColor, Qt::EditRole, randomColor );
680 mDiagramAttributesTreeWidget->addTopLevelItem( newItem );
685 const auto constSelectedItems = mAttributesTreeWidget->selectedItems();
686 for ( QTreeWidgetItem *attributeItem : constSelectedItems )
700 const auto constSelectedItems = mDiagramAttributesTreeWidget->selectedItems();
701 for ( QTreeWidgetItem *attributeItem : constSelectedItems )
703 delete attributeItem;
712 float maxValue = 0.0;
715 const QString sizeFieldNameOrExp = mSizeFieldExpressionWidget->currentField( &isExpression );
733 maxValue = std::max( maxValue, exp.
evaluate( &context ).toFloat() );
744 maxValue = mLayer->
maximumValue( attributeNumber ).toFloat();
747 mMaxValueSpinBox->setValue( maxValue );
754 case ColumnAttributeExpression:
756 const QString currentExpression = item->data( 0, RoleAttributeExpression ).toString();
758 const QString newExpression = showExpressionBuilder( currentExpression );
759 if ( !newExpression.isEmpty() )
761 item->setData( 0, Qt::DisplayRole, newExpression );
762 item->setData( 0, RoleAttributeExpression, newExpression );
770 case ColumnLegendText:
795 const int index = mDiagramTypeComboBox->currentIndex();
796 const bool diagramsEnabled = ( index != 0 );
798 std::unique_ptr< QgsDiagram > diagram;
800 if ( diagramsEnabled && 0 == mDiagramAttributesTreeWidget->topLevelItemCount() )
802 QMessageBox::warning(
this, tr(
"Diagrams: No attributes added." ),
803 tr(
"You did not add any attributes to this diagram layer. Please specify the attributes to visualize on the diagrams or disable diagrams." ) );
808 diagram = std::make_unique< QgsTextDiagram >();
812 diagram = std::make_unique< QgsPieDiagram >();
816 diagram = std::make_unique< QgsStackedBarDiagram >();
820 diagram = std::make_unique< QgsHistogramDiagram >();
824 ds.
enabled = ( mDiagramTypeComboBox->currentIndex() != 0 );
825 ds.
font = mDiagramFontButton->currentFont();
826 ds.
opacity = mOpacityWidget->opacity();
828 QList<QColor> categoryColors;
829 QList<QString> categoryAttributes;
830 QList<QString> categoryLabels;
831 categoryColors.reserve( mDiagramAttributesTreeWidget->topLevelItemCount() );
832 categoryAttributes.reserve( mDiagramAttributesTreeWidget->topLevelItemCount() );
833 categoryLabels.reserve( mDiagramAttributesTreeWidget->topLevelItemCount() );
834 for (
int i = 0; i < mDiagramAttributesTreeWidget->topLevelItemCount(); ++i )
836 QColor color = mDiagramAttributesTreeWidget->topLevelItem( i )->data( ColumnColor, Qt::EditRole ).value<QColor>();
837 categoryColors.append( color );
838 categoryAttributes.append( mDiagramAttributesTreeWidget->topLevelItem( i )->data( 0, RoleAttributeExpression ).toString() );
839 categoryLabels.append( mDiagramAttributesTreeWidget->topLevelItem( i )->text( 2 ) );
844 ds.
size = QSizeF( mDiagramSizeSpinBox->value(), mDiagramSizeSpinBox->value() );
845 ds.
sizeType = mDiagramUnitComboBox->unit();
846 ds.
sizeScale = mDiagramUnitComboBox->getMapUnitScale();
848 ds.
lineSizeScale = mDiagramLineUnitComboBox->getMapUnitScale();
852 if ( mIncreaseSmallDiagramsCheck->isChecked() )
854 ds.
minimumSize = mIncreaseMinimumSizeSpinBox->value();
862 ds.
penColor = mDiagramPenColorButton->color();
863 ds.
penWidth = mPenWidthSpinBox->value();
875 ds.
barWidth = mBarWidthSpinBox->value();
890 if ( mFixedSizeRadio->isChecked() )
902 dr->
setUpperSize( QSizeF( mSizeSpinBox->value(), mSizeSpinBox->value() ) );
905 const QString sizeFieldNameOrExp = mSizeFieldExpressionWidget->currentField( &isExpression );
927 dls.
setDistance( mDiagramDistanceSpinBox->value() );
929 dls.
setZIndex( mZIndexSpinBox->value() );
932 QWidget *curWdgt = stackedPlacement->currentWidget();
933 if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
934 || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
938 else if ( ( curWdgt == pagePoint && radOverPoint->isChecked() )
939 || ( curWdgt == pagePolygon && radOverCentroid->isChecked() ) )
943 else if ( ( curWdgt == pageLine && radAroundLine->isChecked() )
944 || ( curWdgt == pagePolygon && radPolygonPerimeter->isChecked() ) )
948 else if ( ( curWdgt == pageLine && radOverLine->isChecked() )
949 || ( curWdgt == pagePolygon && radInsidePolygon->isChecked() ) )
955 qFatal(
"Invalid settings" );
958 QgsDiagramLayerSettings::LinePlacementFlags flags = QgsDiagramLayerSettings::LinePlacementFlags();
959 if ( chkLineAbove->isChecked() )
961 if ( chkLineBelow->isChecked() )
963 if ( chkLineOn->isChecked() )
965 if ( ! chkLineOrientationDependent->isChecked() )
976 QString QgsDiagramProperties::showExpressionBuilder(
const QString &initialExpression )
986 dlg.setWindowTitle( tr(
"Expression Based Attribute" ) );
991 dlg.setGeomCalculator( myDa );
993 if ( dlg.exec() == QDialog::Accepted )
995 return dlg.expressionText();
1006 QList<QTreeWidgetItem *> selections = mAttributesTreeWidget->selectedItems();
1007 if ( !selections.empty() )
1009 expression = selections[0]->text( 0 );
1012 const QString newExpression = showExpressionBuilder( expression );
1015 if ( !newExpression.isEmpty() )
1017 QTreeWidgetItem *newItem =
new QTreeWidgetItem( mDiagramAttributesTreeWidget );
1019 newItem->setText( 0, newExpression );
1020 newItem->setText( 2, newExpression );
1021 newItem->setData( 0, RoleAttributeExpression, newExpression );
1022 newItem->setFlags( ( newItem->flags() | Qt::ItemIsEditable ) & ~Qt::ItemIsDropEnabled );
1025 QRandomGenerator colorGenerator;
1026 const int red = colorGenerator.bounded( 1, 256 );
1027 const int green = colorGenerator.bounded( 1, 256 );
1028 const int blue = colorGenerator.bounded( 1, 256 );
1030 const QColor randomColor( red, green, blue );
1031 newItem->setData( ColumnColor, Qt::EditRole, randomColor );
1032 mDiagramAttributesTreeWidget->addTopLevelItem( newItem );
1039 mDiagramOptionsListWidget->blockSignals(
true );
1040 mDiagramOptionsListWidget->setCurrentRow( index );
1041 mDiagramOptionsListWidget->blockSignals(
false );
1046 QWidget *curWdgt = stackedPlacement->currentWidget();
1048 if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
1049 || ( curWdgt == pageLine && radAroundLine->isChecked() )
1050 || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
1052 mDiagramDistanceLabel->setEnabled(
true );
1053 mDiagramDistanceSpinBox->setEnabled(
true );
1054 mDistanceDDBtn->setEnabled(
true );
1058 mDiagramDistanceLabel->setEnabled(
false );
1059 mDiagramDistanceSpinBox->setEnabled(
false );
1060 mDistanceDDBtn->setEnabled(
false );
1064 chkLineAbove->setEnabled( linePlacementEnabled );
1065 chkLineBelow->setEnabled( linePlacementEnabled );
1066 chkLineOn->setEnabled( linePlacementEnabled );
1067 chkLineOrientationDependent->setEnabled( linePlacementEnabled );
1072 mButtonSizeLegendSettings->setEnabled( mAttributeBasedScalingRadio->isChecked() );
1079 const QString sizeFieldNameOrExp = mSizeFieldExpressionWidget->currentField( &isExpression );
1081 const bool scaleByArea = mScaleDependencyComboBox->currentData().toBool();
1083 0.0, mMaxValueSpinBox->value(), 0.0, mSizeSpinBox->value() ) );
1085 QgsDataDefinedSizeLegendWidget *panel =
new QgsDataDefinedSizeLegendWidget( mSizeLegend.get(), ddSize,
nullptr, mMapCanvas );
1088 dlg.setLayout(
new QVBoxLayout() );
1089 dlg.setWindowTitle( panel->panelTitle() );
1090 dlg.layout()->addWidget( panel );
1091 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
1092 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1093 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsDiagramProperties::showHelp );
1094 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1095 dlg.layout()->addWidget( buttonBox );
1097 mSizeLegend.reset( panel->dataDefinedSizeLegend() );
1100 void QgsDiagramProperties::showHelp()
1102 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#legend" ) );
1105 void QgsDiagramProperties::createAuxiliaryField()
1129 property.setActive(
true );