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.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <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"
|
2015-06-18 19:23:24 +02:00
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <limits.h>
|
|
|
|
#include <qiterator.h>
|
|
|
|
#include <qnumeric.h>
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QCloseEvent>
|
|
|
|
#include <QComboBox>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QHash>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QKeyEvent>
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QLabel>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QMapIterator>
|
|
|
|
#include <QMessageLogger>
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPlainTextEdit>
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QPushButton>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <QRegularExpressionMatch>
|
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QShowEvent>
|
|
|
|
#include <QSize>
|
|
|
|
#include <QTextCursor>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <Qt>
|
|
|
|
#include <QtDebug>
|
|
|
|
#include <new>
|
2016-11-22 12:04:34 +01:00
|
|
|
#include <QBuffer>
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/xml/vdomdocument.h"
|
|
|
|
#include "../qmuparser/qmudef.h"
|
|
|
|
#include "../qmuparser/qmuparsererror.h"
|
|
|
|
#include "../vgeometry/vpointf.h"
|
|
|
|
#include "../vpatterndb/calculator.h"
|
|
|
|
#include "../vpatterndb/vcontainer.h"
|
|
|
|
#include "../vpatterndb/vtranslatevars.h"
|
2016-11-22 12:04:34 +01:00
|
|
|
#include "../vpatterndb/vpiecenode.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../../tools/vabstracttool.h"
|
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
|
|
|
#include "../vgeometry/vabstractcurve.h"
|
|
|
|
#include "../vgeometry/vgobject.h"
|
|
|
|
|
|
|
|
class QCloseEvent;
|
|
|
|
class QKeyEvent;
|
|
|
|
class QShowEvent;
|
|
|
|
template <class T> class QSharedPointer;
|
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),
|
2015-04-30 13:08:54 +02:00
|
|
|
labelResultCalculation(nullptr), labelEditNamePoint(nullptr), labelEditFormula(nullptr),
|
2015-01-29 16:47:02 +01:00
|
|
|
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr),
|
2015-05-21 21:24:31 +02:00
|
|
|
toolId(toolId), prepare(false), pointName(QString()), number(0), vis(nullptr)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(data != nullptr)
|
2013-07-28 00:18:06 +02:00
|
|
|
timerFormula = new QTimer(this);
|
|
|
|
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
|
|
|
}
|
|
|
|
|
2014-08-13 12:20:30 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogTool::~DialogTool()
|
|
|
|
{
|
|
|
|
emit ToolTip("");
|
2016-07-07 13:56:55 +02:00
|
|
|
|
|
|
|
if (not vis.isNull())
|
|
|
|
{
|
|
|
|
delete vis;
|
|
|
|
}
|
2014-08-13 12:20:30 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2015-11-05 14:01:33 +01:00
|
|
|
// do your init stuff here
|
|
|
|
|
|
|
|
setMaximumSize(size());
|
|
|
|
setMinimumSize(size());
|
|
|
|
|
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
|
|
|
|
*/
|
2015-06-24 16:30:07 +02:00
|
|
|
void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-06-24 16:30:07 +02:00
|
|
|
FillCombo<VPointF>(box, GOType::Point, rule, ch1, ch2);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-24 16:30:07 +02:00
|
|
|
void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2016-03-10 17:09:38 +01:00
|
|
|
FillCombo<VAbstractCurve>(box, GOType::Arc, rule, ch1, ch2);
|
2014-01-08 15:05:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-04-01 16:32:36 +02:00
|
|
|
void DialogTool::FillComboBoxSplines(QComboBox *box) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2016-03-22 16:14:53 +01:00
|
|
|
box->blockSignals(true);
|
|
|
|
|
|
|
|
const auto objs = data->DataGObjects();
|
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
|
|
|
QMap<QString, quint32> list;
|
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
|
|
|
{
|
2016-04-01 16:32:36 +02:00
|
|
|
if (i.key() != toolId)
|
2016-03-22 16:14:53 +01:00
|
|
|
{
|
2016-04-01 16:32:36 +02:00
|
|
|
if (IsSpline(i.value()))
|
2016-03-22 16:14:53 +01:00
|
|
|
{
|
2016-04-01 16:32:36 +02:00
|
|
|
PrepareList<VAbstractCurve>(list, i.key());
|
2016-03-22 16:14:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FillList(box, list);
|
|
|
|
|
|
|
|
box->blockSignals(false);
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-04-01 16:32:36 +02:00
|
|
|
void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const
|
2016-03-10 17:09:38 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2016-03-10 17:09:38 +01:00
|
|
|
box->blockSignals(true);
|
|
|
|
|
|
|
|
const auto objs = data->DataGObjects();
|
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
|
|
|
QMap<QString, quint32> list;
|
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
|
|
|
{
|
2016-04-01 16:32:36 +02:00
|
|
|
if (i.key() != toolId)
|
2016-03-10 17:09:38 +01:00
|
|
|
{
|
2016-04-01 16:32:36 +02:00
|
|
|
if (IsSplinePath(i.value()))
|
2016-03-10 17:09:38 +01:00
|
|
|
{
|
2016-04-01 16:32:36 +02:00
|
|
|
PrepareList<VAbstractCurve>(list, i.key());
|
2016-03-10 17:09:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FillList(box, list);
|
|
|
|
|
|
|
|
box->blockSignals(false);
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-10-23 10:38:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::FillComboBoxCurves(QComboBox *box) const
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2016-03-10 17:09:38 +01:00
|
|
|
const auto objs = data->DataGObjects();
|
2014-10-23 10:38:57 +02:00
|
|
|
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();
|
2016-12-20 12:04:56 +01:00
|
|
|
if ((obj->getType() == GOType::Arc
|
|
|
|
|| obj->getType() == GOType::EllipticalArc
|
|
|
|
|| obj->getType() == GOType::Spline
|
|
|
|
|| obj->getType() == GOType::SplinePath
|
|
|
|
|| obj->getType() == GOType::CubicBezier
|
|
|
|
|| obj->getType() == GOType::CubicBezierPath) && obj->getMode() == Draw::Calculation)
|
2014-10-23 10:38:57 +02:00
|
|
|
{
|
2016-03-22 16:14:53 +01:00
|
|
|
PrepareList<VAbstractCurve>(list, i.key());
|
2014-10-23 10:38:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2016-12-20 19:57:20 +01: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
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2015-02-02 11:28:09 +01:00
|
|
|
|
2015-12-01 16:13:57 +01:00
|
|
|
box->clear();
|
|
|
|
int size = box->iconSize().height();
|
|
|
|
// On Mac pixmap should be little bit smaller.
|
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
size -= 2; // Two pixels should be enough.
|
|
|
|
#endif //defined(Q_OS_MAC)
|
|
|
|
|
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-12-01 16:13:57 +01:00
|
|
|
QPixmap pix(size, size);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-30 12:02:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::FillComboBoxCrossCirclesPoints(QComboBox *box) const
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2015-05-30 12:02:20 +02:00
|
|
|
|
|
|
|
box->addItem(tr("First point"), QVariant(static_cast<int>(CrossCirclesPoint::FirstPoint)));
|
|
|
|
box->addItem(tr("Second point"), QVariant(static_cast<int>(CrossCirclesPoint::SecondPoint)));
|
|
|
|
}
|
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::FillComboBoxVCrossCurvesPoint(QComboBox *box) const
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
|
|
|
|
box->addItem(tr("Highest point"), QVariant(static_cast<int>(VCrossCurvesPoint::HighestPoint)));
|
|
|
|
box->addItem(tr("Lowest point"), QVariant(static_cast<int>(VCrossCurvesPoint::LowestPoint)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::FillComboBoxHCrossCurvesPoint(QComboBox *box) const
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
|
2016-01-25 18:10:39 +01:00
|
|
|
box->addItem(tr("Leftmost point"), QVariant(static_cast<int>(HCrossCurvesPoint::LeftmostPoint)));
|
|
|
|
box->addItem(tr("Rightmost point"), QVariant(static_cast<int>(HCrossCurvesPoint::RightmostPoint)));
|
2016-01-24 17:15:08 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-10-17 13:53:46 +02:00
|
|
|
QString DialogTool::GetComboBoxCurrentData(const QComboBox *box, const QString &def) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-01-29 16:47:02 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2015-04-02 11:51:27 +02:00
|
|
|
QString value;
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
|
|
|
value = box->itemData(box->currentIndex()).toString();
|
|
|
|
#else
|
|
|
|
value = box->currentData().toString();
|
|
|
|
#endif
|
2015-01-29 16:47:02 +01:00
|
|
|
if (value.isEmpty())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-10-17 13:53:46 +02:00
|
|
|
value = def;
|
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-10-29 14:40:56 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit)
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(plainTextEdit != nullptr)
|
2014-10-29 14:40:56 +01:00
|
|
|
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)
|
|
|
|
{
|
2016-08-23 20:24:14 +02:00
|
|
|
if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object))
|
2014-10-29 19:00:38 +01:00
|
|
|
{
|
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;
|
|
|
|
}
|
2016-08-23 20:24:14 +02:00
|
|
|
else if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
|
|
|
|
{
|
|
|
|
if (qApp->Settings()->GetOsSeparator())
|
|
|
|
{
|
2017-01-03 09:46:28 +01:00
|
|
|
plainTextEdit->insertPlainText(QLocale().decimalPoint());
|
2016-08-23 20:24:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
plainTextEdit->insertPlainText(QLocale::c().decimalPoint());
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-29 19:00:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// pass the event on to the parent class
|
|
|
|
return QDialog::eventFilter(object, event);
|
|
|
|
}
|
2016-08-23 20:24:14 +02:00
|
|
|
return false;// pass the event to the widget
|
2014-10-29 19:00:38 +01:00
|
|
|
}
|
|
|
|
|
2016-02-16 13:00:56 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogTool::DNumber(const QString &baseName) const
|
|
|
|
{
|
|
|
|
quint32 num = 0;
|
|
|
|
QString name;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
++num;
|
|
|
|
name = baseName + QString("_%1").arg(num);
|
|
|
|
} while (not data->IsUnique(name));
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
2016-11-22 12:04:34 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogTool::RowId(QListWidget *listWidget, int i)
|
|
|
|
{
|
|
|
|
SCASSERT(listWidget != nullptr);
|
|
|
|
const QListWidgetItem *rowItem = listWidget->item(i);
|
|
|
|
SCASSERT(rowItem != nullptr);
|
|
|
|
const VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
|
|
|
return rowNode.GetId();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogTool::FirstPointEqualLast(QListWidget *listWidget)
|
|
|
|
{
|
|
|
|
SCASSERT(listWidget != nullptr);
|
|
|
|
if (listWidget->count() > 1)
|
|
|
|
{
|
|
|
|
return RowId(listWidget, 0) == RowId(listWidget, listWidget->count()-1);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogTool::DoublePoints(QListWidget *listWidget)
|
|
|
|
{
|
|
|
|
SCASSERT(listWidget != nullptr);
|
|
|
|
for (int i=0, sz = listWidget->count()-1; i<sz; ++i)
|
|
|
|
{
|
|
|
|
if (RowId(listWidget, i) == RowId(listWidget, i+1))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogTool::DialogWarningIcon()
|
|
|
|
{
|
|
|
|
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
|
|
|
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
|
|
|
|
|
|
|
|
const QPixmap pixmap = icon.pixmap(QSize(16, 16));
|
|
|
|
QByteArray byteArray;
|
|
|
|
QBuffer buffer(&byteArray);
|
|
|
|
pixmap.save(&buffer, "PNG");
|
|
|
|
const QString url = QString("<img src=\"data:image/png;base64,") + byteArray.toBase64() + QLatin1String("\"/> ");
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogTool::GetNodeName(const VPieceNode &node) const
|
|
|
|
{
|
|
|
|
const QSharedPointer<VGObject> obj = data->GeometricObject<VGObject>(node.GetId());
|
|
|
|
QString name = obj->name();
|
|
|
|
|
|
|
|
if (node.GetTypeTool() != Tool::NodePoint && node.GetReverse())
|
|
|
|
{
|
|
|
|
name = QLatin1String("- ") + name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::NewNodeItem(QListWidget *listWidget, const VPieceNode &node)
|
|
|
|
{
|
|
|
|
SCASSERT(listWidget != nullptr);
|
|
|
|
SCASSERT(node.GetId() > NULL_ID);
|
|
|
|
QString name;
|
|
|
|
switch (node.GetTypeTool())
|
|
|
|
{
|
|
|
|
case (Tool::NodePoint):
|
|
|
|
case (Tool::NodeArc):
|
|
|
|
case (Tool::NodeSpline):
|
|
|
|
case (Tool::NodeSplinePath):
|
|
|
|
{
|
|
|
|
name = GetNodeName(node);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
qDebug()<<"Got wrong tools. Ignore.";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canAddNewPoint = false;
|
|
|
|
|
|
|
|
if(listWidget->count() == 0)
|
|
|
|
{
|
|
|
|
canAddNewPoint = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(RowId(listWidget, listWidget->count()-1) != node.GetId())
|
|
|
|
{
|
|
|
|
canAddNewPoint = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(canAddNewPoint)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(name);
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
|
|
|
listWidget->addItem(item);
|
|
|
|
listWidget->setCurrentRow(listWidget->count()-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-28 12:58:17 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::InitNodeAngles(QComboBox *box)
|
|
|
|
{
|
|
|
|
SCASSERT(box != nullptr);
|
|
|
|
box->clear();
|
|
|
|
|
|
|
|
box->addItem(tr("by length"), static_cast<unsigned char>(PieceNodeAngle::ByLength));
|
|
|
|
box->addItem(tr("by points intersetions"), static_cast<unsigned char>(PieceNodeAngle::ByPointsIntersection));
|
|
|
|
box->addItem(tr("by first edge symmetry"), static_cast<unsigned char>(PieceNodeAngle::ByFirstEdgeSymmetry));
|
|
|
|
box->addItem(tr("by second edge symmetry"), static_cast<unsigned char>(PieceNodeAngle::BySecondEdgeSymmetry));
|
|
|
|
box->addItem(tr("by first edge right angle"), static_cast<unsigned char>(PieceNodeAngle::ByFirstEdgeRightAngle));
|
|
|
|
box->addItem(tr("by second edge right angle"), static_cast<unsigned char>(PieceNodeAngle::BySecondEdgeRightAngle));
|
|
|
|
}
|
|
|
|
|
2016-03-22 16:14:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogTool::IsSplinePath(const QSharedPointer<VGObject> &obj) const
|
|
|
|
{
|
|
|
|
return (obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath) &&
|
|
|
|
obj->getMode() == Draw::Calculation;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2016-03-05 13:30:18 +01:00
|
|
|
void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer, const QString& postfix)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(edit != nullptr)
|
|
|
|
SCASSERT(timer != nullptr)
|
|
|
|
SCASSERT(labelEditFormula != nullptr)
|
|
|
|
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);
|
2016-03-05 13:30:18 +01:00
|
|
|
if (postfix.isEmpty())
|
|
|
|
{
|
|
|
|
labelResultCalculation->setText(tr("Error"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
labelResultCalculation->setText(tr("Error") + " (" + postfix + ")");
|
|
|
|
}
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-03-05 13:30:18 +01:00
|
|
|
void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *timer, const QString& postfix)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(edit != nullptr)
|
|
|
|
SCASSERT(timer != nullptr)
|
|
|
|
SCASSERT(labelEditFormula != nullptr)
|
|
|
|
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);
|
2016-03-05 13:30:18 +01:00
|
|
|
if (postfix.isEmpty())
|
|
|
|
{
|
|
|
|
labelResultCalculation->setText(tr("Error"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
labelResultCalculation->setText(tr("Error") + " (" + postfix + ")");
|
|
|
|
}
|
|
|
|
|
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
|
2015-02-08 14:43:30 +01:00
|
|
|
* @param text expresion that we parse
|
|
|
|
* @param flag flag state of eval formula
|
2014-06-02 16:28:02 +02:00
|
|
|
* @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
|
|
|
{
|
2016-09-10 15:17:55 +02:00
|
|
|
qDebug() << "Eval started";
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(label != nullptr)
|
2016-09-10 15:17:55 +02:00
|
|
|
qDebug() << "Label ok";
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(labelEditFormula != nullptr)
|
2016-09-10 15:17:55 +02:00
|
|
|
qDebug() << "lef ok";
|
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);
|
2015-07-03 16:14:35 +02:00
|
|
|
label->setText(tr("Error") + " (" + postfix + ")");
|
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
|
|
|
{
|
2015-02-08 14:43:30 +01:00
|
|
|
// Replace line return character with spaces for calc if exist
|
2014-06-18 13:38:20 +02:00
|
|
|
QString formula = text;
|
2014-06-16 19:18:36 +02:00
|
|
|
formula.replace("\n", " ");
|
2015-06-12 10:55:44 +02:00
|
|
|
// Translate to internal look.
|
2015-06-18 10:49:25 +02:00
|
|
|
formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
|
2016-05-24 14:25:58 +02:00
|
|
|
QScopedPointer<Calculator> cal(new Calculator());
|
2015-10-15 12:07:43 +02:00
|
|
|
result = cal->EvalFormula(data->PlainVariables(), formula);
|
2014-05-26 16:33:44 +02:00
|
|
|
|
2016-05-24 14:06:35 +02:00
|
|
|
if (qIsInf(result) || qIsNaN(result))
|
2014-05-30 21:03:17 +02:00
|
|
|
{
|
2014-07-21 11:05:59 +02:00
|
|
|
flag = false;
|
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
2015-07-03 16:14:35 +02:00
|
|
|
label->setText(tr("Error") + " (" + postfix + ")");
|
2016-05-24 14:06:35 +02:00
|
|
|
label->setToolTip(tr("Invalid value"));
|
2014-05-30 21:03:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-24 14:06:35 +02:00
|
|
|
//if result equal 0
|
|
|
|
if (checkZero && qFuzzyIsNull(result))
|
|
|
|
{
|
|
|
|
flag = false;
|
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
|
|
|
label->setText(tr("Error") + " (" + postfix + ")");
|
|
|
|
label->setToolTip(tr("Value can't be 0"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label->setText(qApp->LocaleToString(result) + " " +postfix);
|
|
|
|
flag = true;
|
|
|
|
ChangeColor(labelEditFormula, okColor);
|
|
|
|
label->setToolTip(tr("Value"));
|
|
|
|
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
|
|
|
{
|
2015-07-03 16:14:35 +02:00
|
|
|
label->setText(tr("Error") + " (" + postfix + ")");
|
2014-05-26 16:33:44 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2015-02-08 14:43:30 +01:00
|
|
|
CheckState(); // Disable Ok and Apply buttons if something wrong.
|
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-06-24 16:30:07 +02:00
|
|
|
void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value, FillComboBox rule,
|
|
|
|
const quint32 &ch1, const quint32 &ch2) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2015-02-03 09:17:59 +01:00
|
|
|
|
|
|
|
box->blockSignals(true);
|
|
|
|
|
2015-06-24 16:30:07 +02:00
|
|
|
FillComboBoxPoints(box, rule, ch1, ch2);
|
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
|
|
|
|
*/
|
2016-04-01 16:32:36 +02:00
|
|
|
void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2016-04-01 16:32:36 +02:00
|
|
|
FillComboBoxSplines(box);
|
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
|
|
|
|
*/
|
2015-06-24 16:30:07 +02:00
|
|
|
void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, FillComboBox rule,
|
|
|
|
const quint32 &ch1, const quint32 &ch2) const
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2015-06-24 16:30:07 +02:00
|
|
|
FillComboBoxArcs(box, rule, ch1, ch2);
|
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
|
|
|
|
*/
|
2016-04-01 16:32:36 +02:00
|
|
|
void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value) const
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2016-04-01 16:32:36 +02:00
|
|
|
FillComboBoxSplinesPath(box);
|
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
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2014-10-23 10:38:57 +02:00
|
|
|
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
|
|
|
{
|
2016-12-20 19:57:20 +01: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
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2015-07-03 19:06:30 +02:00
|
|
|
const qint32 index = box->findData(id);
|
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
|
|
|
|
{
|
2015-07-03 19:06:30 +02:00
|
|
|
qWarning()<<"Can't find object by id"<<id;
|
2014-08-17 20:49:29 +02:00
|
|
|
}
|
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)
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(formula != nullptr)
|
|
|
|
SCASSERT(buttonGrowLength != nullptr)
|
2015-10-05 16:12:36 +02:00
|
|
|
|
|
|
|
const QTextCursor cursor = formula->textCursor();
|
|
|
|
|
2016-02-25 20:39:21 +01:00
|
|
|
//Before deploy ned to release dialog size
|
|
|
|
//I don't know why, but don't need to fixate again.
|
|
|
|
//A dialog will be lefted fixated. That's what we need.
|
|
|
|
setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
|
|
|
setMinimumSize(QSize(0, 0));
|
|
|
|
|
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);
|
2015-10-05 16:12:36 +02:00
|
|
|
|
|
|
|
formula->setFocus();
|
|
|
|
formula->setTextCursor(cursor);
|
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
|
|
|
{
|
2016-12-20 19:57:20 +01: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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-22 16:14:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
void DialogTool::PrepareList(QMap<QString, quint32> &list, quint32 id) const
|
|
|
|
{
|
|
|
|
const auto obj = data->GeometricObject<T>(id);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(obj != nullptr)
|
2016-03-22 16:14:53 +01:00
|
|
|
|
|
|
|
QString newName = obj->name();
|
|
|
|
int bias = 0;
|
|
|
|
if (qApp->TrVars()->VariablesToUser(newName, 0, obj->name(), bias))
|
|
|
|
{
|
|
|
|
list[newName] = id;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
list[obj->name()] = id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogTool::IsSpline(const QSharedPointer<VGObject> &obj) const
|
|
|
|
{
|
|
|
|
return (obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier) &&
|
|
|
|
obj->getMode() == Draw::Calculation;
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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
|
|
|
{
|
2016-12-20 20:19:21 +01:00
|
|
|
Q_UNUSED(id)
|
|
|
|
Q_UNUSED(type)
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2016-04-05 19:14:12 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::SelectedObject(bool selected, quint32 object, quint32 tool)
|
|
|
|
{
|
2016-12-20 20:19:21 +01:00
|
|
|
Q_UNUSED(selected)
|
|
|
|
Q_UNUSED(object)
|
|
|
|
Q_UNUSED(tool)
|
2016-04-05 19:14:12 +02:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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();
|
2015-05-11 14:59:53 +02:00
|
|
|
QRegularExpression rx(NameRegExp());
|
2014-11-08 14:26:33 +01:00
|
|
|
if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false) ||
|
2015-05-11 14:59:53 +02:00
|
|
|
rx.match(name).hasMatch() == false)
|
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)
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(widget != nullptr)
|
2014-07-14 12:21:46 +02:00
|
|
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-10-28 15:22:36 +01:00
|
|
|
void DialogTool::FormulaChangedPlainText() //-V524
|
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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01: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()
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(plainTextEditFormula != nullptr)
|
|
|
|
SCASSERT(labelResultCalculation != nullptr)
|
2015-02-08 14:43:30 +01:00
|
|
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit());//Show unit in dialog lable (cm, mm or inch)
|
2014-11-22 11:57:05 +01:00
|
|
|
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-07-29 14:19:11 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-04-15 14:44:57 +02:00
|
|
|
// cppcheck-suppress unusedFunction
|
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-07-23 10:56:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::ShowDialog(bool click)
|
|
|
|
{
|
2016-12-20 20:19:21 +01:00
|
|
|
Q_UNUSED(click)
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|
2014-07-25 13:22:25 +02:00
|
|
|
|
2016-06-23 19:20:21 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::Build(const Tool &type)
|
|
|
|
{
|
2016-12-20 20:19:21 +01:00
|
|
|
Q_UNUSED(type)
|
2016-06-23 19:20:21 +02:00
|
|
|
}
|
|
|
|
|
2016-11-23 17:41:01 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::SetPiecesList(const QVector<quint32> &list)
|
|
|
|
{
|
|
|
|
Q_UNUSED(list);
|
|
|
|
}
|
|
|
|
|
2014-07-25 13:22:25 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::SetAssociatedTool(VAbstractTool *tool)
|
|
|
|
{
|
2016-07-02 11:12:12 +02:00
|
|
|
if (tool != nullptr)
|
|
|
|
{
|
|
|
|
associatedTool = tool;
|
|
|
|
SetToolId(tool->getId());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
associatedTool = nullptr;
|
|
|
|
SetToolId(NULL_ID);
|
|
|
|
}
|
2014-07-25 13:22:25 +02:00
|
|
|
}
|
2015-06-20 20:32:35 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename GObject>
|
2015-06-24 16:30:07 +02:00
|
|
|
void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, const quint32 &ch1,
|
|
|
|
const quint32 &ch2) const
|
2015-06-20 20:32:35 +02:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(box != nullptr)
|
2015-06-24 16:30:07 +02:00
|
|
|
box->blockSignals(true);
|
|
|
|
|
2015-06-20 20:32:35 +02:00
|
|
|
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
|
|
|
QMap<QString, quint32> list;
|
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
|
|
|
{
|
|
|
|
if (rule == FillComboBox::NoChildren)
|
|
|
|
{
|
2015-06-24 16:30:07 +02:00
|
|
|
if (i.key() != toolId && i.key() != ch1 && i.key() != ch2)
|
2015-06-20 20:32:35 +02:00
|
|
|
{
|
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
|
|
|
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
|
|
|
|
{
|
2016-03-22 16:14:53 +01:00
|
|
|
PrepareList<GObject>(list, i.key());
|
2015-06-20 20:32:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i.key() != toolId)
|
|
|
|
{
|
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
|
|
|
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
|
|
|
|
{
|
2016-03-22 16:14:53 +01:00
|
|
|
PrepareList<GObject>(list, i.key());
|
2015-06-20 20:32:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FillList(box, list);
|
2015-06-24 16:30:07 +02:00
|
|
|
|
|
|
|
box->blockSignals(false);
|
2015-06-20 20:32:35 +02:00
|
|
|
}
|