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
|
2013-11-15 13:41:26 +01:00
|
|
|
** @author Roman Telezhinsky <dismine@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 <QPushButton>
|
|
|
|
#include <QDebug>
|
|
|
|
|
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-03-06 14:28:46 +01:00
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
|
2014-03-06 14:28:46 +01:00
|
|
|
Q_CHECK_PTR(bOk);
|
|
|
|
connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted);
|
|
|
|
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
|
|
|
|
Q_CHECK_PTR(bCansel);
|
|
|
|
connect(bCansel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
|
2014-01-09 13:23:26 +01:00
|
|
|
|
|
|
|
flagName = true;//We have default name of detail.
|
|
|
|
QPalette palette = labelEditNamePoint->palette();
|
|
|
|
palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76));
|
|
|
|
labelEditNamePoint->setPalette(palette);
|
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-02-05 14:30:54 +01:00
|
|
|
connect(ui.spinBoxBiasX, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
|
2013-10-25 13:10:45 +02:00
|
|
|
this, &DialogDetail::BiasXChanged);
|
2014-02-05 14:30:54 +01:00
|
|
|
connect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::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-02-25 15:40:24 +01:00
|
|
|
void DialogDetail::ChoosedObject(quint32 id, const Scene::Scenes &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
if (type != Scene::Line && type != Scene::Detail)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case (Scene::Arc):
|
2013-12-21 12:36:51 +01:00
|
|
|
NewItem(id, Tool::NodeArc, NodeDetail::Contour);
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
|
|
|
case (Scene::Point):
|
2013-12-21 12:36:51 +01:00
|
|
|
NewItem(id, Tool::NodePoint, NodeDetail::Contour);
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
|
|
|
case (Scene::Spline):
|
2013-12-21 12:36:51 +01:00
|
|
|
NewItem(id, Tool::NodeSpline, NodeDetail::Contour);
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
|
|
|
case (Scene::SplinePath):
|
2013-12-21 12:36:51 +01:00
|
|
|
NewItem(id, Tool::NodeSplinePath, NodeDetail::Contour);
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
|
|
|
default:
|
2013-12-19 15:30:11 +01:00
|
|
|
qWarning()<<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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-02-05 14:30:54 +01:00
|
|
|
details.setWidth(ui.spinBoxSeams->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-02-25 15:40:24 +01:00
|
|
|
void DialogDetail::NewItem(quint32 id, const Tool::Tools &typeTool, const NodeDetail::NodeDetails &typeNode, qreal mx,
|
2013-12-21 12:36:51 +01:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
case (Tool::NodePoint):
|
|
|
|
{
|
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
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeArc):
|
|
|
|
{
|
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
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeSpline):
|
|
|
|
{
|
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
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeSplinePath):
|
|
|
|
{
|
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:
|
2013-12-19 15:30:11 +01:00
|
|
|
qWarning()<<tr("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-02-05 14:30:54 +01:00
|
|
|
disconnect(ui.spinBoxBiasX, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
|
2013-10-25 13:10:45 +02:00
|
|
|
this, &DialogDetail::BiasXChanged);
|
2014-02-05 14:30:54 +01:00
|
|
|
disconnect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
|
2013-10-25 13:10:45 +02:00
|
|
|
this, &DialogDetail::BiasYChanged);
|
2014-02-05 14:30:54 +01:00
|
|
|
ui.spinBoxBiasX->setValue(static_cast<qint32>(toMM(node.getMx())));
|
|
|
|
ui.spinBoxBiasY->setValue(static_cast<qint32>(toMM(node.getMy())));
|
|
|
|
connect(ui.spinBoxBiasX, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
|
2013-10-25 13:10:45 +02:00
|
|
|
this, &DialogDetail::BiasXChanged);
|
2014-02-05 14:30:54 +01:00
|
|
|
connect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
|
2013-10-25 13:10:45 +02:00
|
|
|
this, &DialogDetail::BiasYChanged);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getTypeNode(), details[i].getMx(),
|
|
|
|
details[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-02-05 14:30:54 +01:00
|
|
|
ui.spinBoxSeams->setValue(static_cast<qint32>(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
|
|
|
}
|
|
|
|
|
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-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(item);
|
2013-10-25 13:10:45 +02:00
|
|
|
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
|
|
|
|
node.setMx(toPixel(d));
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
|
|
|
}
|
|
|
|
|
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-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(item);
|
2013-10-25 13:10:45 +02:00
|
|
|
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
|
|
|
|
node.setMy(toPixel(d));
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
|
|
|
}
|
|
|
|
|
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-02-05 14:30:54 +01:00
|
|
|
ui.spinBoxSeams->setEnabled(checked);
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogDetail::ClickedClosed(bool checked)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
closed = checked;
|
|
|
|
}
|
|
|
|
|
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-02-05 14:30:54 +01:00
|
|
|
ui.spinBoxBiasX->setValue(static_cast<qint32>(toMM(node.getMx())));
|
|
|
|
ui.spinBoxBiasY->setValue(static_cast<qint32>(toMM(node.getMy())));
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2014-01-13 01:48:31 +01:00
|
|
|
|
|
|
|
void DialogDetail::DeleteItem()
|
|
|
|
{
|
|
|
|
qint32 row = ui.listWidget->currentRow();
|
|
|
|
delete ui.listWidget->item( row );
|
|
|
|
}
|