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(),
|
2018-04-12 12:13:19 +02:00
|
|
|
width('0'),
|
2017-09-18 10:37:23 +02:00
|
|
|
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
|
|
|
|
2018-07-24 13:57:41 +02:00
|
|
|
static VToolSeamAllowance* Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene,
|
2017-04-15 16:39:59 +02:00
|
|
|
VAbstractPattern *doc, VContainer *data);
|
2017-09-18 10:37:23 +02:00
|
|
|
static VToolSeamAllowance* Create(VToolSeamAllowanceInitData &initData);
|
2018-07-24 13:57:41 +02:00
|
|
|
static VToolSeamAllowance* Duplicate(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene,
|
2017-10-26 15:57:52 +02:00
|
|
|
VAbstractPattern *doc);
|
2017-10-25 16:49:04 +02:00
|
|
|
static VToolSeamAllowance* Duplicate(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
|
|
|
|
2018-02-03 13:18:32 +01:00
|
|
|
|
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);
|
2019-02-11 12:25:27 +01:00
|
|
|
static void AddCSARecord(VAbstractPattern *doc, QDomElement &domElement, CustomSARecord record);
|
2016-11-25 13:19:44 +01:00
|
|
|
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-11-21 10:55:37 +01:00
|
|
|
void RefreshGeometry(bool updateChildren = true);
|
2017-10-18 10:24:15 +02:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual int type() const override {return Type;}
|
2016-11-08 11:57:01 +01:00
|
|
|
enum { Type = UserType + static_cast<int>(Tool::Piece)};
|
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual QString getTagName() const override;
|
|
|
|
virtual void ShowVisualization(bool show) override;
|
|
|
|
virtual void GroupVisibility(quint32 object, bool visible) override;
|
2017-08-01 11:57:19 +02:00
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
2018-06-26 14:53:48 +02:00
|
|
|
QWidget *widget) override;
|
|
|
|
virtual QRectF boundingRect() const override;
|
|
|
|
virtual QPainterPath shape() const override;
|
2016-11-08 11:57:01 +01:00
|
|
|
public slots:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void FullUpdateFromGuiApply() override;
|
|
|
|
virtual void FullUpdateFromFile () override;
|
2017-01-12 14:51:08 +01:00
|
|
|
void EnableToolMove(bool move);
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void AllowHover(bool enabled) override;
|
|
|
|
virtual void AllowSelecting(bool enabled) override;
|
2017-01-12 14:51:08 +01:00
|
|
|
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:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void AddToFile () override;
|
|
|
|
virtual void RefreshDataInFile() override;
|
|
|
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) override;
|
|
|
|
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event) override;
|
|
|
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) override;
|
|
|
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) override;
|
|
|
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) override;
|
|
|
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) override;
|
|
|
|
virtual void keyReleaseEvent(QKeyEvent * event) override;
|
|
|
|
virtual void SetVisualization() override {}
|
|
|
|
virtual void DeleteToolWithConfirm(bool ask = true) override;
|
|
|
|
virtual void ToolCreation(const Source &typeCreation) override;
|
|
|
|
virtual void SetDialog() final;
|
|
|
|
virtual void SaveDialogChange(const QString &undoText = QString()) final;
|
2016-11-08 11:57:01 +01:00
|
|
|
|
2017-10-27 10:53:35 +02:00
|
|
|
private slots:
|
|
|
|
void ShowOptions();
|
|
|
|
void ToggleInLayout(bool checked);
|
2018-02-03 13:18:32 +01:00
|
|
|
void ToggleForbidFlipping(bool checked);
|
|
|
|
void ToggleForceFlipping(bool checked);
|
2017-10-27 10:53:35 +02:00
|
|
|
void DeleteFromMenu();
|
2017-10-27 13:02:17 +02:00
|
|
|
void ToggleExcludeState(quint32 id);
|
2018-09-01 11:21:29 +02:00
|
|
|
void ToggleNodePointAngleType(quint32 id, PieceNodeAngle type);
|
2018-10-22 14:06:32 +02:00
|
|
|
void ToggleNodePointPassmark(quint32 id, bool toggle);
|
2017-10-27 10:53:35 +02:00
|
|
|
|
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-10-30 10:08:25 +01:00
|
|
|
bool m_acceptHoverEvents;
|
|
|
|
|
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-11-21 10:55:37 +01:00
|
|
|
void UpdateInternalPaths();
|
2017-04-15 16:39:59 +02:00
|
|
|
|
2019-02-24 05:58:35 +01:00
|
|
|
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, const QVector<quint32> &pins,
|
|
|
|
qreal &rotationAngle, qreal &labelWidth, qreal &labelHeight, QPointF &pos);
|
|
|
|
VPieceItem::MoveTypes FindGrainlineGeometry(const VGrainlineData &geom, const QVector<quint32> &pins, 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
|
|
|
|
2019-02-24 05:58:35 +01:00
|
|
|
bool PrepareLabelData(const VPatternLabelData &labelData, const QVector<quint32> &pins,
|
|
|
|
VTextGraphicsItem *labelItem, QPointF &pos, qreal &labelAngle);
|
2017-04-27 13:30:20 +02:00
|
|
|
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);
|
2017-10-26 15:57:52 +02:00
|
|
|
|
|
|
|
static QVector<VPieceNode> DuplicateNodes(const VPiecePath &path, const VToolSeamAllowanceInitData &initData,
|
|
|
|
QMap<quint32, quint32> &replacements);
|
|
|
|
static quint32 DuplicateNode(const VPieceNode &node, const VToolSeamAllowanceInitData &initData);
|
|
|
|
|
|
|
|
static quint32 DuplicatePiecePath(quint32 id, const VToolSeamAllowanceInitData &initData);
|
|
|
|
|
|
|
|
static QVector<CustomSARecord> DuplicateCustomSARecords(const QVector<CustomSARecord> &records,
|
|
|
|
const VToolSeamAllowanceInitData &initData,
|
|
|
|
const QMap<quint32, quint32> &replacements);
|
|
|
|
|
|
|
|
static QVector<quint32> DuplicateInternalPaths(const QVector<quint32> &iPaths,
|
|
|
|
const VToolSeamAllowanceInitData &initData);
|
|
|
|
static QVector<quint32> DuplicatePins(const QVector<quint32> &pins, const VToolSeamAllowanceInitData &initData);
|
|
|
|
static QVector<quint32> DuplicatePlaceLabels(const QVector<quint32> &placeLabels,
|
|
|
|
const VToolSeamAllowanceInitData &initData);
|
2016-11-08 11:57:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLSEAMALLOWANCE_H
|