~librecad-dev/librecad/librecad

« back to all changes in this revision

Viewing changes to librecad/src/actions/rs_actiondrawcircletan3.h

  • Committer: Scott Howard
  • Date: 2014-02-21 19:07:55 UTC
  • Revision ID: showard@debian.org-20140221190755-csjax9wb146hgdq4
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <QVector>
 
28
#include "rs_circle.h"
 
29
#include "rs_previewactioninterface.h"
 
30
 
 
31
/**
 
32
 * Draw ellipse by foci and a point on ellipse
 
33
 *
 
34
 * @author Dongxu Li
 
35
 */
 
36
class RS_ActionDrawCircleTan3 : public RS_PreviewActionInterface {
 
37
        Q_OBJECT
 
38
public:
 
39
    /**
 
40
     * Action States.
 
41
     */
 
42
    enum Status {
 
43
        SetCircle1,   //  Setting the First Circle.  */
 
44
        SetCircle2,   //  Setting the Second Circle.  */
 
45
        SetCircle3,   //  Setting the Third Circle.  */
 
46
        SetCenter   //  select the closest tangential Circle.  */
 
47
    };
 
48
 
 
49
public:
 
50
    RS_ActionDrawCircleTan3(RS_EntityContainer& container,
 
51
                                 RS_GraphicView& graphicView);
 
52
    ~RS_ActionDrawCircleTan3();
 
53
 
 
54
    static QAction* createGUIAction(RS2::ActionType type, QObject* /*parent*/);
 
55
 
 
56
    virtual RS2::ActionType rtti() {
 
57
        return RS2::ActionDrawCircleTan3;
 
58
    }
 
59
    virtual void init(int status=0);
 
60
 
 
61
    virtual void trigger();
 
62
    virtual bool getData();
 
63
    virtual bool preparePreview();
 
64
 
 
65
    virtual void mouseMoveEvent(QMouseEvent* e);
 
66
    virtual void mouseReleaseEvent(QMouseEvent* e);
 
67
 
 
68
    //        virtual void coordinateEvent(RS_CoordinateEvent* e);
 
69
    //    virtual void commandEvent(RS_CommandEvent* e);
 
70
    virtual QStringList getAvailableCommands();
 
71
    virtual void finish(bool updateTB=true);
 
72
    virtual void updateMouseButtonHints();
 
73
    virtual void updateMouseCursor();
 
74
//    virtual void updateToolBar();
 
75
 
 
76
//    virtual void showOptions();
 
77
//    virtual void hideOptions();
 
78
 
 
79
 
 
80
 
 
81
//protected:
 
82
    private:
 
83
    QVector<double> verifyCenter(const RS_Vector& center) const;
 
84
    QVector<double> getRadii(RS_AtomicEntity* entity, const RS_Vector& center) const;
 
85
    RS_Entity* catchCircle(QMouseEvent* e);
 
86
    QVector<RS_AtomicEntity*> circles;
 
87
    RS_CircleData cData;
 
88
    QVector<RS_CircleData> m_vCandidates;
 
89
    RS_Vector coord;
 
90
    bool valid;
 
91
    QVector<RS2::EntityType> enTypeList;
 
92
    //keep a list of centers found
 
93
    QList<RS_Circle> candidates;
 
94
    RS_VectorSolutions centers;
 
95
 
 
96
};
 
97
 
 
98
#endif