]> Shamusworld >> Repos - architektonas/blob - src/forms/dlgline.cpp
86075384cc9a3b98242afefecf4dc5bb0571d6d4
[architektonas] / src / forms / dlgline.cpp
1 // dlgline.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  06/11/2010  Created this file. :-)
13 //
14
15 #include "dlgline.h"
16
17 #include "rs_insert.h"
18 #include "drawing.h"
19 #include "rs_math.h"
20
21 DlgLine::DlgLine(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
22         QDialog(parent, flags)
23 {
24         ui.setupUi(this);
25 }
26
27 DlgLine::~DlgLine()
28 {
29 }
30
31 void DlgLine::setLine(RS_Line & l)
32 {
33         line = &l;
34         //pen = line->getPen();
35         ui.wPen->setPen(line->getPen(false), true, false, "Pen");
36         Drawing * graphic = line->getGraphic();
37
38         if (graphic)
39                 ui.cbLayer->init(*(graphic->getLayerList()), false, false);
40
41         RS_Layer * lay = line->getLayer(false);
42
43         if (lay)
44                 ui.cbLayer->setLayer(*lay);
45
46         QString s;
47         s.setNum(line->getStartpoint().x);
48         ui.leStartX->setText(s);
49         s.setNum(line->getStartpoint().y);
50         ui.leStartY->setText(s);
51         s.setNum(line->getEndpoint().x);
52         ui.leEndX->setText(s);
53         s.setNum(line->getEndpoint().y);
54         ui.leEndY->setText(s);
55 }
56
57 void DlgLine::updateLine()
58 {
59         line->setStartpoint(Vector(RS_Math::eval(ui.leStartX->text()),
60                 RS_Math::eval(ui.leStartY->text())));
61         line->setEndpoint(Vector(RS_Math::eval(ui.leEndX->text()),
62                 RS_Math::eval(ui.leEndY->text())));
63         line->setPen(ui.wPen->getPen());
64         line->setLayer(ui.cbLayer->currentText());
65 }