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
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013 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 "dialoguniondetails.h"
|
|
|
|
#include "ui_dialoguniondetails.h"
|
|
|
|
|
|
|
|
DialogUnionDetails::DialogUnionDetails(const VContainer *data, QWidget *parent) :
|
2014-01-02 16:50:01 +01:00
|
|
|
DialogTool(data, parent), ui(new Ui::DialogUnionDetails), indexD1(0), indexD2(0), d1(0), d2(0), numberD(0),
|
|
|
|
numberP(0), p1(0), p2(0)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2014-03-06 14:28:46 +01:00
|
|
|
InitOkCansel(ui);
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DialogUnionDetails::~DialogUnionDetails()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2014-03-11 12:43:24 +01:00
|
|
|
void DialogUnionDetails::ChoosedObject(quint32 id, const Valentina::Scenes &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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogUnionDetails::DialogAccepted()
|
|
|
|
{
|
|
|
|
emit DialogClosed(QDialog::Accepted);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
if (idDetail == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-30 19:59:33 +01:00
|
|
|
VDetail det = data->GetDetail(idDetail);
|
|
|
|
return det.Containes(id);
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
|
2014-03-11 12:43:24 +01:00
|
|
|
void DialogUnionDetails::ChoosedDetail(const quint32 &id, const Valentina::Scenes &type, quint32 &idDetail,
|
2014-02-26 10:51:37 +01:00
|
|
|
ptrdiff_t &index)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
|
|
|
if (idDetail == 0)
|
|
|
|
{
|
2014-03-11 12:43:24 +01:00
|
|
|
if (type == Valentina::Detail)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
|
|
|
idDetail = id;
|
|
|
|
emit ToolTip(tr("Select first point"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CheckObject(id, idDetail) == false)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
if (type == Valentina::Point)
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
|
|
|
if (numberP == 0)
|
|
|
|
{
|
|
|
|
p1 = id;
|
|
|
|
++numberP;
|
|
|
|
emit ToolTip(tr("Select 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
|
|
|
{
|
2014-01-02 16:50:01 +01:00
|
|
|
emit ToolTip(tr("Select another second point"));
|
2013-12-29 17:48:57 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-02 16:50:01 +01:00
|
|
|
VDetail d = data->GetDetail(idDetail);
|
|
|
|
if (d.OnEdge(p1, id))
|
2013-12-23 18:23:50 +01:00
|
|
|
{
|
2014-01-02 16:50:01 +01:00
|
|
|
p2 = id;
|
|
|
|
index = d.Edge(p1, p2);
|
|
|
|
++numberD;
|
|
|
|
if (numberD > 1)
|
|
|
|
{
|
|
|
|
++numberP;
|
|
|
|
emit ToolTip("");
|
|
|
|
this->show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numberP = 0;
|
|
|
|
p1 = 0;
|
|
|
|
p2 = 0;
|
|
|
|
emit ToolTip(tr("Select detail"));
|
|
|
|
return;
|
|
|
|
}
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-02 16:50:01 +01:00
|
|
|
emit ToolTip(tr("Select another second point"));
|
|
|
|
return;
|
2013-12-23 18:23:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|