1 /*
2  *    Copyright 2014 Thomas Schöps
3  *
4  *    This file is part of OpenOrienteering.
5  *
6  *    OpenOrienteering is free software: you can redistribute it and/or modify
7  *    it under the terms of the GNU General Public License as published by
8  *    the Free Software Foundation, either version 3 of the License, or
9  *    (at your option) any later version.
10  *
11  *    OpenOrienteering is distributed in the hope that it will be useful,
12  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *    GNU General Public License for more details.
15  *
16  *    You should have received a copy of the GNU General Public License
17  *    along with OpenOrienteering.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 
21 #ifndef OPENORIENTEERING_DRAW_POINT_GPS_H
22 #define OPENORIENTEERING_DRAW_POINT_GPS_H
23 
24 #include <QObject>
25 #include <QPointer>
26 #include <QScopedPointer>
27 #include <QString>
28 
29 #include "tools/tool_base.h"
30 
31 class QAction;
32 class QKeyEvent;
33 class QLabel;
34 class QPainter;
35 class QRectF;
36 
37 namespace OpenOrienteering {
38 
39 class GPSDisplay;
40 class MapCoordF;
41 class MapEditorController;
42 class MapRenderables;
43 class MapWidget;
44 class PointObject;
45 class Symbol;
46 
47 
48 /**
49  * Tool to draw a PointObject at the GPS position.
50  */
51 class DrawPointGPSTool : public MapEditorToolBase
52 {
53 Q_OBJECT
54 public:
55 	DrawPointGPSTool(GPSDisplay* gps_display, MapEditorController* editor, QAction* tool_action);
56 	~DrawPointGPSTool() override;
57 
58 public slots:
59 	void newGPSPosition(const OpenOrienteering::MapCoordF& coord, float accuracy);
60 
61 protected slots:
62 	void activeSymbolChanged(const OpenOrienteering::Symbol* symbol);
63 	void symbolDeleted(int pos, const OpenOrienteering::Symbol* old_symbol);
64 
65 protected:
66 	void initImpl() override;
67 	int updateDirtyRectImpl(QRectF& rect) override;
68 	void drawImpl(QPainter* painter, MapWidget* widget) override;
69 	void updateStatusText() override;
70 	void objectSelectionChangedImpl() override;
71 
72 	void clickRelease() override;
73 	bool keyPress(QKeyEvent* event) override;
74 
75 	double x_sum;
76 	double y_sum;
77 	double weights_sum;
78 
79 	const Symbol* last_used_symbol = nullptr;
80 	PointObject* preview_object = nullptr;
81 	QScopedPointer<MapRenderables> renderables;
82 	QPointer<QLabel> help_label;
83 };
84 
85 
86 }  // namespace OpenOrienteering
87 #endif
88