]> Shamusworld >> Repos - architektonas/blob - src/actions/actionmodifyentity.cpp
93cf9965ff6b1e0b274202609e693a105da40e2a
[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_dialogfactory.h"
20 #include "graphicview.h"
21
22 ActionModifyEntity::ActionModifyEntity(RS_EntityContainer & container,
23         GraphicView & graphicView):
24         ActionInterface("Modify Entity", container, graphicView)
25 {
26         en = NULL;
27 }
28
29 ActionModifyEntity::~ActionModifyEntity()
30 {
31 }
32
33 void ActionModifyEntity::trigger()
34 {
35         if (en != NULL)
36         {
37                 RS_Entity * clone = en->clone();
38
39                 if (RS_DIALOGFACTORY->requestModifyEntityDialog(clone))
40                 {
41                         container->addEntity(clone);
42
43                         graphicView->deleteEntity(en);
44                         en->setSelected(false);
45
46                         clone->setSelected(false);
47                         graphicView->drawEntity(clone);
48
49                         if (document != NULL)
50                         {
51                                 document->startUndoCycle();
52
53                                 document->addUndoable(clone);
54                                 en->setUndoState(true);
55                                 document->addUndoable(en);
56
57                                 document->endUndoCycle();
58                         }
59                         RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
60                 }
61                 else
62                         delete clone;
63
64         }
65         else
66                 RS_DEBUG->print("ActionModifyEntity::trigger: Entity is NULL\n");
67 }
68
69 void ActionModifyEntity::mouseReleaseEvent(QMouseEvent * e)
70 {
71         if (e->button() == Qt::RightButton)
72                 init(getStatus() - 1);
73         else
74         {
75                 en = catchEntity(e);
76                 trigger();
77         }
78 }
79
80 void ActionModifyEntity::updateMouseCursor()
81 {
82         graphicView->setMouseCursor(RS2::SelectCursor);
83 }
84
85