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
|
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-07-25 20:39:51 +02:00
|
|
|
#ifndef VABSTRACTTOOL_H
|
|
|
|
#define VABSTRACTTOOL_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <Qt>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
2015-09-04 14:39:01 +02:00
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
2016-10-06 18:12:25 +02:00
|
|
|
#include "../vtools/visualization/visualization.h"
|
2015-09-04 14:39:01 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
2016-10-06 18:12:25 +02:00
|
|
|
#include "../vmisc/def.h"
|
2015-09-04 14:39:01 +02:00
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "vdatatool.h"
|
2014-06-08 20:10:57 +02:00
|
|
|
|
2014-06-12 15:38:28 +02:00
|
|
|
class QDomElement;
|
2016-08-08 13:44:49 +02:00
|
|
|
class QGraphicsEllipseItem;
|
|
|
|
class QGraphicsItem;
|
|
|
|
class QGraphicsLineItem;
|
2014-06-13 19:02:41 +02:00
|
|
|
class QGraphicsScene;
|
|
|
|
class QGraphicsView;
|
2016-08-08 13:44:49 +02:00
|
|
|
class QIcon;
|
|
|
|
class QLineF;
|
|
|
|
class QPointF;
|
2014-06-13 19:02:41 +02:00
|
|
|
class QRectF;
|
2016-08-08 13:44:49 +02:00
|
|
|
class VContainer;
|
2015-12-11 15:20:32 +01:00
|
|
|
class VGraphicsSimpleTextItem;
|
2016-08-08 13:44:49 +02:00
|
|
|
class Visualization;
|
2013-07-25 20:39:51 +02:00
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 13:54:29 +01:00
|
|
|
* @brief The VAbstractTool abstract class for all tools.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
class VAbstractTool: public VDataTool
|
|
|
|
{
|
2013-07-25 20:39:51 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-06-16 17:01:17 +02:00
|
|
|
VAbstractTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr);
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual ~VAbstractTool() Q_DECL_OVERRIDE;
|
2014-02-26 09:18:59 +01:00
|
|
|
quint32 getId() const;
|
2015-02-02 11:28:09 +01:00
|
|
|
|
2015-12-26 18:10:02 +01:00
|
|
|
static const QString AttrInUse;
|
|
|
|
|
2015-01-29 16:47:02 +01:00
|
|
|
static const QStringList StylesList();
|
|
|
|
static Qt::PenStyle LineStyleToPenStyle(const QString &typeLine);
|
|
|
|
static QMap<QString, QIcon> LineStylesPics();
|
|
|
|
|
2015-02-07 13:31:10 +01:00
|
|
|
static const QStringList Colors();
|
|
|
|
static QMap<QString, QString> ColorsList();
|
2015-02-02 11:28:09 +01:00
|
|
|
|
2015-06-16 17:01:17 +02:00
|
|
|
static void AddRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc);
|
2015-01-29 16:47:02 +01:00
|
|
|
|
2014-07-25 13:22:25 +02:00
|
|
|
const VContainer *getData() const;
|
2014-08-28 13:05:58 +02:00
|
|
|
|
|
|
|
QMap<QString, quint32> PointsList() const;
|
2014-08-30 21:58:31 +02:00
|
|
|
virtual QString getTagName() const =0;
|
2014-09-03 15:52:16 +02:00
|
|
|
virtual void ShowVisualization(bool show) =0;
|
2013-07-25 20:39:51 +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
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
virtual void FullUpdateFromFile()=0;
|
2016-03-31 16:01:41 +02:00
|
|
|
virtual void AllowHover(bool enabled)=0;
|
|
|
|
virtual void AllowSelecting(bool enabled)=0;
|
2016-03-31 19:10:20 +02:00
|
|
|
virtual void ToolSelectionType(const SelectionType &type);
|
2013-07-25 20:39:51 +02:00
|
|
|
signals:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 13:54:29 +01:00
|
|
|
* @brief toolhaveChange emit if tool create change that need save.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
void toolhaveChange();
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 13:54:29 +01:00
|
|
|
* @brief ChoosedTool emit if object was clicked.
|
|
|
|
* @param id object id in container.
|
|
|
|
* @param type type of scene object.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-06-12 09:22:29 +02:00
|
|
|
void ChoosedTool(quint32 id, SceneObject type);
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 13:54:29 +01:00
|
|
|
* @brief FullUpdateTree emit if need reparse pattern file.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-08-04 15:37:36 +02:00
|
|
|
void LiteUpdateTree(const Document &parse);
|
2016-07-13 13:05:37 +02:00
|
|
|
|
|
|
|
void ToolTip(const QString &toolTip);
|
2013-07-25 20:39:51 +02:00
|
|
|
protected:
|
2014-06-13 19:02:41 +02:00
|
|
|
/** @brief doc dom document container */
|
2015-06-16 17:01:17 +02:00
|
|
|
VAbstractPattern *doc;
|
2014-06-13 19:02:41 +02:00
|
|
|
|
|
|
|
/** @brief id object id. */
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id;
|
2014-06-13 19:02:41 +02:00
|
|
|
|
|
|
|
/** @brief baseColor base color for tool. */
|
2014-01-07 13:54:50 +01:00
|
|
|
Qt::GlobalColor baseColor;
|
2014-06-13 19:02:41 +02:00
|
|
|
|
2016-09-24 15:09:09 +02:00
|
|
|
QPointer<Visualization> vis;
|
2016-03-31 19:10:20 +02:00
|
|
|
SelectionType selectionType;
|
2014-09-03 15:52:16 +02:00
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 13:54:29 +01:00
|
|
|
* @brief AddToFile add tag with informations about tool into file.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2013-10-27 12:56:05 +01:00
|
|
|
virtual void AddToFile()=0;
|
2013-12-24 12:24:29 +01:00
|
|
|
/**
|
|
|
|
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
|
|
|
|
*/
|
|
|
|
virtual void RefreshDataInFile()=0;
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-24 13:54:29 +01:00
|
|
|
* @brief RemoveReferens decrement value of reference.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void RemoveReferens() {}
|
2014-06-16 14:14:46 +02:00
|
|
|
virtual void DeleteTool(bool ask = true);
|
2014-06-26 12:41:59 +02:00
|
|
|
static int ConfirmDeletion();
|
2015-05-23 13:40:43 +02:00
|
|
|
|
|
|
|
template <typename T>
|
2015-07-03 16:03:19 +02:00
|
|
|
void AddVisualization();
|
2015-05-23 13:40:43 +02:00
|
|
|
|
|
|
|
virtual void SetVisualization()=0;
|
2015-05-28 12:16:59 +02:00
|
|
|
void ToolCreation(const Source &typeCreation);
|
2015-12-11 10:31:21 +01:00
|
|
|
|
|
|
|
static void RefreshLine(QGraphicsEllipseItem *point, VGraphicsSimpleTextItem *namePoint, QGraphicsLineItem *lineName,
|
2015-12-11 12:35:48 +01:00
|
|
|
const qreal radius);
|
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
|
|
|
};
|
2014-02-26 09:18:59 +01:00
|
|
|
|
2014-06-13 19:02:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief getId return object id.
|
|
|
|
* @return id.
|
|
|
|
*/
|
2014-02-26 09:18:59 +01:00
|
|
|
inline quint32 VAbstractTool::getId() const
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2014-06-13 19:02:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief getData return pointer to data container.
|
|
|
|
* @return container.
|
|
|
|
*/
|
2014-02-26 09:18:59 +01:00
|
|
|
inline const VContainer *VAbstractTool::getData() const
|
|
|
|
{
|
|
|
|
return &data;
|
|
|
|
}
|
2015-07-03 16:03:19 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
inline void VAbstractTool::AddVisualization()
|
|
|
|
{
|
|
|
|
T *visual = new T(getData());
|
|
|
|
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
|
|
|
SCASSERT(scene != nullptr)
|
|
|
|
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
|
|
|
scene->addItem(visual);
|
|
|
|
|
2016-09-24 15:09:09 +02:00
|
|
|
connect(visual, &Visualization::ToolTip, [=] (const QString &toolTip) {emit ToolTip(toolTip);});
|
2015-07-03 16:03:19 +02:00
|
|
|
vis = visual;
|
|
|
|
}
|
|
|
|
|
2013-07-25 20:39:51 +02:00
|
|
|
#endif // VABSTRACTTOOL_H
|