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"
|
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);
|
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-01-02 12:08:24 +01:00
|
|
|
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
|
2015-06-12 10:55:44 +02:00
|
|
|
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);
|
|
|
|
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(bCansel != nullptr);
|
2014-03-06 14:28:46 +01:00
|
|
|
connect(bCansel, &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);
|
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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
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);
|
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));
|
|
|
|
}
|
|
|
|
|
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);
|
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);
|
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 14:58:31 +01:00
|
|
|
QString url = QString("<img src=\"data:image/png;base64,") + byteArray.toBase64() + "\"/>" + QString(" ");
|
2015-11-16 16:34:16 +01:00
|
|
|
|
2015-11-10 10:58:33 +01:00
|
|
|
if (ui.listWidget->count() < 3)
|
|
|
|
{
|
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-11-22 14:58:31 +01:00
|
|
|
url += tr("First point can not equal 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
|
|
|
|
{
|
|
|
|
if(ui.listWidget->count() < 3)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2015-11-22 14:58:31 +01:00
|
|
|
VDetail detail;
|
2015-11-22 00:52:18 +01:00
|
|
|
for (qint32 i = 0; i < ui.listWidget->count(); ++i)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = ui.listWidget->item(i);
|
|
|
|
detail.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
|
|
|
|
}
|
2015-11-22 14:58:31 +01:00
|
|
|
const QVector<QPointF> points = detail.ContourPoints(data);
|
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;
|
|
|
|
}
|