2015-06-06 08:33:19 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogpointfromarcandtangent.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 5 6, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-06-06 08:33:19 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-06-06 08:33:19 +02:00
|
|
|
**
|
|
|
|
** 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 "dialogpointfromarcandtangent.h"
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPointer>
|
|
|
|
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../../visualization/line/vistoolpointfromarcandtangent.h"
|
2023-10-07 11:47:43 +02:00
|
|
|
#include "../../visualization/visualization.h"
|
2023-01-04 17:31:50 +01:00
|
|
|
#include "dialogtool.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "ui_dialogpointfromarcandtangent.h"
|
|
|
|
|
2015-06-06 08:33:19 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-10-07 11:47:43 +02:00
|
|
|
DialogPointFromArcAndTangent::DialogPointFromArcAndTangent(const VContainer *data, VAbstractPattern *doc,
|
|
|
|
quint32 toolId, QWidget *parent)
|
|
|
|
: DialogTool(data, doc, toolId, parent),
|
|
|
|
ui(new Ui::DialogPointFromArcAndTangent),
|
|
|
|
pointName(),
|
|
|
|
flagName(true)
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2015-12-09 11:40:43 +01:00
|
|
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
|
|
|
|
2021-02-06 14:52:21 +01:00
|
|
|
ui->lineEditNamePoint->setText(
|
2023-10-07 11:47:43 +02:00
|
|
|
VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
2015-06-06 08:33:19 +02:00
|
|
|
|
|
|
|
InitOkCancelApply(ui);
|
|
|
|
|
|
|
|
FillComboBoxPoints(ui->comboBoxTangentPoint);
|
|
|
|
FillComboBoxArcs(ui->comboBoxArc);
|
|
|
|
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
|
|
|
|
2023-10-07 11:47:43 +02:00
|
|
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this,
|
|
|
|
[this]()
|
|
|
|
{
|
|
|
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
|
|
|
CheckState();
|
|
|
|
});
|
2015-06-06 08:33:19 +02:00
|
|
|
|
|
|
|
vis = new VisToolPointFromArcAndTangent(data);
|
2020-10-28 13:09:56 +01:00
|
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
|
|
|
SetTabStopDistance(ui->plainTextEditToolNotes);
|
2015-06-06 08:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogPointFromArcAndTangent::~DialogPointFromArcAndTangent()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto DialogPointFromArcAndTangent::GetPointName() const -> QString
|
2019-02-11 12:25:27 +01:00
|
|
|
{
|
|
|
|
return pointName;
|
|
|
|
}
|
|
|
|
|
2015-06-06 08:33:19 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointFromArcAndTangent::SetPointName(const QString &value)
|
|
|
|
{
|
|
|
|
pointName = value;
|
|
|
|
ui->lineEditNamePoint->setText(pointName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto DialogPointFromArcAndTangent::GetArcId() const -> quint32
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
|
|
|
return getCurrentObjectId(ui->comboBoxArc);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogPointFromArcAndTangent::SetArcId(quint32 value)
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
2016-02-01 20:16:32 +01:00
|
|
|
setCurrentArcId(ui->comboBoxArc, value);
|
2015-06-06 08:33:19 +02:00
|
|
|
|
2024-02-19 17:15:42 +01:00
|
|
|
auto *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2022-08-23 15:37:58 +02:00
|
|
|
point->SetArcId(value);
|
2015-06-06 08:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto DialogPointFromArcAndTangent::GetTangentPointId() const -> quint32
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
|
|
|
return getCurrentObjectId(ui->comboBoxTangentPoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogPointFromArcAndTangent::SetTangentPointId(quint32 value)
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
|
|
|
setCurrentPointId(ui->comboBoxTangentPoint, value);
|
|
|
|
|
2022-08-23 15:37:58 +02:00
|
|
|
auto *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2022-08-23 15:37:58 +02:00
|
|
|
point->SetPointId(value);
|
2015-06-06 08:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto DialogPointFromArcAndTangent::GetCrossCirclesPoint() const -> CrossCirclesPoint
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
return getCurrentCrossPoint<CrossCirclesPoint>(ui->comboBoxResult);
|
2015-06-06 08:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-02-11 12:25:27 +01:00
|
|
|
void DialogPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint p)
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
|
|
|
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
ui->comboBoxResult->setCurrentIndex(index);
|
|
|
|
|
2024-02-19 17:15:42 +01:00
|
|
|
auto *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2022-08-23 15:37:58 +02:00
|
|
|
point->SetCrossPoint(p);
|
2015-06-06 08:33:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &type)
|
|
|
|
{
|
2023-10-07 11:47:43 +02:00
|
|
|
if (prepare == false) // After first choose we ignore all objects
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
|
|
|
if (type == SceneObject::Point || type == SceneObject::Arc)
|
|
|
|
{
|
2024-02-19 17:15:42 +01:00
|
|
|
auto *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2015-06-06 08:33:19 +02:00
|
|
|
|
|
|
|
switch (number)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (type == SceneObject::Point)
|
|
|
|
{
|
|
|
|
if (SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc")))
|
|
|
|
{
|
|
|
|
number++;
|
|
|
|
point->VisualMode(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (type == SceneObject::Arc)
|
|
|
|
{
|
2018-03-14 15:01:24 +01:00
|
|
|
if (SetObject(id, ui->comboBoxArc, QString()))
|
2015-06-06 08:33:19 +02:00
|
|
|
{
|
|
|
|
number = 0;
|
2022-08-23 15:37:58 +02:00
|
|
|
point->SetArcId(id);
|
2015-06-06 08:33:19 +02:00
|
|
|
point->RefreshGeometry();
|
|
|
|
prepare = true;
|
2015-07-03 21:22:52 +02:00
|
|
|
DialogAccepted();
|
2015-06-06 08:33:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointFromArcAndTangent::ShowVisualization()
|
|
|
|
{
|
|
|
|
AddVisualization<VisToolPointFromArcAndTangent>();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointFromArcAndTangent::SaveData()
|
|
|
|
{
|
|
|
|
pointName = ui->lineEditNamePoint->text();
|
|
|
|
|
2022-08-23 15:37:58 +02:00
|
|
|
auto *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2015-06-06 08:33:19 +02:00
|
|
|
|
2022-08-23 15:37:58 +02:00
|
|
|
point->SetPointId(GetTangentPointId());
|
|
|
|
point->SetArcId(GetArcId());
|
|
|
|
point->SetCrossPoint(GetCrossCirclesPoint());
|
2015-06-06 08:33:19 +02:00
|
|
|
point->RefreshGeometry();
|
|
|
|
}
|
2020-10-28 13:09:56 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointFromArcAndTangent::SetNotes(const QString ¬es)
|
|
|
|
{
|
|
|
|
ui->plainTextEditToolNotes->setPlainText(notes);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto DialogPointFromArcAndTangent::GetNotes() const -> QString
|
2020-10-28 13:09:56 +01:00
|
|
|
{
|
|
|
|
return ui->plainTextEditToolNotes->toPlainText();
|
|
|
|
}
|