|
QGIS API Documentation
master-6227475
|
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 <QFont> 00021 #include <QPen> 00022 #include <QColor> 00023 00024 class QgsComposerMap; 00025 class QgsScaleBarStyle; 00030 class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem 00031 { 00032 Q_OBJECT 00033 00034 public: 00035 00037 enum Alignment 00038 { 00039 Left = 0, 00040 Middle, 00041 Right 00042 }; 00043 00045 enum ScaleBarUnits 00046 { 00047 MapUnits = 0, 00048 Meters, 00049 Feet 00050 }; 00051 00052 QgsComposerScaleBar( QgsComposition* composition ); 00053 ~QgsComposerScaleBar(); 00054 00056 virtual int type() const { return ComposerScaleBar; } 00057 00059 void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ); 00060 00061 //getters and setters 00062 int numSegments() const {return mNumSegments;} 00063 void setNumSegments( int nSegments ); 00064 00065 int numSegmentsLeft() const {return mNumSegmentsLeft;} 00066 void setNumSegmentsLeft( int nSegmentsLeft ); 00067 00068 double numUnitsPerSegment() const {return mNumUnitsPerSegment;} 00069 void setNumUnitsPerSegment( double units ); 00070 00071 double numMapUnitsPerScaleBarUnit() const {return mNumMapUnitsPerScaleBarUnit;} 00072 void setNumMapUnitsPerScaleBarUnit( double d ) {mNumMapUnitsPerScaleBarUnit = d;} 00073 00074 QString unitLabeling() const {return mUnitLabeling;} 00075 void setUnitLabeling( const QString& label ) {mUnitLabeling = label;} 00076 00077 QFont font() const; 00078 00079 QColor fontColor() const {return mFontColor;} 00080 void setFontColor( const QColor& c ) {mFontColor = c;} 00081 00082 void setFont( const QFont& font ); 00083 00084 QPen pen() const {return mPen;} 00085 void setPen( const QPen& pen ) {mPen = pen;} 00086 00087 QBrush brush() const {return mBrush;} 00088 void setBrush( const QBrush& brush ) {mBrush = brush;} 00089 00090 double height() const {return mHeight;} 00091 void setHeight( double h ) {mHeight = h;} 00092 00093 void setComposerMap( const QgsComposerMap* map ); 00094 const QgsComposerMap* composerMap() const {return mComposerMap;} 00095 00096 double labelBarSpace() const {return mLabelBarSpace;} 00097 void setLabelBarSpace( double space ) {mLabelBarSpace = space;} 00098 00099 double boxContentSpace() const {return mBoxContentSpace;} 00100 void setBoxContentSpace( double space ); 00101 00102 double segmentMillimeters() const {return mSegmentMillimeters;} 00103 00106 Alignment alignment() const { return mAlignment; } 00107 00109 void setAlignment( Alignment a ) { mAlignment = a; } 00110 00112 ScaleBarUnits units() const { return mUnits; } 00113 00115 void setUnits( ScaleBarUnits u ); 00116 00118 void applyDefaultSettings(); 00121 void applyDefaultSize(); 00122 00125 void setStyle( const QString& styleName ); 00126 00128 QString style() const; 00129 00132 void segmentPositions( QList<QPair<double, double> >& posWidthList ) const; 00133 00135 void adjustBoxSize(); 00136 00138 void update(); 00139 00141 QString firstLabelString() const; 00142 00147 bool writeXML( QDomElement& elem, QDomDocument & doc ) const; 00148 00153 bool readXML( const QDomElement& itemElem, const QDomDocument& doc ); 00154 00156 void correctXPositionAlignment( double width, double widthAfter ); 00157 00158 public slots: 00159 void updateSegmentSize(); 00161 void invalidateCurrentMap(); 00162 00163 protected: 00164 00166 const QgsComposerMap* mComposerMap; 00168 int mNumSegments; 00170 int mNumSegmentsLeft; 00172 double mNumUnitsPerSegment; 00174 double mNumMapUnitsPerScaleBarUnit; 00175 00177 QString mUnitLabeling; 00179 QFont mFont; 00180 QColor mFontColor; 00182 QPen mPen; 00184 QBrush mBrush; 00186 double mHeight; 00188 QgsScaleBarStyle* mStyle; 00189 00191 double mLabelBarSpace; 00192 00194 double mBoxContentSpace; 00195 00197 double mSegmentMillimeters; 00198 00199 Alignment mAlignment; 00200 00201 ScaleBarUnits mUnits; 00202 00204 void refreshSegmentMillimeters(); 00205 00207 double mapWidth() const; 00208 }; 00209 00210 #endif //QGSCOMPOSERSCALEBAR_H 00211 00212