LCOV - code coverage report
Current view: top level - core - qgstolerance.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 1 1 100.0 %
Date: 2021-04-10 08:29:14 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :     qgstolerance.h  -  wrapper for tolerance handling
       3                 :            :     ----------------------
       4                 :            :     begin                : March 2009
       5                 :            :     copyright            : (C) 2009 by Richard Kostecky
       6                 :            :     email                : csf.kostej 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                 :            : #ifndef QGSTOLERANCE_H
      17                 :            : #define QGSTOLERANCE_H
      18                 :            : 
      19                 :            : #include <QObject>
      20                 :            : 
      21                 :            : #include "qgis_core.h"
      22                 :            : #include "qgis_sip.h"
      23                 :            : 
      24                 :            : class QgsMapSettings;
      25                 :            : class QgsMapLayer;
      26                 :            : class QgsPointXY;
      27                 :            : 
      28                 :            : /**
      29                 :            :  * \ingroup core
      30                 :            :  * \brief This is the class is providing tolerance value in map unit values.
      31                 :            :  */
      32                 :            : class CORE_EXPORT QgsTolerance
      33                 :            : {
      34                 :            :     Q_GADGET
      35                 :            :   public:
      36                 :            : 
      37                 :            :     /**
      38                 :            :      * Type of unit of tolerance value from settings.
      39                 :            :      * For map (project) units, use ProjectUnits.
      40                 :            :     */
      41                 :            :     enum UnitType
      42                 :            :     {
      43                 :            :       //! Layer unit value
      44                 :            :       LayerUnits,
      45                 :            :       //! Pixels unit of tolerance
      46                 :            :       Pixels,
      47                 :            :       //! Map (project) units. Added in 2.8
      48                 :            :       ProjectUnits
      49                 :            :     };
      50                 :         28 :     Q_ENUM( UnitType )
      51                 :            : 
      52                 :            :     /**
      53                 :            :      * Static function to get vertex tolerance value.
      54                 :            :      * The value is read from settings and transformed if necessary.
      55                 :            :      * \returns value of vertex tolerance in map units (not layer units)
      56                 :            :      * \since QGIS 2.8
      57                 :            :      */
      58                 :            :     static double vertexSearchRadius( const QgsMapSettings &mapSettings );
      59                 :            : 
      60                 :            :     /**
      61                 :            :      * Static function to get vertex tolerance value for a layer.
      62                 :            :      * The value is read from settings and transformed if necessary.
      63                 :            :      * \returns value of vertex tolerance in layer units
      64                 :            :      */
      65                 :            :     static double vertexSearchRadius( QgsMapLayer *layer, const QgsMapSettings &mapSettings );
      66                 :            : 
      67                 :            :     /**
      68                 :            :      * Static function to get default tolerance value for a layer.
      69                 :            :      * The value is read from settings and transformed if necessary.
      70                 :            :      * \returns value of default tolerance in layer units
      71                 :            :      */
      72                 :            :     static double defaultTolerance( QgsMapLayer *layer, const QgsMapSettings &mapSettings );
      73                 :            : 
      74                 :            :     /**
      75                 :            :      * Static function to translate tolerance value into map units
      76                 :            :      * \param tolerance tolerance value to be translated
      77                 :            :      * \param layer source layer necessary in case tolerance is in layer units
      78                 :            :      * \param mapSettings settings of the map
      79                 :            :      * \param units type of units to be translated
      80                 :            :      * \returns value of tolerance in map units
      81                 :            :      * \since QGIS 2.8
      82                 :            :      */
      83                 :            :     static double toleranceInProjectUnits( double tolerance, QgsMapLayer *layer, const QgsMapSettings &mapSettings, QgsTolerance::UnitType units );
      84                 :            : 
      85                 :            :     /**
      86                 :            :      * Static function to translate tolerance value into layer units
      87                 :            :      * \param tolerance tolerance value to be translated
      88                 :            :      * \param layer reference layer
      89                 :            :      * \param mapSettings settings of the map
      90                 :            :      * \param units type of units to be translated
      91                 :            :      * \returns value of tolerance in layer units
      92                 :            :      */
      93                 :            :     static double toleranceInMapUnits( double tolerance, QgsMapLayer *layer, const QgsMapSettings &mapSettings, UnitType units = LayerUnits );
      94                 :            : 
      95                 :            :   private:
      96                 :            :     static double computeMapUnitPerPixel( QgsMapLayer *layer, const QgsMapSettings &mapSettings );
      97                 :            :     static QgsPointXY toLayerCoordinates( QgsMapLayer *layer, const QgsMapSettings &mapSettings, QPoint point );
      98                 :            : 
      99                 :            : };
     100                 :            : 
     101                 :            : #endif

Generated by: LCOV version 1.14