valentina/src/app/puzzle/vpgraphicssheet.cpp

93 lines
3.2 KiB
C++
Raw Normal View History

2020-05-05 07:44:20 +02:00
/************************************************************************
**
2020-05-23 14:48:31 +02:00
** @file vpgraphicssheet.cpp
2020-05-05 07:44:20 +02:00
** @author Ronan Le Tiec
** @date 3 5, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/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/>.
**
*************************************************************************/
2020-05-23 14:48:31 +02:00
#include "vpgraphicssheet.h"
2020-05-05 07:44:20 +02:00
//---------------------------------------------------------------------------------------------------------------------
VPGraphicsSheet::VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent):
2020-05-05 07:44:20 +02:00
QGraphicsItem(parent),
m_sheet(sheet),
m_boundingRect(GetSheetRect())
2020-05-05 07:44:20 +02:00
{
2020-05-05 07:44:20 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:48:31 +02:00
VPGraphicsSheet::~VPGraphicsSheet()
2020-05-05 07:44:20 +02:00
{
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:48:31 +02:00
void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
2020-05-05 07:44:20 +02:00
{
Q_UNUSED(widget);
Q_UNUSED(option);
QPen pen(QColor(0,179,255), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
pen.setCosmetic(true);
QBrush noBrush(Qt::NoBrush);
painter->setPen(pen);
painter->setBrush(noBrush);
painter->drawRect(GetMarginsRect());
pen.setColor(Qt::black);
painter->setPen(pen);
painter->drawRect(GetSheetRect());
2020-05-05 07:44:20 +02:00
m_boundingRect = GetSheetRect();
2020-05-05 07:44:20 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VPGraphicsSheet::GetSheetRect() const
2020-05-05 07:44:20 +02:00
{
QRectF rect = QRectF(QPointF(0,0), m_sheet->GetSheetSize());
2020-05-05 07:44:20 +02:00
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:48:31 +02:00
QRectF VPGraphicsSheet::GetMarginsRect() const
2020-05-05 07:44:20 +02:00
{
QMarginsF margins = m_sheet->GetSheetMargins();
QSizeF size = m_sheet->GetSheetSize();
2020-05-05 07:44:20 +02:00
QRectF rect = QRectF(
QPointF(margins.left(),margins.top()),
QPointF(size.width()-margins.right(), size.height()-margins.bottom())
);
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:48:31 +02:00
QRectF VPGraphicsSheet::boundingRect() const
2020-05-05 07:44:20 +02:00
{
return m_boundingRect;
}