valentina/src/app/puzzle/vpgraphicspiece.h

111 lines
3.4 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-11-22 12:45:38 +01:00
#include <QCursor>
2020-05-05 07:44:20 +02:00
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:
2021-07-31 11:32:23 +02:00
explicit VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent = nullptr);
~VPGraphicsPiece() = default;
2020-05-05 07:44:20 +02:00
void Init();
/**
* @brief GetPiece Returns the piece that corresponds to the graphics piece
* @return the piece
*/
2021-07-31 11:32:23 +02:00
auto GetPiece() -> VPPiece*;
2021-07-31 15:00:32 +02:00
virtual int type() const override {return Type;}
enum { Type = UserType + 1};
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:
2021-07-31 11:32:23 +02:00
auto boundingRect() const -> QRectF override;
auto shape() const -> QPainterPath 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;
2021-07-31 11:32:23 +02:00
auto itemChange(GraphicsItemChange change, const QVariant &value) -> QVariant override;
2020-05-05 07:44:20 +02:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
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
2021-07-31 11:32:23 +02:00
QPainterPath m_cuttingLine{};
QPainterPath m_seamLine{};
QPainterPath m_grainline{};
QPainterPath m_passmarks{};
2020-05-09 14:45:36 +02:00
2021-07-31 11:32:23 +02:00
QVector<QPainterPath> m_internalPaths{};
QVector<Qt::PenStyle> m_internalPathsPenStyle{};
2020-05-09 14:45:36 +02:00
2021-07-31 11:32:23 +02:00
QVector<QPainterPath> m_placeLabels{};
2020-11-20 17:05:56 +01:00
2021-07-31 11:32:23 +02:00
QPointF m_rotationStartPoint{};
2020-11-22 12:45:38 +01:00
2021-07-31 11:32:23 +02:00
QCursor m_rotateCursor{};
2020-05-05 07:44:20 +02:00
};
2020-05-23 14:50:22 +02:00
#endif // VPGRAPHICSPIECE_H