]> Shamusworld >> Repos - architektonas/blob - src/forms/dlgmoverotate.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / forms / dlgmoverotate.cpp
1 // dlgmoverotate.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  06/11/2010  Created this file. :-)
15 //
16
17 #include "dlgmoverotate.h"
18
19 #include "modification.h"
20 #include "settings.h"
21
22 DlgMoveRotate::DlgMoveRotate(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
23         QDialog(parent, flags)
24 {
25         ui.setupUi(this);
26
27         settings.beginGroup("Modify");
28         copies = settings.value("MoveRotateCopies", "10").toString();
29         numberMode = settings.value("MoveRotateMode", 0).toInt();
30         useCurrentLayer = settings.value("MoveRotateUseCurrentLayer", false).toBool();
31         useCurrentAttributes = settings.value("MoveRotateUseCurrentAttributes", false).toBool();
32         angle = settings.value("MoveRotateAngle", "0.0").toString();
33         settings.endGroup();
34
35         switch (numberMode)
36         {
37         case 0:
38                 ui.rbMove->setChecked(true);
39                 break;
40
41         case 1:
42                 ui.rbCopy->setChecked(true);
43                 break;
44
45         case 2:
46                 ui.rbMultiCopy->setChecked(true);
47                 break;
48
49         default:
50                 break;
51         }
52
53         ui.leNumber->setText(copies);
54         ui.leAngle->setText(angle);
55         ui.cbCurrentAttributes->setChecked(useCurrentAttributes);
56         ui.cbCurrentLayer->setChecked(useCurrentLayer);
57 }
58
59 DlgMoveRotate::~DlgMoveRotate()
60 {
61         settings.beginGroup("Modify");
62         settings.setValue("MoveRotateCopies", ui.leNumber->text());
63
64         if (ui.rbMove->isChecked())
65                 numberMode = 0;
66         else if (ui.rbCopy->isChecked())
67                 numberMode = 1;
68         else
69                 numberMode = 2;
70
71         settings.setValue("MoveRotateMode", numberMode);
72         settings.setValue("MoveRotateAngle", ui.leAngle->text());
73         settings.setValue("MoveRotateUseCurrentLayer", ui.cbCurrentLayer->isChecked());
74         settings.setValue("MoveRotateUseCurrentAttributes", ui.cbCurrentAttributes->isChecked());
75         settings.endGroup();
76 }
77
78 void DlgMoveRotate::setData(MoveRotateData * d)
79 {
80         data = d;
81         ui.leAngle->setText(QString("%1").arg(Math::rad2deg(data->angle)));
82 }
83
84 void DlgMoveRotate::updateData()
85 {
86         if (ui.rbMove->isChecked())
87                 data->number = 0;
88         else if (ui.rbCopy->isChecked())
89                 data->number = 1;
90         else
91                 data->number = ui.leNumber->text().toInt();
92
93         data->angle = Math::deg2rad(Math::eval(ui.leAngle->text()));
94         data->useCurrentAttributes = ui.cbCurrentAttributes->isChecked();
95         data->useCurrentLayer = ui.cbCurrentLayer->isChecked();
96 }