16
16
17
17
#include " qgsgcpcanvasitem.h"
18
18
19
- QgsGCPCanvasItem::QgsGCPCanvasItem (QgsMapCanvas* mapCanvas, const QgsPoint& rasterCoords,
20
- const QgsPoint& worldCoords, bool isGCPSource )
21
- : QgsMapCanvasItem( mapCanvas )
22
- , mPointBrush(Qt::red)
23
- , mLabelBrush(Qt::yellow)
24
- , mRasterCoords(rasterCoords)
25
- , mWorldCoords(worldCoords)
26
- , mId(- 1 )
27
- , mIsGCPSource(isGCPSource)
28
- , mEnabled(true )
19
+ QgsGCPCanvasItem::QgsGCPCanvasItem ( QgsMapCanvas* mapCanvas, const QgsPoint& rasterCoords,
20
+ const QgsPoint& worldCoords, bool isGCPSource )
21
+ : QgsMapCanvasItem( mapCanvas )
22
+ , mPointBrush( Qt::red )
23
+ , mLabelBrush( Qt::yellow )
24
+ , mRasterCoords( rasterCoords )
25
+ , mWorldCoords( worldCoords )
26
+ , mId( - 1 )
27
+ , mIsGCPSource( isGCPSource )
28
+ , mEnabled( true )
29
29
{
30
- setFlags (QGraphicsItem::ItemIsMovable);
30
+ setFlags ( QGraphicsItem::ItemIsMovable );
31
31
32
32
updatePosition ();
33
33
}
34
34
35
35
void QgsGCPCanvasItem::paint ( QPainter* p )
36
36
{
37
- p->setRenderHint (QPainter::Antialiasing);
38
- p->setOpacity (mEnabled ? 1.0 : 0.3 );
37
+ p->setRenderHint ( QPainter::Antialiasing );
38
+ p->setOpacity ( mEnabled ? 1.0 : 0.3 );
39
39
40
40
// draw the point
41
41
p->setPen ( Qt::black );
42
42
p->setBrush ( mPointBrush );
43
43
p->drawEllipse ( -2 , -2 , 5 , 5 );
44
44
45
45
QSettings s;
46
- bool showIDs = s.value (" /Plugin-GeoReferencer/Config/ShowId" ).toBool ();
47
- if (!showIDs && mIsGCPSource )
46
+ bool showIDs = s.value ( " /Plugin-GeoReferencer/Config/ShowId" ).toBool ();
47
+ if ( !showIDs && mIsGCPSource )
48
48
{
49
49
QString msg = QString ( " X %1\n Y %2" ).arg ( QString::number ( mWorldCoords .x (), ' f' ) ).
50
50
arg ( QString::number ( mWorldCoords .y (), ' f' ) );
@@ -53,17 +53,17 @@ void QgsGCPCanvasItem::paint( QPainter* p )
53
53
p->setBrush ( mLabelBrush );
54
54
p->drawRect ( textBounds.x () - 2 , textBounds.y () - 2 , textBounds.width () + 4 , textBounds.height () + 4 );
55
55
p->drawText ( textBounds, Qt::AlignLeft, msg );
56
- mTextBounds = QSizeF (textBounds.width () + 4 , textBounds.height () + 4 );
56
+ mTextBounds = QSizeF ( textBounds.width () + 4 , textBounds.height () + 4 );
57
57
}
58
- else if (showIDs)
58
+ else if ( showIDs )
59
59
{
60
60
p->setFont ( QFont ( " helvetica" , 12 ) );
61
- QString msg = QString::number (mId );
61
+ QString msg = QString::number ( mId );
62
62
p->setBrush ( mLabelBrush );
63
- p->drawRect ( 5 , 4 , p->fontMetrics ().width (msg) + 2 , 14 );
64
- p->drawText (6 , 16 , msg);
63
+ p->drawRect ( 5 , 4 , p->fontMetrics ().width ( msg ) + 2 , 14 );
64
+ p->drawText ( 6 , 16 , msg );
65
65
QFontMetrics fm = p->fontMetrics ();
66
- mTextBounds = QSize (fm.width (msg) + 4 , fm.height () + 4 );
66
+ mTextBounds = QSize ( fm.width ( msg ) + 4 , fm.height () + 4 );
67
67
}
68
68
// else
69
69
// mTextBounds = QSizeF(0, 0);
@@ -77,36 +77,37 @@ QRectF QgsGCPCanvasItem::boundingRect() const
77
77
QPainterPath QgsGCPCanvasItem::shape () const
78
78
{
79
79
QPainterPath p;
80
- p.addEllipse (-2 , -2 , 5 , 5 );
81
- p.addRect (6 , 6 , mTextBounds .width (), mTextBounds .height ());
80
+ p.addEllipse ( -2 , -2 , 5 , 5 );
81
+ p.addRect ( 6 , 6 , mTextBounds .width (), mTextBounds .height () );
82
82
83
83
return p;
84
84
}
85
85
86
- void QgsGCPCanvasItem::setEnabled (bool enabled)
86
+ void QgsGCPCanvasItem::setEnabled ( bool enabled )
87
87
{
88
88
mEnabled = enabled;
89
- mPointBrush = enabled ? QBrush (Qt::red) : QBrush (Qt::gray);
90
- mLabelBrush = enabled ? QBrush (Qt::yellow) : QBrush (Qt::gray);
89
+ mPointBrush = enabled ? QBrush ( Qt::red ) : QBrush ( Qt::gray );
90
+ mLabelBrush = enabled ? QBrush ( Qt::yellow ) : QBrush ( Qt::gray );
91
91
update ();
92
92
}
93
93
94
- void QgsGCPCanvasItem::setRasterCoords (QgsPoint p)
94
+ void QgsGCPCanvasItem::setRasterCoords ( QgsPoint p )
95
95
{
96
96
mRasterCoords = p;
97
97
}
98
98
99
- void QgsGCPCanvasItem::setWorldCoords (QgsPoint p)
99
+ void QgsGCPCanvasItem::setWorldCoords ( QgsPoint p )
100
100
{
101
101
mWorldCoords = p;
102
102
}
103
103
104
- void QgsGCPCanvasItem::setId (int id) {
104
+ void QgsGCPCanvasItem::setId ( int id )
105
+ {
105
106
mId = id;
106
107
update ();
107
108
}
108
109
109
110
void QgsGCPCanvasItem::updatePosition ()
110
111
{
111
- setPos ( toCanvasCoordinates ( mIsGCPSource ? mRasterCoords : mWorldCoords ) );
112
+ setPos ( toCanvasCoordinates ( mIsGCPSource ? mRasterCoords : mWorldCoords ) );
112
113
}
0 commit comments