1 /**********************************************************************************************
2     Copyright (C) 2017 Oliver Eichler <oliver.eichler@gmx.de>
3 
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 
17 **********************************************************************************************/
18 
19 #ifndef COVERLAYGRIDTOOL_H
20 #define COVERLAYGRIDTOOL_H
21 
22 #include "canvas/CCanvas.h"
23 #include "ui_IOverlayGridTool.h"
24 
25 class CItemRefMap;
26 class COverlayRefMapPoint;
27 
28 class COverlayGridTool : public QWidget, private Ui::IOverlayGridTool
29 {
30     Q_OBJECT
31 public:
32     COverlayGridTool(QWidget* parent);
33     virtual ~COverlayGridTool() = default;
34 
35     bool drawFx(QPainter& p, CCanvas::redraw_e needsRedraw);
36     void mouseMoveEventFx(QMouseEvent* e);
37     void mouseReleaseEventFx(QMouseEvent* e);
38     void leaveEventFx(QEvent* e);
39     QCursor getCursorFx();
40 
41     void registerItem(CItemRefMap* item);
42 
getRefPoints()43     QList<COverlayRefMapPoint*>& getRefPoints()
44     {
45         return refPoints;
46     }
47 
48 signals:
49     void sigChanged(bool ok);
50 
51 public slots:
52     void slotReset();
53 
54 private slots:
55     void slotCheckInput();
56     void slotSetArea(const QRectF& rect);
57     void slotCalculate();
58 
59 private:
60 
61     CItemRefMap* item = nullptr;
62     const IDrawContext* context = nullptr;
63 
64     QList<COverlayRefMapPoint*> refPoints;
65 };
66 
67 #endif //COVERLAYGRIDTOOL_H
68 
69