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