]> Shamusworld >> Repos - architektonas/blobdiff - src/actions/rs_actionzoomwindow.cpp
Major refactoring of actions: Moved implementation from header files
[architektonas] / src / actions / rs_actionzoomwindow.cpp
index 65c09ffb3fae7f73dcc8b0228bd19eeb12576191..5ef6118ba966f32972152a8139696d6ea98d964c 100644 (file)
@@ -1,36 +1,22 @@
-/****************************************************************************
-** $Id: rs_actionzoomwindow.cpp 1134 2004-07-13 23:26:13Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionzoomwindow.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/05/2010  Added this text. :-)
+//
 
 #include "rs_actionzoomwindow.h"
 
-#include "rs.h"
-#include "rs_snapper.h"
-#include "rs_point.h"
-//Added by qt3to4:
-//#include <QIcon>
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_preview.h"
 
 /**
  * Default constructor.
  *          area will be fit to the viewport.
  */
 RS_ActionZoomWindow::RS_ActionZoomWindow(RS_EntityContainer & container,
-       RS_GraphicView& graphicView, bool keepAspectRatio):
+       RS_GraphicView & graphicView, bool keepAspectRatio):
        RS_PreviewActionInterface("Zoom Window", container, graphicView)
 {
        this->keepAspectRatio = keepAspectRatio;
 }
 
-QAction* RS_ActionZoomWindow::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
+RS_ActionZoomWindow::~RS_ActionZoomWindow()
 {
-       QAction * action = new QAction(QIcon(":/res/zoomwindow.png"), tr("&Window Zoom"), 0);
-//     QAction* action = new QAction(tr("Window Zoom"), QPixmap::fromMimeSource("zoomwindow.png"),
-//                                                                     tr("&Window Zoom"), QKeySequence(), NULL);
-       action->setStatusTip(tr("Zooms in a window"));
-       return action;
 }
 
 void RS_ActionZoomWindow::init(int status)
@@ -92,13 +73,13 @@ void RS_ActionZoomWindow::mouseMoveEvent(QMouseEvent * e)
                deletePreview();
                clearPreview();
                preview->addEntity(new RS_Line(preview,
-                       RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
+                               RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
                preview->addEntity(new RS_Line(preview,
-                       RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
+                               RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
                preview->addEntity(new RS_Line(preview,
-                       RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
+                               RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
                preview->addEntity(new RS_Line(preview,
-                       RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));
+                               RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));
                drawPreview();
        }
 }
@@ -129,20 +110,16 @@ void RS_ActionZoomWindow::mouseReleaseEvent(QMouseEvent * e)
        if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
        {
                if (getStatus() == 1)
-               {
                        deletePreview();
-               }
 
                init(getStatus() - 1);
        }
        else if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
-       {
                if (getStatus() == 1)
                {
                        v2 = snapPoint(e);
                        trigger();
                }
-       }
 }
 
 void RS_ActionZoomWindow::updateMouseButtonHints()
@@ -154,9 +131,11 @@ void RS_ActionZoomWindow::updateMouseButtonHints()
        case 0:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first edge"), tr("Cancel"));
                break;
+
        case 1:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second edge"), tr("Back"));
                break;
+
        default:
                RS_DIALOGFACTORY->updateMouseWidget("", "");
                break;