File: qgspropertytransformer.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (744 lines) | stat: -rw-r--r-- 20,747 bytes parent folder | download | duplicates (6)
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
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgspropertytransformer.h                                    *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/





class QgsCurveTransform
{
%Docstring(signature="appended")
Handles scaling of input values to output values by using a curve
created from smoothly joining a number of set control points.

:py:class:`QgsCurveTransform` assists in creation of curve type
transforms, typically seen in raster image editing software (eg the
curves dialog in GIMP or Photoshop). Transforms are created by passing a
number of set control points through which the transform curve must
pass. The curve is guaranteed to exactly pass through these control
points. Between control points the curve is smoothly interpolated so
that no disjoint sections or "corners" are present.

If the first or last control point are not located at x = 0 and x = 1
respectively, then values outside this range will be mapped to the y
value of either the first or last control point. In other words, the
curve will have a flat segment for values outside of the control point
range.
%End

%TypeHeaderCode
#include "qgspropertytransformer.h"
%End
  public:

    QgsCurveTransform();
%Docstring
Constructs a default QgsCurveTransform which linearly maps values
between 0 and 1 unchanged. I.e. y == x.
%End

    QgsCurveTransform( const QList< QgsPointXY > &controlPoints );
%Docstring
Constructs a QgsCurveTransform using a specified list of
``controlPoints``. Behavior is undefined if duplicate x values exist in
the control points list.
%End

    ~QgsCurveTransform();

    QgsCurveTransform( const QgsCurveTransform &other );


    QList< QgsPointXY > controlPoints() const;
%Docstring
Returns a list of the control points for the transform.

.. seealso:: :py:func:`setControlPoints`
%End

    void setControlPoints( const QList< QgsPointXY > &points );
%Docstring
Sets the list of control points for the transform. Any existing points
are removed.

.. seealso:: :py:func:`controlPoints`
%End

    void addControlPoint( double x, double y );
%Docstring
Adds a control point to the transform. Behavior is undefined if
duplicate x values exist in the control points list.

.. seealso:: :py:func:`removeControlPoint`
%End

    void removeControlPoint( double x, double y );
%Docstring
Removes a control point from the transform. This will have no effect if
a matching control point does not exist.

.. seealso:: :py:func:`addControlPoint`
%End

    double y( double x ) const;
%Docstring
Returns the mapped y value corresponding to the specified ``x`` value.
%End

    QVector< double > y( const QVector< double > &x ) const;
%Docstring
Returns a list of y values corresponding to a list of ``x`` values.
Calling this method is faster then calling the double variant multiple
times.
%End

    bool readXml( const QDomElement &elem, const QDomDocument &doc );
%Docstring
Reads the curve's state from an XML element.

:param elem: source DOM element for transform's state
:param doc: DOM document

.. seealso:: :py:func:`writeXml`
%End

    bool writeXml( QDomElement &transformElem, QDomDocument &doc ) const;
%Docstring
Writes the current state of the transform into an XML element

:param transformElem: destination element for the transform's state
:param doc: DOM document

.. seealso:: :py:func:`readXml`
%End

    QVariant toVariant() const;
%Docstring
Saves this curve transformer to a QVariantMap, wrapped in a QVariant.
You can use :py:class:`QgsXmlUtils`.writeVariant to save it to an XML
document.

.. seealso:: :py:func:`loadVariant`
%End

    bool loadVariant( const QVariant &transformer );
%Docstring
Load this curve transformer from a QVariantMap, wrapped in a QVariant.
You can use :py:class:`QgsXmlUtils`.writeVariant to load it from an XML
document.

.. seealso:: :py:func:`toVariant`
%End

};


class QgsPropertyTransformer
{
%Docstring(signature="appended")
Abstract base class for objects which transform the calculated value of
a property. Possible uses include transformers which map a value into a
scaled size or color from a gradient.
%End

%TypeHeaderCode
#include "qgspropertytransformer.h"
%End
%ConvertToSubClassCode
    if ( sipCpp->transformerType() == QgsPropertyTransformer::GenericNumericTransformer )
      sipType = sipType_QgsGenericNumericTransformer;
    else if ( sipCpp->transformerType() == QgsPropertyTransformer::SizeScaleTransformer )
      sipType = sipType_QgsSizeScaleTransformer;
    else if ( sipCpp->transformerType() == QgsPropertyTransformer::ColorRampTransformer )
      sipType = sipType_QgsColorRampTransformer;
    else
      sipType = sipType_QgsPropertyTransformer;
%End
  public:

    enum Type /BaseType=IntEnum/
    {
      GenericNumericTransformer,
      SizeScaleTransformer,
      ColorRampTransformer,
    };

    static QgsPropertyTransformer *create( Type type ) /Factory/;
%Docstring
Factory method for creating a new property transformer of the specified
type.

:param type: transformer type to create
%End

    QgsPropertyTransformer( double minValue = 0.0, double maxValue = 1.0 );
%Docstring
Constructor for QgsPropertyTransformer

:param minValue: minimum expected value from source property
:param maxValue: maximum expected value from source property
%End

    QgsPropertyTransformer( const QgsPropertyTransformer &other );

    virtual ~QgsPropertyTransformer();

    virtual Type transformerType() const = 0;
%Docstring
Returns the transformer type.
%End

    virtual QgsPropertyTransformer *clone() const = 0 /Factory/;
%Docstring
Returns a clone of the transformer.
%End

    virtual bool loadVariant( const QVariant &transformer );
%Docstring
Loads this transformer from a QVariantMap, wrapped in a QVariant. You
can use :py:class:`QgsXmlUtils`.readVariant to read it from an XML
document.

.. seealso:: :py:func:`toVariant`
%End

    virtual QVariant toVariant() const;
%Docstring
Saves this transformer to a QVariantMap, wrapped in a QVariant. You can
use :py:class:`QgsXmlUtils`.writeVariant to save it to an XML document.

.. seealso:: :py:func:`loadVariant`
%End

    double minValue() const;
%Docstring
Returns the minimum value expected by the transformer.

.. seealso:: :py:func:`maxValue`

.. seealso:: :py:func:`setMinValue`
%End

    void setMinValue( double min );
%Docstring
Sets the minimum value expected by the transformer.

:param min: minimum value

.. seealso:: :py:func:`setMaxValue`

.. seealso:: :py:func:`minValue`
%End

    double maxValue() const;
%Docstring
Returns the maximum value expected by the transformer.

.. seealso:: :py:func:`minValue`

.. seealso:: :py:func:`setMaxValue`
%End

    void setMaxValue( double max );
%Docstring
Sets the maximum value expected by the transformer.

:param max: maximum value

.. seealso:: :py:func:`setMinValue`

.. seealso:: :py:func:`maxValue`
%End

    QgsCurveTransform *curveTransform() const;
%Docstring
Returns the curve transform applied to input values before they are
transformed by the individual transform subclasses.

.. seealso:: :py:func:`setCurveTransform`
%End

    void setCurveTransform( QgsCurveTransform *transform /Transfer/ );
%Docstring
Sets a curve transform to apply to input values before they are
transformed by the individual transform subclasses. Ownership of
``transform`` is transferred to the property transformer.

.. seealso:: :py:func:`curveTransform`
%End

    virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const = 0;
%Docstring
Calculates the transform of a value. Derived classes must implement this
to perform their transformations on input values

:param context: expression context
:param value: input value to transform
%End

    virtual QString toExpression( const QString &baseExpression ) const = 0;
%Docstring
Converts the transformer to a QGIS expression string. The
``baseExpression`` string consists of a sub-expression reflecting the
parent property's state.
%End

    static QgsPropertyTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/;
%Docstring
Attempts to parse an expression into a corresponding property
transformer.

:param expression: expression to parse

:return: - corresponding property transformer, or ``None`` if expression
           could not be parsed to a transformer.
         - baseExpression: the component of the source expression which
           is used to calculate the input to the property transformer.
           This an empty string if a field reference is the transformer
           input.
         - fieldName: a field name which is used to calculate the input
           to the property transformer. This an empty string if an
           expression is the transformer input.
%End

  protected:

    double transformNumeric( double input ) const;
%Docstring
Applies base class numeric transformations. Derived classes should call
this to transform an ``input`` numeric value before they apply any
transform to the result. This applies any curve transforms which may
exist on the transformer.
%End
};


class QgsGenericNumericTransformer : QgsPropertyTransformer
{
%Docstring(signature="appended")
:py:class:`QgsPropertyTransformer` subclass for scaling an input numeric
value into an output numeric value.
%End

%TypeHeaderCode
#include "qgspropertytransformer.h"
%End
  public:

    QgsGenericNumericTransformer( double minValue = 0.0,
                                  double maxValue = 1.0,
                                  double minOutput = 0.0,
                                  double maxOutput = 1.0,
                                  double nullOutput = 0.0,
                                  double exponent = 1.0 );
%Docstring
Constructor for QgsGenericNumericTransformer.

:param minValue: minimum expected input value
:param maxValue: maximum expected input value
:param minOutput: minimum value to return
:param maxOutput: maximum value to return
:param nullOutput: value to return for null inputs
:param exponent: optional exponential for non-linear scaling
%End

    virtual Type transformerType() const;
    virtual QgsGenericNumericTransformer *clone() const /Factory/;

    virtual QVariant toVariant() const;

    virtual bool loadVariant( const QVariant &definition );

    virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const;

    virtual QString toExpression( const QString &baseExpression ) const;


    static QgsGenericNumericTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/;
%Docstring
Attempts to parse an expression into a corresponding
:py:class:`QgsSizeScaleTransformer`.

:param expression: expression to parse

:return: - corresponding :py:class:`QgsSizeScaleTransformer`, or
           ``None`` if expression could not be parsed to a size scale
           transformer.
         - baseExpression: the component of the source expression which
           is used to calculate the input to the property transformer.
           This will be set to an empty string if a field reference is
           the transformer input.
         - fieldName: a field name which is used to calculate the input
           to the property transformer. This will be set to an empty
           string if an expression is the transformer input.
%End

    double value( double input ) const;
%Docstring
Calculates the size corresponding to a specific ``input`` value.

:return: calculated size using size scale transformer's parameters and
         type
%End

    double minOutputValue() const;
%Docstring
Returns the minimum calculated size.

.. seealso:: :py:func:`setMinOutputValue`

.. seealso:: :py:func:`maxOutputValue`
%End

    void setMinOutputValue( double size );
%Docstring
Sets the minimum calculated size.

:param size: minimum size

.. seealso:: :py:func:`minOutputValue`

.. seealso:: :py:func:`setMaxOutputValue`
%End

    double maxOutputValue() const;
%Docstring
Returns the maximum calculated size.

.. seealso:: :py:func:`minOutputValue`
%End

    void setMaxOutputValue( double size );
%Docstring
Sets the maximum calculated size.

:param size: maximum size

.. seealso:: :py:func:`maxOutputValue`

.. seealso:: :py:func:`setMinOutputValue`
%End

    double nullOutputValue() const;
%Docstring
Returns the size value when an expression evaluates to NULL.

.. seealso:: :py:func:`setNullOutputValue`
%End

    void setNullOutputValue( double size );
%Docstring
Sets the size value for when an expression evaluates to NULL.

:param size: null size

.. seealso:: :py:func:`nullOutputValue`
%End

    double exponent() const;
%Docstring
Returns the exponent for an exponential expression.

.. seealso:: :py:func:`setExponent`
%End

    void setExponent( double exponent );
%Docstring
Sets the exponent for an exponential expression.

:param exponent: exponent

.. seealso:: :py:func:`exponent`
%End

};


class QgsSizeScaleTransformer : QgsPropertyTransformer
{
%Docstring(signature="appended")
:py:class:`QgsPropertyTransformer` subclass for scaling a value into a
size according to various scaling methods.
%End

%TypeHeaderCode
#include "qgspropertytransformer.h"
%End
  public:

    enum ScaleType /BaseType=IntEnum/
    {
      Linear,
      Area,
      Flannery,
      Exponential,
    };

    QgsSizeScaleTransformer( ScaleType type = Linear,
                             double minValue = 0.0,
                             double maxValue = 1.0,
                             double minSize = 0.0,
                             double maxSize = 1.0,
                             double nullSize = 0.0,
                             double exponent = 1.0 );
%Docstring
Constructor for QgsSizeScaleTransformer.

:param type: scaling type
:param minValue: minimum expected value
:param maxValue: maximum expected value
:param minSize: minimum size to return
:param maxSize: maximum size to return
:param nullSize: size to return for null values
:param exponent: exponent for Exponential scaling method
%End

    virtual Type transformerType() const;
    virtual QgsSizeScaleTransformer *clone() const /Factory/;

    virtual QVariant toVariant() const;

    virtual bool loadVariant( const QVariant &definition );

    virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const;

    virtual QString toExpression( const QString &baseExpression ) const;


    static QgsSizeScaleTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/;
%Docstring
Attempts to parse an expression into a corresponding
QgsSizeScaleTransformer.

:param expression: expression to parse

:return: - corresponding QgsSizeScaleTransformer, or ``None`` if
           expression could not be parsed to a size scale transformer.
         - baseExpression: the component of the source expression which
           is used to calculate the input to the property transformer.
           This an empty string if a field reference is the transformer
           input.
         - fieldName: a field name which is used to calculate the input
           to the property transformer. This an empty string if an
           expression is the transformer input.
%End

    double size( double value ) const;
%Docstring
Calculates the size corresponding to a specific value.

:param value: value to calculate size for

:return: calculated size using size scale transformer's parameters and
         type
%End

    double minSize() const;
%Docstring
Returns the minimum calculated size.

.. seealso:: :py:func:`setMinSize`

.. seealso:: :py:func:`maxSize`
%End

    void setMinSize( double size );
%Docstring
Sets the minimum calculated size.

:param size: minimum size

.. seealso:: :py:func:`minSize`

.. seealso:: :py:func:`setMaxSize`
%End

    double maxSize() const;
%Docstring
Returns the maximum calculated size.

.. seealso:: :py:func:`minSize`
%End

    void setMaxSize( double size );
%Docstring
Sets the maximum calculated size.

:param size: maximum size

.. seealso:: :py:func:`maxSize`

.. seealso:: :py:func:`setMinSize`
%End

    double nullSize() const;
%Docstring
Returns the size value when an expression evaluates to NULL.

.. seealso:: :py:func:`setNullSize`
%End

    void setNullSize( double size );
%Docstring
Sets the size value for when an expression evaluates to NULL.

:param size: null size

.. seealso:: :py:func:`nullSize`
%End

    double exponent() const;
%Docstring
Returns the exponent for an exponential expression.

.. seealso:: :py:func:`setExponent`

.. seealso:: :py:func:`type`
%End

    void setExponent( double exponent );
%Docstring
Sets the exponent for an exponential expression.

:param exponent: exponent

.. seealso:: :py:func:`exponent`
%End

    ScaleType type() const;
%Docstring
Returns the size transformer's scaling type (the method used to
calculate the size from a value).

.. seealso:: :py:func:`setType`
%End

    void setType( ScaleType type );
%Docstring
Sets the size transformer's scaling type (the method used to calculate
the size from a value).

:param type: scale type

.. seealso:: :py:func:`type`
%End

};


class QgsColorRampTransformer : QgsPropertyTransformer
{
%Docstring(signature="appended")
:py:class:`QgsPropertyTransformer` subclass for transforming a numeric
value into a color from a color ramp.
%End

%TypeHeaderCode
#include "qgspropertytransformer.h"
%End
  public:

    QgsColorRampTransformer( double minValue = 0.0,
                             double maxValue = 1.0,
                             QgsColorRamp *ramp /Transfer/ = 0,
                             const QColor &nullColor = QColor( 0, 0, 0, 0 ),
                             const QString &rampName = QString() );
%Docstring
Constructor for QgsColorRampTransformer.

:param minValue: minimum expected value
:param maxValue: maximum expected value
:param ramp: source color ramp. Ownership is transferred to the
             transformer.
:param nullColor: color to return for null values
:param rampName: name of the source color ramp (since QGIS 3.36)
%End

    QgsColorRampTransformer( const QgsColorRampTransformer &other );

    virtual Type transformerType() const;
    virtual QgsColorRampTransformer *clone() const /Factory/;

    virtual QVariant toVariant() const;

    virtual bool loadVariant( const QVariant &definition );

    virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const;

    virtual QString toExpression( const QString &baseExpression ) const;


    QColor color( double value ) const;
%Docstring
Calculates the color corresponding to a specific value.

:param value: value to calculate color for

:return: calculated color using transformer's parameters and type
%End

    QgsColorRamp *colorRamp() const;
%Docstring
Returns the color ramp used for calculating property colors.

:return: color ramp

.. seealso:: :py:func:`setColorRamp`
%End

    void setColorRamp( QgsColorRamp *ramp /Transfer/ );
%Docstring
Sets the color ramp to use for calculating property colors.

:param ramp: color ramp, ownership of ramp is transferred to the
             transformer.

.. seealso:: :py:func:`colorRamp`
%End

    QColor nullColor() const;
%Docstring
Returns the color corresponding to a null value.

.. seealso:: :py:func:`setNullColor`
%End

    void setNullColor( const QColor &color );
%Docstring
Sets the color corresponding to a null value.

:param color: null color

.. seealso:: :py:func:`nullColor`
%End

    QString rampName() const;
%Docstring
Returns the color ramp's name.

.. seealso:: :py:func:`setRampName`
%End

    void setRampName( const QString &name );
%Docstring
Sets the color ramp's ``name``. The ramp name must be set to match a
color ramp available in the style database for conversion to expression
to work correctly.

.. seealso:: :py:func:`rampName`
%End

};

/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgspropertytransformer.h                                    *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/