]> Shamusworld >> Repos - architektonas/blob - src/forms/imageoptions.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / forms / imageoptions.cpp
1 // imageoptions.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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  05/12/2010  Created this file. :-)
15 //
16
17 #include "imageoptions.h"
18
19 #include "enums.h"
20 #include "actiondrawimage.h"
21 #include "actioninterface.h"
22 #include "debug.h"
23 #include "settings.h"
24
25 ImageOptions::ImageOptions(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
26         QWidget(parent, flags)
27 {
28         ui.setupUi(this);
29 }
30
31 ImageOptions::~ImageOptions()
32 {
33         settings.beginGroup("Image");
34         settings.setValue("ImageAngle", ui.leAngle->text());
35         settings.setValue("ImageFactor", ui.leFactor->text());
36         settings.endGroup();
37 }
38
39 void ImageOptions::setAction(ActionInterface * a, bool update)
40 {
41         if (a != NULL && a->rtti() == RS2::ActionDrawImage)
42         {
43                 action = (ActionDrawImage *)a;
44
45                 QString sAngle;
46                 QString sFactor;
47
48                 if (update)
49                 {
50                         sAngle = QString("%1").arg(Math::rad2deg(action->getAngle()));
51                         sFactor = QString("%1").arg(action->getFactor());
52                 }
53                 else
54                 {
55                         settings.beginGroup("Image");
56                         sAngle = settings.value("ImageAngle", "0.0").toString();
57                         sFactor = settings.value("ImageFactor", "1.0").toString();
58                         settings.endGroup();
59                 }
60
61                 ui.leAngle->setText(sAngle);
62                 ui.leFactor->setText(sFactor);
63                 updateData();
64         }
65         else
66         {
67                 DEBUG->print(Debug::D_ERROR, "ImageOptions::setAction: wrong action type");
68                 action = NULL;
69         }
70 }
71
72 void ImageOptions::updateData()
73 {
74         if (action != NULL)
75         {
76                 action->setAngle(Math::deg2rad(Math::eval(ui.leAngle->text())));
77                 action->setFactor(Math::eval(ui.leFactor->text()));
78         }
79 }