]> Shamusworld >> Repos - architektonas/blob - src/actions/actioninfoinside.cpp
Last checkin before major refactor...
[architektonas] / src / actions / actioninfoinside.cpp
1 // actioninfoinside.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 "actioninfoinside.h"
16
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19 #include "rs_information.h"
20
21 ActionInfoInside::ActionInfoInside(RS_EntityContainer & container, GraphicView & graphicView):
22         ActionInterface("Info Inside", container, graphicView)
23 {
24         contour = new RS_EntityContainer(NULL, false);
25
26         for (RS_Entity * e = container.firstEntity(); e != NULL; e = container.nextEntity())
27                 if (e->isSelected())
28                         contour->addEntity(e);
29 }
30
31 ActionInfoInside::~ActionInfoInside()
32 {
33         delete contour;
34 }
35
36 void ActionInfoInside::trigger()
37 {
38         deleteSnapper();
39         bool onContour = false;
40
41         if (RS_Information::isPointInsideContour(pt, contour, &onContour))
42                 RS_DIALOGFACTORY->commandMessage(tr("Point is inside selected contour."));
43         else
44                 RS_DIALOGFACTORY->commandMessage(tr("Point is outside selected contour."));
45
46         finish();
47 }
48
49 void ActionInfoInside::mouseMoveEvent(QMouseEvent * /*e*/)
50 {
51 }
52
53 void ActionInfoInside::mouseReleaseEvent(QMouseEvent * e)
54 {
55         if (e->button() == Qt::RightButton)
56         {
57                 deleteSnapper();
58                 init(getStatus() - 1);
59         }
60         else
61         {
62                 pt = snapPoint(e);
63                 trigger();
64         }
65 }
66
67 void ActionInfoInside::updateMouseButtonHints()
68 {
69         switch (getStatus())
70         {
71         case 0:
72                 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Cancel"));
73                 break;
74
75         default:
76                 RS_DIALOGFACTORY->updateMouseWidget("", "");
77                 break;
78         }
79 }
80
81 void ActionInfoInside::updateMouseCursor()
82 {
83         graphicView->setMouseCursor(RS2::CadCursor);
84 }
85
86 void ActionInfoInside::updateToolBar()
87 {
88         if (!isFinished())
89                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
90         else
91                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
92 }