1 /****************************************************************************
2 ** $Id: rs_actionsetrelativezero.cpp 1134 2004-07-13 23:26:13Z 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_actionsetrelativezero.h"
29 #include "rs_snapper.h"
34 RS_ActionSetRelativeZero::RS_ActionSetRelativeZero(RS_EntityContainer& container,
35 RS_GraphicView& graphicView)
36 :RS_PreviewActionInterface("Set the relative Zero",
37 container, graphicView) {}
40 QAction * RS_ActionSetRelativeZero::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
42 QAction * action = new QAction(tr("&Set Relative Zero"), 0);
43 // QAction* action = new QAction(tr("Set Relative Zero"), tr("&Set Relative Zero"),
44 // QKeySequence(), NULL);
45 action->setStatusTip(tr("Set position of the Relative Zero point"));
50 void RS_ActionSetRelativeZero::trigger() {
51 bool wasLocked = graphicView->isRelativeZeroLocked();
53 graphicView->lockRelativeZero(false);
54 graphicView->moveRelativeZero(pt);
55 graphicView->lockRelativeZero(wasLocked);
62 void RS_ActionSetRelativeZero::mouseMoveEvent(QMouseEvent* e) {
68 void RS_ActionSetRelativeZero::mouseReleaseEvent(QMouseEvent* e) {
69 if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
73 RS_CoordinateEvent ce(snapPoint(e));
80 void RS_ActionSetRelativeZero::coordinateEvent(RS_CoordinateEvent* e) {
85 pt = e->getCoordinate();
91 void RS_ActionSetRelativeZero::updateMouseButtonHints() {
92 switch (getStatus()) {
94 RS_DIALOGFACTORY->updateMouseWidget(tr("Set relative Zero"), tr("Cancel"));
97 RS_DIALOGFACTORY->updateMouseWidget("", "");
104 void RS_ActionSetRelativeZero::updateMouseCursor() {
105 graphicView->setMouseCursor(RS2::CadCursor);
110 void RS_ActionSetRelativeZero::updateToolBar() {
112 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
114 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);