]> Shamusworld >> Repos - architektonas/blob - src/actions/actionmodifyentity.cpp
Initial removal of unnecessary rs_ prefixes from files.
[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 /*
18 Program received signal SIGSEGV, Segmentation fault.
19 0x080d0fd1 in PaintInterface::fillRect(int, int, int, int, RS_Color const&) ()
20 (gdb) bt
21 #0  0x080d0fd1 in PaintInterface::fillRect(int, int, int, int, RS_Color const&)
22     ()
23 #1  0x080cf523 in PaintInterface::drawHandle(Vector const&, RS_Color const&, int) ()
24 #2  0x0822d7e0 in GraphicView::drawEntity(RS_Entity*, double, bool) ()
25 #3  0x0822d9a0 in GraphicView::deleteEntity(RS_Entity*) ()
26 #4  0x081334dc in ActionModifyEntity::trigger() ()
27 #5  0x081336ef in ActionModifyEntity::mouseReleaseEvent(QMouseEvent*) ()
28 #6  0x08089d2a in RS_EventHandler::mouseReleaseEvent(QMouseEvent*) ()
29 #7  0x0822a482 in GraphicView::mouseReleaseEvent(QMouseEvent*) ()
30 #8  0x081eb00a in QG_GraphicView::mouseReleaseEvent(QMouseEvent*) ()
31 #9  0xb77063c1 in QWidget::event(QEvent*) () from /usr/lib/qt4/libQtGui.so.4
32 #10 0xb76a6b0c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
33    from /usr/lib/qt4/libQtGui.so.4
34 #11 0xb76ae24a in QApplication::notify(QObject*, QEvent*) ()
35    from /usr/lib/qt4/libQtGui.so.4
36 #12 0xb7458882 in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
37    from /usr/lib/qt4/libQtCore.so.4
38 #13 0xb76acfa8 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
39    from /usr/lib/qt4/libQtGui.so.4
40 #14 0xb7739755 in ?? () from /usr/lib/qt4/libQtGui.so.4
41 #15 0xb7738bac in QApplication::x11ProcessEvent(_XEvent*) ()
42    from /usr/lib/qt4/libQtGui.so.4
43 #16 0xb7766064 in ?? () from /usr/lib/qt4/libQtGui.so.4
44 #17 0xb720b654 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
45 #18 0xb720f430 in ?? () from /usr/lib/libglib-2.0.so.0
46 #19 0xb720f5d8 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
47 #20 0xb7484ed5 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
48 #21 0xb7765b85 in ?? () from /usr/lib/qt4/libQtGui.so.4
49 #22 0xb7456de9 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
50 #23 0xb745724a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
51    from /usr/lib/qt4/libQtCore.so.4
52 #24 0xb745c56f in QCoreApplication::exec() () from /usr/lib/qt4/libQtCore.so.4
53 #25 0xb76a6ba7 in QApplication::exec() () from /usr/lib/qt4/libQtGui.so.4
54 #26 0x082325e7 in main ()
55 */
56
57 #include "actionmodifyentity.h"
58
59 #include "debug.h"
60 #include "dialogfactory.h"
61 #include "graphicview.h"
62
63 ActionModifyEntity::ActionModifyEntity(RS_EntityContainer & container,
64         GraphicView & graphicView):
65         ActionInterface("Modify Entity", container, graphicView), en(NULL)
66 {
67 //      en = NULL;
68 }
69
70 ActionModifyEntity::~ActionModifyEntity()
71 {
72 }
73
74 void ActionModifyEntity::trigger()
75 {
76         if (!en)
77         {
78                 RS_DEBUG->print("ActionModifyEntity::trigger: Entity is NULL\n");
79                 return;
80         }
81
82         RS_Entity * clone = en->clone();
83
84         if (RS_DIALOGFACTORY->requestModifyEntityDialog(clone))
85         {
86                 container->addEntity(clone);
87 #warning "!!! Old rendering path need upgrade !!!"
88 #if 0
89                 //(delete from screen...bleh)
90                 graphicView->deleteEntity(en);
91 #endif
92                 en->setSelected(false);
93                 clone->setSelected(false);
94                 graphicView->drawEntity(clone);
95
96                 if (document)
97                 {
98                         document->startUndoCycle();
99                         document->addUndoable(clone);
100                         en->setUndoState(true);
101                         document->addUndoable(en);
102                         document->endUndoCycle();
103                 }
104
105                 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
106         }
107         else
108                 delete clone;
109 }
110
111 void ActionModifyEntity::mouseReleaseEvent(QMouseEvent * e)
112 {
113         if (e->button() == Qt::RightButton)
114                 init(getStatus() - 1);
115         else
116         {
117                 en = catchEntity(e);
118                 trigger();
119         }
120 }
121
122 void ActionModifyEntity::updateMouseCursor()
123 {
124         graphicView->setMouseCursor(RS2::SelectCursor);
125 }