2013-12-23 18:23:50 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialoguniondetails.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-12-23 18:23:50 +01:00
|
|
|
** @date 23 12, 2013
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2013-12-23 18:23:50 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2013-12-23 18:23:50 +01: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 "dialoguniondetails.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QVector>
|
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/ifcdef.h"
|
2015-10-08 20:11:50 +02:00
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2017-01-17 12:49:55 +01:00
|
|
|
#include "../vpatterndb/vpiece.h"
|
|
|
|
#include "../vpatterndb/vpiecenode.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "dialogtool.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "ui_dialoguniondetails.h"
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogUnionDetails create dialog
|
|
|
|
* @param data container with data
|
|
|
|
* @param parent parent widget
|
|
|
|
*/
|
2019-02-11 12:25:27 +01:00
|
|
|
DialogUnionDetails::DialogUnionDetails(const VContainer *data, quint32 toolId, QWidget *parent)
|
|
|
|
: DialogTool(data, toolId, parent),
|
|
|
|
ui(new Ui::DialogUnionDetails),
|
|
|
|
indexD1(0),
|
|
|
|
indexD2(0),
|
|
|
|
d1(NULL_ID),
|
|
|
|
d2(NULL_ID),
|
|
|
|
numberD(0),
|
|
|
|
numberP(0),
|
|
|
|
p1(NULL_ID),
|
|
|
|
p2(NULL_ID)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2014-06-09 18:37:11 +02:00
|
|
|
InitOkCancel(ui);
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-12-23 18:23:50 +01:00
|
|
|
DialogUnionDetails::~DialogUnionDetails()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2016-06-30 18:48:46 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogUnionDetails::RetainPieces() const
|
|
|
|
{
|
|
|
|
return ui->checkBox->isChecked();
|
|
|
|
}
|
|
|
|
|
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 correct 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 DialogUnionDetails::ChosenObject(quint32 id, const SceneObject &type)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
2013-12-31 09:44:54 +01:00
|
|
|
if (numberD == 0)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
2014-01-02 16:50:01 +01:00
|
|
|
ChoosedDetail(id, type, d1, indexD1);
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-02 16:50:01 +01:00
|
|
|
ChoosedDetail(id, type, d2, indexD2);
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-15 16:28:19 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief CheckObject check if detail contain this id
|
|
|
|
* @param id id of item
|
|
|
|
* @param idDetail detail id
|
|
|
|
* @return true if contain
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
bool DialogUnionDetails::CheckObject(const quint32 &id, const quint32 &idDetail) const
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
2015-03-30 16:27:45 +02:00
|
|
|
if (idDetail == NULL_ID)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-01-17 12:49:55 +01:00
|
|
|
const VPiece det = data->GetPiece(idDetail);
|
|
|
|
return det.GetPath().Contains(id);
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
|
2015-03-30 16:27:45 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogUnionDetails::CheckDetail(const quint32 &idDetail) const
|
|
|
|
{
|
|
|
|
if (idDetail == NULL_ID)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-01-17 12:49:55 +01:00
|
|
|
const VPiece det = data->GetPiece(idDetail);
|
|
|
|
if (det.GetPath().CountNodes() >= 3 && det.GetPath().ListNodePoint().size() >= 2)
|
2015-03-30 16:27:45 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ChoosedDetail help save information about detail and points on detail
|
|
|
|
* @param id id selected object
|
|
|
|
* @param type type selected object
|
|
|
|
* @param idDetail id detail
|
|
|
|
* @param index index of edge
|
|
|
|
*/
|
2014-06-12 09:22:29 +02:00
|
|
|
void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail,
|
2014-10-05 22:25:07 +02:00
|
|
|
int &index)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
2015-03-30 16:27:45 +02:00
|
|
|
if (idDetail == NULL_ID)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
if (type == SceneObject::Detail)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
2015-03-30 16:27:45 +02:00
|
|
|
if (CheckDetail(id))
|
|
|
|
{
|
|
|
|
idDetail = id;
|
|
|
|
emit ToolTip(tr("Select a first point"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
emit ToolTip(tr("Workpiece should have at least two points and three objects"));
|
|
|
|
return;
|
|
|
|
}
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CheckObject(id, idDetail) == false)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-06-12 09:22:29 +02:00
|
|
|
if (type == SceneObject::Point)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
|
|
|
if (numberP == 0)
|
|
|
|
{
|
|
|
|
p1 = id;
|
|
|
|
++numberP;
|
2015-03-30 16:27:45 +02:00
|
|
|
emit ToolTip(tr("Select a second point"));
|
2014-01-02 16:50:01 +01:00
|
|
|
return;
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
if (numberP == 1)
|
|
|
|
{
|
2013-12-31 09:44:54 +01:00
|
|
|
if (id == p1)
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
2015-03-30 16:27:45 +02:00
|
|
|
emit ToolTip(tr("Select a unique point"));
|
2013-12-29 17:48:57 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-01-17 12:49:55 +01:00
|
|
|
VPiece d = data->GetPiece(idDetail);
|
|
|
|
if (d.GetPath().OnEdge(p1, id))
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
2014-01-02 16:50:01 +01:00
|
|
|
p2 = id;
|
2017-01-17 12:49:55 +01:00
|
|
|
index = d.GetPath().Edge(p1, p2);
|
2014-01-02 16:50:01 +01:00
|
|
|
++numberD;
|
|
|
|
if (numberD > 1)
|
|
|
|
{
|
|
|
|
++numberP;
|
2018-03-14 15:01:24 +01:00
|
|
|
emit ToolTip(QString());
|
2014-07-04 13:55:36 +02:00
|
|
|
this->setModal(true);
|
2014-01-02 16:50:01 +01:00
|
|
|
this->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numberP = 0;
|
|
|
|
p1 = 0;
|
|
|
|
p2 = 0;
|
2015-03-30 16:27:45 +02:00
|
|
|
emit ToolTip(tr("Select a detail"));
|
2014-01-02 16:50:01 +01:00
|
|
|
}
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-03-30 16:27:45 +02:00
|
|
|
emit ToolTip(tr("Select a point on edge"));
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|