Quantum GIS API Documentation
1.7.4
|
00001 /*************************************************************************** 00002 qgscomposerscalebar.h 00003 ------------------- 00004 begin : March 2005 00005 copyright : (C) 2005 by Radim Blazek 00006 email : blazek@itc.it 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 00035 QgsComposerScaleBar( QgsComposition* composition ); 00036 ~QgsComposerScaleBar(); 00037 00039 virtual int type() const { return ComposerScaleBar; } 00040 00042 void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ); 00043 00044 //getters and setters 00045 int numSegments() const {return mNumSegments;} 00046 void setNumSegments( int nSegments ) {mNumSegments = nSegments;} 00047 00048 int numSegmentsLeft() const {return mNumSegmentsLeft;} 00049 void setNumSegmentsLeft( int nSegmentsLeft ) {mNumSegmentsLeft = nSegmentsLeft;} 00050 00051 double numUnitsPerSegment() const {return mNumUnitsPerSegment;} 00052 void setNumUnitsPerSegment( double units ); 00053 00054 double numMapUnitsPerScaleBarUnit() const {return mNumMapUnitsPerScaleBarUnit;} 00055 void setNumMapUnitsPerScaleBarUnit( double d ) {mNumMapUnitsPerScaleBarUnit = d;} 00056 00057 QString unitLabeling() const {return mUnitLabeling;} 00058 void setUnitLabeling( const QString& label ) {mUnitLabeling = label;} 00059 00060 QFont font() const; 00061 00062 void setFont( const QFont& font ); 00063 00064 QPen pen() const {return mPen;} 00065 void setPen( const QPen& pen ) {mPen = pen;} 00066 00067 QBrush brush() const {return mBrush;} 00068 void setBrush( const QBrush& brush ) {mBrush = brush;} 00069 00070 double height() const {return mHeight;} 00071 void setHeight( double h ) {mHeight = h;} 00072 00073 void setComposerMap( const QgsComposerMap* map ); 00074 const QgsComposerMap* composerMap() const {return mComposerMap;} 00075 00076 double labelBarSpace() const {return mLabelBarSpace;} 00077 void setLabelBarSpace( double space ) {mLabelBarSpace = space;} 00078 00079 double boxContentSpace() const {return mBoxContentSpace;} 00080 void setBoxContentSpace( double space ) {mBoxContentSpace = space;} 00081 00082 double segmentMillimeters() const {return mSegmentMillimeters;} 00083 00085 void applyDefaultSettings(); 00088 void applyDefaultSize(); 00089 00092 void setStyle( const QString& styleName ); 00093 00095 QString style() const; 00096 00099 void segmentPositions( QList<QPair<double, double> >& posWidthList ) const; 00100 00102 void adjustBoxSize(); 00103 00105 void update(); 00106 00108 QString firstLabelString() const; 00109 00114 bool writeXML( QDomElement& elem, QDomDocument & doc ) const; 00115 00120 bool readXML( const QDomElement& itemElem, const QDomDocument& doc ); 00121 00122 public slots: 00123 void updateSegmentSize(); 00125 void invalidateCurrentMap(); 00126 00127 protected: 00128 00130 const QgsComposerMap* mComposerMap; 00132 int mNumSegments; 00134 int mNumSegmentsLeft; 00136 double mNumUnitsPerSegment; 00138 double mNumMapUnitsPerScaleBarUnit; 00139 00141 QString mUnitLabeling; 00143 QFont mFont; 00145 QPen mPen; 00147 QBrush mBrush; 00149 double mHeight; 00151 QgsScaleBarStyle* mStyle; 00152 00154 double mLabelBarSpace; 00155 00157 double mBoxContentSpace; 00158 00160 double mSegmentMillimeters; 00161 00163 void refreshSegmentMillimeters(); 00164 }; 00165 00166 #endif //QGSCOMPOSERSCALEBAR_H 00167 00168