1 /**************************************************************************** 2 ** 3 * Draw ellipse by foci and a point on ellipse 4 5 Copyright (C) 2012 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_ACTIONDRAWCIRCLETAN2_1P_H 24 #define RS_ACTIONDRAWCIRCLETAN2_1P_H 25 26 #include "rs_previewactioninterface.h" 27 28 class RS_AtomicEntity; 29 struct RS_CircleData; 30 31 /** 32 * Given two circles and a point, draw a common tangent circle passing the point 33 * 34 * @author Dongxu Li 35 */ 36 class RS_ActionDrawCircleTan2_1P : public RS_PreviewActionInterface { 37 Q_OBJECT 38 public: 39 /** 40 * Action States. 41 */ 42 enum Status { 43 SetCircle1=0, // Setting the first circle. */ 44 SetCircle2=1, // Setting the second circle. */ 45 SetPoint=2, // Setting point on the desired circle. */ 46 SetCenter 47 }; 48 49 public: 50 RS_ActionDrawCircleTan2_1P(RS_EntityContainer& container, 51 RS_GraphicView& graphicView); 52 ~RS_ActionDrawCircleTan2_1P() override; 53 54 void init(int status=0) override; 55 56 void trigger() override; 57 bool getCenters(); 58 bool preparePreview(); 59 60 void mouseMoveEvent(QMouseEvent* e) override; 61 void mouseReleaseEvent(QMouseEvent* e) override; 62 63 void coordinateEvent(RS_CoordinateEvent* e) override; 64 // void commandEvent(RS_CommandEvent* e) override; 65 QStringList getAvailableCommands() override; 66 void finish(bool updateTB=true) override; 67 void updateMouseButtonHints() override; 68 void updateMouseCursor() override; 69 70 71 protected: 72 RS_Entity* catchCircle(QMouseEvent* e); 73 private: 74 struct Points; 75 std::unique_ptr<Points> pPoints; 76 77 //list of entity types supported by current action 78 const EntityTypeList enTypeList = EntityTypeList {RS2::EntityLine, RS2::EntityArc, RS2::EntityCircle}; 79 }; 80 81 #endif 82