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
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013 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 VPATTERN_H
|
|
|
|
#define VPATTERN_H
|
|
|
|
|
|
|
|
#include "vdomdocument.h"
|
|
|
|
#include "vtoolrecord.h"
|
2014-06-08 20:10:57 +02:00
|
|
|
|
|
|
|
class VDataTool;
|
|
|
|
class VMainGraphicsScene;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-06-12 09:22:29 +02:00
|
|
|
enum class Document : char { LiteParse, FullParse};
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-05-16 16:11:31 +02:00
|
|
|
/*
|
|
|
|
VAL_VERSION is (major << 16) + (minor << 8) + patch.
|
|
|
|
*/
|
|
|
|
// version without patch part
|
|
|
|
#define VAL_MIN_VERSION 0x000100
|
|
|
|
// max support version of format
|
|
|
|
#define VAL_VERSION 0x000100
|
|
|
|
|
2014-05-21 16:40:21 +02:00
|
|
|
#define VAL_STR_VERSION "0.1.0"
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
/**
|
|
|
|
* @brief The VPattern class working with pattern file.
|
|
|
|
*/
|
|
|
|
class VPattern : public QObject, public VDomDocument
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-06-12 09:22:29 +02:00
|
|
|
VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
2014-06-05 13:35:38 +02:00
|
|
|
QObject *parent = nullptr);
|
2014-07-17 14:41:48 +02:00
|
|
|
|
2014-03-16 07:32:52 +01:00
|
|
|
void CreateEmptyFile(const QString &tablePath);
|
2014-06-12 09:22:29 +02:00
|
|
|
void ChangeActivPP(const QString& name, const Document &parse = Document::FullParse);
|
2014-07-17 14:41:48 +02:00
|
|
|
QString GetNameActivPP() const;
|
2014-06-05 11:52:00 +02:00
|
|
|
bool GetActivDrawElement(QDomElement &element) const;
|
2014-06-06 17:06:41 +02:00
|
|
|
bool appendPP(const QString& name);
|
2014-07-17 14:41:48 +02:00
|
|
|
bool ChangeNamePP(const QString& oldName, const QString &newName);
|
|
|
|
QDomElement GetPPElement(const QString &name);
|
|
|
|
bool CheckExistNamePP(const QString& name) const;
|
|
|
|
int CountPP() const;
|
|
|
|
|
2014-06-12 09:22:29 +02:00
|
|
|
void Parse(const Document &parse);
|
2014-02-26 09:18:59 +01:00
|
|
|
QHash<quint32, VDataTool*>* getTools();
|
|
|
|
VDataTool* getTool(const quint32 &id);
|
|
|
|
QVector<VToolRecord> *getHistory();
|
|
|
|
quint32 getCursor() const;
|
2014-02-25 15:40:24 +01:00
|
|
|
void setCursor(const quint32 &value);
|
2014-02-25 15:02:09 +01:00
|
|
|
void setCurrentData();
|
2014-02-25 15:40:24 +01:00
|
|
|
void AddTool(const quint32 &id, VDataTool *tool);
|
|
|
|
void UpdateToolData(const quint32 &id, VContainer *data);
|
|
|
|
void IncrementReferens(quint32 id) const;
|
|
|
|
void DecrementReferens(quint32 id) const;
|
2014-02-25 15:02:09 +01:00
|
|
|
void TestUniqueId() const;
|
2014-02-26 09:18:59 +01:00
|
|
|
quint32 SPointActiveDraw();
|
|
|
|
bool isPatternModified() const;
|
|
|
|
void setPatternModified(bool value);
|
2014-06-05 11:52:00 +02:00
|
|
|
bool GetActivNodeElement(const QString& name, QDomElement& element) const;
|
2014-03-21 11:08:29 +01:00
|
|
|
QString MPath() const;
|
2014-03-24 16:02:57 +01:00
|
|
|
void SetPath(const QString &path);
|
2014-06-12 09:22:29 +02:00
|
|
|
Unit MUnit() const;
|
|
|
|
MeasurementsType MType() const;
|
2014-02-25 19:03:17 +01:00
|
|
|
static const QString TagPattern;
|
2014-02-25 15:02:09 +01:00
|
|
|
static const QString TagCalculation;
|
|
|
|
static const QString TagModeling;
|
|
|
|
static const QString TagDetails;
|
|
|
|
static const QString TagAuthor;
|
|
|
|
static const QString TagDescription;
|
|
|
|
static const QString TagNotes;
|
2014-03-16 07:32:52 +01:00
|
|
|
static const QString TagMeasurements;
|
2014-02-25 15:02:09 +01:00
|
|
|
static const QString TagIncrements;
|
2014-02-25 19:03:17 +01:00
|
|
|
static const QString TagIncrement;
|
2014-02-25 15:02:09 +01:00
|
|
|
static const QString TagDraw;
|
2014-02-25 19:03:17 +01:00
|
|
|
static const QString TagPoint;
|
|
|
|
static const QString TagLine;
|
|
|
|
static const QString TagSpline;
|
|
|
|
static const QString TagArc;
|
|
|
|
static const QString TagTools;
|
2014-02-25 15:02:09 +01:00
|
|
|
static const QString AttrName;
|
2014-02-25 19:03:17 +01:00
|
|
|
static const QString AttrType;
|
2014-03-21 11:08:29 +01:00
|
|
|
static const QString AttrPath;
|
2014-02-25 19:03:17 +01:00
|
|
|
static const QString IncrementName;
|
|
|
|
static const QString IncrementBase;
|
|
|
|
static const QString IncrementKsize;
|
|
|
|
static const QString IncrementKgrowth;
|
|
|
|
static const QString IncrementDescription;
|
2014-03-28 14:11:46 +01:00
|
|
|
virtual bool SaveDocument(const QString &fileName);
|
2014-06-05 13:35:38 +02:00
|
|
|
QStringList getPatternPieces() const;
|
2014-07-12 18:25:25 +02:00
|
|
|
QRectF ActiveDrawBoundingRect() const;
|
2014-07-16 14:37:38 +02:00
|
|
|
quint32 GetParametrId(const QDomElement& domElement) const;
|
2014-02-25 15:02:09 +01:00
|
|
|
signals:
|
|
|
|
/**
|
|
|
|
* @brief ChangedActivDraw change active pattern peace.
|
|
|
|
* @param newName new pattern peace name.
|
|
|
|
*/
|
2014-06-06 17:06:41 +02:00
|
|
|
void ChangedActivPP(const QString &newName);
|
2014-02-25 15:02:09 +01:00
|
|
|
/**
|
2014-07-17 14:41:48 +02:00
|
|
|
* @brief ChangedNameDraw save new name pattern peace.
|
2014-02-25 15:02:09 +01:00
|
|
|
* @param oldName old name.
|
|
|
|
* @param newName new name.
|
|
|
|
*/
|
|
|
|
void ChangedNameDraw(const QString &oldName, const QString &newName);
|
|
|
|
/**
|
|
|
|
* @brief FullUpdateFromFile update tool data form file.
|
|
|
|
*/
|
|
|
|
void FullUpdateFromFile();
|
|
|
|
/**
|
|
|
|
* @brief patternChanged emit if we have unsaved change.
|
|
|
|
*/
|
2014-06-18 18:11:14 +02:00
|
|
|
void patternChanged(bool saved);
|
2014-02-25 15:02:09 +01:00
|
|
|
/**
|
|
|
|
* @brief ShowTool highlight tool.
|
|
|
|
* @param id tool id.
|
|
|
|
* @param color highlight color.
|
|
|
|
* @param enable enable or disable highlight.
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
|
2014-02-25 15:02:09 +01:00
|
|
|
/**
|
|
|
|
* @brief ChangedCursor change cursor position.
|
|
|
|
* @param id tool id.
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
void ChangedCursor(quint32 id);
|
2014-05-30 15:22:03 +02:00
|
|
|
void ClearMainWindow();
|
2014-06-06 12:36:34 +02:00
|
|
|
void UndoCommand();
|
2014-06-24 10:23:39 +02:00
|
|
|
void SetEnabledGUI(bool enabled);
|
2014-02-25 15:02:09 +01:00
|
|
|
public slots:
|
2014-06-05 11:52:00 +02:00
|
|
|
void LiteParseTree();
|
2014-02-25 15:02:09 +01:00
|
|
|
void haveLiteChange();
|
2014-02-25 15:40:24 +01:00
|
|
|
void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable);
|
2014-06-06 12:36:34 +02:00
|
|
|
void NeedFullParsing();
|
2014-06-06 17:06:41 +02:00
|
|
|
void ClearScene();
|
2014-06-24 10:23:39 +02:00
|
|
|
protected:
|
|
|
|
virtual void customEvent(QEvent * event);
|
2014-02-25 15:02:09 +01:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VPattern)
|
2014-06-05 12:02:35 +02:00
|
|
|
|
|
|
|
/** @brief nameActivDraw name current pattern peace. */
|
2014-07-17 14:41:48 +02:00
|
|
|
QString nameActivPP;
|
2014-06-05 12:02:35 +02:00
|
|
|
|
|
|
|
/** @brief tools list with pointer on tools. */
|
2014-02-25 15:40:24 +01:00
|
|
|
QHash<quint32, VDataTool*> tools;
|
2014-06-05 12:02:35 +02:00
|
|
|
|
|
|
|
/** @brief history history records. */
|
2014-02-25 15:02:09 +01:00
|
|
|
QVector<VToolRecord> history;
|
2014-06-05 12:02:35 +02:00
|
|
|
|
|
|
|
/** @brief cursor cursor keep id tool after which we will add new tool in file. */
|
2014-06-05 13:35:38 +02:00
|
|
|
quint32 cursor;
|
2014-06-05 12:02:35 +02:00
|
|
|
|
2014-07-17 14:41:48 +02:00
|
|
|
/** @brief patternPieces list of patern pieces names for combobox*/
|
2014-06-05 13:35:38 +02:00
|
|
|
QStringList patternPieces;
|
2014-06-05 12:02:35 +02:00
|
|
|
|
|
|
|
/** @brief mode current draw mode. */
|
2014-06-12 09:22:29 +02:00
|
|
|
Draw *mode;
|
2014-06-05 12:02:35 +02:00
|
|
|
|
2014-06-05 13:35:38 +02:00
|
|
|
VMainGraphicsScene *sceneDraw;
|
|
|
|
VMainGraphicsScene *sceneDetail;
|
2014-06-05 12:02:35 +02:00
|
|
|
|
2014-06-06 17:06:41 +02:00
|
|
|
void SetActivPP(const QString& name);
|
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);
|
|
|
|
void ParseDetailElement(const QDomElement &domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
const Document &parse);
|
2014-07-16 14:47:31 +02:00
|
|
|
void ParseDetails(const QDomElement &domElement, const Document &parse);
|
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);
|
2014-02-25 15:02:09 +01:00
|
|
|
void ParseSplineElement(VMainGraphicsScene *scene, const 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);
|
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);
|
2014-02-25 15:02:09 +01:00
|
|
|
void ParseIncrementsElement(const QDomNode& node);
|
2014-02-25 15:40:24 +01:00
|
|
|
void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
|
2014-06-12 09:22:29 +02:00
|
|
|
void PrepareForParse(const Document &parse);
|
2014-03-24 16:02:57 +01:00
|
|
|
void UpdateMeasurements();
|
2014-06-12 11:51:40 +02:00
|
|
|
void GarbageCollector();
|
2014-06-18 18:11:14 +02:00
|
|
|
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id);
|
|
|
|
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
|
|
|
|
qreal &my, QString &typeLine);
|
|
|
|
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
|
|
|
|
qreal &my);
|
|
|
|
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my);
|
|
|
|
void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject,
|
|
|
|
quint32 &idTool);
|
2014-07-12 18:25:25 +02:00
|
|
|
template <typename T>
|
|
|
|
QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const;
|
2014-02-25 15:02:09 +01:00
|
|
|
};
|
|
|
|
|
2014-06-05 12:02:35 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
2014-07-17 14:41:48 +02:00
|
|
|
* @brief GetNameActivPP return current pattern piece name.
|
|
|
|
* @return pattern piece name.
|
2014-06-05 12:02:35 +02:00
|
|
|
*/
|
2014-07-17 14:41:48 +02:00
|
|
|
inline QString VPattern::GetNameActivPP() const
|
2014-02-26 09:18:59 +01:00
|
|
|
{
|
2014-07-17 14:41:48 +02:00
|
|
|
return nameActivPP;
|
2014-02-26 09:18:59 +01:00
|
|
|
}
|
|
|
|
|
2014-06-05 12:02:35 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief getTools return list of tools pointers.
|
|
|
|
* @return list.
|
|
|
|
*/
|
2014-02-26 09:18:59 +01:00
|
|
|
inline QHash<quint32, VDataTool *> *VPattern::getTools()
|
|
|
|
{
|
|
|
|
return &tools;
|
|
|
|
}
|
|
|
|
|
2014-06-05 12:02:35 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief getHistory return list with list of history records.
|
|
|
|
* @return list of history records.
|
|
|
|
*/
|
2014-02-26 09:18:59 +01:00
|
|
|
inline QVector<VToolRecord> *VPattern::getHistory()
|
|
|
|
{
|
|
|
|
return &history;
|
|
|
|
}
|
|
|
|
|
2014-06-05 12:02:35 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief getCursor return cursor.
|
|
|
|
* @return cursor.
|
|
|
|
*/
|
2014-02-26 09:18:59 +01:00
|
|
|
inline quint32 VPattern::getCursor() const
|
|
|
|
{
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2014-06-05 13:35:38 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline QStringList VPattern::getPatternPieces() const
|
|
|
|
{
|
|
|
|
return patternPieces;
|
|
|
|
}
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
#endif // VPATTERN_H
|