QGIS API Documentation  2.12.0-Lyon
Public Types | Public Member Functions | List of all members
QgsScaleExpression Class Reference

Class storing parameters of a scale expression, which is a subclass of QgsExpression for expressions which return a size or width. More...

#include <qgsscaleexpression.h>

Inheritance diagram for QgsScaleExpression:
Inheritance graph
[legend]

Public Types

enum  Type { Linear, Area, Flannery, Unknown }
 
- Public Types inherited from QgsExpression
enum  BinaryOperator {
  boOr, boAnd, boEQ, boNE,
  boLE, boGE, boLT, boGT,
  boRegexp, boLike, boNotLike, boILike,
  boNotILike, boIs, boIsNot, boPlus,
  boMinus, boMul, boDiv, boIntDiv,
  boMod, boPow, boConcat
}
 list of binary operators More...
 
typedef QVariant(* FcnEval) (const QVariantList &values, const QgsFeature *f, QgsExpression *parent)
 
typedef QVariant(* FcnEvalContext) (const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
 Function definition for evaluation against an expression context. More...
 
enum  NodeType {
  ntUnaryOperator, ntBinaryOperator, ntInOperator, ntFunction,
  ntLiteral, ntColumnRef, ntCondition
}
 
enum  SpatialOperator {
  soBbox, soIntersects, soContains, soCrosses,
  soEquals, soDisjoint, soOverlaps, soTouches,
  soWithin
}
 
enum  UnaryOperator { uoNot, uoMinus }
 list of unary operators More...
 
typedef QList< WhenThen * > WhenThenList
 

Public Member Functions

 QgsScaleExpression (const QString &expression)
 Constructor for QgsScaleExpression which parses an expression string to determine whether it's a scale expression. More...
 
 QgsScaleExpression (Type type, const QString &baseExpression, double minValue, double maxValue, double minSize, double maxSize, double nullSize=0)
 Constructor for QgsScaleExpression which creates an expression from specified parameters. More...
 
QString baseExpression () const
 Returns the base expression string (or field reference) used for calculating the values to be mapped to a size. More...
 
double maxSize () const
 Returns the maximum size calculated by the expression. More...
 
double maxValue () const
 Returns the maximum value expected by the expression. More...
 
double minSize () const
 Returns the minimum size calculated by the expression. More...
 
double minValue () const
 Returns the minimum value expected by the expression. More...
 
double nullSize () const
 Returns the size value when expression evaluates to NULL. More...
 
 operator bool () const
 
double size (double value) const
 Calculates the size corresponding to a specific value. More...
 
Type type () const
 Returns the scale expression's type (method used to calculate the size from a value). More...
 
- Public Member Functions inherited from QgsExpression
 QgsExpression (const QString &expr)
 
 ~QgsExpression ()
 
void acceptVisitor (Visitor &v) const
 Entry function for the visitor pattern. More...
 
Q_DECL_DEPRECATED int currentRowNumber ()
 Return the number used for $rownum special column. More...
 
QString dump () const
 Return the expression string that represents this QgsExpression. More...
 
QString evalErrorString () const
 Returns evaluation error. More...
 
Q_DECL_DEPRECATED QVariant evaluate (const QgsFeature *f)
 Evaluate the feature and return the result. More...
 
Q_DECL_DEPRECATED QVariant evaluate (const QgsFeature &f)
 Evaluate the feature and return the result. More...
 
Q_DECL_DEPRECATED QVariant evaluate (const QgsFeature *f, const QgsFields &fields)
 Evaluate the feature and return the result. More...
 
Q_DECL_DEPRECATED QVariant evaluate (const QgsFeature &f, const QgsFields &fields)
 Evaluate the feature and return the result. More...
 
QVariant evaluate ()
 Evaluate the feature and return the result. More...
 
QVariant evaluate (const QgsExpressionContext *context)
 Evaluate the expression against the specified context and return the result. More...
 
const QString expression () const
 Alias for dump() More...
 
QgsDistanceAreageomCalculator ()
 Return calculator used for distance and area calculations (used by internal functions) More...
 
bool hasEvalError () const
 Returns true if an error occurred when evaluating last input. More...
 
bool hasParserError () const
 Returns true if an error occurred when parsing the input expression. More...
 
bool isField () const
 Checks whether an expression consists only of a single field reference. More...
 
bool needsGeometry () const
 Returns true if the expression uses feature geometry for some computation. More...
 
QString parserErrorString () const
 Returns parser error. More...
 
Q_DECL_DEPRECATED bool prepare (const QgsFields &fields)
 Get the expression ready for evaluation - find out column indexes. More...
 
bool prepare (const QgsExpressionContext *context)
 Get the expression ready for evaluation - find out column indexes. More...
 
QStringList referencedColumns () const
 Get list of columns referenced by the expression. More...
 
const NoderootNode () const
 Returns root node of the expression. Root node is null is parsing has failed. More...
 
double scale ()
 
Q_DECL_DEPRECATED void setCurrentRowNumber (int rowNumber)
 Set the number for $rownum special column. More...
 
void setEvalErrorString (const QString &str)
 Set evaluation error (used internally by evaluation functions) More...
 
void setGeomCalculator (const QgsDistanceArea &calc)
 Sets the geometry calculator used in evaluation of expressions,. More...
 
void setScale (double scale)
 

Additional Inherited Members

- Static Public Member Functions inherited from QgsExpression
static const QStringListBuiltinFunctions ()
 
static void cleanRegisteredFunctions ()
 Deletes all registered functions whose ownership have been transferred to the expression engine. More...
 
static double evaluateToDouble (const QString &text, const double fallbackValue)
 Attempts to evaluate a text string as an expression to a resultant double value. More...
 
static int functionCount ()
 Returns the number of functions defined in the parser. More...
 
static int functionIndex (const QString &name)
 
static const QList< Function * > & Functions ()
 
static QString group (const QString &group)
 Returns the translated name for a function group. More...
 
static bool hasSpecialColumn (const QString &name)
 Check whether a special column exists. More...
 
static QString helptext (QString name)
 Returns the help text for a specified function. More...
 
static bool isFunctionName (const QString &name)
 
static Q_DECL_DEPRECATED bool isValid (const QString &text, const QgsFields &fields, QString &errorMessage)
 
static bool isValid (const QString &text, const QgsExpressionContext *context, QString &errorMessage)
 Tests whether a string is a valid expression. More...
 
static QString quotedColumnRef (QString name)
 return quoted column reference (in double quotes) More...
 
static QString quotedString (QString text)
 return quoted string (in single quotes) More...
 
static bool registerFunction (Function *function, bool transferOwnership=false)
 Registers a function to the expression engine. More...
 
static Q_DECL_DEPRECATED QString replaceExpressionText (const QString &action, const QgsFeature *feat, QgsVectorLayer *layer, const QMap< QString, QVariant > *substitutionMap=0, const QgsDistanceArea *distanceArea=0)
 This function currently replaces each expression between [% and %] in the string with the result of its evaluation on the feature passed as argument. More...
 
static QString replaceExpressionText (const QString &action, const QgsExpressionContext *context, const QMap< QString, QVariant > *substitutionMap=0, const QgsDistanceArea *distanceArea=0)
 This function replaces each expression between [% and %] in the string with the result of its evaluation with the specified context. More...
 
static Q_DECL_DEPRECATED void setSpecialColumn (const QString &name, const QVariant &value)
 Assign a special column. More...
 
static Q_DECL_DEPRECATED QVariant specialColumn (const QString &name)
 Return the value of the given special column or a null QVariant if undefined. More...
 
static QList< Function * > specialColumns ()
 Returns a list of special Column definitions. More...
 
static bool unregisterFunction (const QString &name)
 Unregisters a function from the expression engine. More...
 
static Q_DECL_DEPRECATED void unsetSpecialColumn (const QString &name)
 Unset a special column. More...
 
static QString variableHelpText (const QString &variableName, bool showValue=true, const QVariant &value=QVariant())
 Returns the help text for a specified variable. More...
 
- Static Public Attributes inherited from QgsExpression
static const char * BinaryOperatorText []
 
static QStringList gmBuiltinFunctions
 
static QList< Function * > gmFunctions
 
static QList< Function * > gmOwnedFunctions
 List of functions owned by the expression engine. More...
 
static const char * UnaryOperatorText []
 
- Protected Member Functions inherited from QgsExpression
 QgsExpression ()
 Used by QgsOgcUtils to create an empty. More...
 
void initGeomCalculator ()
 
- Static Protected Member Functions inherited from QgsExpression
static void initFunctionHelp ()
 
static void initVariableHelp ()
 
- Protected Attributes inherited from QgsExpression
QgsDistanceAreamCalc
 
QString mEvalErrorString
 
QString mExp
 
QString mParserErrorString
 
NodemRootNode
 
int mRowNumber
 
double mScale
 
- Static Protected Attributes inherited from QgsExpression
static QHash< QString, HelpgFunctionHelpTexts
 
static QHash< QString, QStringgGroups
 
static QMap< QString, QStringgmSpecialColumnGroups
 
static QMap< QString, QVariantgmSpecialColumns
 
static QHash< QString, QStringgVariableHelpTexts
 

Detailed Description

Class storing parameters of a scale expression, which is a subclass of QgsExpression for expressions which return a size or width.

Note
Added in version 2.9

Definition at line 28 of file qgsscaleexpression.h.

Member Enumeration Documentation

Enumerator
Linear 
Area 
Flannery 
Unknown 

Definition at line 32 of file qgsscaleexpression.h.

Constructor & Destructor Documentation

QgsScaleExpression::QgsScaleExpression ( const QString expression)

Constructor for QgsScaleExpression which parses an expression string to determine whether it's a scale expression.

Parameters
expressionexpression string

Definition at line 21 of file qgsscaleexpression.cpp.

QgsScaleExpression::QgsScaleExpression ( Type  type,
const QString baseExpression,
double  minValue,
double  maxValue,
double  minSize,
double  maxSize,
double  nullSize = 0 
)

Constructor for QgsScaleExpression which creates an expression from specified parameters.

Parameters
typescale method
baseExpressionexpression (or field) used for value
minValueminimum value, corresponds to specified minimum size
maxValuemaximum value, corresponds to specified maximum size
minSizeminimum size
maxSizemaximum size
nullSizesize in case expression evaluates to NULL

Definition at line 33 of file qgsscaleexpression.cpp.

Member Function Documentation

QString QgsScaleExpression::baseExpression ( ) const
inline

Returns the base expression string (or field reference) used for calculating the values to be mapped to a size.

Definition at line 96 of file qgsscaleexpression.h.

double QgsScaleExpression::maxSize ( ) const
inline

Returns the maximum size calculated by the expression.

See also
minSize

Definition at line 74 of file qgsscaleexpression.h.

double QgsScaleExpression::maxValue ( ) const
inline

Returns the maximum value expected by the expression.

The maximum value corresponds to the expression's maximum size.

See also
minValue

Definition at line 86 of file qgsscaleexpression.h.

double QgsScaleExpression::minSize ( ) const
inline

Returns the minimum size calculated by the expression.

See also
maxSize

Definition at line 69 of file qgsscaleexpression.h.

double QgsScaleExpression::minValue ( ) const
inline

Returns the minimum value expected by the expression.

The minimum value corresponds to the expression's minimum size.

See also
maxValue

Definition at line 80 of file qgsscaleexpression.h.

double QgsScaleExpression::nullSize ( ) const
inline

Returns the size value when expression evaluates to NULL.

See also
nullSize

Definition at line 91 of file qgsscaleexpression.h.

QgsScaleExpression::operator bool ( ) const
inline

Definition at line 58 of file qgsscaleexpression.h.

double QgsScaleExpression::size ( double  value) const

Calculates the size corresponding to a specific value.

Parameters
value
Returns
calculated size using expression's parameters and type

Definition at line 139 of file qgsscaleexpression.cpp.

Type QgsScaleExpression::type ( ) const
inline

Returns the scale expression's type (method used to calculate the size from a value).

Definition at line 101 of file qgsscaleexpression.h.


The documentation for this class was generated from the following files: