2016-11-08 11:57:01 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 6 11, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 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 VTOOLSEAMALLOWANCE_H
|
|
|
|
#define VTOOLSEAMALLOWANCE_H
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
#include <QObject>
|
2016-12-03 17:51:36 +01:00
|
|
|
#include <QGraphicsPathItem>
|
2016-11-08 11:57:01 +01:00
|
|
|
|
2017-04-15 16:39:59 +02:00
|
|
|
#include "vinteractivetool.h"
|
2017-01-19 11:23:42 +01:00
|
|
|
#include "../vwidgets/vtextgraphicsitem.h"
|
|
|
|
#include "../vwidgets/vgrainlineitem.h"
|
2016-11-08 11:57:01 +01:00
|
|
|
|
|
|
|
class DialogTool;
|
2017-01-19 11:23:42 +01:00
|
|
|
class VNoBrushScalePathItem;
|
2016-11-08 11:57:01 +01:00
|
|
|
|
2017-04-15 16:39:59 +02:00
|
|
|
class VToolSeamAllowance : public VInteractiveTool, public QGraphicsPathItem
|
2016-11-08 11:57:01 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-04-15 16:39:59 +02:00
|
|
|
virtual ~VToolSeamAllowance() Q_DECL_EQ_DEFAULT;
|
2016-11-08 11:57:01 +01:00
|
|
|
|
2017-04-15 16:39:59 +02:00
|
|
|
static VToolSeamAllowance* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
|
|
|
VAbstractPattern *doc, VContainer *data);
|
2017-01-21 14:24:40 +01:00
|
|
|
static VToolSeamAllowance* Create(quint32 id, VPiece newPiece, QString &width, VMainGraphicsScene *scene,
|
2016-11-08 11:57:01 +01:00
|
|
|
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
2017-04-06 14:50:15 +02:00
|
|
|
const Source &typeCreation, const QString &drawName = QString());
|
2016-11-08 11:57:01 +01:00
|
|
|
|
|
|
|
static const quint8 pieceVersion;
|
|
|
|
|
2016-11-25 13:19:44 +01:00
|
|
|
static const QString TagCSA;
|
|
|
|
static const QString TagRecord;
|
2016-12-03 17:01:39 +01:00
|
|
|
static const QString TagIPaths;
|
2017-01-31 17:09:18 +01:00
|
|
|
static const QString TagPins;
|
2016-11-25 13:19:44 +01:00
|
|
|
|
2016-11-08 11:57:01 +01:00
|
|
|
static const QString AttrVersion;
|
2016-11-10 10:56:40 +01:00
|
|
|
static const QString AttrForbidFlipping;
|
2016-11-10 11:53:02 +01:00
|
|
|
static const QString AttrSeamAllowance;
|
2017-05-16 14:16:50 +02:00
|
|
|
static const QString AttrHideMainPath;
|
2017-04-05 12:22:33 +02:00
|
|
|
static const QString AttrSeamAllowanceBuiltIn;
|
2017-01-12 14:51:08 +01:00
|
|
|
static const QString AttrHeight;
|
2016-11-23 17:40:27 +01:00
|
|
|
static const QString AttrUnited;
|
2017-01-12 14:51:08 +01:00
|
|
|
static const QString AttrFont;
|
2017-02-23 15:49:20 +01:00
|
|
|
static const QString AttrTopLeftPin;
|
|
|
|
static const QString AttrBottomRightPin;
|
2017-03-09 12:10:46 +01:00
|
|
|
static const QString AttrCenterPin;
|
2017-02-23 15:49:20 +01:00
|
|
|
static const QString AttrTopPin;
|
|
|
|
static const QString AttrBottomPin;
|
2016-11-08 11:57:01 +01:00
|
|
|
|
2016-11-09 10:57:39 +01:00
|
|
|
void Remove(bool ask);
|
|
|
|
|
2017-03-21 17:00:31 +01:00
|
|
|
static void InsertNode(VPieceNode node, quint32 pieceId, VMainGraphicsScene *scene, VContainer *data,
|
|
|
|
VAbstractPattern *doc);
|
2017-03-21 16:18:48 +01:00
|
|
|
|
2016-11-09 13:11:58 +01:00
|
|
|
static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece);
|
2016-11-25 13:19:44 +01:00
|
|
|
static void AddCSARecord(VAbstractPattern *doc, QDomElement &domElement, const CustomSARecord &record);
|
|
|
|
static void AddCSARecords(VAbstractPattern *doc, QDomElement &domElement, const QVector<CustomSARecord> &records);
|
2016-12-03 17:01:39 +01:00
|
|
|
static void AddInternalPaths(VAbstractPattern *doc, QDomElement &domElement, const QVector<quint32> &paths);
|
2017-01-31 17:09:18 +01:00
|
|
|
static void AddPins(VAbstractPattern *doc, QDomElement &domElement, const QVector<quint32> &pins);
|
2016-11-09 13:11:58 +01:00
|
|
|
static void AddPatternPieceData(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece);
|
|
|
|
static void AddPatternInfo(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece);
|
|
|
|
static void AddGrainline(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece);
|
2016-11-08 11:57:01 +01:00
|
|
|
|
|
|
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
|
|
|
enum { Type = UserType + static_cast<int>(Tool::Piece)};
|
|
|
|
|
|
|
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
|
|
|
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
|
|
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
2017-06-16 13:53:08 +02:00
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget) Q_DECL_OVERRIDE;
|
2016-11-08 11:57:01 +01:00
|
|
|
public slots:
|
2017-01-12 14:51:08 +01:00
|
|
|
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
|
|
|
void EnableToolMove(bool move);
|
|
|
|
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
|
|
|
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
|
|
|
virtual void ResetChildren(QGraphicsItem* pItem);
|
|
|
|
virtual void UpdateAll();
|
|
|
|
virtual void retranslateUi();
|
|
|
|
void Highlight(quint32 id);
|
2017-07-01 13:41:46 +02:00
|
|
|
void UpdateDetailLabel();
|
|
|
|
void UpdatePatternInfo();
|
2017-01-12 14:51:08 +01:00
|
|
|
protected slots:
|
2017-04-27 13:30:20 +02:00
|
|
|
void UpdateGrainline();
|
|
|
|
void SaveMoveDetail(const QPointF &ptPos);
|
|
|
|
void SaveResizeDetail(qreal dLabelW, int iFontSize);
|
|
|
|
void SaveRotationDetail(qreal dRot);
|
|
|
|
void SaveMovePattern(const QPointF& ptPos);
|
|
|
|
void SaveResizePattern(qreal dLabelW, int iFontSize);
|
|
|
|
void SaveRotationPattern(qreal dRot);
|
|
|
|
void SaveMoveGrainline(const QPointF& ptPos);
|
|
|
|
void SaveResizeGrainline(qreal dLength);
|
|
|
|
void SaveRotateGrainline(qreal dRot, const QPointF& ptPos);
|
2016-11-08 11:57:01 +01:00
|
|
|
protected:
|
|
|
|
virtual void AddToFile () Q_DECL_OVERRIDE;
|
|
|
|
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
|
|
|
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
|
|
|
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void hoverMoveEvent( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
|
|
|
|
virtual void SetVisualization() Q_DECL_OVERRIDE {}
|
2016-11-09 10:57:39 +01:00
|
|
|
virtual void DeleteTool(bool ask = true) Q_DECL_OVERRIDE;
|
2017-01-18 09:17:18 +01:00
|
|
|
virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE;
|
2017-04-15 16:39:59 +02:00
|
|
|
virtual void SetDialog() Q_DECL_FINAL;
|
|
|
|
virtual void SaveDialogChange() Q_DECL_FINAL;
|
2016-11-08 11:57:01 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VToolSeamAllowance)
|
|
|
|
|
|
|
|
/** @brief sceneDetails pointer to the scene. */
|
|
|
|
VMainGraphicsScene *m_sceneDetails;
|
|
|
|
QString m_drawName;
|
|
|
|
|
2016-11-10 13:06:09 +01:00
|
|
|
VNoBrushScalePathItem *m_seamAllowance;
|
2017-01-12 14:51:08 +01:00
|
|
|
VTextGraphicsItem *m_dataLabel;
|
|
|
|
VTextGraphicsItem *m_patternInfo;
|
|
|
|
VGrainlineItem *m_grainLine;
|
2016-11-10 13:06:09 +01:00
|
|
|
|
2016-11-08 11:57:01 +01:00
|
|
|
VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
|
2017-04-06 14:50:15 +02:00
|
|
|
VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem * parent = nullptr);
|
2016-11-08 11:57:01 +01:00
|
|
|
|
2017-03-22 11:05:53 +01:00
|
|
|
void UpdateExcludeState();
|
2016-11-09 15:27:55 +01:00
|
|
|
void RefreshGeometry();
|
2017-04-15 16:39:59 +02:00
|
|
|
|
2017-03-13 13:27:29 +01:00
|
|
|
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,
|
|
|
|
qreal &labelHeight, QPointF &pos);
|
2017-03-10 15:22:19 +01:00
|
|
|
VPieceItem::MoveTypes FindGrainlineGeometry(const VGrainlineData &geom, qreal &length, qreal &rotationAngle,
|
|
|
|
QPointF &pos);
|
2016-11-08 11:57:01 +01:00
|
|
|
|
2016-11-25 15:37:32 +01:00
|
|
|
void InitNodes(const VPiece &detail, VMainGraphicsScene *scene);
|
2017-03-21 17:00:31 +01:00
|
|
|
static void InitNode(const VPieceNode &node, VMainGraphicsScene *scene, VContainer *data, VAbstractPattern *doc,
|
|
|
|
VToolSeamAllowance *parent);
|
2016-11-25 15:37:32 +01:00
|
|
|
void InitCSAPaths(const VPiece &detail);
|
2016-12-03 17:01:39 +01:00
|
|
|
void InitInternalPaths(const VPiece &detail);
|
2017-02-24 18:48:54 +01:00
|
|
|
void InitPins(const VPiece &detail);
|
2017-04-27 13:30:20 +02:00
|
|
|
|
|
|
|
bool PrepareLabelData(const VPatternLabelData &labelData, VTextGraphicsItem *labelItem, QPointF &pos,
|
|
|
|
qreal &labelAngle);
|
|
|
|
void UpdateLabelItem(VTextGraphicsItem *labelItem, QPointF pos, qreal labelAngle);
|
2016-11-08 11:57:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLSEAMALLOWANCE_H
|