]> Shamusworld >> Repos - architektonas/blob - src/actions/actionmodifyentity.cpp
Adding missing implementation.
[architektonas] / src / actions / actionmodifyentity.cpp
1 // actionmodifyentity.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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  06/04/2010  Added this text. :-)
15 //
16
17 #include "actionmodifyentity.h"
18
19 #include "rs_debug.h"
20 #include "rs_dialogfactory.h"
21 #include "graphicview.h"
22
23 ActionModifyEntity::ActionModifyEntity(RS_EntityContainer & container,
24         GraphicView & graphicView):
25         ActionInterface("Modify Entity", container, graphicView)
26 {
27         en = NULL;
28 }
29
30 ActionModifyEntity::~ActionModifyEntity()
31 {
32 }
33
34 void ActionModifyEntity::trigger()
35 {
36         if (en != NULL)
37         {
38                 RS_Entity * clone = en->clone();
39
40                 if (RS_DIALOGFACTORY->requestModifyEntityDialog(clone))
41                 {
42                         container->addEntity(clone);
43
44                         graphicView->deleteEntity(en);
45                         en->setSelected(false);
46
47                         clone->setSelected(false);
48                         graphicView->drawEntity(clone);
49
50                         if (document != NULL)
51                         {
52                                 document->startUndoCycle();
53
54                                 document->addUndoable(clone);
55                                 en->setUndoState(true);
56                                 document->addUndoable(en);
57
58                                 document->endUndoCycle();
59                         }
60                         RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
61                 }
62                 else
63                         delete clone;
64
65         }
66         else
67                 RS_DEBUG->print("ActionModifyEntity::trigger: Entity is NULL\n");
68 }
69
70 void ActionModifyEntity::mouseReleaseEvent(QMouseEvent * e)
71 {
72         if (e->button() == Qt::RightButton)
73                 init(getStatus() - 1);
74         else
75         {
76                 en = catchEntity(e);
77                 trigger();
78         }
79 }
80
81 void ActionModifyEntity::updateMouseCursor()
82 {
83         graphicView->setMouseCursor(RS2::SelectCursor);
84 }
85
86