LCOV - code coverage report
Current view: top level - core/labeling - qgslabelobstaclesettings.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 0 19 0.0 %
Date: 2021-04-10 08:29:14 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :   qgslabelobstaclesettings.cpp
       3                 :            :   ----------------------------
       4                 :            :   Date                 : December 2019
       5                 :            :   Copyright            : (C) 2019 by Nyall Dawson
       6                 :            :   Email                : nyall dot dawson at gmail 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                 :            : #include "qgslabelobstaclesettings.h"
      17                 :            : #include "qgspropertycollection.h"
      18                 :            : #include "qgsexpressioncontext.h"
      19                 :            : #include "qgspallabeling.h"
      20                 :            : 
      21                 :          0 : void QgsLabelObstacleSettings::setObstacleGeometry( const QgsGeometry &obstacleGeom )
      22                 :            : {
      23                 :          0 :   mObstacleGeometry = obstacleGeom;
      24                 :          0 : }
      25                 :            : 
      26                 :          0 : QgsGeometry QgsLabelObstacleSettings::obstacleGeometry() const
      27                 :            : {
      28                 :          0 :   return mObstacleGeometry;
      29                 :            : }
      30                 :            : 
      31                 :          0 : void QgsLabelObstacleSettings::updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context )
      32                 :            : {
      33                 :          0 :   if ( properties.isActive( QgsPalLayerSettings::ObstacleFactor ) )
      34                 :            :   {
      35                 :          0 :     context.setOriginalValueVariable( mObstacleFactor );
      36                 :          0 :     QVariant exprVal = properties.value( QgsPalLayerSettings::ObstacleFactor, context );
      37                 :          0 :     if ( exprVal.isValid() )
      38                 :            :     {
      39                 :            :       bool ok;
      40                 :          0 :       double factorD = exprVal.toDouble( &ok );
      41                 :          0 :       if ( ok )
      42                 :            :       {
      43                 :          0 :         factorD = std::clamp( factorD, 0.0, 10.0 );
      44                 :          0 :         factorD = factorD / 5.0 + 0.0001; // convert 0 -> 10 to 0.0001 -> 2.0
      45                 :          0 :         mObstacleFactor = factorD;
      46                 :          0 :       }
      47                 :          0 :     }
      48                 :          0 :   }
      49                 :            : 
      50                 :          0 : }

Generated by: LCOV version 1.14