mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-28 00:06:23 -05:00
color ramp button widget for gradiant fill and categorized renderer
This commit is contained in:
parent
fa16e3e403
commit
deb18c40db
@ -48,7 +48,7 @@ class QgsColorRamp
|
|||||||
*/
|
*/
|
||||||
virtual QString type() const = 0;
|
virtual QString type() const = 0;
|
||||||
|
|
||||||
virtual void invert() = 0;
|
virtual void invert();
|
||||||
|
|
||||||
/** Creates a clone of the color ramp.
|
/** Creates a clone of the color ramp.
|
||||||
*/
|
*/
|
||||||
@ -226,8 +226,6 @@ class QgsLimitedRandomColorRamp : QgsColorRamp
|
|||||||
|
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
|
||||||
virtual void invert();
|
|
||||||
|
|
||||||
virtual QgsLimitedRandomColorRamp* clone() const /Factory/;
|
virtual QgsLimitedRandomColorRamp* clone() const /Factory/;
|
||||||
|
|
||||||
virtual QgsStringMap properties() const;
|
virtual QgsStringMap properties() const;
|
||||||
@ -287,8 +285,6 @@ class QgsRandomColorRamp : QgsColorRamp
|
|||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
|
|
||||||
virtual void invert();
|
|
||||||
|
|
||||||
virtual QgsRandomColorRamp* clone() const /Factory/;
|
virtual QgsRandomColorRamp* clone() const /Factory/;
|
||||||
|
|
||||||
QgsStringMap properties() const;
|
QgsStringMap properties() const;
|
||||||
|
|||||||
@ -157,16 +157,11 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
|
|||||||
*/
|
*/
|
||||||
void setSourceColorRamp( QgsColorRamp* ramp /Transfer/ );
|
void setSourceColorRamp( QgsColorRamp* ramp /Transfer/ );
|
||||||
|
|
||||||
//! @note added in 2.1
|
|
||||||
bool invertedColorRamp();
|
|
||||||
void setInvertedColorRamp( bool inverted );
|
|
||||||
|
|
||||||
/** Update the color ramp used and all symbols colors.
|
/** Update the color ramp used and all symbols colors.
|
||||||
* @param ramp color ramp. Ownership is transferred to the renderer
|
* @param ramp color ramp. Ownership is transferred to the renderer
|
||||||
* @param inverted set to true to invert ramp colors
|
|
||||||
* @note added in 2.5
|
* @note added in 2.5
|
||||||
*/
|
*/
|
||||||
void updateColorRamp( QgsColorRamp* ramp /Transfer/, bool inverted = false );
|
void updateColorRamp( QgsColorRamp* ramp /Transfer/ );
|
||||||
|
|
||||||
//! items of symbology items in legend should be checkable
|
//! items of symbology items in legend should be checkable
|
||||||
//! @note added in 2.5
|
//! @note added in 2.5
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
%Include qgscharacterselectdialog.sip
|
%Include qgscharacterselectdialog.sip
|
||||||
%Include qgscolorbrewercolorrampdialog.sip
|
%Include qgscolorbrewercolorrampdialog.sip
|
||||||
%Include qgscolorbutton.sip
|
%Include qgscolorbutton.sip
|
||||||
%Include qgscolorbutton.sip
|
%Include qgscolorrampbutton.sip
|
||||||
%Include qgscolordialog.sip
|
%Include qgscolordialog.sip
|
||||||
%Include qgscolorschemelist.sip
|
%Include qgscolorschemelist.sip
|
||||||
%Include qgscolorswatchgrid.sip
|
%Include qgscolorswatchgrid.sip
|
||||||
|
|||||||
@ -72,8 +72,6 @@ class QgsCategorizedSymbolRendererWidget : QgsRendererWidget
|
|||||||
|
|
||||||
void changeCategorySymbol();
|
void changeCategorySymbol();
|
||||||
|
|
||||||
QgsColorRamp* getColorRamp();
|
|
||||||
|
|
||||||
QList<QgsSymbol*> selectedSymbols();
|
QList<QgsSymbol*> selectedSymbols();
|
||||||
QgsCategoryList selectedCategoryList();
|
QgsCategoryList selectedCategoryList();
|
||||||
void refreshSymbolView();
|
void refreshSymbolView();
|
||||||
|
|||||||
@ -51,7 +51,9 @@ class CORE_EXPORT QgsColorRamp
|
|||||||
virtual QString type() const = 0;
|
virtual QString type() const = 0;
|
||||||
|
|
||||||
|
|
||||||
virtual void invert() = 0;
|
/** Inverts the ordering of the color ramp.
|
||||||
|
*/
|
||||||
|
virtual void invert() {}
|
||||||
|
|
||||||
/** Creates a clone of the color ramp.
|
/** Creates a clone of the color ramp.
|
||||||
*/
|
*/
|
||||||
@ -259,7 +261,6 @@ class CORE_EXPORT QgsLimitedRandomColorRamp : public QgsColorRamp
|
|||||||
virtual double value( int index ) const override;
|
virtual double value( int index ) const override;
|
||||||
virtual QColor color( double value ) const override;
|
virtual QColor color( double value ) const override;
|
||||||
virtual QString type() const override { return QStringLiteral( "random" ); }
|
virtual QString type() const override { return QStringLiteral( "random" ); }
|
||||||
virtual void invert() override { return; }
|
|
||||||
virtual QgsLimitedRandomColorRamp* clone() const override;
|
virtual QgsLimitedRandomColorRamp* clone() const override;
|
||||||
virtual QgsStringMap properties() const override;
|
virtual QgsStringMap properties() const override;
|
||||||
int count() const override { return mCount; }
|
int count() const override { return mCount; }
|
||||||
@ -375,8 +376,6 @@ class CORE_EXPORT QgsRandomColorRamp: public QgsColorRamp
|
|||||||
|
|
||||||
QString type() const override;
|
QString type() const override;
|
||||||
|
|
||||||
virtual void invert() override { return; }
|
|
||||||
|
|
||||||
QgsRandomColorRamp* clone() const override;
|
QgsRandomColorRamp* clone() const override;
|
||||||
|
|
||||||
QgsStringMap properties() const override;
|
QgsStringMap properties() const override;
|
||||||
|
|||||||
@ -152,7 +152,6 @@ void QgsRendererCategory::toSld( QDomDocument &doc, QDomElement &element, QgsStr
|
|||||||
QgsCategorizedSymbolRenderer::QgsCategorizedSymbolRenderer( const QString& attrName, const QgsCategoryList& categories )
|
QgsCategorizedSymbolRenderer::QgsCategorizedSymbolRenderer( const QString& attrName, const QgsCategoryList& categories )
|
||||||
: QgsFeatureRenderer( QStringLiteral( "categorizedSymbol" ) )
|
: QgsFeatureRenderer( QStringLiteral( "categorizedSymbol" ) )
|
||||||
, mAttrName( attrName )
|
, mAttrName( attrName )
|
||||||
, mInvertedColorRamp( false )
|
|
||||||
, mAttrNum( -1 )
|
, mAttrNum( -1 )
|
||||||
, mCounting( false )
|
, mCounting( false )
|
||||||
{
|
{
|
||||||
@ -472,7 +471,6 @@ QgsCategorizedSymbolRenderer* QgsCategorizedSymbolRenderer::clone() const
|
|||||||
if ( mSourceColorRamp.data() )
|
if ( mSourceColorRamp.data() )
|
||||||
{
|
{
|
||||||
r->setSourceColorRamp( mSourceColorRamp->clone() );
|
r->setSourceColorRamp( mSourceColorRamp->clone() );
|
||||||
r->setInvertedColorRamp( mInvertedColorRamp );
|
|
||||||
}
|
}
|
||||||
r->setUsingSymbolLevels( usingSymbolLevels() );
|
r->setUsingSymbolLevels( usingSymbolLevels() );
|
||||||
|
|
||||||
@ -631,9 +629,6 @@ QgsFeatureRenderer* QgsCategorizedSymbolRenderer::create( QDomElement& element )
|
|||||||
if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral( "name" ) ) == QLatin1String( "[source]" ) )
|
if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral( "name" ) ) == QLatin1String( "[source]" ) )
|
||||||
{
|
{
|
||||||
r->setSourceColorRamp( QgsSymbolLayerUtils::loadColorRamp( sourceColorRampElem ) );
|
r->setSourceColorRamp( QgsSymbolLayerUtils::loadColorRamp( sourceColorRampElem ) );
|
||||||
QDomElement invertedColorRampElem = element.firstChildElement( QStringLiteral( "invertedcolorramp" ) );
|
|
||||||
if ( !invertedColorRampElem.isNull() )
|
|
||||||
r->setInvertedColorRamp( invertedColorRampElem.attribute( QStringLiteral( "value" ) ) == QLatin1String( "1" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement rotationElem = element.firstChildElement( QStringLiteral( "rotation" ) );
|
QDomElement rotationElem = element.firstChildElement( QStringLiteral( "rotation" ) );
|
||||||
@ -721,9 +716,6 @@ QDomElement QgsCategorizedSymbolRenderer::save( QDomDocument& doc )
|
|||||||
{
|
{
|
||||||
QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( QStringLiteral( "[source]" ), mSourceColorRamp.data(), doc );
|
QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( QStringLiteral( "[source]" ), mSourceColorRamp.data(), doc );
|
||||||
rendererElem.appendChild( colorRampElem );
|
rendererElem.appendChild( colorRampElem );
|
||||||
QDomElement invertedElem = doc.createElement( QStringLiteral( "invertedcolorramp" ) );
|
|
||||||
invertedElem.setAttribute( QStringLiteral( "value" ), mInvertedColorRamp );
|
|
||||||
rendererElem.appendChild( invertedElem );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement rotationElem = doc.createElement( QStringLiteral( "rotation" ) );
|
QDomElement rotationElem = doc.createElement( QStringLiteral( "rotation" ) );
|
||||||
@ -864,10 +856,9 @@ void QgsCategorizedSymbolRenderer::setSourceColorRamp( QgsColorRamp* ramp )
|
|||||||
mSourceColorRamp.reset( ramp );
|
mSourceColorRamp.reset( ramp );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsCategorizedSymbolRenderer::updateColorRamp( QgsColorRamp* ramp, bool inverted )
|
void QgsCategorizedSymbolRenderer::updateColorRamp( QgsColorRamp* ramp )
|
||||||
{
|
{
|
||||||
setSourceColorRamp( ramp );
|
setSourceColorRamp( ramp );
|
||||||
setInvertedColorRamp( inverted );
|
|
||||||
double num = mCategories.count() - 1;
|
double num = mCategories.count() - 1;
|
||||||
double count = 0;
|
double count = 0;
|
||||||
|
|
||||||
@ -882,7 +873,6 @@ void QgsCategorizedSymbolRenderer::updateColorRamp( QgsColorRamp* ramp, bool inv
|
|||||||
Q_FOREACH ( const QgsRendererCategory &cat, mCategories )
|
Q_FOREACH ( const QgsRendererCategory &cat, mCategories )
|
||||||
{
|
{
|
||||||
double value = count / num;
|
double value = count / num;
|
||||||
if ( mInvertedColorRamp ) value = 1.0 - value;
|
|
||||||
cat.symbol()->setColor( mSourceColorRamp->color( value ) );
|
cat.symbol()->setColor( mSourceColorRamp->color( value ) );
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -167,16 +167,11 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
|
|||||||
*/
|
*/
|
||||||
void setSourceColorRamp( QgsColorRamp* ramp );
|
void setSourceColorRamp( QgsColorRamp* ramp );
|
||||||
|
|
||||||
//! @note added in 2.1
|
|
||||||
bool invertedColorRamp() { return mInvertedColorRamp; }
|
|
||||||
void setInvertedColorRamp( bool inverted ) { mInvertedColorRamp = inverted; }
|
|
||||||
|
|
||||||
/** Update the color ramp used and all symbols colors.
|
/** Update the color ramp used and all symbols colors.
|
||||||
* @param ramp color ramp. Ownership is transferred to the renderer
|
* @param ramp color ramp. Ownership is transferred to the renderer
|
||||||
* @param inverted set to true to invert ramp colors
|
|
||||||
* @note added in 2.5
|
* @note added in 2.5
|
||||||
*/
|
*/
|
||||||
void updateColorRamp( QgsColorRamp* ramp, bool inverted = false );
|
void updateColorRamp( QgsColorRamp* ramp );
|
||||||
|
|
||||||
virtual bool legendSymbolItemsCheckable() const override;
|
virtual bool legendSymbolItemsCheckable() const override;
|
||||||
virtual bool legendSymbolItemChecked( const QString& key ) override;
|
virtual bool legendSymbolItemChecked( const QString& key ) override;
|
||||||
@ -194,7 +189,6 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
|
|||||||
QgsCategoryList mCategories;
|
QgsCategoryList mCategories;
|
||||||
QScopedPointer<QgsSymbol> mSourceSymbol;
|
QScopedPointer<QgsSymbol> mSourceSymbol;
|
||||||
QScopedPointer<QgsColorRamp> mSourceColorRamp;
|
QScopedPointer<QgsColorRamp> mSourceColorRamp;
|
||||||
bool mInvertedColorRamp;
|
|
||||||
QScopedPointer<QgsExpression> mExpression;
|
QScopedPointer<QgsExpression> mExpression;
|
||||||
|
|
||||||
//! attribute index (derived from attribute name in startRender)
|
//! attribute index (derived from attribute name in startRender)
|
||||||
|
|||||||
@ -188,6 +188,7 @@ SET(QGIS_GUI_SRCS
|
|||||||
qgscollapsiblegroupbox.cpp
|
qgscollapsiblegroupbox.cpp
|
||||||
qgscolorbrewercolorrampdialog.cpp
|
qgscolorbrewercolorrampdialog.cpp
|
||||||
qgscolorbutton.cpp
|
qgscolorbutton.cpp
|
||||||
|
qgscolorrampbutton.cpp
|
||||||
qgscolordialog.cpp
|
qgscolordialog.cpp
|
||||||
qgscolorschemelist.cpp
|
qgscolorschemelist.cpp
|
||||||
qgscolorswatchgrid.cpp
|
qgscolorswatchgrid.cpp
|
||||||
@ -356,6 +357,7 @@ SET(QGIS_GUI_MOC_HDRS
|
|||||||
qgscollapsiblegroupbox.h
|
qgscollapsiblegroupbox.h
|
||||||
qgscolorbrewercolorrampdialog.h
|
qgscolorbrewercolorrampdialog.h
|
||||||
qgscolorbutton.h
|
qgscolorbutton.h
|
||||||
|
qgscolorrampbutton.h
|
||||||
qgscolordialog.h
|
qgscolordialog.h
|
||||||
qgscolorschemelist.h
|
qgscolorschemelist.h
|
||||||
qgscolorswatchgrid.h
|
qgscolorswatchgrid.h
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "qgssymbol.h"
|
#include "qgssymbol.h"
|
||||||
#include "qgssymbollayerutils.h"
|
#include "qgssymbollayerutils.h"
|
||||||
#include "qgscolorramp.h"
|
#include "qgscolorramp.h"
|
||||||
|
#include "qgscolorrampbutton.h"
|
||||||
#include "qgsstyle.h"
|
#include "qgsstyle.h"
|
||||||
#include "qgslogger.h"
|
#include "qgslogger.h"
|
||||||
|
|
||||||
@ -410,21 +411,15 @@ QgsCategorizedSymbolRendererWidget::QgsCategorizedSymbolRendererWidget( QgsVecto
|
|||||||
|
|
||||||
mExpressionWidget->setLayer( mLayer );
|
mExpressionWidget->setLayer( mLayer );
|
||||||
|
|
||||||
cboCategorizedColorRamp->populate( mStyle );
|
// initiate color ramp button to random
|
||||||
int randomIndex = cboCategorizedColorRamp->findText( tr( "Random colors" ) );
|
btnColorRamp->setShowRandomColorRamp( true );
|
||||||
if ( randomIndex != -1 )
|
btnColorRamp->setRandomColorRamp();
|
||||||
{
|
|
||||||
cboCategorizedColorRamp->setCurrentIndex( randomIndex );
|
|
||||||
mButtonEditRamp->setEnabled( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
// set project default color ramp
|
// set project default color ramp
|
||||||
QString defaultColorRamp = QgsProject::instance()->readEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/ColorRamp" ), QLatin1String( "" ) );
|
QString defaultColorRamp = QgsProject::instance()->readEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/ColorRamp" ), QLatin1String( "" ) );
|
||||||
if ( defaultColorRamp != QLatin1String( "" ) )
|
if ( defaultColorRamp != QLatin1String( "" ) )
|
||||||
{
|
{
|
||||||
int index = cboCategorizedColorRamp->findText( defaultColorRamp, Qt::MatchCaseSensitive );
|
btnColorRamp->setColorRampFromName( defaultColorRamp );
|
||||||
if ( index >= 0 )
|
|
||||||
cboCategorizedColorRamp->setCurrentIndex( index );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mCategorizedSymbol = QgsSymbol::defaultSymbol( mLayer->geometryType() );
|
mCategorizedSymbol = QgsSymbol::defaultSymbol( mLayer->geometryType() );
|
||||||
@ -455,10 +450,8 @@ QgsCategorizedSymbolRendererWidget::QgsCategorizedSymbolRendererWidget( QgsVecto
|
|||||||
connect( btnDeleteCategories, SIGNAL( clicked() ), this, SLOT( deleteCategories() ) );
|
connect( btnDeleteCategories, SIGNAL( clicked() ), this, SLOT( deleteCategories() ) );
|
||||||
connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) );
|
connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) );
|
||||||
connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) );
|
connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) );
|
||||||
connect( cbxInvertedColorRamp, SIGNAL( toggled( bool ) ), this, SLOT( applyColorRamp() ) );
|
|
||||||
connect( cboCategorizedColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
|
connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsCategorizedSymbolRendererWidget::applyColorRamp );
|
||||||
connect( cboCategorizedColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
|
|
||||||
connect( mButtonEditRamp, SIGNAL( clicked() ), cboCategorizedColorRamp, SLOT( editSourceRamp() ) );
|
|
||||||
|
|
||||||
// menus for data-defined rotation/size
|
// menus for data-defined rotation/size
|
||||||
QMenu* advMenu = new QMenu;
|
QMenu* advMenu = new QMenu;
|
||||||
@ -501,17 +494,11 @@ void QgsCategorizedSymbolRendererWidget::updateUiFromRenderer()
|
|||||||
updateCategorizedSymbolIcon();
|
updateCategorizedSymbolIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set source color ramp
|
// if a color ramp attached to the renderer, enable the color ramp button
|
||||||
if ( mRenderer->sourceColorRamp() )
|
if ( mRenderer->sourceColorRamp() )
|
||||||
{
|
{
|
||||||
cboCategorizedColorRamp->setSourceColorRamp( mRenderer->sourceColorRamp() );
|
btnColorRamp->setColorRamp( mRenderer->sourceColorRamp() );
|
||||||
cbxInvertedColorRamp->setChecked( mRenderer->invertedColorRamp() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cboCategorizedColorRamp->currentText() == tr( "Random colors" ) )
|
|
||||||
mButtonEditRamp->setEnabled( false );
|
|
||||||
else
|
|
||||||
mButtonEditRamp->setEnabled( true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsFeatureRenderer* QgsCategorizedSymbolRendererWidget::renderer()
|
QgsFeatureRenderer* QgsCategorizedSymbolRendererWidget::renderer()
|
||||||
@ -628,20 +615,6 @@ static void _createCategories( QgsCategoryList& cats, QList<QVariant>& values, Q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsColorRamp* QgsCategorizedSymbolRendererWidget::getColorRamp()
|
|
||||||
{
|
|
||||||
QgsColorRamp* ramp = cboCategorizedColorRamp->currentColorRamp();
|
|
||||||
if ( !ramp )
|
|
||||||
{
|
|
||||||
if ( cboCategorizedColorRamp->count() == 0 )
|
|
||||||
QMessageBox::critical( this, tr( "Error" ), tr( "There are no available color ramps. You can add them in Style Manager." ) );
|
|
||||||
else if ( !cboCategorizedColorRamp->createNewColorRampSelected() )
|
|
||||||
QMessageBox::critical( this, tr( "Error" ), tr( "The selected color ramp is not available." ) );
|
|
||||||
}
|
|
||||||
return ramp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QgsCategorizedSymbolRendererWidget::addCategories()
|
void QgsCategorizedSymbolRendererWidget::addCategories()
|
||||||
{
|
{
|
||||||
QString attrName = mExpressionWidget->currentField();
|
QString attrName = mExpressionWidget->currentField();
|
||||||
@ -759,8 +732,7 @@ void QgsCategorizedSymbolRendererWidget::addCategories()
|
|||||||
// recreate renderer
|
// recreate renderer
|
||||||
QgsCategorizedSymbolRenderer *r = new QgsCategorizedSymbolRenderer( attrName, cats );
|
QgsCategorizedSymbolRenderer *r = new QgsCategorizedSymbolRenderer( attrName, cats );
|
||||||
r->setSourceSymbol( mCategorizedSymbol->clone() );
|
r->setSourceSymbol( mCategorizedSymbol->clone() );
|
||||||
r->setInvertedColorRamp( cbxInvertedColorRamp->isChecked() );
|
QScopedPointer< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
|
||||||
QScopedPointer< QgsColorRamp > ramp( getColorRamp() );
|
|
||||||
if ( ramp )
|
if ( ramp )
|
||||||
r->setSourceColorRamp( ramp->clone() );
|
r->setSourceColorRamp( ramp->clone() );
|
||||||
|
|
||||||
@ -777,15 +749,9 @@ void QgsCategorizedSymbolRendererWidget::addCategories()
|
|||||||
|
|
||||||
void QgsCategorizedSymbolRendererWidget::applyColorRamp()
|
void QgsCategorizedSymbolRendererWidget::applyColorRamp()
|
||||||
{
|
{
|
||||||
if ( cboCategorizedColorRamp->currentText() == tr( "Random colors" ) )
|
if ( !btnColorRamp->isNull() )
|
||||||
mButtonEditRamp->setEnabled( false );
|
|
||||||
else
|
|
||||||
mButtonEditRamp->setEnabled( true );
|
|
||||||
|
|
||||||
QgsColorRamp* ramp = getColorRamp();
|
|
||||||
if ( ramp )
|
|
||||||
{
|
{
|
||||||
mRenderer->updateColorRamp( ramp, cbxInvertedColorRamp->isChecked() );
|
mRenderer->updateColorRamp( btnColorRamp->colorRamp()->clone() );
|
||||||
}
|
}
|
||||||
mModel->updateSymbology();
|
mModel->updateSymbology();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,7 +107,11 @@ class GUI_EXPORT QgsCategorizedSymbolRendererWidget : public QgsRendererWidget,
|
|||||||
void categoriesDoubleClicked( const QModelIndex & idx );
|
void categoriesDoubleClicked( const QModelIndex & idx );
|
||||||
void addCategory();
|
void addCategory();
|
||||||
void addCategories();
|
void addCategories();
|
||||||
|
|
||||||
|
/** Applies the color ramp passed on by the color ramp button
|
||||||
|
*/
|
||||||
void applyColorRamp();
|
void applyColorRamp();
|
||||||
|
|
||||||
void deleteCategories();
|
void deleteCategories();
|
||||||
void deleteAllCategories();
|
void deleteAllCategories();
|
||||||
|
|
||||||
@ -156,8 +160,6 @@ class GUI_EXPORT QgsCategorizedSymbolRendererWidget : public QgsRendererWidget,
|
|||||||
|
|
||||||
void changeCategorySymbol();
|
void changeCategorySymbol();
|
||||||
|
|
||||||
QgsColorRamp* getColorRamp();
|
|
||||||
|
|
||||||
QList<QgsSymbol*> selectedSymbols() override;
|
QList<QgsSymbol*> selectedSymbols() override;
|
||||||
QgsCategoryList selectedCategoryList();
|
QgsCategoryList selectedCategoryList();
|
||||||
void refreshSymbolView() override;
|
void refreshSymbolView() override;
|
||||||
|
|||||||
@ -1012,8 +1012,7 @@ QgsGradientFillSymbolLayerWidget::QgsGradientFillSymbolLayerWidget( const QgsVec
|
|||||||
setupUi( this );
|
setupUi( this );
|
||||||
mOffsetUnitWidget->setUnits( QgsUnitTypes::RenderUnitList() << QgsUnitTypes::RenderMillimeters << QgsUnitTypes::RenderMapUnits << QgsUnitTypes::RenderPixels );
|
mOffsetUnitWidget->setUnits( QgsUnitTypes::RenderUnitList() << QgsUnitTypes::RenderMillimeters << QgsUnitTypes::RenderMapUnits << QgsUnitTypes::RenderPixels );
|
||||||
|
|
||||||
cboGradientColorRamp->setShowGradientOnly( true );
|
btnColorRamp->setShowGradientOnly( true );
|
||||||
cboGradientColorRamp->populate( QgsStyle::defaultStyle() );
|
|
||||||
|
|
||||||
btnChangeColor->setAllowAlpha( true );
|
btnChangeColor->setAllowAlpha( true );
|
||||||
btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
|
btnChangeColor->setColorDialogTitle( tr( "Select gradient color" ) );
|
||||||
@ -1031,9 +1030,7 @@ QgsGradientFillSymbolLayerWidget::QgsGradientFillSymbolLayerWidget( const QgsVec
|
|||||||
|
|
||||||
connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
|
connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
|
||||||
connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
|
connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
|
||||||
connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
|
connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsGradientFillSymbolLayerWidget::applyColorRamp );
|
||||||
connect( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
|
|
||||||
connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
|
|
||||||
connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
|
connect( cboGradientType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientType( int ) ) );
|
||||||
connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
|
connect( cboCoordinateMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCoordinateMode( int ) ) );
|
||||||
connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
|
connect( cboGradientSpread, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setGradientSpread( int ) ) );
|
||||||
@ -1067,7 +1064,7 @@ void QgsGradientFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* layer )
|
|||||||
if ( mLayer->gradientColorType() == QgsGradientFillSymbolLayer::SimpleTwoColor )
|
if ( mLayer->gradientColorType() == QgsGradientFillSymbolLayer::SimpleTwoColor )
|
||||||
{
|
{
|
||||||
radioTwoColor->setChecked( true );
|
radioTwoColor->setChecked( true );
|
||||||
cboGradientColorRamp->setEnabled( false );
|
btnColorRamp->setEnabled( false );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1079,9 +1076,9 @@ void QgsGradientFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* layer )
|
|||||||
// set source color ramp
|
// set source color ramp
|
||||||
if ( mLayer->colorRamp() )
|
if ( mLayer->colorRamp() )
|
||||||
{
|
{
|
||||||
cboGradientColorRamp->blockSignals( true );
|
btnColorRamp->blockSignals( true );
|
||||||
cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
|
btnColorRamp->setColorRamp( mLayer->colorRamp() );
|
||||||
cboGradientColorRamp->blockSignals( false );
|
btnColorRamp->blockSignals( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
cboGradientType->blockSignals( true );
|
cboGradientType->blockSignals( true );
|
||||||
@ -1219,11 +1216,10 @@ void QgsGradientFillSymbolLayerWidget::colorModeChanged()
|
|||||||
|
|
||||||
void QgsGradientFillSymbolLayerWidget::applyColorRamp()
|
void QgsGradientFillSymbolLayerWidget::applyColorRamp()
|
||||||
{
|
{
|
||||||
QgsColorRamp* ramp = cboGradientColorRamp->currentColorRamp();
|
if ( btnColorRamp->isNull() )
|
||||||
if ( !ramp )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mLayer->setColorRamp( ramp );
|
mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -314,7 +314,11 @@ class GUI_EXPORT QgsGradientFillSymbolLayerWidget : public QgsSymbolLayerWidget,
|
|||||||
public slots:
|
public slots:
|
||||||
void setColor( const QColor& color );
|
void setColor( const QColor& color );
|
||||||
void setColor2( const QColor& color );
|
void setColor2( const QColor& color );
|
||||||
|
|
||||||
|
/** Applies the color ramp passed on by the color ramp button
|
||||||
|
*/
|
||||||
void applyColorRamp();
|
void applyColorRamp();
|
||||||
|
|
||||||
void setGradientType( int index );
|
void setGradientType( int index );
|
||||||
void setCoordinateMode( int index );
|
void setCoordinateMode( int index );
|
||||||
void setGradientSpread( int index );
|
void setGradientSpread( int index );
|
||||||
|
|||||||
@ -76,32 +76,24 @@
|
|||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QgsColorRampComboBox" name="cboCategorizedColorRamp">
|
<widget class="QgsColorRampButton" name="btnColorRamp">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="mButtonEditRamp">
|
|
||||||
<property name="text">
|
|
||||||
<string>Edit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbxInvertedColorRamp">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="minimumSize">
|
||||||
<string>Invert</string>
|
<size>
|
||||||
|
<width>120</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -223,9 +215,10 @@
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QgsColorRampComboBox</class>
|
<class>QgsColorRampButton</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QToolButton</extends>
|
||||||
<header>qgscolorrampcombobox.h</header>
|
<header>qgscolorrampbutton.h</header>
|
||||||
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
|||||||
@ -331,9 +331,10 @@ suffix</string>
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QgsColorRampComboBox</class>
|
<class>QgsColorRampButton</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QToolButton</extends>
|
||||||
<header>qgscolorrampcombobox.h</header>
|
<header>qgscolorrampbutton.h</header>
|
||||||
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
|
|||||||
@ -152,18 +152,24 @@
|
|||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QgsColorRampComboBox" name="cboGradientColorRamp"/>
|
<widget class="QgsColorRampButton" name="btnColorRamp">
|
||||||
</item>
|
<property name="sizePolicy">
|
||||||
<item>
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<widget class="QPushButton" name="mButtonEditRamp">
|
<horstretch>0</horstretch>
|
||||||
<property name="maximumSize">
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>120</width>
|
||||||
<height>16777215</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="maximumSize">
|
||||||
<string>Edit</string>
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -544,6 +550,12 @@
|
|||||||
<header>qgscolorbutton.h</header>
|
<header>qgscolorbutton.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>QgsColorRampButton</class>
|
||||||
|
<extends>QToolButton</extends>
|
||||||
|
<header>qgscolorrampbutton.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QgsDataDefinedButton</class>
|
<class>QgsDataDefinedButton</class>
|
||||||
<extends>QToolButton</extends>
|
<extends>QToolButton</extends>
|
||||||
@ -560,18 +572,13 @@
|
|||||||
<header>qgsunitselectionwidget.h</header>
|
<header>qgsunitselectionwidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>QgsColorRampComboBox</class>
|
|
||||||
<extends>QComboBox</extends>
|
|
||||||
<header>qgscolorrampcombobox.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>radioTwoColor</tabstop>
|
<tabstop>radioTwoColor</tabstop>
|
||||||
<tabstop>btnChangeColor</tabstop>
|
<tabstop>btnChangeColor</tabstop>
|
||||||
<tabstop>btnChangeColor2</tabstop>
|
<tabstop>btnChangeColor2</tabstop>
|
||||||
<tabstop>radioColorRamp</tabstop>
|
<tabstop>radioColorRamp</tabstop>
|
||||||
<tabstop>cboGradientColorRamp</tabstop>
|
<tabstop>btnColorRamp</tabstop>
|
||||||
<tabstop>mButtonEditRamp</tabstop>
|
<tabstop>mButtonEditRamp</tabstop>
|
||||||
<tabstop>cboGradientType</tabstop>
|
<tabstop>cboGradientType</tabstop>
|
||||||
<tabstop>cboCoordinateMode</tabstop>
|
<tabstop>cboCoordinateMode</tabstop>
|
||||||
@ -623,7 +630,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>radioColorRamp</sender>
|
<sender>radioColorRamp</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>cboGradientColorRamp</receiver>
|
<receiver>btnColorRamp</receiver>
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user