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 dialogdetail.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-08-28 10:55:11 +02:00
|
|
|
#include "dialogdetail.h"
|
|
|
|
|
2015-11-17 11:17:53 +01:00
|
|
|
#include <QBuffer>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
#include <QFlags>
|
|
|
|
#include <QFont>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLatin1String>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QList>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QListWidgetItem>
|
|
|
|
#include <QMessageLogger>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QSize>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QToolButton>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QVector>
|
|
|
|
#include <Qt>
|
|
|
|
#include <QtDebug>
|
|
|
|
#include <new>
|
2013-11-21 13:05:26 +01:00
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/xml/vdomdocument.h"
|
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vgeometry/vgobject.h"
|
|
|
|
#include "../vmisc/vabstractapplication.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "dialogtool.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "vnodedetail.h"
|
|
|
|
|
|
|
|
class QPointF;
|
|
|
|
class QWidget;
|
2014-06-08 20:10:57 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogDetail create dialog
|
|
|
|
* @param data container with data
|
|
|
|
* @param parent parent widget
|
|
|
|
*/
|
2014-07-29 14:19:11 +02:00
|
|
|
DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
2016-07-06 20:49:36 +02:00
|
|
|
:DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true),
|
|
|
|
m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
ui.setupUi(this);
|
2015-12-09 11:40:43 +01:00
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
2016-07-06 20:49:36 +02:00
|
|
|
ui.lineEditName->setClearButtonEnabled(true);
|
2016-08-07 22:41:49 +02:00
|
|
|
ui.lineEditLetter->setClearButtonEnabled(true);
|
2015-12-09 11:40:43 +01:00
|
|
|
#endif
|
|
|
|
|
2016-09-06 16:05:54 +02:00
|
|
|
ui.checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping());
|
|
|
|
|
2016-07-06 20:49:36 +02:00
|
|
|
labelEditNamePoint = ui.labelEditName;
|
2014-06-12 18:56:24 +02:00
|
|
|
ui.labelUnit->setText( VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
|
|
|
ui.labelUnitX->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
|
|
|
ui.labelUnitY->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
2014-03-06 14:28:46 +01:00
|
|
|
|
2015-11-28 21:48:43 +01:00
|
|
|
if(qApp->patternUnit() == Unit::Inch)
|
|
|
|
{
|
|
|
|
ui.doubleSpinBoxSeams->setDecimals(5);
|
|
|
|
}
|
2015-11-29 15:42:39 +01:00
|
|
|
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
|
|
|
|
ui.doubleSpinBoxSeams->setValue(UnitConvertor(1, Unit::Cm, qApp->patternUnit()));
|
2015-01-02 12:08:24 +01:00
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(bOk != nullptr);
|
2014-03-06 14:28:46 +01:00
|
|
|
connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted);
|
2016-01-06 07:05:41 +01:00
|
|
|
QPushButton *bCancel = ui.buttonBox->button(QDialogButtonBox::Cancel);
|
|
|
|
SCASSERT(bCancel != nullptr);
|
|
|
|
connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
|
2014-01-09 13:23:26 +01:00
|
|
|
|
|
|
|
flagName = true;//We have default name of detail.
|
2014-07-14 18:28:41 +02:00
|
|
|
ChangeColor(labelEditNamePoint, okColor);
|
2013-10-25 13:10:45 +02:00
|
|
|
CheckState();
|
2014-01-09 13:23:26 +01:00
|
|
|
|
2013-10-25 13:10:45 +02:00
|
|
|
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged);
|
2014-06-12 18:56:24 +02:00
|
|
|
connect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
|
2013-10-25 13:10:45 +02:00
|
|
|
this, &DialogDetail::BiasXChanged);
|
2014-06-12 18:56:24 +02:00
|
|
|
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
|
2013-10-25 13:10:45 +02:00
|
|
|
this, &DialogDetail::BiasYChanged);
|
2015-03-14 11:39:09 +01:00
|
|
|
connect(ui.doubleSpinBoxSeams, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, &DialogDetail::AlowenceChanged);
|
2013-10-25 13:10:45 +02:00
|
|
|
connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams);
|
|
|
|
connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed);
|
2014-12-17 13:56:14 +01:00
|
|
|
connect(ui.checkBoxReverse, &QCheckBox::clicked, this, &DialogDetail::ClickedReverse);
|
2016-07-06 20:49:36 +02:00
|
|
|
connect(ui.lineEditName, &QLineEdit::textChanged, this, &DialogDetail::NameDetailChanged);
|
2014-01-13 01:48:31 +01:00
|
|
|
|
|
|
|
connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem);
|
2015-11-13 11:31:10 +01:00
|
|
|
connect(ui.toolButtonUp, &QToolButton::clicked, this, &DialogDetail::ScrollUp);
|
|
|
|
connect(ui.toolButtonDown, &QToolButton::clicked, this, &DialogDetail::ScrollDown);
|
2016-06-18 22:14:35 +02:00
|
|
|
|
2016-08-11 22:44:53 +02:00
|
|
|
m_qslMaterials << QApplication::translate("Detail", "Fabric", 0)
|
|
|
|
<< QApplication::translate("Detail", "Lining", 0)
|
|
|
|
<< QApplication::translate("Detail", "Interfacing", 0)
|
|
|
|
<< QApplication::translate("Detail", "Interlining", 0);
|
2016-08-09 18:42:00 +02:00
|
|
|
|
2016-08-11 22:44:53 +02:00
|
|
|
for (int i = 0; i < m_qslMaterials.count(); ++i)
|
|
|
|
{
|
|
|
|
ui.comboBoxMaterial->addItem(m_qslMaterials[i], i);
|
|
|
|
}
|
2016-08-12 01:22:23 +02:00
|
|
|
|
|
|
|
QStringList qsl = qApp->Settings()->GetUserDefinedMaterials();
|
|
|
|
for (int i = 0; i < qsl.count(); ++i)
|
|
|
|
{
|
|
|
|
ui.comboBoxMaterial->addItem(qsl[i], int(MaterialType::mtUserDefined));
|
|
|
|
}
|
|
|
|
|
2016-06-18 22:14:35 +02:00
|
|
|
m_qslPlacements << tr("None") << tr("Cut on fold");
|
|
|
|
ui.comboBoxPlacement->addItems(m_qslPlacements);
|
|
|
|
|
|
|
|
connect(ui.pushButtonAdd, &QPushButton::clicked, this, &DialogDetail::AddUpdate);
|
|
|
|
connect(ui.pushButtonCancel, &QPushButton::clicked, this, &DialogDetail::Cancel);
|
|
|
|
connect(ui.pushButtonRemove, &QPushButton::clicked, this, &DialogDetail::Remove);
|
|
|
|
connect(ui.listWidgetMCP, &QListWidget::itemClicked, this, &DialogDetail::SetEditMode);
|
2016-08-12 01:22:23 +02:00
|
|
|
connect(ui.comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogDetail::MaterialChanged);
|
2016-06-18 22:14:35 +02:00
|
|
|
SetAddMode();
|
|
|
|
|
|
|
|
ui.tabWidget->setCurrentIndex(0);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
|
|
|
* @param id id of objects (points, arcs, splines, spline paths)
|
|
|
|
* @param type type of object
|
|
|
|
*/
|
2014-07-15 16:42:41 +02:00
|
|
|
void DialogDetail::ChosenObject(quint32 id, const SceneObject &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
if (type != SceneObject::Line && type != SceneObject::Detail)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
case (SceneObject::Arc):
|
|
|
|
NewItem(id, Tool::NodeArc, NodeDetail::Contour);
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2014-06-12 09:22:29 +02:00
|
|
|
case (SceneObject::Point):
|
|
|
|
NewItem(id, Tool::NodePoint, NodeDetail::Contour);
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2014-06-12 09:22:29 +02:00
|
|
|
case (SceneObject::Spline):
|
|
|
|
NewItem(id, Tool::NodeSpline, NodeDetail::Contour);
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2014-06-12 09:22:29 +02:00
|
|
|
case (SceneObject::SplinePath):
|
|
|
|
NewItem(id, Tool::NodeSplinePath, NodeDetail::Contour);
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2014-06-12 09:22:29 +02:00
|
|
|
case (SceneObject::Line):
|
|
|
|
case (SceneObject::Detail):
|
2014-09-11 18:52:02 +02:00
|
|
|
case (SceneObject::Unknown):
|
2013-11-04 21:35:15 +01:00
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<tr("Got wrong scene object. Ignore.");
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2015-01-27 17:32:50 +01:00
|
|
|
|
|
|
|
if (ui.listWidget->count() > 0)
|
|
|
|
{
|
|
|
|
EnableObjectGUI(true);
|
|
|
|
}
|
|
|
|
|
2015-11-11 18:38:21 +01:00
|
|
|
ValidObjects(DetailIsValid());
|
2016-07-09 12:57:37 +02:00
|
|
|
// Fix issue #526. Dialog Detail is not on top after selection second object on Mac.
|
|
|
|
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
2013-08-28 10:55:11 +02:00
|
|
|
this->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-08-13 12:20:30 +02:00
|
|
|
void DialogDetail::SaveData()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-01-27 17:32:50 +01:00
|
|
|
detail.Clear();
|
|
|
|
detail = CreateDetail();
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2015-03-14 11:39:09 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::CheckState()
|
|
|
|
{
|
|
|
|
SCASSERT(bOk != nullptr);
|
|
|
|
bOk->setEnabled(flagFormula && flagName && flagError && flagWidth);
|
|
|
|
// In case dialog hasn't apply button
|
|
|
|
if ( bApply != nullptr)
|
|
|
|
{
|
|
|
|
bApply->setEnabled(bOk->isEnabled());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-18 22:14:35 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::UpdateList()
|
|
|
|
{
|
|
|
|
ui.listWidgetMCP->clear();
|
2016-06-21 00:49:22 +02:00
|
|
|
for (int i = 0; i < m_conMCP.count(); ++i)
|
2016-06-18 22:14:35 +02:00
|
|
|
{
|
2016-06-21 19:53:15 +02:00
|
|
|
MaterialCutPlacement mcp = m_conMCP.at(i);
|
2016-06-19 13:46:19 +02:00
|
|
|
QString qsText = tr("Cut %1 of %2%3").arg(mcp.m_iCutNumber);
|
2016-06-18 22:14:35 +02:00
|
|
|
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
|
2016-06-19 13:46:19 +02:00
|
|
|
{
|
2016-06-18 22:14:35 +02:00
|
|
|
qsText = qsText.arg(m_qslMaterials[int(mcp.m_eMaterial)]);
|
2016-06-19 13:46:19 +02:00
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
else
|
2016-06-19 13:46:19 +02:00
|
|
|
{
|
2016-06-18 22:14:35 +02:00
|
|
|
qsText = qsText.arg(mcp.m_qsMaterialUserDef);
|
2016-06-19 13:46:19 +02:00
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
if (mcp.m_ePlacement == PlacementType::ptCutOnFold)
|
2016-06-19 13:46:19 +02:00
|
|
|
{
|
2016-08-09 18:42:00 +02:00
|
|
|
qsText = qsText.arg(QLatin1String(" ") + tr("on Fold"));
|
2016-06-19 13:46:19 +02:00
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
else
|
2016-06-19 13:46:19 +02:00
|
|
|
{
|
2016-06-18 22:14:35 +02:00
|
|
|
qsText = qsText.arg("");
|
2016-06-19 13:46:19 +02:00
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
|
|
|
|
ui.listWidgetMCP->addItem(qsText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::AddUpdate()
|
|
|
|
{
|
|
|
|
MaterialCutPlacement mcp;
|
2016-08-12 01:22:23 +02:00
|
|
|
QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
|
|
|
|
|
2016-08-22 11:16:12 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
|
|
|
int i = ui.comboBoxMaterial->itemData(ui.comboBoxMaterial->currentIndex()).toInt();
|
|
|
|
#else
|
2016-08-11 22:44:53 +02:00
|
|
|
int i = ui.comboBoxMaterial->currentData().toInt();
|
2016-08-22 11:16:12 +02:00
|
|
|
#endif
|
2016-08-21 11:48:51 +02:00
|
|
|
QString qsMat = ui.comboBoxMaterial->currentText();
|
|
|
|
if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i])
|
2016-06-19 13:46:19 +02:00
|
|
|
{
|
2016-08-11 22:44:53 +02:00
|
|
|
mcp.m_eMaterial = MaterialType(i);
|
2016-08-21 10:27:39 +02:00
|
|
|
mcp.m_qsMaterialUserDef.clear();
|
2016-08-11 22:44:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mcp.m_eMaterial = MaterialType::mtUserDefined;
|
2016-08-21 11:48:51 +02:00
|
|
|
mcp.m_qsMaterialUserDef = qsMat;
|
2016-08-12 01:22:23 +02:00
|
|
|
// check if we have new user defined material
|
|
|
|
bool bFound = false;
|
|
|
|
for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++i)
|
|
|
|
{
|
|
|
|
if (mcp.m_qsMaterialUserDef == qslUserMaterials[i])
|
|
|
|
{
|
|
|
|
bFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bFound == false)
|
|
|
|
{
|
|
|
|
qApp->Settings()->AddUserDefinedMaterial(mcp.m_qsMaterialUserDef);
|
|
|
|
qApp->Settings()->sync();
|
|
|
|
ui.comboBoxMaterial->addItem(mcp.m_qsMaterialUserDef, int(MaterialType::mtUserDefined));
|
|
|
|
}
|
2016-06-19 13:46:19 +02:00
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
|
|
|
|
mcp.m_iCutNumber = ui.spinBoxCutNumber->value();
|
|
|
|
mcp.m_ePlacement = PlacementType(ui.comboBoxPlacement->currentIndex());
|
|
|
|
|
|
|
|
if (m_bAddMode == true)
|
|
|
|
{
|
2016-06-21 00:49:22 +02:00
|
|
|
m_conMCP << mcp;
|
2016-06-18 22:14:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int iR = ui.listWidgetMCP->currentRow();
|
|
|
|
SCASSERT(iR >= 0);
|
2016-06-21 00:49:22 +02:00
|
|
|
m_conMCP[iR] = mcp;
|
2016-06-18 22:14:35 +02:00
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
UpdateList();
|
|
|
|
ClearFields();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::Cancel()
|
|
|
|
{
|
|
|
|
ClearFields();
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::Remove()
|
|
|
|
{
|
|
|
|
int iR = ui.listWidgetMCP->currentRow();
|
|
|
|
SCASSERT(iR >= 0);
|
2016-06-21 00:49:22 +02:00
|
|
|
m_conMCP.removeAt(iR);
|
2016-06-18 22:14:35 +02:00
|
|
|
UpdateList();
|
|
|
|
ClearFields();
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
|
2016-07-02 13:43:01 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::NameDetailChanged()
|
|
|
|
{
|
|
|
|
SCASSERT(labelEditNamePoint != nullptr);
|
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
|
|
|
if (edit)
|
|
|
|
{
|
|
|
|
if (edit->text().isEmpty())
|
|
|
|
{
|
|
|
|
flagName = false;
|
|
|
|
ChangeColor(labelEditNamePoint, Qt::red);
|
2016-07-08 00:46:33 +02:00
|
|
|
QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png");
|
|
|
|
ui.tabWidget->setTabIcon(1, icon);
|
2016-07-02 13:43:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagName = true;
|
|
|
|
ChangeColor(labelEditNamePoint, okColor);
|
2016-07-08 00:46:33 +02:00
|
|
|
QIcon icon;
|
|
|
|
ui.tabWidget->setTabIcon(1, icon);
|
2016-07-02 13:43:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2016-08-12 01:22:23 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::MaterialChanged()
|
|
|
|
{
|
|
|
|
ui.pushButtonAdd->setEnabled(ui.comboBoxMaterial->currentText().isEmpty() == false);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief NewItem add new object (point, arc, spline or spline path) to list
|
|
|
|
* @param id id of object
|
|
|
|
* @param typeTool type of tool
|
|
|
|
* @param typeNode type of node in detail
|
|
|
|
* @param mx offset respect to x
|
|
|
|
* @param my offset respect to y
|
2014-12-17 13:56:14 +01:00
|
|
|
* @param reverse reverse list of points
|
2014-06-02 16:28:02 +02:00
|
|
|
*/
|
2014-06-12 09:22:29 +02:00
|
|
|
void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode,
|
2014-12-17 13:56:14 +01:00
|
|
|
qreal mx, qreal my, bool reverse)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-07-06 12:34:05 +02:00
|
|
|
SCASSERT(id > NULL_ID);
|
2013-08-28 10:55:11 +02:00
|
|
|
QString name;
|
2013-11-04 21:35:15 +01:00
|
|
|
switch (typeTool)
|
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
case (Tool::NodePoint):
|
|
|
|
case (Tool::NodeArc):
|
|
|
|
case (Tool::NodeSpline):
|
|
|
|
case (Tool::NodeSplinePath):
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-06-03 13:16:46 +02:00
|
|
|
const QSharedPointer<VGObject> obj = data->GeometricObject<VGObject>(id);
|
|
|
|
name = obj->name();
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Got wrong tools. Ignore.";
|
2015-06-03 13:16:46 +02:00
|
|
|
return;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-10 09:07:40 +01:00
|
|
|
bool canAddNewPoint = false;
|
|
|
|
|
|
|
|
if(ui.listWidget->count() == 0)
|
2014-12-17 13:56:14 +01:00
|
|
|
{
|
2015-11-10 09:07:40 +01:00
|
|
|
canAddNewPoint = true;
|
2015-11-13 14:23:56 +01:00
|
|
|
ui.toolButtonUp->setEnabled(false);
|
|
|
|
ui.toolButtonDown->setEnabled(false);
|
2014-12-17 13:56:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-06 12:34:05 +02:00
|
|
|
if(RowId(ui.listWidget->count()-1) != id)
|
2015-11-10 09:07:40 +01:00
|
|
|
{
|
|
|
|
canAddNewPoint = true;
|
|
|
|
}
|
2015-11-13 14:23:56 +01:00
|
|
|
ui.toolButtonUp->setEnabled(true);
|
|
|
|
ui.toolButtonDown->setEnabled(true);
|
2014-12-17 13:56:14 +01:00
|
|
|
}
|
|
|
|
|
2015-11-10 09:07:40 +01:00
|
|
|
if(canAddNewPoint)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(name);
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
VNodeDetail node(id, typeTool, typeNode, mx, my, reverse);
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
|
|
|
ui.listWidget->addItem(item);
|
|
|
|
ui.listWidget->setCurrentRow(ui.listWidget->count()-1);
|
|
|
|
|
|
|
|
ui.doubleSpinBoxBiasX->blockSignals(true);
|
|
|
|
ui.doubleSpinBoxBiasY->blockSignals(true);
|
|
|
|
|
|
|
|
ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx()));
|
|
|
|
ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy()));
|
|
|
|
if (node.getTypeTool() == Tool::NodePoint)
|
|
|
|
{
|
|
|
|
ui.checkBoxReverse->setChecked(false);
|
|
|
|
ui.checkBoxReverse->setEnabled(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.checkBoxReverse->setEnabled(true);
|
|
|
|
ui.checkBoxReverse->setChecked(node.getReverse());
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.doubleSpinBoxBiasX->blockSignals(false);
|
|
|
|
ui.doubleSpinBoxBiasY->blockSignals(false);
|
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2015-01-27 17:32:50 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VDetail DialogDetail::CreateDetail() const
|
|
|
|
{
|
|
|
|
VDetail detail;
|
|
|
|
for (qint32 i = 0; i < ui.listWidget->count(); ++i)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = ui.listWidget->item(i);
|
|
|
|
detail.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
|
|
|
|
}
|
|
|
|
detail.setWidth(ui.doubleSpinBoxSeams->value());
|
2016-07-06 20:49:36 +02:00
|
|
|
detail.setName(ui.lineEditName->text());
|
2015-01-27 17:32:50 +01:00
|
|
|
detail.setSeamAllowance(supplement);
|
|
|
|
detail.setClosed(closed);
|
2016-09-06 12:24:52 +02:00
|
|
|
detail.setForbidFlipping(ui.checkBoxForbidFlipping->isChecked());
|
2016-06-18 22:14:35 +02:00
|
|
|
|
|
|
|
detail.GetPatternPieceData().SetLetter(ui.lineEditLetter->text());
|
|
|
|
|
2016-06-21 00:49:22 +02:00
|
|
|
for (int i = 0; i < m_conMCP.count(); ++i)
|
|
|
|
{
|
|
|
|
detail.GetPatternPieceData().Append(m_conMCP[i]);
|
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
|
2016-07-06 20:49:36 +02:00
|
|
|
detail.GetPatternPieceData().SetPos(m_oldData.GetPos());
|
|
|
|
detail.GetPatternPieceData().SetLabelWidth(m_oldData.GetLabelWidth());
|
|
|
|
detail.GetPatternPieceData().SetLabelHeight(m_oldData.GetLabelHeight());
|
|
|
|
detail.GetPatternPieceData().SetFontSize(m_oldData.GetFontSize());
|
|
|
|
detail.GetPatternPieceData().SetRotation(m_oldData.GetRotation());
|
2016-07-06 21:56:52 +02:00
|
|
|
detail.GetPatternPieceData().SetVisible(ui.checkBoxDetail->isChecked());
|
|
|
|
|
2016-07-06 20:49:36 +02:00
|
|
|
detail.GetPatternInfo() = m_oldGeom;
|
2016-07-06 21:56:52 +02:00
|
|
|
detail.GetPatternInfo().SetVisible(ui.checkBoxPattern->isChecked());
|
2016-06-26 14:21:06 +02:00
|
|
|
|
2015-01-27 17:32:50 +01:00
|
|
|
return detail;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::ValidObjects(bool value)
|
|
|
|
{
|
|
|
|
flagError = value;
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::EnableObjectGUI(bool value)
|
|
|
|
{
|
|
|
|
ui.toolButtonDelete->setEnabled(value);
|
|
|
|
ui.doubleSpinBoxBiasX->setEnabled(value);
|
|
|
|
ui.doubleSpinBoxBiasY->setEnabled(value);
|
|
|
|
|
|
|
|
if (value == false)
|
|
|
|
{
|
|
|
|
ui.checkBoxReverse->setEnabled(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-06 12:34:05 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogDetail::RowId(int i) const
|
|
|
|
{
|
|
|
|
const QListWidgetItem *rowItem = ui.listWidget->item(i);
|
|
|
|
SCASSERT(rowItem != nullptr);
|
|
|
|
const VNodeDetail rowNode = qvariant_cast<VNodeDetail>(rowItem->data(Qt::UserRole));
|
|
|
|
return rowNode.getId();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief setDetails set detail
|
|
|
|
* @param value detail
|
|
|
|
*/
|
2015-01-27 17:32:50 +01:00
|
|
|
void DialogDetail::setDetail(const VDetail &value)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-01-27 17:32:50 +01:00
|
|
|
detail = value;
|
2013-08-28 10:55:11 +02:00
|
|
|
ui.listWidget->clear();
|
2015-01-27 17:32:50 +01:00
|
|
|
for (int i = 0; i < detail.CountNode(); ++i)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-11-05 14:01:33 +01:00
|
|
|
const VNodeDetail &node = detail.at(i);
|
2015-10-28 15:22:36 +01:00
|
|
|
NewItem(node.getId(), node.getTypeTool(), node.getTypeNode(), node.getMx(),
|
|
|
|
node.getMy(), node.getReverse());
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2016-07-06 20:49:36 +02:00
|
|
|
ui.lineEditName->setText(detail.getName());
|
2015-01-27 17:32:50 +01:00
|
|
|
ui.checkBoxSeams->setChecked(detail.getSeamAllowance());
|
|
|
|
ui.checkBoxClosed->setChecked(detail.getClosed());
|
2016-09-06 12:24:52 +02:00
|
|
|
ui.checkBoxForbidFlipping->setChecked(detail.getForbidFlipping());
|
2015-01-27 17:32:50 +01:00
|
|
|
ClickedClosed(detail.getClosed());
|
|
|
|
ClickedSeams(detail.getSeamAllowance());
|
|
|
|
ui.doubleSpinBoxSeams->setValue(detail.getWidth());
|
2013-10-25 13:10:45 +02:00
|
|
|
ui.listWidget->setCurrentRow(0);
|
2013-08-28 10:55:11 +02:00
|
|
|
ui.listWidget->setFocus(Qt::OtherFocusReason);
|
2014-01-13 01:48:31 +01:00
|
|
|
ui.toolButtonDelete->setEnabled(true);
|
2016-06-18 22:14:35 +02:00
|
|
|
|
|
|
|
ui.lineEditLetter->setText(detail.GetPatternPieceData().GetLetter());
|
2016-07-06 21:56:52 +02:00
|
|
|
ui.checkBoxDetail->setChecked(detail.GetPatternPieceData().IsVisible());
|
|
|
|
ui.checkBoxPattern->setChecked(detail.GetPatternInfo().IsVisible());
|
2016-06-21 00:49:22 +02:00
|
|
|
|
|
|
|
m_conMCP.clear();
|
|
|
|
for (int i = 0; i < detail.GetPatternPieceData().GetMCPCount(); ++i)
|
|
|
|
{
|
|
|
|
m_conMCP << detail.GetPatternPieceData().GetMCP(i);
|
|
|
|
}
|
|
|
|
|
2016-06-18 22:14:35 +02:00
|
|
|
UpdateList();
|
2016-07-06 20:49:36 +02:00
|
|
|
m_oldData = detail.GetPatternPieceData();
|
|
|
|
m_oldGeom = detail.GetPatternInfo();
|
2016-06-18 22:14:35 +02:00
|
|
|
|
2015-12-26 14:18:58 +01:00
|
|
|
ValidObjects(DetailIsValid());
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief BiasXChanged changed value of offset for object respect to x
|
|
|
|
* @param d value in mm
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogDetail::BiasXChanged(qreal d)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
qint32 row = ui.listWidget->currentRow();
|
|
|
|
QListWidgetItem *item = ui.listWidget->item( row );
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(item != nullptr);
|
2013-10-25 13:10:45 +02:00
|
|
|
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
|
2014-03-19 19:27:11 +01:00
|
|
|
node.setMx(qApp->toPixel(d));
|
2013-10-25 13:10:45 +02:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief BiasYChanged changed value of offset for object respect to y
|
|
|
|
* @param d value in mm
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogDetail::BiasYChanged(qreal d)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
qint32 row = ui.listWidget->currentRow();
|
|
|
|
QListWidgetItem *item = ui.listWidget->item( row );
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(item != nullptr);
|
2013-10-25 13:10:45 +02:00
|
|
|
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
|
2014-03-19 19:27:11 +01:00
|
|
|
node.setMy(qApp->toPixel(d));
|
2013-10-25 13:10:45 +02:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
|
|
|
}
|
|
|
|
|
2015-03-14 11:39:09 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::AlowenceChanged(qreal d)
|
|
|
|
{
|
|
|
|
if (ui.doubleSpinBoxSeams->isEnabled())
|
|
|
|
{
|
|
|
|
if (d <= 0)
|
|
|
|
{
|
|
|
|
flagWidth = false;
|
|
|
|
ChangeColor(ui.labelEditWidth, errorColor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagWidth = true;
|
|
|
|
ChangeColor(ui.labelEditWidth, okColor);
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ClickedSeams save supplement of seams for detail
|
|
|
|
* @param checked 1 - need supplement, 0 - don't need supplement
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogDetail::ClickedSeams(bool checked)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
supplement = checked;
|
|
|
|
ui.checkBoxClosed->setEnabled(checked);
|
2014-06-12 18:56:24 +02:00
|
|
|
ui.doubleSpinBoxSeams->setEnabled(checked);
|
2015-03-14 11:39:09 +01:00
|
|
|
|
|
|
|
if (checked && ui.doubleSpinBoxSeams->value() <= 0)
|
|
|
|
{
|
|
|
|
flagWidth = false;
|
|
|
|
ChangeColor(ui.labelEditWidth, errorColor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagWidth = true;
|
|
|
|
ChangeColor(ui.labelEditWidth, okColor);
|
|
|
|
}
|
|
|
|
CheckState();
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ClickedClosed save closed equdistant or not
|
|
|
|
* @param checked 1 - closed, 0 - don't closed
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogDetail::ClickedClosed(bool checked)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
closed = checked;
|
|
|
|
}
|
|
|
|
|
2014-12-17 13:56:14 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::ClickedReverse(bool checked)
|
|
|
|
{
|
|
|
|
qint32 row = ui.listWidget->currentRow();
|
|
|
|
QListWidgetItem *item = ui.listWidget->item( row );
|
|
|
|
SCASSERT(item != nullptr);
|
|
|
|
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
|
|
|
|
node.setReverse(checked);
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
2016-02-10 20:39:20 +01:00
|
|
|
ValidObjects(DetailIsValid());
|
2014-12-17 13:56:14 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ObjectChanged changed new object (point, arc, spline or spline path) form list
|
|
|
|
* @param row number of row
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogDetail::ObjectChanged(int row)
|
|
|
|
{
|
2015-02-25 19:21:44 +01:00
|
|
|
if (ui.listWidget->count() == 0 || row == -1 || row >= ui.listWidget->count())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-12-17 13:56:14 +01:00
|
|
|
const QListWidgetItem *item = ui.listWidget->item( row );
|
2015-02-25 19:21:44 +01:00
|
|
|
SCASSERT(item != nullptr);
|
2014-12-17 13:56:14 +01:00
|
|
|
const VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
|
2014-06-12 18:56:24 +02:00
|
|
|
ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx()));
|
|
|
|
ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy()));
|
2014-12-17 13:56:14 +01:00
|
|
|
if (node.getTypeTool() == Tool::NodePoint)
|
|
|
|
{
|
|
|
|
ui.checkBoxReverse->setChecked(false);
|
|
|
|
ui.checkBoxReverse->setEnabled(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.checkBoxReverse->setEnabled(true);
|
|
|
|
ui.checkBoxReverse->setChecked(node.getReverse());
|
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2014-01-13 01:48:31 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DeleteItem delete item from list
|
|
|
|
*/
|
2014-01-13 01:48:31 +01:00
|
|
|
void DialogDetail::DeleteItem()
|
|
|
|
{
|
2015-01-27 17:32:50 +01:00
|
|
|
if (ui.listWidget->count() == 1)
|
|
|
|
{
|
|
|
|
EnableObjectGUI(false);
|
|
|
|
}
|
|
|
|
|
2015-11-11 18:38:21 +01:00
|
|
|
delete ui.listWidget->item(ui.listWidget->currentRow());
|
|
|
|
ValidObjects(DetailIsValid());
|
2015-11-13 14:23:56 +01:00
|
|
|
|
|
|
|
if(ui.listWidget->count() < 2)
|
|
|
|
{
|
|
|
|
ui.toolButtonUp->setEnabled(false);
|
|
|
|
ui.toolButtonDown->setEnabled(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.toolButtonUp->setEnabled(true);
|
|
|
|
ui.toolButtonDown->setEnabled(true);
|
|
|
|
}
|
2014-01-13 01:48:31 +01:00
|
|
|
}
|
2015-11-10 10:58:33 +01:00
|
|
|
|
2015-11-13 11:31:10 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::ScrollUp()
|
|
|
|
{
|
|
|
|
if (ui.listWidget->count() > 1)
|
|
|
|
{
|
2015-11-13 13:04:51 +01:00
|
|
|
QListWidgetItem *item = ui.listWidget->takeItem(0);
|
|
|
|
ui.listWidget->addItem(item);
|
2016-02-10 20:39:20 +01:00
|
|
|
ValidObjects(DetailIsValid());
|
2015-11-13 11:31:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::ScrollDown()
|
|
|
|
{
|
|
|
|
if (ui.listWidget->count() > 1)
|
|
|
|
{
|
2015-11-13 13:04:51 +01:00
|
|
|
QListWidgetItem *item = ui.listWidget->takeItem(ui.listWidget->count()-1);
|
|
|
|
ui.listWidget->insertItem(0, item);
|
2016-02-10 20:39:20 +01:00
|
|
|
ValidObjects(DetailIsValid());
|
2015-11-13 11:31:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-10 10:58:33 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-11 20:46:36 +01:00
|
|
|
bool DialogDetail::DetailIsValid() const
|
2015-11-10 10:58:33 +01:00
|
|
|
{
|
2015-11-16 16:54:45 +01:00
|
|
|
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
2015-11-16 16:34:16 +01:00
|
|
|
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
|
|
|
|
|
2015-11-16 16:54:45 +01:00
|
|
|
const QPixmap pixmap = icon.pixmap(QSize(16, 16));
|
2015-11-16 16:34:16 +01:00
|
|
|
QByteArray byteArray;
|
|
|
|
QBuffer buffer(&byteArray);
|
|
|
|
pixmap.save(&buffer, "PNG");
|
2016-07-20 10:39:15 +02:00
|
|
|
QString url = QString("<img src=\"data:image/png;base64,") + byteArray.toBase64() + QLatin1String("\"/> ");
|
2015-11-16 16:34:16 +01:00
|
|
|
|
2016-02-10 20:39:20 +01:00
|
|
|
if(CreateDetail().ContourPoints(data).count() < 3)
|
2015-11-10 10:58:33 +01:00
|
|
|
{
|
2015-11-22 14:58:31 +01:00
|
|
|
url += tr("You need more points!");
|
2015-11-16 16:34:16 +01:00
|
|
|
ui.helpLabel->setText(url);
|
2015-11-10 10:58:33 +01:00
|
|
|
return false;
|
|
|
|
}
|
2015-11-11 18:38:21 +01:00
|
|
|
else
|
2015-11-10 10:58:33 +01:00
|
|
|
{
|
2015-11-22 00:52:18 +01:00
|
|
|
if(not DetailIsClockwise())
|
|
|
|
{
|
2015-11-22 14:58:31 +01:00
|
|
|
url += tr("You have to choose points in a clockwise direction!");
|
2015-11-22 00:52:18 +01:00
|
|
|
ui.helpLabel->setText(url);
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-10 10:58:33 +01:00
|
|
|
if (FirstPointEqualLast())
|
|
|
|
{
|
2015-12-26 14:18:58 +01:00
|
|
|
url += tr("First point cannot be equal to the last point!");
|
2015-11-16 16:34:16 +01:00
|
|
|
ui.helpLabel->setText(url);
|
2015-11-10 10:58:33 +01:00
|
|
|
return false;
|
|
|
|
}
|
2015-11-11 18:38:21 +01:00
|
|
|
else
|
|
|
|
{
|
2015-11-11 20:46:36 +01:00
|
|
|
for (int i=0, sz = ui.listWidget->count()-1; i<sz; ++i)
|
2015-11-11 18:38:21 +01:00
|
|
|
{
|
2016-07-06 12:34:05 +02:00
|
|
|
if (RowId(i) == RowId(i+1))
|
2015-11-11 18:38:21 +01:00
|
|
|
{
|
2015-11-22 14:58:31 +01:00
|
|
|
url += tr("You have double points!");
|
2015-11-16 16:34:16 +01:00
|
|
|
ui.helpLabel->setText(url);
|
2015-11-11 18:38:21 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-16 16:34:16 +01:00
|
|
|
}
|
2015-11-16 16:54:45 +01:00
|
|
|
ui.helpLabel->setText(tr("Ready!"));
|
2015-11-10 10:58:33 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-11 20:46:36 +01:00
|
|
|
bool DialogDetail::FirstPointEqualLast() const
|
2015-11-10 10:58:33 +01:00
|
|
|
{
|
2015-11-11 20:46:36 +01:00
|
|
|
if (ui.listWidget->count() > 1)
|
2015-11-10 10:58:33 +01:00
|
|
|
{
|
2016-07-06 12:34:05 +02:00
|
|
|
if (RowId(0) == RowId(ui.listWidget->count()-1))
|
2015-11-11 20:46:36 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-10 10:58:33 +01:00
|
|
|
}
|
2015-11-11 20:46:36 +01:00
|
|
|
return false;
|
2015-11-10 10:58:33 +01:00
|
|
|
}
|
2015-11-22 00:52:18 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogDetail::DetailIsClockwise() const
|
|
|
|
{
|
2016-02-10 20:39:20 +01:00
|
|
|
const QVector<QPointF> points = CreateDetail().ContourPoints(data);
|
|
|
|
|
|
|
|
if(points.count() < 3)
|
2015-11-22 00:52:18 +01:00
|
|
|
{
|
2015-11-22 15:58:58 +01:00
|
|
|
return false;
|
2015-11-22 00:52:18 +01:00
|
|
|
}
|
|
|
|
|
2015-11-22 14:58:31 +01:00
|
|
|
const qreal res = VDetail::SumTrapezoids(points);
|
2015-11-22 00:52:18 +01:00
|
|
|
if (res < 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::ClearFields()
|
|
|
|
{
|
|
|
|
ui.comboBoxMaterial->setCurrentIndex(0);
|
|
|
|
ui.spinBoxCutNumber->setValue(0);
|
|
|
|
ui.comboBoxPlacement->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::SetAddMode()
|
|
|
|
{
|
|
|
|
ui.pushButtonAdd->setText(tr("Add"));
|
|
|
|
ui.pushButtonCancel->hide();
|
|
|
|
ui.pushButtonRemove->hide();
|
|
|
|
ui.listWidgetMCP->setCurrentRow(-1);
|
|
|
|
m_bAddMode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::SetEditMode()
|
|
|
|
{
|
|
|
|
int iR = ui.listWidgetMCP->currentRow();
|
|
|
|
// this method can be called by clicking on item or by update. In the latter case there is nothing else to do!
|
2016-06-26 14:21:06 +02:00
|
|
|
if (iR < 0 || iR >= m_conMCP.count())
|
2016-06-19 13:46:19 +02:00
|
|
|
{
|
2016-06-18 22:14:35 +02:00
|
|
|
return;
|
2016-06-19 13:46:19 +02:00
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
|
|
|
|
ui.pushButtonAdd->setText(tr("Update"));
|
|
|
|
ui.pushButtonCancel->show();
|
|
|
|
ui.pushButtonRemove->show();
|
|
|
|
|
2016-06-26 14:21:06 +02:00
|
|
|
MaterialCutPlacement mcp = m_conMCP.at(iR);
|
2016-08-11 22:44:53 +02:00
|
|
|
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
|
|
|
|
{
|
2016-08-12 01:22:23 +02:00
|
|
|
int iRow = qApp->Settings()->GetUserDefinedMaterials().indexOf(mcp.m_qsMaterialUserDef);
|
|
|
|
if (iRow >= 0)
|
|
|
|
{
|
|
|
|
ui.comboBoxMaterial->setCurrentIndex(iRow + m_qslMaterials.count());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
|
|
|
|
}
|
2016-08-11 22:44:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-12 01:22:23 +02:00
|
|
|
ui.comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial));
|
2016-08-11 22:44:53 +02:00
|
|
|
}
|
2016-06-18 22:14:35 +02:00
|
|
|
ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber);
|
|
|
|
ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));
|
|
|
|
|
|
|
|
m_bAddMode = false;
|
|
|
|
}
|