]> Shamusworld >> Repos - architektonas/blob - src/forms/dlginsert.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / forms / dlginsert.cpp
1 // dlginsert.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  06/11/2010  Created this file. :-)
15 //
16
17 #include "dlginsert.h"
18
19 #include "insert.h"
20 #include "drawing.h"
21 #include "math.h"
22
23 DlgInsert::DlgInsert(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
24         QDialog(parent, flags)
25 {
26         ui.setupUi(this);
27 }
28
29 DlgInsert::~DlgInsert()
30 {
31 }
32
33 void DlgInsert::setInsert(Insert & i)
34 {
35         insert = &i;
36         //pen = insert->getPen();
37         ui.wPen->setPen(insert->getPen(false), true, false, "Pen");
38         Drawing * graphic = insert->getGraphic();
39
40         if (graphic)
41                 ui.cbLayer->init(*(graphic->getLayerList()), false, false);
42
43         Layer * lay = insert->getLayer(false);
44
45         if (lay)
46                 ui.cbLayer->setLayer(*lay);
47
48         QString s;
49         s.setNum(insert->getInsertionPoint().x);
50         ui.leInsertionPointX->setText(s);
51         s.setNum(insert->getInsertionPoint().y);
52         ui.leInsertionPointY->setText(s);
53         s.setNum(insert->getScale().x);
54         ui.leScale->setText(s);
55         s.setNum(Math::rad2deg(insert->getAngle()));
56         ui.leAngle->setText(s);
57         s.setNum(insert->getRows());
58         ui.leRows->setText(s);
59         s.setNum(insert->getCols());
60         ui.leCols->setText(s);
61         s.setNum(insert->getSpacing().x);
62         ui.leRowSpacing->setText(s);
63         s.setNum(insert->getSpacing().y);
64         ui.leColSpacing->setText(s);
65 }
66
67 void DlgInsert::updateInsert()
68 {
69         insert->setInsertionPoint(Vector(Math::eval(ui.leInsertionPointX->text()),
70                 Math::eval(ui.leInsertionPointY->text())));
71         insert->setScale(Vector(Math::eval(ui.leScale->text()),
72                 Math::eval(ui.leScale->text())));
73         insert->setAngle(Math::deg2rad(Math::eval(ui.leAngle->text())));
74         insert->setRows(Math::round(Math::eval(ui.leRows->text())));
75         insert->setCols(Math::round(Math::eval(ui.leCols->text())));
76         insert->setSpacing(Vector(Math::eval(ui.leRowSpacing->text()),
77                 Math::eval(ui.leColSpacing->text())));
78         insert->setPen(ui.wPen->getPen());
79         insert->setLayer(ui.cbLayer->currentText());
80 }