2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-11-04 21:38:54 +01:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file dialogpointofintersection.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-11-04 21:38:54 +01: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.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-11-04 21:38:54 +01:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-11-04 21:38:54 +01: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.
|
|
|
|
**
|
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-11-04 21:38:54 +01:00
|
|
|
|
2013-10-21 16:09:05 +02:00
|
|
|
#include "dialogpointofintersection.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/vistoolpointofintersection.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/ifcdef.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_dialogpointofintersection.h"
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogPointOfIntersection create dialog
|
|
|
|
* @param data container with data
|
|
|
|
* @param parent parent widget
|
|
|
|
*/
|
2014-07-29 14:19:11 +02:00
|
|
|
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
2015-05-21 21:24:31 +02:00
|
|
|
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-21 16:09:05 +02:00
|
|
|
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
|
|
|
|
|
2014-09-05 10:01:46 +02:00
|
|
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
2013-10-21 16:09:05 +02:00
|
|
|
labelEditNamePoint = ui->labelEditNamePoint;
|
2014-06-19 13:43:02 +02:00
|
|
|
|
2014-08-13 13:12:00 +02:00
|
|
|
InitOkCancelApply(ui);
|
2017-03-31 10:54:05 +02:00
|
|
|
DialogTool::CheckState();
|
2013-12-21 12:36:51 +01:00
|
|
|
|
|
|
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
|
|
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
|
|
|
|
2013-10-21 16:09:05 +02:00
|
|
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged);
|
2014-07-14 17:32:00 +02:00
|
|
|
connect(ui->comboBoxFirstPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogPointOfIntersection::PointNameChanged);
|
|
|
|
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogPointOfIntersection::PointNameChanged);
|
2014-08-13 13:31:01 +02:00
|
|
|
|
2015-05-21 21:24:31 +02:00
|
|
|
vis = new VisToolPointOfIntersection(data);
|
2015-07-03 21:22:52 +02:00
|
|
|
vis->VisualMode(NULL_ID);//Show vertical axis
|
2013-10-21 16:09:05 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
DialogPointOfIntersection::~DialogPointOfIntersection()
|
|
|
|
{
|
2013-10-21 16:09:05 +02:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
2015-02-03 11:17:04 +01:00
|
|
|
* @brief SetSecondPointId set id of second point
|
2014-06-02 16:28:02 +02:00
|
|
|
* @param value id
|
|
|
|
*/
|
2015-02-03 11:17:04 +01:00
|
|
|
void DialogPointOfIntersection::SetSecondPointId(const quint32 &value)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-02-03 09:17:59 +01:00
|
|
|
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
|
|
|
VisToolPointOfIntersection *line = qobject_cast<VisToolPointOfIntersection *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(line != nullptr)
|
2015-02-03 09:17:59 +01:00
|
|
|
line->setPoint2Id(value);
|
2013-10-21 16:09:05 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
|
|
|
* @param id id of point or detail
|
|
|
|
* @param type type of object
|
|
|
|
*/
|
2014-07-15 16:42:41 +02:00
|
|
|
void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-17 20:49:29 +02:00
|
|
|
if (prepare == false)// After first choose we ignore all objects
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-17 20:49:29 +02:00
|
|
|
if (type == SceneObject::Point)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-05-21 21:24:31 +02:00
|
|
|
VisToolPointOfIntersection *line = qobject_cast<VisToolPointOfIntersection *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(line != nullptr)
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2014-08-17 20:49:29 +02:00
|
|
|
switch (number)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-17 20:49:29 +02:00
|
|
|
case 0:
|
2015-01-26 23:13:57 +01:00
|
|
|
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point for Y value (horizontal)")))
|
2014-08-17 20:49:29 +02:00
|
|
|
{
|
|
|
|
number++;
|
2016-01-24 17:15:08 +01:00
|
|
|
line->setObject1Id(id);
|
2015-01-27 19:17:28 +01:00
|
|
|
line->RefreshGeometry();
|
2014-08-17 20:49:29 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2014-11-09 11:57:49 +01:00
|
|
|
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
|
2014-08-17 20:49:29 +02:00
|
|
|
{
|
2014-11-09 11:57:49 +01:00
|
|
|
if (SetObject(id, ui->comboBoxSecondPoint, ""))
|
|
|
|
{
|
|
|
|
line->setPoint2Id(id);
|
|
|
|
line->RefreshGeometry();
|
|
|
|
prepare = true;
|
2015-07-03 21:22:52 +02:00
|
|
|
DialogAccepted();
|
2014-11-09 11:57:49 +01:00
|
|
|
}
|
2014-08-17 20:49:29 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-10-21 16:09:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-08-13 12:20:30 +02:00
|
|
|
void DialogPointOfIntersection::SaveData()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-21 16:09:05 +02:00
|
|
|
pointName = ui->lineEditNamePoint->text();
|
2014-08-13 13:31:01 +02:00
|
|
|
|
2015-05-21 21:24:31 +02:00
|
|
|
VisToolPointOfIntersection *line = qobject_cast<VisToolPointOfIntersection *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(line != nullptr)
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
line->setObject1Id(GetFirstPointId());
|
2015-02-03 11:17:04 +01:00
|
|
|
line->setPoint2Id(GetSecondPointId());
|
2014-08-13 13:31:01 +02:00
|
|
|
line->RefreshGeometry();
|
2013-10-21 16:09:05 +02:00
|
|
|
}
|
|
|
|
|
2014-07-14 17:32:00 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersection::PointNameChanged()
|
|
|
|
{
|
2014-07-14 18:28:41 +02:00
|
|
|
QColor color = okColor;
|
2014-07-14 17:32:00 +02:00
|
|
|
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
|
|
|
{
|
|
|
|
flagError = false;
|
2014-07-14 18:28:41 +02:00
|
|
|
color = errorColor;
|
2014-07-14 17:32:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagError = true;
|
2014-07-14 18:28:41 +02:00
|
|
|
color = okColor;
|
2014-07-14 17:32:00 +02:00
|
|
|
}
|
2014-07-14 18:28:41 +02:00
|
|
|
ChangeColor(ui->labelFirstPoint, color);
|
|
|
|
ChangeColor(ui->labelSecondPoint, color);
|
2014-07-14 17:32:00 +02:00
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2014-08-13 13:31:01 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogPointOfIntersection::ShowVisualization()
|
|
|
|
{
|
2015-05-27 12:48:21 +02:00
|
|
|
AddVisualization<VisToolPointOfIntersection>();
|
2014-08-13 13:31:01 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
2015-02-03 11:17:04 +01:00
|
|
|
* @brief SetFirstPointId set id of first point
|
2014-06-02 16:28:02 +02:00
|
|
|
* @param value id
|
|
|
|
*/
|
2015-02-03 11:17:04 +01:00
|
|
|
void DialogPointOfIntersection::SetFirstPointId(const quint32 &value)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-02-03 09:17:59 +01:00
|
|
|
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
|
|
|
VisToolPointOfIntersection *line = qobject_cast<VisToolPointOfIntersection *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(line != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
line->setObject1Id(value);
|
2013-10-21 16:09:05 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
2015-02-03 11:17:04 +01:00
|
|
|
* @brief SetPointName set name of point
|
2014-06-02 16:28:02 +02:00
|
|
|
* @param value name
|
|
|
|
*/
|
2015-02-03 11:17:04 +01:00
|
|
|
void DialogPointOfIntersection::SetPointName(const QString &value)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-21 16:09:05 +02:00
|
|
|
pointName = value;
|
|
|
|
ui->lineEditNamePoint->setText(pointName);
|
|
|
|
}
|
2015-02-02 16:11:48 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
2015-02-03 11:17:04 +01:00
|
|
|
* @brief GetFirstPointId return id of first point
|
2015-02-02 16:11:48 +01:00
|
|
|
* @return id
|
|
|
|
*/
|
2015-02-03 11:17:04 +01:00
|
|
|
quint32 DialogPointOfIntersection::GetFirstPointId() const
|
2015-02-02 16:11:48 +01:00
|
|
|
{
|
2015-02-03 09:17:59 +01:00
|
|
|
return getCurrentObjectId(ui->comboBoxFirstPoint);
|
2015-02-02 16:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
2015-02-03 11:17:04 +01:00
|
|
|
* @brief GetSecondPointId return id of second point
|
2015-02-02 16:11:48 +01:00
|
|
|
* @return id
|
|
|
|
*/
|
2015-02-03 11:17:04 +01:00
|
|
|
quint32 DialogPointOfIntersection::GetSecondPointId() const
|
2015-02-02 16:11:48 +01:00
|
|
|
{
|
2015-02-03 09:17:59 +01:00
|
|
|
return getCurrentObjectId(ui->comboBoxSecondPoint);
|
2015-02-02 16:11:48 +01:00
|
|
|
}
|