/
qgsmaptoolmovelabel.h
63 lines (50 loc) · 2.61 KB
/
qgsmaptoolmovelabel.h
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
/***************************************************************************
qgsmaptoolmovelabel.h
--------------------
begin : 2010-11-03
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMAPTOOLMOVELABEL_H
#define QGSMAPTOOLMOVELABEL_H
#include "qgsmaptoollabel.h"
/**A map tool for dragging label positions*/
class QgsMapToolMoveLabel: public QgsMapToolLabel
{
Q_OBJECT
public:
QgsMapToolMoveLabel( QgsMapCanvas* canvas );
~QgsMapToolMoveLabel();
virtual void canvasPressEvent( QMouseEvent * e );
virtual void canvasMoveEvent( QMouseEvent * e );
virtual void canvasReleaseEvent( QMouseEvent * e );
protected:
/**Get data defined position of a feature
@param layerId layer identification string
@param x out: data defined x-coordinate
@param xSuccess out: false if attribute value is NULL
@param y out: data defined y-coordinate
@param ySuccess out: false if attribute value is NULL
@param xCol out: index of the x position column
@param yCol out: index of the y position column
@return false if layer does not have data defined label position enabled*/
bool dataDefinedPosition( QgsVectorLayer* vlayer, int featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const;
/**Returns true if layer move can be applied to a layer
@param xCol out: index of the attribute for data defined x coordinate
@param yCol out: index of the attribute for data defined y coordinate
@return true if labels of layer can be moved*/
bool layerIsMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
/**Start point of the move in map coordinates*/
QgsPoint mStartPointMapCoords;
double mClickOffsetX;
double mClickOffsetY;
};
#endif // QGSMAPTOOLMOVELABEL_H