2016-06-23 00:59:45 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vtextgraphicsitem.h
|
|
|
|
** @author Bojan Kverh
|
|
|
|
** @date June 16, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-06-23 00:59:45 +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 VTEXTGRAPHICSITEM_H
|
|
|
|
#define VTEXTGRAPHICSITEM_H
|
|
|
|
|
2016-06-25 17:19:44 +02:00
|
|
|
#include <QFont>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QGraphicsObject>
|
2016-06-25 17:19:44 +02:00
|
|
|
#include <QList>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QRectF>
|
|
|
|
#include <QSizeF>
|
|
|
|
#include <QString>
|
|
|
|
#include <QtGlobal>
|
2016-06-23 00:59:45 +02:00
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
#include "vpieceitem.h"
|
2016-07-19 14:23:20 +02:00
|
|
|
#include "../vlayout/vtextmanager.h"
|
2016-06-25 17:19:44 +02:00
|
|
|
|
2016-07-23 15:26:15 +02:00
|
|
|
/**
|
|
|
|
* @brief The VTextGraphicsItem class. This class implements text graphics item,
|
|
|
|
* which can be dragged around, resized and rotated within the parent item. The text font
|
|
|
|
* size will be automatically updated, so that the entire text will fit into the item.
|
|
|
|
*/
|
2017-01-19 11:07:26 +01:00
|
|
|
class VTextGraphicsItem : public VPieceItem
|
2016-06-23 00:59:45 +02:00
|
|
|
{
|
2016-06-23 22:35:32 +02:00
|
|
|
Q_OBJECT
|
2016-06-23 00:59:45 +02:00
|
|
|
public:
|
2016-08-02 14:12:13 +02:00
|
|
|
explicit VTextGraphicsItem(QGraphicsItem* pParent = nullptr);
|
2017-04-01 16:27:55 +02:00
|
|
|
virtual ~VTextGraphicsItem() Q_DECL_EQ_DEFAULT;
|
2016-06-23 00:59:45 +02:00
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
|
|
|
|
virtual void Update() Q_DECL_OVERRIDE;
|
2016-06-23 00:59:45 +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::TextGraphicsItem)};
|
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
void SetFont(const QFont& fnt);
|
|
|
|
int GetFontSize() const;
|
|
|
|
void SetSize(qreal fW, qreal fH);
|
|
|
|
bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const;
|
2017-02-23 10:19:27 +01:00
|
|
|
void UpdateData(const QString& qsName, const VPieceLabelData& data);
|
2017-08-19 18:52:33 +02:00
|
|
|
void UpdateData(VAbstractPattern* pDoc);
|
2017-01-19 11:07:26 +01:00
|
|
|
int GetTextLines() const;
|
2016-06-23 22:35:32 +02:00
|
|
|
|
2016-06-23 00:59:45 +02:00
|
|
|
protected:
|
2017-01-19 11:07:26 +01:00
|
|
|
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-10-28 16:31:18 +02:00
|
|
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *pME) Q_DECL_OVERRIDE;
|
2017-01-19 11:07:26 +01:00
|
|
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) Q_DECL_OVERRIDE;
|
2016-06-25 17:19:44 +02:00
|
|
|
|
2017-01-19 11:07:26 +01:00
|
|
|
void UpdateBox();
|
|
|
|
void CorrectLabel();
|
2016-06-30 18:04:25 +02:00
|
|
|
|
2016-06-25 17:19:44 +02:00
|
|
|
signals:
|
2017-01-19 11:07:26 +01:00
|
|
|
void SignalResized(qreal iTW, int iFontSize);
|
|
|
|
void SignalRotated(qreal dAng);
|
|
|
|
void SignalShrink();
|
2016-06-23 00:59:45 +02:00
|
|
|
|
|
|
|
private:
|
2017-01-19 11:07:26 +01:00
|
|
|
Q_DISABLE_COPY(VTextGraphicsItem)
|
|
|
|
QPointF m_ptStartPos;
|
|
|
|
QPointF m_ptStart;
|
|
|
|
QSizeF m_szStart;
|
|
|
|
double m_dRotation;
|
|
|
|
double m_dAngle;
|
|
|
|
QRectF m_rectResize;
|
|
|
|
VTextManager m_tm;
|
2017-03-13 14:54:38 +01:00
|
|
|
|
|
|
|
void AllUserModifications(const QPointF &pos);
|
|
|
|
void UserRotateAndMove();
|
|
|
|
void UserMoveAndResize(const QPointF &pos);
|
2016-06-23 00:59:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTEXTGRAPHICSITEM_H
|