QGIS API Documentation  2.12.0-Lyon
qgsscaleexpression.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsscaleexpression.h
3  ---------------------
4  begin : November 2014
5  copyright : (C) 2014 by Vincent Mora
6  email : vincent dor mora at oslandia dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSSCALEEXPRESSION_H
17 #define QGSSCALEEXPRESSION_H
18 
19 #include "qgsexpression.h"
20 
28 class CORE_EXPORT QgsScaleExpression : public QgsExpression
29 {
30  public:
31 
32  enum Type
33  {
38  };
39 
44  QgsScaleExpression( const QString &expression );
45 
56  QgsScaleExpression( Type type, const QString& baseExpression, double minValue, double maxValue, double minSize, double maxSize, double nullSize = 0 );
57 
58  operator bool() const { return ! mExpression.isEmpty(); }
59 
64  double size( double value ) const;
65 
69  double minSize() const { return mMinSize; }
70 
74  double maxSize() const { return mMaxSize; }
75 
80  double minValue() const { return mMinValue; }
81 
86  double maxValue() const { return mMaxValue; }
87 
91  double nullSize() const { return mNullSize; }
92 
96  QString baseExpression() const { return mExpression; }
97 
101  Type type() const { return mType; }
102 
103  private:
104  QString mExpression;
105  Type mType;
106  double mMinSize;
107  double mMaxSize;
108  double mMinValue;
109  double mMaxValue;
110  double mNullSize;
111 
112  void init();
113  static QString createExpression( Type type, const QString& baseExpr, double minValue, double maxValue, double minSize, double maxSize, double nullSize );
114 
115 };
116 
117 #endif
118 
119 
120 
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:92
Class storing parameters of a scale expression, which is a subclass of QgsExpression for expressions ...
double nullSize() const
Returns the size value when expression evaluates to NULL.
double maxValue() const
Returns the maximum value expected by the expression.
QString baseExpression() const
Returns the base expression string (or field reference) used for calculating the values to be mapped ...
Type type() const
Returns the scale expression's type (method used to calculate the size from a value).
double minSize() const
Returns the minimum size calculated by the expression.
double minValue() const
Returns the minimum value expected by the expression.
double maxSize() const
Returns the maximum size calculated by the expression.