1 // actiondrawlineparallelthrough.cpp
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
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 06/04/2010 Added this text. :-)
17 #include "actiondrawlineparallelthrough.h"
19 #include "commandevent.h"
22 #include "dialogfactory.h"
23 #include "graphicview.h"
26 ActionDrawLineParallelThrough::ActionDrawLineParallelThrough(
27 EntityContainer & container, GraphicView & graphicView):
28 ActionInterface("Draw Parallels", container, graphicView)
34 coord = Vector(false);
37 ActionDrawLineParallelThrough::~ActionDrawLineParallelThrough()
41 /*virtual*/ RS2::ActionType ActionDrawLineParallelThrough::rtti()
43 return RS2::ActionDrawLineParallelThrough;
46 void ActionDrawLineParallelThrough::trigger()
48 ActionInterface::trigger();
53 Creation creation(container, graphicView);
54 Entity * e = creation.createParallelThrough(coord, number, entity);
57 DEBUG->print("ActionDrawLineParallelThrough::trigger:"
58 " No parallels added\n");
62 void ActionDrawLineParallelThrough::mouseMoveEvent(QMouseEvent * e)
64 DEBUG->print("ActionDrawLineParallelThrough::mouseMoveEvent begin");
69 entity = catchEntity(e, RS2::ResolveAll);
78 // Creation creation(preview, NULL, false);
79 // creation.createParallelThrough(coord, number, entity);
89 DEBUG->print("ActionDrawLineParallelThrough::mouseMoveEvent end");
92 void ActionDrawLineParallelThrough::mouseReleaseEvent(QMouseEvent * e)
94 if (e->button() == Qt::LeftButton)
99 entity = catchEntity(e, RS2::ResolveAll);
103 entity->setHighlighted(true);
104 graphicView->drawEntity(entity);
112 Vector ce(snapPoint(e));
113 coordinateEvent(&ce);
121 else if (e->button() == Qt::RightButton)
128 entity->setHighlighted(false);
129 graphicView->drawEntity(entity);
133 init(getStatus() - 1);
137 void ActionDrawLineParallelThrough::coordinateEvent(Vector * e)
156 void ActionDrawLineParallelThrough::updateMouseButtonHints()
161 DIALOGFACTORY->updateMouseWidget(tr("Select entity"), tr("Cancel"));
165 DIALOGFACTORY->updateMouseWidget(tr("Specify through point"), tr("Back"));
169 DIALOGFACTORY->updateMouseWidget(tr("Number:"), tr("Back"));
173 DIALOGFACTORY->updateMouseWidget("", "");
178 void ActionDrawLineParallelThrough::showOptions()
180 ActionInterface::showOptions();
181 DIALOGFACTORY->requestOptions(this, true);
182 updateMouseButtonHints();
185 void ActionDrawLineParallelThrough::hideOptions()
187 ActionInterface::hideOptions();
188 DIALOGFACTORY->requestOptions(this, false);
191 void ActionDrawLineParallelThrough::commandEvent(CommandEvent * e)
193 QString c = e->getCommand().toLower();
195 if (checkCommand("help", c))
197 DIALOGFACTORY->commandMessage(msgAvailableCommands()
198 + getAvailableCommands().join(", "));
207 if (checkCommand("number", c))
212 lastStatus = (Status)getStatus();
213 setStatus(SetNumber);
220 int n = c.toInt(&ok);
224 if (n > 0 && n < 100)
227 DIALOGFACTORY->commandMessage(tr("Not a valid number. "
231 DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
232 DIALOGFACTORY->requestOptions(this, true, true);
233 setStatus(lastStatus);
242 QStringList ActionDrawLineParallelThrough::getAvailableCommands()
249 cmd += command("number");
259 void ActionDrawLineParallelThrough::updateMouseCursor()
261 graphicView->setMouseCursor(RS2::CadCursor);
264 void ActionDrawLineParallelThrough::updateToolBar()
266 if (getStatus() == SetPos && !isFinished())
267 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
269 DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
272 int ActionDrawLineParallelThrough::getNumber()
277 void ActionDrawLineParallelThrough::setNumber(int n)