Quantum GIS API Documentation  1.8
src/core/composer/qgscomposerscalebar.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                             qgscomposerscalebar.h
00003                              -------------------
00004     begin                : March 2005
00005     copyright            : (C) 2005 by Radim Blazek
00006     email                : [email protected]
00007  ***************************************************************************/
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
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 
00036     enum Alignment
00037     {
00038       Left = 0,
00039       Middle,
00040       Right
00041     };
00042 
00043     QgsComposerScaleBar( QgsComposition* composition );
00044     ~QgsComposerScaleBar();
00045 
00047     virtual int type() const { return ComposerScaleBar; }
00048 
00050     void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
00051 
00052     //getters and setters
00053     int numSegments() const {return mNumSegments;}
00054     void setNumSegments( int nSegments );
00055 
00056     int numSegmentsLeft() const {return mNumSegmentsLeft;}
00057     void setNumSegmentsLeft( int nSegmentsLeft );
00058 
00059     double numUnitsPerSegment() const {return mNumUnitsPerSegment;}
00060     void setNumUnitsPerSegment( double units );
00061 
00062     double numMapUnitsPerScaleBarUnit() const {return mNumMapUnitsPerScaleBarUnit;}
00063     void setNumMapUnitsPerScaleBarUnit( double d ) {mNumMapUnitsPerScaleBarUnit = d;}
00064 
00065     QString unitLabeling() const {return mUnitLabeling;}
00066     void setUnitLabeling( const QString& label ) {mUnitLabeling = label;}
00067 
00068     QFont font() const;
00069 
00070     void setFont( const QFont& font );
00071 
00072     QPen pen() const {return mPen;}
00073     void setPen( const QPen& pen ) {mPen = pen;}
00074 
00075     QBrush brush() const {return mBrush;}
00076     void setBrush( const QBrush& brush ) {mBrush = brush;}
00077 
00078     double height() const {return mHeight;}
00079     void setHeight( double h ) {mHeight = h;}
00080 
00081     void setComposerMap( const QgsComposerMap* map );
00082     const QgsComposerMap* composerMap() const {return mComposerMap;}
00083 
00084     double labelBarSpace() const {return mLabelBarSpace;}
00085     void setLabelBarSpace( double space ) {mLabelBarSpace = space;}
00086 
00087     double boxContentSpace() const {return mBoxContentSpace;}
00088     void setBoxContentSpace( double space );
00089 
00090     double segmentMillimeters() const {return mSegmentMillimeters;}
00091 
00094     Alignment alignment() const { return mAlignment; }
00095 
00097     void setAlignment( Alignment a ) { mAlignment = a; }
00098 
00100     void applyDefaultSettings();
00103     void applyDefaultSize();
00104 
00107     void setStyle( const QString& styleName );
00108 
00110     QString style() const;
00111 
00114     void segmentPositions( QList<QPair<double, double> >& posWidthList ) const;
00115 
00117     void adjustBoxSize();
00118 
00120     void update();
00121 
00123     QString firstLabelString() const;
00124 
00129     bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
00130 
00135     bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
00136 
00138     void correctXPositionAlignment( double width, double widthAfter );
00139 
00140   public slots:
00141     void updateSegmentSize();
00143     void invalidateCurrentMap();
00144 
00145   protected:
00146 
00148     const QgsComposerMap* mComposerMap;
00150     int mNumSegments;
00152     int mNumSegmentsLeft;
00154     double mNumUnitsPerSegment;
00156     double mNumMapUnitsPerScaleBarUnit;
00157 
00159     QString mUnitLabeling;
00161     QFont mFont;
00163     QPen mPen;
00165     QBrush mBrush;
00167     double mHeight;
00169     QgsScaleBarStyle* mStyle;
00170 
00172     double mLabelBarSpace;
00173 
00175     double mBoxContentSpace;
00176 
00178     double mSegmentMillimeters;
00179 
00180     Alignment mAlignment;
00181 
00183     void refreshSegmentMillimeters();
00184 };
00185 
00186 #endif //QGSCOMPOSERSCALEBAR_H
00187 
00188 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines