]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actioneditcopy.cpp
e174d428e0c025b43f2b165711f9ecafd0cae078
[architektonas] / src / actions / rs_actioneditcopy.cpp
1 // rs_actioneditcopy.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  05/22/2010  Added this text. :-)
13 //
14
15 #include "rs_actioneditcopy.h"
16
17 #include "rs_dialogfactory.h"
18 #include "rs_modification.h"
19
20 /**
21  * Constructor.
22  *
23  * @param undo true for undo and false for redo.
24  */
25 RS_ActionEditCopy::RS_ActionEditCopy(bool copy, RS_EntityContainer & container, GraphicView & graphicView):
26         RS_ActionInterface("Edit Copy", container, graphicView)
27 {
28         this->copy = copy;
29 }
30
31 RS_ActionEditCopy::~RS_ActionEditCopy()
32 {
33 }
34
35 void RS_ActionEditCopy::init(int status)
36 {
37         RS_ActionInterface::init(status);
38         //trigger();
39 }
40
41 void RS_ActionEditCopy::trigger()
42 {
43         deleteSnapper();
44
45         RS_Modification m(*container, graphicView);
46         m.copy(referencePoint, !copy);
47
48         //graphicView->redraw();
49         finish();
50         graphicView->killSelectActions();
51         //init(getStatus()-1);
52         RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
53 }
54
55 void RS_ActionEditCopy::mouseMoveEvent(QMouseEvent * e)
56 {
57         snapPoint(e);
58 }
59
60 void RS_ActionEditCopy::mouseReleaseEvent(QMouseEvent * e)
61 {
62         if (e->button() == Qt::LeftButton)
63         {
64                 Vector ce(snapPoint(e));
65                 coordinateEvent(&ce);
66         }
67         else if (e->button() == Qt::RightButton)
68         {
69                 deleteSnapper();
70                 init(getStatus() - 1);
71         }
72 }
73
74 void RS_ActionEditCopy::coordinateEvent(Vector * e)
75 {
76         if (e == NULL)
77                 return;
78
79         referencePoint = *e;
80         trigger();
81 }
82
83 void RS_ActionEditCopy::updateMouseButtonHints()
84 {
85         switch (getStatus())
86         {
87         case SetReferencePoint:
88                 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
89                         tr("Cancel"));
90                 break;
91
92         default:
93                 RS_DIALOGFACTORY->updateMouseWidget("", "");
94                 break;
95         }
96 }
97
98 void RS_ActionEditCopy::updateMouseCursor()
99 {
100         graphicView->setMouseCursor(RS2::CadCursor);
101 }
102
103 void RS_ActionEditCopy::updateToolBar()
104 {
105         if (!isFinished())
106                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
107         else
108                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
109 }
110
111 // EOF