valentina/src/libs/vtools/visualization/line/operation/visoperation.h

102 lines
3.6 KiB
C
Raw Normal View History

/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 9, 2016
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2016 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** 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 VISOPERATION_H
#define VISOPERATION_H
#include <QtGlobal>
#include "../visline.h"
#include "../vpatterndb/vcontainer.h"
class VisOperation : public VisLine
{
2022-08-12 17:50:13 +02:00
Q_OBJECT // NOLINT
public:
explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr);
2022-08-23 15:37:58 +02:00
~VisOperation() override;
2020-11-07 14:02:30 +01:00
void SetObjects(const QVector<quint32> &objects);
2022-08-23 15:37:58 +02:00
void VisualMode(quint32 id = NULL_ID) override;
2022-08-23 15:37:58 +02:00
auto type() const -> int override {return Type;}
enum {Type = UserType + static_cast<int>(Vis::ToolRotation)};
protected:
2022-08-23 15:37:58 +02:00
auto GetPoint(quint32 i, const QColor &color) -> VScaledEllipse *;
auto GetCurve(quint32 i, const QColor &color) -> VCurvePathItem *;
template <class Item>
2022-08-23 15:37:58 +02:00
auto AddFlippedCurve(quint32 originPointId, const QPointF &firstPoint, const QPointF &secondPoint, quint32 id,
int i) -> int;
void RefreshFlippedObjects(quint32 originPointId, const QPointF &firstPoint, const QPointF &secondPoint);
2022-08-23 15:37:58 +02:00
auto Objects() const -> const QVector<quint32> &;
private:
2022-08-30 13:42:44 +02:00
// cppcheck-suppress unknownMacro
2022-08-12 17:50:13 +02:00
Q_DISABLE_COPY_MOVE(VisOperation) // NOLINT
2022-08-23 15:37:58 +02:00
QVector<quint32> m_objects{};
QVector<VScaledEllipse *> m_points{};
QVector<VCurvePathItem *> m_curves{};
};
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
2022-08-23 15:37:58 +02:00
auto VisOperation::AddFlippedCurve(quint32 originPointId, const QPointF &firstPoint, const QPointF &secondPoint,
quint32 id, int i) -> int
{
2022-08-23 15:37:58 +02:00
const QSharedPointer<Item> curve = GetData()->template GeometricObject<Item>(id);
++i;
2022-08-23 15:37:58 +02:00
VCurvePathItem *path = GetCurve(static_cast<quint32>(i), Color(VColor::SupportColor2));
DrawPath(path, curve->GetPath(), curve->DirectionArrows(), Color(VColor::SupportColor2), Qt::SolidLine,
Qt::RoundCap);
++i;
2022-08-23 15:37:58 +02:00
path = GetCurve(static_cast<quint32>(i), Color(VColor::SupportColor));
if (originPointId != NULL_ID)
{
const Item flipped = curve->Flip(QLineF(firstPoint, secondPoint));
2022-08-23 15:37:58 +02:00
DrawPath(path, flipped.GetPath(), flipped.DirectionArrows(), Color(VColor::SupportColor), Qt::SolidLine,
Qt::RoundCap);
}
return i;
}
2022-08-23 15:37:58 +02:00
//---------------------------------------------------------------------------------------------------------------------
inline auto VisOperation::Objects() const -> const QVector<quint32> &
{
return m_objects;
}
#endif // VISOPERATION_H