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
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/10/2010 Created this file. :-)
15 #include "cadtoolbar.h"
17 #include "cadtoolbararcs.h"
18 #include "cadtoolbarcircles.h"
19 #include "cadtoolbardim.h"
20 #include "cadtoolbarellipses.h"
21 #include "cadtoolbarinfo.h"
22 #include "cadtoolbarlines.h"
23 #include "cadtoolbarmain.h"
24 #include "cadtoolbarmodify.h"
25 #include "cadtoolbarpoints.h"
26 #include "cadtoolbarpolylines.h"
27 #include "cadtoolbarselect.h"
28 #include "cadtoolbarsnap.h"
29 #include "cadtoolbarsplines.h"
32 CadToolBar::CadToolBar(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
33 QWidget(parent, flags), actionHandler(NULL), currentTb(NULL), tbSplines(NULL),
34 tbInfo(NULL),tbMain(NULL), tbDim(NULL), tbLines(NULL), tbPoints(NULL),
35 tbEllipses(NULL), tbArcs(NULL), tbModify(NULL), tbCircles(NULL), tbSnap(NULL),
36 tbSelect(NULL), tbPolylines(NULL)
39 //hm. here maybe? Yesh!
41 ((QToolBar *)parent)->addWidget(this);
44 CadToolBar::~CadToolBar()
49 * @return Pointer to action handler or NULL.
51 QG_ActionHandler * CadToolBar::getActionHandler()
57 * Called from the sub toolbar
59 void CadToolBar::back()
65 * Called from the application.
67 void CadToolBar::forceNext()
69 if (currentTb && currentTb == tbSelect)
70 tbSelect->runNextAction();
73 void CadToolBar::mouseReleaseEvent(QMouseEvent * e)
75 if (e->button() == Qt::RightButton)
82 void CadToolBar::contextMenuEvent(QContextMenuEvent * e)
88 * Creates all tool bars and shows the main toolbar.
90 * @param ah Pointer to action handler which will deal with the actions in this tool bar.
92 void CadToolBar::createSubToolBars(QG_ActionHandler * ah)
95 tbMain = new CadToolBarMain(this);
96 tbMain->setCadToolBar(this);
99 tbPoints = new CadToolBarPoints(this);
100 tbPoints->setCadToolBar(this);
103 tbLines = new CadToolBarLines(this);
104 // tbLines->setCadToolBar(this);
107 tbArcs = new CadToolBarArcs(this);
108 tbArcs->setCadToolBar(this);
111 tbCircles = new CadToolBarCircles(this);
112 tbCircles->setCadToolBar(this);
115 tbEllipses = new CadToolBarEllipses(this);
116 tbEllipses->setCadToolBar(this);
119 tbSplines = new CadToolBarSplines(this);
120 tbSplines->setCadToolBar(this);
123 tbPolylines = new CadToolBarPolylines(this);
124 tbPolylines->setCadToolBar(this);
127 tbDim = new CadToolBarDim(this);
128 tbDim->setCadToolBar(this);
131 tbInfo = new CadToolBarInfo(this);
132 tbInfo->setCadToolBar(this);
135 tbModify = new CadToolBarModify(this);
136 tbModify->setCadToolBar(this);
139 tbSnap = new CadToolBarSnap(this);
140 tbSnap->setCadToolBar(this);
143 tbSelect = new CadToolBarSelect(this);
144 tbSelect->setCadToolBar(this);
148 void CadToolBar::showToolBar(int id)
150 QWidget * newTb = NULL;
155 case RS2::ToolBarMain:
158 case RS2::ToolBarPoints:
161 case RS2::ToolBarLines:
164 case RS2::ToolBarArcs:
167 case RS2::ToolBarEllipses:
170 case RS2::ToolBarSplines:
173 case RS2::ToolBarPolylines:
176 case RS2::ToolBarCircles:
179 case RS2::ToolBarInfo:
182 case RS2::ToolBarModify:
185 case RS2::ToolBarDim:
188 case RS2::ToolBarSnap:
191 case RS2::ToolBarSelect:
196 if (currentTb == newTb)
208 void CadToolBar::showToolBarMain()
210 showToolBar(RS2::ToolBarMain);
213 void CadToolBar::showToolBarPoints()
215 showToolBar(RS2::ToolBarPoints);
218 void CadToolBar::showToolBarLines()
220 showToolBar(RS2::ToolBarLines);
223 void CadToolBar::showToolBarArcs()
225 showToolBar(RS2::ToolBarArcs);
228 void CadToolBar::showToolBarEllipses()
230 showToolBar(RS2::ToolBarEllipses);
233 void CadToolBar::showToolBarSplines()
235 showToolBar(RS2::ToolBarSplines);
238 void CadToolBar::showToolBarPolylines()
241 showToolBar(RS2::ToolBarPolylines);
245 void CadToolBar::showToolBarCircles()
247 showToolBar(RS2::ToolBarCircles);
250 void CadToolBar::showToolBarInfo()
252 showToolBar(RS2::ToolBarInfo);
255 void CadToolBar::showToolBarModify()
257 showToolBar(RS2::ToolBarModify);
260 void CadToolBar::showToolBarSnap()
262 showToolBar(RS2::ToolBarSnap);
265 void CadToolBar::showToolBarDim()
267 showToolBar(RS2::ToolBarDim);
270 void CadToolBar::showToolBarSelect()
272 showToolBarSelect(NULL, -1);
275 void CadToolBar::showToolBarSelect(RS_ActionInterface * selectAction, int nextAction)
277 tbSelect->setNextAction(nextAction);
278 tbSelect->setSelectAction(selectAction);
279 showToolBar(RS2::ToolBarSelect);