2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file dialogtool.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-07-28 00:18:06 +02:00
|
|
|
#include "dialogtool.h"
|
2014-02-21 14:04:39 +01:00
|
|
|
#include "../../container/calculator.h"
|
|
|
|
#include "../../geometry/vgobject.h"
|
|
|
|
#include "../../tools/vabstracttool.h"
|
2013-07-28 00:18:06 +02:00
|
|
|
|
2013-11-21 13:05:26 +01:00
|
|
|
#include <QtWidgets>
|
2014-05-21 10:51:16 +02:00
|
|
|
#include "../../../libs/qmuparser/qmuparsererror.h"
|
2013-11-21 13:05:26 +01:00
|
|
|
|
2014-05-25 11:46:54 +02:00
|
|
|
// TODO : for issue #79
|
|
|
|
// replace lineEditFormula -> plainTextEditFormula
|
|
|
|
// delete lineEditFormala everywhrer
|
|
|
|
// delete PutValHere and eval overloaded functions
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-12-21 12:36:51 +01:00
|
|
|
DialogTool::DialogTool(const VContainer *data, QWidget *parent)
|
2014-02-26 10:22:05 +01:00
|
|
|
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr),
|
2014-05-26 13:48:42 +02:00
|
|
|
bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), plainTextEditFormula(nullptr),
|
|
|
|
listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
|
2014-02-26 10:22:05 +01:00
|
|
|
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
|
|
|
|
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
|
2014-05-26 09:03:51 +02:00
|
|
|
radioButtonLengthCurve(nullptr), lineStyles(QStringList()), associatedTool(nullptr)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(data);
|
2013-07-28 00:18:06 +02:00
|
|
|
timerFormula = new QTimer(this);
|
|
|
|
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
2014-01-29 13:47:43 +01:00
|
|
|
//Keep synchronize with VAbstractTool styles list!!!
|
|
|
|
lineStyles<<tr("No line")<<tr("Line")<<tr("Dash Line")<<tr("Dot Line")<<tr("Dash Dot Line")
|
|
|
|
<<tr("Dash Dot Dot Line");
|
2014-02-06 14:57:23 +01:00
|
|
|
Qt::WindowFlags flags = windowFlags();
|
|
|
|
setWindowFlags(flags | Qt::WindowStaysOnTopHint);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
DialogClosed(QDialog::Rejected);
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::showEvent(QShowEvent *event)
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
QDialog::showEvent( event );
|
2013-11-04 21:35:15 +01:00
|
|
|
if ( event->spontaneous() )
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (isInitialized)
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-10-04 18:51:03 +02:00
|
|
|
isInitialized = true;//first show windows are held
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::FillComboBoxPoints(QComboBox *box, const quint32 &id) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2014-02-25 15:40:24 +01:00
|
|
|
const QHash<quint32, VGObject*> *objs = data->DataGObjects();
|
|
|
|
QHashIterator<quint32, VGObject*> i(*objs);
|
|
|
|
QMap<QString, quint32> list;
|
2013-12-21 12:36:51 +01:00
|
|
|
while (i.hasNext())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
i.next();
|
|
|
|
if (i.key() != id)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VGObject *obj = i.value();
|
2014-03-11 12:43:24 +01:00
|
|
|
if (obj->getType() == GObject::Point && obj->getMode() == Valentina::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
|
|
|
const VPointF *point = data->GeometricObject<const VPointF *>(i.key());
|
2014-01-05 21:56:18 +01:00
|
|
|
list[point->name()] = i.key();
|
2013-12-29 17:48:57 +01:00
|
|
|
}
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2014-01-05 21:56:18 +01:00
|
|
|
FillList(box, list);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::FillComboBoxArcs(QComboBox *box, const quint32 &id, ComboMode::ComboBoxCutArc cut) const
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2014-02-25 15:40:24 +01:00
|
|
|
const QHash<quint32, VGObject *> *objs = data->DataGObjects();
|
|
|
|
QHashIterator<quint32, VGObject*> i(*objs);
|
|
|
|
QMap<QString, quint32> list;
|
2014-01-08 15:05:32 +01:00
|
|
|
while (i.hasNext())
|
|
|
|
{
|
|
|
|
i.next();
|
|
|
|
if (cut == ComboMode::CutArc)
|
|
|
|
{
|
|
|
|
if (i.key() != id + 1 && i.key() != id + 2)
|
|
|
|
{
|
|
|
|
VGObject *obj = i.value();
|
2014-03-11 12:43:24 +01:00
|
|
|
if (obj->getType() == GObject::Arc && obj->getMode() == Valentina::Calculation)
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
|
|
|
const VArc *arc = data->GeometricObject<const VArc *>(i.key());
|
|
|
|
list[arc->name()] = i.key();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i.key() != id)
|
|
|
|
{
|
|
|
|
VGObject *obj = i.value();
|
2014-03-11 12:43:24 +01:00
|
|
|
if (obj->getType() == GObject::Arc && obj->getMode() == Valentina::Calculation)
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
|
|
|
const VArc *arc = data->GeometricObject<const VArc *>(i.key());
|
|
|
|
list[arc->name()] = i.key();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FillList(box, list);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::FillComboBoxSplines(QComboBox *box, const quint32 &id, ComboMode::ComboBoxCutSpline cut) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2014-02-25 15:40:24 +01:00
|
|
|
const QHash<quint32, VGObject *> *objs = data->DataGObjects();
|
|
|
|
QHashIterator<quint32, VGObject*> i(*objs);
|
|
|
|
QMap<QString, quint32> list;
|
2013-12-21 12:36:51 +01:00
|
|
|
while (i.hasNext())
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
i.next();
|
2013-12-31 09:44:54 +01:00
|
|
|
if (cut == ComboMode::CutSpline)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
if (i.key() != id + 1 && i.key() != id + 2)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VGObject *obj = i.value();
|
2014-03-11 12:43:24 +01:00
|
|
|
if (obj->getType() == GObject::Spline && obj->getMode() == Valentina::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
|
|
|
const VSpline *spl = data->GeometricObject<const VSpline *>(i.key());
|
2014-01-05 21:56:18 +01:00
|
|
|
list[spl->name()] = i.key();
|
2013-12-29 17:48:57 +01:00
|
|
|
}
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-21 12:36:51 +01:00
|
|
|
else
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
if (i.key() != id)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VGObject *obj = i.value();
|
2014-03-11 12:43:24 +01:00
|
|
|
if (obj->getType() == GObject::Spline && obj->getMode() == Valentina::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
|
|
|
const VSpline *spl = data->GeometricObject<const VSpline *>(i.key());
|
2014-01-05 21:56:18 +01:00
|
|
|
list[spl->name()] = i.key();
|
2013-12-29 17:48:57 +01:00
|
|
|
}
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-05 21:56:18 +01:00
|
|
|
FillList(box, list);
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const quint32 &id, ComboMode::ComboBoxCutSpline cut) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2014-02-25 15:40:24 +01:00
|
|
|
const QHash<quint32, VGObject *> *objs = data->DataGObjects();
|
|
|
|
QHashIterator<quint32, VGObject *> i(*objs);
|
|
|
|
QMap<QString, quint32> list;
|
2013-12-21 12:36:51 +01:00
|
|
|
while (i.hasNext())
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
i.next();
|
2013-12-31 09:44:54 +01:00
|
|
|
if (cut == ComboMode::CutSpline)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
if (i.key() != id + 1 && i.key() != id + 2)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VGObject *obj = i.value();
|
2014-03-11 12:43:24 +01:00
|
|
|
if (obj->getType() == GObject::SplinePath && obj->getMode() == Valentina::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
|
|
|
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(i.key());
|
2014-01-05 21:56:18 +01:00
|
|
|
list[splPath->name()] = i.key();
|
2013-12-29 17:48:57 +01:00
|
|
|
}
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-21 12:36:51 +01:00
|
|
|
else
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
if (i.key() != id)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VGObject *obj = i.value();
|
2014-03-11 12:43:24 +01:00
|
|
|
if (obj->getType() == GObject::SplinePath && obj->getMode() == Valentina::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
|
|
|
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(i.key());
|
2014-01-05 21:56:18 +01:00
|
|
|
list[splPath->name()] = i.key();
|
2013-12-29 17:48:57 +01:00
|
|
|
}
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-05 21:56:18 +01:00
|
|
|
FillList(box, list);
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2014-01-29 13:47:43 +01:00
|
|
|
box->addItems(lineStyles);
|
|
|
|
box->setCurrentIndex(1);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
QString DialogTool::GetTypeLine(const QComboBox *box) const
|
|
|
|
{
|
2014-02-26 10:51:37 +01:00
|
|
|
switch (lineStyles.indexOf(box->currentText()))
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-02-17 13:10:37 +01:00
|
|
|
case 0: //No line
|
2014-01-29 13:47:43 +01:00
|
|
|
return VAbstractTool::TypeLineNone;
|
|
|
|
break;
|
2014-02-17 13:10:37 +01:00
|
|
|
case 1: //Line
|
2014-01-29 13:47:43 +01:00
|
|
|
return VAbstractTool::TypeLineLine;
|
|
|
|
break;
|
2014-02-17 13:10:37 +01:00
|
|
|
case 2: //Dash Line
|
2014-01-29 13:47:43 +01:00
|
|
|
return VAbstractTool::TypeLineDashLine;
|
|
|
|
break;
|
2014-02-17 13:10:37 +01:00
|
|
|
case 3: //Dot Line
|
2014-01-29 13:47:43 +01:00
|
|
|
return VAbstractTool::TypeLineDotLine;
|
|
|
|
break;
|
2014-02-17 13:10:37 +01:00
|
|
|
case 4: //Dash Dot Line
|
2014-01-29 13:47:43 +01:00
|
|
|
return VAbstractTool::TypeLineDashDotLine;
|
|
|
|
break;
|
2014-02-17 13:10:37 +01:00
|
|
|
case 5: //Dash Dot Dot Line
|
2014-01-29 13:47:43 +01:00
|
|
|
return VAbstractTool::TypeLineDashDotDotLine;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return VAbstractTool::TypeLineLine;
|
|
|
|
break;
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
|
|
|
|
{
|
2014-01-29 13:47:43 +01:00
|
|
|
QStringList styles = VAbstractTool::Styles();
|
|
|
|
qint32 index = box->findText(lineStyles.at(styles.indexOf(value)));
|
|
|
|
if (index != -1)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-01-29 13:47:43 +01:00
|
|
|
box->setCurrentIndex(index);
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
qint32 index = box->findText(value);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
box->setCurrentIndex(index);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Can't find object by name"<<value;
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::ChangeCurrentData(QComboBox *box, const quint32 &value) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
qint32 index = box->findData(value);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
box->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget)
|
2014-05-25 11:46:54 +02:00
|
|
|
{ // TODO issue #79 : erase this function after all tools updated to plainTextEdit
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(lineEdit);
|
|
|
|
Q_CHECK_PTR(listWidget);
|
2013-08-06 09:56:09 +02:00
|
|
|
QListWidgetItem *item = listWidget->currentItem();
|
2014-03-10 17:22:55 +01:00
|
|
|
Q_CHECK_PTR(item);
|
2014-05-25 11:46:54 +02:00
|
|
|
|
2013-10-14 18:18:08 +02:00
|
|
|
int pos = lineEdit->cursorPosition();
|
|
|
|
lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
|
2013-10-04 18:51:03 +02:00
|
|
|
lineEdit->setFocus();
|
2013-10-14 18:18:08 +02:00
|
|
|
lineEdit->setCursorPosition(pos + item->text().size());
|
2014-05-25 11:46:54 +02:00
|
|
|
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-25 11:46:54 +02:00
|
|
|
void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-25 11:46:54 +02:00
|
|
|
Q_CHECK_PTR(plainTextEdit);
|
|
|
|
Q_CHECK_PTR(listWidget);
|
|
|
|
QListWidgetItem *item = listWidget->currentItem();
|
|
|
|
Q_CHECK_PTR(item);
|
|
|
|
|
|
|
|
QTextCursor cursor = plainTextEdit->textCursor();
|
|
|
|
cursor.insertText(item->text());
|
|
|
|
plainTextEdit->setTextCursor(cursor);
|
|
|
|
/*
|
|
|
|
int pos = lineEdit->cursorPosition();
|
|
|
|
lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
|
|
|
|
lineEdit->setFocus();
|
|
|
|
lineEdit->setCursorPosition(pos + item->text().size());
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
|
|
|
|
{// TODO issue #79 : erase this function after all tools updated to plainTextEdit
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(edit);
|
|
|
|
Q_CHECK_PTR(timer);
|
|
|
|
Q_CHECK_PTR(labelEditFormula);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (edit->text().isEmpty())
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
flag = false;
|
|
|
|
CheckState();
|
2013-10-06 18:22:21 +02:00
|
|
|
QPalette palette = labelEditFormula->palette();
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
|
|
|
labelEditFormula->setPalette(palette);
|
2013-08-06 09:56:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
timer->start(1000);
|
|
|
|
}
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-25 11:46:54 +02:00
|
|
|
void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *timer)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-25 11:46:54 +02:00
|
|
|
Q_CHECK_PTR(edit);
|
|
|
|
Q_CHECK_PTR(timer);
|
|
|
|
Q_CHECK_PTR(labelEditFormula);
|
|
|
|
if (edit->toPlainText().isEmpty())
|
|
|
|
{
|
|
|
|
flag = false;
|
|
|
|
CheckState();
|
|
|
|
QPalette palette = labelEditFormula->palette();
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
|
|
|
labelEditFormula->setPalette(palette);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
timer->start(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
|
|
|
|
{ // TODO issue #79 : erase this function after all tools updated to plainTextEdit
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(edit);
|
|
|
|
Q_CHECK_PTR(timer);
|
|
|
|
Q_CHECK_PTR(label);
|
|
|
|
Q_CHECK_PTR(labelEditFormula);
|
2013-10-06 18:22:21 +02:00
|
|
|
QPalette palette = labelEditFormula->palette();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (edit->text().isEmpty())
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
flag = false;
|
2013-10-06 18:22:21 +02:00
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-21 10:51:16 +02:00
|
|
|
try
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-23 20:11:13 +02:00
|
|
|
const QString formula = qApp->FormulaFromUser(edit->text());
|
2014-05-30 10:32:40 +02:00
|
|
|
Calculator *cal = new Calculator(data);
|
|
|
|
const qreal result = cal->EvalFormula(formula);
|
|
|
|
delete cal;
|
2014-05-21 10:51:16 +02:00
|
|
|
|
2014-05-29 10:46:28 +02:00
|
|
|
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
|
|
|
|
QApplication::applicationName());
|
|
|
|
bool osSeparatorValue = settings.value("configuration/osSeparator", 1).toBool();
|
|
|
|
|
|
|
|
if (osSeparatorValue)
|
|
|
|
{
|
|
|
|
QLocale loc = QLocale::system();
|
|
|
|
label->setText(loc.toString(result));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QLocale loc = QLocale(QLocale::C);
|
|
|
|
label->setText(loc.toString(result));
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
flag = true;
|
2013-11-04 21:35:15 +01:00
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
|
2014-05-21 10:51:16 +02:00
|
|
|
emit ToolTip("");
|
|
|
|
}
|
|
|
|
catch(qmu::QmuParserError &e)
|
|
|
|
{
|
|
|
|
label->setText(tr("Error"));
|
|
|
|
flag = false;
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
2014-05-23 20:11:13 +02:00
|
|
|
emit ToolTip("Parser error: "+e.GetMsg());
|
2014-05-21 18:59:53 +02:00
|
|
|
qDebug() << "\nMath parser error:\n"
|
|
|
|
<< "--------------------------------------\n"
|
|
|
|
<< "Message: " << e.GetMsg() << "\n"
|
|
|
|
<< "Expression: " << e.GetExpr() << "\n"
|
|
|
|
<< "--------------------------------------";
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
timer->stop();
|
2013-10-06 18:22:21 +02:00
|
|
|
labelEditFormula->setPalette(palette);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-25 11:46:54 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(edit);
|
|
|
|
Q_CHECK_PTR(timer);
|
|
|
|
Q_CHECK_PTR(label);
|
|
|
|
Q_CHECK_PTR(labelEditFormula);
|
|
|
|
QPalette palette = labelEditFormula->palette();
|
|
|
|
if (edit->toPlainText().isEmpty())
|
|
|
|
{
|
|
|
|
flag = false;
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-26 16:33:44 +02:00
|
|
|
try
|
2014-05-25 11:46:54 +02:00
|
|
|
{
|
2014-05-26 16:33:44 +02:00
|
|
|
// Replace line return with spaces for calc
|
|
|
|
QString formula = edit->toPlainText();
|
|
|
|
formula.replace("\n"," ");
|
|
|
|
formula = qApp->FormulaFromUser(formula);
|
|
|
|
Calculator cal(data);
|
|
|
|
const qreal result = cal.EvalFormula(formula);
|
|
|
|
|
2014-05-27 20:39:54 +02:00
|
|
|
QLocale loc = QLocale::system();
|
|
|
|
label->setText(loc.toString(result));
|
2014-05-25 11:46:54 +02:00
|
|
|
flag = true;
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
|
2014-05-26 16:33:44 +02:00
|
|
|
emit ToolTip("");
|
|
|
|
}
|
|
|
|
catch(qmu::QmuParserError &e)
|
|
|
|
{
|
|
|
|
label->setText(tr("Error"));
|
|
|
|
flag = false;
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
|
|
|
emit ToolTip("Parser error: "+e.GetMsg());
|
|
|
|
qDebug() << "\nMath parser error:\n"
|
|
|
|
<< "--------------------------------------\n"
|
|
|
|
<< "Message: " << e.GetMsg() << "\n"
|
|
|
|
<< "Expression: " << e.GetExpr() << "\n"
|
|
|
|
<< "--------------------------------------";
|
2014-05-25 11:46:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
timer->stop();
|
|
|
|
labelEditFormula->setPalette(palette);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2013-08-13 18:48:36 +02:00
|
|
|
FillComboBoxPoints(box, id);
|
|
|
|
pointId = value;
|
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, const quint32 &id,
|
2013-12-18 12:13:32 +01:00
|
|
|
ComboMode::ComboBoxCutSpline cut) const
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2013-12-18 12:13:32 +01:00
|
|
|
FillComboBoxSplines(box, id, cut);
|
|
|
|
splineId = value;
|
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 &value, const quint32 &id,
|
2014-01-08 15:05:32 +01:00
|
|
|
ComboMode::ComboBoxCutArc cut) const
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2014-01-08 15:05:32 +01:00
|
|
|
FillComboBoxArcs(box, id, cut);
|
|
|
|
arcId = value;
|
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value,
|
|
|
|
const quint32 &id, ComboMode::ComboBoxCutSpline cut) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2013-12-20 14:35:14 +01:00
|
|
|
FillComboBoxSplinesPath(box, id, cut);
|
2013-12-18 12:13:32 +01:00
|
|
|
splinePathId = value;
|
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 DialogTool::getCurrentObjectId(QComboBox *box) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2013-08-13 18:48:36 +02:00
|
|
|
qint32 index = box->currentIndex();
|
|
|
|
Q_ASSERT(index != -1);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
return qvariant_cast<quint32>(box->itemData(index));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-04 18:13:10 +01:00
|
|
|
bool DialogTool::ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(box);
|
|
|
|
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
|
|
|
Q_CHECK_PTR(point);
|
|
|
|
const qint32 index = box->findText(point->name());
|
|
|
|
if ( index != -1 )
|
|
|
|
{ // -1 for not found
|
|
|
|
box->setCurrentIndex(index);
|
|
|
|
emit ToolTip(toolTip);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogTool::FillList(QComboBox *box, const QMap<QString, quint32> &list) const
|
2014-01-05 21:56:18 +01:00
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(box);
|
2014-01-05 21:56:18 +01:00
|
|
|
box->clear();
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
QMapIterator<QString, quint32> iter(list);
|
2014-01-05 21:56:18 +01:00
|
|
|
while (iter.hasNext())
|
|
|
|
{
|
|
|
|
iter.next();
|
|
|
|
box->addItem(iter.key(), iter.value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::CheckState()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(bOk);
|
2013-09-12 15:25:24 +02:00
|
|
|
bOk->setEnabled(flagFormula && flagName);
|
2014-05-26 13:48:42 +02:00
|
|
|
Q_CHECK_PTR(bApply);
|
|
|
|
bApply->setEnabled(flagFormula && flagName);
|
|
|
|
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-11 12:43:24 +01:00
|
|
|
void DialogTool::ChoosedObject(quint32 id, const Valentina::Scenes &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
Q_UNUSED(id);
|
|
|
|
Q_UNUSED(type);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::NamePointChanged()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(labelEditNamePoint);
|
2013-07-28 00:18:06 +02:00
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
2013-11-04 21:35:15 +01:00
|
|
|
if (edit)
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
QString name = edit->text();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (name.isEmpty() || name.contains(" "))
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
flagName = false;
|
2013-10-06 18:22:21 +02:00
|
|
|
QPalette palette = labelEditNamePoint->palette();
|
|
|
|
palette.setColor(labelEditNamePoint->foregroundRole(), Qt::red);
|
|
|
|
labelEditNamePoint->setPalette(palette);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
flagName = true;
|
2013-10-06 18:22:21 +02:00
|
|
|
QPalette palette = labelEditNamePoint->palette();
|
2013-11-04 21:35:15 +01:00
|
|
|
palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76));
|
2013-10-06 18:22:21 +02:00
|
|
|
labelEditNamePoint->setPalette(palette);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::DialogAccepted()
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
emit DialogClosed(QDialog::Accepted);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::DialogRejected()
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
emit DialogClosed(QDialog::Rejected);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::FormulaChanged()
|
2014-05-25 11:46:54 +02:00
|
|
|
{ // TODO issue #79 : erase after full update of tools.
|
2013-07-28 00:18:06 +02:00
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
2013-11-04 21:35:15 +01:00
|
|
|
if (edit)
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
ValFormulaChanged(flagFormula, edit, timerFormula);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
}
|
2014-05-25 11:46:54 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::FormulaChanged2()
|
|
|
|
{
|
|
|
|
QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(sender());
|
|
|
|
if (edit)
|
|
|
|
{
|
|
|
|
ValFormulaChanged(flagFormula, edit, timerFormula);
|
|
|
|
}
|
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowUp()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spinBoxAngle);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(90);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowDown()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spinBoxAngle);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(270);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowLeft()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spinBoxAngle);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(180);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowRight()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spinBoxAngle);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(0);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowLeftUp()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spinBoxAngle);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(135);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowLeftDown()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spinBoxAngle);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(225);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowRightUp()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spinBoxAngle);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(45);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowRightDown()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spinBoxAngle);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(315);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::EvalFormula()
|
|
|
|
{
|
2014-05-25 11:46:54 +02:00
|
|
|
Q_CHECK_PTR(plainTextEditFormula);
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(labelResultCalculation);
|
2014-05-25 11:46:54 +02:00
|
|
|
Eval(plainTextEditFormula, flagFormula, timerFormula, labelResultCalculation);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-11 21:19:13 +01:00
|
|
|
void DialogTool::SizeHeight()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-11 21:19:13 +01:00
|
|
|
Q_CHECK_PTR(listWidget);
|
|
|
|
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
|
|
|
listWidget->clear();
|
|
|
|
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(data->HeightName());
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
listWidget->addItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(data->SizeName());
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
listWidget->addItem(item);
|
|
|
|
|
|
|
|
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
|
|
|
listWidget->setCurrentRow (0);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-16 14:17:39 +01:00
|
|
|
void DialogTool::Measurements()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-16 14:17:39 +01:00
|
|
|
ShowVariable(data->DataMeasurements());
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::LengthLines()
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
ShowVariable(data->DataLengthLines());
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::LengthArcs()
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
ShowVariable(data->DataLengthArcs());
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::LengthCurves()
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
ShowVariable(data->DataLengthSplines());
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::Increments()
|
|
|
|
{
|
2014-03-19 19:27:11 +01:00
|
|
|
ShowVariable(data->DataIncrements());
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::PutHere()
|
|
|
|
{
|
2014-05-25 11:46:54 +02:00
|
|
|
PutValHere(plainTextEditFormula, listWidget);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::PutVal(QListWidgetItem *item)
|
|
|
|
{
|
2014-05-25 11:46:54 +02:00
|
|
|
Q_CHECK_PTR(plainTextEditFormula);
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(item);
|
2014-05-25 11:46:54 +02:00
|
|
|
QTextCursor cursor = plainTextEditFormula->textCursor();
|
|
|
|
cursor.insertText(item->text());
|
|
|
|
plainTextEditFormula->setTextCursor(cursor);
|
|
|
|
/*int pos = plainTextEditFormula->cursorPosition();
|
2013-10-14 18:18:08 +02:00
|
|
|
lineEditFormula->setText(lineEditFormula->text().insert(lineEditFormula->cursorPosition(),
|
|
|
|
item->text()));
|
2013-10-04 18:51:03 +02:00
|
|
|
lineEditFormula->setFocus();
|
2013-10-14 18:18:08 +02:00
|
|
|
lineEditFormula->setCursorPosition(pos + item->text().size());
|
2014-05-25 11:46:54 +02:00
|
|
|
*/
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ValChenged(int row)
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(listWidget);
|
|
|
|
Q_CHECK_PTR(labelDescription);
|
|
|
|
Q_CHECK_PTR(radioButtonSizeGrowth);
|
|
|
|
Q_CHECK_PTR(radioButtonStandardTable);
|
|
|
|
Q_CHECK_PTR(radioButtonIncrements);
|
|
|
|
Q_CHECK_PTR(radioButtonLengthLine);
|
|
|
|
Q_CHECK_PTR(radioButtonLengthArc);
|
|
|
|
Q_CHECK_PTR(radioButtonLengthCurve);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (listWidget->count() == 0)
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
QListWidgetItem *item = listWidget->item( row );
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonSizeGrowth->isChecked())
|
|
|
|
{
|
2014-03-11 21:19:13 +01:00
|
|
|
if (item->text()==data->HeightName())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-11 21:19:13 +01:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->height()).arg(tr("Height"));
|
2013-07-28 00:18:06 +02:00
|
|
|
labelDescription->setText(desc);
|
|
|
|
}
|
2014-03-11 21:19:13 +01:00
|
|
|
if (item->text()==data->SizeName())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size"));
|
2013-07-28 00:18:06 +02:00
|
|
|
labelDescription->setText(desc);
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
return;
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2014-01-15 00:55:41 +01:00
|
|
|
if (radioButtonStandardTable->isChecked())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-26 15:18:48 +02:00
|
|
|
QString name = qApp->VarFromUser(item->text());
|
|
|
|
VMeasurement stable = data->GetMeasurement(name);
|
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandardTableRow(name))
|
2013-07-28 00:18:06 +02:00
|
|
|
.arg(stable.GetDescription());
|
|
|
|
labelDescription->setText(desc);
|
2013-08-06 09:56:09 +02:00
|
|
|
return;
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonIncrements->isChecked())
|
|
|
|
{
|
2014-03-19 19:27:11 +01:00
|
|
|
VIncrement incr = data->GetIncrement(item->text());
|
2013-07-28 00:18:06 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text()))
|
2014-03-19 19:27:11 +01:00
|
|
|
.arg(incr.getDescription());
|
2013-07-28 00:18:06 +02:00
|
|
|
labelDescription->setText(desc);
|
2013-08-06 09:56:09 +02:00
|
|
|
return;
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonLengthLine->isChecked())
|
|
|
|
{
|
2014-05-26 15:18:48 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(qApp->VarFromUser(item->text())))
|
2013-10-04 18:51:03 +02:00
|
|
|
.arg(tr("Line length"));
|
2013-07-29 14:55:40 +02:00
|
|
|
labelDescription->setText(desc);
|
2013-08-06 09:56:09 +02:00
|
|
|
return;
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonLengthArc->isChecked())
|
|
|
|
{
|
2014-05-26 15:18:48 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthArc(qApp->VarFromUser(item->text())))
|
2013-10-13 17:31:42 +02:00
|
|
|
.arg(tr("Arc length"));
|
|
|
|
labelDescription->setText(desc);
|
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonLengthCurve->isChecked())
|
|
|
|
{
|
2014-05-26 15:18:48 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text())
|
|
|
|
.arg(data->GetLengthSpline(qApp->VarFromUser(item->text()))).arg(tr("Curve length"));
|
2013-10-13 17:31:42 +02:00
|
|
|
labelDescription->setText(desc);
|
|
|
|
return;
|
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::UpdateList()
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(radioButtonSizeGrowth);
|
|
|
|
Q_CHECK_PTR(radioButtonStandardTable);
|
|
|
|
Q_CHECK_PTR(radioButtonIncrements);
|
|
|
|
Q_CHECK_PTR(radioButtonLengthLine);
|
|
|
|
Q_CHECK_PTR(radioButtonLengthArc);
|
|
|
|
Q_CHECK_PTR(radioButtonLengthCurve);
|
2013-10-13 17:31:42 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonSizeGrowth->isChecked())
|
|
|
|
{
|
2014-03-11 21:19:13 +01:00
|
|
|
SizeHeight();
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2014-01-15 00:55:41 +01:00
|
|
|
if (radioButtonStandardTable->isChecked())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-16 14:17:39 +01:00
|
|
|
ShowVariable(data->DataMeasurements());
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonIncrements->isChecked())
|
|
|
|
{
|
2014-03-19 19:27:11 +01:00
|
|
|
ShowVariable(data->DataIncrements());
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonLengthLine->isChecked())
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
ShowVariable(data->DataLengthLines());
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonLengthArc->isChecked())
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
ShowVariable(data->DataLengthArcs());
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (radioButtonLengthCurve->isChecked())
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
ShowVariable(data->DataLengthSplines());
|
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-08-20 12:26:02 +02:00
|
|
|
template <class key, class val>
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ShowVariable(const QHash<key, val> *var)
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(listWidget);
|
2013-08-06 09:56:09 +02:00
|
|
|
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
|
|
|
listWidget->clear();
|
2013-10-13 13:04:26 +02:00
|
|
|
|
2013-10-04 13:32:42 +02:00
|
|
|
QHashIterator<key, val> i(*var);
|
2013-10-13 13:04:26 +02:00
|
|
|
QMap<key, val> map;
|
2013-11-04 21:35:15 +01:00
|
|
|
while (i.hasNext())
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
i.next();
|
2014-05-26 15:18:48 +02:00
|
|
|
map.insert(qApp->VarToUser(i.key()), i.value());
|
2013-10-13 13:04:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QMapIterator<key, val> iMap(map);
|
2013-11-04 21:35:15 +01:00
|
|
|
while (iMap.hasNext())
|
|
|
|
{
|
2013-10-13 13:04:26 +02:00
|
|
|
iMap.next();
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(iMap.key());
|
2013-08-06 09:56:09 +02:00
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
listWidget->addItem(item);
|
|
|
|
}
|
2013-10-13 13:04:26 +02:00
|
|
|
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
2013-10-15 11:26:47 +02:00
|
|
|
listWidget->setCurrentRow (0);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
2014-05-25 21:54:17 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::DialogApply()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|