Navigation Menu

Skip to content

Commit

Permalink
Fix few bugs + fix test images + allow data-defined size without tran…
Browse files Browse the repository at this point in the history
…sformer
  • Loading branch information
wonder-sk committed Jun 22, 2017
1 parent 59ca985 commit 4976d59
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgsrendererwidget.sip
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp
Expand Up @@ -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
}
}
8 changes: 4 additions & 4 deletions src/gui/symbology-ng/qgsdatadefinedsizelegendwidget.cpp
Expand Up @@ -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 );

Expand All @@ -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();
Expand Down Expand Up @@ -187,7 +187,7 @@ void QgsDataDefinedSizeLegendWidget::changeSymbol()
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSourceSymbol.get(), btnChangeSymbol->iconSize() );
btnChangeSymbol->setIcon( icon );

updatePreview();
emit widgetChanged();
}

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

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

mSizeClassesModel->removeRow( idx.row() );
updatePreview();
emit widgetChanged();
}
3 changes: 2 additions & 1 deletion src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp
Expand Up @@ -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
}
}
8 changes: 1 addition & 7 deletions src/gui/symbology-ng/qgsrendererwidget.cpp
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/gui/symbology-ng/qgsrendererwidget.h
Expand Up @@ -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 );
Expand Down
3 changes: 2 additions & 1 deletion src/gui/symbology-ng/qgssinglesymbolrendererwidget.cpp
Expand Up @@ -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
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4976d59

Please sign in to comment.