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 dialogspline.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-05 10:37:56 +02:00
|
|
|
#include "dialogspline.h"
|
|
|
|
#include "ui_dialogspline.h"
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *parent)
|
|
|
|
:DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
|
|
|
|
kAsm1(1), kAsm2(1), kCurve(1)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
ui->setupUi(this);
|
|
|
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
|
|
|
connect(bOk, &QPushButton::clicked, this, &DialogSpline::DialogAccepted);
|
|
|
|
|
|
|
|
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
|
|
|
connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (mode == Draw::Calculation)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
FillComboBoxPoints(ui->comboBoxP1);
|
|
|
|
FillComboBoxPoints(ui->comboBoxP4);
|
|
|
|
}
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
DialogSpline::~DialogSpline()
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2013-11-06 20:46:07 +01:00
|
|
|
void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
if (idDetail == 0 && mode == Draw::Modeling)
|
|
|
|
{
|
|
|
|
if (type == Scene::Detail)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
idDetail = id;
|
|
|
|
FillComboBoxPoints(ui->comboBoxP1);
|
|
|
|
FillComboBoxPoints(ui->comboBoxP4);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (mode == Draw::Modeling)
|
|
|
|
{
|
|
|
|
if (CheckObject(id) == false)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (type == Scene::Point)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
VPointF point;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (mode == Draw::Calculation)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
point = data->GetPoint(id);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
point = data->GetModelingPoint(id);
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (number == 0)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
qint32 index = ui->comboBoxP1->findText(point.name());
|
2013-11-04 21:35:15 +01:00
|
|
|
if ( index != -1 )
|
|
|
|
{ // -1 for not found
|
2013-08-05 10:37:56 +02:00
|
|
|
ui->comboBoxP1->setCurrentIndex(index);
|
|
|
|
number++;
|
2013-10-07 13:11:56 +02:00
|
|
|
emit ToolTip(tr("Select last point of curve"));
|
2013-08-05 10:37:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (number == 1)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
qint32 index = ui->comboBoxP4->findText(point.name());
|
2013-11-04 21:35:15 +01:00
|
|
|
if ( index != -1 )
|
|
|
|
{ // -1 for not found
|
2013-08-05 10:37:56 +02:00
|
|
|
ui->comboBoxP4->setCurrentIndex(index);
|
|
|
|
number = 0;
|
2013-10-07 13:11:56 +02:00
|
|
|
emit ToolTip("");
|
2013-08-05 10:37:56 +02:00
|
|
|
index = ui->comboBoxP1->currentIndex();
|
|
|
|
qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index));
|
2013-09-10 14:29:06 +02:00
|
|
|
QPointF p1;
|
|
|
|
QPointF p4;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (mode == Draw::Calculation)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
p1 = data->GetPoint(p1Id).toQPointF();
|
|
|
|
p4 = data->GetPoint(id).toQPointF();
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
p1 = data->GetModelingPoint(p1Id).toQPointF();
|
|
|
|
p4 = data->GetModelingPoint(id).toQPointF();
|
|
|
|
}
|
2013-08-20 12:26:02 +02:00
|
|
|
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
|
|
|
|
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (isInitialized == false)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
this->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSpline::DialogAccepted()
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
p1 = getCurrentPointId(ui->comboBoxP1);
|
|
|
|
p4 = getCurrentPointId(ui->comboBoxP4);
|
2013-08-05 10:37:56 +02:00
|
|
|
angle1 = ui->spinBoxAngle1->value();
|
|
|
|
angle2 = ui->spinBoxAngle2->value();
|
|
|
|
kAsm1 = ui->doubleSpinBoxKasm1->value();
|
|
|
|
kAsm2 = ui->doubleSpinBoxKasm2->value();
|
|
|
|
kCurve = ui->doubleSpinBoxKcurve->value();
|
|
|
|
emit DialogClosed(QDialog::Accepted);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSpline::setKCurve(const qreal &value)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
kCurve = value;
|
|
|
|
ui->doubleSpinBoxKcurve->setValue(value);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSpline::setKAsm2(const qreal &value)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
kAsm2 = value;
|
|
|
|
ui->doubleSpinBoxKasm2->setValue(value);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSpline::setKAsm1(const qreal &value)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
kAsm1 = value;
|
|
|
|
ui->doubleSpinBoxKasm1->setValue(value);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSpline::setAngle2(const qreal &value)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
angle2 = value;
|
2013-08-20 12:26:02 +02:00
|
|
|
ui->spinBoxAngle2->setValue(static_cast<qint32>(value));
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSpline::setAngle1(const qreal &value)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
angle1 = value;
|
2013-08-20 12:26:02 +02:00
|
|
|
ui->spinBoxAngle1->setValue(static_cast<qint32>(value));
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSpline::setP4(const qint64 &value)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
p4 = value;
|
|
|
|
ChangeCurrentData(ui->comboBoxP4, value);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSpline::setP1(const qint64 &value)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
p1 = value;
|
|
|
|
ChangeCurrentData(ui->comboBoxP1, value);
|
|
|
|
}
|