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.
|
|
|
|
** Copyright (C) 2013 Valentina project
|
|
|
|
** <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"
|
|
|
|
|
2013-11-21 13:05:26 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
2014-06-08 20:10:57 +02:00
|
|
|
#include "../../geometry/varc.h"
|
|
|
|
#include "../../geometry/vpointf.h"
|
|
|
|
#include "../../geometry/vsplinepath.h"
|
|
|
|
#include "../../container/vcontainer.h"
|
2014-06-12 18:56:24 +02:00
|
|
|
#include "../../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
|
|
|
|
*/
|
2013-12-21 12:36:51 +01:00
|
|
|
DialogDetail::DialogDetail(const VContainer *data, QWidget *parent)
|
|
|
|
:DialogTool(data, parent), ui(), details(VDetail()), supplement(true), closed(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
|
|
|
|
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 12:21:46 +02:00
|
|
|
ChangeColor(labelEditNamePoint, QColor(76, 76, 76));
|
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);
|
|
|
|
connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams);
|
|
|
|
connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed);
|
|
|
|
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged);
|
2014-01-13 01:48:31 +01:00
|
|
|
|
|
|
|
connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem);
|
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-06-12 09:22:29 +02:00
|
|
|
void DialogDetail::ChoosedObject(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):
|
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
|
|
|
}
|
2014-01-13 01:48:31 +01:00
|
|
|
ui.toolButtonDelete->setEnabled(true);
|
2013-08-28 10:55:11 +02:00
|
|
|
this->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogAccepted save data and emit signal about closed dialog.
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogDetail::DialogAccepted()
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
details.Clear();
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < ui.listWidget->count(); ++i)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
QListWidgetItem *item = ui.listWidget->item(i);
|
|
|
|
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
|
|
|
|
}
|
2014-06-12 18:56:24 +02:00
|
|
|
details.setWidth(ui.doubleSpinBoxSeams->value());
|
2013-08-28 10:55:11 +02:00
|
|
|
details.setName(ui.lineEditNameDetail->text());
|
2014-01-21 14:51:41 +01:00
|
|
|
details.setSeamAllowance(supplement);
|
2013-10-25 13:10:45 +02:00
|
|
|
details.setClosed(closed);
|
2013-10-07 13:11:56 +02:00
|
|
|
emit ToolTip("");
|
2013-10-09 18:24:28 +02:00
|
|
|
emit DialogClosed(QDialog::Accepted);
|
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 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-06-12 09:22:29 +02:00
|
|
|
void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode,
|
2014-05-01 13:33:40 +02:00
|
|
|
qreal mx, qreal my)
|
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):
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
|
|
|
name = point->name();
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2014-06-12 09:22:29 +02:00
|
|
|
case (Tool::NodeArc):
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VArc *arc = data->GeometricObject<const VArc *>(id);
|
|
|
|
name = arc->name();
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2014-06-12 09:22:29 +02:00
|
|
|
case (Tool::NodeSpline):
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSpline *spl = data->GeometricObject<const VSpline *>(id);
|
|
|
|
name = spl->name();
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2014-06-12 09:22:29 +02:00
|
|
|
case (Tool::NodeSplinePath):
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(id);
|
|
|
|
name = splPath->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.";
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(name);
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
2013-12-21 12:36:51 +01:00
|
|
|
VNodeDetail node(id, typeTool, typeNode, mx, my);
|
2013-08-28 10:55:11 +02:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
|
|
|
ui.listWidget->addItem(item);
|
2014-01-02 21:27:53 +01:00
|
|
|
ui.listWidget->setCurrentRow(ui.listWidget->count()-1);
|
2014-06-12 18:56:24 +02:00
|
|
|
disconnect(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
|
|
|
disconnect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
|
2013-10-25 13:10:45 +02:00
|
|
|
this, &DialogDetail::BiasYChanged);
|
2014-06-12 18:56:24 +02:00
|
|
|
ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx()));
|
|
|
|
ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy()));
|
|
|
|
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);
|
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 setDetails set detail
|
|
|
|
* @param value detail
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogDetail::setDetails(const VDetail &value)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
details = value;
|
|
|
|
ui.listWidget->clear();
|
2013-11-07 15:40:39 +01:00
|
|
|
for (ptrdiff_t i = 0; i < details.CountNode(); ++i)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-06-09 21:11:33 +02:00
|
|
|
NewItem(details.at(i).getId(), details.at(i).getTypeTool(), details.at(i).getTypeNode(), details.at(i).getMx(),
|
|
|
|
details.at(i).getMy());
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
ui.lineEditNameDetail->setText(details.getName());
|
2014-01-21 14:51:41 +01:00
|
|
|
ui.checkBoxSeams->setChecked(details.getSeamAllowance());
|
2013-10-25 13:10:45 +02:00
|
|
|
ui.checkBoxClosed->setChecked(details.getClosed());
|
2014-01-12 20:53:15 +01:00
|
|
|
ClickedClosed(details.getClosed());
|
2014-01-21 14:51:41 +01:00
|
|
|
ClickedSeams(details.getSeamAllowance());
|
2014-06-12 18:56:24 +02:00
|
|
|
ui.doubleSpinBoxSeams->setValue(details.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));
|
|
|
|
}
|
|
|
|
|
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);
|
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-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)
|
|
|
|
{
|
|
|
|
if (ui.listWidget->count() == 0)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
QListWidgetItem *item = ui.listWidget->item( row );
|
|
|
|
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()));
|
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()
|
|
|
|
{
|
|
|
|
qint32 row = ui.listWidget->currentRow();
|
|
|
|
delete ui.listWidget->item( row );
|
|
|
|
}
|