Skip to content

Commit 5ac5035

Browse files
committed
Indentation and docs
1 parent b225a82 commit 5ac5035

4 files changed

Lines changed: 172 additions & 20 deletions

File tree

src/core/qgscolorramp.h

Lines changed: 124 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/** \ingroup core
2424
* \class QgsColorRamp
2525
* \brief Abstract base class for color ramps
26+
* \note added in QGIS 3.0
2627
*/
2728
class 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
*/
6466
class 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
*/
99102
class 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
*/
225229
class 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
*/
280350
class 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
*/
320392
class 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;

src/core/symbology-ng/qgsfillsymbollayer.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,19 @@ class CORE_EXPORT QgsGradientFillSymbolLayer : public QgsFillSymbolLayer
238238
GradientColorType gradientColorType() const { return mGradientColorType; }
239239
void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
240240

241-
/** Color ramp used for the gradient fill, only used if the gradient color type is set to ColorRamp*/
241+
/** Returns the color ramp used for the gradient fill. This is only
242+
* used if the gradient color type is set to ColorRamp.
243+
* @see setColorRamp()
244+
* @see gradientColorType()
245+
*/
242246
QgsColorRamp* colorRamp() { return mGradientRamp; }
247+
248+
/** Sets the color ramp used for the gradient fill. This is only
249+
* used if the gradient color type is set to ColorRamp.
250+
* @param ramp color ramp. Ownership is transferred.
251+
* @see colorRamp()
252+
* @see setGradientColorType()
253+
*/
243254
void setColorRamp( QgsColorRamp* ramp );
244255

245256
/** Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor*/

src/core/symbology-ng/qgsgraduatedsymbolrenderer.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
247247
//! @note Added in 2.6
248248
void calculateLabelPrecision( bool updateRanges = true );
249249

250+
/** Creates a new graduated renderer.
251+
* @param vlayer vector layer
252+
* @param attrName attribute to classify
253+
* @param classes number of classes
254+
* @param mode classification mode
255+
* @param symbol base symbol
256+
* @param ramp color ramp for classes
257+
* @param inverted set to true to invert color ramp
258+
* @param legendFormat
259+
* @returns new QgsGraduatedSymbolRenderer object
260+
*/
250261
static QgsGraduatedSymbolRenderer* createRenderer(
251262
QgsVectorLayer* vlayer,
252263
const QString& attrName,

src/core/symbology-ng/qgssymbollayerutils.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,24 @@ class CORE_EXPORT QgsSymbolLayerUtils
138138
*/
139139
static QIcon symbolLayerPreviewIcon( QgsSymbolLayer* layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale& scale = QgsMapUnitScale() );
140140

141+
/** Returns a icon preview for a color ramp.
142+
* @param ramp color ramp
143+
* @param size target icon size
144+
* @see colorRampPreviewPixmap()
145+
*/
141146
static QIcon colorRampPreviewIcon( QgsColorRamp* ramp, QSize size );
142147

148+
/** Returns a pixmap preview for a color ramp.
149+
* @param ramp color ramp
150+
* @param size target pixmap size
151+
* @see colorRampPreviewIcon()
152+
*/
153+
static QPixmap colorRampPreviewPixmap( QgsColorRamp* ramp, QSize size );
154+
143155
static void drawStippledBackground( QPainter* painter, QRect rect );
144156

145157
//! @note customContext parameter added in 2.6
146158
static QPixmap symbolPreviewPixmap( QgsSymbol* symbol, QSize size, QgsRenderContext* customContext = nullptr );
147-
static QPixmap colorRampPreviewPixmap( QgsColorRamp* ramp, QSize size );
148159

149160
/** Returns the maximum estimated bleed for the symbol */
150161
static double estimateMaxSymbolBleed( QgsSymbol* symbol );
@@ -297,7 +308,20 @@ class CORE_EXPORT QgsSymbolLayerUtils
297308

298309
static void clearSymbolMap( QgsSymbolMap& symbols );
299310

311+
/** Creates a color ramp from the settings encoded in an XML element
312+
* @param element DOM element
313+
* @returns new color ramp. Caller takes responsiblity for deleting the returned value.
314+
* @see saveColorRamp()
315+
*/
300316
static QgsColorRamp* loadColorRamp( QDomElement& element );
317+
318+
/** Encodes a color ramp's settings to an XML element
319+
* @param name name of ramp
320+
* @param ramp color ramp to save
321+
* @param doc XML document
322+
* @returns DOM element representing state of color ramp
323+
* @see loadColorRamp()
324+
*/
301325
static QDomElement saveColorRamp( const QString& name, QgsColorRamp* ramp, QDomDocument& doc );
302326

303327
/**

0 commit comments

Comments
 (0)