]> Shamusworld >> Repos - architektonas/blob - src/forms/textoptions.cpp
In the middle of major refactoring...
[architektonas] / src / forms / textoptions.cpp
1 // textoptions.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  05/28/2010  Created this file. :-)
13 //
14
15 #include "textoptions.h"
16
17 #include "actiondrawtext.h"
18 #include "actioninterface.h"
19
20 TextOptions::TextOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
21         QWidget(parent, flags)
22 {
23         ui.setupUi(this);
24
25         // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
26         // nothing will show up on the screen. :-)
27         if (parent)
28                 parent->addWidget(this);
29 }
30
31 TextOptions::~TextOptions()
32 {
33 }
34
35 void TextOptions::setAction(ActionInterface * a, bool update)
36 {
37         if (a != NULL && a->rtti() == RS2::ActionDrawText)
38         {
39                 action = (ActionDrawText *)a;
40
41                 QString st;
42                 QString sa;
43
44                 if (update)
45                 {
46                         st = action->getText();
47                         sa = QString("%1").arg(RS_Math::rad2deg(action->getAngle()));
48                 }
49                 else
50                 {
51                         st = "";
52                         sa = "0.0";
53                 }
54
55                 ui.teText->setText(st);
56                 ui.leAngle->setText(sa);
57         }
58         else
59         {
60                 RS_DEBUG->print(RS_Debug::D_ERROR, "TextOptions::setAction: wrong action type");
61                 action = NULL;
62         }
63 }
64
65 void TextOptions::updateText()
66 {
67         if (action != NULL)
68                 action->setText(ui.teText->text());
69 }
70
71 void TextOptions::updateAngle()
72 {
73         if (action != NULL)
74                 action->setAngle(RS_Math::deg2rad(RS_Math::eval(ui.leAngle->text())));
75 }