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
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2013-11-15 13:41:26 +01:00
|
|
|
** 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"
|
|
|
|
|
|
|
|
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-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
|
|
|
|
*/
|
2019-02-11 12:25:27 +01:00
|
|
|
DialogTool::DialogTool(const VContainer *data, quint32 toolId, QWidget *parent)
|
2017-02-24 16:17:56 +01:00
|
|
|
: QDialog(parent),
|
|
|
|
data(data),
|
|
|
|
isInitialized(false),
|
|
|
|
bOk(nullptr),
|
|
|
|
bApply(nullptr),
|
|
|
|
associatedTool(nullptr),
|
|
|
|
toolId(toolId),
|
|
|
|
prepare(false),
|
|
|
|
number(0),
|
|
|
|
vis(nullptr)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
SCASSERT(data != nullptr)
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-08-13 12:20:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogTool::~DialogTool()
|
|
|
|
{
|
2018-03-14 15:01:24 +01:00
|
|
|
emit ToolTip(QString());
|
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)
|
|
|
|
{
|
2018-05-07 13:23:47 +02: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();
|
2019-02-11 12:25:27 +01:00
|
|
|
|
|
|
|
CheckState();
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2017-04-14 12:52:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-05-07 13:28:51 +02:00
|
|
|
void DialogTool::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->key())
|
|
|
|
{
|
|
|
|
case Qt::Key_Escape:
|
|
|
|
DialogRejected();
|
|
|
|
return; // After reject the dialog will be destroyed, exit imidiately
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QDialog::keyPressEvent ( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-04-14 12:52:59 +02:00
|
|
|
void DialogTool::FillComboBoxPiecesList(QComboBox *box, const QVector<quint32> &list)
|
|
|
|
{
|
|
|
|
SCASSERT(box != nullptr)
|
|
|
|
box->blockSignals(true);
|
|
|
|
box->clear();
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto id : list)
|
2017-04-14 12:52:59 +02:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
box->addItem(data->GetPiece(id).GetName(), id);
|
2017-04-14 12:52:59 +02:00
|
|
|
}
|
|
|
|
box->blockSignals(false);
|
|
|
|
box->setCurrentIndex(-1); // Force a user to choose
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule, quint32 ch1, 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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule, quint32 ch1, 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);
|
|
|
|
|
2017-10-26 11:54:08 +02:00
|
|
|
const auto objs = data->CalculationGObjects();
|
2016-03-22 16:14:53 +01:00
|
|
|
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);
|
|
|
|
|
2017-10-26 11:54:08 +02:00
|
|
|
const auto objs = data->CalculationGObjects();
|
2016-03-10 17:09:38 +01:00
|
|
|
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)
|
2017-10-26 11:54:08 +02:00
|
|
|
const auto objs = data->CalculationGObjects();
|
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();
|
2017-10-26 11:54:08 +02: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)
|
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())
|
|
|
|
{
|
2018-03-14 15:01:24 +01:00
|
|
|
box->addItem(i.value(), QString(), QVariant(i.key()));
|
2015-01-29 16:47:02 +01:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
const int index = box->findData(QVariant(TypeLineLine));
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
box->setCurrentIndex(index);
|
|
|
|
}
|
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;
|
|
|
|
value = box->currentData().toString();
|
2017-05-30 18:52:38 +02:00
|
|
|
|
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 19:00:38 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
const bool fitered = FilterObject(object, event);
|
|
|
|
if (fitered)
|
2014-10-29 19:00:38 +01:00
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
return fitered;
|
2014-10-29 19:00:38 +01:00
|
|
|
}
|
2019-02-11 12:25:27 +01:00
|
|
|
|
|
|
|
return QDialog::eventFilter(object, event);
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-09-24 13:41:34 +02:00
|
|
|
QString DialogTool::GetNodeName(const VPieceNode &node, bool showDetails) const
|
2016-11-22 12:04:34 +01:00
|
|
|
{
|
2017-02-14 14:12:37 +01:00
|
|
|
const QSharedPointer<VGObject> obj = data->GetGObject(node.GetId());
|
2016-11-22 12:04:34 +01:00
|
|
|
QString name = obj->name();
|
|
|
|
|
2017-02-14 14:12:37 +01:00
|
|
|
if (node.GetTypeTool() != Tool::NodePoint)
|
2016-11-22 12:04:34 +01:00
|
|
|
{
|
2017-02-14 14:12:37 +01:00
|
|
|
int bias = 0;
|
|
|
|
qApp->TrVars()->VariablesToUser(name, 0, obj->name(), bias);
|
|
|
|
|
2018-09-24 13:41:34 +02:00
|
|
|
if (showDetails && node.GetReverse())
|
2017-02-14 14:12:37 +01:00
|
|
|
{
|
|
|
|
name = QLatin1String("- ") + name;
|
|
|
|
}
|
2016-11-22 12:04:34 +01:00
|
|
|
}
|
2018-03-05 11:05:59 +01:00
|
|
|
else
|
2017-03-24 12:08:16 +01:00
|
|
|
{
|
2018-09-24 13:41:34 +02:00
|
|
|
if (showDetails && node.IsPassmark())
|
2018-03-05 11:05:59 +01:00
|
|
|
{
|
|
|
|
switch(node.GetPassmarkLineType())
|
|
|
|
{
|
|
|
|
case PassmarkLineType::OneLine:
|
|
|
|
name += QLatin1Char('|');
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::TwoLines:
|
|
|
|
name += QLatin1Literal("||");
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::ThreeLines:
|
|
|
|
name += QLatin1Literal("|||");
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::TMark:
|
2019-01-24 08:26:57 +01:00
|
|
|
name += QStringLiteral("┴");
|
2018-03-05 11:05:59 +01:00
|
|
|
break;
|
|
|
|
case PassmarkLineType::VMark:
|
2019-01-24 08:26:57 +01:00
|
|
|
name += QStringLiteral("⊼");
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::VMark2:
|
|
|
|
name += QStringLiteral("⊽");
|
2018-03-05 11:05:59 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-24 13:41:34 +02:00
|
|
|
if (showDetails && not node.IsCheckUniqueness())
|
2017-03-24 12:08:16 +01:00
|
|
|
{
|
2018-03-05 11:05:59 +01:00
|
|
|
name = QLatin1Char('[') + name + QLatin1Char(']');
|
2017-03-24 12:08:16 +01:00
|
|
|
}
|
|
|
|
}
|
2016-11-22 12:04:34 +01:00
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-07-22 10:31:57 +02:00
|
|
|
void DialogTool::NewNodeItem(QListWidget *listWidget, const VPieceNode &node, bool showPassmark)
|
2016-11-22 12:04:34 +01:00
|
|
|
{
|
|
|
|
SCASSERT(listWidget != nullptr);
|
|
|
|
SCASSERT(node.GetId() > NULL_ID);
|
|
|
|
QString name;
|
|
|
|
switch (node.GetTypeTool())
|
|
|
|
{
|
|
|
|
case (Tool::NodePoint):
|
|
|
|
case (Tool::NodeArc):
|
2017-02-10 15:47:15 +01:00
|
|
|
case (Tool::NodeElArc):
|
2016-11-22 12:04:34 +01:00
|
|
|
case (Tool::NodeSpline):
|
|
|
|
case (Tool::NodeSplinePath):
|
2018-07-22 10:31:57 +02:00
|
|
|
name = GetNodeName(node, showPassmark);
|
2016-11-22 12:04:34 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
qDebug()<<"Got wrong tools. Ignore.";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canAddNewPoint = false;
|
|
|
|
|
|
|
|
if(listWidget->count() == 0)
|
|
|
|
{
|
|
|
|
canAddNewPoint = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-20 10:47:01 +01:00
|
|
|
if(RowNode(listWidget, listWidget->count()-1).GetId() != node.GetId())
|
2016-11-22 12:04:34 +01:00
|
|
|
{
|
|
|
|
canAddNewPoint = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(canAddNewPoint)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(name);
|
2018-04-08 18:45:23 +02:00
|
|
|
item->setFont(NodeFont(item->font(), node.IsExcluded()));
|
2016-11-22 12:04:34 +01:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2018-03-23 10:16:23 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::MoveListRowTop(QListWidget *list)
|
|
|
|
{
|
|
|
|
SCASSERT(list != nullptr)
|
|
|
|
const int currentIndex = list->currentRow();
|
|
|
|
if (QListWidgetItem *currentItem = list->takeItem(currentIndex))
|
|
|
|
{
|
|
|
|
list->insertItem(0, currentItem);
|
|
|
|
list->setCurrentRow(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::MoveListRowUp(QListWidget *list)
|
|
|
|
{
|
|
|
|
SCASSERT(list != nullptr)
|
|
|
|
int currentIndex = list->currentRow();
|
|
|
|
if (QListWidgetItem *currentItem = list->takeItem(currentIndex--))
|
|
|
|
{
|
|
|
|
if (currentIndex < 0)
|
|
|
|
{
|
|
|
|
currentIndex = 0;
|
|
|
|
}
|
|
|
|
list->insertItem(currentIndex, currentItem);
|
|
|
|
list->setCurrentRow(currentIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::MoveListRowDown(QListWidget *list)
|
|
|
|
{
|
|
|
|
SCASSERT(list != nullptr)
|
|
|
|
int currentIndex = list->currentRow();
|
|
|
|
if (QListWidgetItem *currentItem = list->takeItem(currentIndex++))
|
|
|
|
{
|
|
|
|
if (currentIndex > list->count())
|
|
|
|
{
|
|
|
|
currentIndex = list->count();
|
|
|
|
}
|
|
|
|
list->insertItem(currentIndex, currentItem);
|
|
|
|
list->setCurrentRow(currentIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::MoveListRowBottom(QListWidget *list)
|
|
|
|
{
|
|
|
|
SCASSERT(list != nullptr)
|
|
|
|
const int currentIndex = list->currentRow();
|
|
|
|
if (QListWidgetItem *currentItem = list->takeItem(currentIndex))
|
|
|
|
{
|
|
|
|
list->insertItem(list->count(), currentItem);
|
|
|
|
list->setCurrentRow(list->count()-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-22 16:14:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogTool::IsSplinePath(const QSharedPointer<VGObject> &obj) const
|
|
|
|
{
|
2017-10-26 11:54:08 +02:00
|
|
|
return obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath;
|
2016-03-22 16:14:53 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief Eval evaluate formula and show result
|
2019-02-11 12:25:27 +01:00
|
|
|
* @param formulaData options to control parsing
|
2014-06-02 16:28:02 +02:00
|
|
|
*/
|
2019-02-11 12:25:27 +01:00
|
|
|
qreal DialogTool::Eval(const FormulaData &formulaData, bool &flag)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
const qreal result = EvalToolFormula(this, formulaData, flag);
|
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-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
|
|
|
|
{
|
2017-10-26 11:54:08 +02:00
|
|
|
return obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier;
|
2016-03-22 16:14:53 +01:00
|
|
|
}
|
|
|
|
|
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)
|
2019-02-11 12:25:27 +01:00
|
|
|
bOk->setEnabled(IsValid());
|
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 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();
|
2018-05-07 13:23:47 +02:00
|
|
|
emit DialogClosed(QDialog::Accepted);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
|
2014-08-13 12:20:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogTool::DialogApply()
|
|
|
|
{
|
|
|
|
SaveData();
|
|
|
|
emit DialogApplied();
|
|
|
|
}
|
|
|
|
|
2018-05-07 13:23:47 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief DialogRejected emit signal dialog rejected
|
|
|
|
*/
|
|
|
|
void DialogTool::DialogRejected()
|
|
|
|
{
|
|
|
|
emit DialogClosed(QDialog::Rejected);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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());
|
2017-02-06 12:38:47 +01:00
|
|
|
data = tool->getData();
|
|
|
|
if (not vis.isNull())
|
|
|
|
{
|
|
|
|
vis->SetData(data);
|
|
|
|
}
|
2016-07-02 11:12:12 +02:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
|
2017-10-26 11:54:08 +02:00
|
|
|
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->CalculationGObjects();
|
2015-06-20 20:32:35 +02:00
|
|
|
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
|
|
|
QMap<QString, quint32> list;
|
|
|
|
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
|
|
|
{
|
|
|
|
if (rule == FillComboBox::NoChildren)
|
|
|
|
{
|
2017-11-17 11:28:57 +01:00
|
|
|
if (i.key() != toolId && i.value()->getIdTool() != toolId && i.key() != ch1 && i.key() != ch2)
|
2015-06-20 20:32:35 +02:00
|
|
|
{
|
|
|
|
QSharedPointer<VGObject> obj = i.value();
|
2017-10-26 11:54:08 +02:00
|
|
|
if (obj->getType() == gType)
|
2015-06-20 20:32:35 +02:00
|
|
|
{
|
2016-03-22 16:14:53 +01:00
|
|
|
PrepareList<GObject>(list, i.key());
|
2015-06-20 20:32:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-17 11:28:57 +01:00
|
|
|
if (i.key() != toolId && i.value()->getIdTool() != toolId)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FillList(box, list);
|
2015-06-24 16:30:07 +02:00
|
|
|
|
|
|
|
box->blockSignals(false);
|
2015-06-20 20:32:35 +02:00
|
|
|
}
|