]> Shamusworld >> Repos - architektonas/blob - src/forms/dlgrotate2.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / forms / dlgrotate2.cpp
1 // dlgrotate2.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/12/2010  Created this file. :-)
15 //
16
17 #include "dlgrotate2.h"
18
19 #include "modification.h"
20 #include "settings.h"
21
22 DlgRotate2::DlgRotate2(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("Rotate2Copies", "10").toString();
29         numberMode = settings.value("Rotate2Mode", 0).toInt();
30         useCurrentLayer = settings.value("Rotate2UseCurrentLayer", false).toBool();
31         useCurrentAttributes = settings.value("MoveRotate2UseCurrentAttributes", false).toBool();
32         angle1 = settings.value("Rotate2Angle1", "30.0").toString();
33         angle2 = settings.value("Rotate2Angle2", "-30.0").toString();
34         settings.endGroup();
35
36         switch (numberMode)
37         {
38         case 0:
39                 ui.rbMove->setChecked(true);
40                 break;
41
42         case 1:
43                 ui.rbCopy->setChecked(true);
44                 break;
45
46         case 2:
47                 ui.rbMultiCopy->setChecked(true);
48                 break;
49
50         default:
51                 break;
52         }
53
54         ui.leNumber->setText(copies);
55         ui.leAngle1->setText(angle1);
56         ui.leAngle2->setText(angle2);
57         ui.cbCurrentAttributes->setChecked(useCurrentAttributes);
58         ui.cbCurrentLayer->setChecked(useCurrentLayer);
59 }
60
61 DlgRotate2::~DlgRotate2()
62 {
63         settings.beginGroup("Modify");
64         settings.setValue("Rotate2Copies", ui.leNumber->text());
65
66         if (ui.rbMove->isChecked())
67                 numberMode = 0;
68         else if (ui.rbCopy->isChecked())
69                 numberMode = 1;
70         else
71                 numberMode = 2;
72
73         settings.setValue("Rotate2Mode", numberMode);
74         settings.setValue("Rotate2Angle1", ui.leAngle1->text());
75         settings.setValue("Rotate2Angle2", ui.leAngle2->text());
76         settings.setValue("Rotate2UseCurrentLayer", ui.cbCurrentLayer->isChecked());
77         settings.setValue("Rotate2UseCurrentAttributes", ui.cbCurrentAttributes->isChecked());
78         settings.endGroup();
79 }
80
81 void DlgRotate2::setData(Rotate2Data * d)
82 {
83         data = d;
84
85         //leAngle1->setText(QString("%1").arg(Math::rad2deg(data->angle1)));
86         //leAngle2->setText(QString("%1").arg(Math::rad2deg(data->angle2)));
87 }
88
89 void DlgRotate2::updateData()
90 {
91         if (ui.rbMove->isChecked())
92                 data->number = 0;
93         else if (ui.rbCopy->isChecked())
94                 data->number = 1;
95         else
96                 data->number = ui.leNumber->text().toInt();
97
98         data->angle1 = Math::deg2rad(Math::eval(ui.leAngle1->text()));
99         data->angle2 = Math::deg2rad(Math::eval(ui.leAngle2->text()));
100         data->useCurrentAttributes = ui.cbCurrentAttributes->isChecked();
101         data->useCurrentLayer = ui.cbCurrentLayer->isChecked();
102 }