1 /****************************************************************************
2 **
3 ** This file is part of the LibreCAD project, a 2D CAD program
4 **
5 ** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
6 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
7 **
8 **
9 ** This file may be distributed and/or modified under the terms of the
10 ** GNU General Public License version 2 as published by the Free Software
11 ** Foundation and appearing in the file gpl-2.0.txt included in the
12 ** packaging of this file.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** You should have received a copy of the GNU General Public License
20 ** along with this program; if not, write to the Free Software
21 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 **
23 ** This copyright notice MUST APPEAR in all copies of the script!
24 **
25 **********************************************************************/
26 #include "qg_dlgcircle.h"
27
28
29 #include "rs_circle.h"
30 #include "rs_graphic.h"
31 #include "rs_math.h"
32
33 /*
34 * Constructs a QG_DlgCircle as a child of 'parent', with the
35 * name 'name' and widget flags set to 'f'.
36 *
37 * The dialog will by default be modeless, unless you set 'modal' to
38 * true to construct a modal dialog.
39 */
QG_DlgCircle(QWidget * parent,bool modal,Qt::WindowFlags fl)40 QG_DlgCircle::QG_DlgCircle(QWidget* parent, bool modal, Qt::WindowFlags fl)
41 : QDialog(parent, fl)
42 {
43 setModal(modal);
44 setupUi(this);
45
46 }
47
48 /*
49 * Destroys the object and frees any allocated resources
50 */
~QG_DlgCircle()51 QG_DlgCircle::~QG_DlgCircle()
52 {
53 // no need to delete child widgets, Qt does it all for us
54 }
55
56 /*
57 * Sets the strings of the subwidgets using the current
58 * language.
59 */
languageChange()60 void QG_DlgCircle::languageChange()
61 {
62 retranslateUi(this);
63 }
64
setCircle(RS_Circle & c)65 void QG_DlgCircle::setCircle(RS_Circle& c) {
66 circle = &c;
67 //pen = circle->getPen();
68 wPen->setPen(circle->getPen(false), true, false, "Pen");
69 RS_Graphic* graphic = circle->getGraphic();
70 if (graphic) {
71 cbLayer->init(*(graphic->getLayerList()), false, false);
72 }
73 RS_Layer* lay = circle->getLayer(false);
74 if (lay) {
75 cbLayer->setLayer(*lay);
76 }
77 QString s;
78 s.setNum(circle->getCenter().x);
79 leCenterX->setText(s);
80 s.setNum(circle->getCenter().y);
81 leCenterY->setText(s);
82 s.setNum(circle->getRadius());
83 leRadius->setText(s);
84 }
85
updateCircle()86 void QG_DlgCircle::updateCircle() {
87 circle->setCenter(RS_Vector(RS_Math::eval(leCenterX->text()),
88 RS_Math::eval(leCenterY->text())));
89 circle->setRadius(RS_Math::eval(leRadius->text()));
90 circle->setPen(wPen->getPen());
91 circle->setLayer(cbLayer->currentText());
92 circle->calculateBorders();
93 }
94
95