~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/core/qgsscalecalculator.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
                          qgsscalecalculator.h    
 
2
                          qgsscalecalculator.h
3
3
              Calculates scale based on map extent and units
4
4
                             -------------------
5
5
    begin                : May 18, 2004
15
15
 *   (at your option) any later version.                                   *
16
16
 *                                                                         *
17
17
 ***************************************************************************/
18
 
/* $Id: qgsscalecalculator.h 4502 2006-01-08 01:18:20Z timlinux $ */
 
18
/* $Id$ */
19
19
 
20
20
#ifndef QGSSCALECALCULATOR_H
21
21
#define QGSSCALECALCULATOR_H
23
23
#include <qgis.h>
24
24
 
25
25
class QString;
26
 
class QgsRect;
 
26
class QgsRectangle;
27
27
 
28
 
/**
29
 
 * \class QgsScaleCalculator
30
 
 * \brief Calculates scale for a given combination of canvas size, map extent,
 
28
/** \ingroup core
 
29
 * Calculates scale for a given combination of canvas size, map extent,
31
30
 * and monitor dpi.
32
31
 */
33
 
class QgsScaleCalculator
 
32
class CORE_EXPORT QgsScaleCalculator
34
33
{
35
34
  public:
36
35
 
38
37
     * Constructor
39
38
     * @param dpi Monitor resolution in dots per inch
40
39
     * @param mapUnits Units of the data on the map. Must match a value from the
41
 
     * QGis::units enum (METERS, FEET, DEGREES)
 
40
     * QGis::UnitType enum (Meters, Feet, Degrees)
42
41
     */
43
 
    QgsScaleCalculator(int dpi = 0, 
44
 
                       QGis::units mapUnits = QGis::METERS);
 
42
    QgsScaleCalculator( double dpi = 0,
 
43
                        QGis::UnitType mapUnits = QGis::Meters );
45
44
 
46
45
    //! Destructor
47
46
    ~QgsScaleCalculator();
50
49
     * Set the dpi to be used in scale calculations
51
50
     * @param dpi Dots per inch of monitor resolution
52
51
     */
53
 
    void setDpi(int dpi);
 
52
    void setDpi( double dpi );
 
53
    /**
 
54
     * Accessor for dpi used in scale calculations
 
55
     * @return int the dpi used for scale calculations.
 
56
     */
 
57
    double dpi();
54
58
 
55
59
    /**
56
60
     * Set the map units
57
61
     * @param mapUnits Units of the data on the map. Must match a value from the
58
62
     */
59
 
    void setMapUnits(QGis::units mapUnits);
 
63
    void setMapUnits( QGis::UnitType mapUnits );
 
64
 
 
65
    /** Returns current map units */
 
66
    QGis::UnitType mapUnits() const;
60
67
 
61
68
    /**
62
69
     * Calculate the scale
63
 
     * @param mapExtent QgsRect containing the current map extent
 
70
     * @param mapExtent QgsRectangle containing the current map extent
64
71
     * @param canvasWidth Width of the map canvas in pixel (physical) units
65
72
     * @return scale of current map view
66
73
     */
67
 
    double calculate(QgsRect &mapExtent, int canvasWidth);
 
74
    double calculate( const QgsRectangle &mapExtent, int canvasWidth );
68
75
 
69
76
    /**
70
 
     * Calculate the distance between to points in geographic coordinates.
 
77
     * Calculate the distance between two points in geographic coordinates.
71
78
     * Used to calculate scale for map views with geographic (decimal degree)
72
79
     * data.
73
 
     * @param mapExtent QgsRect containing the current map extent
 
80
     * @param mapExtent QgsRectangle containing the current map extent
74
81
     */
75
 
    double calculateGeographicDistance(QgsRect &mapExtent);
 
82
    double calculateGeographicDistance( const QgsRectangle &mapExtent );
76
83
 
77
84
  private:
78
85
 
79
86
    //! dpi member
80
 
    int mDpi;
 
87
    double mDpi;
81
88
 
82
89
    //! map unit member
83
 
    QGis::units mMapUnits;
 
90
    QGis::UnitType mMapUnits;
84
91
};
85
92
 
86
93
#endif // #ifndef QGSSCALECALCULATOR_H