1/************************************************************************ 2 * This file has been generated automatically from * 3 * * 4 * src/core/qgspropertytransformer.h * 5 * * 6 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 7 ************************************************************************/ 8 9 10 11 12 13class QgsCurveTransform 14{ 15%Docstring 16Handles scaling of input values to output values by using a curve created 17from smoothly joining a number of set control points. 18 19QgsCurveTransform assists in creation of curve type transforms, typically seen in 20raster image editing software (eg the curves dialog in GIMP or Photoshop). 21Transforms are created by passing a number of set control points through which 22the transform curve must pass. The curve is guaranteed to exactly pass through 23these control points. Between control points the curve is smoothly interpolated 24so that no disjoint sections or "corners" are present. 25 26If the first or last control point are not located at x = 0 and x = 1 respectively, 27then values outside this range will be mapped to the y value of either the first 28or last control point. In other words, the curve will have a flat segment 29for values outside of the control point range. 30 31.. versionadded:: 3.0 32%End 33 34%TypeHeaderCode 35#include "qgspropertytransformer.h" 36%End 37 public: 38 39 QgsCurveTransform(); 40%Docstring 41Constructs a default QgsCurveTransform which linearly maps values 42between 0 and 1 unchanged. I.e. y == x. 43%End 44 45 QgsCurveTransform( const QList< QgsPointXY > &controlPoints ); 46%Docstring 47Constructs a QgsCurveTransform using a specified list of ``controlPoints``. 48Behavior is undefined if duplicate x values exist in the control points 49list. 50%End 51 52 ~QgsCurveTransform(); 53 54 QgsCurveTransform( const QgsCurveTransform &other ); 55%Docstring 56Copy constructor 57%End 58 59 60 QList< QgsPointXY > controlPoints() const; 61%Docstring 62Returns a list of the control points for the transform. 63 64.. seealso:: :py:func:`setControlPoints` 65%End 66 67 void setControlPoints( const QList< QgsPointXY > &points ); 68%Docstring 69Sets the list of control points for the transform. Any existing 70points are removed. 71 72.. seealso:: :py:func:`controlPoints` 73%End 74 75 void addControlPoint( double x, double y ); 76%Docstring 77Adds a control point to the transform. Behavior is undefined if duplicate 78x values exist in the control points list. 79 80.. seealso:: :py:func:`removeControlPoint` 81%End 82 83 void removeControlPoint( double x, double y ); 84%Docstring 85Removes a control point from the transform. This will have no effect if a 86matching control point does not exist. 87 88.. seealso:: :py:func:`addControlPoint` 89%End 90 91 double y( double x ) const; 92%Docstring 93Returns the mapped y value corresponding to the specified ``x`` value. 94%End 95 96 QVector< double > y( const QVector< double > &x ) const; 97%Docstring 98Returns a list of y values corresponding to a list of ``x`` values. 99Calling this method is faster then calling the double variant multiple 100times. 101%End 102 103 bool readXml( const QDomElement &elem, const QDomDocument &doc ); 104%Docstring 105Reads the curve's state from an XML element. 106 107:param elem: source DOM element for transform's state 108:param doc: DOM document 109 110.. seealso:: :py:func:`writeXml` 111%End 112 113 bool writeXml( QDomElement &transformElem, QDomDocument &doc ) const; 114%Docstring 115Writes the current state of the transform into an XML element 116 117:param transformElem: destination element for the transform's state 118:param doc: DOM document 119 120.. seealso:: :py:func:`readXml` 121%End 122 123 QVariant toVariant() const; 124%Docstring 125Saves this curve transformer to a QVariantMap, wrapped in a QVariant. 126You can use QgsXmlUtils.writeVariant to save it to an XML document. 127 128.. seealso:: :py:func:`loadVariant` 129%End 130 131 bool loadVariant( const QVariant &transformer ); 132%Docstring 133Load this curve transformer from a QVariantMap, wrapped in a QVariant. 134You can use QgsXmlUtils.writeVariant to load it from an XML document. 135 136.. seealso:: :py:func:`toVariant` 137%End 138 139}; 140 141 142class QgsPropertyTransformer 143{ 144%Docstring 145Abstract base class for objects which transform the calculated value of a property. 146Possible uses include transformers which map a value into a scaled size or color from a gradient. 147 148.. versionadded:: 3.0 149%End 150 151%TypeHeaderCode 152#include "qgspropertytransformer.h" 153%End 154%ConvertToSubClassCode 155 if ( sipCpp->transformerType() == QgsPropertyTransformer::GenericNumericTransformer ) 156 sipType = sipType_QgsGenericNumericTransformer; 157 else if ( sipCpp->transformerType() == QgsPropertyTransformer::SizeScaleTransformer ) 158 sipType = sipType_QgsSizeScaleTransformer; 159 else if ( sipCpp->transformerType() == QgsPropertyTransformer::ColorRampTransformer ) 160 sipType = sipType_QgsColorRampTransformer; 161 else 162 sipType = sipType_QgsPropertyTransformer; 163%End 164 public: 165 166 enum Type 167 { 168 GenericNumericTransformer, 169 SizeScaleTransformer, 170 ColorRampTransformer, 171 }; 172 173 static QgsPropertyTransformer *create( Type type ) /Factory/; 174%Docstring 175Factory method for creating a new property transformer of the specified type. 176 177:param type: transformer type to create 178%End 179 180 QgsPropertyTransformer( double minValue = 0.0, double maxValue = 1.0 ); 181%Docstring 182Constructor for QgsPropertyTransformer 183 184:param minValue: minimum expected value from source property 185:param maxValue: maximum expected value from source property 186%End 187 188 QgsPropertyTransformer( const QgsPropertyTransformer &other ); 189%Docstring 190Copy constructor. 191%End 192 193 virtual ~QgsPropertyTransformer(); 194 195 virtual Type transformerType() const = 0; 196%Docstring 197Returns the transformer type. 198%End 199 200 virtual QgsPropertyTransformer *clone() const = 0 /Factory/; 201%Docstring 202Returns a clone of the transformer. 203%End 204 205 virtual bool loadVariant( const QVariant &transformer ); 206%Docstring 207Loads this transformer from a QVariantMap, wrapped in a QVariant. 208You can use QgsXmlUtils.readVariant to read it from an XML document. 209 210.. seealso:: :py:func:`toVariant` 211%End 212 213 virtual QVariant toVariant() const; 214%Docstring 215Saves this transformer to a QVariantMap, wrapped in a QVariant. 216You can use QgsXmlUtils.writeVariant to save it to an XML document. 217 218.. seealso:: :py:func:`loadVariant` 219%End 220 221 double minValue() const; 222%Docstring 223Returns the minimum value expected by the transformer. 224 225.. seealso:: :py:func:`maxValue` 226 227.. seealso:: :py:func:`setMinValue` 228%End 229 230 void setMinValue( double min ); 231%Docstring 232Sets the minimum value expected by the transformer. 233 234:param min: minimum value 235 236.. seealso:: :py:func:`setMaxValue` 237 238.. seealso:: :py:func:`minValue` 239%End 240 241 double maxValue() const; 242%Docstring 243Returns the maximum value expected by the transformer. 244 245.. seealso:: :py:func:`minValue` 246 247.. seealso:: :py:func:`setMaxValue` 248%End 249 250 void setMaxValue( double max ); 251%Docstring 252Sets the maximum value expected by the transformer. 253 254:param max: maximum value 255 256.. seealso:: :py:func:`setMinValue` 257 258.. seealso:: :py:func:`maxValue` 259%End 260 261 QgsCurveTransform *curveTransform() const; 262%Docstring 263Returns the curve transform applied to input values before they are transformed 264by the individual transform subclasses. 265 266.. seealso:: :py:func:`setCurveTransform` 267%End 268 269 void setCurveTransform( QgsCurveTransform *transform /Transfer/ ); 270%Docstring 271Sets a curve transform to apply to input values before they are transformed 272by the individual transform subclasses. Ownership of ``transform`` is transferred 273to the property transformer. 274 275.. seealso:: :py:func:`curveTransform` 276%End 277 278 virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const = 0; 279%Docstring 280Calculates the transform of a value. Derived classes must implement this to perform their transformations 281on input values 282 283:param context: expression context 284:param value: input value to transform 285%End 286 287 virtual QString toExpression( const QString &baseExpression ) const = 0; 288%Docstring 289Converts the transformer to a QGIS expression string. The ``baseExpression`` string consists 290of a sub-expression reflecting the parent property's state. 291%End 292 293 static QgsPropertyTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/; 294%Docstring 295Attempts to parse an expression into a corresponding property transformer. 296 297:param expression: expression to parse 298 299:return: - corresponding property transformer, or ``None`` if expression could not 300 - baseExpression: will be set to 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. 301 - fieldName: will be set to 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. 302 be parsed to a transformer. 303%End 304 305 protected: 306 307 double transformNumeric( double input ) const; 308%Docstring 309Applies base class numeric transformations. Derived classes should call this 310to transform an ``input`` numeric value before they apply any transform to the result. 311This applies any curve transforms which may exist on the transformer. 312%End 313}; 314 315 316class QgsGenericNumericTransformer : QgsPropertyTransformer 317{ 318%Docstring 319QgsPropertyTransformer subclass for scaling an input numeric value into an output numeric value. 320 321.. versionadded:: 3.0 322%End 323 324%TypeHeaderCode 325#include "qgspropertytransformer.h" 326%End 327 public: 328 329 QgsGenericNumericTransformer( double minValue = 0.0, 330 double maxValue = 1.0, 331 double minOutput = 0.0, 332 double maxOutput = 1.0, 333 double nullOutput = 0.0, 334 double exponent = 1.0 ); 335%Docstring 336Constructor for QgsGenericNumericTransformer. 337 338:param minValue: minimum expected input value 339:param maxValue: maximum expected input value 340:param minOutput: minimum value to return 341:param maxOutput: maximum value to return 342:param nullOutput: value to return for null inputs 343:param exponent: optional exponential for non-linear scaling 344%End 345 346 virtual Type transformerType() const; 347 virtual QgsGenericNumericTransformer *clone() const /Factory/; 348 349 virtual QVariant toVariant() const; 350 351 virtual bool loadVariant( const QVariant &definition ); 352 353 virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const; 354 355 virtual QString toExpression( const QString &baseExpression ) const; 356 357 358 static QgsGenericNumericTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/; 359%Docstring 360Attempts to parse an expression into a corresponding :py:class:`QgsSizeScaleTransformer`. 361 362:param expression: expression to parse 363 364:return: - corresponding :py:class:`QgsSizeScaleTransformer`, or ``None`` if expression could not 365 - baseExpression: will be set to 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. 366 - fieldName: will be set to 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. 367 be parsed to a size scale transformer. 368%End 369 370 double value( double input ) const; 371%Docstring 372Calculates the size corresponding to a specific ``input`` value. 373 374:return: calculated size using size scale transformer's parameters and type 375%End 376 377 double minOutputValue() const; 378%Docstring 379Returns the minimum calculated size. 380 381.. seealso:: :py:func:`setMinOutputValue` 382 383.. seealso:: :py:func:`maxOutputValue` 384%End 385 386 void setMinOutputValue( double size ); 387%Docstring 388Sets the minimum calculated size. 389 390:param size: minimum size 391 392.. seealso:: :py:func:`minOutputValue` 393 394.. seealso:: :py:func:`setMaxOutputValue` 395%End 396 397 double maxOutputValue() const; 398%Docstring 399Returns the maximum calculated size. 400 401.. seealso:: :py:func:`minOutputValue` 402%End 403 404 void setMaxOutputValue( double size ); 405%Docstring 406Sets the maximum calculated size. 407 408:param size: maximum size 409 410.. seealso:: :py:func:`maxOutputValue` 411 412.. seealso:: :py:func:`setMinOutputValue` 413%End 414 415 double nullOutputValue() const; 416%Docstring 417Returns the size value when an expression evaluates to NULL. 418 419.. seealso:: :py:func:`setNullOutputValue` 420%End 421 422 void setNullOutputValue( double size ); 423%Docstring 424Sets the size value for when an expression evaluates to NULL. 425 426:param size: null size 427 428.. seealso:: :py:func:`nullOutputValue` 429%End 430 431 double exponent() const; 432%Docstring 433Returns the exponent for an exponential expression. 434 435.. seealso:: :py:func:`setExponent` 436%End 437 438 void setExponent( double exponent ); 439%Docstring 440Sets the exponent for an exponential expression. 441 442:param exponent: exponent 443 444.. seealso:: :py:func:`exponent` 445%End 446 447}; 448 449 450class QgsSizeScaleTransformer : QgsPropertyTransformer 451{ 452%Docstring 453QgsPropertyTransformer subclass for scaling a value into a size according to various 454scaling methods. 455 456.. versionadded:: 3.0 457%End 458 459%TypeHeaderCode 460#include "qgspropertytransformer.h" 461%End 462 public: 463 464 enum ScaleType 465 { 466 Linear, 467 Area, 468 Flannery, 469 Exponential, 470 }; 471 472 QgsSizeScaleTransformer( ScaleType type = Linear, 473 double minValue = 0.0, 474 double maxValue = 1.0, 475 double minSize = 0.0, 476 double maxSize = 1.0, 477 double nullSize = 0.0, 478 double exponent = 1.0 ); 479%Docstring 480Constructor for QgsSizeScaleTransformer. 481 482:param type: scaling type 483:param minValue: minimum expected value 484:param maxValue: maximum expected value 485:param minSize: minimum size to return 486:param maxSize: maximum size to return 487:param nullSize: size to return for null values 488:param exponent: exponent for Exponential scaling method 489%End 490 491 virtual Type transformerType() const; 492 virtual QgsSizeScaleTransformer *clone() const /Factory/; 493 494 virtual QVariant toVariant() const; 495 496 virtual bool loadVariant( const QVariant &definition ); 497 498 virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const; 499 500 virtual QString toExpression( const QString &baseExpression ) const; 501 502 503 static QgsSizeScaleTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/; 504%Docstring 505Attempts to parse an expression into a corresponding QgsSizeScaleTransformer. 506 507:param expression: expression to parse 508 509:return: - corresponding QgsSizeScaleTransformer, or ``None`` if expression could not 510 - baseExpression: will be set to 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. 511 - fieldName: will be set to 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. 512 be parsed to a size scale transformer. 513%End 514 515 double size( double value ) const; 516%Docstring 517Calculates the size corresponding to a specific value. 518 519:param value: value to calculate size for 520 521:return: calculated size using size scale transformer's parameters and type 522%End 523 524 double minSize() const; 525%Docstring 526Returns the minimum calculated size. 527 528.. seealso:: :py:func:`setMinSize` 529 530.. seealso:: :py:func:`maxSize` 531%End 532 533 void setMinSize( double size ); 534%Docstring 535Sets the minimum calculated size. 536 537:param size: minimum size 538 539.. seealso:: :py:func:`minSize` 540 541.. seealso:: :py:func:`setMaxSize` 542%End 543 544 double maxSize() const; 545%Docstring 546Returns the maximum calculated size. 547 548.. seealso:: :py:func:`minSize` 549%End 550 551 void setMaxSize( double size ); 552%Docstring 553Sets the maximum calculated size. 554 555:param size: maximum size 556 557.. seealso:: :py:func:`maxSize` 558 559.. seealso:: :py:func:`setMinSize` 560%End 561 562 double nullSize() const; 563%Docstring 564Returns the size value when an expression evaluates to NULL. 565 566.. seealso:: :py:func:`setNullSize` 567%End 568 569 void setNullSize( double size ); 570%Docstring 571Sets the size value for when an expression evaluates to NULL. 572 573:param size: null size 574 575.. seealso:: :py:func:`nullSize` 576%End 577 578 double exponent() const; 579%Docstring 580Returns the exponent for an exponential expression. 581 582.. seealso:: :py:func:`setExponent` 583 584.. seealso:: :py:func:`type` 585%End 586 587 void setExponent( double exponent ); 588%Docstring 589Sets the exponent for an exponential expression. 590 591:param exponent: exponent 592 593.. seealso:: :py:func:`exponent` 594%End 595 596 ScaleType type() const; 597%Docstring 598Returns the size transformer's scaling type (the method used to calculate 599the size from a value). 600 601.. seealso:: :py:func:`setType` 602%End 603 604 void setType( ScaleType type ); 605%Docstring 606Sets the size transformer's scaling type (the method used to calculate 607the size from a value). 608 609:param type: scale type 610 611.. seealso:: :py:func:`type` 612%End 613 614}; 615 616 617class QgsColorRampTransformer : QgsPropertyTransformer 618{ 619%Docstring 620QgsPropertyTransformer subclass for transforming a numeric value into a color from a 621color ramp. 622 623.. versionadded:: 3.0 624%End 625 626%TypeHeaderCode 627#include "qgspropertytransformer.h" 628%End 629 public: 630 631 QgsColorRampTransformer( double minValue = 0.0, 632 double maxValue = 1.0, 633 QgsColorRamp *ramp /Transfer/ = 0, 634 const QColor &nullColor = QColor( 0, 0, 0, 0 ) ); 635%Docstring 636Constructor for QgsColorRampTransformer. 637 638:param minValue: minimum expected value 639:param maxValue: maximum expected value 640:param ramp: source color ramp. Ownership is transferred to the transformer. 641:param nullColor: color to return for null values 642%End 643 644 QgsColorRampTransformer( const QgsColorRampTransformer &other ); 645%Docstring 646Copy constructor 647%End 648 649 650 virtual Type transformerType() const; 651 virtual QgsColorRampTransformer *clone() const /Factory/; 652 653 virtual QVariant toVariant() const; 654 655 virtual bool loadVariant( const QVariant &definition ); 656 657 virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const; 658 659 virtual QString toExpression( const QString &baseExpression ) const; 660 661 662 QColor color( double value ) const; 663%Docstring 664Calculates the color corresponding to a specific value. 665 666:param value: value to calculate color for 667 668:return: calculated color using transformer's parameters and type 669%End 670 671 QgsColorRamp *colorRamp() const; 672%Docstring 673Returns the color ramp used for calculating property colors. 674 675:return: color ramp 676 677.. seealso:: :py:func:`setColorRamp` 678%End 679 680 void setColorRamp( QgsColorRamp *ramp /Transfer/ ); 681%Docstring 682Sets the color ramp to use for calculating property colors. 683 684:param ramp: color ramp, ownership of ramp is transferred to the transformer. 685 686.. seealso:: :py:func:`colorRamp` 687%End 688 689 QColor nullColor() const; 690%Docstring 691Returns the color corresponding to a null value. 692 693.. seealso:: :py:func:`setNullColor` 694%End 695 696 void setNullColor( const QColor &color ); 697%Docstring 698Sets the color corresponding to a null value. 699 700:param color: null color 701 702.. seealso:: :py:func:`nullColor` 703%End 704 705 QString rampName() const; 706%Docstring 707Returns the color ramp's name. 708 709.. seealso:: :py:func:`setRampName` 710%End 711 712 void setRampName( const QString &name ); 713%Docstring 714Sets the color ramp's ``name``. The ramp name must be set to match 715a color ramp available in the style database for conversion to expression 716to work correctly. 717 718.. seealso:: :py:func:`rampName` 719%End 720 721}; 722 723/************************************************************************ 724 * This file has been generated automatically from * 725 * * 726 * src/core/qgspropertytransformer.h * 727 * * 728 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 729 ************************************************************************/ 730