1 /****************************************************************************
2 ** $Id: rs_actionmodifyscale.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_actionmodifyscale.h"
29 #include "rs_snapper.h"
33 RS_ActionModifyScale::RS_ActionModifyScale(RS_EntityContainer& container,
34 RS_GraphicView& graphicView)
35 :RS_PreviewActionInterface("Scale Entities",
36 container, graphicView) {}
39 QAction* RS_ActionModifyScale::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
41 QAction * action = new QAction(tr("&Scale"), 0);
42 // QAction* action = new QAction(tr("Scale"), tr("&Scale"),
43 // QKeySequence(), NULL);
44 action->setStatusTip(tr("Scale Entities"));
48 void RS_ActionModifyScale::init(int status) {
49 RS_ActionInterface::init(status);
55 void RS_ActionModifyScale::trigger() {
57 RS_DEBUG->print("RS_ActionModifyScale::trigger()");
59 RS_Modification m(*container, graphicView);
62 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
67 void RS_ActionModifyScale::mouseMoveEvent(QMouseEvent* e) {
68 RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent begin");
70 if (getStatus()==SetReferencePoint) {
72 Vector mouse = snapPoint(e);
73 switch (getStatus()) {
74 case SetReferencePoint:
75 referencePoint = mouse;
83 RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent end");
88 void RS_ActionModifyScale::mouseReleaseEvent(QMouseEvent* e) {
89 if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
90 Vector mouse = snapPoint(e);
92 switch (getStatus()) {
93 case SetReferencePoint:
94 setStatus(ShowDialog);
95 if (RS_DIALOGFACTORY->requestScaleDialog(data)) {
96 data.referencePoint = referencePoint;
105 } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
114 void RS_ActionModifyScale::updateMouseButtonHints() {
115 switch (getStatus()) {
117 RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to scale"),
120 case SetReferencePoint:
121 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
125 RS_DIALOGFACTORY->updateMouseWidget("", "");
132 void RS_ActionModifyScale::updateMouseCursor() {
133 graphicView->setMouseCursor(RS2::CadCursor);
138 void RS_ActionModifyScale::updateToolBar() {
139 switch (getStatus()) {
141 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
143 case SetReferencePoint:
144 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
147 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);