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>
|
2013-11-21 13:05:26 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
2015-06-18 19:23:24 +02:00
|
|
|
#include "../../../vgeometry/varc.h"
|
|
|
|
#include "../../../vgeometry/vpointf.h"
|
|
|
|
#include "../../../vgeometry/vsplinepath.h"
|
|
|
|
#include "../../../vpatterndb/vcontainer.h"
|
|
|
|
#include "../../../ifc/xml/vdomdocument.h"
|
2016-06-18 22:14:35 +02:00
|
|
|
#include "vpatternpiecedata.h"
|
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)
|
2015-03-14 11:39:09 +01:00
|
|
|
:DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true)
|
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)
|
|
|
|
ui.lineEditNameDetail->setClearButtonEnabled(true);
|
|
|
|
#endif
|
|
|
|
|
2013-10-25 13:10:45 +02:00
|
|
|
labelEditNamePoint = ui.labelEditNameDetail;
|
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);
|
2013-10-25 13:10:45 +02:00
|
|
|
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged);
|
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
|
|
|
|
|
|
|
m_qslMaterials << tr("Fabric") << tr("Lining") << tr("Interfacing") << tr("Interlining");
|
|
|
|
ui.comboBoxMaterial->addItems(m_qslMaterials);
|
|
|
|
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);
|
|
|
|
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());
|
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();
|
|
|
|
for (int i = 0; i < detail.GetPatternPieceData().GetMCPCount(); ++i)
|
|
|
|
{
|
|
|
|
MaterialCutPlacement mcp = detail.GetPatternPieceData().GetMCP(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-06-18 22:14:35 +02:00
|
|
|
qsText = qsText.arg(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;
|
|
|
|
mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText();
|
|
|
|
mcp.m_eMaterial = MaterialType::mtUserDefined;
|
|
|
|
for (int i = 0; i < m_qslMaterials.count(); ++i)
|
2016-06-19 13:46:19 +02:00
|
|
|
{
|
2016-06-18 22:14:35 +02:00
|
|
|
if (mcp.m_qsMaterialUserDef == m_qslMaterials[i])
|
2016-06-19 13:46:19 +02:00
|
|
|
{
|
2016-06-18 22:14:35 +02:00
|
|
|
mcp.m_eMaterial = MaterialType(i);
|
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)
|
|
|
|
{
|
|
|
|
detail.GetPatternPieceData().Append(mcp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int iR = ui.listWidgetMCP->currentRow();
|
|
|
|
SCASSERT(iR >= 0);
|
|
|
|
detail.GetPatternPieceData().Set(iR, mcp);
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
UpdateList();
|
|
|
|
ClearFields();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::Cancel()
|
|
|
|
{
|
|
|
|
ClearFields();
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogDetail::Remove()
|
|
|
|
{
|
|
|
|
int iR = ui.listWidgetMCP->currentRow();
|
|
|
|
SCASSERT(iR >= 0);
|
|
|
|
detail.GetPatternPieceData().RemoveMCP(iR);
|
|
|
|
UpdateList();
|
|
|
|
ClearFields();
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
|
{
|
2015-11-11 20:46:36 +01:00
|
|
|
const QString previousItemName = ui.listWidget->item(ui.listWidget->count()-1)->text();
|
2015-11-11 18:38:21 +01:00
|
|
|
if(QString::compare(previousItemName, name) != 0)
|
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());
|
|
|
|
detail.setName(ui.lineEditNameDetail->text());
|
|
|
|
detail.setSeamAllowance(supplement);
|
|
|
|
detail.setClosed(closed);
|
2016-06-18 22:14:35 +02:00
|
|
|
|
|
|
|
detail.GetPatternPieceData().SetLetter(ui.lineEditLetter->text());
|
|
|
|
detail.GetPatternPieceData().SetName(ui.lineEditName->text());
|
|
|
|
|
|
|
|
qDebug() << "DD" << detail.GetPatternPieceData().GetLetter()
|
|
|
|
<< detail.GetPatternPieceData().GetName()
|
|
|
|
<< detail.GetPatternPieceData().GetMCPCount();
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2015-01-27 17:32:50 +01:00
|
|
|
ui.lineEditNameDetail->setText(detail.getName());
|
|
|
|
ui.checkBoxSeams->setChecked(detail.getSeamAllowance());
|
|
|
|
ui.checkBoxClosed->setChecked(detail.getClosed());
|
|
|
|
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());
|
|
|
|
ui.lineEditName->setText(detail.GetPatternPieceData().GetName());
|
|
|
|
UpdateList();
|
|
|
|
|
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");
|
2015-11-22 15:47:50 +01:00
|
|
|
QString url = QString("<img src=\"data:image/png;base64,") + byteArray.toBase64() + QLatin1Literal("\"/> ");
|
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
|
|
|
{
|
2015-11-11 20:46:36 +01:00
|
|
|
const QString previousRow = ui.listWidget->item(i)->text();
|
|
|
|
const QString nextRow = ui.listWidget->item(i+1)->text();
|
2015-11-11 18:38:21 +01:00
|
|
|
|
|
|
|
if (QString::compare(previousRow, nextRow) == 0)
|
|
|
|
{
|
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
|
|
|
{
|
2015-11-11 20:46:36 +01:00
|
|
|
const QString firstDetailPoint = ui.listWidget->item(0)->text();
|
|
|
|
const QString lastDetailPoint = ui.listWidget->item(ui.listWidget->count()-1)->text();
|
|
|
|
|
|
|
|
if (QString::compare(firstDetailPoint, lastDetailPoint) == 0)
|
|
|
|
{
|
|
|
|
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!
|
|
|
|
if (iR < 0 || iR >= detail.GetPatternPieceData().GetMCPCount())
|
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();
|
|
|
|
|
|
|
|
MaterialCutPlacement mcp = detail.GetPatternPieceData().GetMCP(iR);
|
|
|
|
ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
|
|
|
|
ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber);
|
|
|
|
ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));
|
|
|
|
|
|
|
|
m_bAddMode = false;
|
|
|
|
}
|