Skip to content
Permalink
Browse files

Fix few bugs + fix test images + allow data-defined size without tran…

…sformer
  • Loading branch information
wonder-sk committed Jun 22, 2017
1 parent 59ca985 commit 4976d59fc5125112058b7f7086bf3d83fb10b61a
@@ -86,7 +86,7 @@ and by connecting the slot contextMenuViewCategories(const QPoint&)*
%End
virtual void refreshSymbolView();

QgsDataDefinedSizeLegendWidget *openDataDefinedSizeLegendWidget( const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend );
QgsDataDefinedSizeLegendWidget *createDataDefinedSizeLegendWidget( const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend ) /Factory/;
%Docstring
.. versionadded:: 3.0
:rtype: QgsDataDefinedSizeLegendWidget
@@ -1046,13 +1046,14 @@ QgsExpressionContext QgsCategorizedSymbolRendererWidget::createExpressionContext
void QgsCategorizedSymbolRendererWidget::dataDefinedSizeLegend()
{
QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( mCategorizedSymbol ); // this should be only enabled for marker symbols
QgsDataDefinedSizeLegendWidget *panel = openDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() );
QgsDataDefinedSizeLegendWidget *panel = createDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() );
if ( panel )
{
connect( panel, &QgsPanelWidget::widgetChanged, [ = ]
{
mRenderer->setDataDefinedSizeLegend( panel->dataDefinedSizeLegend() );
emit widgetChanged();
} );
openPanel( panel ); // takes ownership of the panel
}
}
@@ -90,7 +90,6 @@ QgsDataDefinedSizeLegendWidget::QgsDataDefinedSizeLegendWidget( const QgsDataDef
mSizeClassesModel->sort( 0 );
}

connect( groupManualSizeClasses, &QGroupBox::clicked, this, &QgsDataDefinedSizeLegendWidget::updatePreview );
connect( btnAddClass, &QToolButton::clicked, this, &QgsDataDefinedSizeLegendWidget::addSizeClass );
connect( btnRemoveClass, &QToolButton::clicked, this, &QgsDataDefinedSizeLegendWidget::removeSizeClass );

@@ -109,6 +108,7 @@ QgsDataDefinedSizeLegendWidget::QgsDataDefinedSizeLegendWidget( const QgsDataDef
connect( radDisabled, &QRadioButton::clicked, this, &QgsPanelWidget::widgetChanged );
connect( radSeparated, &QRadioButton::clicked, this, &QgsPanelWidget::widgetChanged );
connect( radCollapsed, &QRadioButton::clicked, this, &QgsPanelWidget::widgetChanged );
connect( groupManualSizeClasses, &QGroupBox::clicked, this, &QgsPanelWidget::widgetChanged );
connect( btnChangeSymbol, &QPushButton::clicked, this, &QgsDataDefinedSizeLegendWidget::changeSymbol );
connect( this, &QgsPanelWidget::widgetChanged, this, &QgsDataDefinedSizeLegendWidget::updatePreview );
updatePreview();
@@ -187,7 +187,7 @@ void QgsDataDefinedSizeLegendWidget::changeSymbol()
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSourceSymbol.get(), btnChangeSymbol->iconSize() );
btnChangeSymbol->setIcon( icon );

updatePreview();
emit widgetChanged();
}

void QgsDataDefinedSizeLegendWidget::addSizeClass()
@@ -203,7 +203,7 @@ void QgsDataDefinedSizeLegendWidget::addSizeClass()
item->setData( v );
mSizeClassesModel->appendRow( item );
mSizeClassesModel->sort( 0 );
updatePreview();
emit widgetChanged();
}

void QgsDataDefinedSizeLegendWidget::removeSizeClass()
@@ -213,5 +213,5 @@ void QgsDataDefinedSizeLegendWidget::removeSizeClass()
return;

mSizeClassesModel->removeRow( idx.row() );
updatePreview();
emit widgetChanged();
}
@@ -1178,13 +1178,14 @@ void QgsGraduatedSymbolRendererWidget::keyPressEvent( QKeyEvent *event )
void QgsGraduatedSymbolRendererWidget::dataDefinedSizeLegend()
{
QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( mGraduatedSymbol ); // this should be only enabled for marker symbols
QgsDataDefinedSizeLegendWidget *panel = openDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() );
QgsDataDefinedSizeLegendWidget *panel = createDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() );
if ( panel )
{
connect( panel, &QgsPanelWidget::widgetChanged, [ = ]
{
mRenderer->setDataDefinedSizeLegend( panel->dataDefinedSizeLegend() );
emit widgetChanged();
} );
openPanel( panel ); // takes ownership of the panel
}
}
@@ -275,23 +275,17 @@ void QgsRendererWidget::applyChanges()
apply();
}

QgsDataDefinedSizeLegendWidget *QgsRendererWidget::openDataDefinedSizeLegendWidget( const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend )
QgsDataDefinedSizeLegendWidget *QgsRendererWidget::createDataDefinedSizeLegendWidget( const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend )
{
QgsProperty ddSize = symbol->dataDefinedSize();
if ( !ddSize || !ddSize.isActive() )
{
QMessageBox::warning( this, tr( "Data-defined size legend" ), tr( "Data-defined size is not enabled!" ) );
return nullptr;
}
if ( !ddSize.transformer() )
{
QMessageBox::warning( this, tr( "Data-defined size legend" ), tr( "Data-defined size is enabled, but without size scale transformer. Use assistant to define it." ) );
return nullptr;
}

QgsDataDefinedSizeLegendWidget *panel = new QgsDataDefinedSizeLegendWidget( ddsLegend, ddSize, symbol->clone(), mContext.mapCanvas() );
connect( panel, &QgsPanelWidget::widgetChanged, this, &QgsPanelWidget::widgetChanged );
openPanel( panel );
return panel;
}

@@ -100,10 +100,10 @@ class GUI_EXPORT QgsRendererWidget : public QgsPanelWidget
virtual QList<QgsSymbol *> selectedSymbols() { return QList<QgsSymbol *>(); }
virtual void refreshSymbolView() {}

//! Shows GUI to setup data-defined size legend.
//! Returns newly open panel - may be null if it could not be opened. Ownership is not transferred.
//! Creates widget to setup data-defined size legend.
//! Returns newly created panel - may be null if it could not be opened. Ownership is transferred to the caller.
//! \since QGIS 3.0
QgsDataDefinedSizeLegendWidget *openDataDefinedSizeLegendWidget( const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend );
QgsDataDefinedSizeLegendWidget *createDataDefinedSizeLegendWidget( const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend ) SIP_FACTORY;

protected slots:
void contextMenuViewCategories( QPoint p );
@@ -119,13 +119,14 @@ void QgsSingleSymbolRendererWidget::showSymbolLevels()
void QgsSingleSymbolRendererWidget::dataDefinedSizeLegend()
{
QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( mSingleSymbol ); // this should be only enabled for marker symbols
QgsDataDefinedSizeLegendWidget *panel = openDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() );
QgsDataDefinedSizeLegendWidget *panel = createDataDefinedSizeLegendWidget( s, mRenderer->dataDefinedSizeLegend() );
if ( panel )
{
connect( panel, &QgsPanelWidget::widgetChanged, [ = ]
{
mRenderer->setDataDefinedSizeLegend( panel->dataDefinedSizeLegend() );
emit widgetChanged();
} );
openPanel( panel ); // takes ownership of the panel
}
}
Binary file not shown.
Binary file not shown.

0 comments on commit 4976d59

Please sign in to comment.
You can’t perform that action at this time.