1
/***************************************************************************
5
copyright : (C) 2005 by Radim Blazek
7
***************************************************************************/
8
/***************************************************************************
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. *
15
***************************************************************************/
16
#ifndef QGSCOMPOSERSCALEBAR_H
17
#define QGSCOMPOSERSCALEBAR_H
25
#include "qgscomposer.h"
26
#include "qgscomposition.h"
27
#include "qgscomposeritem.h"
30
#include "qgscomposerscalebarbase.h"
32
#include "qgscomposerscalebarbase.uic.h"
36
class QCanvasRectangle;
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
60
// NOTE: QgsComposerScalebarBase must be first, otherwise does not compile
61
class QgsComposerScalebar : public QgsComposerScalebarBase, public QCanvasPolygonalItem, public QgsComposerItem
66
/** \brief Constructor
68
* \param fontSize font size in typographic points!
70
QgsComposerScalebar( QgsComposition *composition, int id, int x, int y );
72
/** \brief Constructor. Settings are read from project.
75
QgsComposerScalebar( QgsComposition *composition, int id );
76
~QgsComposerScalebar();
78
/** \brief Initialise GUI etc., shared by constructors. */
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 );
91
QRect boundingRect ( void ) const;
93
/** \brief Draw to paint device, internal use
94
* \param painter painter or 0
95
* \return bounding box
97
QRect render (QPainter *painter);
99
/** \brief Reimplementation of QCanvasItem::draw - draw on canvas */
100
void draw ( QPainter & painter );
102
void drawShape(QPainter&);
103
QPointArray areaPoints() const;
105
/** \brief Calculate size according to current settings */
106
void recalculate ( void );
108
/** \brief Set values in GUI to current values */
109
void setOptions ( void );
113
void changeFont ( void );
116
void unitLabelChanged ( void );
119
void sizeChanged ( void );
121
// Called by GUI when map selection changed
122
void mapSelectionChanged ( int i );
124
// Called when map was changed
125
void mapChanged ( int id );
128
void moveBy ( double x, double y );
131
// Pointer to composition
132
QgsComposition *mComposition;
134
// Pointer to map canvas
135
QgsMapCanvas *mMapCanvas;
137
// Composer map id or 0
140
// Vector of map id for maps in combobox
141
std::vector<int> mMaps;
143
// Current bounding box
146
// Number of map units in scalebar unit
147
double mMapUnitsPerUnit;
152
// Font. Font size in typographic points!
164
// Segment size in map units
165
double mSegmentLength;
167
// Height of scalebar box in canvas units (box style only)