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