/
qgscolorrampimpl.h
804 lines (675 loc) · 24.8 KB
/
qgscolorrampimpl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
/***************************************************************************
qgscolorrampimpl.h
---------------------
begin : November 2009
copyright : (C) 2009 by Martin Dobias
email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCOLORRAMPIMPL_H
#define QGSCOLORRAMPIMPL_H
#include "qgis_core.h"
#include <QColor>
#include <QGradient>
#include "qgis.h"
#include "qgscolorscheme.h"
#include "qgscolorramp.h"
#ifndef SIP_RUN
///@cond PRIVATE
typedef QColor( *InterpolateColorFunc )( const QColor &c1, const QColor &c2, const double value, Qgis::AngularDirection direction );
///@endcond
#endif
/**
* \ingroup core
* \class QgsGradientStop
* \brief Represents a color stop within a QgsGradientColorRamp color ramp.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsGradientStop
{
public:
/**
* Constructor for QgsGradientStop
* \param offset positional offset for stop, between 0 and 1.0
* \param color color for stop
*/
QgsGradientStop( double offset, const QColor &color );
//! Relative positional offset, between 0 and 1
double offset;
//! Gradient color at stop
QColor color;
bool operator==( const QgsGradientStop &other ) const
{
return other.color == color && qgsDoubleNear( other.offset, offset ) && other.mColorSpec == mColorSpec && other.mDirection == mDirection;
}
bool operator!=( const QgsGradientStop &other ) const
{
return !( *this == other );
}
/**
* Returns the color specification in which the color component interpolation will occur.
*
* For multi-stop gradients this color spec will be used for the portion of the color ramp
* leading into the current stop.
*
* \see setColorSpec()
* \since QGIS 3.24
*/
QColor::Spec colorSpec() const { return mColorSpec; }
/**
* Sets the color specification in which the color component interpolation will occur.
*
* Only QColor::Spec::Rgb, QColor::Spec::Hsv and QColor::Spec::Hsl are currently supported.
*
* For multi-stop gradients this color spec will be used for the portion of the color ramp
* leading into the current stop.
*
* \see colorSpec()
* \since QGIS 3.24
*/
void setColorSpec( QColor::Spec spec );
/**
* Returns the direction to traverse the color wheel using when interpolating hue-based color
* specifications.
*
* For multi-stop gradients this direction will be used for the portion of the color ramp
* leading into the current stop.
*
* \see setDirection()
* \since QGIS 3.24
*/
Qgis::AngularDirection direction() const { return mDirection; }
/**
* Sets the \a direction to traverse the color wheel using when interpolating hue-based color
* specifications.
*
* For multi-stop gradients this direction will be used for the portion of the color ramp
* leading into the current stop.
*
* \see direction()
* \since QGIS 3.24
*/
void setDirection( Qgis::AngularDirection direction ) { mDirection = direction; }
private:
QColor::Spec mColorSpec = QColor::Spec::Rgb;
Qgis::AngularDirection mDirection = Qgis::AngularDirection::CounterClockwise;
InterpolateColorFunc mFunc = nullptr;
friend class QgsGradientColorRamp;
};
//! List of gradient stops
typedef QList<QgsGradientStop> QgsGradientStopsList;
// these are the QGIS branding colors, exaggerated a bit to make a default ramp with greater color variation
// then the official QGIS color gradient!
#define DEFAULT_GRADIENT_COLOR1 QColor(69, 116, 40)
#define DEFAULT_GRADIENT_COLOR2 QColor(188, 220, 60)
/**
* \ingroup core
* \class QgsGradientColorRamp
* \brief Gradient color ramp, which smoothly interpolates between two colors and also
* supports optional extra color stops.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsGradientColorRamp : public QgsColorRamp
{
public:
/**
* Constructor for QgsGradientColorRamp
* \param color1 start color, corresponding to a position of 0.0
* \param color2 end color, corresponding to a position of 1.0
* \param discrete set to TRUE for discrete interpolation instead of smoothly
* interpolating between colors
* \param stops optional list of additional color stops
*/
QgsGradientColorRamp( const QColor &color1 = DEFAULT_GRADIENT_COLOR1,
const QColor &color2 = DEFAULT_GRADIENT_COLOR2,
bool discrete = false,
const QgsGradientStopsList &stops = QgsGradientStopsList() );
//! Creates a new QgsColorRamp from a map of properties
static QgsColorRamp *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
int count() const override { return mStops.count() + 2; }
double value( int index ) const override;
QColor color( double value ) const override;
/**
* Returns the string identifier for QgsGradientColorRamp.
*
* \since QGIS 3.16
*/
static QString typeString() { return QStringLiteral( "gradient" ); }
QString type() const override;
void invert() override;
QgsGradientColorRamp *clone() const override SIP_FACTORY;
QVariantMap properties() const override;
/**
* Returns the gradient start color.
* \see setColor1()
* \see color2()
*/
QColor color1() const { return mColor1; }
/**
* Returns the gradient end color.
* \see setColor2()
* \see color1()
*/
QColor color2() const { return mColor2; }
/**
* Sets the gradient start color.
* \param color start color
* \see color1()
* \see setColor2()
*/
void setColor1( const QColor &color ) { mColor1 = color; }
/**
* Sets the gradient end color.
* \param color end color
* \see color2()
* \see setColor1()
*/
void setColor2( const QColor &color ) { mColor2 = color; }
/**
* Returns TRUE if the gradient is using discrete interpolation, rather than
* smoothly interpolating between colors.
* \see setDiscrete()
*/
bool isDiscrete() const { return mDiscrete; }
/**
* Sets whether the gradient should use discrete interpolation, rather than
* smoothly interpolating between colors.
* \param discrete set to TRUE to use discrete interpolation
* \see convertToDiscrete()
* \see isDiscrete()
*/
void setDiscrete( bool discrete ) { mDiscrete = discrete; }
/**
* Converts a gradient with existing color stops to or from discrete
* interpolation.
* \param discrete set to TRUE to convert the gradient stops to discrete,
* or FALSE to convert them to smooth interpolation
* \see isDiscrete()
*/
void convertToDiscrete( bool discrete );
/**
* Sets the list of intermediate gradient stops for the ramp.
* \param stops list of stops. Any existing color stops will be replaced. The stop
* list will be automatically reordered so that stops are listed in ascending offset
* order.
* \see stops()
*/
void setStops( const QgsGradientStopsList &stops );
/**
* Returns the list of intermediate gradient stops for the ramp.
* \see setStops()
*/
QgsGradientStopsList stops() const { return mStops; }
/**
* Returns any additional info attached to the gradient ramp (e.g., authorship notes)
* \see setInfo()
*/
QgsStringMap info() const { return mInfo; }
/**
* Sets additional info to attach to the gradient ramp (e.g., authorship notes)
* \param info map of string info to attach
* \see info()
*/
void setInfo( const QgsStringMap &info ) { mInfo = info; }
/**
* Copy color ramp stops to a QGradient
* \param gradient gradient to copy stops into
* \param opacity opacity multiplier. Opacity of colors will be multiplied
* by this factor before adding to the gradient.
* \since QGIS 2.1
*/
void addStopsToGradient( QGradient *gradient, double opacity = 1 ) const;
/**
* Returns the color specification in which the color component interpolation will occur.
*
* For multi-stop gradients this color spec will be used for the portion of the color ramp
* leading into the final stop (i.e. color2()).
*
* \see setColorSpec()
* \since QGIS 3.24
*/
QColor::Spec colorSpec() const { return mColorSpec; }
/**
* Sets the color specification in which the color component interpolation will occur.
*
* Only QColor::Spec::Rgb, QColor::Spec::Hsv and QColor::Spec::Hsl are currently supported.
*
* For multi-stop gradients this color spec will be used for the portion of the color ramp
* leading into the final stop (i.e. color2()).
*
* \see colorSpec()
* \since QGIS 3.24
*/
void setColorSpec( QColor::Spec spec );
/**
* Returns the direction to traverse the color wheel using when interpolating hue-based color
* specifications.
*
* For multi-stop gradients this direction will be used for the portion of the color ramp
* leading into the final stop (i.e. color2()).
*
* \see setDirection()
* \since QGIS 3.24
*/
Qgis::AngularDirection direction() const { return mDirection; }
/**
* Sets the \a direction to traverse the color wheel using when interpolating hue-based color
* specifications.
*
* For multi-stop gradients this direction will be used for the portion of the color ramp
* leading into the final stop (i.e. color2()).
*
* \see direction()
* \since QGIS 3.24
*/
void setDirection( Qgis::AngularDirection direction ) { mDirection = direction; }
protected:
QColor mColor1;
QColor mColor2;
bool mDiscrete;
QgsGradientStopsList mStops;
QgsStringMap mInfo;
QColor::Spec mColorSpec = QColor::Spec::Rgb;
Qgis::AngularDirection mDirection = Qgis::AngularDirection::CounterClockwise;
InterpolateColorFunc mFunc = nullptr;
};
Q_DECLARE_METATYPE( QgsGradientColorRamp )
#define DEFAULT_RANDOM_COUNT 10
#define DEFAULT_RANDOM_HUE_MIN 0
#define DEFAULT_RANDOM_HUE_MAX 359
#define DEFAULT_RANDOM_VAL_MIN 200
#define DEFAULT_RANDOM_VAL_MAX 240
#define DEFAULT_RANDOM_SAT_MIN 100
#define DEFAULT_RANDOM_SAT_MAX 240
/**
* \ingroup core
* \class QgsLimitedRandomColorRamp
* \brief Constrained random color ramp, which returns random colors based on preset parameters.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsLimitedRandomColorRamp : public QgsColorRamp
{
public:
/**
* Constructor for QgsLimitedRandomColorRamp
* \param count number of colors in ramp
* \param hueMin minimum hue
* \param hueMax maximum hue
* \param satMin minimum saturation
* \param satMax maximum saturation
* \param valMin minimum color value
* \param valMax maximum color value
*/
QgsLimitedRandomColorRamp( 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 );
/**
* Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string
* map.
* \param properties color ramp properties
* \see properties()
*/
static QgsColorRamp *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
double value( int index ) const override;
QColor color( double value ) const override;
/**
* Returns the string identifier for QgsLimitedRandomColorRamp.
*
* \since QGIS 3.16
*/
static QString typeString() { return QStringLiteral( "random" ); }
QString type() const override;
QgsLimitedRandomColorRamp *clone() const override SIP_FACTORY;
QVariantMap properties() const override;
int count() const override { return mCount; }
/**
* Gets a list of random colors
* \since QGIS 2.4
*/
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 );
/**
* Must be called after changing the properties of the color ramp
* to regenerate the list of random colors.
*/
void updateColors();
/**
* Returns the minimum hue for generated colors
* \see setHueMin()
*/
int hueMin() const { return mHueMin; }
/**
* Returns the maximum hue for generated colors
* \see setHueMax()
*/
int hueMax() const { return mHueMax; }
/**
* Returns the minimum saturation for generated colors
* \see setSatMin()
*/
int satMin() const { return mSatMin; }
/**
* Returns the maximum saturation for generated colors
* \see setSatMax()
*/
int satMax() const { return mSatMax; }
/**
* Returns the minimum value for generated colors
* \see setValMin()
*/
int valMin() const { return mValMin; }
/**
* Returns the maximum value for generated colors
* \see setValMax()
*/
int valMax() const { return mValMax; }
/**
* Sets the number of colors contained in the ramp.
*/
void setCount( int val ) { mCount = val; }
/**
* Sets the minimum hue for generated colors
* \see hueMin()
*/
void setHueMin( int val ) { mHueMin = val; }
/**
* Sets the maximum hue for generated colors
* \see hueMax()
*/
void setHueMax( int val ) { mHueMax = val; }
/**
* Sets the minimum saturation for generated colors
* \see satMin()
*/
void setSatMin( int val ) { mSatMin = val; }
/**
* Sets the maximum saturation for generated colors
* \see satMax()
*/
void setSatMax( int val ) { mSatMax = val; }
/**
* Sets the minimum value for generated colors
* \see valMin()
*/
void setValMin( int val ) { mValMin = val; }
/**
* Sets the maximum value for generated colors
* \see valMax()
*/
void setValMax( int val ) { mValMax = val; }
protected:
int mCount;
int mHueMin;
int mHueMax;
int mSatMin;
int mSatMax;
int mValMin;
int mValMax;
QList<QColor> mColors;
};
/**
* \ingroup core
* \class QgsRandomColorRamp
* \brief Totally random color ramp. Returns colors generated at random, but constrained
* to some hardcoded saturation and value ranges to prevent ugly color generation.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsRandomColorRamp: public QgsColorRamp
{
public:
/**
* Constructor for QgsRandomColorRamp.
*/
QgsRandomColorRamp() = default;
int count() const override;
double value( int index ) const override;
QColor color( double value ) const override;
/**
* Sets the desired total number of unique colors for the resultant ramp. Calling
* this method pregenerates a set of visually distinct colors which are returned
* by subsequent calls to color().
* \param colorCount number of unique colors
* \since QGIS 2.5
*/
virtual void setTotalColorCount( int colorCount );
/**
* Returns the string identifier for QgsRandomColorRamp.
*
* \since QGIS 3.16
*/
static QString typeString() { return QStringLiteral( "randomcolors" ); }
QString type() const override;
QgsRandomColorRamp *clone() const override SIP_FACTORY;
QVariantMap properties() const override;
protected:
int mTotalColorCount = 0;
QList<QColor> mPrecalculatedColors;
};
/**
* \ingroup core
* \class QgsPresetSchemeColorRamp
* \brief A scheme based color ramp consisting of a list of predefined colors.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsPresetSchemeColorRamp : public QgsColorRamp, public QgsColorScheme
{
public:
/**
* Constructor for QgsPresetSchemeColorRamp.
* \param colors list of colors in ramp
*/
QgsPresetSchemeColorRamp( const QList< QColor > &colors = QList< QColor >() );
/**
* Constructor for QgsPresetColorRamp.
* \param colors list of named colors in ramp
*/
QgsPresetSchemeColorRamp( const QgsNamedColorList &colors );
/**
* Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string
* map.
* \param properties color ramp properties
* \see properties()
*/
static QgsColorRamp *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
/**
* Sets the list of colors used by the ramp.
* \param colors list of colors
* \see colors()
*/
bool setColors( const QgsNamedColorList &colors, const QString & = QString(), const QColor & = QColor() ) override { mColors = colors; return true; }
/**
* Returns the list of colors used by the ramp.
* \see setColors()
*/
QList< QColor > colors() const;
double value( int index ) const override;
QColor color( double value ) const override;
/**
* Returns the string identifier for QgsPresetSchemeColorRamp.
*
* \since QGIS 3.16
*/
static QString typeString() { return QStringLiteral( "preset" ); }
QString type() const override;
void invert() override;
QgsPresetSchemeColorRamp *clone() const override SIP_FACTORY;
QVariantMap properties() const override;
int count() const override;
QString schemeName() const override { return QStringLiteral( "preset" ); }
QgsNamedColorList fetchColors( const QString &context = QString(), const QColor &baseColor = QColor() ) override;
bool isEditable() const override { return true; }
private:
QgsNamedColorList mColors;
};
#define DEFAULT_COLORBREWER_SCHEMENAME "Spectral"
#define DEFAULT_COLORBREWER_COLORS 5
/**
* \ingroup core
* \class QgsColorBrewerColorRamp
* \brief Color ramp utilising "Color Brewer" preset color schemes.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsColorBrewerColorRamp : public QgsColorRamp
{
public:
/**
* Constructor for QgsColorBrewerColorRamp
* \param schemeName color brewer scheme name
* \param colors number of colors in ramp
* \param inverted invert ramp ordering
*/
QgsColorBrewerColorRamp( const QString &schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
int colors = DEFAULT_COLORBREWER_COLORS,
bool inverted = false );
/**
* Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string
* map.
* \param properties color ramp properties
* \see properties()
*/
static QgsColorRamp *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
double value( int index ) const override;
QColor color( double value ) const override;
/**
* Returns the string identifier for QgsColorBrewerColorRamp.
*
* \since QGIS 3.16
*/
static QString typeString() { return QStringLiteral( "colorbrewer" ); }
QString type() const override { return QgsColorBrewerColorRamp::typeString(); }
void invert() override;
QgsColorBrewerColorRamp *clone() const override SIP_FACTORY;
QVariantMap properties() const override;
int count() const override { return mColors; }
/**
* Returns the name of the color brewer color scheme.
* \see setSchemeName()
*/
QString schemeName() const { return mSchemeName; }
/**
* Returns the number of colors in the ramp.
* \see setColors()
*/
int colors() const { return mColors; }
/**
* Sets the name of the color brewer color scheme.
* \param schemeName scheme name, must match a valid color brewer scheme name
* \see schemeName()
* \see listSchemeNames()
*/
void setSchemeName( const QString &schemeName ) { mSchemeName = schemeName; loadPalette(); }
/**
* Sets the number of colors in the ramp.
* \param colors number of colors. Must match a valid value for the scheme,
* which can be retrieved using listSchemeVariants()
* \see colors()
*/
void setColors( int colors ) { mColors = colors; loadPalette(); }
/**
* Returns a list of all valid color brewer scheme names.
* \see listSchemeVariants()
*/
static QStringList listSchemeNames();
/**
* Returns a list of the valid variants (numbers of colors) for a specified
* color brewer scheme name
* \param schemeName color brewer scheme name
* \see listSchemeNames()
*/
static QList<int> listSchemeVariants( const QString &schemeName );
protected:
//! Generates the scheme using the current name and number of colors
void loadPalette();
QString mSchemeName;
int mColors;
QList<QColor> mPalette;
bool mInverted;
};
#define DEFAULT_CPTCITY_SCHEMENAME "cb/div/BrBG_" //change this
#define DEFAULT_CPTCITY_VARIANTNAME "05"
/**
* \ingroup core
* \class QgsCptCityColorRamp
*/
class CORE_EXPORT QgsCptCityColorRamp : public QgsGradientColorRamp
{
public:
/**
* Constructor for QgsCptCityColorRamp
* \param schemeName cpt-city scheme name
* \param variantName cpt-city variant name
* \param inverted invert ramp ordering
* \param doLoadFile load cpt-city ramp from file
*/
QgsCptCityColorRamp( const QString &schemeName = DEFAULT_CPTCITY_SCHEMENAME,
const QString &variantName = DEFAULT_CPTCITY_VARIANTNAME,
bool inverted = false,
bool doLoadFile = true );
/**
* Constructor for QgsCptCityColorRamp
* \param schemeName cpt-city scheme name
* \param variantList cpt-city variant list
* \param variantName cpt-city variant name
* \param inverted invert ramp ordering
* \param doLoadFile load cpt-city ramp from file
*/
QgsCptCityColorRamp( const QString &schemeName, const QStringList &variantList,
const QString &variantName = QString(), bool inverted = false,
bool doLoadFile = true );
//! Creates the symbol layer
static QgsColorRamp *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
/**
* Returns the string identifier for QgsCptCityColorRamp.
*
* \since QGIS 3.16
*/
static QString typeString() { return QStringLiteral( "cpt-city" ); }
QString type() const override;
void invert() override;
QgsCptCityColorRamp *clone() const override SIP_FACTORY;
void copy( const QgsCptCityColorRamp *other );
QgsGradientColorRamp *cloneGradientRamp() const SIP_FACTORY;
QVariantMap properties() const override;
QString schemeName() const { return mSchemeName; }
QString variantName() const { return mVariantName; }
QStringList variantList() const { return mVariantList; }
// lazy loading - have to call loadPalette() explicitly
void setSchemeName( const QString &schemeName ) { mSchemeName = schemeName; mFileLoaded = false; }
void setVariantName( const QString &variantName ) { mVariantName = variantName; mFileLoaded = false; }
void setVariantList( const QStringList &variantList ) { mVariantList = variantList; }
void setName( const QString &schemeName, const QString &variantName = QString(), const QStringList &variantList = QStringList() )
{ mSchemeName = schemeName; mVariantName = variantName; mVariantList = variantList; mFileLoaded = false; }
void loadPalette() { loadFile(); }
bool hasMultiStops() const { return mMultiStops; }
/**
* Returns the source file name for a CPT \a schema and \a variant.
*
* \note Not available in Python bindings
* \since QGIS 3.28
*/
static QString fileNameForVariant( const QString &schema, const QString &variant ) SIP_SKIP;
QString fileName() const;
bool loadFile();
bool fileLoaded() const { return mFileLoaded; }
QString copyingFileName() const;
QString descFileName() const;
QgsStringMap copyingInfo() const;
protected:
QString mSchemeName;
QString mVariantName;
QStringList mVariantList;
bool mFileLoaded = false;
bool mMultiStops = false;
bool mInverted;
};
// clazy:excludeall=qstring-allocations
#endif