]> Shamusworld >> Repos - architektonas/blob - src/actions/actionselectcontour.cpp
0c018547d3d908558c8545f19aeb724f107ff693
[architektonas] / src / actions / actionselectcontour.cpp
1 // actionselectcontour.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  06/04/2010  Added this text. :-)
13 //
14
15 #include "actionselectcontour.h"
16
17 #include "rs_dialogfactory.h"
18 #include "rs_selection.h"
19
20 ActionSelectContour::ActionSelectContour(RS_EntityContainer & container,
21         GraphicView & graphicView):
22         ActionInterface("Select Contours", container, graphicView)
23 {
24         en = NULL;
25 }
26
27 ActionSelectContour::~ActionSelectContour()
28 {
29 }
30
31 /*virtual*/ RS2::ActionType ActionSelectContour::rtti()
32 {
33         return RS2::ActionSelectContour;
34 }
35
36 void ActionSelectContour::trigger()
37 {
38         if (en)
39         {
40                 if (en->isAtomic())
41                 {
42                         RS_Selection s(*container, graphicView);
43                         s.selectContour(en);
44
45                         if (RS_DIALOGFACTORY)
46                                 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
47                 }
48                 else if (RS_DIALOGFACTORY)
49                         RS_DIALOGFACTORY->commandMessage(tr("Entity must be an Atomic Entity."));
50         }
51         else
52                 RS_DEBUG->print("ActionSelectContour::trigger: Entity is NULL\n");
53 }
54
55 void ActionSelectContour::mouseReleaseEvent(QMouseEvent * e)
56 {
57         if (e->button() == Qt::RightButton)
58                 init(getStatus() - 1);
59         else
60         {
61                 en = catchEntity(e);
62                 trigger();
63         }
64 }
65
66 void ActionSelectContour::updateMouseCursor()
67 {
68         graphicView->setMouseCursor(RS2::SelectCursor);
69 }