/
qgscomposerscalebar.sip
136 lines (100 loc) · 3.72 KB
/
qgscomposerscalebar.sip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/** \ingroup MapComposer
* A scale bar item that can be added to a map composition.
*/
class QgsComposerScaleBar: QgsComposerItem
{
%TypeHeaderCode
#include "qgscomposerscalebar.h"
%End
public:
/**Added in version 1.8*/
enum Alignment
{
Left = 0,
Middle,
Right
};
/**Added in version 1.9*/
enum ScaleBarUnits
{
MapUnits = 0,
Meters,
Feet
};
QgsComposerScaleBar( QgsComposition* composition /TransferThis/);
~QgsComposerScaleBar();
/** return correct graphics item type. Added in v1.7 */
virtual int type() const;
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
//getters and setters
int numSegments() const;
void setNumSegments( int nSegments );
int numSegmentsLeft() const;
void setNumSegmentsLeft( int nSegmentsLeft );
double numUnitsPerSegment() const;
void setNumUnitsPerSegment( double units );
double numMapUnitsPerScaleBarUnit() const;
void setNumMapUnitsPerScaleBarUnit( double d );
QString unitLabeling() const;
void setUnitLabeling( const QString& label );
QFont font() const;
void setFont( const QFont& font );
QPen pen() const;
void setPen( const QPen& pen );
QBrush brush() const;
void setBrush( const QBrush& brush );
double height() const;
void setHeight( double h );
void setComposerMap( const QgsComposerMap* map );
const QgsComposerMap* composerMap();
double labelBarSpace() const;
void setLabelBarSpace( double space );
double boxContentSpace() const;
void setBoxContentSpace( double space );
double segmentMillimeters() const;
/**Left / Middle/ Right
@note: this method was added in version 1.8*/
Alignment alignment() const;
/**@note: this method was added in version 1.8*/
void setAlignment( Alignment a );
/**@note: this method was added in version 1.9*/
ScaleBarUnits units() const;
/**@note: this method was added in version 1.9*/
void setUnits( ScaleBarUnits u );
/**Apply default settings*/
void applyDefaultSettings();
/**Apply default size (scale bar 1/5 of map item width)
@note this method was added in version 1.7*/
void applyDefaultSize();
/**Sets style by name
@param styleName (untranslated) style name. Possibilities are: 'Single Box', 'Double Box', 'Line Ticks Middle', 'Line Ticks Down', 'Line Ticks Up', 'Numeric'*/
void setStyle( const QString& styleName );
/**Returns style name*/
QString style() const;
/**Returns the x - positions of the segment borders (in item coordinates) and the width
of the segment*/
void segmentPositions( QList<QPair<double, double> >& posWidthList ) const;
/**Sets box size suitable to content*/
void adjustBoxSize();
/**Adjusts box size and calls QgsComposerItem::update()*/
void update();
/**Returns string of first label (important for drawing, labeling, size calculation*/
QString firstLabelString() const;
/** stores state in Dom node
* @param elem is Dom element corresponding to 'Composer' tag
* @param temp write template file
*/
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
/** sets state from Dom document
* @param itemElem is Dom node corresponding to item tag
*/
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
public slots:
void updateSegmentSize();
/**Sets mCompositionMap to 0 if the map is deleted*/
void invalidateCurrentMap();
protected:
/**Calculates with of a segment in mm and stores it in mSegmentMillimeters*/
void refreshSegmentMillimeters();
};