Seamly2D
Code documentation
vispath.cpp
Go to the documentation of this file.
1 /**************************************************************************
2  **
3  ** @file vispath.cpp
4  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
5  ** @date 15 8, 2014
6  **
7  ** @author Douglas S Caskey
8  ** @date 7.23.2022
9  **
10  ** @brief
11  ** @copyright
12  ** This source code is part of the Valentine project, a pattern making
13  ** program, whose allow create and modeling patterns of clothing.
14  ** Copyright (C) 2013-2022 Seamly2D project
15  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
16  **
17  ** Seamly2D is free software: you can redistribute it and/or modify
18  ** it under the terms of the GNU General Public License as published by
19  ** the Free Software Foundation, either version 3 of the License, or
20  ** (at your option) any later version.
21  **
22  ** Seamly2D is distributed in the hope that it will be useful,
23  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
24  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  ** GNU General Public License for more details.
26  **
27  ** You should have received a copy of the GNU General Public License
28  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
29  **
30  *************************************************************************/
31 
32 #include "vispath.h"
33 
34 #include "../visualization.h"
35 #include "../ifc/ifcdef.h"
36 #include "../vmisc/vabstractapplication.h"
37 #include "../vpatterndb/vcontainer.h"
38 #include "../vwidgets/vsimplepoint.h"
39 
40 #include <QPen>
41 
42 //---------------------------------------------------------------------------------------------------------------------
43 VisPath::VisPath(const VContainer *data, QGraphicsItem *parent)
44  : Visualization(data)
45  , VCurvePathItem(parent)
46 {
47  this->setZValue(1);// Show on top real tool
48  initPen();
49 }
50 
51 //---------------------------------------------------------------------------------------------------------------------
53 {
54  QPen visPen = pen();
55  visPen.setColor(mainColor);
56  visPen.setStyle(lineStyle);
57  visPen.setWidthF(lineWeight);
58 
59  this->setPen(visPen);
60 }
61 
62 //---------------------------------------------------------------------------------------------------------------------
64 {
65  addItem(this);
66 }
67 
68 //---------------------------------------------------------------------------------------------------------------------
69 VSimplePoint *VisPath::GetPoint(QVector<VSimplePoint *> &points, quint32 i, const QColor &color)
70 {
71  if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
72  {
73  return points.at(static_cast<int>(i));
74  }
75  else
76  {
77  VSimplePoint *point = new VSimplePoint(NULL_ID, color);
78  point->SetPointHighlight(true);
79  point->setParentItem(this);
80  point->SetVisualizationMode(true);
81  points.append(point);
82 
83  return point;
84  }
85  return nullptr;
86 }
The VContainer class container of all variables.
Definition: vcontainer.h:141
void SetPointHighlight(bool value)
void SetVisualizationMode(bool value)
VisPath(const VContainer *data, QGraphicsItem *parent=nullptr)
Definition: vispath.cpp:43
virtual void AddOnScene() Q_DECL_OVERRIDE
Definition: vispath.cpp:63
virtual void initPen() Q_DECL_OVERRIDE
Definition: vispath.cpp:52
VSimplePoint * GetPoint(QVector< VSimplePoint * > &points, quint32 i, const QColor &color)
Definition: vispath.cpp:69
QColor mainColor
Definition: visualization.h:99
Qt::PenStyle lineStyle
void addItem(Item *item)
#define NULL_ID
Definition: ifcdef.h:76