QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsvectorcolorrampv2.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorcolorrampv2.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 
16 #include "qgsvectorcolorrampv2.h"
17 #include "qgscolorbrewerpalette.h"
18 #include "qgscptcityarchive.h"
19 
20 #include "qgssymbollayerv2utils.h"
21 #include "qgsapplication.h"
22 #include "qgslogger.h"
23 
24 #include <stdlib.h> // for random()
25 #include <algorithm>
26 
27 #include <QTime>
28 
30 
31 static QColor _interpolate( QColor c1, QColor c2, double value )
32 {
33  if ( qIsNaN( value ) ) value = 1;
34  int r = ( int )( c1.red() + value * ( c2.red() - c1.red() ) );
35  int g = ( int )( c1.green() + value * ( c2.green() - c1.green() ) );
36  int b = ( int )( c1.blue() + value * ( c2.blue() - c1.blue() ) );
37  int a = ( int )( c1.alpha() + value * ( c2.alpha() - c1.alpha() ) );
38 
39  return QColor::fromRgb( r, g, b, a );
40 }
41 
43 
45  bool discrete, QgsGradientStopsList stops )
46  : mColor1( color1 ), mColor2( color2 ), mDiscrete( discrete ), mStops( stops )
47 {
48 }
49 
51 {
52  // color1 and color2
55  if ( props.contains( "color1" ) )
56  color1 = QgsSymbolLayerV2Utils::decodeColor( props["color1"] );
57  if ( props.contains( "color2" ) )
58  color2 = QgsSymbolLayerV2Utils::decodeColor( props["color2"] );
59 
60  //stops
62  if ( props.contains( "stops" ) )
63  {
64  foreach ( QString stop, props["stops"].split( ':' ) )
65  {
66  int i = stop.indexOf( ';' );
67  if ( i == -1 )
68  continue;
69 
70  QColor c = QgsSymbolLayerV2Utils::decodeColor( stop.mid( i + 1 ) );
71  stops.append( QgsGradientStop( stop.left( i ).toDouble(), c ) );
72  }
73  }
74 
75  // discrete vs. continuous
76  bool discrete = false;
77  if ( props.contains( "discrete" ) )
78  {
79  if ( props["discrete"] == "1" )
80  discrete = true;
81  }
82 
83  // search for information keys starting with "info_"
85  for ( QgsStringMap::const_iterator it = props.constBegin();
86  it != props.constEnd(); ++it )
87  {
88  if ( it.key().startsWith( "info_" ) )
89  info[ it.key().mid( 5 )] = it.value();
90  }
91 
92  QgsVectorGradientColorRampV2* r = new QgsVectorGradientColorRampV2( color1, color2, discrete, stops );
93  r->setInfo( info );
94  return r;
95 }
96 
98 {
99  if ( index <= 0 )
100  {
101  return 0;
102  }
103  else if ( index >= mStops.size() + 1 )
104  {
105  return 1;
106  }
107  else
108  {
109  return mStops[index-1].offset;
110  }
111 }
112 
113 QColor QgsVectorGradientColorRampV2::color( double value ) const
114 {
115  if ( mStops.isEmpty() )
116  {
117  if ( mDiscrete )
118  return mColor1;
119  return _interpolate( mColor1, mColor2, value );
120  }
121  else
122  {
123  double lower = 0, upper = 0;
124  QColor c1 = mColor1, c2;
125  for ( QgsGradientStopsList::const_iterator it = mStops.begin(); it != mStops.end(); ++it )
126  {
127  if ( it->offset > value )
128  {
129  if ( mDiscrete )
130  return c1;
131 
132  upper = it->offset;
133  c2 = it->color;
134 
135  return upper == lower ? c1 : _interpolate( c1, c2, ( value - lower ) / ( upper - lower ) );
136  }
137  lower = it->offset;
138  c1 = it->color;
139  }
140 
141  if ( mDiscrete )
142  return c1;
143 
144  upper = 1;
145  c2 = mColor2;
146  return upper == lower ? c1 : _interpolate( c1, c2, ( value - lower ) / ( upper - lower ) );
147  }
148 }
149 
151 {
153  mDiscrete, mStops );
154  r->setInfo( mInfo );
155  return r;
156 }
157 
159 {
160  QgsStringMap map;
161  map["color1"] = QgsSymbolLayerV2Utils::encodeColor( mColor1 );
162  map["color2"] = QgsSymbolLayerV2Utils::encodeColor( mColor2 );
163  if ( !mStops.isEmpty() )
164  {
165  QStringList lst;
166  for ( QgsGradientStopsList::const_iterator it = mStops.begin(); it != mStops.end(); ++it )
167  {
168  lst.append( QString( "%1;%2" ).arg( it->offset ).arg( QgsSymbolLayerV2Utils::encodeColor( it->color ) ) );
169  }
170  map["stops"] = lst.join( ":" );
171  }
172 
173  map["discrete"] = mDiscrete ? "1" : "0";
174 
175  for ( QgsStringMap::const_iterator it = mInfo.constBegin();
176  it != mInfo.constEnd(); ++it )
177  {
178  map["info_" + it.key()] = it.value();
179  }
180 
181  return map;
182 }
184 {
185  if ( discrete == mDiscrete )
186  return;
187 
188  // if going to/from Discrete, re-arrange stops
189  // this will only work when stops are equally-spaced
190  QgsGradientStopsList newStops;
191  if ( discrete )
192  {
193  // re-arrange stops offset
194  int numStops = mStops.count() + 2;
195  int i = 1;
196  for ( QgsGradientStopsList::const_iterator it = mStops.begin();
197  it != mStops.end(); ++it )
198  {
199  newStops.append( QgsGradientStop(( double ) i / numStops, it->color ) );
200  if ( i == numStops - 1 )
201  break;
202  i++;
203  }
204  // replicate last color
205  newStops.append( QgsGradientStop(( double ) i / numStops, mColor2 ) );
206  }
207  else
208  {
209  // re-arrange stops offset, remove duplicate last color
210  int numStops = mStops.count() + 2;
211  int i = 1;
212  for ( QgsGradientStopsList::const_iterator it = mStops.begin();
213  it != mStops.end(); ++it )
214  {
215  newStops.append( QgsGradientStop(( double ) i / ( numStops - 2 ), it->color ) );
216  if ( i == numStops - 3 )
217  break;
218  i++;
219  }
220  }
221  mStops = newStops;
222  mDiscrete = discrete;
223 }
224 
225 void QgsVectorGradientColorRampV2::addStopsToGradient( QGradient* gradient, double alpha )
226 {
227  //copy color ramp stops to a QGradient
228  QColor color1 = mColor1;
229  QColor color2 = mColor2;
230  if ( alpha < 1 )
231  {
232  color1.setAlpha( color1.alpha() * alpha );
233  color2.setAlpha( color2.alpha() * alpha );
234  }
235  gradient->setColorAt( 0, color1 );
236  gradient->setColorAt( 1, color2 );
237 
238  for ( QgsGradientStopsList::const_iterator it = mStops.begin();
239  it != mStops.end(); ++it )
240  {
241  QColor rampColor = it->color;
242  if ( alpha < 1 )
243  {
244  rampColor.setAlpha( rampColor.alpha() * alpha );
245  }
246  gradient->setColorAt( it->offset, rampColor );
247  }
248 }
249 
250 
252 
253 
255  int satMin, int satMax, int valMin, int valMax )
256  : mCount( count ), mHueMin( hueMin ), mHueMax( hueMax ),
257  mSatMin( satMin ), mSatMax( satMax ), mValMin( valMin ), mValMax( valMax )
258 {
259  updateColors();
260 }
261 
263 {
268 
269  if ( props.contains( "count" ) ) count = props["count"].toInt();
270  if ( props.contains( "hueMin" ) ) hueMin = props["hueMin"].toInt();
271  if ( props.contains( "hueMax" ) ) hueMax = props["hueMax"].toInt();
272  if ( props.contains( "satMin" ) ) satMin = props["satMin"].toInt();
273  if ( props.contains( "satMax" ) ) satMax = props["satMax"].toInt();
274  if ( props.contains( "valMin" ) ) valMin = props["valMin"].toInt();
275  if ( props.contains( "valMax" ) ) valMax = props["valMax"].toInt();
276 
277  return new QgsVectorRandomColorRampV2( count, hueMin, hueMax, satMin, satMax, valMin, valMax );
278 }
279 
281 {
282  if ( mColors.size() < 1 ) return 0;
283  return index / mColors.size() - 1;
284 }
285 
286 QColor QgsVectorRandomColorRampV2::color( double value ) const
287 {
288  int colorCnt = mColors.count();
289  int colorIdx = ( int )( value * colorCnt );
290 
291  if ( colorIdx >= 0 && colorIdx < colorCnt )
292  return mColors.at( colorIdx );
293 
294  return QColor();
295 }
296 
298 {
300 }
301 
303 {
304  QgsStringMap map;
305  map["count"] = QString::number( mCount );
306  map["hueMin"] = QString::number( mHueMin );
307  map["hueMax"] = QString::number( mHueMax );
308  map["satMin"] = QString::number( mSatMin );
309  map["satMax"] = QString::number( mSatMax );
310  map["valMin"] = QString::number( mValMin );
311  map["valMax"] = QString::number( mValMax );
312  return map;
313 }
314 
316  int hueMax, int hueMin, int satMax, int satMin, int valMax, int valMin )
317 {
318  int h, s, v;
319  QList<QColor> colors;
320 
321  //start hue at random angle
322  double currentHueAngle = 360.0 * ( double )rand() / RAND_MAX;
323 
324  for ( int i = 0; i < count; i++ )
325  {
326  //increment hue by golden ratio (approx 137.507 degrees)
327  //as this minimises hue nearness as count increases
328  //see http://basecase.org/env/on-rainbows for more details
329  currentHueAngle += 137.50776;
330  //scale hue to between hueMax and hueMin
331  h = ( fmod( currentHueAngle, 360.0 ) / 360.0 ) * ( hueMax - hueMin ) + hueMin;
332  s = ( rand() % ( satMax - satMin + 1 ) ) + satMin;
333  v = ( rand() % ( valMax - valMin + 1 ) ) + valMin;
334  colors.append( QColor::fromHsv( h, s, v ) );
335  }
336  return colors;
337 }
338 
340 {
342 }
343 
345 
347 {
348  srand( QTime::currentTime().msec() );
349 }
350 
352 {
353 
354 }
355 
357 {
358  return INT_MAX;
359 }
360 
361 double QgsRandomColorsV2::value( int index ) const
362 {
363  Q_UNUSED( index );
364  return 0.0;
365 }
366 
367 QColor QgsRandomColorsV2::color( double value ) const
368 {
369  int minVal = 130;
370  int maxVal = 255;
371 
372  //if value is nan, then use last precalculated color
373  int colorIndex = ( !qIsNaN( value ) ? value : 1 ) * ( mTotalColorCount - 1 );
374  if ( mTotalColorCount >= 1 && mPrecalculatedColors.length() > colorIndex )
375  {
376  //use precalculated hue
377  return mPrecalculatedColors.at( colorIndex );
378  }
379 
380  //can't use precalculated hues, use a totally random hue
381  int h = 1 + ( int )( 360.0 * rand() / ( RAND_MAX + 1.0 ) );
383  int v = ( rand() % ( maxVal - minVal + 1 ) ) + minVal;
384  return QColor::fromHsv( h, s, v );
385 }
386 
387 void QgsRandomColorsV2::setTotalColorCount( const int colorCount )
388 {
389  //calculate colors in advance, so that we can ensure they are more visually distinct than pure random colors
390  mPrecalculatedColors.clear();
391  mTotalColorCount = colorCount;
392 
393  //This works ok for low color counts, but for > 10 or so colors there's still a good chance of
394  //similar colors being picked. TODO - investigate alternative "n-visually distinct color" routines
395 
396  //random offsets
397  double hueOffset = ( 360.0 * rand() / ( RAND_MAX + 1.0 ) );
398 
399  //try to maximise difference between hues. this is not an ideal implementation, as constant steps
400  //through the hue wheel are not visually perceived as constant changes in hue
401  //(for instance, we are much more likely to get green hues than yellow hues)
402  double hueStep = 359.0 / colorCount;
403  double currentHue = hueOffset;
404 
405  //build up a list of colors
406  for ( int idx = 0; idx < colorCount; ++ idx )
407  {
408  int h = qRound( currentHue ) % 360;
411  mPrecalculatedColors << QColor::fromHsv( h, s, v );
412  currentHue += hueStep;
413  }
414 
415  //lastly, shuffle color list
416  std::random_shuffle( mPrecalculatedColors.begin(), mPrecalculatedColors.end() );
417 }
418 
419 QString QgsRandomColorsV2::type() const
420 {
421  return "randomcolors";
422 }
423 
425 {
426  return new QgsRandomColorsV2();
427 }
428 
430 {
431  return QgsStringMap();
432 }
433 
435 
437  : mSchemeName( schemeName ), mColors( colors )
438 {
439  loadPalette();
440 }
441 
443 {
446 
447  if ( props.contains( "schemeName" ) )
448  schemeName = props["schemeName"];
449  if ( props.contains( "colors" ) )
450  colors = props["colors"].toInt();
451 
452  return new QgsVectorColorBrewerColorRampV2( schemeName, colors );
453 }
454 
456 {
458 }
459 
461 {
463 }
464 
466 {
467  return QgsColorBrewerPalette::listSchemeVariants( schemeName );
468 }
469 
471 {
472  if ( mPalette.size() < 1 ) return 0;
473  return index / mPalette.size() - 1;
474 }
475 
476 QColor QgsVectorColorBrewerColorRampV2::color( double value ) const
477 {
478  if ( mPalette.isEmpty() || value < 0 || value > 1 )
479  return QColor( 255, 0, 0 ); // red color as a warning :)
480 
481  int paletteEntry = ( int )( value * mPalette.count() );
482  if ( paletteEntry >= mPalette.count() )
483  paletteEntry = mPalette.count() - 1;
484  return mPalette.at( paletteEntry );
485 }
486 
488 {
490 }
491 
493 {
494  QgsStringMap map;
495  map["schemeName"] = mSchemeName;
496  map["colors"] = QString::number( mColors );
497  return map;
498 }
499 
500 
502 
503 
504 QgsCptCityColorRampV2::QgsCptCityColorRampV2( QString schemeName, QString variantName,
505  bool doLoadFile )
507  mSchemeName( schemeName ), mVariantName( variantName ),
508  mVariantList( QStringList() ), mFileLoaded( false ), mMultiStops( false )
509 {
510  // TODO replace this with hard-coded data in the default case
511  // don't load file if variant is missing
512  if ( doLoadFile && ( variantName != QString() || mVariantList.isEmpty() ) )
513  loadFile();
514 }
515 
516 QgsCptCityColorRampV2::QgsCptCityColorRampV2( QString schemeName, QStringList variantList,
517  QString variantName, bool doLoadFile )
519  mSchemeName( schemeName ), mVariantName( variantName ),
520  mVariantList( variantList ), mFileLoaded( false ), mMultiStops( false )
521 {
523 
524  // TODO replace this with hard-coded data in the default case
525  // don't load file if variant is missing
526  if ( doLoadFile && ( variantName != QString() || mVariantList.isEmpty() ) )
527  loadFile();
528 }
529 
531 {
534 
535  if ( props.contains( "schemeName" ) )
536  schemeName = props["schemeName"];
537  if ( props.contains( "variantName" ) )
538  variantName = props["variantName"];
539 
540  return new QgsCptCityColorRampV2( schemeName, variantName );
541 }
542 
544 {
545  QgsCptCityColorRampV2* ramp = new QgsCptCityColorRampV2( "", "", false );
546  ramp->copy( this );
547  return ramp;
548 }
549 
551 {
552  if ( ! other )
553  return;
554  mColor1 = other->color1();
555  mColor2 = other->color2();
556  mDiscrete = other->isDiscrete();
557  mStops = other->stops();
558  mSchemeName = other->mSchemeName;
559  mVariantName = other->mVariantName;
560  mVariantList = other->mVariantList;
561  mFileLoaded = other->mFileLoaded;
562 }
563 
565 {
568  // add author and copyright information
569  // TODO also add COPYING.xml file/link?
571  info["cpt-city-gradient"] = "<cpt-city>/" + mSchemeName + mVariantName + ".svg";
572  QString copyingFilename = copyingFileName();
573  copyingFilename.remove( QgsCptCityArchive::defaultBaseDir() );
574  info["cpt-city-license"] = "<cpt-city>" + copyingFilename;
575  ramp->setInfo( info );
576  return ramp;
577 }
578 
579 
581 {
582  QgsStringMap map;
583  map["schemeName"] = mSchemeName;
584  map["variantName"] = mVariantName;
585  return map;
586 }
587 
588 
590 {
591  if ( mSchemeName == "" )
592  return QString();
593  else
594  {
595  return QgsCptCityArchive::defaultBaseDir() + QDir::separator() + mSchemeName + mVariantName + ".svg";
596  }
597 }
598 
600 {
601  return QgsCptCityArchive::findFileName( "COPYING.xml", QFileInfo( fileName() ).dir().path(),
603 }
604 
606 {
607  return QgsCptCityArchive::findFileName( "DESC.xml", QFileInfo( fileName() ).dir().path(),
609 }
610 
612 {
614 }
615 
617 {
618  if ( mFileLoaded )
619  {
620  QgsDebugMsg( "File already loaded for " + mSchemeName + mVariantName );
621  return true;
622  }
623 
624  // get filename
625  QString filename = fileName();
626  if ( filename.isNull() )
627  {
628  QgsDebugMsg( "Couldn't get fileName() for " + mSchemeName + mVariantName );
629  return false;
630  }
631 
632  QgsDebugMsg( QString( "filename= %1 loaded=%2" ).arg( filename ).arg( mFileLoaded ) );
633 
634  // get color ramp from svg file
635  QMap< double, QPair<QColor, QColor> > colorMap =
637 
638  // add colors to palette
639  mFileLoaded = false;
640  mStops.clear();
641  QMap<double, QPair<QColor, QColor> >::const_iterator it, prev;
642  // first detect if file is gradient is continuous or dicrete
643  // discrete: stop contains 2 colors and first color is identical to previous second
644  // multi: stop contains 2 colors and no relation with previous stop
645  mDiscrete = false;
646  mMultiStops = false;
647  it = prev = colorMap.constBegin();
648  while ( it != colorMap.constEnd() )
649  {
650  // look for stops that contain multiple values
651  if ( it != colorMap.constBegin() && ( it.value().first != it.value().second ) )
652  {
653  if ( it.value().first == prev.value().second )
654  {
655  mDiscrete = true;
656  break;
657  }
658  else
659  {
660  mMultiStops = true;
661  break;
662  }
663  }
664  prev = it;
665  ++it;
666  }
667 
668  // fill all stops
669  it = prev = colorMap.constBegin();
670  while ( it != colorMap.constEnd() )
671  {
672  if ( mDiscrete )
673  {
674  // mPalette << qMakePair( it.key(), it.value().second );
675  mStops.append( QgsGradientStop( it.key(), it.value().second ) );
676  }
677  else
678  {
679  // mPalette << qMakePair( it.key(), it.value().first );
680  mStops.append( QgsGradientStop( it.key(), it.value().first ) );
681  if (( mMultiStops ) &&
682  ( it.key() != 0.0 && it.key() != 1.0 ) )
683  {
684  mStops.append( QgsGradientStop( it.key(), it.value().second ) );
685  }
686  }
687  prev = it;
688  ++it;
689  }
690 
691  // remove first and last items (mColor1 and mColor2)
692  if ( ! mStops.isEmpty() && mStops.first().offset == 0.0 )
693  mColor1 = mStops.takeFirst().color;
694  if ( ! mStops.isEmpty() && mStops.last().offset == 1.0 )
695  mColor2 = mStops.takeLast().color;
696 
697  mFileLoaded = true;
698  return true;
699 }
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
static unsigned index
#define DEFAULT_CPTCITY_VARIANTNAME
double value(int index) const
QgsVectorGradientColorRampV2(QColor color1=DEFAULT_GRADIENT_COLOR1, QColor color2=DEFAULT_GRADIENT_COLOR2, bool discrete=false, QgsGradientStopsList stops=QgsGradientStopsList())
void copy(const QgsCptCityColorRampV2 *other)
static QList< int > listSchemeVariants(QString schemeName)
QgsVectorColorRampV2 * clone() const
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
static QString defaultBaseDir()
#define DEFAULT_COLORBREWER_SCHEMENAME
#define DEFAULT_RANDOM_HUE_MIN
static QColor _interpolate(QColor c1, QColor c2, double value)
void setInfo(const QgsStringMap &info)
static QList< int > listSchemeVariants(QString schemeName)
virtual void setTotalColorCount(const int colorCount)
static QColor decodeColor(QString str)
#define DEFAULT_CPTCITY_SCHEMENAME
QMap< QString, QString > QgsStringMap
Definition: qgis.h:412
#define DEFAULT_RANDOM_SAT_MAX
static QString encodeColor(QColor color)
virtual QgsStringMap properties() const
virtual QgsStringMap properties() const
QString variantName() const
virtual QColor color(double value) const
QStringList variantList() const
#define DEFAULT_GRADIENT_COLOR2
static QList< QColor > listSchemeColors(QString schemeName, int colors)
QgsVectorRandomColorRampV2(int count=DEFAULT_RANDOM_COUNT, int hueMin=DEFAULT_RANDOM_HUE_MIN, int hueMax=DEFAULT_RANDOM_HUE_MAX, int satMin=DEFAULT_RANDOM_SAT_MIN, int satMax=DEFAULT_RANDOM_SAT_MAX, int valMin=DEFAULT_RANDOM_VAL_MIN, int valMax=DEFAULT_RANDOM_VAL_MAX)
QColor color(double value) const
#define DEFAULT_GRADIENT_COLOR1
#define DEFAULT_RANDOM_VAL_MAX
QgsStringMap copyingInfo() const
virtual double value(int index) const
static QMap< QString, QString > copyingInfo(const QString &fileName)
static QList< QColor > randomColors(int count, int hueMax=DEFAULT_RANDOM_HUE_MAX, int hueMin=DEFAULT_RANDOM_HUE_MIN, int satMax=DEFAULT_RANDOM_SAT_MAX, int satMin=DEFAULT_RANDOM_SAT_MIN, int valMax=DEFAULT_RANDOM_VAL_MAX, int valMin=DEFAULT_RANDOM_VAL_MIN)
get a list of random colors
virtual QgsStringMap properties() const
virtual double value(int index) const
virtual QgsStringMap properties() const
#define DEFAULT_RANDOM_SAT_MIN
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
virtual QColor color(double value) const
virtual QgsVectorColorRampV2 * clone() const
QgsVectorGradientColorRampV2 * cloneGradientRamp() const
int ANALYSIS_EXPORT lower(int n, int i)
lower function
QList< QgsGradientStop > QgsGradientStopsList
virtual double value(int index) const
#define DEFAULT_COLORBREWER_COLORS
static QStringList listSchemes()
const QgsGradientStopsList & stops() const
virtual QgsVectorColorRampV2 * clone() const
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
QList< QColor > mPrecalculatedColors
#define DEFAULT_RANDOM_HUE_MAX
virtual QgsVectorColorRampV2 * clone() const
QgsCptCityColorRampV2(QString schemeName=DEFAULT_CPTCITY_SCHEMENAME, QString variantName=DEFAULT_CPTCITY_VARIANTNAME, bool doLoadFile=true)
QgsStringMap properties() const
static QMap< double, QPair< QColor, QColor > > gradientColorMap(const QString &fileName)
note not available in python bindings
QgsVectorColorBrewerColorRampV2(QString schemeName=DEFAULT_COLORBREWER_SCHEMENAME, int colors=DEFAULT_COLORBREWER_COLORS)
virtual QColor color(double value) const
#define DEFAULT_RANDOM_VAL_MIN
void addStopsToGradient(QGradient *gradient, double alpha=1)
copy color ramp stops to a QGradient
QString copyingFileName() const
#define DEFAULT_RANDOM_COUNT
static QString findFileName(const QString &target, const QString &startDir, const QString &baseDir)
virtual QgsVectorColorRampV2 * clone() const