]> Shamusworld >> Repos - architektonas/blob - src/forms/dlgcircle.cpp
72fc3fca5bb0d3e19b1e00754b09a1235a91917a
[architektonas] / src / forms / dlgcircle.cpp
1 // dlgcircle.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 "dlgcircle.h"
16
17 #include "rs_circle.h"
18 #include "drawing.h"
19 #include "rs_math.h"
20
21 DlgCircle::DlgCircle(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
22         QDialog(parent, flags)
23 {
24         ui.setupUi(this);
25 }
26
27 DlgCircle::~DlgCircle()
28 {
29 }
30
31 void DlgCircle::setCircle(RS_Circle & c)
32 {
33         circle = &c;
34         //pen = circle->getPen();
35         ui.wPen->setPen(circle->getPen(false), true, false, "Pen");
36         Drawing * graphic = circle->getGraphic();
37
38         if (graphic != NULL)
39                 ui.cbLayer->init(*(graphic->getLayerList()), false, false);
40
41         RS_Layer * lay = circle->getLayer(false);
42
43         if (lay != NULL)
44                 ui.cbLayer->setLayer(*lay);
45
46         QString s;
47         s.setNum(circle->getCenter().x);
48         ui.leCenterX->setText(s);
49         s.setNum(circle->getCenter().y);
50         ui.leCenterY->setText(s);
51         s.setNum(circle->getRadius());
52         ui.leRadius->setText(s);
53 }
54
55 void DlgCircle::updateCircle()
56 {
57         circle->setCenter(Vector(RS_Math::eval(ui.leCenterX->text()),
58                 RS_Math::eval(ui.leCenterY->text())));
59         circle->setRadius(RS_Math::eval(ui.leRadius->text()));
60         circle->setPen(ui.wPen->getPen());
61         circle->setLayer(ui.cbLayer->currentText());
62         circle->calculateBorders();
63 }