Seamly2D
Code documentation
pieceanchorpoint_visual.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * @file pieceanchorpoint_visual.cpp
3  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
4  ** @date 14 2, 2017
5  **
6  ** @brief
7  ** @copyright
8  ** This source code is part of the Seamly project, a pattern making
9  ** program, whose allow create and modeling patterns of clothing.
10  ** Copyright (C) 2022 Seamly2D project
11  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
12  **
13  ** Seamly2D is free software: you can redistribute it and/or modify
14  ** it under the terms of the GNU General Public License as published by
15  ** the Free Software Foundation, either version 3 of the License, or
16  ** (at your option) any later version.
17  **
18  ** Seamly2D is distributed in the hope that it will be useful,
19  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  ** GNU General Public License for more details.
22  **
23  ** You should have received a copy of the GNU General Public License
24  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
25  **
26  *****************************************************************************/
27 
29 #include "../vwidgets/vsimplepoint.h"
30 #include "../vgeometry/vpointf.h"
31 #include "../vpatterndb/vcontainer.h"
32 
33 //---------------------------------------------------------------------------------------------------------------------
35  : VisPath(data, parent)
36  , m_points()
37  , m_anchors()
38 {
39 }
40 
41 //---------------------------------------------------------------------------------------------------------------------
43 {
44  HideAllItems();
45 
46  for (int i = 0; i < m_anchors.size(); ++i)
47  {
48  VSimplePoint *point = GetPoint(static_cast<quint32>(i), supportColor);
49  point->setOnlyPoint(false);
51  point->refreshPointGeometry(*p);
52  point->setVisible(true);
53  }
54 }
55 
56 //---------------------------------------------------------------------------------------------------------------------
58 {
59  m_anchors = anchors;
60 }
61 
62 //---------------------------------------------------------------------------------------------------------------------
63 VSimplePoint *PieceAnchorPointVisual::GetPoint(quint32 i, const QColor &color)
64 {
65  return VisPath::GetPoint(m_points, i, color);
66 }
67 
68 //---------------------------------------------------------------------------------------------------------------------
70 {
71  for (int i=0; i < m_points.size(); ++i)
72  {
73  if (QGraphicsEllipseItem *item = m_points.at(i))
74  {
75  item->setVisible(false);
76  }
77  }
78 }
virtual void RefreshGeometry() Q_DECL_OVERRIDE
void setAnchors(const QVector< quint32 > &anchors)
QVector< VSimplePoint * > m_points
PieceAnchorPointVisual(const VContainer *data, QGraphicsItem *parent=nullptr)
VSimplePoint * GetPoint(quint32 i, const QColor &color)
The VContainer class container of all variables.
Definition: vcontainer.h:141
const QSharedPointer< T > GeometricObject(const quint32 &id) const
Definition: vcontainer.h:266
The VPointF class keep data of point.
Definition: vpointf.h:75
virtual void refreshPointGeometry(const VPointF &point)
void setOnlyPoint(bool value)
VSimplePoint * GetPoint(QVector< VSimplePoint * > &points, quint32 i, const QColor &color)
Definition: vispath.cpp:69
QColor supportColor
const VContainer * data
Definition: visualization.h:97