2015-06-20 08:23:04 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vabstractpoint.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 19 6, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-06-20 08:23:04 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-06-20 08:23:04 +02:00
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** 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.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** 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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VABSTRACTPOINT_H
|
|
|
|
#define VABSTRACTPOINT_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QColor>
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPen>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QString>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
#include "../../../visualization/visualization.h"
|
|
|
|
#include "../../vabstracttool.h"
|
2015-06-20 08:23:04 +02:00
|
|
|
#include "../vdrawtool.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../vmisc/def.h"
|
2023-07-13 16:49:20 +02:00
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
class VAbstractPoint : public VDrawTool
|
2015-06-20 08:23:04 +02:00
|
|
|
{
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_OBJECT // NOLINT
|
2023-07-13 16:49:20 +02:00
|
|
|
|
2015-06-20 08:23:04 +02:00
|
|
|
public:
|
2020-10-28 13:09:56 +01:00
|
|
|
VAbstractPoint(VAbstractPattern *doc, VContainer *data, quint32 id, const QString ¬es);
|
2022-08-22 15:36:01 +02:00
|
|
|
virtual ~VAbstractPoint() = default;
|
2015-06-20 18:14:04 +02:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
virtual auto getTagName() const -> QString override;
|
2015-06-20 18:14:04 +02:00
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
template <typename T> void ShowToolVisualization(bool show);
|
2015-06-20 18:14:04 +02:00
|
|
|
|
|
|
|
public slots:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void ShowTool(quint32 id, bool enable) override;
|
2023-07-13 16:49:20 +02:00
|
|
|
void DeleteFromLabel();
|
2015-06-20 18:14:04 +02:00
|
|
|
|
|
|
|
protected:
|
2016-03-28 14:49:35 +02:00
|
|
|
void SetPointName(quint32 id, const QString &name);
|
2015-06-20 18:14:04 +02:00
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
template <typename T> static void InitToolConnections(VMainGraphicsScene *scene, T *tool);
|
2016-03-31 16:01:41 +02:00
|
|
|
|
2015-06-20 18:14:04 +02:00
|
|
|
private:
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(VAbstractPoint) // NOLINT
|
2015-06-20 08:23:04 +02:00
|
|
|
};
|
|
|
|
|
2015-06-20 18:14:04 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-07-13 16:49:20 +02:00
|
|
|
template <typename T> void VAbstractPoint::ShowToolVisualization(bool show)
|
2015-06-20 18:14:04 +02:00
|
|
|
{
|
|
|
|
if (show)
|
|
|
|
{
|
2016-09-24 15:09:09 +02:00
|
|
|
if (vis.isNull())
|
2015-06-20 18:14:04 +02:00
|
|
|
{
|
|
|
|
AddVisualization<T>();
|
|
|
|
SetVisualization();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (T *visual = qobject_cast<T *>(vis))
|
|
|
|
{
|
|
|
|
visual->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete vis;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-31 16:01:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-07-13 16:49:20 +02:00
|
|
|
template <typename T> void VAbstractPoint::InitToolConnections(VMainGraphicsScene *scene, T *tool)
|
2016-03-31 16:01:41 +02:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(scene != nullptr)
|
|
|
|
SCASSERT(tool != nullptr)
|
2016-03-31 16:01:41 +02:00
|
|
|
|
|
|
|
InitDrawToolConnections(scene, tool);
|
|
|
|
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemHover, tool, &T::AllowHover);
|
|
|
|
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemSelection, tool, &T::AllowSelecting);
|
|
|
|
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemHover, tool, &T::AllowLabelHover);
|
|
|
|
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, tool, &T::AllowLabelSelecting);
|
|
|
|
}
|
|
|
|
|
2015-06-20 08:23:04 +02:00
|
|
|
#endif // VABSTRACTPOINT_H
|