Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgscomposerscalebar.h
Go to the documentation of this file.
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 "qgscomposeritem.h"
20 #include <QPen>
21 
22 class QgsComposerMap;
23 class QgsScaleBarStyle;
28 class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
29 {
30 
31  Q_OBJECT
32 
33  public:
34 
35  QgsComposerScaleBar( QgsComposition* composition );
37 
39  virtual int type() const { return ComposerScaleBar; }
40 
42  void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
43 
44  //getters and setters
45  int numSegments() const {return mNumSegments;}
46  void setNumSegments( int nSegments ) {mNumSegments = nSegments;}
47 
48  int numSegmentsLeft() const {return mNumSegmentsLeft;}
49  void setNumSegmentsLeft( int nSegmentsLeft ) {mNumSegmentsLeft = nSegmentsLeft;}
50 
51  double numUnitsPerSegment() const {return mNumUnitsPerSegment;}
52  void setNumUnitsPerSegment( double units );
53 
54  double numMapUnitsPerScaleBarUnit() const {return mNumMapUnitsPerScaleBarUnit;}
55  void setNumMapUnitsPerScaleBarUnit( double d ) {mNumMapUnitsPerScaleBarUnit = d;}
56 
57  QString unitLabeling() const {return mUnitLabeling;}
58  void setUnitLabeling( const QString& label ) {mUnitLabeling = label;}
59 
60  QFont font() const;
61 
62  void setFont( const QFont& font );
63 
64  QPen pen() const {return mPen;}
65  void setPen( const QPen& pen ) {mPen = pen;}
66 
67  QBrush brush() const {return mBrush;}
68  void setBrush( const QBrush& brush ) {mBrush = brush;}
69 
70  double height() const {return mHeight;}
71  void setHeight( double h ) {mHeight = h;}
72 
73  void setComposerMap( const QgsComposerMap* map );
74  const QgsComposerMap* composerMap() const {return mComposerMap;}
75 
76  double labelBarSpace() const {return mLabelBarSpace;}
77  void setLabelBarSpace( double space ) {mLabelBarSpace = space;}
78 
79  double boxContentSpace() const {return mBoxContentSpace;}
80  void setBoxContentSpace( double space ) {mBoxContentSpace = space;}
81 
82  double segmentMillimeters() const {return mSegmentMillimeters;}
83 
85  void applyDefaultSettings();
88  void applyDefaultSize();
89 
92  void setStyle( const QString& styleName );
93 
95  QString style() const;
96 
99  void segmentPositions( QList<QPair<double, double> >& posWidthList ) const;
100 
102  void adjustBoxSize();
103 
105  void update();
106 
108  QString firstLabelString() const;
109 
114  bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
115 
120  bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
121 
122  public slots:
123  void updateSegmentSize();
125  void invalidateCurrentMap();
126 
127  protected:
128 
139 
141  QString mUnitLabeling;
143  QFont mFont;
145  QPen mPen;
147  QBrush mBrush;
149  double mHeight;
152 
155 
158 
161 
163  void refreshSegmentMillimeters();
164 };
165 
166 #endif //QGSCOMPOSERSCALEBAR_H
167 
168