1 /***************************************************************************
2     qgsmaptoolcircle2tangentspoint.h  -  map tool for adding circle
3     from 2 tangents and a point
4     ---------------------
5     begin                : July 2017
6     copyright            : (C) 2017 by Loïc Bartoletti
7     email                : lbartoletti at tuxfamily dot org
8  ***************************************************************************
9  *                                                                         *
10  *   This program is free software; you can redistribute it and/or modify  *
11  *   it under the terms of the GNU General Public License as published by  *
12  *   the Free Software Foundation; either version 3 of the License, or     *
13  *   (at your option) any later version.                                   *
14  *                                                                         *
15  ***************************************************************************/
16 
17 #ifndef QGSMAPTOOLCIRCLE2TANGENTSPOINT_H
18 #define QGSMAPTOOLCIRCLE2TANGENTSPOINT_H
19 
20 #include "qgspointlocator.h"
21 #include "qgsmaptooladdcircle.h"
22 #include "qspinbox.h"
23 
24 class QSpinBox;
25 
26 class QgsMapToolCircle2TangentsPoint: public QgsMapToolAddCircle
27 {
28     Q_OBJECT
29 
30   public:
31     QgsMapToolCircle2TangentsPoint( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode = CaptureLine );
32     ~QgsMapToolCircle2TangentsPoint() override;
33 
34     void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) override;
35     void cadCanvasMoveEvent( QgsMapMouseEvent *e ) override;
36 
37   public slots:
38     void radiusSpinBoxChanged( double radius );
39 
40   private:
41     //! Compute 4 possible centers
42     void getPossibleCenter();
43 
44     //! (re-)create the spin box to enter the radius of the circle
45     void createRadiusSpinBox();
46     //! delete the spin box to enter the radius of the circle, if it exists
47     void deleteRadiusSpinBox();
48 
49     QDoubleSpinBox *mRadiusSpinBox = nullptr;
50 
51     double mRadius = 0.0;
52     QVector<QgsPoint> mCenters;
53     QVector<QgsGeometryRubberBand *> mRubberBands;
54 };
55 
56 #endif // QGSMAPTOOLCIRCLE2TANGENTSPOINT_H
57