Fix a crash.
Valentina crahed if create a curve. --HG-- branch : develop
This commit is contained in:
parent
4243804f55
commit
8d0b2c0af9
|
@ -165,6 +165,8 @@ enum class Vis : ToolVisHolderType
|
||||||
{
|
{
|
||||||
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
|
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
|
||||||
GraphicsSimpleTextItem,
|
GraphicsSimpleTextItem,
|
||||||
|
ScaledLine,
|
||||||
|
ScaledEllipse,
|
||||||
SimplePoint,
|
SimplePoint,
|
||||||
SimpleCurve,
|
SimpleCurve,
|
||||||
Line,
|
Line,
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "../../../../vabstracttool.h"
|
#include "../../../../vabstracttool.h"
|
||||||
#include "../../../vdrawtool.h"
|
#include "../../../vdrawtool.h"
|
||||||
#include "../vtoolsinglepoint.h"
|
#include "../vtoolsinglepoint.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
@ -74,7 +75,8 @@ VToolLinePoint::VToolLinePoint(VAbstractPattern *doc, VContainer *data, const qu
|
||||||
Q_ASSERT_X(basePointId != 0, Q_FUNC_INFO, "basePointId == 0"); //-V654 //-V712
|
Q_ASSERT_X(basePointId != 0, Q_FUNC_INFO, "basePointId == 0"); //-V654 //-V712
|
||||||
QPointF point1 = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
|
QPointF point1 = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
|
||||||
QPointF point2 = static_cast<QPointF>(*data->GeometricObject<VPointF>(id));
|
QPointF point2 = static_cast<QPointF>(*data->GeometricObject<VPointF>(id));
|
||||||
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
|
mainLine = new VScaledLine(QLineF(point1 - point2, QPointF()), this);
|
||||||
|
mainLine->SetBasicWidth(widthHairLine);
|
||||||
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,21 +89,15 @@ VToolLinePoint::~VToolLinePoint()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolLinePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void VToolLinePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
const qreal width = ScaleWidth(m_isHovered ? widthMainLine : widthHairLine, SceneScale(scene()));
|
QPen mPen = mainLine->pen();
|
||||||
|
mPen.setColor(CorrectColor(this, lineColor));
|
||||||
|
mPen.setStyle(LineStyleToPenStyle(m_lineType));
|
||||||
|
|
||||||
mainLine->setPen(QPen(CorrectColor(this, lineColor), width, LineStyleToPenStyle(m_lineType)));
|
mainLine->setPen(mPen);
|
||||||
|
|
||||||
VToolSinglePoint::paint(painter, option, widget);
|
VToolSinglePoint::paint(painter, option, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QRectF VToolLinePoint::boundingRect() const
|
|
||||||
{
|
|
||||||
QRectF recTool = VToolSinglePoint::boundingRect();
|
|
||||||
recTool = recTool.united(childrenBoundingRect());
|
|
||||||
return recTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief RefreshGeometry refresh item on scene.
|
* @brief RefreshGeometry refresh item on scene.
|
||||||
|
@ -133,6 +129,20 @@ void VToolLinePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
|
||||||
doc->SetAttribute(tag, AttrLineColor, lineColor);
|
doc->SetAttribute(tag, AttrLineColor, lineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolLinePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
mainLine->SetBasicWidth(widthMainLine);
|
||||||
|
VToolSinglePoint::hoverEnterEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolLinePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
mainLine->SetBasicWidth(widthHairLine);
|
||||||
|
VToolSinglePoint::hoverLeaveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolLinePoint::Disable(bool disable, const QString &namePP)
|
void VToolLinePoint::Disable(bool disable, const QString &namePP)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,7 +58,6 @@ public:
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
VFormula GetFormulaLength() const;
|
VFormula GetFormulaLength() const;
|
||||||
void SetFormulaLength(const VFormula &value);
|
void SetFormulaLength(const VFormula &value);
|
||||||
|
@ -88,7 +87,7 @@ protected:
|
||||||
quint32 basePointId;
|
quint32 basePointId;
|
||||||
|
|
||||||
/** @brief mainLine line item. */
|
/** @brief mainLine line item. */
|
||||||
QGraphicsLineItem *mainLine;
|
VScaledLine *mainLine;
|
||||||
|
|
||||||
/** @brief lineColor color of a line. */
|
/** @brief lineColor color of a line. */
|
||||||
QString lineColor;
|
QString lineColor;
|
||||||
|
@ -96,6 +95,8 @@ protected:
|
||||||
virtual void RefreshGeometry();
|
virtual void RefreshGeometry();
|
||||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||||
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolLinePoint)
|
Q_DISABLE_COPY(VToolLinePoint)
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vwidgets/vgraphicssimpletextitem.h"
|
#include "../vwidgets/vgraphicssimpletextitem.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
#include "../../../vabstracttool.h"
|
#include "../../../vabstracttool.h"
|
||||||
#include "../../vdrawtool.h"
|
#include "../../vdrawtool.h"
|
||||||
#include "../vabstractpoint.h"
|
#include "../vabstractpoint.h"
|
||||||
|
|
|
@ -201,7 +201,7 @@ void VNodePoint::RefreshDataInFile()
|
||||||
void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
// Special for not selectable item first need to call standard mousePressEvent then accept event
|
// Special for not selectable item first need to call standard mousePressEvent then accept event
|
||||||
QGraphicsEllipseItem::mousePressEvent(event);
|
VScenePoint::mousePressEvent(event);
|
||||||
|
|
||||||
// Somehow clicking on notselectable object do not clean previous selections.
|
// Somehow clicking on notselectable object do not clean previous selections.
|
||||||
if (not (flags() & ItemIsSelectable) && scene())
|
if (not (flags() & ItemIsSelectable) && scene())
|
||||||
|
@ -223,7 +223,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
emit ChoosedTool(id, SceneObject::Point);
|
emit ChoosedTool(id, SceneObject::Point);
|
||||||
}
|
}
|
||||||
QGraphicsEllipseItem::mouseReleaseEvent(event);
|
VScenePoint::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -75,7 +75,7 @@ void VisOperation::VisualMode(const quint32 &pointId)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsEllipseItem *VisOperation::GetPoint(quint32 i, const QColor &color)
|
VScaledEllipse *VisOperation::GetPoint(quint32 i, const QColor &color)
|
||||||
{
|
{
|
||||||
return GetPointItem(points, i, color, this);
|
return GetPointItem(points, i, color, this);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPoint
|
||||||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||||
|
|
||||||
++iPoint;
|
++iPoint;
|
||||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||||
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
||||||
|
|
||||||
++iPoint;
|
++iPoint;
|
||||||
|
|
|
@ -50,10 +50,10 @@ protected:
|
||||||
QVector<quint32> objects;
|
QVector<quint32> objects;
|
||||||
QColor supportColor2;
|
QColor supportColor2;
|
||||||
|
|
||||||
QVector<QGraphicsEllipseItem *> points;
|
QVector<VScaledEllipse *> points;
|
||||||
QVector<VCurvePathItem *> curves;
|
QVector<VCurvePathItem *> curves;
|
||||||
|
|
||||||
QGraphicsEllipseItem * GetPoint(quint32 i, const QColor &color);
|
VScaledEllipse *GetPoint(quint32 i, const QColor &color);
|
||||||
VCurvePathItem *GetCurve(quint32 i, const QColor &color);
|
VCurvePathItem *GetCurve(quint32 i, const QColor &color);
|
||||||
|
|
||||||
template <class Item>
|
template <class Item>
|
||||||
|
|
|
@ -80,13 +80,3 @@ void VisToolFlippingByAxis::SetAxisType(AxisType value)
|
||||||
{
|
{
|
||||||
m_axisType = value;
|
m_axisType = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolFlippingByAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point1, scale);
|
|
||||||
|
|
||||||
VisOperation::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -48,15 +48,12 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByAxis)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByAxis)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolFlippingByAxis)
|
Q_DISABLE_COPY(VisToolFlippingByAxis)
|
||||||
|
|
||||||
AxisType m_axisType;
|
AxisType m_axisType;
|
||||||
|
|
||||||
QGraphicsEllipseItem *point1;
|
VScaledEllipse *point1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLFLIPPINGBYAXIS_H
|
#endif // VISTOOLFLIPPINGBYAXIS_H
|
||||||
|
|
|
@ -72,17 +72,6 @@ void VisToolFlippingByLine::RefreshGeometry()
|
||||||
RefreshFlippedObjects(firstPoint, secondPoint);
|
RefreshFlippedObjects(firstPoint, secondPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolFlippingByLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point1, scale);
|
|
||||||
ScalePoint(point2, scale);
|
|
||||||
|
|
||||||
VisOperation::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolFlippingByLine::SetFirstLinePointId(quint32 value)
|
void VisToolFlippingByLine::SetFirstLinePointId(quint32 value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,8 +41,6 @@ public:
|
||||||
virtual ~VisToolFlippingByLine() = default;
|
virtual ~VisToolFlippingByLine() = default;
|
||||||
|
|
||||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
void SetFirstLinePointId(quint32 value);
|
void SetFirstLinePointId(quint32 value);
|
||||||
void SetSecondLinePointId(quint32 value);
|
void SetSecondLinePointId(quint32 value);
|
||||||
|
@ -52,8 +50,8 @@ public:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolFlippingByLine)
|
Q_DISABLE_COPY(VisToolFlippingByLine)
|
||||||
quint32 object2Id;
|
quint32 object2Id;
|
||||||
QGraphicsEllipseItem *point1;
|
VScaledEllipse *point1;
|
||||||
QGraphicsEllipseItem *point2;
|
VScaledEllipse *point2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLFLIPPINGBYLINE_H
|
#endif // VISTOOLFLIPPINGBYLINE_H
|
||||||
|
|
|
@ -128,17 +128,6 @@ void VisToolMove::RefreshGeometry()
|
||||||
CreateMovedObjects(iPoint, iCurve, tempLength, tempAngle);
|
CreateMovedObjects(iPoint, iCurve, tempLength, tempAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolMove::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(pointOrigin, scale);
|
|
||||||
ScalePoint(pointFinish, scale);
|
|
||||||
|
|
||||||
VisOperation::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VisToolMove::Angle() const
|
QString VisToolMove::Angle() const
|
||||||
{
|
{
|
||||||
|
@ -244,7 +233,7 @@ QVector<QGraphicsItem *> VisToolMove::CreateOriginObjects(int &iPoint, int &iCur
|
||||||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||||
|
|
||||||
++iPoint;
|
++iPoint;
|
||||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||||
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
||||||
originObjects.append(point);
|
originObjects.append(point);
|
||||||
|
|
||||||
|
@ -299,7 +288,7 @@ void VisToolMove::CreateMovedObjects(int &iPoint, int &iCurve, qreal length, qre
|
||||||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||||
|
|
||||||
++iPoint;
|
++iPoint;
|
||||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor);
|
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor);
|
||||||
DrawPoint(point, static_cast<QPointF>(p->Move(length, angle)), supportColor);
|
DrawPoint(point, static_cast<QPointF>(p->Move(length, angle)), supportColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,6 @@ public:
|
||||||
virtual ~VisToolMove();
|
virtual ~VisToolMove();
|
||||||
|
|
||||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
QString Angle() const;
|
QString Angle() const;
|
||||||
void SetAngle(const QString &expression);
|
void SetAngle(const QString &expression);
|
||||||
|
@ -67,8 +65,8 @@ private:
|
||||||
Q_DISABLE_COPY(VisToolMove)
|
Q_DISABLE_COPY(VisToolMove)
|
||||||
qreal angle;
|
qreal angle;
|
||||||
qreal length;
|
qreal length;
|
||||||
QGraphicsEllipseItem *pointOrigin;
|
VScaledEllipse *pointOrigin;
|
||||||
QGraphicsEllipseItem *pointFinish;
|
VScaledEllipse *pointFinish;
|
||||||
|
|
||||||
template <class Item>
|
template <class Item>
|
||||||
QGraphicsPathItem *AddOriginCurve(quint32 id, int &i);
|
QGraphicsPathItem *AddOriginCurve(quint32 id, int &i);
|
||||||
|
|
|
@ -65,7 +65,7 @@ VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
|
||||||
{
|
{
|
||||||
point = InitPoint(supportColor2, this);
|
point = InitPoint(supportColor2, this);
|
||||||
angleArc = InitItem<VCurvePathItem>(supportColor2, this);
|
angleArc = InitItem<VCurvePathItem>(supportColor2, this);
|
||||||
xAxis = InitItem<QGraphicsLineItem>(supportColor2, this);
|
xAxis = InitItem<VScaledLine>(supportColor2, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -140,7 +140,7 @@ void VisToolRotation::RefreshGeometry()
|
||||||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||||
|
|
||||||
++iPoint;
|
++iPoint;
|
||||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||||
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
||||||
|
|
||||||
++iPoint;
|
++iPoint;
|
||||||
|
@ -190,18 +190,6 @@ void VisToolRotation::RefreshGeometry()
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolRotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePenWidth(angleArc, scale);
|
|
||||||
ScalePenWidth(xAxis, scale);
|
|
||||||
|
|
||||||
VisOperation::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolRotation::SetOriginPointId(quint32 value)
|
void VisToolRotation::SetOriginPointId(quint32 value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,8 +51,6 @@ public:
|
||||||
virtual ~VisToolRotation();
|
virtual ~VisToolRotation();
|
||||||
|
|
||||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
void SetOriginPointId(quint32 value);
|
void SetOriginPointId(quint32 value);
|
||||||
|
|
||||||
|
@ -64,9 +62,9 @@ public:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolRotation)
|
Q_DISABLE_COPY(VisToolRotation)
|
||||||
qreal angle;
|
qreal angle;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
VCurvePathItem *angleArc;
|
VCurvePathItem *angleArc;
|
||||||
QGraphicsLineItem *xAxis;
|
VScaledLine *xAxis;
|
||||||
|
|
||||||
template <class Item>
|
template <class Item>
|
||||||
int AddCurve(qreal angle, const QPointF &origin, quint32 id, int i);
|
int AddCurve(qreal angle, const QPointF &origin, quint32 id, int i);
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisLine::VisLine(const VContainer *data, QGraphicsItem *parent)
|
VisLine::VisLine(const VContainer *data, QGraphicsItem *parent)
|
||||||
:Visualization(data), QGraphicsLineItem(parent)
|
:Visualization(data), VScaledLine(parent)
|
||||||
{
|
{
|
||||||
this->setZValue(1);// Show on top real tool
|
this->setZValue(1);// Show on top real tool
|
||||||
InitPen();
|
InitPen();
|
||||||
|
@ -78,22 +78,6 @@ qreal VisLine::CorrectAngle(const qreal &angle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
ScalePenWidth(this, SceneScale(scene()));
|
|
||||||
|
|
||||||
QGraphicsLineItem::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QRectF VisLine::boundingRect() const
|
|
||||||
{
|
|
||||||
QRectF recTool = QGraphicsLineItem::boundingRect();
|
|
||||||
recTool = recTool.united(childrenBoundingRect());
|
|
||||||
return recTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
|
QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
|
||||||
{
|
{
|
||||||
|
@ -164,7 +148,7 @@ void VisLine::AddOnScene()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisLine::DrawRay(QGraphicsLineItem *lineItem, const QPointF &p, const QPointF &pTangent, const QColor &color,
|
void VisLine::DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent, const QColor &color,
|
||||||
Qt::PenStyle style)
|
Qt::PenStyle style)
|
||||||
{
|
{
|
||||||
SCASSERT (lineItem != nullptr)
|
SCASSERT (lineItem != nullptr)
|
||||||
|
|
|
@ -43,8 +43,9 @@
|
||||||
|
|
||||||
#include "../vtools/visualization/visualization.h"
|
#include "../vtools/visualization/visualization.h"
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
class VisLine: public Visualization, public QGraphicsLineItem
|
class VisLine: public Visualization, public VScaledLine
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -54,10 +55,6 @@ public:
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::Line)};
|
enum { Type = UserType + static_cast<int>(Vis::Line)};
|
||||||
static qreal CorrectAngle(const qreal &angle);
|
static qreal CorrectAngle(const qreal &angle);
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
|
||||||
protected:
|
protected:
|
||||||
QPointF Ray(const QPointF &firstPoint, const qreal &angle) const;
|
QPointF Ray(const QPointF &firstPoint, const qreal &angle) const;
|
||||||
QPointF Ray(const QPointF &firstPoint) const;
|
QPointF Ray(const QPointF &firstPoint) const;
|
||||||
|
@ -66,7 +63,7 @@ protected:
|
||||||
virtual void InitPen() Q_DECL_OVERRIDE;
|
virtual void InitPen() Q_DECL_OVERRIDE;
|
||||||
virtual void AddOnScene() Q_DECL_OVERRIDE;
|
virtual void AddOnScene() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void DrawRay(QGraphicsLineItem *lineItem, const QPointF &p, const QPointF &pTangent,
|
void DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent,
|
||||||
const QColor &color, Qt::PenStyle style);
|
const QColor &color, Qt::PenStyle style);
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisLine)
|
Q_DISABLE_COPY(VisLine)
|
||||||
|
|
|
@ -53,7 +53,7 @@ VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent
|
||||||
|
|
||||||
lineP1 = InitPoint(supportColor, this);
|
lineP1 = InitPoint(supportColor, this);
|
||||||
lineP2 = InitPoint(supportColor, this); //-V656
|
lineP2 = InitPoint(supportColor, this); //-V656
|
||||||
line = InitItem<QGraphicsLineItem>(supportColor, this);
|
line = InitItem<VScaledLine>(supportColor, this);
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,19 +69,6 @@ void VisToolAlongLine::setLength(const QString &expression)
|
||||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolAlongLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(lineP1, scale);
|
|
||||||
ScalePoint(lineP2, scale);
|
|
||||||
ScalePenWidth(line, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolAlongLine::RefreshGeometry()
|
void VisToolAlongLine::RefreshGeometry()
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,16 +51,13 @@ public:
|
||||||
void setLength(const QString &expression);
|
void setLength(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolAlongLine)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolAlongLine)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolAlongLine)
|
Q_DISABLE_COPY(VisToolAlongLine)
|
||||||
quint32 object2Id;
|
quint32 object2Id;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *lineP1;
|
VScaledEllipse *lineP1;
|
||||||
QGraphicsEllipseItem *lineP2;
|
VScaledEllipse *lineP2;
|
||||||
QGraphicsLineItem *line;
|
VScaledLine *line;
|
||||||
qreal length;
|
qreal length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,10 @@ VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
|
||||||
{
|
{
|
||||||
line1P1 = InitPoint(supportColor, this);
|
line1P1 = InitPoint(supportColor, this);
|
||||||
line1P2 = InitPoint(supportColor, this); //-V656
|
line1P2 = InitPoint(supportColor, this); //-V656
|
||||||
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
line1 = InitItem<VScaledLine>(supportColor, this);
|
||||||
|
|
||||||
line2P2 = InitPoint(supportColor, this);
|
line2P2 = InitPoint(supportColor, this);
|
||||||
line2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
line2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
|
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
@ -75,21 +75,6 @@ void VisToolBisector::setLength(const QString &expression)
|
||||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolBisector::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(line1P1, scale);
|
|
||||||
ScalePoint(line1P2, scale);
|
|
||||||
ScalePenWidth(line1, scale);
|
|
||||||
ScalePoint(line2P2, scale);
|
|
||||||
ScalePenWidth(line2, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolBisector::RefreshGeometry()
|
void VisToolBisector::RefreshGeometry()
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,19 +52,16 @@ public:
|
||||||
void setLength(const QString &expression);
|
void setLength(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolBisector)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolBisector)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolBisector)
|
Q_DISABLE_COPY(VisToolBisector)
|
||||||
quint32 object2Id;
|
quint32 object2Id;
|
||||||
quint32 object3Id;
|
quint32 object3Id;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *line1P1;
|
VScaledEllipse *line1P1;
|
||||||
QGraphicsEllipseItem *line1P2;
|
VScaledEllipse *line1P2;
|
||||||
QGraphicsLineItem *line1;
|
VScaledLine *line1;
|
||||||
QGraphicsEllipseItem *line2P2;
|
VScaledEllipse *line2P2;
|
||||||
QGraphicsLineItem *line2;
|
VScaledLine *line2;
|
||||||
qreal length;
|
qreal length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,8 @@ VisToolCurveIntersectAxis::VisToolCurveIntersectAxis(const VContainer *data, QGr
|
||||||
|
|
||||||
visCurve = InitItem<VCurvePathItem>(Qt::darkGreen, this);
|
visCurve = InitItem<VCurvePathItem>(Qt::darkGreen, this);
|
||||||
basePoint = InitPoint(supportColor, this);
|
basePoint = InitPoint(supportColor, this);
|
||||||
baseLine = InitItem<QGraphicsLineItem>(supportColor, this);
|
baseLine = InitItem<VScaledLine>(supportColor, this);
|
||||||
axisLine = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
|
axisLine = InitItem<VScaledLine>(supportColor, this); //-V656
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,17 +113,3 @@ void VisToolCurveIntersectAxis::setAxisPointId(const quint32 &value)
|
||||||
{
|
{
|
||||||
axisPointId = value;
|
axisPointId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolCurveIntersectAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(basePoint, scale);
|
|
||||||
ScalePenWidth(baseLine, scale);
|
|
||||||
ScalePenWidth(axisLine, scale);
|
|
||||||
ScalePenWidth(visCurve, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -54,17 +54,14 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolCurveIntersectAxis)
|
Q_DISABLE_COPY(VisToolCurveIntersectAxis)
|
||||||
quint32 axisPointId;
|
quint32 axisPointId;
|
||||||
qreal angle;
|
qreal angle;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *basePoint;
|
VScaledEllipse *basePoint;
|
||||||
QGraphicsLineItem *baseLine;
|
VScaledLine *baseLine;
|
||||||
QGraphicsLineItem *axisLine;
|
VScaledLine *axisLine;
|
||||||
VCurvePathItem *visCurve;
|
VCurvePathItem *visCurve;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -110,13 +110,3 @@ void VisToolEndLine::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolEndLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -56,14 +56,11 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolEndLine)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolEndLine)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolEndLine)
|
Q_DISABLE_COPY(VisToolEndLine)
|
||||||
qreal length;
|
qreal length;
|
||||||
qreal angle;
|
qreal angle;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLENDLINE_H
|
#endif // VISTOOLENDLINE_H
|
||||||
|
|
|
@ -50,8 +50,8 @@ VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent)
|
||||||
base_point = InitPoint(supportColor, this);
|
base_point = InitPoint(supportColor, this);
|
||||||
lineP1 = InitPoint(supportColor, this);
|
lineP1 = InitPoint(supportColor, this);
|
||||||
lineP2 = InitPoint(supportColor, this);
|
lineP2 = InitPoint(supportColor, this);
|
||||||
line = InitItem<QGraphicsLineItem>(supportColor, this);
|
line = InitItem<VScaledLine>(supportColor, this);
|
||||||
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
|
line_intersection = InitItem<VScaledLine>(supportColor, this); //-V656
|
||||||
|
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
@ -112,21 +112,6 @@ void VisToolHeight::setLineP2Id(const quint32 &value)
|
||||||
lineP2Id = value;
|
lineP2Id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolHeight::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(base_point, scale);
|
|
||||||
ScalePoint(lineP1, scale);
|
|
||||||
ScalePoint(lineP2, scale);
|
|
||||||
ScalePenWidth(line, scale);
|
|
||||||
ScalePenWidth(line_intersection, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line)
|
void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,20 +53,17 @@ public:
|
||||||
void setLineP2Id(const quint32 &value);
|
void setLineP2Id(const quint32 &value);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolHeight)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolHeight)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolHeight)
|
Q_DISABLE_COPY(VisToolHeight)
|
||||||
//base point in parent class
|
//base point in parent class
|
||||||
quint32 lineP1Id;//first point of line
|
quint32 lineP1Id;//first point of line
|
||||||
quint32 lineP2Id;//second point of line
|
quint32 lineP2Id;//second point of line
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *base_point;
|
VScaledEllipse *base_point;
|
||||||
QGraphicsEllipseItem *lineP1;
|
VScaledEllipse *lineP1;
|
||||||
QGraphicsEllipseItem *lineP2;
|
VScaledEllipse *lineP2;
|
||||||
QGraphicsLineItem *line;
|
VScaledLine *line;
|
||||||
QGraphicsLineItem *line_intersection;
|
VScaledLine *line_intersection;
|
||||||
void ShowIntersection(const QLineF &height_line, const QLineF &base_line);
|
void ShowIntersection(const QLineF &height_line, const QLineF &base_line);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ void VisToolLine::setPoint2Id(const quint32 &value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolLine::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style)
|
void VisToolLine::DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style)
|
||||||
{
|
{
|
||||||
SCASSERT (lineItem != nullptr)
|
SCASSERT (lineItem != nullptr)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolLine)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolLine)};
|
||||||
protected:
|
protected:
|
||||||
virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
|
virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color,
|
||||||
Qt::PenStyle style = Qt::SolidLine) Q_DECL_OVERRIDE;
|
Qt::PenStyle style = Qt::SolidLine) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolLine)
|
Q_DISABLE_COPY(VisToolLine)
|
||||||
|
|
|
@ -48,7 +48,7 @@ VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem
|
||||||
{
|
{
|
||||||
line1P1 = InitPoint(supportColor, this);
|
line1P1 = InitPoint(supportColor, this);
|
||||||
line1P2 = InitPoint(supportColor, this);
|
line1P2 = InitPoint(supportColor, this);
|
||||||
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
line1 = InitItem<VScaledLine>(supportColor, this);
|
||||||
|
|
||||||
line2P1 = InitPoint(supportColor, this);
|
line2P1 = InitPoint(supportColor, this);
|
||||||
line2P2 = InitPoint(supportColor, this);
|
line2P2 = InitPoint(supportColor, this);
|
||||||
|
@ -135,18 +135,3 @@ void VisToolLineIntersect::setLine2P2Id(const quint32 &value)
|
||||||
{
|
{
|
||||||
line2P2Id = value;
|
line2P2Id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolLineIntersect::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(line1P1, scale);
|
|
||||||
ScalePoint(line1P2, scale);
|
|
||||||
ScalePenWidth(line1, scale);
|
|
||||||
ScalePoint(line2P1, scale);
|
|
||||||
ScalePoint(line2P2, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -53,20 +53,17 @@ public:
|
||||||
void setLine2P2Id(const quint32 &value);
|
void setLine2P2Id(const quint32 &value);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersect)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersect)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolLineIntersect)
|
Q_DISABLE_COPY(VisToolLineIntersect)
|
||||||
quint32 line1P2Id;
|
quint32 line1P2Id;
|
||||||
quint32 line2P1Id;
|
quint32 line2P1Id;
|
||||||
quint32 line2P2Id;
|
quint32 line2P2Id;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *line1P1;
|
VScaledEllipse *line1P1;
|
||||||
QGraphicsEllipseItem *line1P2;
|
VScaledEllipse *line1P2;
|
||||||
QGraphicsLineItem *line1;
|
VScaledLine *line1;
|
||||||
QGraphicsEllipseItem *line2P1;
|
VScaledEllipse *line2P1;
|
||||||
QGraphicsEllipseItem *line2P2;
|
VScaledEllipse *line2P2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLLINEINTERSECT_H
|
#endif // VISTOOLLINEINTERSECT_H
|
||||||
|
|
|
@ -53,9 +53,9 @@ VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGrap
|
||||||
lineP1 = InitPoint(supportColor, this);
|
lineP1 = InitPoint(supportColor, this);
|
||||||
lineP2 = InitPoint(supportColor, this);
|
lineP2 = InitPoint(supportColor, this);
|
||||||
basePoint = InitPoint(supportColor, this);
|
basePoint = InitPoint(supportColor, this);
|
||||||
baseLine = InitItem<QGraphicsLineItem>(supportColor, this);
|
baseLine = InitItem<VScaledLine>(supportColor, this);
|
||||||
axisLine = InitItem<QGraphicsLineItem>(supportColor, this);
|
axisLine = InitItem<VScaledLine>(supportColor, this);
|
||||||
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this);
|
line_intersection = InitItem<VScaledLine>(supportColor, this);
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,22 +133,6 @@ void VisToolLineIntersectAxis::setAxisPointId(const quint32 &value)
|
||||||
axisPointId = value;
|
axisPointId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolLineIntersectAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(lineP1, scale);
|
|
||||||
ScalePoint(lineP2, scale);
|
|
||||||
ScalePoint(basePoint, scale);
|
|
||||||
ScalePenWidth(baseLine, scale);
|
|
||||||
ScalePenWidth(axisLine, scale);
|
|
||||||
ScalePenWidth(line_intersection, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line)
|
void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,21 +56,18 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolLineIntersectAxis)
|
Q_DISABLE_COPY(VisToolLineIntersectAxis)
|
||||||
quint32 point2Id;
|
quint32 point2Id;
|
||||||
quint32 axisPointId;
|
quint32 axisPointId;
|
||||||
qreal angle;
|
qreal angle;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *lineP1;
|
VScaledEllipse *lineP1;
|
||||||
QGraphicsEllipseItem *lineP2;
|
VScaledEllipse *lineP2;
|
||||||
QGraphicsEllipseItem *basePoint;
|
VScaledEllipse *basePoint;
|
||||||
QGraphicsLineItem *baseLine;
|
VScaledLine *baseLine;
|
||||||
QGraphicsLineItem *axisLine;
|
VScaledLine *axisLine;
|
||||||
QGraphicsLineItem *line_intersection;
|
VScaledLine *line_intersection;
|
||||||
void ShowIntersection(const QLineF &axis_line, const QLineF &base_line);
|
void ShowIntersection(const QLineF &axis_line, const QLineF &base_line);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
|
||||||
lineP1 = InitPoint(supportColor, this);
|
lineP1 = InitPoint(supportColor, this);
|
||||||
lineP2 = InitPoint(supportColor, this); //-V656
|
lineP2 = InitPoint(supportColor, this); //-V656
|
||||||
line = InitItem<QGraphicsLineItem>(supportColor, this);
|
line = InitItem<VScaledLine>(supportColor, this);
|
||||||
|
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
@ -124,16 +124,3 @@ void VisToolNormal::SetAngle(const qreal &value)
|
||||||
{
|
{
|
||||||
angle = value;
|
angle = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolNormal::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(lineP1, scale);
|
|
||||||
ScalePoint(lineP2, scale);
|
|
||||||
ScalePenWidth(line, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,15 +55,13 @@ public:
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolNormal)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolNormal)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolNormal)
|
Q_DISABLE_COPY(VisToolNormal)
|
||||||
quint32 object2Id;
|
quint32 object2Id;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *lineP1;
|
VScaledEllipse *lineP1;
|
||||||
QGraphicsEllipseItem *lineP2;
|
VScaledEllipse *lineP2;
|
||||||
QGraphicsLineItem *line;
|
VScaledLine *line;
|
||||||
qreal length;
|
qreal length;
|
||||||
qreal angle;
|
qreal angle;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *d
|
||||||
arcPath = InitItem<VCurvePathItem>(Qt::darkGreen, this);
|
arcPath = InitItem<VCurvePathItem>(Qt::darkGreen, this);
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
tangent = InitPoint(supportColor, this);
|
tangent = InitPoint(supportColor, this);
|
||||||
tangentLine2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
tangentLine2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -91,19 +91,6 @@ void VisToolPointFromArcAndTangent::setCrossPoint(const CrossCirclesPoint &value
|
||||||
crossPoint = value;
|
crossPoint = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolPointFromArcAndTangent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(tangent, scale);
|
|
||||||
ScalePenWidth(arcPath, scale);
|
|
||||||
ScalePenWidth(tangentLine2, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc)
|
void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,17 +55,14 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromArcAndTangent)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromArcAndTangent)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolPointFromArcAndTangent)
|
Q_DISABLE_COPY(VisToolPointFromArcAndTangent)
|
||||||
quint32 arcId;
|
quint32 arcId;
|
||||||
CrossCirclesPoint crossPoint;
|
CrossCirclesPoint crossPoint;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *tangent;
|
VScaledEllipse *tangent;
|
||||||
VCurvePathItem *arcPath;
|
VCurvePathItem *arcPath;
|
||||||
QGraphicsLineItem *tangentLine2;
|
VScaledLine *tangentLine2;
|
||||||
|
|
||||||
void FindRays(const QPointF &p, const VArc *arc);
|
void FindRays(const QPointF &p, const VArc *arc);
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,11 +47,11 @@ VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContai
|
||||||
: VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint),
|
: VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint),
|
||||||
point(nullptr), tangent(nullptr), cCenter(nullptr), cPath(nullptr), tangent2(nullptr)
|
point(nullptr), tangent(nullptr), cCenter(nullptr), cPath(nullptr), tangent2(nullptr)
|
||||||
{
|
{
|
||||||
cPath = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this);
|
cPath = InitItem<VScaledEllipse>(Qt::darkGreen, this);
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
tangent = InitPoint(supportColor, this);
|
tangent = InitPoint(supportColor, this);
|
||||||
cCenter = InitPoint(supportColor, this); //-V656
|
cCenter = InitPoint(supportColor, this); //-V656
|
||||||
tangent2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
tangent2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -101,20 +101,6 @@ void VisToolPointFromCircleAndTangent::setCrossPoint(const CrossCirclesPoint &va
|
||||||
crossPoint = value;
|
crossPoint = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolPointFromCircleAndTangent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(tangent, scale);
|
|
||||||
ScalePoint(cCenter, scale);
|
|
||||||
ScalePoint(cPath, scale);
|
|
||||||
ScalePenWidth(tangent2, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPointFromCircleAndTangent::FindRays(const QPointF &p, const QPointF ¢er, qreal radius)
|
void VisToolPointFromCircleAndTangent::FindRays(const QPointF &p, const QPointF ¢er, qreal radius)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,19 +56,16 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromCircleAndTangent)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromCircleAndTangent)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolPointFromCircleAndTangent)
|
Q_DISABLE_COPY(VisToolPointFromCircleAndTangent)
|
||||||
quint32 object2Id;
|
quint32 object2Id;
|
||||||
qreal cRadius;
|
qreal cRadius;
|
||||||
CrossCirclesPoint crossPoint;
|
CrossCirclesPoint crossPoint;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *tangent;
|
VScaledEllipse *tangent;
|
||||||
QGraphicsEllipseItem *cCenter;
|
VScaledEllipse *cCenter;
|
||||||
QGraphicsEllipseItem *cPath;
|
VScaledEllipse *cPath;
|
||||||
QGraphicsLineItem *tangent2;
|
VScaledLine *tangent2;
|
||||||
|
|
||||||
void FindRays(const QPointF &p, const QPointF ¢er, qreal radius);
|
void FindRays(const QPointF &p, const QPointF ¢er, qreal radius);
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,7 +50,7 @@ VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsIt
|
||||||
arc_point = InitPoint(supportColor, this);
|
arc_point = InitPoint(supportColor, this);
|
||||||
lineP1 = InitPoint(supportColor, this);
|
lineP1 = InitPoint(supportColor, this);
|
||||||
lineP2 = InitPoint(supportColor, this);
|
lineP2 = InitPoint(supportColor, this);
|
||||||
circle = InitItem<QGraphicsEllipseItem>(supportColor, this);
|
circle = InitItem<VScaledEllipse>(supportColor, this);
|
||||||
|
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
@ -114,17 +114,3 @@ void VisToolPointOfContact::setRadius(const QString &expression)
|
||||||
{
|
{
|
||||||
radius = FindLength(expression, Visualization::data->PlainVariables());
|
radius = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolPointOfContact::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(lineP1, scale);
|
|
||||||
ScalePoint(lineP2, scale);
|
|
||||||
ScalePoint(arc_point, scale);
|
|
||||||
ScalePoint(circle, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -52,18 +52,15 @@ public:
|
||||||
void setRadius(const QString &expression);
|
void setRadius(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfContact)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfContact)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolPointOfContact)
|
Q_DISABLE_COPY(VisToolPointOfContact)
|
||||||
quint32 lineP2Id;
|
quint32 lineP2Id;
|
||||||
quint32 radiusId;
|
quint32 radiusId;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *lineP1;
|
VScaledEllipse *lineP1;
|
||||||
QGraphicsEllipseItem *lineP2;
|
VScaledEllipse *lineP2;
|
||||||
QGraphicsEllipseItem *arc_point;
|
VScaledEllipse *arc_point;
|
||||||
QGraphicsEllipseItem *circle;
|
VScaledEllipse *circle;
|
||||||
qreal radius;
|
qreal radius;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,7 +48,7 @@ VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, Q
|
||||||
{
|
{
|
||||||
axisP1 = InitPoint(supportColor, this);
|
axisP1 = InitPoint(supportColor, this);
|
||||||
axisP2 = InitPoint(supportColor, this); //-V656
|
axisP2 = InitPoint(supportColor, this); //-V656
|
||||||
axis2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
axis2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
|
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
@ -93,19 +93,6 @@ void VisToolPointOfIntersection::setPoint2Id(const quint32 &value)
|
||||||
point2Id = value;
|
point2Id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolPointOfIntersection::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(axisP1, scale);
|
|
||||||
ScalePoint(axisP2, scale);
|
|
||||||
ScalePenWidth(axis2, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color)
|
void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,16 +53,13 @@ public:
|
||||||
void setPoint2Id(const quint32 &value);
|
void setPoint2Id(const quint32 &value);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolPointOfIntersection)
|
Q_DISABLE_COPY(VisToolPointOfIntersection)
|
||||||
quint32 point2Id;
|
quint32 point2Id;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *axisP1;//axis1 is class themself
|
VScaledEllipse *axisP1;//axis1 is class themself
|
||||||
QGraphicsEllipseItem *axisP2;
|
VScaledEllipse *axisP2;
|
||||||
QGraphicsLineItem *axis2;//axis1 is class themself
|
VScaledLine *axis2;//axis1 is class themself
|
||||||
|
|
||||||
void ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color);
|
void ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color);
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,15 +114,3 @@ void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossCirclesPoint &valu
|
||||||
{
|
{
|
||||||
crossPoint = value;
|
crossPoint = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolPointOfIntersectionArcs::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePenWidth(arc1Path, scale);
|
|
||||||
ScalePenWidth(arc2Path, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -56,15 +56,12 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionArcs)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionArcs)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolPointOfIntersectionArcs)
|
Q_DISABLE_COPY(VisToolPointOfIntersectionArcs)
|
||||||
quint32 arc1Id;
|
quint32 arc1Id;
|
||||||
quint32 arc2Id;
|
quint32 arc2Id;
|
||||||
CrossCirclesPoint crossPoint;
|
CrossCirclesPoint crossPoint;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
VCurvePathItem *arc1Path;
|
VCurvePathItem *arc1Path;
|
||||||
VCurvePathItem *arc2Path;
|
VCurvePathItem *arc2Path;
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,8 +52,8 @@ VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VCont
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::NoPen)); // don't use parent this time
|
this->setPen(QPen(Qt::NoPen)); // don't use parent this time
|
||||||
|
|
||||||
c1Path = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this);
|
c1Path = InitItem<VScaledEllipse>(Qt::darkGreen, this);
|
||||||
c2Path = InitItem<QGraphicsEllipseItem>(Qt::darkRed, this);
|
c2Path = InitItem<VScaledEllipse>(Qt::darkRed, this);
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
c1Center = InitPoint(supportColor, this);
|
c1Center = InitPoint(supportColor, this);
|
||||||
c2Center = InitPoint(supportColor, this); //-V656
|
c2Center = InitPoint(supportColor, this); //-V656
|
||||||
|
@ -125,18 +125,3 @@ void VisToolPointOfIntersectionCircles::setCrossPoint(const CrossCirclesPoint &v
|
||||||
{
|
{
|
||||||
crossPoint = value;
|
crossPoint = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolPointOfIntersectionCircles::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(c1Center, scale);
|
|
||||||
ScalePoint(c2Center, scale);
|
|
||||||
ScalePoint(c1Path, scale);
|
|
||||||
ScalePoint(c2Path, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -57,20 +57,17 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCircles)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCircles)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolPointOfIntersectionCircles)
|
Q_DISABLE_COPY(VisToolPointOfIntersectionCircles)
|
||||||
quint32 object2Id;
|
quint32 object2Id;
|
||||||
qreal c1Radius;
|
qreal c1Radius;
|
||||||
qreal c2Radius;
|
qreal c2Radius;
|
||||||
CrossCirclesPoint crossPoint;
|
CrossCirclesPoint crossPoint;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *c1Center;
|
VScaledEllipse *c1Center;
|
||||||
QGraphicsEllipseItem *c2Center;
|
VScaledEllipse *c2Center;
|
||||||
QGraphicsEllipseItem *c1Path;
|
VScaledEllipse *c1Path;
|
||||||
QGraphicsEllipseItem *c2Path;
|
VScaledEllipse *c2Path;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLPOINTOFINTERSECTIONCIRCLES_H
|
#endif // VISTOOLPOINTOFINTERSECTIONCIRCLES_H
|
||||||
|
|
|
@ -50,11 +50,11 @@ VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem
|
||||||
{
|
{
|
||||||
line1P1 = InitPoint(supportColor, this);
|
line1P1 = InitPoint(supportColor, this);
|
||||||
line1P2 = InitPoint(supportColor, this); //-V656
|
line1P2 = InitPoint(supportColor, this); //-V656
|
||||||
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
line1 = InitItem<VScaledLine>(supportColor, this);
|
||||||
|
|
||||||
line2P2 = InitPoint(supportColor, this);
|
line2P2 = InitPoint(supportColor, this);
|
||||||
line2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
line2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
line3 = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
|
line3 = InitItem<VScaledLine>(supportColor, this); //-V656
|
||||||
|
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
@ -131,19 +131,3 @@ void VisToolShoulderPoint::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolShoulderPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(line1P1, scale);
|
|
||||||
ScalePoint(line1P2, scale);
|
|
||||||
ScalePenWidth(line1, scale);
|
|
||||||
ScalePoint(line2P2, scale);
|
|
||||||
ScalePenWidth(line2, scale);
|
|
||||||
ScalePenWidth(line3, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -52,20 +52,17 @@ public:
|
||||||
void setLength(const QString &expression);
|
void setLength(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolShoulderPoint)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolShoulderPoint)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolShoulderPoint)
|
Q_DISABLE_COPY(VisToolShoulderPoint)
|
||||||
quint32 lineP1Id;
|
quint32 lineP1Id;
|
||||||
quint32 lineP2Id;
|
quint32 lineP2Id;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *line1P1;
|
VScaledEllipse *line1P1;
|
||||||
QGraphicsEllipseItem *line1P2;
|
VScaledEllipse *line1P2;
|
||||||
QGraphicsLineItem *line1;
|
VScaledLine *line1;
|
||||||
QGraphicsEllipseItem *line2P2;
|
VScaledEllipse *line2P2;
|
||||||
QGraphicsLineItem *line2;
|
VScaledLine *line2;
|
||||||
QGraphicsLineItem *line3;
|
VScaledLine *line3;
|
||||||
qreal length;
|
qreal length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,11 @@ VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent)
|
||||||
{
|
{
|
||||||
axisP1 = InitPoint(supportColor, this);
|
axisP1 = InitPoint(supportColor, this);
|
||||||
axisP2 = InitPoint(supportColor, this);
|
axisP2 = InitPoint(supportColor, this);
|
||||||
axis = InitItem<QGraphicsPathItem>(supportColor, this);
|
axis = InitItem<VCurvePathItem>(supportColor, this);
|
||||||
hypotenuseP1 = InitPoint(supportColor, this);
|
hypotenuseP1 = InitPoint(supportColor, this);
|
||||||
hypotenuseP2 = InitPoint(supportColor, this);
|
hypotenuseP2 = InitPoint(supportColor, this);
|
||||||
foot1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
foot1 = InitItem<VScaledLine>(supportColor, this);
|
||||||
foot2 = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
|
foot2 = InitItem<VScaledLine>(supportColor, this); //-V656
|
||||||
|
|
||||||
point = InitPoint(mainColor, this);
|
point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
@ -144,24 +144,7 @@ void VisToolTriangle::setHypotenuseP2Id(const quint32 &value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolTriangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void VisToolTriangle::DrawAimedAxis(VCurvePathItem *item, const QLineF &line, const QColor &color,
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePoint(axisP1, scale);
|
|
||||||
ScalePoint(axisP2, scale);
|
|
||||||
ScalePenWidth(axis, scale);
|
|
||||||
ScalePoint(hypotenuseP1, scale);
|
|
||||||
ScalePoint(hypotenuseP2, scale);
|
|
||||||
ScalePenWidth(foot1, scale);
|
|
||||||
ScalePenWidth(foot2, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolTriangle::DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line, const QColor &color,
|
|
||||||
Qt::PenStyle style)
|
Qt::PenStyle style)
|
||||||
{
|
{
|
||||||
SCASSERT (item != nullptr)
|
SCASSERT (item != nullptr)
|
||||||
|
|
|
@ -57,24 +57,21 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolTriangle)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolTriangle)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolTriangle)
|
Q_DISABLE_COPY(VisToolTriangle)
|
||||||
quint32 object2Id;//axis second point
|
quint32 object2Id;//axis second point
|
||||||
quint32 hypotenuseP1Id;
|
quint32 hypotenuseP1Id;
|
||||||
quint32 hypotenuseP2Id;
|
quint32 hypotenuseP2Id;
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *axisP1;
|
VScaledEllipse *axisP1;
|
||||||
QGraphicsEllipseItem *axisP2;
|
VScaledEllipse *axisP2;
|
||||||
QGraphicsPathItem *axis;
|
VCurvePathItem *axis;
|
||||||
QGraphicsEllipseItem *hypotenuseP1;
|
VScaledEllipse *hypotenuseP1;
|
||||||
QGraphicsEllipseItem *hypotenuseP2;
|
VScaledEllipse *hypotenuseP2;
|
||||||
QGraphicsLineItem *foot1;
|
VScaledLine *foot1;
|
||||||
QGraphicsLineItem *foot2;
|
VScaledLine *foot2;
|
||||||
|
|
||||||
void DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line, const QColor &color,
|
void DrawAimedAxis(VCurvePathItem *item, const QLineF &line, const QColor &color,
|
||||||
Qt::PenStyle style = Qt::SolidLine);
|
Qt::PenStyle style = Qt::SolidLine);
|
||||||
void DrawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size);
|
void DrawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size);
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,10 +67,10 @@ VisToolTrueDarts::VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent
|
||||||
dartP2 = InitPoint(supportColor, this);
|
dartP2 = InitPoint(supportColor, this);
|
||||||
dartP3 = InitPoint(supportColor, this);
|
dartP3 = InitPoint(supportColor, this);
|
||||||
|
|
||||||
lineblP1P1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
lineblP1P1 = InitItem<VScaledLine>(supportColor, this);
|
||||||
lineblP2P2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
lineblP2P2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
p1d2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
p1d2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
d2p2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
d2p2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
|
|
||||||
point1 = InitPoint(mainColor, this);
|
point1 = InitPoint(mainColor, this);
|
||||||
point2 = InitPoint(mainColor, this); //-V656
|
point2 = InitPoint(mainColor, this); //-V656
|
||||||
|
@ -163,24 +163,3 @@ void VisToolTrueDarts::setD3PointId(const quint32 &value)
|
||||||
{
|
{
|
||||||
dartP3Id = value;
|
dartP3Id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolTrueDarts::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point1, scale);
|
|
||||||
ScalePoint(point2, scale);
|
|
||||||
ScalePoint(baseLineP1, scale);
|
|
||||||
ScalePoint(baseLineP2, scale);
|
|
||||||
ScalePoint(dartP1, scale);
|
|
||||||
ScalePoint(dartP2, scale);
|
|
||||||
ScalePoint(dartP3, scale);
|
|
||||||
|
|
||||||
ScalePenWidth(lineblP1P1, scale);
|
|
||||||
ScalePenWidth(lineblP2P2, scale);
|
|
||||||
ScalePenWidth(p1d2, scale);
|
|
||||||
ScalePenWidth(d2p2, scale);
|
|
||||||
|
|
||||||
VisLine::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolTrueDarts)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolTrueDarts)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolTrueDarts)
|
Q_DISABLE_COPY(VisToolTrueDarts)
|
||||||
quint32 baseLineP2Id;
|
quint32 baseLineP2Id;
|
||||||
|
@ -65,18 +62,18 @@ private:
|
||||||
quint32 dartP2Id;
|
quint32 dartP2Id;
|
||||||
quint32 dartP3Id;
|
quint32 dartP3Id;
|
||||||
|
|
||||||
QGraphicsEllipseItem *point1;
|
VScaledEllipse *point1;
|
||||||
QGraphicsEllipseItem *point2;
|
VScaledEllipse *point2;
|
||||||
QGraphicsEllipseItem *baseLineP1;
|
VScaledEllipse *baseLineP1;
|
||||||
QGraphicsEllipseItem *baseLineP2;
|
VScaledEllipse *baseLineP2;
|
||||||
QGraphicsEllipseItem *dartP1;
|
VScaledEllipse *dartP1;
|
||||||
QGraphicsEllipseItem *dartP2;
|
VScaledEllipse *dartP2;
|
||||||
QGraphicsEllipseItem *dartP3;
|
VScaledEllipse *dartP3;
|
||||||
|
|
||||||
QGraphicsLineItem *lineblP1P1;
|
VScaledLine *lineblP1P1;
|
||||||
QGraphicsLineItem *lineblP2P2;
|
VScaledLine *lineblP2P2;
|
||||||
QGraphicsLineItem *p1d2;
|
VScaledLine *p1d2;
|
||||||
QGraphicsLineItem *d2p2;
|
VScaledLine *d2p2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLTRUEDARTS_H
|
#endif // VISTOOLTRUEDARTS_H
|
||||||
|
|
|
@ -45,22 +45,6 @@ VisPath::VisPath(const VContainer *data, QGraphicsItem *parent)
|
||||||
InitPen();
|
InitPen();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
ScalePenWidth(this, SceneScale(scene()));
|
|
||||||
|
|
||||||
VCurvePathItem::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QRectF VisPath::boundingRect() const
|
|
||||||
{
|
|
||||||
QRectF recTool = VCurvePathItem::boundingRect();
|
|
||||||
recTool = recTool.united(childrenBoundingRect());
|
|
||||||
return recTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisPath::InitPen()
|
void VisPath::InitPen()
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,10 +51,6 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::Path)};
|
enum { Type = UserType + static_cast<int>(Vis::Path)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
|
||||||
protected:
|
protected:
|
||||||
virtual void InitPen() Q_DECL_OVERRIDE;
|
virtual void InitPen() Q_DECL_OVERRIDE;
|
||||||
virtual void AddOnScene() Q_DECL_OVERRIDE;
|
virtual void AddOnScene() Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../visualization.h"
|
#include "../visualization.h"
|
||||||
#include "vispath.h"
|
#include "vispath.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent)
|
VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -82,13 +83,3 @@ void VisToolArc::setF2(const QString &expression)
|
||||||
{
|
{
|
||||||
f2 = FindVal(expression, Visualization::data->PlainVariables());
|
f2 = FindVal(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(arcCenter, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -52,12 +52,9 @@ public:
|
||||||
void setF2(const QString &expression);
|
void setF2(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolArc)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolArc)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolArc)
|
Q_DISABLE_COPY(VisToolArc)
|
||||||
QGraphicsEllipseItem *arcCenter;
|
VScaledEllipse *arcCenter;
|
||||||
qreal radius;
|
qreal radius;
|
||||||
qreal f1;
|
qreal f1;
|
||||||
qreal f2;
|
qreal f2;
|
||||||
|
|
|
@ -82,13 +82,3 @@ void VisToolArcWithLength::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolArcWithLength::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(arcCenter, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -52,12 +52,9 @@ public:
|
||||||
void setLength(const QString &expression);
|
void setLength(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolArcWithLength)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolArcWithLength)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolArcWithLength)
|
Q_DISABLE_COPY(VisToolArcWithLength)
|
||||||
QGraphicsEllipseItem *arcCenter;
|
VScaledEllipse *arcCenter;
|
||||||
qreal radius;
|
qreal radius;
|
||||||
qreal f1;
|
qreal f1;
|
||||||
qreal length;
|
qreal length;
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../visualization.h"
|
#include "../visualization.h"
|
||||||
#include "vispath.h"
|
#include "vispath.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent)
|
VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -57,8 +58,8 @@ VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *pa
|
||||||
helpLine1(nullptr),
|
helpLine1(nullptr),
|
||||||
helpLine2(nullptr)
|
helpLine2(nullptr)
|
||||||
{
|
{
|
||||||
helpLine1 = InitItem<QGraphicsLineItem>(mainColor, this);
|
helpLine1 = InitItem<VScaledLine>(mainColor, this);
|
||||||
helpLine2 = InitItem<QGraphicsLineItem>(mainColor, this);
|
helpLine2 = InitItem<VScaledLine>(mainColor, this);
|
||||||
|
|
||||||
point1 = InitPoint(supportColor, this);
|
point1 = InitPoint(supportColor, this);
|
||||||
point2 = InitPoint(supportColor, this); //-V656
|
point2 = InitPoint(supportColor, this); //-V656
|
||||||
|
@ -135,18 +136,3 @@ void VisToolCubicBezier::setObject4Id(const quint32 &value)
|
||||||
{
|
{
|
||||||
object4Id = value;
|
object4Id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolCubicBezier::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point1, scale);
|
|
||||||
ScalePoint(point2, scale);
|
|
||||||
ScalePoint(point3, scale);
|
|
||||||
ScalePoint(point4, scale);
|
|
||||||
ScalePenWidth(helpLine1, scale);
|
|
||||||
ScalePenWidth(helpLine2, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -54,20 +54,17 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolCubicBezier)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolCubicBezier)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
protected:
|
protected:
|
||||||
Q_DISABLE_COPY(VisToolCubicBezier)
|
Q_DISABLE_COPY(VisToolCubicBezier)
|
||||||
quint32 object2Id;
|
quint32 object2Id;
|
||||||
quint32 object3Id;
|
quint32 object3Id;
|
||||||
quint32 object4Id;
|
quint32 object4Id;
|
||||||
QGraphicsEllipseItem *point1;
|
VScaledEllipse *point1;
|
||||||
QGraphicsEllipseItem *point2;
|
VScaledEllipse *point2;
|
||||||
QGraphicsEllipseItem *point3;
|
VScaledEllipse *point3;
|
||||||
QGraphicsEllipseItem *point4;
|
VScaledEllipse *point4;
|
||||||
QGraphicsLineItem *helpLine1;
|
VScaledLine *helpLine1;
|
||||||
QGraphicsLineItem *helpLine2;
|
VScaledLine *helpLine2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLCUBICBEZIER_H
|
#endif // VISTOOLCUBICBEZIER_H
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "../vgeometry/vspline.h"
|
#include "../vgeometry/vspline.h"
|
||||||
#include "../visualization.h"
|
#include "../visualization.h"
|
||||||
#include "vispath.h"
|
#include "vispath.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent)
|
VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -53,8 +54,8 @@ VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphics
|
||||||
helpLine1(nullptr),
|
helpLine1(nullptr),
|
||||||
helpLine2(nullptr)
|
helpLine2(nullptr)
|
||||||
{
|
{
|
||||||
helpLine1 = InitItem<QGraphicsLineItem>(mainColor, this);
|
helpLine1 = InitItem<VScaledLine>(mainColor, this);
|
||||||
helpLine2 = InitItem<QGraphicsLineItem>(mainColor, this);
|
helpLine2 = InitItem<VScaledLine>(mainColor, this);
|
||||||
|
|
||||||
newCurveSegment = InitItem<VCurvePathItem>(mainColor, this);
|
newCurveSegment = InitItem<VCurvePathItem>(mainColor, this);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ void VisToolCubicBezierPath::RefreshGeometry()
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
QGraphicsEllipseItem *point = this->getPoint(mainPoints, static_cast<unsigned>(i), 1/*zValue*/);
|
VScaledEllipse *point = this->getPoint(mainPoints, static_cast<unsigned>(i), 1/*zValue*/);
|
||||||
DrawPoint(point, static_cast<QPointF>(pathPoints.at(i)), supportColor);
|
DrawPoint(point, static_cast<QPointF>(pathPoints.at(i)), supportColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,18 +107,18 @@ void VisToolCubicBezierPath::RefreshGeometry()
|
||||||
|
|
||||||
const VSpline spl = path.GetSpline(i);
|
const VSpline spl = path.GetSpline(i);
|
||||||
|
|
||||||
QGraphicsLineItem *ctrlLine1 = this->getLine(static_cast<unsigned>(preLastPoint));
|
VScaledLine *ctrlLine1 = this->getLine(static_cast<unsigned>(preLastPoint));
|
||||||
DrawLine(ctrlLine1, QLineF(static_cast<QPointF>(spl.GetP1()), static_cast<QPointF>(spl.GetP2())),
|
DrawLine(ctrlLine1, QLineF(static_cast<QPointF>(spl.GetP1()), static_cast<QPointF>(spl.GetP2())),
|
||||||
mainColor, Qt::DashLine);
|
mainColor, Qt::DashLine);
|
||||||
|
|
||||||
QGraphicsEllipseItem *p2 = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
VScaledEllipse *p2 = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||||
DrawPoint(p2, static_cast<QPointF>(spl.GetP2()), Qt::green);
|
DrawPoint(p2, static_cast<QPointF>(spl.GetP2()), Qt::green);
|
||||||
|
|
||||||
QGraphicsLineItem *ctrlLine2 = this->getLine(static_cast<unsigned>(lastPoint));
|
VScaledLine *ctrlLine2 = this->getLine(static_cast<unsigned>(lastPoint));
|
||||||
DrawLine(ctrlLine2, QLineF(static_cast<QPointF>(spl.GetP4()), static_cast<QPointF>(spl.GetP3())),
|
DrawLine(ctrlLine2, QLineF(static_cast<QPointF>(spl.GetP4()), static_cast<QPointF>(spl.GetP3())),
|
||||||
mainColor, Qt::DashLine);
|
mainColor, Qt::DashLine);
|
||||||
|
|
||||||
QGraphicsEllipseItem *p3 = this->getPoint(ctrlPoints, static_cast<unsigned>(lastPoint));
|
VScaledEllipse *p3 = this->getPoint(ctrlPoints, static_cast<unsigned>(lastPoint));
|
||||||
DrawPoint(p3, static_cast<QPointF>(spl.GetP3()), Qt::green);
|
DrawPoint(p3, static_cast<QPointF>(spl.GetP3()), Qt::green);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,34 +143,7 @@ VCubicBezierPath VisToolCubicBezierPath::getPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolCubicBezierPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
VScaledEllipse *VisToolCubicBezierPath::getPoint(QVector<VScaledEllipse *> &points, quint32 i, qreal z)
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
for (int i=0; i < mainPoints.size(); ++i)
|
|
||||||
{
|
|
||||||
ScalePoint(mainPoints[i], scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i < ctrlPoints.size(); ++i)
|
|
||||||
{
|
|
||||||
ScalePoint(ctrlPoints[i], scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i < lines.size(); ++i)
|
|
||||||
{
|
|
||||||
ScalePenWidth(lines[i], scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScalePenWidth(newCurveSegment, scale);
|
|
||||||
ScalePenWidth(helpLine1, scale);
|
|
||||||
ScalePenWidth(helpLine2, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QGraphicsEllipseItem *VisToolCubicBezierPath::getPoint(QVector<QGraphicsEllipseItem *> &points, quint32 i, qreal z)
|
|
||||||
{
|
{
|
||||||
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
||||||
{
|
{
|
||||||
|
@ -184,7 +158,7 @@ QGraphicsEllipseItem *VisToolCubicBezierPath::getPoint(QVector<QGraphicsEllipseI
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsLineItem *VisToolCubicBezierPath::getLine(quint32 i)
|
VScaledLine *VisToolCubicBezierPath::getLine(quint32 i)
|
||||||
{
|
{
|
||||||
if (static_cast<quint32>(lines.size() - 1) >= i && lines.isEmpty() == false)
|
if (static_cast<quint32>(lines.size() - 1) >= i && lines.isEmpty() == false)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +166,7 @@ QGraphicsLineItem *VisToolCubicBezierPath::getLine(quint32 i)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto line = InitItem<QGraphicsLineItem>(mainColor, this);
|
auto line = InitItem<VScaledLine>(mainColor, this);
|
||||||
lines.append(line);
|
lines.append(line);
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +208,7 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
|
||||||
DrawLine(helpLine1, p1p2, mainColor, Qt::DashLine);
|
DrawLine(helpLine1, p1p2, mainColor, Qt::DashLine);
|
||||||
|
|
||||||
const int preLastPoint = subSplCount * 2;
|
const int preLastPoint = subSplCount * 2;
|
||||||
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||||
DrawPoint(p2Ctrl, p2, Qt::green);
|
DrawPoint(p2Ctrl, p2, Qt::green);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -263,7 +237,7 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
|
||||||
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||||
|
|
||||||
const int preLastPoint = subSplCount * 2;
|
const int preLastPoint = subSplCount * 2;
|
||||||
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||||
DrawPoint(p2Ctrl, p2, Qt::green);
|
DrawPoint(p2Ctrl, p2, Qt::green);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +263,7 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
|
||||||
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||||
|
|
||||||
const int preLastPoint = subSplCount * 2;
|
const int preLastPoint = subSplCount * 2;
|
||||||
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||||
DrawPoint(p2Ctrl, p2, Qt::green);
|
DrawPoint(p2Ctrl, p2, Qt::green);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,22 +55,19 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolCubicBezierPath)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolCubicBezierPath)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
protected:
|
protected:
|
||||||
Q_DISABLE_COPY(VisToolCubicBezierPath)
|
Q_DISABLE_COPY(VisToolCubicBezierPath)
|
||||||
QVector<QGraphicsEllipseItem *> mainPoints;
|
QVector<VScaledEllipse *> mainPoints;
|
||||||
QVector<QGraphicsEllipseItem *> ctrlPoints;
|
QVector<VScaledEllipse *> ctrlPoints;
|
||||||
QVector<QGraphicsLineItem *> lines;
|
QVector<VScaledLine *> lines;
|
||||||
VCurvePathItem *newCurveSegment;
|
VCurvePathItem *newCurveSegment;
|
||||||
VCubicBezierPath path;
|
VCubicBezierPath path;
|
||||||
QGraphicsLineItem *helpLine1;
|
VScaledLine *helpLine1;
|
||||||
QGraphicsLineItem *helpLine2;
|
VScaledLine *helpLine2;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsEllipseItem *getPoint(QVector<QGraphicsEllipseItem *> &points, quint32 i, qreal z = 0);
|
VScaledEllipse *getPoint(QVector<VScaledEllipse *> &points, quint32 i, qreal z = 0);
|
||||||
QGraphicsLineItem *getLine(quint32 i);
|
VScaledLine *getLine(quint32 i);
|
||||||
void Creating(const QVector<VPointF> &pathPoints , int pointsLeft);
|
void Creating(const QVector<VPointF> &pathPoints , int pointsLeft);
|
||||||
void RefreshToolTip();
|
void RefreshToolTip();
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../visualization.h"
|
#include "../visualization.h"
|
||||||
#include "vispath.h"
|
#include "vispath.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
|
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -83,15 +84,3 @@ void VisToolCutArc::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolCutArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePenWidth(arc1, scale);
|
|
||||||
ScalePenWidth(arc2, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -50,12 +50,9 @@ public:
|
||||||
void setLength(const QString &expression);
|
void setLength(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolCutArc)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolCutArc)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
protected:
|
protected:
|
||||||
Q_DISABLE_COPY(VisToolCutArc)
|
Q_DISABLE_COPY(VisToolCutArc)
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
VCurvePathItem *arc1;
|
VCurvePathItem *arc1;
|
||||||
VCurvePathItem *arc2;
|
VCurvePathItem *arc2;
|
||||||
qreal length;
|
qreal length;
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../visualization.h"
|
#include "../visualization.h"
|
||||||
#include "vispath.h"
|
#include "vispath.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent)
|
VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -91,15 +92,3 @@ void VisToolCutSpline::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolCutSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePenWidth(spl1, scale);
|
|
||||||
ScalePenWidth(spl2, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -50,12 +50,9 @@ public:
|
||||||
void setLength(const QString &expression);
|
void setLength(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
protected:
|
protected:
|
||||||
Q_DISABLE_COPY(VisToolCutSpline)
|
Q_DISABLE_COPY(VisToolCutSpline)
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
VCurvePathItem *spl1;
|
VCurvePathItem *spl1;
|
||||||
VCurvePathItem *spl2;
|
VCurvePathItem *spl2;
|
||||||
qreal length;
|
qreal length;
|
||||||
|
|
|
@ -93,15 +93,3 @@ void VisToolCutSplinePath::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolCutSplinePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePenWidth(splPath1, scale);
|
|
||||||
ScalePenWidth(splPath2, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -50,12 +50,9 @@ public:
|
||||||
void setLength(const QString &expression);
|
void setLength(const QString &expression);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
protected:
|
protected:
|
||||||
Q_DISABLE_COPY(VisToolCutSplinePath)
|
Q_DISABLE_COPY(VisToolCutSplinePath)
|
||||||
QGraphicsEllipseItem *point;
|
VScaledEllipse *point;
|
||||||
VCurvePathItem *splPath1;
|
VCurvePathItem *splPath1;
|
||||||
VCurvePathItem *splPath2;
|
VCurvePathItem *splPath2;
|
||||||
qreal length;
|
qreal length;
|
||||||
|
|
|
@ -91,13 +91,3 @@ void VisToolEllipticalArc::setRotationAngle(const QString &expression)
|
||||||
{
|
{
|
||||||
rotationAngle = FindVal(expression, Visualization::data->PlainVariables());
|
rotationAngle = FindVal(expression, Visualization::data->PlainVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolEllipticalArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(arcCenter, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -54,12 +54,9 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolEllipticalArc)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolEllipticalArc)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolEllipticalArc)
|
Q_DISABLE_COPY(VisToolEllipticalArc)
|
||||||
QGraphicsEllipseItem *arcCenter;
|
VScaledEllipse *arcCenter;
|
||||||
qreal radius1;
|
qreal radius1;
|
||||||
qreal radius2;
|
qreal radius2;
|
||||||
qreal f1;
|
qreal f1;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "vistoolpiece.h"
|
#include "vistoolpiece.h"
|
||||||
#include "../vpatterndb/vpiecepath.h"
|
#include "../vpatterndb/vpiecepath.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -38,8 +39,8 @@ VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
||||||
m_line2(nullptr),
|
m_line2(nullptr),
|
||||||
m_piece()
|
m_piece()
|
||||||
{
|
{
|
||||||
m_line1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
m_line1 = InitItem<VScaledLine>(supportColor, this);
|
||||||
m_line2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
m_line2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -55,7 +56,7 @@ void VisToolPiece::RefreshGeometry()
|
||||||
|
|
||||||
for (int i = 0; i < nodes.size(); ++i)
|
for (int i = 0; i < nodes.size(); ++i)
|
||||||
{
|
{
|
||||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(i), supportColor);
|
VScaledEllipse *point = GetPoint(static_cast<quint32>(i), supportColor);
|
||||||
DrawPoint(point, nodes.at(i).toQPointF(), supportColor);
|
DrawPoint(point, nodes.at(i).toQPointF(), supportColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,23 +80,7 @@ void VisToolPiece::SetPiece(const VPiece &piece)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPiece::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
VScaledEllipse *VisToolPiece::GetPoint(quint32 i, const QColor &color)
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
for (int i=0; i < m_points.size(); ++i)
|
|
||||||
{
|
|
||||||
ScalePoint(m_points[i], scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScalePenWidth(m_line1, scale);
|
|
||||||
ScalePenWidth(m_line2, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QGraphicsEllipseItem *VisToolPiece::GetPoint(quint32 i, const QColor &color)
|
|
||||||
{
|
{
|
||||||
return GetPointItem(m_points, i, color, this);
|
return GetPointItem(m_points, i, color, this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,18 +46,15 @@ public:
|
||||||
void SetPiece(const VPiece &piece);
|
void SetPiece(const VPiece &piece);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPiece)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPiece)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolPiece)
|
Q_DISABLE_COPY(VisToolPiece)
|
||||||
QVector<QGraphicsEllipseItem *> m_points;
|
QVector<VScaledEllipse *> m_points;
|
||||||
|
|
||||||
QGraphicsLineItem *m_line1;
|
VScaledLine *m_line1;
|
||||||
QGraphicsLineItem *m_line2;
|
VScaledLine *m_line2;
|
||||||
VPiece m_piece;
|
VPiece m_piece;
|
||||||
|
|
||||||
QGraphicsEllipseItem* GetPoint(quint32 i, const QColor &color);
|
VScaledEllipse* GetPoint(quint32 i, const QColor &color);
|
||||||
|
|
||||||
void HideAllItems();
|
void HideAllItems();
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "vistoolpiecepath.h"
|
#include "vistoolpiecepath.h"
|
||||||
#include "../vwidgets/vsimplepoint.h"
|
#include "../vwidgets/vsimplepoint.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ VisToolPiecePath::VisToolPiecePath(const VContainer *data, QGraphicsItem *parent
|
||||||
m_line(nullptr),
|
m_line(nullptr),
|
||||||
m_path()
|
m_path()
|
||||||
{
|
{
|
||||||
m_line = InitItem<QGraphicsLineItem>(supportColor, this);
|
m_line = InitItem<VScaledLine>(supportColor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -78,21 +79,6 @@ void VisToolPiecePath::SetPath(const VPiecePath &path)
|
||||||
m_path = path;
|
m_path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolPiecePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
for (int i=0; i < m_points.size(); ++i)
|
|
||||||
{
|
|
||||||
ScalePoint(m_points[i], scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScalePenWidth(m_line, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPiecePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void VisToolPiecePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,9 +48,6 @@ public:
|
||||||
void SetPath(const VPiecePath &path);
|
void SetPath(const VPiecePath &path);
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPiecePath)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPiecePath)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
@ -58,7 +55,7 @@ private:
|
||||||
Q_DISABLE_COPY(VisToolPiecePath)
|
Q_DISABLE_COPY(VisToolPiecePath)
|
||||||
QVector<VSimplePoint *> m_points;
|
QVector<VSimplePoint *> m_points;
|
||||||
|
|
||||||
QGraphicsLineItem *m_line;
|
VScaledLine *m_line;
|
||||||
|
|
||||||
VPiecePath m_path;
|
VPiecePath m_path;
|
||||||
|
|
||||||
|
|
|
@ -107,14 +107,3 @@ void VisToolPointOfIntersectionCurves::setHCrossPoint(const HCrossCurvesPoint &v
|
||||||
{
|
{
|
||||||
hCrossPoint = value;
|
hCrossPoint = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolPointOfIntersectionCurves::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point, scale);
|
|
||||||
ScalePenWidth(visCurve2, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
|
@ -56,16 +56,12 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCurves)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCurves)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VisToolPointOfIntersectionCurves)
|
Q_DISABLE_COPY(VisToolPointOfIntersectionCurves)
|
||||||
quint32 object2Id;
|
quint32 object2Id;
|
||||||
VCrossCurvesPoint vCrossPoint;
|
VCrossCurvesPoint vCrossPoint;
|
||||||
HCrossCurvesPoint hCrossPoint;
|
HCrossCurvesPoint hCrossPoint;
|
||||||
|
VScaledEllipse *point;
|
||||||
QGraphicsEllipseItem *point;
|
|
||||||
VCurvePathItem *visCurve2;
|
VCurvePathItem *visCurve2;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -221,17 +221,6 @@ QPointF VisToolSpline::GetP3() const
|
||||||
return p3;
|
return p3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
ScalePoint(point1, scale);
|
|
||||||
ScalePoint(point4, scale);
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolSpline::MouseLeftPressed()
|
void VisToolSpline::MouseLeftPressed()
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,9 +64,6 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolSpline)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolSpline)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
public slots:
|
public slots:
|
||||||
void MouseLeftPressed();
|
void MouseLeftPressed();
|
||||||
void MouseLeftReleased();
|
void MouseLeftReleased();
|
||||||
|
@ -74,8 +71,8 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
Q_DISABLE_COPY(VisToolSpline)
|
Q_DISABLE_COPY(VisToolSpline)
|
||||||
quint32 object4Id;
|
quint32 object4Id;
|
||||||
QGraphicsEllipseItem *point1;
|
VScaledEllipse *point1;
|
||||||
QGraphicsEllipseItem *point4;
|
VScaledEllipse *point4;
|
||||||
qreal angle1;
|
qreal angle1;
|
||||||
qreal angle2;
|
qreal angle2;
|
||||||
qreal kAsm1;
|
qreal kAsm1;
|
||||||
|
|
|
@ -48,10 +48,10 @@
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *parent)
|
VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *parent)
|
||||||
: VisPath(data, parent),
|
: VisPath(data, parent),
|
||||||
points(QVector<QGraphicsEllipseItem *>()),
|
points(),
|
||||||
ctrlPoints(QVector<VControlPointSpline *>()),
|
ctrlPoints(),
|
||||||
newCurveSegment(nullptr),
|
newCurveSegment(nullptr),
|
||||||
path(VSplinePath()),
|
path(),
|
||||||
isLeftMousePressed(false),
|
isLeftMousePressed(false),
|
||||||
pointSelected(false),
|
pointSelected(false),
|
||||||
ctrlPoint()
|
ctrlPoint()
|
||||||
|
@ -62,8 +62,6 @@ VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *pare
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolSplinePath::~VisToolSplinePath()
|
VisToolSplinePath::~VisToolSplinePath()
|
||||||
{
|
{
|
||||||
qDeleteAll(ctrlPoints);
|
|
||||||
qDeleteAll(points);
|
|
||||||
emit ToolTip("");
|
emit ToolTip("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +75,7 @@ void VisToolSplinePath::RefreshGeometry()
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
QGraphicsEllipseItem *point = this->getPoint(static_cast<unsigned>(i));
|
VScaledEllipse *point = this->getPoint(static_cast<unsigned>(i));
|
||||||
DrawPoint(point, static_cast<QPointF>(pathPoints.at(i).P()), supportColor);
|
DrawPoint(point, static_cast<QPointF>(pathPoints.at(i).P()), supportColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,19 +137,6 @@ VSplinePath VisToolSplinePath::getPath()
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VisToolSplinePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
|
|
||||||
for (int i=0; i < points.size(); ++i)
|
|
||||||
{
|
|
||||||
ScalePoint(points[i], scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
VisPath::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolSplinePath::MouseLeftPressed()
|
void VisToolSplinePath::MouseLeftPressed()
|
||||||
{
|
{
|
||||||
|
@ -172,7 +157,7 @@ void VisToolSplinePath::MouseLeftReleased()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsEllipseItem *VisToolSplinePath::getPoint(quint32 i)
|
VScaledEllipse *VisToolSplinePath::getPoint(quint32 i)
|
||||||
{
|
{
|
||||||
if (static_cast<quint32>(points.size() - 1) >= i && points.isEmpty() == false)
|
if (static_cast<quint32>(points.size() - 1) >= i && points.isEmpty() == false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,9 +58,6 @@ public:
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::ToolSplinePath)};
|
enum { Type = UserType + static_cast<int>(Vis::ToolSplinePath)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
signals:
|
signals:
|
||||||
void PathChanged(const VSplinePath &path);
|
void PathChanged(const VSplinePath &path);
|
||||||
|
|
||||||
|
@ -70,7 +67,7 @@ public slots:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Q_DISABLE_COPY(VisToolSplinePath)
|
Q_DISABLE_COPY(VisToolSplinePath)
|
||||||
QVector<QGraphicsEllipseItem *> points;
|
QVector<VScaledEllipse *> points;
|
||||||
QVector<VControlPointSpline *> ctrlPoints;
|
QVector<VControlPointSpline *> ctrlPoints;
|
||||||
VCurvePathItem *newCurveSegment;
|
VCurvePathItem *newCurveSegment;
|
||||||
VSplinePath path;
|
VSplinePath path;
|
||||||
|
@ -80,7 +77,7 @@ protected:
|
||||||
|
|
||||||
QPointF ctrlPoint;
|
QPointF ctrlPoint;
|
||||||
|
|
||||||
QGraphicsEllipseItem * getPoint(quint32 i);
|
VScaledEllipse * getPoint(quint32 i);
|
||||||
void Creating(const QPointF &pSpl, int size);
|
void Creating(const QPointF &pSpl, int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
#include "../vwidgets/vcurvepathitem.h"
|
#include "../vwidgets/vcurvepathitem.h"
|
||||||
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
|
||||||
template <class K, class V> class QHash;
|
template <class K, class V> class QHash;
|
||||||
|
|
||||||
|
@ -136,14 +137,7 @@ void Visualization::MousePos(const QPointF &scenePos)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void Visualization::ScalePoint(QGraphicsEllipseItem *item, qreal scale)
|
VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const
|
||||||
{
|
|
||||||
ScaleCircleSize(item, scale);
|
|
||||||
ScalePenWidth(item, scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const
|
|
||||||
{
|
{
|
||||||
return InitPointItem(color, parent, z);
|
return InitPointItem(color, parent, z);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +186,7 @@ qreal Visualization::FindVal(const QString &expression, const QHash<QString, qre
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style)
|
void Visualization::DrawPoint(VScaledEllipse *point, const QPointF &pos, const QColor &color, Qt::PenStyle style)
|
||||||
{
|
{
|
||||||
SCASSERT (point != nullptr)
|
SCASSERT (point != nullptr)
|
||||||
|
|
||||||
|
@ -207,7 +201,7 @@ void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, c
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void Visualization::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style)
|
void Visualization::DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style)
|
||||||
{
|
{
|
||||||
SCASSERT (lineItem != nullptr)
|
SCASSERT (lineItem != nullptr)
|
||||||
|
|
||||||
|
@ -245,7 +239,7 @@ void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path,
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsEllipseItem *Visualization::GetPointItem(QVector<QGraphicsEllipseItem *> &points, quint32 i,
|
VScaledEllipse *Visualization::GetPointItem(QVector<VScaledEllipse *> &points, quint32 i,
|
||||||
const QColor &color, QGraphicsItem *parent)
|
const QColor &color, QGraphicsItem *parent)
|
||||||
{
|
{
|
||||||
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
||||||
|
@ -262,9 +256,9 @@ QGraphicsEllipseItem *Visualization::GetPointItem(QVector<QGraphicsEllipseItem *
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsEllipseItem *Visualization::InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z)
|
VScaledEllipse *Visualization::InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z)
|
||||||
{
|
{
|
||||||
QGraphicsEllipseItem *point = new QGraphicsEllipseItem(parent);
|
VScaledEllipse *point = new VScaledEllipse(parent);
|
||||||
point->setZValue(1);
|
point->setZValue(1);
|
||||||
point->setBrush(QBrush(Qt::NoBrush));
|
point->setBrush(QBrush(Qt::NoBrush));
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,9 @@
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(vVis)
|
Q_DECLARE_LOGGING_CATEGORY(vVis)
|
||||||
|
|
||||||
|
class VScaledEllipse;
|
||||||
|
class VScaledLine;
|
||||||
|
|
||||||
enum class Mode : char {Creation, Show};
|
enum class Mode : char {Creation, Show};
|
||||||
|
|
||||||
class Visualization : public QObject
|
class Visualization : public QObject
|
||||||
|
@ -86,15 +89,10 @@ protected:
|
||||||
virtual void InitPen()=0;
|
virtual void InitPen()=0;
|
||||||
virtual void AddOnScene()=0;
|
virtual void AddOnScene()=0;
|
||||||
|
|
||||||
template <typename Item>
|
VScaledEllipse *InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) const;
|
||||||
void ScalePenWidth(Item *item, qreal scale);
|
void DrawPoint(VScaledEllipse *point, const QPointF &pos, const QColor &color,
|
||||||
|
|
||||||
void ScalePoint(QGraphicsEllipseItem *item, qreal scale);
|
|
||||||
|
|
||||||
QGraphicsEllipseItem *InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) const;
|
|
||||||
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color,
|
|
||||||
Qt::PenStyle style = Qt::SolidLine);
|
Qt::PenStyle style = Qt::SolidLine);
|
||||||
virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
|
virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color,
|
||||||
Qt::PenStyle style = Qt::SolidLine);
|
Qt::PenStyle style = Qt::SolidLine);
|
||||||
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color,
|
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color,
|
||||||
Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap);
|
Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap);
|
||||||
|
@ -107,12 +105,12 @@ protected:
|
||||||
template <class Item>
|
template <class Item>
|
||||||
Item *InitItem(const QColor &color, QGraphicsItem *parent);
|
Item *InitItem(const QColor &color, QGraphicsItem *parent);
|
||||||
|
|
||||||
static QGraphicsEllipseItem* GetPointItem(QVector<QGraphicsEllipseItem *> &points, quint32 i, const QColor &color,
|
static VScaledEllipse *GetPointItem(QVector<VScaledEllipse *> &points, quint32 i, const QColor &color,
|
||||||
QGraphicsItem *parent);
|
QGraphicsItem *parent);
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(Visualization)
|
Q_DISABLE_COPY(Visualization)
|
||||||
|
|
||||||
static QGraphicsEllipseItem* InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0);
|
static VScaledEllipse* InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -143,18 +141,4 @@ inline Item *Visualization::InitItem(const QColor &color, QGraphicsItem *parent)
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
template <class Item>
|
|
||||||
void Visualization::ScalePenWidth(Item *item, qreal scale)
|
|
||||||
{
|
|
||||||
SCASSERT(item != nullptr)
|
|
||||||
|
|
||||||
const qreal width = ScaleWidth(widthMainLine, scale);
|
|
||||||
|
|
||||||
QPen visPen = item->pen();
|
|
||||||
visPen.setWidthF(width);
|
|
||||||
|
|
||||||
item->setPen(visPen);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // VISUALIZATION_H
|
#endif // VISUALIZATION_H
|
||||||
|
|
86
src/libs/vwidgets/scalesceneitems.cpp
Normal file
86
src/libs/vwidgets/scalesceneitems.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 21 6, 2017
|
||||||
|
**
|
||||||
|
** @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) 2017 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/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/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "scalesceneitems.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPen>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VScaledLine::VScaledLine(QGraphicsItem *parent)
|
||||||
|
: QGraphicsLineItem(parent),
|
||||||
|
basicWidth(widthMainLine)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VScaledLine::VScaledLine(const QLineF &line, QGraphicsItem *parent)
|
||||||
|
: QGraphicsLineItem(line, parent),
|
||||||
|
basicWidth(widthMainLine)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VScaledLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
QPen lPen = pen();
|
||||||
|
lPen.setWidthF(ScaleWidth(basicWidth, SceneScale(scene())));
|
||||||
|
setPen(lPen);
|
||||||
|
|
||||||
|
QGraphicsLineItem::paint(painter, option, widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal VScaledLine::GetBasicWidth() const
|
||||||
|
{
|
||||||
|
return basicWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VScaledLine::SetBasicWidth(const qreal &value)
|
||||||
|
{
|
||||||
|
basicWidth = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VScaledEllipse::VScaledEllipse(QGraphicsItem *parent)
|
||||||
|
: QGraphicsEllipseItem(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VScaledEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
const qreal scale = SceneScale(scene());
|
||||||
|
const qreal width = ScaleWidth(widthMainLine, scale);
|
||||||
|
|
||||||
|
QPen visPen = pen();
|
||||||
|
visPen.setWidthF(width);
|
||||||
|
|
||||||
|
setPen(visPen);
|
||||||
|
ScaleCircleSize(this, scale);
|
||||||
|
|
||||||
|
QGraphicsEllipseItem::paint(painter, option, widget);
|
||||||
|
}
|
73
src/libs/vwidgets/scalesceneitems.h
Normal file
73
src/libs/vwidgets/scalesceneitems.h
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 21 6, 2017
|
||||||
|
**
|
||||||
|
** @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) 2017 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/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 SCALESCENEITEMS_H
|
||||||
|
#define SCALESCENEITEMS_H
|
||||||
|
|
||||||
|
#include <QGraphicsLineItem>
|
||||||
|
|
||||||
|
#include "../vmisc/def.h"
|
||||||
|
|
||||||
|
class VScaledLine : public QGraphicsLineItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit VScaledLine(QGraphicsItem * parent = nullptr);
|
||||||
|
VScaledLine(const QLineF &line, QGraphicsItem * parent = nullptr);
|
||||||
|
virtual ~VScaledLine() = default;
|
||||||
|
|
||||||
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
enum { Type = UserType + static_cast<int>(Vis::ScaledLine)};
|
||||||
|
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
qreal GetBasicWidth() const;
|
||||||
|
void SetBasicWidth(const qreal &value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VScaledLine)
|
||||||
|
|
||||||
|
qreal basicWidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
class VScaledEllipse : public QGraphicsEllipseItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit VScaledEllipse(QGraphicsItem * parent = nullptr);
|
||||||
|
virtual ~VScaledEllipse() = default;
|
||||||
|
|
||||||
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
enum { Type = UserType + static_cast<int>(Vis::ScaledEllipse)};
|
||||||
|
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VScaledEllipse)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCALESCENEITEMS_H
|
|
@ -48,6 +48,7 @@
|
||||||
#include "vmaingraphicsscene.h"
|
#include "vmaingraphicsscene.h"
|
||||||
#include "vmaingraphicsview.h"
|
#include "vmaingraphicsview.h"
|
||||||
#include "vgraphicssimpletextitem.h"
|
#include "vgraphicssimpletextitem.h"
|
||||||
|
#include "scalesceneitems.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem *parent)
|
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem *parent)
|
||||||
|
@ -100,21 +101,13 @@ VControlPointSpline::~VControlPointSpline()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
const qreal scale = SceneScale(scene());
|
QPen lPen = controlLine->pen();
|
||||||
|
lPen.setColor(CorrectColor(controlLine, Qt::black));
|
||||||
ScaleLinePenWidth(controlLine, scale);
|
controlLine->setPen(lPen);
|
||||||
|
|
||||||
VScenePoint::paint(painter, option, widget);
|
VScenePoint::paint(painter, option, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QRectF VControlPointSpline::boundingRect() const
|
|
||||||
{
|
|
||||||
QRectF recTool = VScenePoint::boundingRect();
|
|
||||||
recTool = recTool.united(childrenBoundingRect());
|
|
||||||
return recTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief hoverEnterEvent handle hover enter events.
|
* @brief hoverEnterEvent handle hover enter events.
|
||||||
|
@ -267,12 +260,8 @@ void VControlPointSpline::Init()
|
||||||
this->setBrush(QBrush(Qt::NoBrush));
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
this->setZValue(100);
|
this->setZValue(100);
|
||||||
|
|
||||||
controlLine = new QGraphicsLineItem(this);
|
controlLine = new VScaledLine(this);
|
||||||
|
controlLine->SetBasicWidth(widthHairLine);
|
||||||
QPen cPen = controlLine->pen();
|
|
||||||
cPen.setBrush(QBrush(Qt::red));
|
|
||||||
|
|
||||||
controlLine->setPen(cPen);
|
|
||||||
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ public:
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief ControlPointChangePosition emit when control point change position.
|
* @brief ControlPointChangePosition emit when control point change position.
|
||||||
|
@ -81,7 +80,7 @@ public slots:
|
||||||
void setEnabledPoint(bool enable);
|
void setEnabledPoint(bool enable);
|
||||||
protected:
|
protected:
|
||||||
/** @brief controlLine pointer to line control point. */
|
/** @brief controlLine pointer to line control point. */
|
||||||
QGraphicsLineItem *controlLine;
|
VScaledLine *controlLine;
|
||||||
|
|
||||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vcurvepathitem.h"
|
#include "vcurvepathitem.h"
|
||||||
|
#include "../vwidgets/global.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
@ -37,9 +38,49 @@ VCurvePathItem::VCurvePathItem(QGraphicsItem *parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QPainterPath VCurvePathItem::shape() const
|
||||||
|
{
|
||||||
|
QPainterPath itemPath = path();
|
||||||
|
|
||||||
|
if (m_direction != QPainterPath())
|
||||||
|
{
|
||||||
|
itemPath.addPath(m_direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemPath.setFillRule(Qt::WindingFill);
|
||||||
|
|
||||||
|
// We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
|
||||||
|
// if we pass a value of 0.0 to QPainterPathStroker::setWidth()
|
||||||
|
const qreal penWidthZero = qreal(0.00000001);
|
||||||
|
|
||||||
|
if (itemPath == QPainterPath() || pen() == Qt::NoPen)
|
||||||
|
{
|
||||||
|
return itemPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPathStroker ps;
|
||||||
|
ps.setCapStyle(pen().capStyle());
|
||||||
|
if (pen().widthF() <= 0.0)
|
||||||
|
{
|
||||||
|
ps.setWidth(penWidthZero);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ps.setWidth(pen().widthF());
|
||||||
|
}
|
||||||
|
ps.setJoinStyle(pen().joinStyle());
|
||||||
|
ps.setMiterLimit(pen().miterLimit());
|
||||||
|
QPainterPath p = ps.createStroke(itemPath);
|
||||||
|
p.addPath(itemPath);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
|
ScalePenWidth();
|
||||||
|
|
||||||
if (m_direction != QPainterPath())
|
if (m_direction != QPainterPath())
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
@ -62,3 +103,14 @@ void VCurvePathItem::SetDirectionPath(const QPainterPath &path)
|
||||||
{
|
{
|
||||||
m_direction = path;
|
m_direction = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCurvePathItem::ScalePenWidth()
|
||||||
|
{
|
||||||
|
const qreal width = ScaleWidth(widthMainLine, SceneScale(scene()));
|
||||||
|
|
||||||
|
QPen toolPen = pen();
|
||||||
|
toolPen.setWidthF(width);
|
||||||
|
|
||||||
|
setPen(toolPen);
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ class VCurvePathItem : public QGraphicsPathItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit VCurvePathItem(QGraphicsItem *parent = nullptr);
|
explicit VCurvePathItem(QGraphicsItem *parent = nullptr);
|
||||||
|
virtual ~VCurvePathItem() = default;
|
||||||
|
|
||||||
|
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||||
|
@ -46,6 +49,8 @@ public:
|
||||||
enum { Type = UserType + static_cast<int>(Vis::CurvePathItem)};
|
enum { Type = UserType + static_cast<int>(Vis::CurvePathItem)};
|
||||||
|
|
||||||
void SetDirectionPath(const QPainterPath &path);
|
void SetDirectionPath(const QPainterPath &path);
|
||||||
|
protected:
|
||||||
|
virtual void ScalePenWidth();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VCurvePathItem)
|
Q_DISABLE_COPY(VCurvePathItem)
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "vgraphicssimpletextitem.h"
|
#include "vgraphicssimpletextitem.h"
|
||||||
|
#include "scalesceneitems.h"
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
@ -46,7 +47,8 @@ VScenePoint::VScenePoint(QGraphicsItem *parent)
|
||||||
m_baseColor(Qt::black)
|
m_baseColor(Qt::black)
|
||||||
{
|
{
|
||||||
m_namePoint = new VGraphicsSimpleTextItem(this);
|
m_namePoint = new VGraphicsSimpleTextItem(this);
|
||||||
m_lineName = new QGraphicsLineItem(this);
|
m_lineName = new VScaledLine(this);
|
||||||
|
m_lineName->SetBasicWidth(widthHairLine);
|
||||||
this->setBrush(QBrush(Qt::NoBrush));
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
@ -72,7 +74,9 @@ void VScenePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||||
m_namePoint->setVisible(true);
|
m_namePoint->setVisible(true);
|
||||||
m_lineName->setVisible(true);
|
m_lineName->setVisible(true);
|
||||||
|
|
||||||
ScaleLinePenWidth(m_lineName, scale);
|
QPen lPen = m_lineName->pen();
|
||||||
|
lPen.setColor(CorrectColor(m_lineName, Qt::black));
|
||||||
|
m_lineName->setPen(lPen);
|
||||||
|
|
||||||
RefreshLine();
|
RefreshLine();
|
||||||
}
|
}
|
||||||
|
@ -96,14 +100,6 @@ void VScenePoint::RefreshPointGeometry(const VPointF &point)
|
||||||
RefreshLine();
|
RefreshLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QRectF VScenePoint::boundingRect() const
|
|
||||||
{
|
|
||||||
QRectF recTool = QGraphicsEllipseItem::boundingRect();
|
|
||||||
recTool = recTool.united(childrenBoundingRect());
|
|
||||||
return recTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VScenePoint::SetOnlyPoint(bool value)
|
void VScenePoint::SetOnlyPoint(bool value)
|
||||||
{
|
{
|
||||||
|
@ -169,13 +165,3 @@ void VScenePoint::ScaleMainPenWidth(qreal scale)
|
||||||
|
|
||||||
setPen(QPen(CorrectColor(this, m_baseColor), width));
|
setPen(QPen(CorrectColor(this, m_baseColor), width));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VScenePoint::ScaleLinePenWidth(QGraphicsLineItem *line, qreal scale)
|
|
||||||
{
|
|
||||||
SCASSERT(line != nullptr)
|
|
||||||
const qreal width = ScaleWidth(widthHairLine, scale);
|
|
||||||
|
|
||||||
line->setPen(QPen(CorrectColor(line, Qt::black), width));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -34,25 +34,24 @@
|
||||||
|
|
||||||
class VGraphicsSimpleTextItem;
|
class VGraphicsSimpleTextItem;
|
||||||
class VPointF;
|
class VPointF;
|
||||||
|
class VScaledLine;
|
||||||
|
|
||||||
class VScenePoint: public QGraphicsEllipseItem
|
class VScenePoint: public QGraphicsEllipseItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit VScenePoint(QGraphicsItem *parent = nullptr);
|
explicit VScenePoint(QGraphicsItem *parent = nullptr);
|
||||||
~VScenePoint() = default;
|
virtual ~VScenePoint() = default;
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
virtual void RefreshPointGeometry(const VPointF &point);
|
virtual void RefreshPointGeometry(const VPointF &point);
|
||||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @brief namePoint point label. */
|
/** @brief namePoint point label. */
|
||||||
VGraphicsSimpleTextItem *m_namePoint;
|
VGraphicsSimpleTextItem *m_namePoint;
|
||||||
|
|
||||||
/** @brief lineName line what we see if label moved too away from point. */
|
/** @brief lineName line what we see if label moved too away from point. */
|
||||||
QGraphicsLineItem *m_lineName;
|
VScaledLine *m_lineName;
|
||||||
|
|
||||||
bool m_onlyPoint;
|
bool m_onlyPoint;
|
||||||
bool m_isHovered;
|
bool m_isHovered;
|
||||||
|
@ -64,7 +63,6 @@ protected:
|
||||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void RefreshLine();
|
void RefreshLine();
|
||||||
void ScaleLinePenWidth(QGraphicsLineItem *line, qreal scale);
|
|
||||||
|
|
||||||
void SetOnlyPoint(bool value);
|
void SetOnlyPoint(bool value);
|
||||||
bool IsOnlyPoint() const;
|
bool IsOnlyPoint() const;
|
||||||
|
|
|
@ -57,30 +57,6 @@ VSimpleCurve::VSimpleCurve(quint32 id, const QSharedPointer<VAbstractCurve> &cur
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VSimpleCurve::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
qreal width = 1;
|
|
||||||
if (m_isHovered)
|
|
||||||
{
|
|
||||||
width = widthMainLine;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
width = widthHairLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
const qreal scale = SceneScale(scene());
|
|
||||||
if (scale > 1)
|
|
||||||
{
|
|
||||||
width = qMax(1., width/scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
setPen(QPen(CorrectColor(this, m_curve->GetColor()), width, LineStyleToPenStyle(m_curve->GetPenStyle())));
|
|
||||||
|
|
||||||
VCurvePathItem::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
|
void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
|
||||||
{
|
{
|
||||||
|
@ -191,3 +167,20 @@ void VSimpleCurve::keyReleaseEvent(QKeyEvent *event)
|
||||||
}
|
}
|
||||||
QGraphicsPathItem::keyReleaseEvent ( event );
|
QGraphicsPathItem::keyReleaseEvent ( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::ScalePenWidth()
|
||||||
|
{
|
||||||
|
qreal width = 1;
|
||||||
|
if (m_isHovered)
|
||||||
|
{
|
||||||
|
width = widthMainLine;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
width = widthHairLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = ScaleWidth(width, SceneScale(scene()));
|
||||||
|
setPen(QPen(CorrectColor(this, m_curve->GetColor()), width, LineStyleToPenStyle(m_curve->GetPenStyle())));
|
||||||
|
}
|
||||||
|
|
|
@ -56,9 +56,6 @@ public:
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::SimpleCurve)};
|
enum { Type = UserType + static_cast<int>(Vis::SimpleCurve)};
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
void RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve);
|
void RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve);
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
|
@ -80,6 +77,7 @@ protected:
|
||||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE;
|
virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
virtual void ScalePenWidth() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VSimpleCurve)
|
Q_DISABLE_COPY(VSimpleCurve)
|
||||||
|
|
|
@ -20,7 +20,8 @@ SOURCES += \
|
||||||
$$PWD/fancytabbar/stylehelper.cpp \
|
$$PWD/fancytabbar/stylehelper.cpp \
|
||||||
$$PWD/vcurvepathitem.cpp \
|
$$PWD/vcurvepathitem.cpp \
|
||||||
$$PWD/global.cpp \
|
$$PWD/global.cpp \
|
||||||
$$PWD/vscenepoint.cpp
|
$$PWD/vscenepoint.cpp \
|
||||||
|
$$PWD/scalesceneitems.cpp
|
||||||
|
|
||||||
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
||||||
|
|
||||||
|
@ -44,4 +45,5 @@ HEADERS += \
|
||||||
$$PWD/fancytabbar/stylehelper.h \
|
$$PWD/fancytabbar/stylehelper.h \
|
||||||
$$PWD/vcurvepathitem.h \
|
$$PWD/vcurvepathitem.h \
|
||||||
$$PWD/global.h \
|
$$PWD/global.h \
|
||||||
$$PWD/vscenepoint.h
|
$$PWD/vscenepoint.h \
|
||||||
|
$$PWD/scalesceneitems.h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user