valentina/src/app/puzzle/vpgraphicspiece.h

111 lines
3.3 KiB
C
Raw Normal View History

2020-05-05 07:44:20 +02:00
/************************************************************************
**
2020-05-23 14:50:22 +02:00
** @file vpgraphicspiece.h
2020-05-05 07:44:20 +02:00
** @author Ronan Le Tiec
** @date 4 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:50:22 +02:00
#ifndef VPGRAPHICSPIECE_H
#define VPGRAPHICSPIECE_H
2020-05-05 07:44:20 +02:00
#include <QGraphicsItem>
2020-05-23 15:42:51 +02:00
class VPPiece;
2020-05-05 07:44:20 +02:00
2020-05-23 14:50:22 +02:00
class VPGraphicsPiece : public QGraphicsObject
2020-05-05 07:44:20 +02:00
{
2020-05-05 17:40:36 +02:00
Q_OBJECT
2020-05-05 07:44:20 +02:00
public:
2020-05-23 15:42:51 +02:00
VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent = nullptr);
2020-05-23 14:50:22 +02:00
~VPGraphicsPiece();
2020-05-05 07:44:20 +02:00
void Init();
/**
* @brief GetPiece Returns the piece that corresponds to the graphics piece
* @return the piece
*/
2020-05-23 15:42:51 +02:00
VPPiece* GetPiece();
2020-05-05 17:40:36 +02:00
public slots:
/**
2020-05-09 11:13:29 +02:00
* @brief on_PieceSelectionChanged Slot called when the piece selection was changed
2020-05-05 17:40:36 +02:00
*/
void on_PieceSelectionChanged();
/**
2020-05-09 11:13:29 +02:00
* @brief on_PiecePositionChanged Slot called when the piece position was changed
2020-05-05 17:40:36 +02:00
*/
void on_PiecePositionChanged();
2020-05-09 11:13:29 +02:00
/**
* @brief on_PieceRotationChanged Slot called when the piece rotation was changed
*/
void on_PieceRotationChanged();
2020-11-10 21:29:23 +01:00
/**
* @brief on_PiecePropertiesChanged Slot called when the showSeamline / mirrored was changed
*/
void on_PiecePropertiesChanged();
2020-05-05 07:44:20 +02:00
protected:
QRectF boundingRect() const override;
QPainterPath shape() const override;
2020-11-10 15:14:51 +01:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
2020-05-05 07:44:20 +02:00
void mousePressEvent(QGraphicsSceneMouseEvent * event) override;
2020-05-09 14:45:36 +02:00
void mouseMoveEvent(QGraphicsSceneMouseEvent * event) override;
2020-05-05 07:44:20 +02:00
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
2020-05-09 14:45:36 +02:00
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
2020-05-05 17:40:36 +02:00
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
2020-05-05 07:44:20 +02:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
private slots:
/**
2020-05-23 15:29:57 +02:00
* @brief on_ActionPieceMovedToPieceList Slot called when the piece is moved via the
* context menu to anoter piece list
*/
2020-05-23 15:29:57 +02:00
void on_ActionPieceMovedToPieceList();
2020-05-05 07:44:20 +02:00
private:
2020-05-23 14:50:22 +02:00
Q_DISABLE_COPY(VPGraphicsPiece)
2020-05-23 15:42:51 +02:00
VPPiece *m_piece;
2020-05-05 07:44:20 +02:00
QPainterPath m_cuttingLine;
QPainterPath m_seamLine;
QPainterPath m_grainline;
2020-11-20 17:05:56 +01:00
QPainterPath m_passmarks;
2020-05-09 14:45:36 +02:00
2020-11-19 16:32:47 +01:00
QVector<QPainterPath> m_internalPaths;
QVector<Qt::PenStyle> m_internalPathsPenStyle;
2020-05-09 14:45:36 +02:00
2020-11-20 17:05:56 +01:00
QVector<QPainterPath> m_placeLabels;
2020-11-19 16:32:47 +01:00
QPointF m_rotationStartPoint;
2020-05-05 07:44:20 +02:00
};
2020-05-23 14:50:22 +02:00
#endif // VPGRAPHICSPIECE_H