]> Shamusworld >> Repos - architektonas/blob - src/forms/cadtoolbarselect.cpp
Initial import
[architektonas] / src / forms / cadtoolbarselect.cpp
1 // cadtoolbarselect.cpp
2 //
3 // Originally part of QCad Community Edition by Andrew Mustun
4 // Extensively rewritten and refactored by James L. Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James L. Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
10 // ---  ----------  -----------------------------------------------------------
11 // JLH  05/10/2010  Created this file. :-)
12 //
13
14 #include "cadtoolbarselect.h"
15
16 #include "cadtoolbar.h"
17 #include "qg_actionhandler.h"
18 #include "rs_actioninterface.h"
19
20 CadToolBarSelect::CadToolBarSelect(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
21         QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL), selectAction(NULL),
22         nextAction(-1)
23 {
24         ui.setupUi(this);
25 }
26
27 CadToolBarSelect::~CadToolBarSelect()
28 {
29 }
30
31 void CadToolBarSelect::mousePressEvent(QMouseEvent * e)
32 {
33         if (e->button() == Qt::RightButton && cadToolBar != NULL)
34         {
35                 cadToolBar->back();
36                 e->accept();
37         }
38 }
39
40 void CadToolBarSelect::contextMenuEvent(QContextMenuEvent *e) {
41         e->accept();
42 }
43
44 void CadToolBarSelect::setCadToolBar(CadToolBar * tb)
45 {
46         cadToolBar = tb;
47
48         if (tb != NULL)
49                 actionHandler = tb->getActionHandler();
50                 //actionHandler->setCadToolBarSelect(this);
51         else
52                 RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarSelect::setCadToolBar(): No valid toolbar set.");
53 }
54
55 void CadToolBarSelect::selectSingle()
56 {
57         if (actionHandler!=NULL) {
58                 actionHandler->slotSelectSingle();
59         }
60 }
61
62 void CadToolBarSelect::selectContour() {
63         if (actionHandler!=NULL) {
64                 actionHandler->slotSelectContour();
65         }
66 }
67
68 void CadToolBarSelect::deselectAll() {
69         if (actionHandler!=NULL) {
70                 actionHandler->slotDeselectAll();
71         }
72 }
73
74 void CadToolBarSelect::selectAll() {
75         if (actionHandler!=NULL) {
76                 actionHandler->slotSelectAll();
77         }
78 }
79
80 void CadToolBarSelect::selectWindow() {
81         if (actionHandler!=NULL) {
82                 actionHandler->slotSelectWindow();
83         }
84 }
85
86 void CadToolBarSelect::deselectWindow() {
87         if (actionHandler!=NULL) {
88                 actionHandler->slotDeselectWindow();
89         }
90 }
91
92 void CadToolBarSelect::selectIntersected() {
93         if (actionHandler!=NULL) {
94                 actionHandler->slotSelectIntersected();
95         }
96 }
97
98 void CadToolBarSelect::deselectIntersected() {
99         if (actionHandler!=NULL) {
100                 actionHandler->slotDeselectIntersected();
101         }
102 }
103
104 void CadToolBarSelect::selectInvert() {
105         if (actionHandler!=NULL) {
106                 actionHandler->slotSelectInvert();
107         }
108 }
109
110 void CadToolBarSelect::selectLayer()
111 {
112         if (actionHandler!=NULL)
113                 actionHandler->slotSelectLayer();
114 }
115
116 void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
117 {
118         this->selectAction = selectAction;
119 }
120
121 void CadToolBarSelect::setNextAction(int nextAction)
122 {
123         this->nextAction = nextAction;
124
125         if (nextAction == -1)
126                 ui.bDoit->hide();
127         else
128                 ui.bDoit->show();
129 }
130
131 void CadToolBarSelect::runNextAction()
132 {
133         if (selectAction != NULL)
134         {
135                 selectAction->finish();
136                 selectAction = NULL;
137         }
138
139         if (nextAction != -1)
140         {
141                 actionHandler->killSelectActions();
142                 actionHandler->setCurrentAction((RS2::ActionType)nextAction);
143         }
144 }
145
146 void CadToolBarSelect::back()
147 {
148         if (cadToolBar != NULL)
149                 cadToolBar->back();
150 }