QGIS API Documentation  2.17.0-Master (3a3b9ab7)
qgsvectorrandomcolorrampv2dialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorrandomcolorrampv2dialog.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 
18 #include "qgsvectorcolorrampv2.h"
19 
20 #include <QColorDialog>
21 
22 
24  : QDialog( parent )
25  , mRamp( ramp )
26 {
27  setupUi( this );
28 
29  spinCount->setValue( ramp->count() );
30  spinHue1->setValue( ramp->hueMin() );
31  spinHue2->setValue( ramp->hueMax() );
32  spinSat1->setValue( ramp->satMin() );
33  spinSat2->setValue( ramp->satMax() );
34  spinVal1->setValue( ramp->valMin() );
35  spinVal2->setValue( ramp->valMax() );
36 
37  connect( spinCount, SIGNAL( valueChanged( int ) ), this, SLOT( setCount( int ) ) );
38  connect( spinHue1, SIGNAL( valueChanged( int ) ), this, SLOT( setHue1( int ) ) );
39  connect( spinHue2, SIGNAL( valueChanged( int ) ), this, SLOT( setHue2( int ) ) );
40  connect( spinSat1, SIGNAL( valueChanged( int ) ), this, SLOT( setSat1( int ) ) );
41  connect( spinSat2, SIGNAL( valueChanged( int ) ), this, SLOT( setSat2( int ) ) );
42  connect( spinVal1, SIGNAL( valueChanged( int ) ), this, SLOT( setVal1( int ) ) );
43  connect( spinVal2, SIGNAL( valueChanged( int ) ), this, SLOT( setVal2( int ) ) );
44 
45  updatePreview();
46 }
47 
49 {
51 
52  QSize size( 300, 40 );
53  lblPreview->setPixmap( QgsSymbolLayerV2Utils::colorRampPreviewPixmap( mRamp, size ) );
54 }
55 
57 {
58  mRamp->setCount( val );
59  updatePreview();
60 }
61 
63 {
64  mRamp->setHueMin( val );
65  updatePreview();
66 }
67 
69 {
70  mRamp->setHueMax( val );
71  updatePreview();
72 }
73 
75 {
76  mRamp->setSatMin( val );
77  updatePreview();
78 }
79 
81 {
82  mRamp->setSatMax( val );
83  updatePreview();
84 }
85 
87 {
88  mRamp->setValMin( val );
89  updatePreview();
90 }
91 
93 {
94  mRamp->setValMax( val );
95  updatePreview();
96 }
QgsVectorRandomColorRampV2Dialog(QgsVectorRandomColorRampV2 *ramp, QWidget *parent=nullptr)
int count() const override
Returns number of defined colors, or -1 if undefined.
void setupUi(QWidget *widget)
static QPixmap colorRampPreviewPixmap(QgsVectorColorRampV2 *ramp, QSize size)
QSize size() const
Random color ramp, which returns random colors based on preset parameters.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)