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