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