1
/****************************************************************************
3
** This file is part of the LibreCAD project, a 2D CAD program
5
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
6
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
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.
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.
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
23
** This copyright notice MUST APPEAR in all copies of the script!
25
**********************************************************************/
26
#include "qg_dlgoptionsvariables.h"
28
/*#include <qvariant.h>
29
#include <qmessagebox.h>
30
#include "rs_units.h"*/
31
#include "rs_filterdxf.h"
34
* Constructs a QG_DlgOptionsVariables as a child of 'parent', with the
35
* name 'name' and widget flags set to 'f'.
37
* The dialog will by default be modeless, unless you set 'modal' to
38
* true to construct a modal dialog.
40
QG_DlgOptionsVariables::QG_DlgOptionsVariables(QWidget* parent, bool modal, Qt::WindowFlags fl)
50
* Destroys the object and frees any allocated resources
52
QG_DlgOptionsVariables::~QG_DlgOptionsVariables()
54
// no need to delete child widgets, Qt does it all for us
58
* Sets the strings of the subwidgets using the current
61
void QG_DlgOptionsVariables::languageChange()
66
void QG_DlgOptionsVariables::init() {
70
tabVariables->verticalHeader()->hide();
71
tabVariables->verticalHeader()->setFixedWidth(0);
72
tabVariables->setColumnReadOnly(0, true);
73
tabVariables->setColumnReadOnly(1, true);
74
tabVariables->setColumnReadOnly(2, true);
79
* Sets the graphic and updates the GUI to match the drawing.
81
void QG_DlgOptionsVariables::setGraphic(RS_Graphic* g) {
88
* Updates the Variables tab from the graphic values.
90
void QG_DlgOptionsVariables::updateVariables() {
95
QVector<int> r(tabVariables->numRows());
96
for (int i=0; i<tabVariables->numRows(); ++i) {
99
tabVariables->removeRows(r);
100
QHash<QString, RS_Variable>vars = graphic->getVariableDict();
101
QHash<QString, RS_Variable>::iterator it = vars.begin();
102
while (it != vars.end()) {
103
tabVariables->insertRows(tabVariables->numRows(), 1);
105
tabVariables->setText(tabVariables->numRows()-1, 0, it.key());
106
tabVariables->setText(tabVariables->numRows()-1, 1, QString("%1").arg(it.value().getCode()));
108
switch (it.value().getType()) {
109
case RS2::VariableVoid:
111
case RS2::VariableInt:
112
str = QString("%1").arg(it.value().getInt());
114
case RS2::VariableDouble:
115
str = QString("%1").arg(it.value().getDouble());
117
case RS2::VariableString:
118
str = QString("%1").arg(it.value().getString());
120
case RS2::VariableVector:
121
str = QString("%1/%2")
122
.arg(it.value().getVector().x)
123
.arg(it.value().getVector().y);
124
if (RS_FilterDXF::isVariableTwoDimensional(it.key())==false) {
125
str+= QString("/%1").arg(it.value().getVector().z);
129
tabVariables->setText(tabVariables->numRows()-1, 2, str);