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"
19 #include "rs_dialogfactory.h"
20 #include "rs_modification.h"
21 #include "rs_preview.h"
23 ActionModifyStretch::ActionModifyStretch(RS_EntityContainer & container,
24 GraphicView & graphicView): ActionInterface("Stretch Entities",
25 container, graphicView)
27 firstCorner = Vector(false);
28 secondCorner = Vector(false);
29 referencePoint = Vector(false);
30 targetPoint = Vector(false);
33 ActionModifyStretch::~ActionModifyStretch()
37 void ActionModifyStretch::init(int status)
39 ActionInterface::init(status);
42 void ActionModifyStretch::trigger()
44 RS_DEBUG->print("ActionModifyStretch::trigger()");
51 RS_Modification m(*container, graphicView);
52 m.stretch(firstCorner, secondCorner, targetPoint - referencePoint);
56 setStatus(SetFirstCorner);
58 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
61 void ActionModifyStretch::mouseMoveEvent(QMouseEvent * e)
63 RS_DEBUG->print("ActionModifyStretch::mouseMoveEvent begin");
65 Vector mouse = snapPoint(e);
73 if (firstCorner.valid)
75 secondCorner = snapPoint(e);
78 /* preview->addEntity(
79 new RS_Line(preview, RS_LineData(Vector(firstCorner.x, firstCorner.y),
80 Vector(secondCorner.x, firstCorner.y))));
82 new RS_Line(preview, RS_LineData(Vector(secondCorner.x, firstCorner.y),
83 Vector(secondCorner.x, secondCorner.y))));
85 new RS_Line(preview, RS_LineData(Vector(secondCorner.x, secondCorner.y),
86 Vector(firstCorner.x, secondCorner.y))));
88 new RS_Line(preview, RS_LineData(Vector(firstCorner.x, secondCorner.y),
89 Vector(firstCorner.x, firstCorner.y))));*/
95 case SetReferencePoint:
99 if (referencePoint.valid)
105 /* preview->addStretchablesFrom(*container, firstCorner, secondCorner);
106 preview->stretch(firstCorner, secondCorner, targetPoint - referencePoint);*/
116 RS_DEBUG->print("ActionModifyStretch::mouseMoveEvent end");
119 void ActionModifyStretch::mouseReleaseEvent(QMouseEvent * e)
121 if (e->button() == Qt::LeftButton)
123 Vector ce(snapPoint(e));
124 coordinateEvent(&ce);
126 else if (e->button() == Qt::RightButton)
130 init(getStatus() - 1);
134 void ActionModifyStretch::coordinateEvent(Vector * e)
145 setStatus(SetSecondCorner);
148 case SetSecondCorner:
149 secondCorner = mouse;
152 setStatus(SetReferencePoint);
155 case SetReferencePoint:
156 referencePoint = mouse;
157 graphicView->moveRelativeZero(referencePoint);
158 setStatus(SetTargetPoint);
163 graphicView->moveRelativeZero(targetPoint);
173 void ActionModifyStretch::updateMouseButtonHints()
178 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
182 case SetSecondCorner:
183 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
187 case SetReferencePoint:
188 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
193 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify target point"),
198 RS_DIALOGFACTORY->updateMouseWidget("", "");
203 void ActionModifyStretch::updateMouseCursor()
205 graphicView->setMouseCursor(RS2::CadCursor);
208 void ActionModifyStretch::updateToolBar()
211 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
213 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);