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 vtoolspline.h
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)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.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <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-08-05 10:37:56 +02:00
|
|
|
#ifndef VTOOLSPLINE_H
|
|
|
|
#define VTOOLSPLINE_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
#include <QGraphicsItem>
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QString>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
|
|
#include "../vgeometry/vgeometrydef.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../vmisc/def.h"
|
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
2014-03-04 17:50:54 +01:00
|
|
|
#include "vabstractspline.h"
|
2017-10-03 12:01:56 +02:00
|
|
|
#include "../vgeometry/vspline.h"
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
template <class T> class QSharedPointer;
|
2016-02-12 19:10:01 +01:00
|
|
|
|
2017-09-21 09:05:58 +02:00
|
|
|
struct VToolSplineInitData : VAbstractSplineInitData
|
2017-09-18 10:37:23 +02:00
|
|
|
{
|
|
|
|
VToolSplineInitData()
|
|
|
|
: VAbstractSplineInitData(),
|
|
|
|
point1(NULL_ID),
|
|
|
|
point4(NULL_ID),
|
|
|
|
a1(),
|
|
|
|
a2(),
|
|
|
|
l1(),
|
|
|
|
l2(),
|
|
|
|
duplicate(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
quint32 point1;
|
|
|
|
quint32 point4;
|
|
|
|
QString a1;
|
|
|
|
QString a2;
|
|
|
|
QString l1;
|
|
|
|
QString l2;
|
|
|
|
quint32 duplicate;
|
|
|
|
};
|
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-27 10:54:33 +01:00
|
|
|
* @brief The VToolSpline class tool for creation spline. I mean bezier curve.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-03-04 17:50:54 +01:00
|
|
|
class VToolSpline:public VAbstractSpline
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-08-01 13:35:48 +02:00
|
|
|
virtual ~VToolSpline() =default;
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
2017-04-15 16:39:59 +02:00
|
|
|
static VToolSpline *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
|
|
|
VContainer *data);
|
2017-09-18 10:37:23 +02:00
|
|
|
static VToolSpline *Create(VToolSplineInitData &initData, VSpline *spline);
|
|
|
|
static VToolSpline *Create(VToolSplineInitData &initData);
|
2013-10-29 14:45:07 +01:00
|
|
|
static const QString ToolType;
|
2016-02-26 15:38:42 +01:00
|
|
|
static const QString OldToolType;
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
2014-08-26 20:31:28 +02:00
|
|
|
enum { Type = UserType + static_cast<int>(Tool::Spline)};
|
2014-09-01 18:36:15 +02:00
|
|
|
|
|
|
|
VSpline getSpline()const;
|
|
|
|
void setSpline(const VSpline &spl);
|
2014-09-03 15:52:16 +02:00
|
|
|
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
2013-08-05 10:37:56 +02:00
|
|
|
public slots:
|
2014-06-13 19:02:41 +02:00
|
|
|
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position,
|
|
|
|
const QPointF &pos);
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
|
2017-09-15 16:32:23 +02:00
|
|
|
protected slots:
|
|
|
|
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
2013-08-05 10:37:56 +02:00
|
|
|
protected:
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
|
|
|
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
|
|
|
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
|
|
|
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
|
|
|
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
2017-06-16 13:53:08 +02:00
|
|
|
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
|
2017-10-03 12:01:56 +02:00
|
|
|
private slots:
|
|
|
|
void CurveReleased();
|
2014-02-06 14:57:23 +01:00
|
|
|
private:
|
2014-10-04 08:37:19 +02:00
|
|
|
Q_DISABLE_COPY(VToolSpline)
|
2015-02-12 11:55:09 +01:00
|
|
|
QPointF oldPosition;
|
2016-02-26 15:38:42 +01:00
|
|
|
|
2017-10-03 12:01:56 +02:00
|
|
|
bool moved;
|
|
|
|
QSharedPointer<VSpline> oldMoveSpline;
|
|
|
|
QSharedPointer<VSpline> newMoveSpline;
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
VToolSpline (VToolSplineInitData initData, QGraphicsItem *parent = nullptr );
|
2016-05-14 21:54:57 +02:00
|
|
|
|
2016-03-05 22:06:54 +01:00
|
|
|
bool IsMovable() const;
|
2016-02-26 15:38:42 +01:00
|
|
|
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
|
2017-10-03 12:01:56 +02:00
|
|
|
|
|
|
|
void UndoCommandMove(const VSpline &oldSpl, const VSpline &newSpl);
|
2013-08-05 10:37:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLSPLINE_H
|