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

« back to all changes in this revision

Viewing changes to src/qgscomposerscalebar.h

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-05-06 13:42:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134232-pyli6t388w5asd8x
Tags: 0.8.0-3ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules, debian/qgis.install, debian/qgis.dirs debian/qgis.desktop:
    Add and install .desktop.
* debian/qgis.desktop: Remove Applications category; it's not real.
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                            qgscomposerscalebar.h
3
 
                             -------------------
4
 
    begin                : March 2005
5
 
    copyright            : (C) 2005 by Radim Blazek
6
 
    email                : blazek@itc.it
7
 
 ***************************************************************************/
8
 
/***************************************************************************
9
 
 *                                                                         *
10
 
 *   This program is free software; you can redistribute it and/or modify  *
11
 
 *   it under the terms of the GNU General Public License as published by  *
12
 
 *   the Free Software Foundation; either version 2 of the License, or     *
13
 
 *   (at your option) any later version.                                   *
14
 
 *                                                                         *
15
 
 ***************************************************************************/
16
 
#ifndef QGSCOMPOSERSCALEBAR_H
17
 
#define QGSCOMPOSERSCALEBAR_H
18
 
 
19
 
#include <qwidget.h>
20
 
#include <qcanvas.h>
21
 
#include <qobject.h>
22
 
 
23
 
#include "qgsrect.h"
24
 
 
25
 
#include "qgscomposer.h"
26
 
#include "qgscomposition.h"
27
 
#include "qgscomposeritem.h"
28
 
 
29
 
#ifdef WIN32
30
 
#include "qgscomposerscalebarbase.h"
31
 
#else
32
 
#include "qgscomposerscalebarbase.uic.h"
33
 
#endif
34
 
 
35
 
class QCanvasItem;
36
 
class QCanvasRectangle;
37
 
class QPainter;
38
 
class QWidget;
39
 
class QDomNode;
40
 
class QDomDocument;
41
 
class QPixmap;
42
 
class QImage;
43
 
class QFont;
44
 
class QPen;
45
 
class QRect;
46
 
class QPopupMenu;
47
 
 
48
 
 
49
 
class QgsMapCanvas;
50
 
class QgsRect;
51
 
class QgsMapToPixel;
52
 
class QgsComposition;
53
 
class QgsComposerMap;
54
 
 
55
 
 
56
 
/** \class QgsComposerScalebar
57
 
 *  \brief Object representing map window. 
58
 
 *         x,y is center of upper side of the bar, the center position depends on scalebar style
59
 
 */
60
 
// NOTE: QgsComposerScalebarBase must be first, otherwise does not compile
61
 
class QgsComposerScalebar : public QgsComposerScalebarBase, public QCanvasPolygonalItem, public QgsComposerItem
62
 
{
63
 
    Q_OBJECT
64
 
 
65
 
public:
66
 
    /** \brief Constructor  
67
 
     *  \param id object id
68
 
     *  \param fontSize font size in typographic points!
69
 
     */
70
 
    QgsComposerScalebar( QgsComposition *composition, int id, int x, int y );
71
 
 
72
 
    /** \brief Constructor. Settings are read from project. 
73
 
     *  \param id object id
74
 
     */
75
 
    QgsComposerScalebar( QgsComposition *composition, int id );
76
 
    ~QgsComposerScalebar();
77
 
 
78
 
    /** \brief Initialise GUI etc., shared by constructors. */
79
 
    void init(void);
80
 
 
81
 
    // Reimplement QgsComposerItem:
82
 
    void setSelected( bool s );
83
 
    bool selected( void );
84
 
    QWidget *options ( void );
85
 
    bool writeSettings ( void );
86
 
    bool readSettings ( void );
87
 
    bool removeSettings ( void );
88
 
    bool writeXML( QDomNode & node, QDomDocument & document, bool temp = false );
89
 
    bool readXML( QDomNode & node );
90
 
 
91
 
    QRect boundingRect ( void ) const;
92
 
     
93
 
    /** \brief Draw to paint device, internal use 
94
 
     *  \param painter painter or 0
95
 
     *  \return bounding box 
96
 
     */
97
 
    QRect render (QPainter *painter);
98
 
 
99
 
    /** \brief Reimplementation of QCanvasItem::draw - draw on canvas */
100
 
    void draw ( QPainter & painter );
101
 
 
102
 
    void drawShape(QPainter&);
103
 
    QPointArray areaPoints() const;
104
 
    
105
 
    /** \brief Calculate size according to current settings */
106
 
    void recalculate ( void );
107
 
    
108
 
    /** \brief Set values in GUI to current values */
109
 
    void setOptions ( void );
110
 
 
111
 
public slots:
112
 
    // Open font dialog
113
 
    void changeFont ( void );
114
 
 
115
 
    // Title changed
116
 
    void unitLabelChanged ( void );
117
 
 
118
 
    // Size changed
119
 
    void sizeChanged ( void );
120
 
    
121
 
    // Called by GUI when map selection changed
122
 
    void mapSelectionChanged ( int i );
123
 
 
124
 
    // Called when map was changed
125
 
    void mapChanged ( int id );
126
 
 
127
 
    // Move to position
128
 
    void moveBy ( double x, double y );
129
 
 
130
 
private:
131
 
    // Pointer to composition
132
 
    QgsComposition *mComposition;
133
 
    
134
 
    // Pointer to map canvas
135
 
    QgsMapCanvas *mMapCanvas;
136
 
    
137
 
    // Composer map id or 0
138
 
    int mMap;
139
 
 
140
 
    // Vector of map id for maps in combobox
141
 
    std::vector<int> mMaps;
142
 
 
143
 
    // Current bounding box
144
 
    QRect mBoundingRect;
145
 
 
146
 
    // Number of map units in scalebar unit
147
 
    double mMapUnitsPerUnit;
148
 
 
149
 
    // Unit label
150
 
    QString mUnitLabel;
151
 
 
152
 
    // Font. Font size in typographic points!
153
 
    QFont mFont;
154
 
 
155
 
    // Pen
156
 
    QPen  mPen;
157
 
 
158
 
    // Brush
159
 
    QBrush mBrush;
160
 
 
161
 
    // Number of parts 
162
 
    int mNumSegments;
163
 
 
164
 
    // Segment size in map units
165
 
    double mSegmentLength;
166
 
 
167
 
    // Height of scalebar box in canvas units (box style only)
168
 
    int mHeight;
169
 
 
170
 
    // Margin
171
 
    int mMargin;
172
 
};
173
 
 
174
 
#endif