2323/* * \ingroup core
2424 * \class QgsColorRamp
2525 * \brief Abstract base class for color ramps
26+ * \note added in QGIS 3.0
2627 */
2728class CORE_EXPORT QgsColorRamp
2829{
@@ -60,6 +61,7 @@ class CORE_EXPORT QgsColorRamp
6061/* * \ingroup core
6162 * \class QgsGradientStop
6263 * \brief Represents a color stop within a QgsGradientColorRamp color ramp.
64+ * \note added in QGIS 3.0
6365 */
6466class CORE_EXPORT QgsGradientStop
6567{
@@ -95,6 +97,7 @@ typedef QList<QgsGradientStop> QgsGradientStopsList;
9597 * \class QgsGradientColorRamp
9698 * \brief Gradient color ramp, which smoothly interpolates between two colors and also
9799 * supports optional extra color stops.
100+ * \note added in QGIS 3.0
98101 */
99102class CORE_EXPORT QgsGradientColorRamp : public QgsColorRamp
100103{
@@ -108,9 +111,9 @@ class CORE_EXPORT QgsGradientColorRamp : public QgsColorRamp
108111 * @param stops optional list of additional color stops
109112 */
110113 QgsGradientColorRamp ( const QColor& color1 = DEFAULT_GRADIENT_COLOR1 ,
111- const QColor& color2 = DEFAULT_GRADIENT_COLOR2 ,
112- bool discrete = false ,
113- const QgsGradientStopsList& stops = QgsGradientStopsList () );
114+ const QColor& color2 = DEFAULT_GRADIENT_COLOR2 ,
115+ bool discrete = false ,
116+ const QgsGradientStopsList& stops = QgsGradientStopsList () );
114117
115118 // ! Creates a new QgsColorRamp from a map of properties
116119 static QgsColorRamp* create ( const QgsStringMap& properties = QgsStringMap () );
@@ -221,26 +224,39 @@ class CORE_EXPORT QgsGradientColorRamp : public QgsColorRamp
221224/* * \ingroup core
222225 * \class QgsLimitedRandomColorRamp
223226 * \brief Constrained random color ramp, which returns random colors based on preset parameters.
227+ * \note added in QGIS 3.0
224228 */
225229class CORE_EXPORT QgsLimitedRandomColorRamp : public QgsColorRamp
226230{
227231 public:
228- QgsLimitedRandomColorRamp ( int count = DEFAULT_RANDOM_COUNT ,
229- int hueMin = DEFAULT_RANDOM_HUE_MIN , int hueMax = DEFAULT_RANDOM_HUE_MAX ,
230- int satMin = DEFAULT_RANDOM_SAT_MIN , int satMax = DEFAULT_RANDOM_SAT_MAX ,
231- int valMin = DEFAULT_RANDOM_VAL_MIN , int valMax = DEFAULT_RANDOM_VAL_MAX );
232232
233+ /* * Constructor for QgsLimitedRandomColorRamp
234+ * @param count number of colors in ramp
235+ * @param hueMin minimum hue
236+ * @param hueMax maximum hue
237+ * @param satMin minimum saturation
238+ * @param satMax maximum saturation
239+ * @param valMin minimum color value
240+ * @param valMax maximum color value
241+ */
242+ QgsLimitedRandomColorRamp ( int count = DEFAULT_RANDOM_COUNT ,
243+ int hueMin = DEFAULT_RANDOM_HUE_MIN , int hueMax = DEFAULT_RANDOM_HUE_MAX ,
244+ int satMin = DEFAULT_RANDOM_SAT_MIN , int satMax = DEFAULT_RANDOM_SAT_MAX ,
245+ int valMin = DEFAULT_RANDOM_VAL_MIN , int valMax = DEFAULT_RANDOM_VAL_MAX );
246+
247+ /* * Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string
248+ * map.
249+ * @param properties color ramp properties
250+ * @see properties()
251+ */
233252 static QgsColorRamp* create ( const QgsStringMap& properties = QgsStringMap() );
234253
235254 virtual double value ( int index ) const override ;
236-
237255 virtual QColor color ( double value ) const override ;
238-
239256 virtual QString type () const override { return " random" ; }
240-
241257 virtual QgsLimitedRandomColorRamp* clone () const override ;
242-
243258 virtual QgsStringMap properties () const override ;
259+ int count () const override { return mCount ; }
244260
245261 /* * Get a list of random colors
246262 * @note added in 2.4
@@ -250,22 +266,73 @@ class CORE_EXPORT QgsLimitedRandomColorRamp : public QgsColorRamp
250266 int satMax = DEFAULT_RANDOM_SAT_MAX , int satMin = DEFAULT_RANDOM_SAT_MIN ,
251267 int valMax = DEFAULT_RANDOM_VAL_MAX , int valMin = DEFAULT_RANDOM_VAL_MIN );
252268
269+ /* * Must be called after changing the properties of the color ramp
270+ * to regenerate the list of random colors.
271+ */
253272 void updateColors ();
254273
255- int count () const override { return mCount ; }
274+ /* * Returns the minimum hue for generated colors
275+ * @see setHueMin()
276+ */
256277 int hueMin () const { return mHueMin ; }
278+
279+ /* * Returns the maximum hue for generated colors
280+ * @see setHueMax()
281+ */
257282 int hueMax () const { return mHueMax ; }
283+
284+ /* * Returns the minimum saturation for generated colors
285+ * @see setSatMin()
286+ */
258287 int satMin () const { return mSatMin ; }
288+
289+ /* * Returns the maximum saturation for generated colors
290+ * @see setSatMax()
291+ */
259292 int satMax () const { return mSatMax ; }
293+
294+ /* * Returns the minimum value for generated colors
295+ * @see setValMin()
296+ */
260297 int valMin () const { return mValMin ; }
298+
299+ /* * Returns the maximum value for generated colors
300+ * @see setValMax()
301+ */
261302 int valMax () const { return mValMax ; }
262303
304+ /* * Sets the number of colors contained in the ramp.
305+ */
263306 void setCount ( int val ) { mCount = val; }
307+
308+ /* * Sets the minimum hue for generated colors
309+ * @see hueMin()
310+ */
264311 void setHueMin ( int val ) { mHueMin = val; }
312+
313+ /* * Sets the maximum hue for generated colors
314+ * @see hueMax()
315+ */
265316 void setHueMax ( int val ) { mHueMax = val; }
317+
318+ /* * Sets the minimum saturation for generated colors
319+ * @see satMin()
320+ */
266321 void setSatMin ( int val ) { mSatMin = val; }
322+
323+ /* * Sets the maximum saturation for generated colors
324+ * @see satMax()
325+ */
267326 void setSatMax ( int val ) { mSatMax = val; }
327+
328+ /* * Sets the minimum value for generated colors
329+ * @see valMin()
330+ */
268331 void setValMin ( int val ) { mValMin = val; }
332+
333+ /* * Sets the maximum value for generated colors
334+ * @see valMax()
335+ */
269336 void setValMax ( int val ) { mValMax = val; }
270337
271338 protected:
@@ -276,6 +343,9 @@ class CORE_EXPORT QgsLimitedRandomColorRamp : public QgsColorRamp
276343
277344/* * \ingroup core
278345 * \class QgsRandomColorRamp
346+ * \brief Totally random color ramp. Returns colors generated at random, but constrained
347+ * to some hardcoded saturation and value ranges to prevent ugly color generation.
348+ * \note added in QGIS 3.0
279349 */
280350class CORE_EXPORT QgsRandomColorRamp: public QgsColorRamp
281351{
@@ -316,37 +386,73 @@ class CORE_EXPORT QgsRandomColorRamp: public QgsColorRamp
316386
317387/* * \ingroup core
318388 * \class QgsColorBrewerColorRamp
389+ * \brief Color ramp utilising "Color Brewer" preset color schemes.
390+ * \note added in QGIS 3.0
319391 */
320392class CORE_EXPORT QgsColorBrewerColorRamp : public QgsColorRamp
321393{
322394 public:
395+
396+ /* * Constructor for QgsColorBrewerColorRamp
397+ * @param schemeName color brewer scheme name
398+ * @param colors number of colors in ramp
399+ */
323400 QgsColorBrewerColorRamp ( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME ,
324- int colors = DEFAULT_COLORBREWER_COLORS );
401+ int colors = DEFAULT_COLORBREWER_COLORS );
325402
403+ /* * Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string
404+ * map.
405+ * @param properties color ramp properties
406+ * @see properties()
407+ */
326408 static QgsColorRamp* create ( const QgsStringMap& properties = QgsStringMap() );
327409
328410 virtual double value ( int index ) const override ;
329-
330411 virtual QColor color ( double value ) const override ;
331-
332412 virtual QString type () const override { return " colorbrewer" ; }
333-
334413 virtual QgsColorBrewerColorRamp* clone () const override ;
335-
336414 virtual QgsStringMap properties () const override ;
415+ virtual int count () const override { return mColors ; }
337416
417+ /* * Returns the name of the color brewer color scheme.
418+ * @see setSchemeName()
419+ */
338420 QString schemeName () const { return mSchemeName ; }
339- virtual int count () const override { return mColors ; }
421+
422+ /* * Returns the number of colors in the ramp.
423+ * @see setColors()
424+ */
340425 int colors () const { return mColors ; }
341426
427+ /* * Sets the name of the color brewer color scheme.
428+ * @param schemeName scheme name, must match a valid color brewer scheme name
429+ * @see schemeName()
430+ * @see listSchemeNames()
431+ */
342432 void setSchemeName ( const QString& schemeName ) { mSchemeName = schemeName; loadPalette (); }
433+
434+ /* * Sets the number of colors in the ramp.
435+ * @param colors number of colors. Must match a valid value for the scheme,
436+ * which can be retrieved using listSchemeVariants()
437+ * @see colors()
438+ */
343439 void setColors ( int colors ) { mColors = colors; loadPalette (); }
344440
441+ /* * Returns a list of all valid color brewer scheme names.
442+ * @see listSchemeVariants()
443+ */
345444 static QStringList listSchemeNames ();
445+
446+ /* * Returns a list of the valid variants (numbers of colors) for a specified
447+ * color brewer scheme name
448+ * @param schemeName color brewer scheme name
449+ * @see listSchemeNames()
450+ */
346451 static QList<int > listSchemeVariants ( const QString& schemeName );
347452
348453 protected:
349454
455+ // ! Generates the scheme using the current name and number of colors
350456 void loadPalette ();
351457
352458 QString mSchemeName ;
0 commit comments