~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to src/qgsscalecalculator.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Halasz
  • Date: 2004-12-21 09:46:27 UTC
  • Revision ID: james.westby@ubuntu.com-20041221094627-r9lb6mlz2o3yp8gn
Tags: upstream-0.6.0
ImportĀ upstreamĀ versionĀ 0.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          qgsscalecalculator.h    
 
3
              Calculates scale based on map extent and units
 
4
                             -------------------
 
5
    begin                : May 18, 2004
 
6
    copyright            : (C) 2004 by Gary E.Sherman
 
7
    email                : sherman at mrcc.com
 
8
 ***************************************************************************/
 
9
 
 
10
/***************************************************************************
 
11
 *                                                                         *
 
12
 *   This program is free software; you can redistribute it and/or modify  *
 
13
 *   it under the terms of the GNU General Public License as published by  *
 
14
 *   the Free Software Foundation; either version 2 of the License, or     *
 
15
 *   (at your option) any later version.                                   *
 
16
 *                                                                         *
 
17
 ***************************************************************************/
 
18
/* $Id: qgsscalecalculator.h,v 1.2 2004/10/26 17:28:03 mcoletti Exp $ */
 
19
 
 
20
#ifndef QGSSCALECALCULATOR_H
 
21
#define QGSSCALECALCULATOR_H
 
22
 
 
23
class QString;
 
24
class QgsRect;
 
25
 
 
26
/**
 
27
 * \class QgsScaleCalculator
 
28
 * \brief Calculates scale for a given combination of canvas size, map extent,
 
29
 * and monitor dpi.
 
30
 */
 
31
class QgsScaleCalculator
 
32
{
 
33
  public:
 
34
 
 
35
    /**
 
36
     * Enum for defining map units
 
37
     */
 
38
    typedef enum
 
39
    {
 
40
        METERS,
 
41
        FEET,
 
42
        DEGREES
 
43
    } units;
 
44
 
 
45
 
 
46
    /**
 
47
     * Constructor
 
48
     * @param dpi Monitor resolution in dots per inch
 
49
     * @param mapUnits Units of the data on the map. Must match a value from the
 
50
     * QgsScaleCalculator::units enum (METERS, FEET, DEGREES)
 
51
     */
 
52
    QgsScaleCalculator(int dpi = 0, 
 
53
                       units mapUnits = METERS);
 
54
 
 
55
    //! Destructor
 
56
    ~QgsScaleCalculator();
 
57
 
 
58
    /**
 
59
     * Set the dpi to be used in scale calculations
 
60
     * @param dpi Dots per inch of monitor resolution
 
61
     */
 
62
    void setDpi(int dpi);
 
63
 
 
64
    /**
 
65
     * Set the map units
 
66
     * @param mapUnits Units of the data on the map. Must match a value from the
 
67
     */
 
68
    void setMapUnits(QgsScaleCalculator::units mapUnits);
 
69
 
 
70
    /**
 
71
     * Calculate the scale
 
72
     * @param mapExtent QgsRect containing the current map extent
 
73
     * @param canvasWidth Width of the map canvas in pixel (physical) units
 
74
     * @return scale of current map view
 
75
     */
 
76
    double calculate(QgsRect &mapExtent, int canvasWidth);
 
77
 
 
78
    /**
 
79
     * Calculate the distance between to points in geographic coordinates.
 
80
     * Used to calculate scale for map views with geographic (decimal degree)
 
81
     * data.
 
82
     * @param mapExtent QgsRect containing the current map extent
 
83
     */
 
84
    double calculateGeographicDistance(QgsRect &mapExtent);
 
85
 
 
86
  private:
 
87
 
 
88
    //! dpi member
 
89
    int mDpi;
 
90
 
 
91
    //! map unit member
 
92
    units mMapUnits;
 
93
};
 
94
 
 
95
#endif // #ifndef QGSSCALECALCULATOR_H