2016-01-24 17:15:08 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogpointofintersectioncurves.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 23 1, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-01-24 17:15:08 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** 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.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** 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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "dialogpointofintersectioncurves.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QPushButton>
|
|
|
|
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../../visualization/path/vistoolpointofintersectioncurves.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../../visualization/visualization.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "dialogtool.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "ui_dialogpointofintersectioncurves.h"
|
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContainer *data, quint32 toolId,
|
2016-01-24 17:15:08 +01:00
|
|
|
QWidget *parent)
|
2019-02-11 12:25:27 +01:00
|
|
|
: DialogTool(data, toolId, parent),
|
|
|
|
ui(new Ui::DialogPointOfIntersectionCurves),
|
|
|
|
pointName(),
|
|
|
|
flagName(false),
|
|
|
|
flagError(false)
|
2016-01-24 17:15:08 +01:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
|
|
|
|
|
|
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
|
|
|
|
|
|
|
InitOkCancelApply(ui);
|
|
|
|
|
|
|
|
FillComboBoxCurves(ui->comboBoxCurve1);
|
|
|
|
FillComboBoxCurves(ui->comboBoxCurve2);
|
|
|
|
FillComboBoxVCrossCurvesPoint(ui->comboBoxVCorrection);
|
|
|
|
FillComboBoxHCrossCurvesPoint(ui->comboBoxHCorrection);
|
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
|
|
|
{
|
|
|
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
|
|
|
CheckState();
|
|
|
|
});
|
2018-01-12 14:25:20 +01:00
|
|
|
connect(ui->comboBoxCurve1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
2016-01-25 15:46:24 +01:00
|
|
|
this, &DialogPointOfIntersectionCurves::CurveChanged);
|
2018-01-12 14:25:20 +01:00
|
|
|
connect(ui->comboBoxCurve2, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
2016-01-25 15:46:24 +01:00
|
|
|
this, &DialogPointOfIntersectionCurves::CurveChanged);
|
2016-01-24 17:15:08 +01:00
|
|
|
|
|
|
|
vis = new VisToolPointOfIntersectionCurves(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogPointOfIntersectionCurves::~DialogPointOfIntersectionCurves()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogPointOfIntersectionCurves::GetPointName() const
|
|
|
|
{
|
|
|
|
return pointName;
|
|
|
|
}
|
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionCurves::SetPointName(const QString &value)
|
|
|
|
{
|
|
|
|
pointName = value;
|
|
|
|
ui->lineEditNamePoint->setText(pointName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogPointOfIntersectionCurves::GetFirstCurveId() const
|
|
|
|
{
|
|
|
|
return getCurrentObjectId(ui->comboBoxCurve1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogPointOfIntersectionCurves::SetFirstCurveId(quint32 value)
|
2016-01-24 17:15:08 +01:00
|
|
|
{
|
2016-01-25 15:46:24 +01:00
|
|
|
setCurrentCurveId(ui->comboBoxCurve1, value);
|
2016-01-24 17:15:08 +01:00
|
|
|
|
|
|
|
auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
point->setObject1Id(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogPointOfIntersectionCurves::GetSecondCurveId() const
|
|
|
|
{
|
|
|
|
return getCurrentObjectId(ui->comboBoxCurve2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogPointOfIntersectionCurves::SetSecondCurveId(quint32 value)
|
2016-01-24 17:15:08 +01:00
|
|
|
{
|
2016-01-25 15:46:24 +01:00
|
|
|
setCurrentCurveId(ui->comboBoxCurve2, value);
|
2016-01-24 17:15:08 +01:00
|
|
|
|
|
|
|
auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
point->setObject2Id(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VCrossCurvesPoint DialogPointOfIntersectionCurves::GetVCrossPoint() const
|
|
|
|
{
|
|
|
|
return getCurrentCrossPoint<VCrossCurvesPoint>(ui->comboBoxVCorrection);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogPointOfIntersectionCurves::SetVCrossPoint(VCrossCurvesPoint vP)
|
2016-01-24 17:15:08 +01:00
|
|
|
{
|
|
|
|
auto index = ui->comboBoxVCorrection->findData(static_cast<int>(vP));
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
ui->comboBoxVCorrection->setCurrentIndex(index);
|
|
|
|
|
|
|
|
auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
point->setVCrossPoint(vP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
HCrossCurvesPoint DialogPointOfIntersectionCurves::GetHCrossPoint() const
|
|
|
|
{
|
|
|
|
return getCurrentCrossPoint<HCrossCurvesPoint>(ui->comboBoxHCorrection);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogPointOfIntersectionCurves::SetHCrossPoint(HCrossCurvesPoint hP)
|
2016-01-24 17:15:08 +01:00
|
|
|
{
|
|
|
|
auto index = ui->comboBoxHCorrection->findData(static_cast<int>(hP));
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
ui->comboBoxHCorrection->setCurrentIndex(index);
|
|
|
|
|
|
|
|
auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
point->setHCrossPoint(hP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject &type)
|
|
|
|
{
|
|
|
|
if (prepare == false)// After first choose we ignore all objects
|
|
|
|
{
|
2016-12-20 16:05:34 +01:00
|
|
|
if (type == SceneObject::Spline
|
|
|
|
|| type == SceneObject::Arc
|
|
|
|
|| type == SceneObject::ElArc
|
|
|
|
|| type == SceneObject::SplinePath)
|
2016-01-24 17:15:08 +01:00
|
|
|
{
|
|
|
|
auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
|
|
|
|
switch (number)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (SetObject(id, ui->comboBoxCurve1, tr("Select second curve")))
|
|
|
|
{
|
|
|
|
number++;
|
|
|
|
point->VisualMode(id);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (getCurrentObjectId(ui->comboBoxCurve1) != id)
|
|
|
|
{
|
2018-03-14 15:01:24 +01:00
|
|
|
if (SetObject(id, ui->comboBoxCurve2, QString()))
|
2016-01-24 17:15:08 +01:00
|
|
|
{
|
|
|
|
number = 0;
|
|
|
|
point->setObject2Id(id);
|
|
|
|
point->RefreshGeometry();
|
|
|
|
prepare = true;
|
|
|
|
DialogAccepted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionCurves::ShowVisualization()
|
|
|
|
{
|
|
|
|
AddVisualization<VisToolPointOfIntersectionCurves>();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionCurves::SaveData()
|
|
|
|
{
|
|
|
|
pointName = ui->lineEditNamePoint->text();
|
|
|
|
|
|
|
|
auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
|
|
|
|
point->setObject1Id(GetFirstCurveId());
|
|
|
|
point->setObject2Id(GetSecondCurveId());
|
|
|
|
point->setVCrossPoint(GetVCrossPoint());
|
|
|
|
point->setHCrossPoint(GetHCrossPoint());
|
|
|
|
point->RefreshGeometry();
|
|
|
|
}
|
2016-01-25 15:46:24 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionCurves::CurveChanged()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
QColor color;
|
2016-01-25 15:46:24 +01:00
|
|
|
if (getCurrentObjectId(ui->comboBoxCurve1) == getCurrentObjectId(ui->comboBoxCurve2))
|
|
|
|
{
|
|
|
|
flagError = false;
|
|
|
|
color = errorColor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagError = true;
|
2019-02-11 12:25:27 +01:00
|
|
|
color = OkColor(this);
|
2016-01-25 15:46:24 +01:00
|
|
|
}
|
|
|
|
ChangeColor(ui->labelCurve1, color);
|
|
|
|
ChangeColor(ui->labelCurve2, color);
|
|
|
|
CheckState();
|
|
|
|
}
|