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_dlgspline.h"
27 
28 #include "rs_spline.h"
29 #include "rs_graphic.h"
30 #include "rs_layer.h"
31 #include "qg_widgetpen.h"
32 #include "qg_layerbox.h"
33 #include "rs_math.h"
34 
35 /*
36  *  Constructs a QG_DlgSpline as a child of 'parent', with the
37  *  name 'name' and widget flags set to 'f'.
38  *
39  *  The dialog will by default be modeless, unless you set 'modal' to
40  *  true to construct a modal dialog.
41  */
QG_DlgSpline(QWidget * parent,bool modal,Qt::WindowFlags fl)42 QG_DlgSpline::QG_DlgSpline(QWidget* parent, bool modal, Qt::WindowFlags fl)
43     : QDialog(parent, fl)
44 {
45     setModal(modal);
46     setupUi(this);
47 
48 }
49 
50 /*
51  *  Destroys the object and frees any allocated resources
52  */
~QG_DlgSpline()53 QG_DlgSpline::~QG_DlgSpline()
54 {
55     // no need to delete child widgets, Qt does it all for us
56 }
57 
58 /*
59  *  Sets the strings of the subwidgets using the current
60  *  language.
61  */
languageChange()62 void QG_DlgSpline::languageChange()
63 {
64     retranslateUi(this);
65 }
66 
setSpline(RS_Spline & e)67 void QG_DlgSpline::setSpline(RS_Spline& e) {
68     spline = &e;
69     //pen = spline->getPen();
70     wPen->setPen(spline->getPen(false), true, false, "Pen");
71     RS_Graphic* graphic = spline->getGraphic();
72     if (graphic) {
73         cbLayer->init(*(graphic->getLayerList()), false, false);
74     }
75     RS_Layer* lay = spline->getLayer(false);
76     if (lay) {
77         cbLayer->setLayer(*lay);
78     }
79 
80     QString s;
81     s.setNum(spline->getDegree());
82     cbDegree->setCurrentIndex( cbDegree->findText(s) );
83 
84     cbClosed->setChecked(spline->isClosed());
85 }
86 
87 
88 
updateSpline()89 void QG_DlgSpline::updateSpline() {
90     spline->setDegree(RS_Math::round(RS_Math::eval(cbDegree->currentText())));
91     spline->setClosed(cbClosed->isChecked());
92     spline->setPen(wPen->getPen());
93     spline->setLayer(cbLayer->currentText());
94 	spline->update();
95 }
96 
97