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 vtooldetail.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-28 10:55:11 +02:00
|
|
|
#ifndef VTOOLDETAIL_H
|
|
|
|
#define VTOOLDETAIL_H
|
|
|
|
|
|
|
|
#include "vabstracttool.h"
|
2016-01-10 14:31:43 +01:00
|
|
|
#include "../vwidgets/vnobrushscalepathitem.h"
|
2014-06-08 20:10:57 +02:00
|
|
|
|
|
|
|
class VMainGraphicsScene;
|
|
|
|
class DialogTool;
|
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief The VToolDetail class for working with detail.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2016-01-10 14:31:43 +01:00
|
|
|
class VToolDetail: public VAbstractTool, public VNoBrushScalePathItem
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-06-18 19:23:24 +02:00
|
|
|
VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
|
2016-01-07 17:43:08 +01:00
|
|
|
VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem * parent = nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
~VToolDetail();
|
2014-06-14 08:42:01 +02:00
|
|
|
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void setDialog();
|
2013-12-31 09:28:53 +01:00
|
|
|
template<typename T>
|
2014-01-24 15:25:45 +01:00
|
|
|
/**
|
|
|
|
* @brief CreateNode create new node for detail.
|
|
|
|
* @param data container.
|
|
|
|
* @param id id parent object.
|
|
|
|
* @return id for new object.
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
static quint32 CreateNode(VContainer *data, const quint32 &id)
|
2013-12-31 09:28:53 +01:00
|
|
|
{
|
2014-01-24 15:25:45 +01:00
|
|
|
//We can't use exist object. Need create new.
|
2014-08-21 14:44:40 +02:00
|
|
|
T *node = new T(*data->GeometricObject<T>(id).data());
|
2014-06-12 09:22:29 +02:00
|
|
|
node->setMode(Draw::Modeling);
|
2013-12-31 09:28:53 +01:00
|
|
|
return data->AddGObject(node);
|
|
|
|
}
|
|
|
|
|
2015-06-18 19:23:24 +02:00
|
|
|
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);
|
2014-02-25 15:40:24 +01:00
|
|
|
static void Create(const quint32 &_id, const VDetail &newDetail, VMainGraphicsScene *scene,
|
2015-06-18 19:23:24 +02:00
|
|
|
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
2016-01-07 17:43:08 +01:00
|
|
|
const Source &typeCreation, const QString &drawName = QString());
|
2014-02-06 14:57:23 +01:00
|
|
|
static const QString TagName;
|
|
|
|
static const QString TagNode;
|
|
|
|
static const QString AttrSupplement;
|
|
|
|
static const QString AttrClosed;
|
|
|
|
static const QString AttrWidth;
|
|
|
|
static const QString AttrIdObject;
|
|
|
|
static const QString AttrNodeType;
|
2014-12-17 13:56:14 +01:00
|
|
|
static const QString AttrReverse;
|
2014-02-06 14:57:23 +01:00
|
|
|
static const QString NodeTypeContour;
|
|
|
|
static const QString NodeTypeModeling;
|
2014-02-25 19:03:17 +01:00
|
|
|
static const QString NodeArc;
|
|
|
|
static const QString NodePoint;
|
|
|
|
static const QString NodeSpline;
|
|
|
|
static const QString NodeSplinePath;
|
2014-06-15 19:07:54 +02:00
|
|
|
void Remove(bool ask);
|
2015-06-16 10:30:25 +02:00
|
|
|
static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VNodeDetail &node);
|
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::Detail)};
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
|
|
|
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
2013-08-28 10:55:11 +02:00
|
|
|
public slots:
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
2014-06-11 18:38:09 +02:00
|
|
|
virtual void FullUpdateFromGuiOk(int result);
|
2015-12-20 20:53:59 +01:00
|
|
|
void EnableToolMove(bool move);
|
2013-08-28 10:55:11 +02:00
|
|
|
protected:
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void AddToFile () Q_DECL_OVERRIDE;
|
|
|
|
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
|
|
|
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
2015-12-02 22:07:23 +01:00
|
|
|
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
2015-12-06 17:20:37 +01:00
|
|
|
virtual void hoverMoveEvent( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
2015-12-02 20:33:42 +01:00
|
|
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
|
|
|
|
virtual void SetVisualization() Q_DECL_OVERRIDE {}
|
2013-08-28 10:55:11 +02:00
|
|
|
private:
|
2013-09-26 20:50:52 +02:00
|
|
|
Q_DISABLE_COPY(VToolDetail)
|
2014-06-14 08:42:01 +02:00
|
|
|
/** @brief dialog dialog options. */
|
2014-02-06 14:57:23 +01:00
|
|
|
DialogTool *dialog;
|
2014-06-14 08:42:01 +02:00
|
|
|
|
|
|
|
/** @brief sceneDetails pointer to the scene. */
|
2014-02-06 14:57:23 +01:00
|
|
|
VMainGraphicsScene *sceneDetails;
|
2016-01-07 17:43:08 +01:00
|
|
|
QString drawName;
|
2014-06-14 08:42:01 +02:00
|
|
|
|
2016-01-10 14:31:43 +01:00
|
|
|
VNoBrushScalePathItem *seamAllowance;
|
|
|
|
|
2014-02-06 14:57:23 +01:00
|
|
|
void RefreshGeometry ();
|
2013-10-29 16:01:56 +01:00
|
|
|
template <typename Tool>
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief InitTool initial node item on scene
|
|
|
|
* @param scene pointer to scene.
|
|
|
|
* @param node node of detail.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
void InitTool(VMainGraphicsScene *scene, const VNodeDetail &node);
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void DeleteTool(bool ask = true) Q_DECL_OVERRIDE;
|
2013-08-28 10:55:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLDETAIL_H
|