2015-05-27 12:48:21 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogpointofintersectionarcs.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 25 5, 2015
|
|
|
|
**
|
|
|
|
** @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) 2015 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 "dialogpointofintersectionarcs.h"
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QColor>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPointer>
|
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../../visualization/visualization.h"
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../../visualization/line/vistoolpointofintersectionarcs.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "dialogs/tools/dialogtool.h"
|
|
|
|
#include "ui_dialogpointofintersectionarcs.h"
|
|
|
|
|
2015-05-27 12:48:21 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId,
|
|
|
|
QWidget *parent)
|
|
|
|
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersectionArcs)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2015-12-09 11:40:43 +01:00
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
|
|
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
|
|
|
#endif
|
|
|
|
|
2015-05-27 12:48:21 +02:00
|
|
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
|
|
|
labelEditNamePoint = ui->labelEditNamePoint;
|
|
|
|
|
|
|
|
InitOkCancelApply(ui);
|
2017-03-31 10:54:05 +02:00
|
|
|
DialogTool::CheckState();
|
2015-05-27 12:48:21 +02:00
|
|
|
|
|
|
|
FillComboBoxArcs(ui->comboBoxArc1);
|
|
|
|
FillComboBoxArcs(ui->comboBoxArc2);
|
2015-05-30 12:02:20 +02:00
|
|
|
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
2015-05-27 12:48:21 +02:00
|
|
|
|
|
|
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionArcs::NamePointChanged);
|
|
|
|
connect(ui->comboBoxArc1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogPointOfIntersectionArcs::ArcChanged);
|
|
|
|
connect(ui->comboBoxArc1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogPointOfIntersectionArcs::ArcChanged);
|
|
|
|
|
|
|
|
vis = new VisToolPointOfIntersectionArcs(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogPointOfIntersectionArcs::~DialogPointOfIntersectionArcs()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionArcs::SetPointName(const QString &value)
|
|
|
|
{
|
|
|
|
pointName = value;
|
|
|
|
ui->lineEditNamePoint->setText(pointName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogPointOfIntersectionArcs::GetFirstArcId() const
|
|
|
|
{
|
|
|
|
return getCurrentObjectId(ui->comboBoxArc1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionArcs::SetFirstArcId(const quint32 &value)
|
|
|
|
{
|
2016-02-01 20:16:32 +01:00
|
|
|
setCurrentArcId(ui->comboBoxArc1, value);
|
2015-05-27 12:48:21 +02:00
|
|
|
|
|
|
|
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2015-05-27 12:48:21 +02:00
|
|
|
point->setArc1Id(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogPointOfIntersectionArcs::GetSecondArcId() const
|
|
|
|
{
|
|
|
|
return getCurrentObjectId(ui->comboBoxArc2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
|
|
|
|
{
|
2016-02-01 20:16:32 +01:00
|
|
|
setCurrentArcId(ui->comboBoxArc2, value);
|
2015-05-27 12:48:21 +02:00
|
|
|
|
|
|
|
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2015-05-27 12:48:21 +02:00
|
|
|
point->setArc2Id(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-05-30 12:02:20 +02:00
|
|
|
CrossCirclesPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const
|
2015-05-27 12:48:21 +02:00
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
return getCurrentCrossPoint<CrossCirclesPoint>(ui->comboBoxResult);
|
2015-05-27 12:48:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-10-28 15:22:36 +01:00
|
|
|
void DialogPointOfIntersectionArcs::SetCrossArcPoint(const CrossCirclesPoint &p)
|
2015-05-27 12:48:21 +02:00
|
|
|
{
|
|
|
|
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
ui->comboBoxResult->setCurrentIndex(index);
|
|
|
|
|
|
|
|
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2015-05-27 12:48:21 +02:00
|
|
|
point->setCrossPoint(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &type)
|
|
|
|
{
|
|
|
|
if (prepare == false)// After first choose we ignore all objects
|
|
|
|
{
|
|
|
|
if (type == SceneObject::Arc)
|
|
|
|
{
|
|
|
|
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2015-05-27 12:48:21 +02:00
|
|
|
|
|
|
|
switch (number)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc")))
|
|
|
|
{
|
|
|
|
number++;
|
2015-05-27 18:24:20 +02:00
|
|
|
point->VisualMode(id);
|
2015-05-27 12:48:21 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2015-05-27 18:24:20 +02:00
|
|
|
if (getCurrentObjectId(ui->comboBoxArc1) != id)
|
2015-05-27 12:48:21 +02:00
|
|
|
{
|
|
|
|
if (SetObject(id, ui->comboBoxArc2, ""))
|
|
|
|
{
|
2015-05-27 18:24:20 +02:00
|
|
|
number = 0;
|
2015-05-27 12:48:21 +02:00
|
|
|
point->setArc2Id(id);
|
|
|
|
point->RefreshGeometry();
|
|
|
|
prepare = true;
|
2015-07-03 21:22:52 +02:00
|
|
|
DialogAccepted();
|
2015-05-27 12:48:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionArcs::ArcChanged()
|
|
|
|
{
|
|
|
|
QColor color = okColor;
|
|
|
|
if (getCurrentObjectId(ui->comboBoxArc1) == getCurrentObjectId(ui->comboBoxArc2))
|
|
|
|
{
|
|
|
|
flagError = false;
|
|
|
|
color = errorColor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagError = true;
|
|
|
|
color = okColor;
|
|
|
|
}
|
|
|
|
ChangeColor(ui->labelArc1, color);
|
|
|
|
ChangeColor(ui->labelArc2, color);
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionArcs::ShowVisualization()
|
|
|
|
{
|
|
|
|
AddVisualization<VisToolPointOfIntersectionArcs>();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersectionArcs::SaveData()
|
|
|
|
{
|
|
|
|
pointName = ui->lineEditNamePoint->text();
|
|
|
|
|
|
|
|
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(point != nullptr)
|
2015-05-27 12:48:21 +02:00
|
|
|
|
|
|
|
point->setArc1Id(GetFirstArcId());
|
|
|
|
point->setArc2Id(GetSecondArcId());
|
2015-05-27 20:23:50 +02:00
|
|
|
point->setCrossPoint(GetCrossArcPoint());
|
2015-05-27 12:48:21 +02:00
|
|
|
point->RefreshGeometry();
|
|
|
|
}
|