1 // actionmodifymirror.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 "actionmodifymirror.h"
20 #include "dialogfactory.h"
23 ActionModifyMirror::ActionModifyMirror(EntityContainer & container, GraphicView & graphicView):
24 ActionInterface("Mirror Entities", container, graphicView)
28 ActionModifyMirror::~ActionModifyMirror()
32 void ActionModifyMirror::init(int status)
34 ActionInterface::init(status);
37 void ActionModifyMirror::trigger()
39 DEBUG->print("ActionModifyMirror::trigger()");
41 Modification m(*container, graphicView);
45 DIALOGFACTORY->updateSelectionWidget(container->countSelected());
48 void ActionModifyMirror::mouseMoveEvent(QMouseEvent * e)
50 DEBUG->print("ActionModifyMirror::mouseMoveEvent begin");
52 if (getStatus() == SetAxisPoint1 || getStatus() == SetAxisPoint2)
54 Vector mouse = snapPoint(e);
70 /* preview->addSelectionFrom(*container);
71 preview->mirror(axisPoint1, axisPoint2);
72 preview->addEntity(new Line(preview,LineData(axisPoint1, axisPoint2)));*/
74 graphicView->preview.clear();
75 graphicView->preview.addSelectionFrom(*container);
76 graphicView->preview.mirror(axisPoint1, axisPoint2);
77 graphicView->preview.addEntity(new Line(&(graphicView->preview), LineData(axisPoint1, axisPoint2)));
78 graphicView->redraw();
86 graphicView->redraw();
89 DEBUG->print("ActionModifyMirror::mouseMoveEvent end");
92 void ActionModifyMirror::mouseReleaseEvent(QMouseEvent * e)
94 if (e->button() == Qt::LeftButton)
96 Vector ce(snapPoint(e));
99 else if (e->button() == Qt::RightButton)
103 init(getStatus() - 1);
104 graphicView->redraw(); //hm.
108 void ActionModifyMirror::coordinateEvent(Vector * e)
119 setStatus(SetAxisPoint2);
120 graphicView->moveRelativeZero(mouse);
125 setStatus(ShowDialog);
126 graphicView->moveRelativeZero(mouse);
130 if (DIALOGFACTORY->requestMirrorDialog(data))
132 data.axisPoint1 = axisPoint1;
133 data.axisPoint2 = axisPoint2;
138 graphicView->redraw(); //hm.
148 void ActionModifyMirror::updateMouseButtonHints()
155 DIALOGFACTORY->updateMouseWidget(tr("Pick entities to move"),
159 DIALOGFACTORY->updateMouseWidget(
160 tr("Specify first point of mirror line"), tr("Cancel"));
164 DIALOGFACTORY->updateMouseWidget(
165 tr("Specify second point of mirror line"), tr("Back"));
169 DIALOGFACTORY->updateMouseWidget("", "");
175 void ActionModifyMirror::updateMouseCursor()
177 graphicView->setMouseCursor(RS2::CadCursor);
180 void ActionModifyMirror::updateToolBar()
188 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
192 DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);