1 /****************************************************************************
2 ** $Id: rs_actionmodifymirror.cpp 1161 2004-12-09 23:10:09Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
27 #include "rs_actionmodifymirror.h"
29 #include "rs_snapper.h"
31 RS_ActionModifyMirror::RS_ActionModifyMirror(RS_EntityContainer& container,
32 RS_GraphicView& graphicView):
33 RS_PreviewActionInterface("Mirror Entities", container, graphicView)
37 QAction * RS_ActionModifyMirror::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
39 QAction * action = new QAction(tr("&Mirror"), 0);
40 // QAction* action = new QAction(tr("Mirror"), tr("&Mirror"),
41 // QKeySequence(), NULL);
42 action->setStatusTip(tr("Mirror Entities"));
46 void RS_ActionModifyMirror::init(int status)
48 RS_ActionInterface::init(status);
51 void RS_ActionModifyMirror::trigger()
54 RS_DEBUG->print("RS_ActionModifyMirror::trigger()");
56 RS_Modification m(*container, graphicView);
59 if (RS_DIALOGFACTORY!=NULL) {
60 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
66 void RS_ActionModifyMirror::mouseMoveEvent(QMouseEvent* e) {
67 RS_DEBUG->print("RS_ActionModifyMirror::mouseMoveEvent begin");
69 if (getStatus()==SetAxisPoint1 ||
70 getStatus()==SetAxisPoint2) {
72 Vector mouse = snapPoint(e);
73 switch (getStatus()) {
79 if (axisPoint1.valid) {
84 preview->addSelectionFrom(*container);
85 preview->mirror(axisPoint1, axisPoint2);
87 preview->addEntity(new RS_Line(preview,
88 RS_LineData(axisPoint1,
100 RS_DEBUG->print("RS_ActionModifyMirror::mouseMoveEvent end");
105 void RS_ActionModifyMirror::mouseReleaseEvent(QMouseEvent* e) {
106 if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
107 RS_CoordinateEvent ce(snapPoint(e));
108 coordinateEvent(&ce);
110 } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
119 void RS_ActionModifyMirror::coordinateEvent(RS_CoordinateEvent* e) {
124 Vector mouse = e->getCoordinate();
126 switch (getStatus()) {
129 setStatus(SetAxisPoint2);
130 graphicView->moveRelativeZero(mouse);
135 setStatus(ShowDialog);
136 graphicView->moveRelativeZero(mouse);
137 if (RS_DIALOGFACTORY!=NULL) {
138 if (RS_DIALOGFACTORY->requestMirrorDialog(data)) {
139 data.axisPoint1 = axisPoint1;
140 data.axisPoint2 = axisPoint2;
156 void RS_ActionModifyMirror::updateMouseButtonHints() {
157 if (RS_DIALOGFACTORY!=NULL) {
158 switch (getStatus()) {
160 RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to move"),
164 RS_DIALOGFACTORY->updateMouseWidget(
165 tr("Specify first point of mirror line"),
169 RS_DIALOGFACTORY->updateMouseWidget(
170 tr("Specify second point of mirror line"),
174 RS_DIALOGFACTORY->updateMouseWidget("", "");
182 void RS_ActionModifyMirror::updateMouseCursor() {
183 graphicView->setMouseCursor(RS2::CadCursor);
188 void RS_ActionModifyMirror::updateToolBar() {
189 if (RS_DIALOGFACTORY!=NULL) {
190 switch (getStatus()) {
193 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
196 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);