2014-02-25 15:02:09 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vpattern.h
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2014-02-25 15:02:09 +01:00
|
|
|
** @date 24 2, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2014-02-25 15:02:09 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-02-25 15:02:09 +01:00
|
|
|
** <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 VPATTERN_H
|
|
|
|
#define VPATTERN_H
|
|
|
|
|
2015-07-10 11:24:47 +02:00
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
|
|
|
#include "../ifc/xml/vtoolrecord.h"
|
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2016-07-07 17:04:26 +02:00
|
|
|
#include "../ifc/xml/vpatternconverter.h"
|
2014-06-08 20:10:57 +02:00
|
|
|
|
|
|
|
class VMainGraphicsScene;
|
2017-01-21 18:12:57 +01:00
|
|
|
class VNodeDetail;
|
2017-09-20 18:41:12 +02:00
|
|
|
struct VToolSinglePointInitData;
|
|
|
|
struct VToolLinePointInitData;
|
2018-11-19 10:07:31 +01:00
|
|
|
class VToolSeamAllowance;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The VPattern class working with pattern file.
|
|
|
|
*/
|
2015-06-16 10:30:25 +02:00
|
|
|
class VPattern : public VAbstractPattern
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-07-25 10:26:09 +02:00
|
|
|
VPattern(VContainer *data, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
2014-06-05 13:35:38 +02:00
|
|
|
QObject *parent = nullptr);
|
2014-07-17 14:41:48 +02:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void CreateEmptyFile() override;
|
2014-07-17 14:41:48 +02:00
|
|
|
|
2014-06-12 09:22:29 +02:00
|
|
|
void Parse(const Document &parse);
|
2015-06-16 10:30:25 +02:00
|
|
|
|
2018-05-09 17:09:40 +02:00
|
|
|
void GarbageCollector(bool commit = false);
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
void setCurrentData();
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void UpdateToolData(const quint32 &id, VContainer *data) override;
|
2017-09-25 15:36:04 +02:00
|
|
|
VContainer GetCompleteData() const;
|
2014-08-07 13:17:24 +02:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void IncrementReferens(quint32 id) const override;
|
|
|
|
virtual void DecrementReferens(quint32 id) const override;
|
2014-08-07 13:17:24 +02:00
|
|
|
|
2015-06-16 10:30:25 +02:00
|
|
|
quint32 SPointActiveDraw();
|
2014-08-07 13:17:24 +02:00
|
|
|
|
2016-11-23 17:41:01 +01:00
|
|
|
QVector<quint32> GetActivePPPieces() const;
|
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual bool SaveDocument(const QString &fileName, QString &error) override;
|
2014-08-08 18:07:44 +02:00
|
|
|
|
2015-06-16 11:04:48 +02:00
|
|
|
QRectF ActiveDrawBoundingRect() const;
|
2014-08-08 18:07:44 +02:00
|
|
|
|
2019-01-16 15:24:41 +01:00
|
|
|
void AddEmptyIncrement(const QString &name, IncrementType type = IncrementType::Increment);
|
|
|
|
void AddEmptyPreviewCalculation(const QString &name, IncrementType type = IncrementType::Increment);
|
2017-09-02 13:47:44 +02:00
|
|
|
|
2019-01-16 15:24:41 +01:00
|
|
|
void AddEmptyIncrementAfter(const QString &after, const QString &name,
|
|
|
|
IncrementType type = IncrementType::Increment);
|
|
|
|
void AddEmptyPreviewCalculationAfter(const QString &after, const QString &name,
|
|
|
|
IncrementType type = IncrementType::Increment);
|
2017-09-02 13:47:44 +02:00
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
void RemoveIncrement(const QString &name);
|
2017-09-02 13:47:44 +02:00
|
|
|
void RemovePreviewCalculation(const QString &name);
|
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
void MoveUpIncrement(const QString &name);
|
2017-09-02 13:47:44 +02:00
|
|
|
void MoveUpPreviewCalculation(const QString &name);
|
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
void MoveDownIncrement(const QString &name);
|
2017-09-02 13:47:44 +02:00
|
|
|
void MoveDownPreviewCalculation(const QString &name);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
|
|
|
void SetIncrementName(const QString &name, const QString &text);
|
|
|
|
void SetIncrementFormula(const QString &name, const QString &text);
|
|
|
|
void SetIncrementDescription(const QString &name, const QString &text);
|
|
|
|
|
2017-08-08 16:43:41 +02:00
|
|
|
void ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName);
|
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const override;
|
|
|
|
virtual QString GenerateSuffix() const override;
|
2014-11-10 15:49:39 +01:00
|
|
|
|
2015-12-11 15:19:11 +01:00
|
|
|
bool IsDefCustom() const;
|
|
|
|
void SetDefCustom(bool value);
|
|
|
|
|
|
|
|
int GetDefCustomHeight() const;
|
|
|
|
void SetDefCustomHeight(int value);
|
|
|
|
|
|
|
|
int GetDefCustomSize() const;
|
|
|
|
void SetDefCustomSize(int value);
|
|
|
|
|
2016-01-22 11:45:18 +01:00
|
|
|
bool IsReadOnly() const;
|
|
|
|
void SetReadOnly(bool rOnly);
|
|
|
|
|
2019-01-14 16:38:59 +01:00
|
|
|
QString GetLabelPrefix() const;
|
|
|
|
void SetLabelPrefix(const QString &prefix);
|
|
|
|
|
2017-07-23 15:52:57 +02:00
|
|
|
void LiteParseIncrements();
|
|
|
|
|
2016-01-22 11:45:18 +01:00
|
|
|
static const QString AttrReadOnly;
|
2019-01-14 16:38:59 +01:00
|
|
|
static const QString AttrLabelPrefix;
|
2016-01-22 11:45:18 +01:00
|
|
|
|
2018-01-22 13:26:53 +01:00
|
|
|
int ElementsToParse() const;
|
|
|
|
|
2019-11-28 14:17:27 +01:00
|
|
|
signals:
|
|
|
|
void PreParseState();
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
public slots:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void LiteParseTree(const Document &parse) override;
|
2015-06-16 11:04:48 +02:00
|
|
|
|
2014-06-24 10:23:39 +02:00
|
|
|
protected:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void customEvent(QEvent * event) override;
|
2015-06-16 11:04:48 +02:00
|
|
|
|
2018-11-19 10:07:31 +01:00
|
|
|
private slots:
|
|
|
|
void RefreshPieceGeometry();
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VPattern)
|
2014-06-05 12:02:35 +02:00
|
|
|
|
2014-12-10 19:33:20 +01:00
|
|
|
/** @brief data container with data. */
|
|
|
|
VContainer *data;
|
|
|
|
|
2014-06-05 13:35:38 +02:00
|
|
|
VMainGraphicsScene *sceneDraw;
|
|
|
|
VMainGraphicsScene *sceneDetail;
|
2019-11-14 09:52:07 +01:00
|
|
|
QVector<vidtype> updatePieces{};
|
2014-06-05 12:02:35 +02:00
|
|
|
|
2019-05-28 10:36:03 +02:00
|
|
|
/**
|
|
|
|
* @brief m_parsing true if parsing a pattern. Helps to stop updating piece when new parsing happend before
|
|
|
|
* finish */
|
|
|
|
bool m_parsing{false};
|
|
|
|
|
2016-12-01 19:47:15 +01:00
|
|
|
VNodeDetail ParseDetailNode(const QDomElement &domElement) const;
|
2016-11-28 10:58:44 +01:00
|
|
|
|
2014-07-16 14:47:31 +02:00
|
|
|
void ParseDrawElement(const QDomNode& node, const Document &parse);
|
|
|
|
void ParseDrawMode(const QDomNode& node, const Document &parse, const Draw &mode);
|
2017-01-21 14:24:40 +01:00
|
|
|
void ParseDetailElement(QDomElement &domElement, const Document &parse);
|
2018-01-25 22:53:53 +01:00
|
|
|
void ParseDetailInternals(const QDomElement &domElement, VPiece &detail) const;
|
|
|
|
QVector<VPieceNode> ParseDetailNodes(const QDomElement &domElement, qreal width, bool closed) const;
|
|
|
|
VPieceLabelData ParsePieceDataTag(const QDomElement &domElement, VPieceLabelData ppData) const;
|
|
|
|
VPatternLabelData ParsePiecePatternInfo(const QDomElement &domElement, VPatternLabelData patternInfo) const;
|
|
|
|
VGrainlineData ParsePieceGrainline(const QDomElement &domElement, VGrainlineData gGeometry) const;
|
2014-07-16 14:47:31 +02:00
|
|
|
void ParseDetails(const QDomElement &domElement, const Document &parse);
|
2016-04-06 11:03:34 +02:00
|
|
|
|
2014-05-30 10:32:40 +02:00
|
|
|
void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
const Document &parse, const QString &type);
|
2014-02-25 15:02:09 +01:00
|
|
|
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
const Document &parse);
|
2016-02-26 15:38:42 +01:00
|
|
|
void ParseSplineElement(VMainGraphicsScene *scene, QDomElement &domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
const Document &parse, const QString& type);
|
2014-05-30 13:50:41 +02:00
|
|
|
void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
const Document &parse, const QString& type);
|
2016-12-17 02:53:47 +01:00
|
|
|
void ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
|
2016-12-20 15:51:58 +01:00
|
|
|
const QString &type);
|
2014-02-25 15:02:09 +01:00
|
|
|
void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
const Document &parse, const QString& type);
|
2016-05-16 19:27:51 +02:00
|
|
|
void ParseOperationElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
|
|
|
|
const QString& type);
|
2016-11-24 20:35:54 +01:00
|
|
|
|
|
|
|
void ParsePathElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
|
2018-01-22 13:26:53 +01:00
|
|
|
void ParseIncrementsElement(const QDomNode& node, const Document &parse);
|
2014-06-12 09:22:29 +02:00
|
|
|
void PrepareForParse(const Document &parse);
|
2014-06-18 18:11:14 +02:00
|
|
|
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id);
|
2017-09-18 10:37:23 +02:00
|
|
|
void PointsWithLineCommonAttributes(const QDomElement &domElement, VToolLinePointInitData &initData);
|
|
|
|
void PointsCommonAttributes(const QDomElement &domElement, VToolSinglePointInitData &initData);
|
2014-06-18 18:11:14 +02:00
|
|
|
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my);
|
|
|
|
void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject,
|
|
|
|
quint32 &idTool);
|
2016-03-19 09:38:29 +01:00
|
|
|
template <typename T>
|
2019-01-17 09:36:37 +01:00
|
|
|
QRectF ToolBoundingRect(const QRectF &rec, quint32 id) const;
|
2014-07-30 11:03:50 +02:00
|
|
|
void ParseCurrentPP();
|
2015-10-26 09:36:07 +01:00
|
|
|
QString GetLabelBase(quint32 index)const;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
void ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolAlongLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolShoulderPoint(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolNormal(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolLineIntersect(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2015-06-25 12:52:09 +02:00
|
|
|
void ParseNodePoint(const QDomElement &domElement, const Document &parse);
|
2017-01-31 15:04:51 +01:00
|
|
|
void ParsePinPoint(const QDomElement &domElement, const Document &parse);
|
2017-10-15 11:25:20 +02:00
|
|
|
void ParsePlaceLabel(QDomElement &domElement, const Document &parse);
|
2015-06-24 18:14:26 +02:00
|
|
|
void ParseToolHeight(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolTriangle(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolPointOfIntersection(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolPointOfIntersectionArcs(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
const Document &parse);
|
2016-01-24 17:15:08 +01:00
|
|
|
void ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseToolPointOfIntersectionCurves(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2015-06-24 18:14:26 +02:00
|
|
|
void ParseToolPointFromCircleAndTangent(VMainGraphicsScene *scene, QDomElement &domElement,
|
|
|
|
const Document &parse);
|
|
|
|
void ParseToolPointFromArcAndTangent(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
const Document &parse);
|
|
|
|
void ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
|
|
|
|
2016-02-26 15:38:42 +01:00
|
|
|
// TODO. Delete if minimal supported version is 0.2.7
|
2018-07-26 20:21:08 +02:00
|
|
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 2, 7),
|
2016-07-07 17:04:26 +02:00
|
|
|
"Time to refactor the code.");
|
2016-02-26 15:38:42 +01:00
|
|
|
void ParseOldToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
|
|
|
|
|
|
|
void ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2016-03-10 14:55:04 +01:00
|
|
|
void ParseToolCubicBezier(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
// TODO. Delete if minimal supported version is 0.2.7
|
2018-07-26 20:21:08 +02:00
|
|
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 2, 7),
|
2016-07-07 17:04:26 +02:00
|
|
|
"Time to refactor the code.");
|
2016-03-04 17:08:29 +01:00
|
|
|
void ParseOldToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
void ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
2016-03-18 22:11:14 +01:00
|
|
|
void ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
2015-06-25 12:52:09 +02:00
|
|
|
void ParseNodeSpline(const QDomElement &domElement, const Document &parse);
|
|
|
|
void ParseNodeSplinePath(const QDomElement &domElement, const Document &parse);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
void ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2015-06-25 12:52:09 +02:00
|
|
|
void ParseNodeArc(const QDomElement &domElement, const Document &parse);
|
2015-06-24 18:14:26 +02:00
|
|
|
void ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
2016-12-17 02:53:47 +01:00
|
|
|
void ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2016-12-20 15:51:58 +01:00
|
|
|
void ParseNodeEllipticalArc(const QDomElement &domElement, const Document &parse);
|
2016-12-17 02:53:47 +01:00
|
|
|
|
2016-05-16 19:27:51 +02:00
|
|
|
void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2016-09-13 10:27:44 +02:00
|
|
|
void ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2016-09-17 11:10:03 +02:00
|
|
|
void ParseToolFlippingByAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2016-10-04 16:34:37 +02:00
|
|
|
void ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
2016-05-16 19:27:51 +02:00
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
|
|
|
|
|
2019-01-16 15:24:41 +01:00
|
|
|
QDomElement MakeEmptyIncrement(const QString &name, IncrementType type);
|
2015-08-25 12:35:50 +02:00
|
|
|
QDomElement FindIncrement(const QString &name) const;
|
2015-12-26 14:08:41 +01:00
|
|
|
|
2019-01-16 15:24:41 +01:00
|
|
|
void NewEmptyIncrement(const QString &type, const QString &name, IncrementType varType);
|
|
|
|
void NewEmptyIncrementAfter(const QString &type, const QString &after, const QString &name, IncrementType varType);
|
2017-09-02 13:47:44 +02:00
|
|
|
void RemoveIncrement(const QString &type, const QString &name);
|
|
|
|
void MoveUpIncrement(const QString &type, const QString &name);
|
|
|
|
void MoveDownIncrement(const QString &type, const QString &name);
|
2017-09-02 14:37:52 +02:00
|
|
|
|
|
|
|
void SetIncrementAttribute(const QString &name, const QString &attr, const QString &text);
|
2017-09-25 15:36:04 +02:00
|
|
|
|
|
|
|
QString LastDrawName() const;
|
|
|
|
quint32 LastToolId() const;
|
2014-02-25 15:02:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VPATTERN_H
|