00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef QGSCOMPOSERSCALEBAR_H
00017 #define QGSCOMPOSERSCALEBAR_H
00018
00019 #include "qgscomposeritem.h"
00020 #include <QPen>
00021
00022 class QgsComposerMap;
00023 class QgsScaleBarStyle;
00028 class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
00029 {
00030
00031 Q_OBJECT
00032
00033 public:
00034
00035 QgsComposerScaleBar( QgsComposition* composition );
00036 ~QgsComposerScaleBar();
00037
00039 void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
00040
00041
00042 int numSegments() const {return mNumSegments;}
00043 void setNumSegments( int nSegments ) {mNumSegments = nSegments;}
00044
00045 int numSegmentsLeft() const {return mNumSegmentsLeft;}
00046 void setNumSegmentsLeft( int nSegmentsLeft ) {mNumSegmentsLeft = nSegmentsLeft;}
00047
00048 double numUnitsPerSegment() const {return mNumUnitsPerSegment;}
00049 void setNumUnitsPerSegment( double units );
00050
00051 double numMapUnitsPerScaleBarUnit() const {return mNumMapUnitsPerScaleBarUnit;}
00052 void setNumMapUnitsPerScaleBarUnit( double d ) {mNumMapUnitsPerScaleBarUnit = d;}
00053
00054 QString unitLabeling() const {return mUnitLabeling;}
00055 void setUnitLabeling( const QString& label ) {mUnitLabeling = label;}
00056
00057 QFont font() const;
00058
00059 void setFont( const QFont& font );
00060
00061 QPen pen() const {return mPen;}
00062 void setPen( const QPen& pen ) {mPen = pen;}
00063
00064 QBrush brush() const {return mBrush;}
00065 void setBrush( const QBrush& brush ) {mBrush = brush;}
00066
00067 double height() const {return mHeight;}
00068 void setHeight( double h ) {mHeight = h;}
00069
00070 void setComposerMap( const QgsComposerMap* map );
00071 const QgsComposerMap* composerMap() const {return mComposerMap;}
00072
00073 double labelBarSpace() const {return mLabelBarSpace;}
00074 void setLabelBarSpace( double space ) {mLabelBarSpace = space;}
00075
00076 double boxContentSpace() const {return mBoxContentSpace;}
00077 void setBoxContentSpace( double space ) {mBoxContentSpace = space;}
00078
00079 double segmentMillimeters() const {return mSegmentMillimeters;}
00080
00082 void applyDefaultSettings();
00083
00086 void setStyle( const QString& styleName );
00087
00089 QString style() const;
00090
00093 void segmentPositions( QList<QPair<double, double> >& posWidthList ) const;
00094
00096 void adjustBoxSize();
00097
00099 void update();
00100
00102 QString firstLabelString() const;
00103
00108 bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
00109
00114 bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
00115
00116 public slots:
00117 void updateSegmentSize();
00119 void invalidateCurrentMap();
00120
00121 protected:
00122
00124 const QgsComposerMap* mComposerMap;
00126 int mNumSegments;
00128 int mNumSegmentsLeft;
00130 double mNumUnitsPerSegment;
00132 double mNumMapUnitsPerScaleBarUnit;
00133
00135 QString mUnitLabeling;
00137 QFont mFont;
00139 QPen mPen;
00141 QBrush mBrush;
00143 double mHeight;
00145 QgsScaleBarStyle* mStyle;
00146
00148 double mLabelBarSpace;
00149
00151 double mBoxContentSpace;
00152
00154 double mSegmentMillimeters;
00155
00157 void refreshSegmentMillimeters();
00158 };
00159
00160 #endif //QGSCOMPOSERSCALEBAR_H
00161
00162