]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actiondrawlinerelangle.h
9bd1ca55b9e3a20e25e9343bacd9ef3fef7f6579
[architektonas] / src / actions / rs_actiondrawlinerelangle.h
1 #ifndef RS_ACTIONDRAWLINERELANGLE_H
2 #define RS_ACTIONDRAWLINERELANGLE_H
3
4 #include "rs_previewactioninterface.h"
5
6
7 /**
8  * This action class can handle user events to draw lines with a given angle
9  * to a given entity.
10  *
11  * @author Andrew Mustun
12  */
13 class RS_ActionDrawLineRelAngle : public RS_PreviewActionInterface {
14         //Q_OBJECT
15 private:
16     enum Status {
17         SetEntity,     /**< Choose entity. */
18         SetPos,        /**< Choose position. */
19                 SetAngle,      /**< Set angle in console. */
20                 SetLength      /**< Set length in console. */
21     };
22
23 public:
24     RS_ActionDrawLineRelAngle(RS_EntityContainer& container,
25                               RS_GraphicView& graphicView,
26                               double angle=0.0,
27                               bool fixedAngle=false);
28     ~RS_ActionDrawLineRelAngle() {}
29
30         static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);
31
32         virtual RS2::ActionType rtti() {
33                 return RS2::ActionDrawLineRelAngle;
34         }
35
36     virtual void trigger();
37
38     virtual void mouseMoveEvent(QMouseEvent* e);
39     virtual void mouseReleaseEvent(QMouseEvent* e);
40
41         virtual void coordinateEvent(RS_CoordinateEvent* e);
42     virtual void commandEvent(RS_CommandEvent* e);
43         virtual QStringList getAvailableCommands();
44
45     virtual void hideOptions();
46     virtual void showOptions();
47
48     virtual void updateMouseButtonHints();
49     virtual void updateMouseCursor();
50     virtual void updateToolBar();
51
52         void setAngle(double a) {
53                 angle = a;
54         }
55
56         double getAngle() {
57                 return angle;
58         }
59
60         void setLength(double l) {
61                 length = l;
62         }
63
64         double getLength() {
65                 return length;
66         }
67
68         bool hasFixedAngle() {
69                 return fixedAngle;
70         }
71
72 private:
73     /** new line */
74     //RS_Line* line;
75     /** Chosen entity */
76     RS_Entity* entity;
77     /** Chosen position */
78     Vector pos;
79     /** Data of new line */
80     RS_LineData data;
81     /**
82      * Line angle.
83      */
84     double angle;
85     /**
86      * Line length.
87      */
88     double length;
89     /**
90      * Is the angle fixed?
91      */
92     bool fixedAngle;
93 };
94
95 #endif