]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionzoomin.cpp
Initial import
[architektonas] / src / actions / rs_actionzoomin.cpp
1 // rs_actionzoomin.cpp
2 //
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 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  05/28/2010  Added this text. :-)
13 //
14
15 #include "rs_actionzoomin.h"
16
17 /**
18  * Default constructor.
19  *
20  * @param direction In for zooming in, Out for zooming out.
21  * @param axis Axis that are affected by the zoom (OnlyX, OnlyY or Both)
22  */
23 RS_ActionZoomIn::RS_ActionZoomIn(RS_EntityContainer& container,
24         RS_GraphicView& graphicView, RS2::ZoomDirection direction,
25         RS2::Axis axis, const Vector& center):
26         RS_ActionInterface("Zoom in", container, graphicView)
27 {
28         this->direction = direction;
29         this->axis = axis;
30         this->center = center;
31 }
32
33 QAction * RS_ActionZoomIn::createGUIAction(RS2::ActionType type, QObject * /*parent*/)
34 {
35         QAction * action;
36
37         if (type == RS2::ActionZoomIn)
38         {
39                 action = new QAction(QIcon(":/res/zoomin.png"), tr("Zoom &In"), 0);
40 //              action = new QAction(tr("Zoom in"), QPixmap::fromMimeSource("zoomin.png"),
41 //                                                              tr("Zoom &In"), QKeySequence(), NULL);
42                 action->setStatusTip(tr("Zooms in"));
43         }
44         else
45         {
46                 action = new QAction(QIcon(":/res/zoomout.png"), tr("Zoom &Out"), 0);
47 //              action = new QAction(tr("Zoom out"), QPixmap::fromMimeSource("zoomout.png"),
48 //                                                              tr("Zoom &Out"), QKeySequence(), NULL);
49                 action->setStatusTip(tr("Zooms out"));
50         }
51
52         return action;
53 }
54
55 void RS_ActionZoomIn::init(int status)
56 {
57         RS_ActionInterface::init(status);
58         trigger();
59 }
60
61 void RS_ActionZoomIn::trigger()
62 {
63         switch (axis)
64         {
65         case RS2::OnlyX:
66                 if (direction == RS2::In)
67                 {
68                         graphicView->zoomInX();
69                 }
70                 else
71                 {
72                         graphicView->zoomOutX();
73                 }
74                 break;
75
76         case RS2::OnlyY:
77                 if (direction == RS2::In)
78                 {
79                         graphicView->zoomInY();
80                 }
81                 else
82                 {
83                         graphicView->zoomOutY();
84                 }
85                 break;
86
87         case RS2::Both:
88                 if (direction == RS2::In)
89                 {
90                         graphicView->zoomIn(1.25, center);
91                 }
92                 else
93                 {
94                         graphicView->zoomOut(1.25, center);
95                 }
96                 break;
97         }
98
99         finish();
100 }
101
102 // EOF