/
qgsmaptoolshowhidelabels.h
73 lines (54 loc) · 2.55 KB
/
qgsmaptoolshowhidelabels.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
64
65
66
67
68
69
70
71
72
73
/***************************************************************************
qgsmaptoolshowhidelabels.h
--------------------
begin : 2012-08-12
copyright : (C) 2012 by Larry Shaffer
email : larrys at dakotacarto dot com
***************************************************************************/
/***************************************************************************
* *
* 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 QGSMAPTOOLSHOWHIDELABELS_H
#define QGSMAPTOOLSHOWHIDELABELS_H
#include "qgsmaptoollabel.h"
#include "qgsfeature.h"
/** A map tool for showing or hidding a feature's label*/
class APP_EXPORT QgsMapToolShowHideLabels : public QgsMapToolLabel
{
Q_OBJECT
public:
QgsMapToolShowHideLabels( QgsMapCanvas *canvas );
~QgsMapToolShowHideLabels();
//! Overridden mouse move event
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
//! Overridden mouse press event
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
//! Overridden mouse release event
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
protected:
//! Flag to indicate a map canvas drag operation is taking place
bool mDragging;
//! Stores actual select rect
QRect mSelectRect;
//! Stores selection marquee
QgsRubberBand* mRubberBand;
private:
//! Select valid labels to pin or unpin
void showHideLabels( QMouseEvent * e );
//! Return features intersecting rubberband
bool selectedFeatures( QgsVectorLayer* vlayer,
QgsFeatureIds& selectedFeatIds );
//! Return label features intersecting rubberband
bool selectedLabelFeatures( QgsVectorLayer* vlayer,
QgsFeatureIds& selectedFeatIds );
//! Show or hide chosen label by setting data defined Show Label to 0
bool showHideLabel( QgsVectorLayer* vlayer,
QgsFeatureId fid,
bool hide );
};
#endif // QGSMAPTOOLSHOWHIDELABELS_H