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.
|
|
|
|
** 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-08-28 10:55:11 +02:00
|
|
|
#ifndef VTOOLDETAIL_H
|
|
|
|
#define VTOOLDETAIL_H
|
|
|
|
|
|
|
|
#include "vabstracttool.h"
|
|
|
|
#include <QGraphicsPathItem>
|
2014-06-08 20:10:57 +02:00
|
|
|
#include "../xml/vpattern.h"
|
|
|
|
|
|
|
|
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
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
class VToolDetail: public VAbstractTool, public QGraphicsPathItem
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-06-12 09:22:29 +02:00
|
|
|
VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
|
2014-02-26 10:22:05 +01:00
|
|
|
VMainGraphicsScene *scene, 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);
|
|
|
|
}
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
2014-02-25 15:40:24 +01:00
|
|
|
static void Create(const quint32 &_id, const VDetail &newDetail, VMainGraphicsScene *scene,
|
2014-06-12 09:22:29 +02:00
|
|
|
VPattern *doc, VContainer *data, const Document &parse,
|
|
|
|
const Source &typeCreation);
|
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);
|
2014-06-12 15:38:28 +02:00
|
|
|
static void AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node);
|
2014-08-26 20:31:28 +02:00
|
|
|
virtual int type() const {return Type;}
|
|
|
|
enum { Type = UserType + static_cast<int>(Tool::Detail)};
|
2014-08-30 21:58:31 +02:00
|
|
|
virtual QString getTagName() const;
|
2014-09-03 15:52:16 +02:00
|
|
|
virtual void ShowVisualization(bool show);
|
2013-08-28 10:55:11 +02:00
|
|
|
public slots:
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void FullUpdateFromFile ();
|
2014-06-11 18:38:09 +02:00
|
|
|
virtual void FullUpdateFromGuiOk(int result);
|
2013-08-28 10:55:11 +02:00
|
|
|
protected:
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void AddToFile ();
|
|
|
|
virtual void RefreshDataInFile();
|
|
|
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
|
|
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
|
|
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
|
|
|
virtual void RemoveReferens();
|
|
|
|
virtual void keyReleaseEvent(QKeyEvent * event);
|
2014-08-30 21:58:31 +02:00
|
|
|
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
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;
|
2014-06-14 08:42:01 +02:00
|
|
|
|
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);
|
2014-06-16 14:14:46 +02:00
|
|
|
virtual void DeleteTool(bool ask = true);
|
2013-08-28 10:55:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLDETAIL_H
|