Seamly2D
Code documentation
vgraphicsfillitem.cpp
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vgraphicsfillitem.cpp
4  ** @author Bojan Kverh
5  ** @date October 16, 2016
6  **
7  ** @brief
8  ** @copyright
9  ** This source code is part of the Valentine project, a pattern making
10  ** program, whose allow create and modeling patterns of clothing.
11  ** Copyright (C) 2013-2015 Seamly2D project
12  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
13  **
14  ** Seamly2D 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  ** Seamly2D 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 Seamly2D. If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #include "vgraphicsfillitem.h"
30 
31 //---------------------------------------------------------------------------------------------------------------------
32 VGraphicsFillItem::VGraphicsFillItem(const QColor &color, bool fill, QGraphicsItem *parent)
33  : QGraphicsPathItem(parent)
34  , m_color(color)
35  , m_fill(fill)
36 {}
37 
38 //---------------------------------------------------------------------------------------------------------------------
40 {}
41 
42 //---------------------------------------------------------------------------------------------------------------------
43 void VGraphicsFillItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
44 {
45  Q_UNUSED(option)
46  Q_UNUSED(widget)
47  painter->save();
48  if (m_fill)
49  {
50  painter->setBrush(QBrush(Qt::NoBrush));
51  }
52  else
53  {
54  painter->setBrush(m_color);
55  }
56 
57  painter->setPen(m_color);
58  painter->drawPath(path());
59  painter->restore();
60 }
61 
62 //---------------------------------------------------------------------------------------------------------------------
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
paint Paints the item, filling the inside surface
~VGraphicsFillItem()
~VGraphicsFillItem Destructor
VGraphicsFillItem(const QColor &color, bool fill, QGraphicsItem *parent=nullptr)
VGraphicsFillItem Constructor.