2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vabstracttool.h
|
2013-11-15 13:41:26 +01:00
|
|
|
** @author Roman Telezhinsky <dismine@gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @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.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-07-25 20:39:51 +02:00
|
|
|
#ifndef VABSTRACTTOOL_H
|
|
|
|
#define VABSTRACTTOOL_H
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
#include "vdatatool.h"
|
2013-11-06 16:49:07 +01:00
|
|
|
#include "../xml/vdomdocument.h"
|
2013-07-25 20:39:51 +02:00
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief The VAbstractTool class
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
class VAbstractTool: public VDataTool
|
|
|
|
{
|
2013-07-25 20:39:51 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief VAbstractTool
|
|
|
|
* @param doc dom document container
|
|
|
|
* @param data
|
|
|
|
* @param id
|
|
|
|
* @param parent
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0);
|
2013-10-29 14:45:07 +01:00
|
|
|
virtual ~VAbstractTool() {}
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief LineIntersectRect
|
|
|
|
* @param rec
|
|
|
|
* @param line
|
|
|
|
* @return
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
static QPointF LineIntersectRect(QRectF rec, QLineF line);
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief LineIntersectCircle
|
|
|
|
* @param center
|
|
|
|
* @param radius
|
|
|
|
* @param line
|
|
|
|
* @param p1
|
|
|
|
* @param p2
|
|
|
|
* @return
|
|
|
|
*/
|
2013-11-06 22:11:12 +01:00
|
|
|
static qint32 LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1,
|
|
|
|
QPointF &p2);
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief ClosestPoint
|
|
|
|
* @param line
|
|
|
|
* @param p
|
|
|
|
* @return
|
|
|
|
*/
|
2013-11-06 22:11:12 +01:00
|
|
|
static QPointF ClosestPoint(const QLineF &line, const QPointF &p);
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief addVector
|
|
|
|
* @param p
|
|
|
|
* @param p1
|
|
|
|
* @param p2
|
|
|
|
* @param k
|
|
|
|
* @return
|
|
|
|
*/
|
2013-11-06 22:11:12 +01:00
|
|
|
static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k);
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief getId
|
|
|
|
* @return
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
inline qint64 getId() const {return id;}
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief LineCoefficients
|
|
|
|
* @param line
|
|
|
|
* @param a
|
|
|
|
* @param b
|
|
|
|
* @param c
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrId
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrId;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrType
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrType;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrMx
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrMx;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrMy
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrMy;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrName
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrName;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrX
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrX;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrY
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrY;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrTypeLine
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrTypeLine;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrLength
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrLength;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrBasePoint
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrBasePoint;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrFirstPoint
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrFirstPoint;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrSecondPoint
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrSecondPoint;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrThirdPoint
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrThirdPoint;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrCenter
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrCenter;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrRadius
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrRadius;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrAngle
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrAngle;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrAngle1
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrAngle1;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrAngle2
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrAngle2;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrP1Line
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrP1Line;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrP2Line
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrP2Line;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrP1Line1
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrP1Line1;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrP2Line1
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrP2Line1;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrP1Line2
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrP1Line2;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrP2Line2
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrP2Line2;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrPShoulder
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrPShoulder;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrPoint1
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrPoint1;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrPoint4
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrPoint4;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrKAsm1
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrKAsm1;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrKAsm2
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrKAsm2;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrKCurve
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrKCurve;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrPathPoint
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrPathPoint;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrPSpline
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrPSpline;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrAxisP1
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrAxisP1;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AttrAxisP2
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString AttrAxisP2;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief TypeLineNone
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString TypeLineNone;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief TypeLineLine
|
|
|
|
*/
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString TypeLineLine;
|
2013-07-25 20:39:51 +02:00
|
|
|
public slots:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief FullUpdateFromFile
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
virtual void FullUpdateFromFile()=0;
|
2013-07-25 20:39:51 +02:00
|
|
|
signals:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief toolhaveChange
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
void toolhaveChange();
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief ChoosedTool
|
|
|
|
* @param id
|
|
|
|
* @param type
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
void ChoosedTool(qint64 id, Scene::Scenes type);
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief FullUpdateTree
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
void FullUpdateTree();
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief RemoveTool
|
|
|
|
* @param tool
|
|
|
|
*/
|
2013-10-29 16:01:56 +01:00
|
|
|
void RemoveTool(QGraphicsItem *tool);
|
2013-07-25 20:39:51 +02:00
|
|
|
protected:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief doc dom document container
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
VDomDocument *doc;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief id
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
const qint64 id;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief baseColor
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
const Qt::GlobalColor baseColor;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief currentColor
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
Qt::GlobalColor currentColor;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AddToFile
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
virtual void AddToFile()=0;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief getData
|
|
|
|
* @return
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
inline const VContainer *getData() const {return &data;}
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief RemoveReferens
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
virtual void RemoveReferens(){}
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief RemoveAllChild
|
|
|
|
* @param domElement
|
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
void RemoveAllChild(QDomElement &domElement);
|
2013-10-29 14:45:07 +01:00
|
|
|
template <typename T>
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief AddAttribute
|
|
|
|
* @param domElement
|
|
|
|
* @param name
|
|
|
|
* @param value
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void AddAttribute(QDomElement &domElement, const QString &name, const T &value)
|
|
|
|
{
|
2013-10-29 14:45:07 +01:00
|
|
|
QDomAttr domAttr = doc->createAttribute(name);
|
|
|
|
domAttr.setValue(QString().setNum(value));
|
|
|
|
domElement.setAttributeNode(domAttr);
|
|
|
|
}
|
2013-08-20 12:26:02 +02:00
|
|
|
private:
|
2013-09-26 20:50:52 +02:00
|
|
|
Q_DISABLE_COPY(VAbstractTool)
|
2013-07-25 20:39:51 +02:00
|
|
|
};
|
2013-10-29 14:45:07 +01:00
|
|
|
|
|
|
|
template <>
|
2013-11-04 21:35:15 +01:00
|
|
|
inline void VAbstractTool::AddAttribute<QString>(QDomElement &domElement, const QString &name, const QString &value)
|
|
|
|
{
|
2013-10-29 14:45:07 +01:00
|
|
|
QDomAttr domAttr = doc->createAttribute(name);
|
|
|
|
domAttr.setValue(value);
|
|
|
|
domElement.setAttributeNode(domAttr);
|
|
|
|
}
|
2013-07-25 20:39:51 +02:00
|
|
|
#endif // VABSTRACTTOOL_H
|