2013-12-29 17:48:57 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vtooluniondetails.h
|
|
|
|
** @author Roman Telezhinsky <dismine@gmail.com>
|
|
|
|
** @date 26 12, 2013
|
|
|
|
**
|
|
|
|
** @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 VTOOLUNIONDETAILS_H
|
|
|
|
#define VTOOLUNIONDETAILS_H
|
|
|
|
|
|
|
|
#include "vabstracttool.h"
|
2014-02-21 14:04:39 +01:00
|
|
|
#include "../dialogs/tools/dialoguniondetails.h"
|
2013-12-29 17:48:57 +01:00
|
|
|
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief The VToolUnionDetails class tool union details.
|
|
|
|
*/
|
2013-12-29 17:48:57 +01:00
|
|
|
class VToolUnionDetails : public VAbstractTool
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief VToolUnionDetails costructor.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data dom document container.
|
|
|
|
* @param id object id in container.
|
|
|
|
* @param d1 first detail.
|
|
|
|
* @param d2 second detail.
|
|
|
|
* @param indexD1 index edge in first detail.
|
|
|
|
* @param indexD2 index edge in second detail.
|
|
|
|
* @param typeCreation way we create this tool.
|
|
|
|
* @param parent parent object.
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
VToolUnionDetails(VPattern *doc, VContainer *data, const quint32 &id, const VDetail &d1, const VDetail &d2,
|
|
|
|
const quint32 &indexD1, const quint32 &indexD2, const Tool::Sources &typeCreation,
|
2014-02-26 10:22:05 +01:00
|
|
|
QObject *parent = nullptr);
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief setDialog set dialog when user want change tool option.
|
|
|
|
*/
|
2013-12-29 17:48:57 +01:00
|
|
|
virtual void setDialog() {}
|
|
|
|
/**
|
2014-01-24 16:10:23 +01:00
|
|
|
* @brief Create help create tool from GUI.
|
|
|
|
* @param dialog dialog.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
2013-12-29 17:48:57 +01:00
|
|
|
*/
|
2014-02-25 15:02:09 +01:00
|
|
|
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
2013-12-29 17:48:57 +01:00
|
|
|
/**
|
2014-01-24 16:10:23 +01:00
|
|
|
* @brief Create help create tool.
|
|
|
|
* @param _id tool id, 0 if tool doesn't exist yet.
|
|
|
|
* @param d1 first detail.
|
|
|
|
* @param d2 second detail.
|
|
|
|
* @param d1id id first detail.
|
|
|
|
* @param d2id id second detail.
|
|
|
|
* @param indexD1 index edge in first detail.
|
|
|
|
* @param indexD2 index edge in second detail.
|
|
|
|
* @param scene pointer to scene.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
|
|
|
* @param parse parser file mode.
|
2014-01-24 15:25:45 +01:00
|
|
|
* @param typeCreation way we create this tool.
|
2013-12-29 17:48:57 +01:00
|
|
|
*/
|
2014-02-26 10:51:37 +01:00
|
|
|
static void Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id,
|
|
|
|
const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, VMainGraphicsScene *scene,
|
|
|
|
VPattern *doc, VContainer *data, const Document::Documents &parse,
|
|
|
|
const Tool::Sources &typeCreation);
|
2014-03-04 13:55:57 +01:00
|
|
|
static void PointsOnEdge(const VDetail &d, const qint32 &index, VPointF &p1, VPointF &p2, VContainer *data);
|
2013-12-29 17:48:57 +01:00
|
|
|
/**
|
2014-01-24 16:10:23 +01:00
|
|
|
* @brief GetDetailFromFile parse detail from file.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
* @return detail stored in file.
|
2013-12-29 17:48:57 +01:00
|
|
|
*/
|
2014-02-25 15:02:09 +01:00
|
|
|
static QVector<VDetail> GetDetailFromFile(VPattern *doc, const QDomElement &domElement);
|
2013-12-29 17:48:57 +01:00
|
|
|
static const QString TagName;
|
|
|
|
static const QString ToolType;
|
|
|
|
static const QString TagDetail;
|
|
|
|
static const QString TagNode;
|
2014-01-02 16:50:01 +01:00
|
|
|
static const QString AttrIndexD1;
|
|
|
|
static const QString AttrIndexD2;
|
2013-12-29 17:48:57 +01:00
|
|
|
static const QString AttrIdObject;
|
|
|
|
static const QString AttrNodeType;
|
|
|
|
static const QString NodeTypeContour;
|
|
|
|
static const QString NodeTypeModeling;
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief AddToNewDetail create united detail adding one node per time.
|
|
|
|
* @param tool tool that make union.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
|
|
|
* @param newDetail united detail.
|
|
|
|
* @param det detail what we union.
|
|
|
|
* @param i index node in detail.
|
|
|
|
* @param idTool id tool union details.
|
|
|
|
* @param dx bias node x axis.
|
|
|
|
* @param dy bias node y axis.
|
|
|
|
* @param pRotate point rotation.
|
|
|
|
* @param angle angle rotation.
|
|
|
|
*/
|
2014-02-25 15:02:09 +01:00
|
|
|
static void AddToNewDetail(QObject *tool, VPattern *doc, VContainer *data, VDetail &newDetail,
|
2014-02-25 15:40:24 +01:00
|
|
|
const VDetail &det, const ptrdiff_t &i, const quint32 &idTool, const qreal &dx = 0,
|
|
|
|
const qreal &dy = 0, const quint32 &pRotate = 0, const qreal &angle = 0);
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief UpdatePoints update data for united details.
|
|
|
|
* @param idDetail id united detail.
|
|
|
|
* @param data container with variables.
|
|
|
|
* @param det detail what we union.
|
|
|
|
* @param i index node in detail.
|
|
|
|
* @param idCount
|
|
|
|
* @param dx bias node x axis.
|
|
|
|
* @param dy bias node y axis.
|
|
|
|
* @param pRotate point rotation.
|
|
|
|
* @param angle angle rotation.
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
static void UpdatePoints(const quint32 &idDetail, VContainer *data, const VDetail &det, const ptrdiff_t &i,
|
|
|
|
quint32 &idCount, const qreal &dx = 0, const qreal &dy = 0, const quint32 &pRotate = 0,
|
2014-01-02 16:50:01 +01:00
|
|
|
const qreal &angle = 0);
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief BiasRotatePoint bias and rotate point.
|
|
|
|
* @param point point.
|
|
|
|
* @param dx bias x axis.
|
|
|
|
* @param dy bias y axis.
|
|
|
|
* @param pRotate point rotation.
|
|
|
|
* @param angle angle rotation.
|
|
|
|
*/
|
2014-01-02 16:50:01 +01:00
|
|
|
static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
|
|
|
|
const qreal angle);
|
2013-12-29 17:48:57 +01:00
|
|
|
public slots:
|
|
|
|
/**
|
2014-01-24 13:54:29 +01:00
|
|
|
* @brief FullUpdateFromFile update tool data form file.
|
2013-12-29 17:48:57 +01:00
|
|
|
*/
|
|
|
|
virtual void FullUpdateFromFile (){}
|
|
|
|
protected:
|
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief AddToFile add tag with informations about tool into file.
|
2013-12-29 17:48:57 +01:00
|
|
|
*/
|
|
|
|
virtual void AddToFile();
|
|
|
|
/**
|
|
|
|
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
|
|
|
|
*/
|
|
|
|
virtual void RefreshDataInFile();
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VToolUnionDetails)
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief d1 first detail.
|
|
|
|
*/
|
2013-12-29 17:48:57 +01:00
|
|
|
VDetail d1;
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief d2 second detail.
|
|
|
|
*/
|
2013-12-29 17:48:57 +01:00
|
|
|
VDetail d2;
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief indexD1 index edge in first detail.
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 indexD1;
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief indexD2 index edge in second detail.
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 indexD2;
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief AddDetail add detail to xml file.
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
* @param d detail.
|
|
|
|
*/
|
2013-12-29 17:48:57 +01:00
|
|
|
void AddDetail(QDomElement &domElement, VDetail &d);
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief AddNode add node to xml file.
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
* @param node node.
|
|
|
|
*/
|
2014-01-02 16:50:01 +01:00
|
|
|
void AddNode(QDomElement &domElement, const VNodeDetail &node);
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief UpdateDetail update detail in xml tree.
|
|
|
|
* @param domNode dom node.
|
|
|
|
* @param d detail.
|
|
|
|
* @return return next detail tag in xml tree if exist.
|
|
|
|
*/
|
2014-01-02 16:50:01 +01:00
|
|
|
QDomNode UpdateDetail(const QDomNode &domNode, const VDetail &d);
|
2014-01-24 16:10:23 +01:00
|
|
|
/**
|
|
|
|
* @brief AddToModeling add tool to xml tree.
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
*/
|
2013-12-29 17:48:57 +01:00
|
|
|
void AddToModeling(const QDomElement &domElement);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLUNIONDETAILS_H
|