~librecad-dev/librecad/librecad

« back to all changes in this revision

Viewing changes to librecad/src/ui/forms/qg_dlgpolyline.cpp

  • Committer: Scott Howard
  • Date: 2014-02-21 19:07:55 UTC
  • Revision ID: showard@debian.org-20140221190755-csjax9wb146hgdq4
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** This file is part of the LibreCAD project, a 2D CAD program
 
4
**
 
5
** Copyright (C) 2011 Rallaz (rallazz@gmail.com)
 
6
**
 
7
**
 
8
** This file is free software; you can redistribute it and/or modify
 
9
** it under the terms of the GNU General Public License as published by
 
10
** the Free Software Foundation; either version 2 of the License, or
 
11
** (at your option) any later version.
 
12
**
 
13
** This program is distributed in the hope that it will be useful,
 
14
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
** GNU General Public License for more details.
 
17
** 
 
18
** You should have received a copy of the GNU General Public License
 
19
** along with this program; if not, write to the Free Software
 
20
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
21
**
 
22
** This copyright notice MUST APPEAR in all copies of the script!  
 
23
**
 
24
**********************************************************************/
 
25
#include "qg_dlgpolyline.h"
 
26
 
 
27
#include "rs_polyline.h"
 
28
#include "rs_graphic.h"
 
29
/*#include "rs_layer.h"
 
30
#include "qg_widgetpen.h"
 
31
#include "qg_layerbox.h"*/
 
32
 
 
33
/*
 
34
 *  Constructs a QG_DlgPolyline 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
 */
 
40
QG_DlgPolyline::QG_DlgPolyline(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
 */
 
51
QG_DlgPolyline::~QG_DlgPolyline()
 
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
 */
 
60
void QG_DlgPolyline::languageChange()
 
61
{
 
62
    retranslateUi(this);
 
63
}
 
64
 
 
65
void QG_DlgPolyline::setPolyline(RS_Polyline& e) {
 
66
    polyline = &e;
 
67
    //pen = spline->getPen();
 
68
    wPen->setPen(polyline->getPen(false), true, false, "Pen");
 
69
    RS_Graphic* graphic = polyline->getGraphic();
 
70
    if (graphic!=NULL) {
 
71
        cbLayer->init(*(graphic->getLayerList()), false, false);
 
72
    }
 
73
    RS_Layer* lay = polyline->getLayer(false);
 
74
    if (lay!=NULL) {
 
75
        cbLayer->setLayer(*lay);
 
76
    }
 
77
        
 
78
    cbClosed->setChecked(polyline->isClosed());
 
79
}
 
80
 
 
81
 
 
82
 
 
83
void QG_DlgPolyline::updatePolyline() {
 
84
    polyline->setClosed(cbClosed->isChecked(), 0.0);
 
85
    polyline->setPen(wPen->getPen());
 
86
    polyline->setLayer(cbLayer->currentText());
 
87
        polyline->update();
 
88
}
 
89