1 /************************************************************************
2 **
3 ** @file vistoolduplicatedetail.cpp
4 ** @author Roman Telezhynskyi <dismine(at)gmail.com>
5 ** @date 25 10, 2017
6 **
7 ** @brief
8 ** @copyright
9 ** This source code is part of the Valentina project, a pattern making
10 ** program, whose allow create and modeling patterns of clothing.
11 ** Copyright (C) 2017 Valentina project
12 ** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
13 **
14 ** Valentina is free software: you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License as published by
16 ** the Free Software Foundation, either version 3 of the License, or
17 ** (at your option) any later version.
18 **
19 ** Valentina is distributed in the hope that it will be useful,
20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ** GNU General Public License for more details.
23 **
24 ** You should have received a copy of the GNU General Public License
25 ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
26 **
27 *************************************************************************/
28 #include "vistoolduplicatedetail.h"
29 #include "../vpatterndb/vcontainer.h"
30
31 //---------------------------------------------------------------------------------------------------------------------
VisToolDuplicateDetail(const VContainer * data,QGraphicsItem * parent)32 VisToolDuplicateDetail::VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent)
33 : VisPath(data, parent),
34 m_start(),
35 m_started(false),
36 m_diff()
37 {}
38
39 //---------------------------------------------------------------------------------------------------------------------
RefreshGeometry()40 void VisToolDuplicateDetail::RefreshGeometry()
41 {
42 const VPiece piece = Visualization::data->GetPiece(object1Id);
43
44 if (not m_started)
45 {
46 m_start = Visualization::scenePos;
47 m_started = true;
48 setPos(QPointF(piece.GetMx(), piece.GetMy()));
49 }
50 else
51 {
52 m_diff = Visualization::scenePos - m_start;
53 m_diff = QPointF(m_diff.x() + piece.GetMx(), m_diff.y() + piece.GetMy());
54 setPos(m_diff);
55 }
56
57 DrawPath(this, PiecePath(piece), mainColor, Qt::SolidLine, Qt::RoundCap);
58 }
59
60 //---------------------------------------------------------------------------------------------------------------------
PiecePath(const VPiece & piece) const61 QPainterPath VisToolDuplicateDetail::PiecePath(const VPiece &piece) const
62 {
63 if (not piece.IsHideMainPath() || not piece.IsSeamAllowance() || piece.IsSeamAllowanceBuiltIn())
64 {
65 return piece.MainPathPath(Visualization::data);
66 }
67 else
68 {
69 return piece.SeamAllowancePath(Visualization::data);
70 }
71 }
72