]> Shamusworld >> Repos - architektonas/blob - src/forms/polylineoptions.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / forms / polylineoptions.cpp
1 // polylineoptions.cpp
2 //
3 // Part of the Architektonas Project
4 // by James L. Hammons
5 // Copyright (C) 2010 Underground Software
6 // See the README and GPLv2 files for licensing and warranty information
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  09/13/2010  Created this file. :-)
13 //
14
15 // NOTE: Still need to add "Arc" checkbox and "Radius" textedit
16 #warning "!!! Still need to add 'Arc' checkbox and 'Radius' textedit !!!"
17
18 #include "polylineoptions.h"
19
20 #include "enums.h"
21 #include "actiondrawpolyline.h"
22 #include "actioninterface.h"
23 #include "debug.h"
24
25 PolylineOptions::PolylineOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
26         QWidget(parent, flags), action(NULL),
27         closeButton(new QToolButton(this)),
28         undoButton(new QToolButton(this)),
29         arcCheckBox(new QCheckBox(this)),
30         radiusLabel(new QLabel(this)),
31         radiusEdit(new QLineEdit(this))
32 {
33         QHBoxLayout * layout = new QHBoxLayout(this);
34         layout->setContentsMargins(0, 0, 0, 0);
35
36         closeButton->setText(tr("Close"));
37         undoButton->setText(tr("Undo"));
38         arcCheckBox->setText(tr("Arc"));
39         radiusLabel->setText(tr("Radius:"));
40
41         layout->addWidget(closeButton);
42         layout->addWidget(undoButton);
43         layout->addWidget(arcCheckBox);
44         layout->addWidget(radiusLabel);
45         layout->addWidget(radiusEdit);
46
47         connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
48         connect(undoButton, SIGNAL(clicked()), this, SLOT(undo()));
49
50         // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
51         // nothing will show up on the screen. :-)
52         if (parent)
53                 parent->addWidget(this);
54 }
55
56 PolylineOptions::~PolylineOptions()
57 {
58 }
59
60 void PolylineOptions::setAction(ActionInterface * a, bool /*update*/)
61 {
62         if (a && a->rtti() == RS2::ActionDrawPolyline)
63         {
64                 action = (ActionDrawPolyline *)a;
65         }
66         else
67         {
68                 DEBUG->print(Debug::D_ERROR, "PolylineOptions::setAction: wrong action type");
69                 action = NULL;
70         }
71 }
72
73 void PolylineOptions::close()
74 {
75         if (action)
76                 action->close();
77 }
78
79 void PolylineOptions::undo()
80 {
81         if (action)
82                 action->undo();
83 }