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