1 // actionmodifystretch.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 "actionmodifystretch.h"
20 #include "dialogfactory.h"
21 #include "modification.h"
24 ActionModifyStretch::ActionModifyStretch(EntityContainer & container,
25 GraphicView & graphicView): ActionInterface("Stretch Entities",
26 container, graphicView)
28 firstCorner = Vector(false);
29 secondCorner = Vector(false);
30 referencePoint = Vector(false);
31 targetPoint = Vector(false);
34 ActionModifyStretch::~ActionModifyStretch()
38 void ActionModifyStretch::init(int status)
40 ActionInterface::init(status);
43 void ActionModifyStretch::trigger()
45 DEBUG->print("ActionModifyStretch::trigger()");
52 Modification m(*container, graphicView);
53 m.stretch(firstCorner, secondCorner, targetPoint - referencePoint);
57 setStatus(SetFirstCorner);
59 DIALOGFACTORY->updateSelectionWidget(container->countSelected());
62 void ActionModifyStretch::mouseMoveEvent(QMouseEvent * e)
64 DEBUG->print("ActionModifyStretch::mouseMoveEvent begin");
66 Vector mouse = snapPoint(e);
74 if (firstCorner.valid)
76 secondCorner = snapPoint(e);
79 /* preview->addEntity(
80 new Line(preview, LineData(Vector(firstCorner.x, firstCorner.y),
81 Vector(secondCorner.x, firstCorner.y))));
83 new Line(preview, LineData(Vector(secondCorner.x, firstCorner.y),
84 Vector(secondCorner.x, secondCorner.y))));
86 new Line(preview, LineData(Vector(secondCorner.x, secondCorner.y),
87 Vector(firstCorner.x, secondCorner.y))));
89 new Line(preview, LineData(Vector(firstCorner.x, secondCorner.y),
90 Vector(firstCorner.x, firstCorner.y))));*/
96 case SetReferencePoint:
100 if (referencePoint.valid)
106 /* preview->addStretchablesFrom(*container, firstCorner, secondCorner);
107 preview->stretch(firstCorner, secondCorner, targetPoint - referencePoint);*/
117 DEBUG->print("ActionModifyStretch::mouseMoveEvent end");
120 void ActionModifyStretch::mouseReleaseEvent(QMouseEvent * e)
122 if (e->button() == Qt::LeftButton)
124 Vector ce(snapPoint(e));
125 coordinateEvent(&ce);
127 else if (e->button() == Qt::RightButton)
131 init(getStatus() - 1);
135 void ActionModifyStretch::coordinateEvent(Vector * e)
146 setStatus(SetSecondCorner);
149 case SetSecondCorner:
150 secondCorner = mouse;
153 setStatus(SetReferencePoint);
156 case SetReferencePoint:
157 referencePoint = mouse;
158 graphicView->moveRelativeZero(referencePoint);
159 setStatus(SetTargetPoint);
164 graphicView->moveRelativeZero(targetPoint);
174 void ActionModifyStretch::updateMouseButtonHints()
179 DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
183 case SetSecondCorner:
184 DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
188 case SetReferencePoint:
189 DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
194 DIALOGFACTORY->updateMouseWidget(tr("Specify target point"),
199 DIALOGFACTORY->updateMouseWidget("", "");
204 void ActionModifyStretch::updateMouseCursor()
206 graphicView->setMouseCursor(RS2::CadCursor);
209 void ActionModifyStretch::updateToolBar()
212 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
214 DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);