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-02-06 14:57:23 +01:00
|
|
|
/**
|
|
|
|
* @brief VToolDetail constructor.
|
|
|
|
* @param doc dom document container
|
|
|
|
* @param data container with variables
|
|
|
|
* @param id object id in container
|
|
|
|
* @param typeCreation way we create this tool.
|
|
|
|
* @param scene pointer to scene.
|
|
|
|
* @param parent parent object
|
|
|
|
*/
|
2014-03-11 12:43:24 +01:00
|
|
|
VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, const Valentina::Sources &typeCreation,
|
2014-02-26 10:22:05 +01:00
|
|
|
VMainGraphicsScene *scene, QGraphicsItem * parent = nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
~VToolDetail();
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief setDialog set dialog when user want change tool option.
|
2013-11-19 21:56:49 +01: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.
|
2013-12-31 09:28:53 +01:00
|
|
|
T *node = new T(*data->GeometricObject<const T *>(id));
|
2014-03-11 12:43:24 +01:00
|
|
|
node->setMode(Valentina::Modeling);
|
2013-12-31 09:28:53 +01:00
|
|
|
return data->AddGObject(node);
|
|
|
|
}
|
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief Create help create tool from GUI.
|
|
|
|
* @param dialog dialog.
|
|
|
|
* @param scene pointer to scene.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-25 15:02:09 +01:00
|
|
|
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief Create help create tool.
|
|
|
|
* @param _id tool id, 0 if tool doesn't exist yet.
|
|
|
|
* @param newDetail detail what we want show.
|
|
|
|
* @param scene pointer to scene.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
2014-01-24 16:10:23 +01:00
|
|
|
* @param parse parser file mode.
|
2014-01-24 15:25:45 +01:00
|
|
|
* @param typeCreation way we create this tool.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
static void Create(const quint32 &_id, const VDetail &newDetail, VMainGraphicsScene *scene,
|
2014-02-25 15:02:09 +01:00
|
|
|
VPattern *doc, VContainer *data, const Document::Documents &parse,
|
2014-03-11 12:43:24 +01:00
|
|
|
const Valentina::Sources &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;
|
|
|
|
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;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief Remove full delete detail.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
void Remove();
|
2013-08-28 10:55:11 +02:00
|
|
|
public slots:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 13:54:29 +01:00
|
|
|
* @brief FullUpdateFromFile update tool data form file.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void FullUpdateFromFile ();
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 18:10:04 +01:00
|
|
|
* @brief FullUpdateFromGui refresh tool data after change in options.
|
2014-01-24 15:25:45 +01:00
|
|
|
* @param result keep result working dialog.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void FullUpdateFromGui(int result);
|
2013-08-28 10:55:11 +02:00
|
|
|
protected:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief AddToFile add tag with informations about tool into file.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void AddToFile ();
|
2013-12-24 12:24:29 +01:00
|
|
|
/**
|
|
|
|
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
|
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void RefreshDataInFile();
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief itemChange handle detail change.
|
|
|
|
* @param change change
|
|
|
|
* @param value value
|
|
|
|
* @return new value.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief mouseReleaseEvent handle mouse release events.
|
|
|
|
* @param event mouse release event.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief contextMenuEvent handle context menu events.
|
|
|
|
* @param event context menu event.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief RemoveReferens decrement value of reference.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void RemoveReferens();
|
2014-01-24 15:25:45 +01:00
|
|
|
/**
|
|
|
|
* @brief keyReleaseEvent handle key release events.
|
|
|
|
* @param event key release event.
|
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
virtual void keyReleaseEvent(QKeyEvent * event);
|
2013-08-28 10:55:11 +02:00
|
|
|
private:
|
2013-09-26 20:50:52 +02:00
|
|
|
Q_DISABLE_COPY(VToolDetail)
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-02-06 14:57:23 +01:00
|
|
|
* @brief dialog dialog options.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
DialogTool *dialog;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief sceneDetails pointer to the scene.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
VMainGraphicsScene *sceneDetails;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief RefreshGeometry refresh item on scene.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
void RefreshGeometry ();
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 15:25:45 +01:00
|
|
|
* @brief AddNode add node to the file.
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
* @param node node of detail.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
void AddNode(QDomElement &domElement, const VNodeDetail &node);
|
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);
|
2013-08-28 10:55:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTOOLDETAIL_H
|