]> Shamusworld >> Repos - architektonas/blob - src/forms/polylineoptions.cpp
Phase 3 of polyline functionality added: Create polyline somewhat working...
[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         bClose(new QToolButton(this)),
28         bUndo(new QToolButton(this))
29 {
30         QHBoxLayout * layout = new QHBoxLayout(this);
31         layout->setContentsMargins(0, 0, 0, 0);
32
33         bClose->setText(tr("Close"));
34         bUndo->setText(tr("Undo"));
35
36         layout->addWidget(bClose);
37         layout->addWidget(bUndo);
38
39         connect(bClose, SIGNAL(clicked()), this, SLOT(close()));
40         connect(bUndo, SIGNAL(clicked()), this, SLOT(undo()));
41
42         // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
43         // nothing will show up on the screen. :-)
44         if (parent)
45                 parent->addWidget(this);
46 }
47
48 PolylineOptions::~PolylineOptions()
49 {
50 }
51
52 void PolylineOptions::setAction(ActionInterface * a, bool /*update*/)
53 {
54         if (a && a->rtti() == RS2::ActionDrawPolyline)
55         {
56                 action = (ActionDrawPolyline *)a;
57         }
58         else
59         {
60                 DEBUG->print(Debug::D_ERROR, "PolylineOptions::setAction: wrong action type");
61                 action = NULL;
62         }
63 }
64
65 void PolylineOptions::close()
66 {
67         if (action)
68                 action->close();
69 }
70
71 void PolylineOptions::undo()
72 {
73         if (action)
74                 action->undo();
75 }