1 /**************************************************************************** 2 ** 3 * Draw a common tangent circle of 3 existing circles 4 * Problem of Appollonius 5 6 Copyright (C) 2012 Dongxu Li (dongxuli2011@gmail.com) 7 Copyright (C) 2011 R. van Twisk (librecad@rvt.dds.nl) 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License 11 as published by the Free Software Foundation; either version 2 12 of the License, or (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 **********************************************************************/ 23 24 #ifndef RS_ACTIONDRAWCIRCLETAN3_H 25 #define RS_ACTIONDRAWCIRCLETAN3_H 26 27 #include<vector> 28 #include "rs_previewactioninterface.h" 29 30 struct RS_CircleData; 31 class RS_AtomicEntity; 32 33 /** 34 * Draw Common tangential circle of 3 given circles, i.e. Appollonius's problem 35 * 36 * @author Dongxu Li 37 */ 38 class RS_ActionDrawCircleTan3 : public RS_PreviewActionInterface { 39 Q_OBJECT 40 public: 41 /** 42 * Action States. 43 */ 44 enum Status { 45 SetCircle1, // Setting the First Circle. */ 46 SetCircle2, // Setting the Second Circle. */ 47 SetCircle3, // Setting the Third Circle. */ 48 SetCenter // select the closest tangential Circle. */ 49 }; 50 51 public: 52 RS_ActionDrawCircleTan3(RS_EntityContainer& container, 53 RS_GraphicView& graphicView); 54 ~RS_ActionDrawCircleTan3() override; 55 56 void init(int status=0) override; 57 58 void trigger() override; 59 bool getData(); 60 bool preparePreview(); 61 62 void mouseMoveEvent(QMouseEvent* e) override; 63 void mouseReleaseEvent(QMouseEvent* e) override; 64 65 // void coordinateEvent(RS_CoordinateEvent* e) override; 66 // void commandEvent(RS_CommandEvent* e) override; 67 QStringList getAvailableCommands() override; 68 void finish(bool updateTB=true) override; 69 void updateMouseButtonHints() override; 70 void updateMouseCursor() override; 71 72 //protected: 73 private: 74 std::vector<double> verifyCenter(const RS_Vector& center) const; 75 std::vector<double> getRadii(RS_AtomicEntity* entity, const RS_Vector& center) const; 76 RS_Entity* catchCircle(QMouseEvent* e); 77 78 struct Points; 79 std::unique_ptr<Points> pPoints; 80 81 //list of entity types supported by current action 82 const EntityTypeList enTypeList = EntityTypeList {RS2::EntityArc, RS2::EntityCircle, RS2::EntityLine, RS2::EntityPoint}; 83 }; 84 85 #endif 86