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
|
|
|
|
|
|
|
#include "vabstracttool.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
|
|
|
|
2016-12-03 17:51:36 +01:00
|
|
|
class VToolSeamAllowance : public VAbstractTool, public QGraphicsPathItem
|
2016-11-08 11:57:01 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
virtual ~VToolSeamAllowance();
|
|
|
|
|
|
|
|
static VToolSeamAllowance* Create(DialogTool *m_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,
|
|
|
|
const Source &typeCreation, const QString &m_drawName = QString());
|
|
|
|
|
|
|
|
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-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;
|
|
|
|
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);
|
|
|
|
|
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;
|
|
|
|
public slots:
|
2017-01-12 14:51:08 +01:00
|
|
|
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
|
|
|
virtual void FullUpdateFromGuiOk(int result);
|
|
|
|
void FullUpdateFromGuiApply();
|
|
|
|
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);
|
|
|
|
protected slots:
|
|
|
|
virtual void UpdateLabel();
|
|
|
|
virtual void UpdatePatternInfo();
|
|
|
|
virtual void UpdateGrainline();
|
|
|
|
virtual void SaveMoveDetail(const QPointF &ptPos);
|
|
|
|
virtual void SaveResizeDetail(qreal dLabelW, int iFontSize);
|
|
|
|
virtual void SaveRotationDetail(qreal dRot);
|
|
|
|
virtual void SaveMovePattern(const QPointF& ptPos);
|
|
|
|
virtual void SaveResizePattern(qreal dLabelW, int iFontSize);
|
|
|
|
virtual void SaveRotationPattern(qreal dRot);
|
|
|
|
virtual void SaveMoveGrainline(const QPointF& ptPos);
|
|
|
|
virtual void SaveResizeGrainline(qreal dLength);
|
|
|
|
virtual void SaveRotateGrainline(qreal dRot, const QPointF& ptPos);
|
2016-11-08 11:57:01 +01:00
|
|
|
protected:
|
2017-01-12 14:51:08 +01:00
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget) Q_DECL_OVERRIDE;
|
2016-11-08 11:57:01 +01:00
|
|
|
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;
|
2016-11-08 11:57:01 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VToolSeamAllowance)
|
|
|
|
|
|
|
|
/** @brief dialog dialog options. */
|
2016-11-09 13:11:58 +01:00
|
|
|
QPointer<DialogTool> m_dialog;
|
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;
|
2016-11-10 13:06:09 +01:00
|
|
|
|
2016-11-08 11:57:01 +01:00
|
|
|
void SetDialog();
|
|
|
|
|
|
|
|
VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
|
|
|
|
VMainGraphicsScene *scene, const QString &m_drawName, QGraphicsItem * parent = nullptr);
|
|
|
|
|
2016-11-09 15:27:55 +01:00
|
|
|
void RefreshGeometry();
|
|
|
|
void SaveDialogChange();
|
2017-02-27 13:30:02 +01:00
|
|
|
VPieceItem::MoveType FindLabelGeometry(const VPatternLabelData &labelData, qreal &labelWidth, qreal &labelHeight,
|
|
|
|
QPointF &pos);
|
|
|
|
VPieceItem::MoveType 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);
|
|
|
|
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);
|
2016-11-25 15:37:32 +01:00
|
|
|
|
2016-11-08 11:57:01 +01:00
|
|
|
template <typename Tool>
|
2016-11-25 15:41:52 +01:00
|
|
|
Tool* InitTool(VMainGraphicsScene *scene, quint32 toolId);
|
2016-11-08 11:57:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLSEAMALLOWANCE_H
|