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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/04/2010 Added this text. :-)
15 #include "actionmodifystretch.h"
17 #include "rs_dialogfactory.h"
18 #include "rs_modification.h"
19 #include "rs_preview.h"
21 ActionModifyStretch::ActionModifyStretch(RS_EntityContainer & container,
22 GraphicView & graphicView): ActionInterface("Stretch Entities",
23 container, graphicView)
25 firstCorner = Vector(false);
26 secondCorner = Vector(false);
27 referencePoint = Vector(false);
28 targetPoint = Vector(false);
31 ActionModifyStretch::~ActionModifyStretch()
35 void ActionModifyStretch::init(int status)
37 ActionInterface::init(status);
40 void ActionModifyStretch::trigger()
42 RS_DEBUG->print("ActionModifyStretch::trigger()");
49 RS_Modification m(*container, graphicView);
50 m.stretch(firstCorner, secondCorner, targetPoint - referencePoint);
54 setStatus(SetFirstCorner);
56 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
59 void ActionModifyStretch::mouseMoveEvent(QMouseEvent * e)
61 RS_DEBUG->print("ActionModifyStretch::mouseMoveEvent begin");
63 Vector mouse = snapPoint(e);
71 if (firstCorner.valid)
73 secondCorner = snapPoint(e);
76 /* preview->addEntity(
77 new RS_Line(preview, RS_LineData(Vector(firstCorner.x, firstCorner.y),
78 Vector(secondCorner.x, firstCorner.y))));
80 new RS_Line(preview, RS_LineData(Vector(secondCorner.x, firstCorner.y),
81 Vector(secondCorner.x, secondCorner.y))));
83 new RS_Line(preview, RS_LineData(Vector(secondCorner.x, secondCorner.y),
84 Vector(firstCorner.x, secondCorner.y))));
86 new RS_Line(preview, RS_LineData(Vector(firstCorner.x, secondCorner.y),
87 Vector(firstCorner.x, firstCorner.y))));*/
93 case SetReferencePoint:
97 if (referencePoint.valid)
103 /* preview->addStretchablesFrom(*container, firstCorner, secondCorner);
104 preview->stretch(firstCorner, secondCorner, targetPoint - referencePoint);*/
114 RS_DEBUG->print("ActionModifyStretch::mouseMoveEvent end");
117 void ActionModifyStretch::mouseReleaseEvent(QMouseEvent * e)
119 if (e->button() == Qt::LeftButton)
121 Vector ce(snapPoint(e));
122 coordinateEvent(&ce);
124 else if (e->button() == Qt::RightButton)
128 init(getStatus() - 1);
132 void ActionModifyStretch::coordinateEvent(Vector * e)
143 setStatus(SetSecondCorner);
146 case SetSecondCorner:
147 secondCorner = mouse;
150 setStatus(SetReferencePoint);
153 case SetReferencePoint:
154 referencePoint = mouse;
155 graphicView->moveRelativeZero(referencePoint);
156 setStatus(SetTargetPoint);
161 graphicView->moveRelativeZero(targetPoint);
171 void ActionModifyStretch::updateMouseButtonHints()
176 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
180 case SetSecondCorner:
181 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
185 case SetReferencePoint:
186 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
191 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"),
196 RS_DIALOGFACTORY->updateMouseWidget("", "");
201 void ActionModifyStretch::updateMouseCursor()
203 graphicView->setMouseCursor(RS2::CadCursor);
206 void ActionModifyStretch::updateToolBar()
209 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
211 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);