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"
|
2014-06-08 20:10:57 +02:00
|
|
|
#include "../../container/vcontainer.h"
|
|
|
|
#include "../../geometry/varc.h"
|
|
|
|
#include "../../geometry/vpointf.h"
|
|
|
|
#include "../../geometry/vsplinepath.h"
|
2014-02-21 14:04:39 +01:00
|
|
|
#include "../../tools/vabstracttool.h"
|
2014-05-21 10:51:16 +02:00
|
|
|
#include "../../../libs/qmuparser/qmuparsererror.h"
|
2014-09-25 17:44:06 +02:00
|
|
|
#include "../../core/vapplication.h"
|
2014-11-22 17:15:47 +01:00
|
|
|
#include "../../core/vsettings.h"
|
2014-12-10 19:33:20 +01:00
|
|
|
#include "../../libs/ifc/xml/vdomdocument.h"
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QCloseEvent>
|
|
|
|
#include <QShowEvent>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QListWidgetItem>
|
|
|
|
#include <QTextCursor>
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QDoubleSpinBox>
|
2013-11-21 13:05:26 +01:00
|
|
|
|
2014-11-24 15:51:27 +01:00
|
|
|
Q_LOGGING_CATEGORY(vDialog, "v.dialog")
|
|
|
|
|
2014-08-12 19:21:50 +02:00
|
|
|
#define DIALOG_MAX_FORMULA_HEIGHT 64
|
2014-06-19 11:29:56 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogTool create dialog
|
|
|
|
* @param data container with data
|
|
|
|
* @param parent parent widget
|
|
|
|
*/
|
2014-07-29 14:19:11 +02:00
|
|
|
DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
2014-07-14 12:21:46 +02:00
|
|
|
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), flagError(true),
|
|
|
|
timerFormula(nullptr), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr),
|
2014-05-26 13:48:42 +02:00
|
|
|
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-09-24 18:37:39 +02:00
|
|
|
radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), checkBoxHideEmpty(nullptr),
|
2015-01-29 16:47:02 +01:00
|
|
|
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr),
|
2015-02-03 09:32:32 +01:00
|
|
|
toolId(toolId), prepare(false), pointName(QString()), number(0)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(data != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
timerFormula = new QTimer(this);
|
|
|
|
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
2014-07-04 17:48:53 +02:00
|
|
|
this->setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-08-13 12:20:30 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogTool::~DialogTool()
|
|
|
|
{
|
|
|
|
emit ToolTip("");
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief closeEvent handle when dialog cloded
|
|
|
|
* @param event event
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
2014-11-22 19:37:59 +01:00
|
|
|
DialogRejected();
|
2013-07-28 00:18:06 +02:00
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief showEvent handle when window show
|
|
|
|
* @param event event
|
|
|
|
*/
|
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
|
2014-07-15 15:51:15 +02:00
|
|
|
ShowVisualization();
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief FillComboBoxPoints fill comboBox list of points
|
|
|
|
* @param box comboBox
|
|
|
|
*/
|
2014-07-29 15:08:38 +02:00
|
|
|
void DialogTool::FillComboBoxPoints(QComboBox *box) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2014-08-21 14:44:40 +02:00
|
|
|
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
2014-02-25 15:40:24 +01:00
|
|
|
QMap<QString, quint32> list;
|
2014-08-21 14:44:40 +02:00
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-07-29 15:08:38 +02:00
|
|
|
if (i.key() != toolId)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
2014-06-12 09:22:29 +02:00
|
|
|
if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VPointF> point = data->GeometricObject<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-07-29 15:08:38 +02:00
|
|
|
void DialogTool::FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut) const
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2014-08-21 14:44:40 +02:00
|
|
|
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
2014-02-25 15:40:24 +01:00
|
|
|
QMap<QString, quint32> list;
|
2014-08-21 14:44:40 +02:00
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
if (cut == ComboBoxCutArc::CutArc)
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-07-29 15:08:38 +02:00
|
|
|
if (i.key() != toolId + 1 && i.key() != toolId + 2)
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
2014-06-12 09:22:29 +02:00
|
|
|
if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation)
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(i.key());
|
2014-01-08 15:05:32 +01:00
|
|
|
list[arc->name()] = i.key();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-29 15:08:38 +02:00
|
|
|
if (i.key() != toolId)
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
2014-06-12 09:22:29 +02:00
|
|
|
if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation)
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(i.key());
|
2014-01-08 15:05:32 +01:00
|
|
|
list[arc->name()] = i.key();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FillList(box, list);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief FillComboBoxSplines fill comboBox list of splines
|
|
|
|
* @param box comboBox
|
|
|
|
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
|
|
|
|
*/
|
2014-07-29 15:08:38 +02:00
|
|
|
void DialogTool::FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2014-08-21 14:44:40 +02:00
|
|
|
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
2014-02-25 15:40:24 +01:00
|
|
|
QMap<QString, quint32> list;
|
2014-08-21 14:44:40 +02:00
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
if (cut == ComboBoxCutSpline::CutSpline)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-07-29 15:08:38 +02:00
|
|
|
if (i.key() != toolId + 1 && i.key() != toolId + 2)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
2014-06-12 09:22:29 +02:00
|
|
|
if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSpline> spl = data->GeometricObject<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
|
|
|
{
|
2014-07-29 15:08:38 +02:00
|
|
|
if (i.key() != toolId)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
2014-06-12 09:22:29 +02:00
|
|
|
if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSpline> spl = data->GeometricObject<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-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief FillComboBoxSplinesPath
|
|
|
|
* @param box comboBox
|
|
|
|
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
|
|
|
|
*/
|
2014-07-29 15:08:38 +02:00
|
|
|
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, ComboBoxCutSpline cut) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2014-08-21 14:44:40 +02:00
|
|
|
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
2014-02-25 15:40:24 +01:00
|
|
|
QMap<QString, quint32> list;
|
2014-08-21 14:44:40 +02:00
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
if (cut == ComboBoxCutSpline::CutSpline)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-07-29 15:08:38 +02:00
|
|
|
if (i.key() != toolId + 1 && i.key() != toolId + 2)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
2014-06-12 09:22:29 +02:00
|
|
|
if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<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
|
|
|
{
|
2014-07-29 15:08:38 +02:00
|
|
|
if (i.key() != toolId)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
2014-06-12 09:22:29 +02:00
|
|
|
if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<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-10-23 10:38:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::FillComboBoxCurves(QComboBox *box) const
|
|
|
|
{
|
|
|
|
SCASSERT(box != nullptr);
|
|
|
|
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
|
|
|
QMap<QString, quint32> list;
|
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
|
|
|
{
|
|
|
|
if (i.key() != toolId)
|
|
|
|
{
|
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
|
|
|
if ((obj->getType() == GOType::Arc || obj->getType() == GOType::Spline ||
|
|
|
|
obj->getType() == GOType::SplinePath) && obj->getMode() == Draw::Calculation)
|
|
|
|
{
|
|
|
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(i.key());
|
|
|
|
list[curve->name()] = i.key();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FillList(box, list);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief FillComboBoxTypeLine fill comboBox list of type lines
|
|
|
|
* @param box comboBox
|
|
|
|
*/
|
2015-01-29 16:47:02 +01:00
|
|
|
void DialogTool::FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2015-01-29 16:47:02 +01:00
|
|
|
QMap<QString, QIcon>::const_iterator i = stylesPics.constBegin();
|
|
|
|
while (i != stylesPics.constEnd())
|
|
|
|
{
|
|
|
|
box->addItem(i.value(), "", QVariant(i.key()));
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2015-02-02 23:08:39 +01:00
|
|
|
box->setCurrentIndex(4);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-02 11:28:09 +01:00
|
|
|
void DialogTool::FillComboBoxLineColors(QComboBox *box) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-02-02 11:28:09 +01:00
|
|
|
SCASSERT(box != nullptr);
|
|
|
|
|
2015-02-07 13:31:10 +01:00
|
|
|
const QMap<QString, QString> map = VAbstractTool::ColorsList();
|
|
|
|
QMap<QString, QString>::const_iterator i = map.constBegin();
|
|
|
|
while (i != map.constEnd())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-02-02 11:28:09 +01:00
|
|
|
QPixmap pix(16, 16);
|
2015-02-07 13:31:10 +01:00
|
|
|
pix.fill(QColor(i.key()));
|
|
|
|
box->addItem(QIcon(pix), i.value(), QVariant(i.key()));
|
|
|
|
++i;
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
QString DialogTool::GetComboBoxCurrentData(const QComboBox *box) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-01-29 16:47:02 +01:00
|
|
|
SCASSERT(box != nullptr)
|
|
|
|
QString value = box->currentData().toString();
|
|
|
|
if (value.isEmpty())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-01-29 16:47:02 +01:00
|
|
|
value = VAbstractTool::TypeLineLine;
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
2015-01-29 16:47:02 +01:00
|
|
|
return value;
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ChangeCurrentData select item in combobox by id
|
|
|
|
* @param box combobox
|
|
|
|
* @param value id of item
|
|
|
|
*/
|
2015-02-02 12:55:42 +01:00
|
|
|
void DialogTool::ChangeCurrentData(QComboBox *box, const QVariant &value) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-01-29 16:47:02 +01:00
|
|
|
SCASSERT(box != nullptr)
|
|
|
|
const 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief PutValHere put variable into line edit from list
|
|
|
|
* @param lineEdit lineEdit
|
|
|
|
* @param listWidget listWidget
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget)
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(lineEdit != nullptr);
|
|
|
|
SCASSERT(listWidget != nullptr);
|
2013-08-06 09:56:09 +02:00
|
|
|
QListWidgetItem *item = listWidget->currentItem();
|
2014-10-08 09:34:29 +02:00
|
|
|
if (item != nullptr)
|
|
|
|
{
|
|
|
|
int pos = lineEdit->cursorPosition();
|
|
|
|
lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
|
|
|
|
lineEdit->setFocus();
|
|
|
|
lineEdit->setCursorPosition(pos + item->text().size());
|
|
|
|
}
|
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-30 21:56:05 +02:00
|
|
|
SCASSERT(plainTextEdit != nullptr);
|
|
|
|
SCASSERT(listWidget != nullptr);
|
2013-08-06 09:56:09 +02:00
|
|
|
QListWidgetItem *item = listWidget->currentItem();
|
2014-10-08 09:34:29 +02:00
|
|
|
if (item != nullptr)
|
|
|
|
{
|
|
|
|
QTextCursor cursor = plainTextEdit->textCursor();
|
|
|
|
cursor.insertText(item->text());
|
|
|
|
plainTextEdit->setTextCursor(cursor);
|
2014-10-29 14:11:06 +01:00
|
|
|
plainTextEdit->setFocus();
|
2014-10-08 09:34:29 +02:00
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 14:40:56 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit)
|
|
|
|
{
|
|
|
|
SCASSERT(plainTextEdit != nullptr);
|
|
|
|
QTextCursor cursor = plainTextEdit->textCursor();
|
|
|
|
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
|
|
|
|
plainTextEdit->setTextCursor(cursor);
|
|
|
|
}
|
|
|
|
|
2014-10-29 19:00:38 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
|
|
|
{
|
|
|
|
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object);
|
|
|
|
if (plainTextEdit != nullptr)
|
|
|
|
{
|
2014-12-24 13:11:47 +01:00
|
|
|
if (event->type() == QEvent::KeyPress)
|
2014-10-29 19:00:38 +01:00
|
|
|
{
|
2014-12-24 13:11:47 +01:00
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
|
|
|
if ((keyEvent->key() == Qt::Key_Enter) || (keyEvent->key() == Qt::Key_Return))
|
|
|
|
{
|
|
|
|
// Ignore Enter key
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-29 19:00:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// pass the event on to the parent class
|
|
|
|
return QDialog::eventFilter(object, event);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ValFormulaChanged handle change formula
|
|
|
|
* @param flag flag state of formula
|
|
|
|
* @param edit LineEdit
|
|
|
|
* @param timer timer of formula
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(edit != nullptr);
|
|
|
|
SCASSERT(timer != nullptr);
|
|
|
|
SCASSERT(labelEditFormula != nullptr);
|
2014-08-29 16:38:43 +02:00
|
|
|
SCASSERT(labelResultCalculation != nullptr);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (edit->text().isEmpty())
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
flag = false;
|
|
|
|
CheckState();
|
2014-07-14 12:21:46 +02:00
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
2014-08-29 16:38:43 +02:00
|
|
|
labelResultCalculation->setText(tr("Error"));
|
2014-11-22 11:57:05 +01:00
|
|
|
labelResultCalculation->setToolTip(tr("Empty field"));
|
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-30 21:56:05 +02:00
|
|
|
SCASSERT(edit != nullptr);
|
|
|
|
SCASSERT(timer != nullptr);
|
|
|
|
SCASSERT(labelEditFormula != nullptr);
|
2014-08-29 16:38:43 +02:00
|
|
|
SCASSERT(labelResultCalculation != nullptr);
|
2014-05-25 11:46:54 +02:00
|
|
|
if (edit->toPlainText().isEmpty())
|
|
|
|
{
|
|
|
|
flag = false;
|
|
|
|
CheckState();
|
2014-07-14 12:21:46 +02:00
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
2014-08-29 16:38:43 +02:00
|
|
|
labelResultCalculation->setText(tr("Error"));
|
2014-11-22 11:57:05 +01:00
|
|
|
labelResultCalculation->setToolTip(tr("Empty field"));
|
2014-05-25 11:46:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-08-11 16:41:17 +02:00
|
|
|
timer->setSingleShot(true);
|
2014-05-25 11:46:54 +02:00
|
|
|
timer->start(1000);
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief Eval evaluate formula and show result
|
2014-06-18 13:38:20 +02:00
|
|
|
* @param text formula
|
2014-06-02 16:28:02 +02:00
|
|
|
* @param flag flag state of formula
|
|
|
|
* @param label label for signal error
|
2014-08-11 16:41:17 +02:00
|
|
|
* @param postfix unit name
|
2014-08-11 10:56:50 +02:00
|
|
|
* @param checkZero true - if formula can't be equal zero
|
2014-06-02 16:28:02 +02:00
|
|
|
*/
|
2014-11-21 15:57:47 +01:00
|
|
|
qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(label != nullptr);
|
|
|
|
SCASSERT(labelEditFormula != nullptr);
|
2014-11-21 15:57:47 +01:00
|
|
|
|
2014-11-22 11:57:05 +01:00
|
|
|
qreal result = INT_MIN;//Value can be 0, so use max imposible value
|
2014-11-21 15:57:47 +01:00
|
|
|
|
2014-06-18 13:38:20 +02:00
|
|
|
if (text.isEmpty())
|
2014-05-25 11:46:54 +02:00
|
|
|
{
|
|
|
|
flag = false;
|
2014-07-14 12:21:46 +02:00
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
2014-08-29 16:38:43 +02:00
|
|
|
label->setText(tr("Error"));
|
2014-09-06 10:38:30 +02:00
|
|
|
label->setToolTip(tr("Empty field"));
|
2014-05-25 11:46:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-26 16:33:44 +02:00
|
|
|
try
|
2014-05-25 11:46:54 +02:00
|
|
|
{
|
2014-06-18 13:38:20 +02:00
|
|
|
// Replace line return with spaces for calc if exist
|
|
|
|
QString formula = text;
|
2014-06-16 19:18:36 +02:00
|
|
|
formula.replace("\n", " ");
|
2014-05-26 16:33:44 +02:00
|
|
|
formula = qApp->FormulaFromUser(formula);
|
2014-05-30 21:03:17 +02:00
|
|
|
Calculator *cal = new Calculator(data);
|
2014-11-21 15:57:47 +01:00
|
|
|
result = cal->EvalFormula(formula);
|
2014-05-30 21:03:17 +02:00
|
|
|
delete cal;
|
2014-05-26 16:33:44 +02:00
|
|
|
|
2014-07-21 11:05:59 +02:00
|
|
|
//if result equal 0
|
2014-08-11 10:56:50 +02:00
|
|
|
if (checkZero && qFuzzyCompare(1 + result, 1 + 0))
|
2014-05-30 21:03:17 +02:00
|
|
|
{
|
2014-07-21 11:05:59 +02:00
|
|
|
flag = false;
|
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
2014-08-29 16:38:43 +02:00
|
|
|
label->setText(tr("Error"));
|
2014-09-06 10:38:30 +02:00
|
|
|
label->setToolTip(tr("Value can't be 0"));
|
2014-05-30 21:03:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-11 16:41:17 +02:00
|
|
|
QLocale loc;
|
2014-11-22 17:15:47 +01:00
|
|
|
if (qApp->getSettings()->GetOsSeparator())
|
2014-07-21 11:05:59 +02:00
|
|
|
{
|
2014-08-11 16:41:17 +02:00
|
|
|
loc = QLocale::system();
|
2014-07-21 11:05:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-11 16:41:17 +02:00
|
|
|
loc = QLocale(QLocale::C);
|
2014-07-21 11:05:59 +02:00
|
|
|
}
|
2014-08-11 16:41:17 +02:00
|
|
|
label->setText(loc.toString(result) + postfix);
|
2014-07-21 11:05:59 +02:00
|
|
|
flag = true;
|
|
|
|
ChangeColor(labelEditFormula, okColor);
|
2014-09-06 10:38:30 +02:00
|
|
|
label->setToolTip(tr("Value"));
|
2014-07-21 11:05:59 +02:00
|
|
|
emit ToolTip("");
|
2014-05-30 21:03:17 +02:00
|
|
|
}
|
2014-05-26 16:33:44 +02:00
|
|
|
}
|
2014-06-16 19:18:36 +02:00
|
|
|
catch (qmu::QmuParserError &e)
|
2014-05-26 16:33:44 +02:00
|
|
|
{
|
|
|
|
label->setText(tr("Error"));
|
|
|
|
flag = false;
|
2014-07-14 12:21:46 +02:00
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
2014-12-04 12:35:29 +01:00
|
|
|
emit ToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
|
|
|
label->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
2014-05-26 16:33:44 +02:00
|
|
|
qDebug() << "\nMath parser error:\n"
|
|
|
|
<< "--------------------------------------\n"
|
|
|
|
<< "Message: " << e.GetMsg() << "\n"
|
|
|
|
<< "Expression: " << e.GetExpr() << "\n"
|
|
|
|
<< "--------------------------------------";
|
2014-05-25 11:46:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckState();
|
2014-11-21 15:57:47 +01:00
|
|
|
return result;
|
2014-05-25 11:46:54 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 09:17:59 +01:00
|
|
|
void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2015-02-03 09:17:59 +01:00
|
|
|
|
|
|
|
box->blockSignals(true);
|
|
|
|
|
2014-07-29 15:08:38 +02:00
|
|
|
FillComboBoxPoints(box);
|
2013-08-13 18:48:36 +02:00
|
|
|
ChangeCurrentData(box, value);
|
2015-02-03 09:17:59 +01:00
|
|
|
|
|
|
|
box->blockSignals(false);
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief setCurrentSplineId set current spline id in combobox
|
|
|
|
* @param box combobox
|
|
|
|
* @param value spline id
|
|
|
|
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
|
|
|
|
*/
|
2015-02-03 09:17:59 +01:00
|
|
|
void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2014-07-29 15:08:38 +02:00
|
|
|
FillComboBoxSplines(box, cut);
|
2013-12-18 12:13:32 +01:00
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief setCurrentArcId
|
|
|
|
* @param box combobox
|
|
|
|
* @param value arc id
|
|
|
|
* @param cut if set to ComboMode::CutArc don't show id+1 and id+2
|
|
|
|
*/
|
2015-02-03 09:17:59 +01:00
|
|
|
void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxCutArc cut) const
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2014-07-29 15:08:38 +02:00
|
|
|
FillComboBoxArcs(box, cut);
|
2014-01-08 15:05:32 +01:00
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief setCurrentSplinePathId set current splinePath id in combobox
|
|
|
|
* @param box combobox
|
|
|
|
* @param value splinePath id
|
|
|
|
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
|
|
|
|
*/
|
2015-02-03 09:17:59 +01:00
|
|
|
void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2014-07-29 15:08:38 +02:00
|
|
|
FillComboBoxSplinesPath(box, cut);
|
2013-12-18 12:13:32 +01:00
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
}
|
|
|
|
|
2014-10-23 10:38:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 09:17:59 +01:00
|
|
|
void DialogTool::setCurrentCurveId(QComboBox *box, const quint32 &value) const
|
2014-10-23 10:38:57 +02:00
|
|
|
{
|
|
|
|
SCASSERT(box != nullptr);
|
|
|
|
FillComboBoxCurves(box);
|
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief getCurrentPointId return current point id stored in combobox
|
|
|
|
* @param box combobox
|
|
|
|
* @return id or 0 if combobox is empty
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 DialogTool::getCurrentObjectId(QComboBox *box) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2013-08-13 18:48:36 +02:00
|
|
|
qint32 index = box->currentIndex();
|
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
|
|
|
|
{
|
2014-06-02 09:43:27 +02:00
|
|
|
return 0;
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-08-17 20:49:29 +02:00
|
|
|
bool DialogTool::SetObject(const quint32 &id, QComboBox *box, const QString &toolTip)
|
2014-03-04 18:13:10 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VGObject> obj = data->GetGObject(id);
|
|
|
|
SCASSERT(obj.isNull() == false);
|
2014-08-17 20:49:29 +02:00
|
|
|
const qint32 index = box->findText(obj->name());
|
2014-03-04 18:13:10 +01:00
|
|
|
if ( index != -1 )
|
|
|
|
{ // -1 for not found
|
|
|
|
box->setCurrentIndex(index);
|
|
|
|
emit ToolTip(toolTip);
|
|
|
|
return true;
|
|
|
|
}
|
2014-08-17 20:49:29 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning()<<"Can't find object by name"<<obj->name();
|
|
|
|
}
|
2014-03-04 18:13:10 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-19 11:29:56 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight)
|
|
|
|
{
|
|
|
|
SCASSERT(formula != nullptr);
|
|
|
|
SCASSERT(buttonGrowLength != nullptr)
|
2014-08-12 19:21:50 +02:00
|
|
|
if (formula->height() < DIALOG_MAX_FORMULA_HEIGHT)
|
2014-06-19 11:29:56 +02:00
|
|
|
{
|
2014-08-12 19:21:50 +02:00
|
|
|
formula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT);
|
2014-06-19 11:29:56 +02:00
|
|
|
//Set icon from theme (internal for Windows system)
|
|
|
|
buttonGrowLength->setIcon(QIcon::fromTheme("go-next",
|
|
|
|
QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
formula->setFixedHeight(formulaBaseHeight);
|
|
|
|
//Set icon from theme (internal for Windows system)
|
|
|
|
buttonGrowLength->setIcon(QIcon::fromTheme("go-down",
|
|
|
|
QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png")));
|
|
|
|
}
|
2014-09-26 12:25:47 +02:00
|
|
|
|
|
|
|
// I found that after change size of formula field, it was filed for angle formula, field for formula became black.
|
|
|
|
// This code prevent this.
|
|
|
|
setUpdatesEnabled(false);
|
|
|
|
repaint();
|
|
|
|
setUpdatesEnabled(true);
|
2014-06-19 11:29:56 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief FillList fill combobox list
|
|
|
|
* @param box combobox
|
|
|
|
* @param list list with ids and names
|
|
|
|
*/
|
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-05-30 21:56:05 +02:00
|
|
|
SCASSERT(box != nullptr);
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief CheckState enable, when all is correct, or disable, when something wrong, button ok
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::CheckState()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(bOk != nullptr);
|
2014-07-14 12:21:46 +02:00
|
|
|
bOk->setEnabled(flagFormula && flagName && flagError);
|
2014-06-09 18:37:11 +02:00
|
|
|
// In case dialog hasn't apply button
|
|
|
|
if ( bApply != nullptr)
|
|
|
|
{
|
2014-07-14 12:21:46 +02:00
|
|
|
bApply->setEnabled(bOk->isEnabled());
|
2014-06-09 18:37:11 +02:00
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
2014-07-15 16:42:41 +02:00
|
|
|
* @brief ChosenObject gets id and type of selected object. Save right data and ignore wrong.
|
2014-06-02 16:28:02 +02:00
|
|
|
* @param id id of point or detail
|
|
|
|
* @param type type of object
|
|
|
|
*/
|
2014-07-15 16:42:41 +02:00
|
|
|
void DialogTool::ChosenObject(quint32 id, const SceneObject &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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief NamePointChanged check name of point
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::NamePointChanged()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(labelEditNamePoint != nullptr);
|
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();
|
2014-09-06 10:14:59 +02:00
|
|
|
name.replace(" ", "");
|
2014-11-08 14:26:33 +01:00
|
|
|
QRegExpValidator v(QRegExp(nameRegExp), this);
|
|
|
|
int pos = 0;
|
|
|
|
if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false) ||
|
|
|
|
v.validate(name, pos) == QValidator::Invalid)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
flagName = false;
|
2014-07-14 12:21:46 +02:00
|
|
|
ChangeColor(labelEditNamePoint, Qt::red);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
flagName = true;
|
2014-07-14 18:28:41 +02:00
|
|
|
ChangeColor(labelEditNamePoint, okColor);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2014-07-14 12:21:46 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::ChangeColor(QWidget *widget, const QColor &color)
|
|
|
|
{
|
|
|
|
SCASSERT(widget != nullptr);
|
|
|
|
QPalette palette = widget->palette();
|
|
|
|
palette.setColor(widget->foregroundRole(), color);
|
|
|
|
widget->setPalette(palette);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogAccepted save data and emit signal about closed dialog.
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::DialogAccepted()
|
|
|
|
{
|
2014-08-13 12:20:30 +02:00
|
|
|
SaveData();
|
2013-07-28 00:18:06 +02:00
|
|
|
emit DialogClosed(QDialog::Accepted);
|
|
|
|
}
|
|
|
|
|
2014-08-13 12:20:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::DialogApply()
|
|
|
|
{
|
|
|
|
SaveData();
|
|
|
|
emit DialogApplied();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogRejected emit signal dialog rejected
|
|
|
|
*/
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief formula check formula
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::FormulaChanged()
|
|
|
|
{
|
2014-06-19 11:29:56 +02:00
|
|
|
QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-09 18:37:11 +02:00
|
|
|
void DialogTool::FormulaChangedPlainText()
|
2014-05-25 11:46:54 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ArrowUp set angle value 90 degree
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowUp()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(spinBoxAngle != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(90);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ArrowDown set angle value 270 degree
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowDown()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(spinBoxAngle != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(270);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ArrowLeft set angle value 180 degree
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowLeft()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(spinBoxAngle != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(180);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ArrowRight set angle value 0 degree
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowRight()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(spinBoxAngle != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(0);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ArrowLeftUp set angle value 135 degree
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowLeftUp()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(spinBoxAngle != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(135);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ArrowLeftDown set angle value 225 degree
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowLeftDown()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(spinBoxAngle != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(225);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ArrowRightUp set angle value 45 degree
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowRightUp()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(spinBoxAngle != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(45);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ArrowRightDown set angle value 315 degree
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ArrowRightDown()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(spinBoxAngle != nullptr);
|
2013-07-28 00:18:06 +02:00
|
|
|
spinBoxAngle->setValue(315);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief EvalFormula evaluate formula
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::EvalFormula()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(plainTextEditFormula != nullptr);
|
|
|
|
SCASSERT(labelResultCalculation != nullptr);
|
2014-08-11 16:41:17 +02:00
|
|
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit());
|
2014-11-22 11:57:05 +01:00
|
|
|
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief SizeHeight show in list base variables
|
|
|
|
*/
|
2014-03-11 21:19:13 +01:00
|
|
|
void DialogTool::SizeHeight()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(listWidget != nullptr);
|
2014-08-09 10:43:01 +02:00
|
|
|
listWidget->blockSignals(true);
|
2014-03-11 21:19:13 +01:00
|
|
|
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);
|
|
|
|
|
2014-08-09 10:43:01 +02:00
|
|
|
listWidget->blockSignals(false);
|
2014-03-11 21:19:13 +01:00
|
|
|
listWidget->setCurrentRow (0);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief Measurements show in list measurements
|
|
|
|
*/
|
2014-03-16 14:17:39 +01:00
|
|
|
void DialogTool::Measurements()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-09-24 18:37:39 +02:00
|
|
|
SCASSERT(checkBoxHideEmpty != nullptr);
|
|
|
|
checkBoxHideEmpty->setEnabled(true);
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief LengthLines show in list lengths of lines variables
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::LengthLines()
|
|
|
|
{
|
2014-09-24 18:37:39 +02:00
|
|
|
SCASSERT(checkBoxHideEmpty != nullptr);
|
|
|
|
checkBoxHideEmpty->setEnabled(false);
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief LengthArcs show in list lengths of arcs variables
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::LengthArcs()
|
|
|
|
{
|
2014-09-24 18:37:39 +02:00
|
|
|
SCASSERT(checkBoxHideEmpty != nullptr);
|
|
|
|
checkBoxHideEmpty->setEnabled(false);
|
2013-10-13 17:31:42 +02:00
|
|
|
ShowVariable(data->DataLengthArcs());
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief LengthCurves show in list lengths of curves variables
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::LengthCurves()
|
|
|
|
{
|
2014-09-24 18:37:39 +02:00
|
|
|
SCASSERT(checkBoxHideEmpty != nullptr);
|
|
|
|
checkBoxHideEmpty->setEnabled(false);
|
2013-10-13 17:31:42 +02:00
|
|
|
ShowVariable(data->DataLengthSplines());
|
|
|
|
}
|
|
|
|
|
2014-08-11 16:41:17 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::AngleLines()
|
|
|
|
{
|
2014-09-24 18:37:39 +02:00
|
|
|
SCASSERT(checkBoxHideEmpty != nullptr);
|
|
|
|
checkBoxHideEmpty->setEnabled(false);
|
2014-08-11 16:41:17 +02:00
|
|
|
ShowVariable(data->DataAngleLines());
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief Increments show in list increment variables
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::Increments()
|
|
|
|
{
|
2014-09-24 18:37:39 +02:00
|
|
|
SCASSERT(checkBoxHideEmpty != nullptr);
|
|
|
|
checkBoxHideEmpty->setEnabled(false);
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief PutHere put variable into edit
|
|
|
|
*/
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief PutVal put variable into edit
|
|
|
|
* @param item chosen item of list widget
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::PutVal(QListWidgetItem *item)
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(plainTextEditFormula != nullptr);
|
|
|
|
SCASSERT(item != nullptr);
|
2014-05-25 11:46:54 +02:00
|
|
|
QTextCursor cursor = plainTextEditFormula->textCursor();
|
|
|
|
cursor.insertText(item->text());
|
|
|
|
plainTextEditFormula->setTextCursor(cursor);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ValChenged show description when current variable changed
|
|
|
|
* @param row number of row
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::ValChenged(int row)
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(listWidget != nullptr);
|
|
|
|
SCASSERT(labelDescription != nullptr);
|
|
|
|
SCASSERT(radioButtonSizeGrowth != nullptr);
|
|
|
|
SCASSERT(radioButtonStandardTable != nullptr);
|
|
|
|
SCASSERT(radioButtonIncrements != nullptr);
|
|
|
|
SCASSERT(radioButtonLengthLine != nullptr);
|
|
|
|
SCASSERT(radioButtonLengthArc != nullptr);
|
|
|
|
SCASSERT(radioButtonLengthCurve != nullptr);
|
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());
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
|
2014-07-29 13:28:18 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(name))
|
|
|
|
.arg(stable->GetGuiText());
|
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 (radioButtonIncrements->isChecked())
|
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text());
|
2014-07-29 13:28:18 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(item->text()))
|
|
|
|
.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-07-29 13:28:18 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text())
|
2014-08-21 14:44:40 +02:00
|
|
|
.arg(*data->GetVariable<VLengthLine>(qApp->VarFromUser(item->text()))->GetValue())
|
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-07-29 13:28:18 +02:00
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text())
|
2014-08-21 14:44:40 +02:00
|
|
|
.arg(*data->GetVariable<VArcLength>(qApp->VarFromUser(item->text()))->GetValue())
|
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())
|
2014-08-21 14:44:40 +02:00
|
|
|
.arg(*data->GetVariable<VSplineLength>(qApp->VarFromUser(item->text()))->GetValue())
|
2014-07-29 13:28:18 +02:00
|
|
|
.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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief UpdateList update lists of variables
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogTool::UpdateList()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(radioButtonSizeGrowth != nullptr);
|
|
|
|
SCASSERT(radioButtonStandardTable != nullptr);
|
|
|
|
SCASSERT(radioButtonIncrements != nullptr);
|
|
|
|
SCASSERT(radioButtonLengthLine != nullptr);
|
|
|
|
SCASSERT(radioButtonLengthArc != nullptr);
|
|
|
|
SCASSERT(radioButtonLengthCurve != nullptr);
|
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-07-29 14:19:11 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogTool::GetToolId() const
|
|
|
|
{
|
|
|
|
return toolId;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::SetToolId(const quint32 &value)
|
|
|
|
{
|
|
|
|
toolId = value;
|
|
|
|
}
|
|
|
|
|
2015-02-02 17:35:40 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogTool::getPointName() const
|
|
|
|
{
|
|
|
|
return pointName;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ShowVariable show variables in list
|
|
|
|
* @param var container with variables
|
|
|
|
*/
|
2013-08-20 12:26:02 +02:00
|
|
|
template <class key, class val>
|
2014-07-29 13:28:18 +02:00
|
|
|
void DialogTool::ShowVariable(const QMap<key, val> var)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(listWidget != nullptr);
|
2014-09-24 18:37:39 +02:00
|
|
|
SCASSERT(checkBoxHideEmpty != nullptr);
|
2014-08-09 10:43:01 +02:00
|
|
|
listWidget->blockSignals(true);
|
2013-08-06 09:56:09 +02:00
|
|
|
listWidget->clear();
|
2013-10-13 13:04:26 +02:00
|
|
|
|
2014-07-29 13:28:18 +02:00
|
|
|
QMapIterator<key, val> iMap(var);
|
2013-11-04 21:35:15 +01:00
|
|
|
while (iMap.hasNext())
|
|
|
|
{
|
2013-10-13 13:04:26 +02:00
|
|
|
iMap.next();
|
2014-09-24 18:37:39 +02:00
|
|
|
if (checkBoxHideEmpty->isEnabled() && checkBoxHideEmpty->isChecked() && iMap.value()->IsNotUsed())
|
|
|
|
{
|
|
|
|
continue; //skip this measurement
|
|
|
|
}
|
2014-07-29 14:19:11 +02:00
|
|
|
if (iMap.value()->Filter(toolId) == false)
|
|
|
|
{// If we create this variable don't show
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(iMap.key());
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
listWidget->addItem(item);
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
2014-08-09 10:43:01 +02:00
|
|
|
listWidget->blockSignals(false);
|
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
|
|
|
|
2014-07-23 10:56:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::ShowVisToolTip(const QString &toolTip)
|
|
|
|
{
|
|
|
|
emit ToolTip(toolTip);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::ShowDialog(bool click)
|
|
|
|
{
|
|
|
|
Q_UNUSED(click);
|
|
|
|
}
|
2014-07-25 13:22:25 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::SetAssociatedTool(VAbstractTool *tool)
|
|
|
|
{
|
|
|
|
this->associatedTool=tool;
|
2014-07-29 14:19:11 +02:00
|
|
|
SetToolId(tool->getId());
|
2014-07-25 13:22:25 +02:00
|
|
|
}
|