-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for ColorBrewer palettes - available as a new type of c…
…olor ramps. git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@12121 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
wonder
committed
Nov 15, 2009
1 parent
1ac22c1
commit f3c8e3f
Showing
10 changed files
with
736 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/gui/symbology-ng/qgsvectorcolorbrewercolorrampv2dialog.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
|
||
#include "qgsvectorcolorbrewercolorrampv2dialog.h" | ||
|
||
#include "qgsvectorcolorrampv2.h" | ||
|
||
#include <QAbstractButton> | ||
|
||
static void updateColorButton(QAbstractButton* button, QColor color) | ||
{ | ||
QPixmap p(20,20); | ||
p.fill(color); | ||
button->setIcon(QIcon(p)); | ||
} | ||
|
||
///////// | ||
|
||
|
||
QgsVectorColorBrewerColorRampV2Dialog::QgsVectorColorBrewerColorRampV2Dialog(QgsVectorColorBrewerColorRampV2* ramp, QWidget* parent) | ||
: QDialog(parent), mRamp(ramp) | ||
{ | ||
|
||
setupUi(this); | ||
|
||
QSize iconSize(50,16); | ||
cboSchemeName->setIconSize(iconSize); | ||
|
||
QStringList schemes = QgsVectorColorBrewerColorRampV2::listSchemeNames(); | ||
foreach (QString schemeName, schemes) | ||
{ | ||
// create a preview icon using five color variant | ||
QgsVectorColorBrewerColorRampV2* r = new QgsVectorColorBrewerColorRampV2(schemeName, 5); | ||
QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon(r, iconSize); | ||
delete r; | ||
cboSchemeName->addItem(icon, schemeName); | ||
} | ||
|
||
cboSchemeName->setCurrentIndex(cboSchemeName->findText(ramp->schemeName())); | ||
populateVariants(); | ||
cboColors->setCurrentIndex(cboColors->findText(QString::number(ramp->colors()))); | ||
|
||
connect(cboSchemeName, SIGNAL(currentIndexChanged(int)), this, SLOT(setSchemeName())); | ||
connect(cboColors, SIGNAL(currentIndexChanged(int)), this, SLOT(setColors())); | ||
|
||
updatePreview(); | ||
} | ||
|
||
void QgsVectorColorBrewerColorRampV2Dialog::populateVariants() | ||
{ | ||
QString oldVariant = cboColors->currentText(); | ||
|
||
cboColors->clear(); | ||
QString schemeName = cboSchemeName->currentText(); | ||
QList<int> variants = QgsVectorColorBrewerColorRampV2::listSchemeVariants(schemeName); | ||
foreach (int variant, variants) | ||
{ | ||
cboColors->addItem(QString::number(variant)); | ||
} | ||
|
||
// try to set the original variant again (if exists) | ||
cboColors->setCurrentIndex(cboColors->findText(oldVariant)); | ||
} | ||
|
||
void QgsVectorColorBrewerColorRampV2Dialog::updatePreview() | ||
{ | ||
QSize size(300,40); | ||
lblPreview->setPixmap(QgsSymbolLayerV2Utils::colorRampPreviewPixmap(mRamp, size)); | ||
} | ||
|
||
void QgsVectorColorBrewerColorRampV2Dialog::setSchemeName() | ||
{ | ||
// populate list of variants | ||
populateVariants(); | ||
|
||
mRamp->setSchemeName(cboSchemeName->currentText()); | ||
updatePreview(); | ||
} | ||
|
||
void QgsVectorColorBrewerColorRampV2Dialog::setColors() | ||
{ | ||
int num = cboColors->currentText().toInt(); | ||
mRamp->setColors(num); | ||
updatePreview(); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/gui/symbology-ng/qgsvectorcolorbrewercolorrampv2dialog.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
#ifndef QGSVECTORCOLORBREWERCOLORRAMPV2DIALOG_H | ||
#define QGSVECTORCOLORBREWERCOLORRAMPV2DIALOG_H | ||
|
||
#include <QDialog> | ||
|
||
#include "ui_qgsvectorcolorbrewercolorrampv2dialogbase.h" | ||
|
||
class QgsVectorColorBrewerColorRampV2; | ||
|
||
class QgsVectorColorBrewerColorRampV2Dialog : public QDialog, private Ui::QgsVectorColorBrewerColorRampV2DialogBase | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsVectorColorBrewerColorRampV2Dialog(QgsVectorColorBrewerColorRampV2* ramp, QWidget* parent = NULL); | ||
|
||
public slots: | ||
void setSchemeName(); | ||
void setColors(); | ||
|
||
void populateVariants(); | ||
|
||
protected: | ||
|
||
void updatePreview(); | ||
|
||
QgsVectorColorBrewerColorRampV2* mRamp; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.