@@ -718,6 +718,26 @@ void TestQgsProperty::genericNumericTransformer()
718
718
// non numeric value
719
719
QCOMPARE ( t1.transform ( context, QVariant ( " ffff" ) ), QVariant ( " ffff" ) );
720
720
721
+ // add a curve
722
+ QVERIFY ( !t1.curveTransform () );
723
+ t1.setCurveTransform ( new QgsCurveTransform ( QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) ) );
724
+ QVERIFY ( t1.curveTransform () );
725
+ QCOMPARE ( t1.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
726
+
727
+ QCOMPARE ( t1.transform ( context, 10 ).toInt (), 180 );
728
+ QCOMPARE ( t1.transform ( context, 20 ).toInt (), 120 );
729
+
730
+ // copy
731
+ QgsGenericNumericTransformer s1 ( t1 );
732
+ QVERIFY ( s1.curveTransform () );
733
+ QCOMPARE ( s1.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
734
+
735
+ // assignment
736
+ QgsGenericNumericTransformer s2;
737
+ s2 = t1;
738
+ QVERIFY ( s2.curveTransform () );
739
+ QCOMPARE ( s2.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
740
+
721
741
// saving and restoring
722
742
723
743
// create a test dom element
@@ -733,6 +753,7 @@ void TestQgsProperty::genericNumericTransformer()
733
753
250 ,
734
754
-10 ,
735
755
99 );
756
+ t2.setCurveTransform ( new QgsCurveTransform ( QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) ) );
736
757
737
758
QDomElement element = doc.createElement ( " xform" );
738
759
QVERIFY ( t2.writeXml ( element, doc ) );
@@ -744,6 +765,8 @@ void TestQgsProperty::genericNumericTransformer()
744
765
QCOMPARE ( r1.maxOutputValue (), 250.0 );
745
766
QCOMPARE ( r1.nullOutputValue (), -10.0 );
746
767
QCOMPARE ( r1.exponent (), 99.0 );
768
+ QVERIFY ( r1.curveTransform () );
769
+ QCOMPARE ( r1.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
747
770
748
771
// test cloning
749
772
std::unique_ptr< QgsGenericNumericTransformer > r2 ( t2.clone () );
@@ -753,6 +776,8 @@ void TestQgsProperty::genericNumericTransformer()
753
776
QCOMPARE ( r2->maxOutputValue (), 250.0 );
754
777
QCOMPARE ( r2->nullOutputValue (), -10.0 );
755
778
QCOMPARE ( r2->exponent (), 99.0 );
779
+ QVERIFY ( r2->curveTransform () );
780
+ QCOMPARE ( r2->curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
756
781
757
782
// test various min/max value/size and scaling methods
758
783
@@ -887,6 +912,25 @@ void TestQgsProperty::sizeScaleTransformer()
887
912
// non numeric value
888
913
QCOMPARE ( scale.transform ( context, QVariant ( " ffff" ) ), QVariant ( " ffff" ) );
889
914
915
+ // add a curve
916
+ QVERIFY ( !scale.curveTransform () );
917
+ scale.setCurveTransform ( new QgsCurveTransform ( QList< QgsPoint >() << QgsPoint ( 0 , 0.2 ) << QgsPoint ( 1 , 0.8 ) ) );
918
+ QVERIFY ( scale.curveTransform () );
919
+ QCOMPARE ( scale.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.2 ) << QgsPoint ( 1 , 0.8 ) );
920
+ QCOMPARE ( scale.transform ( context, 10 ).toInt (), 120 );
921
+ QCOMPARE ( scale.transform ( context, 20 ).toInt (), 180 );
922
+
923
+ // copy
924
+ QgsSizeScaleTransformer s1 ( scale );
925
+ QVERIFY ( s1.curveTransform () );
926
+ QCOMPARE ( s1.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.2 ) << QgsPoint ( 1 , 0.8 ) );
927
+
928
+ // assignment
929
+ QgsSizeScaleTransformer s2;
930
+ s2 = scale;
931
+ QVERIFY ( s2.curveTransform () );
932
+ QCOMPARE ( s2.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.2 ) << QgsPoint ( 1 , 0.8 ) );
933
+
890
934
// saving and restoring
891
935
892
936
// create a test dom element
@@ -903,6 +947,7 @@ void TestQgsProperty::sizeScaleTransformer()
903
947
250 ,
904
948
-10 ,
905
949
99 );
950
+ t1.setCurveTransform ( new QgsCurveTransform ( QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) ) );
906
951
907
952
QDomElement element = doc.createElement ( " xform" );
908
953
QVERIFY ( t1.writeXml ( element, doc ) );
@@ -915,6 +960,8 @@ void TestQgsProperty::sizeScaleTransformer()
915
960
QCOMPARE ( r1.nullSize (), -10.0 );
916
961
QCOMPARE ( r1.exponent (), 99.0 );
917
962
QCOMPARE ( r1.type (), QgsSizeScaleTransformer::Exponential );
963
+ QVERIFY ( r1.curveTransform () );
964
+ QCOMPARE ( r1.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
918
965
919
966
// test cloning
920
967
std::unique_ptr< QgsSizeScaleTransformer > r2 ( t1.clone () );
@@ -925,6 +972,8 @@ void TestQgsProperty::sizeScaleTransformer()
925
972
QCOMPARE ( r2->nullSize (), -10.0 );
926
973
QCOMPARE ( r2->exponent (), 99.0 );
927
974
QCOMPARE ( r2->type (), QgsSizeScaleTransformer::Exponential );
975
+ QVERIFY ( r2->curveTransform () );
976
+ QCOMPARE ( r2->curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
928
977
929
978
// test various min/max value/size and scaling methods
930
979
@@ -1092,6 +1141,26 @@ void TestQgsProperty::colorRampTransformer()
1092
1141
// non numeric value
1093
1142
QCOMPARE ( scale.transform ( context, QVariant ( " ffff" ) ), QVariant ( " ffff" ) );
1094
1143
1144
+ // add a curve
1145
+ QVERIFY ( !scale.curveTransform () );
1146
+ scale.setCurveTransform ( new QgsCurveTransform ( QList< QgsPoint >() << QgsPoint ( 0 , 0.2 ) << QgsPoint ( 1 , 0.8 ) ) );
1147
+ QVERIFY ( scale.curveTransform () );
1148
+ QCOMPARE ( scale.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.2 ) << QgsPoint ( 1 , 0.8 ) );
1149
+
1150
+ QCOMPARE ( scale.transform ( context, 10 ).value <QColor>().name (), QString ( " #333333" ) );
1151
+ QCOMPARE ( scale.transform ( context, 20 ).value <QColor>().name (), QString ( " #cccccc" ) );
1152
+
1153
+ // copy
1154
+ QgsColorRampTransformer s1 ( scale );
1155
+ QVERIFY ( s1.curveTransform () );
1156
+ QCOMPARE ( s1.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.2 ) << QgsPoint ( 1 , 0.8 ) );
1157
+
1158
+ // assignment
1159
+ QgsColorRampTransformer s2;
1160
+ s2 = scale;
1161
+ QVERIFY ( s2.curveTransform () );
1162
+ QCOMPARE ( s2.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.2 ) << QgsPoint ( 1 , 0.8 ) );
1163
+
1095
1164
// saving and restoring
1096
1165
1097
1166
// create a test dom element
@@ -1106,6 +1175,7 @@ void TestQgsProperty::colorRampTransformer()
1106
1175
new QgsGradientColorRamp ( QColor ( 10 , 20 , 30 ), QColor ( 200 , 190 , 180 ) ),
1107
1176
QColor ( 100 , 150 , 200 ) );
1108
1177
t1.setRampName ( " rampname " );
1178
+ t1.setCurveTransform ( new QgsCurveTransform ( QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) ) );
1109
1179
1110
1180
QDomElement element = doc.createElement ( " xform" );
1111
1181
QVERIFY ( t1.writeXml ( element, doc ) );
@@ -1118,6 +1188,8 @@ void TestQgsProperty::colorRampTransformer()
1118
1188
QVERIFY ( dynamic_cast < QgsGradientColorRamp* >( r1.colorRamp () ) );
1119
1189
QCOMPARE ( static_cast < QgsGradientColorRamp* >( r1.colorRamp () )->color1 (), QColor ( 10 , 20 , 30 ) );
1120
1190
QCOMPARE ( static_cast < QgsGradientColorRamp* >( r1.colorRamp () )->color2 (), QColor ( 200 , 190 , 180 ) );
1191
+ QVERIFY ( r1.curveTransform () );
1192
+ QCOMPARE ( r1.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
1121
1193
1122
1194
// test cloning
1123
1195
std::unique_ptr< QgsColorRampTransformer > r2 ( t1.clone () );
@@ -1127,6 +1199,8 @@ void TestQgsProperty::colorRampTransformer()
1127
1199
QCOMPARE ( r2->rampName (), QStringLiteral ( " rampname " ) );
1128
1200
QCOMPARE ( static_cast < QgsGradientColorRamp* >( r2->colorRamp () )->color1 (), QColor ( 10 , 20 , 30 ) );
1129
1201
QCOMPARE ( static_cast < QgsGradientColorRamp* >( r2->colorRamp () )->color2 (), QColor ( 200 , 190 , 180 ) );
1202
+ QVERIFY ( r2->curveTransform () );
1203
+ QCOMPARE ( r2->curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
1130
1204
1131
1205
// copy constructor
1132
1206
QgsColorRampTransformer r3 ( t1 );
@@ -1136,6 +1210,8 @@ void TestQgsProperty::colorRampTransformer()
1136
1210
QCOMPARE ( r3.rampName (), QStringLiteral ( " rampname " ) );
1137
1211
QCOMPARE ( static_cast < QgsGradientColorRamp* >( r3.colorRamp () )->color1 (), QColor ( 10 , 20 , 30 ) );
1138
1212
QCOMPARE ( static_cast < QgsGradientColorRamp* >( r3.colorRamp () )->color2 (), QColor ( 200 , 190 , 180 ) );
1213
+ QVERIFY ( r3.curveTransform () );
1214
+ QCOMPARE ( r3.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
1139
1215
1140
1216
// assignment operator
1141
1217
QgsColorRampTransformer r4;
@@ -1146,6 +1222,8 @@ void TestQgsProperty::colorRampTransformer()
1146
1222
QCOMPARE ( r4.rampName (), QStringLiteral ( " rampname " ) );
1147
1223
QCOMPARE ( static_cast < QgsGradientColorRamp* >( r4.colorRamp () )->color1 (), QColor ( 10 , 20 , 30 ) );
1148
1224
QCOMPARE ( static_cast < QgsGradientColorRamp* >( r4.colorRamp () )->color2 (), QColor ( 200 , 190 , 180 ) );
1225
+ QVERIFY ( r4.curveTransform () );
1226
+ QCOMPARE ( r4.curveTransform ()->controlPoints (), QList< QgsPoint >() << QgsPoint ( 0 , 0.8 ) << QgsPoint ( 1 , 0.2 ) );
1149
1227
1150
1228
// test various min/max value/color and scaling methods
1151
1229
0 commit comments