1 /****************************************************************************
2 **
3  * Draw ellipse by foci and a point on ellipse
4 
5 Copyright (C) 2011 Dongxu Li (dongxuli2011@gmail.com)
6 Copyright (C) 2011 R. van Twisk (librecad@rvt.dds.nl)
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 **********************************************************************/
22 
23 #ifndef RS_ACTIONDRAWCIRCLEINSCRIBE_H
24 #define RS_ACTIONDRAWCIRCLEINSCRIBE_H
25 
26 #include "rs_previewactioninterface.h"
27 
28 class RS_Line;
29 struct RS_CircleData;
30 
31 /**
32  * Draw ellipse by foci and a point on ellipse
33  *
34  * @author Dongxu Li
35  */
36 class RS_ActionDrawCircleInscribe : public RS_PreviewActionInterface {
37         Q_OBJECT
38 public:
39     /**
40      * Action States.
41      */
42     enum Status {
43 		SetLine1,   //  Setting the First Line.  */
44         SetLine2,   //  Setting the Second Line.  */
45         SetLine3   //  Setting the Third Line.  */
46     };
47 
48 public:
49     RS_ActionDrawCircleInscribe(RS_EntityContainer& container,
50                                  RS_GraphicView& graphicView);
51 	~RS_ActionDrawCircleInscribe() override;
52 
53 	void init(int status=0) override;
54 
55 	void trigger() override;
56 	bool preparePreview();
57 
58 	void mouseMoveEvent(QMouseEvent* e) override;
59 	void mouseReleaseEvent(QMouseEvent* e) override;
60 
61 	//        void coordinateEvent(RS_CoordinateEvent* e) override;
62 	//    void commandEvent(RS_CommandEvent* e) override;
63 	QStringList getAvailableCommands() override;
64 	void finish(bool updateTB=true) override;
65 	void updateMouseButtonHints() override;
66 	void updateMouseCursor() override;
67 
68 private:
69 	/**
70 	 * @brief clearLines unset highlighten lines, and clear the vector "lines"
71 	 * @param checkStatus keep lines members according to getStatus()
72 	 */
73 	void clearLines(bool checkStatus=false);
74 	struct Points;
75 	std::unique_ptr<Points> pPoints;
76     bool valid;
77 };
78 
79 #endif
80