]> Shamusworld >> Repos - architektonas/blob - src/forms/textoptions.cpp
Initial import
[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 "rs_actiondrawtext.h"
18 #include "rs_actioninterface.h"
19
20 TextOptions::TextOptions(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/)
21 {
22         ui.setupUi(this);
23 }
24
25 TextOptions::~TextOptions()
26 {
27 }
28
29 void TextOptions::setAction(RS_ActionInterface * a, bool update)
30 {
31         if (a != NULL && a->rtti() == RS2::ActionDrawText)
32         {
33                 action = (RS_ActionDrawText *)a;
34
35                 QString st;
36                 QString sa;
37
38                 if (update)
39                 {
40                         st = action->getText();
41                         sa = QString("%1").arg(RS_Math::rad2deg(action->getAngle()));
42                 }
43                 else
44                 {
45                         st = "";
46                         sa = "0.0";
47                 }
48
49                 ui.teText->setText(st);
50                 ui.leAngle->setText(sa);
51         }
52         else
53         {
54                 RS_DEBUG->print(RS_Debug::D_ERROR, "TextOptions::setAction: wrong action type");
55                 action = NULL;
56         }
57 }
58
59 void TextOptions::updateText()
60 {
61         if (action != NULL)
62                 action->setText(ui.teText->text());
63 }
64
65 void TextOptions::updateAngle()
66 {
67         if (action != NULL)
68                 action->setAngle(RS_Math::deg2rad(RS_Math::eval(ui.leAngle->text())));
69 }