]> Shamusworld >> Repos - architektonas/blob - src/forms/arctangentialoptions.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / forms / arctangentialoptions.cpp
1 // arctangentialoptions.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/08/2010  Created this file. :-)
15 //
16
17 #include "arctangentialoptions.h"
18
19 #include "actiondrawarctangential.h"
20 #include "debug.h"
21 #include "settings.h"
22
23 ArcTangentialOptions::ArcTangentialOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
24         QWidget(parent, flags),
25         lRadius(new QLabel(tr("Radius:"))),
26         leRadius(new QLineEdit(this))
27 {
28         QHBoxLayout * layout = new QHBoxLayout(this);
29         layout->setContentsMargins(0, 0, 0, 0);
30
31         leRadius->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
32
33         layout->addWidget(lRadius);
34         layout->addWidget(leRadius);
35
36         connect(leRadius, SIGNAL(textChanged(QString)), this, SLOT(updateRadius(QString)));
37
38         // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
39         // nothing will show up on the screen. :-)
40         if (parent)
41                 parent->addWidget(this);
42 }
43
44 ArcTangentialOptions::~ArcTangentialOptions()
45 {
46         settings.beginGroup("Draw");
47         settings.setValue("ArcTangentialRadius", leRadius->text());
48         settings.endGroup();
49 }
50
51 void ArcTangentialOptions::setAction(ActionInterface * a, bool update)
52 {
53         if (a != NULL && a->rtti() == RS2::ActionDrawArcTangential)
54         {
55                 action = (ActionDrawArcTangential *)a;
56
57                 QString sr;
58
59                 if (update)
60                         sr = QString("%1").arg(action->getRadius());
61                 else
62                 {
63                         settings.beginGroup("Draw");
64                         sr = settings.value("ArcTangentialRadius", "1.0").toString();
65                         settings.endGroup();
66                         action->setRadius(sr.toDouble());
67                 }
68                 leRadius->setText(sr);
69         }
70         else
71         {
72                 DEBUG->print(Debug::D_ERROR,
73                         "ArcTangentialOptions::setAction: wrong action type");
74                 action = NULL;
75         }
76 }
77
78 /*void ArcTangentialOptions::init() {
79     data = NULL;
80     RS_SETTINGS->beginGroup("/Draw");
81     bool reversed = RS_SETTINGS->readNumEntry("/ArcReversed", 0);
82     RS_SETTINGS->endGroup();
83
84     rbNeg->setChecked(reversed);
85    }*/
86
87 /*void ArcTangentialOptions::setData(ArcData* d) {
88     data = d;
89     updateDirection(false);
90    }*/
91
92 void ArcTangentialOptions::updateRadius(const QString & s)
93 {
94         if (action != NULL)
95                 action->setRadius(Math::eval(s));
96 }
97