2016-11-08 11:57:01 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 6 11, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-11-08 11:57:01 +01:00
|
|
|
** 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-09-21 09:05:58 +02:00
|
|
|
struct VToolSeamAllowanceInitData : VAbstractToolInitData
|
2017-09-18 10:37:23 +02:00
|
|
|
{
|
|
|
|
VToolSeamAllowanceInitData()
|
|
|
|
: VAbstractToolInitData(),
|
|
|
|
detail(),
|
|
|
|
width("0"),
|
|
|
|
drawName()
|
|
|
|
{}
|
|
|
|
|
|
|
|
VPiece detail;
|
|
|
|
QString width;
|
|
|
|
QString drawName;
|
|
|
|
};
|
|
|
|
|
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-09-18 10:37:23 +02:00
|
|
|
static VToolSeamAllowance* Create(VToolSeamAllowanceInitData &initData);
|
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;
|
2017-10-15 11:25:20 +02:00
|
|
|
static const QString TagPlaceLabels;
|
2016-11-25 13:19:44 +01:00
|
|
|
|
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;
|
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
|
|
|
|
2017-10-19 10:24:21 +02:00
|
|
|
void RemoveWithConfirm(bool ask);
|
2016-11-09 10:57:39 +01:00
|
|
|
|
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);
|
2017-10-15 11:25:20 +02:00
|
|
|
static void AddPlaceLabels(VAbstractPattern *doc, QDomElement &domElement, const QVector<quint32> &placeLabels);
|
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
|
|
|
|
2017-10-18 10:24:15 +02:00
|
|
|
void Move(qreal x, qreal y);
|
2017-10-18 10:56:29 +02:00
|
|
|
void Update(const VPiece &piece);
|
2017-10-18 15:40:20 +02:00
|
|
|
void DisconnectOutsideSignals();
|
|
|
|
void ConnectOutsideSignals();
|
|
|
|
void ReinitInternals(const VPiece &detail, VMainGraphicsScene *scene);
|
2017-10-23 09:45:58 +02:00
|
|
|
void RefreshGeometry();
|
2017-10-18 10:24:15 +02:00
|
|
|
|
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)};
|
|
|
|
|
2017-08-01 11:57:19 +02:00
|
|
|
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;
|
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget) Q_DECL_OVERRIDE;
|
|
|
|
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
2017-08-01 11:59:31 +02:00
|
|
|
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
|
2016-11-08 11:57:01 +01:00
|
|
|
public slots:
|
2017-10-23 09:45:58 +02:00
|
|
|
virtual void FullUpdateFromGuiApply() Q_DECL_OVERRIDE;
|
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 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 {}
|
2017-10-19 10:24:21 +02:00
|
|
|
virtual void DeleteToolWithConfirm(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;
|
2017-10-23 09:45:58 +02:00
|
|
|
virtual void SaveDialogChange(const QString &undoText = QString()) Q_DECL_FINAL;
|
2016-11-08 11:57:01 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VToolSeamAllowance)
|
|
|
|
|
2017-08-01 11:57:19 +02:00
|
|
|
QPainterPath m_mainPath; // Must be first to prevent crash
|
|
|
|
QRectF m_mainPathRect;
|
|
|
|
|
2016-11-08 11:57:01 +01:00
|
|
|
/** @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;
|
2017-07-11 12:05:48 +02:00
|
|
|
QGraphicsPathItem *m_passmarks;
|
2017-10-15 11:25:20 +02:00
|
|
|
QGraphicsPathItem *m_placeLabels;
|
2016-11-10 13:06:09 +01:00
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
|
2016-11-08 11:57:01 +01:00
|
|
|
|
2017-03-22 11:05:53 +01:00
|
|
|
void UpdateExcludeState();
|
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);
|
2017-10-15 11:25:20 +02:00
|
|
|
void InitCSAPaths(const VPiece &detail) const;
|
2016-12-03 17:01:39 +01:00
|
|
|
void InitInternalPaths(const VPiece &detail);
|
2017-10-15 11:25:20 +02:00
|
|
|
void InitSpecialPoints(const QVector<quint32> &points) const;
|
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);
|
2017-10-19 10:20:19 +02:00
|
|
|
|
|
|
|
QList<VToolSeamAllowance *> SelectedTools() const;
|
2017-10-15 11:25:20 +02:00
|
|
|
|
|
|
|
static void AddPointRecords(VAbstractPattern *doc, QDomElement &domElement, const QVector<quint32> &records,
|
|
|
|
const QString &tag);
|
2016-11-08 11:57:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLSEAMALLOWANCE_H
|