]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actioninfoinside.cpp
Major refactoring of actions: Moved implementation from header files
[architektonas] / src / actions / rs_actioninfoinside.cpp
1 // rs_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 "rs_actioninfoinside.h"
16
17 #include "rs_dialogfactory.h"
18 #include "rs_graphicview.h"
19 #include "rs_information.h"
20
21 RS_ActionInfoInside::RS_ActionInfoInside(RS_EntityContainer & container, RS_GraphicView & graphicView):
22         RS_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 RS_ActionInfoInside::~RS_ActionInfoInside()
32 {
33         delete contour;
34 }
35
36 void RS_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 RS_ActionInfoInside::mouseMoveEvent(QMouseEvent * /*e*/)
50 {
51         //Vector mouse = snapPoint(e);
52         //bool onContour = false;
53         /*if (RS_Information::isPointInsideContour(mouse, contour, &onContour)) {
54            } else {
55            }*/
56 }
57
58 void RS_ActionInfoInside::mouseReleaseEvent(QMouseEvent * e)
59 {
60         if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
61         {
62                 deleteSnapper();
63                 init(getStatus() - 1);
64         }
65         else
66         {
67                 pt = snapPoint(e);
68                 trigger();
69         }
70 }
71
72 void RS_ActionInfoInside::updateMouseButtonHints()
73 {
74         switch (getStatus())
75         {
76         case 0:
77                 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Cancel"));
78                 break;
79
80         default:
81                 RS_DIALOGFACTORY->updateMouseWidget("", "");
82                 break;
83         }
84 }
85
86 void RS_ActionInfoInside::updateMouseCursor()
87 {
88         graphicView->setMouseCursor(RS2::CadCursor);
89 }
90
91 void RS_ActionInfoInside::updateToolBar()
92 {
93         if (!isFinished())
94                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
95         else
96                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);
97 }
98