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