2016-09-10 18:30:03 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vgrainlineitem.h
|
|
|
|
** @author Bojan Kverh
|
|
|
|
** @date September 10, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-09-10 18:30:03 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VGRAINLINEITEM_H
|
|
|
|
#define VGRAINLINEITEM_H
|
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
#include "vpieceitem.h"
|
2017-02-23 10:37:19 +01:00
|
|
|
#include "../vpatterndb/floatItemData/vgrainlinedata.h"
|
2017-06-09 11:39:24 +02:00
|
|
|
#include "../vmisc/def.h"
|
2016-09-10 18:30:03 +02:00
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
class VGrainlineItem : public VPieceItem
|
2016-09-10 18:30:03 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit VGrainlineItem(QGraphicsItem* pParent = nullptr);
|
2017-04-01 16:27:55 +02:00
|
|
|
virtual ~VGrainlineItem() Q_DECL_EQ_DEFAULT;
|
2016-09-10 18:30:03 +02:00
|
|
|
|
2017-02-27 10:59:08 +01:00
|
|
|
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
|
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
virtual void paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption, QWidget* pWidget) Q_DECL_OVERRIDE;
|
2017-02-23 13:04:49 +01:00
|
|
|
void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, ArrowType eAT);
|
2016-09-10 18:30:03 +02:00
|
|
|
|
2017-06-09 11:39:24 +02:00
|
|
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
|
|
|
enum { Type = UserType + static_cast<int>(Vis::GrainlineItem)};
|
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
bool IsContained(const QPointF &pt, qreal dRot, qreal &dX, qreal &dY) const;
|
2016-09-11 12:18:09 +02:00
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
signals:
|
|
|
|
void SignalResized(qreal dLength);
|
|
|
|
void SignalRotated(qreal dRot, const QPointF& ptNewPos);
|
2016-09-11 12:18:09 +02:00
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
protected:
|
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
|
|
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
|
|
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
2017-02-28 16:33:53 +01:00
|
|
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* pME) Q_DECL_OVERRIDE;
|
|
|
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* pME) Q_DECL_OVERRIDE;
|
2017-01-19 11:07:26 +01:00
|
|
|
virtual void Update() Q_DECL_OVERRIDE;
|
|
|
|
void UpdateRectangle();
|
2016-10-12 02:45:01 +02:00
|
|
|
|
2017-03-01 06:38:43 +01:00
|
|
|
virtual double GetAngle(const QPointF &pt) const Q_DECL_OVERRIDE;
|
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
QPointF Rotate(const QPointF& pt, const QPointF& ptCenter, qreal dAng) const;
|
|
|
|
QPointF GetInsideCorner(int i, qreal dDist) const;
|
2016-09-10 18:30:03 +02:00
|
|
|
|
|
|
|
private:
|
2017-01-19 11:07:26 +01:00
|
|
|
Q_DISABLE_COPY(VGrainlineItem)
|
|
|
|
qreal m_dRotation;
|
|
|
|
qreal m_dStartRotation;
|
|
|
|
qreal m_dLength;
|
|
|
|
QPolygonF m_polyBound;
|
|
|
|
QPointF m_ptStartPos;
|
|
|
|
QPointF m_ptStartMove;
|
|
|
|
qreal m_dScale;
|
|
|
|
QPolygonF m_polyResize;
|
|
|
|
qreal m_dStartLength;
|
|
|
|
QPointF m_ptStart;
|
|
|
|
QPointF m_ptFinish;
|
|
|
|
QPointF m_ptCenter;
|
|
|
|
qreal m_dAngle;
|
2017-02-23 13:04:49 +01:00
|
|
|
ArrowType m_eArrowType;
|
2017-02-28 16:33:53 +01:00
|
|
|
int m_penWidth;
|
2017-02-24 18:47:13 +01:00
|
|
|
|
|
|
|
qreal GetScale() const;
|
2017-02-27 10:59:08 +01:00
|
|
|
|
|
|
|
QLineF MainLine() const;
|
|
|
|
QPolygonF FirstArrow(qreal dArrLen) const;
|
|
|
|
QPolygonF SecondArrow(qreal dArrLen) const;
|
2017-02-28 16:33:53 +01:00
|
|
|
|
|
|
|
QPainterPath MainShape() const;
|
2017-03-10 15:22:19 +01:00
|
|
|
|
|
|
|
void AllUserModifications(const QPointF &pos);
|
|
|
|
void UserRotateAndMove();
|
|
|
|
void UserMoveAndResize(const QPointF &pos);
|
2017-03-14 12:19:34 +01:00
|
|
|
|
|
|
|
void UpdatePolyResize();
|
2016-09-10 18:30:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VGRAINLINEITEM_H
|