2017-02-14 16:33:30 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 14 2, 2017
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2017-02-14 16:33:30 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2017 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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
2017-10-15 11:25:20 +02:00
|
|
|
#include "vispiecespecialpoints.h"
|
2017-02-14 16:33:30 +01:00
|
|
|
#include "../vwidgets/vsimplepoint.h"
|
|
|
|
#include "../vgeometry/vpointf.h"
|
2017-07-01 13:43:16 +02:00
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2017-02-14 16:33:30 +01:00
|
|
|
|
2017-10-24 15:42:09 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
QPainterPath RectPath(const QRectF &rect)
|
|
|
|
{
|
|
|
|
QPainterPath path;
|
|
|
|
if (not rect.isNull())
|
|
|
|
{
|
|
|
|
path.addRect(rect);
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-14 16:33:30 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-10-15 11:25:20 +02:00
|
|
|
VisPieceSpecialPoints::VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent)
|
2017-02-14 16:33:30 +01:00
|
|
|
: VisPath(data, parent),
|
|
|
|
m_points(),
|
2017-10-24 15:42:09 +02:00
|
|
|
m_spoints(),
|
|
|
|
m_showRect(false),
|
|
|
|
m_placeLabelRect(),
|
|
|
|
m_rectItem(nullptr),
|
|
|
|
supportColor2(Qt::darkGreen)
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
2017-10-24 15:42:09 +02:00
|
|
|
m_rectItem = InitItem<VCurvePathItem>(supportColor2, this);
|
2018-02-06 18:30:27 +01:00
|
|
|
m_rectItem->SetWidth(qApp->Settings()->WidthHairLine());
|
2017-02-14 16:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-10-15 11:25:20 +02:00
|
|
|
void VisPieceSpecialPoints::RefreshGeometry()
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
|
|
|
HideAllItems();
|
|
|
|
|
2017-10-15 11:25:20 +02:00
|
|
|
for (int i = 0; i < m_spoints.size(); ++i)
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
|
|
|
VSimplePoint *point = GetPoint(static_cast<quint32>(i), supportColor);
|
2018-05-07 16:59:21 +02:00
|
|
|
// Keep first, you can hide only objects those have shape
|
|
|
|
point->RefreshPointGeometry(*Visualization::data->GeometricObject<VPointF>(m_spoints.at(i)));
|
2017-02-14 16:33:30 +01:00
|
|
|
point->SetOnlyPoint(false);
|
|
|
|
point->setVisible(true);
|
|
|
|
|
2017-10-24 15:42:09 +02:00
|
|
|
if (m_showRect)
|
|
|
|
{
|
|
|
|
DrawPath(m_rectItem, RectPath(m_placeLabelRect), supportColor2, Qt::SolidLine, Qt::RoundCap);
|
|
|
|
}
|
|
|
|
}
|
2017-02-14 16:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-10-15 11:25:20 +02:00
|
|
|
VSimplePoint *VisPieceSpecialPoints::GetPoint(quint32 i, const QColor &color)
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
|
|
|
return VisPath::GetPoint(m_points, i, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-10-15 11:25:20 +02:00
|
|
|
void VisPieceSpecialPoints::HideAllItems()
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto item : qAsConst(m_points))
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
if (item)
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
|
|
|
item->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|