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_ACTIONDRAWELLIPSEINSCRIBE_H
24 #define RS_ACTIONDRAWELLIPSEINSCRIBE_H
25 
26 #include "rs_previewactioninterface.h"
27 /**
28  * Draw ellipse by foci and a point on ellipse
29  *
30  * @author Dongxu Li
31  */
32 class RS_ActionDrawEllipseInscribe : public RS_PreviewActionInterface {
33         Q_OBJECT
34 public:
35     /**
36      * Action States.
37      */
38     enum Status {
39         SetLine1,   //  Setting the First Line.  */
40         SetLine2,   //  Setting the Second Line.  */
41         SetLine3,   //  Setting the Third Line.  */
42         SetLine4   //  Setting the Last Line.  */
43     };
44 
45 public:
46     RS_ActionDrawEllipseInscribe(RS_EntityContainer& container,
47                                  RS_GraphicView& graphicView);
48 	~RS_ActionDrawEllipseInscribe() override;
49 
50 	void init(int status=0) override;
51 
52 	void trigger() override;
53 	bool preparePreview();
54 
55 	void mouseMoveEvent(QMouseEvent* e) override;
56 	void mouseReleaseEvent(QMouseEvent* e) override;
57 
58 	//        void coordinateEvent(RS_CoordinateEvent* e) override;
59 	//    void commandEvent(RS_CommandEvent* e) override;
60 	QStringList getAvailableCommands() override;
61 	void finish(bool updateTB=true) override;
62 	void updateMouseButtonHints() override;
63 	void updateMouseCursor() override;
64 
65 protected:
66     // 4 points on ellipse
67 private:
68 	void clearLines(bool checkStatus=false);
69 
70 	struct Points;
71     std::unique_ptr<Points> pPoints;
72 };
73 
74 #endif
75