Fix a crash.

Valentina crahed if create a curve.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-06-23 12:25:02 +03:00
parent 4243804f55
commit 8d0b2c0af9
94 changed files with 586 additions and 1010 deletions

View File

@ -165,6 +165,8 @@ enum class Vis : ToolVisHolderType
{
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
GraphicsSimpleTextItem,
ScaledLine,
ScaledEllipse,
SimplePoint,
SimpleCurve,
Line,

View File

@ -48,6 +48,7 @@
#include "../../../../vabstracttool.h"
#include "../../../vdrawtool.h"
#include "../vtoolsinglepoint.h"
#include "../vwidgets/scalesceneitems.h"
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
QPointF point1 = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
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);
}
@ -87,21 +89,15 @@ VToolLinePoint::~VToolLinePoint()
//---------------------------------------------------------------------------------------------------------------------
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);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VToolLinePoint::boundingRect() const
{
QRectF recTool = VToolSinglePoint::boundingRect();
recTool = recTool.united(childrenBoundingRect());
return recTool;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
@ -133,6 +129,20 @@ void VToolLinePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
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)
{

View File

@ -58,7 +58,6 @@ public:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
VFormula GetFormulaLength() const;
void SetFormulaLength(const VFormula &value);
@ -88,7 +87,7 @@ protected:
quint32 basePointId;
/** @brief mainLine line item. */
QGraphicsLineItem *mainLine;
VScaledLine *mainLine;
/** @brief lineColor color of a line. */
QString lineColor;
@ -96,6 +95,8 @@ protected:
virtual void RefreshGeometry();
virtual void RemoveReferens() 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:
Q_DISABLE_COPY(VToolLinePoint)
};

View File

@ -55,6 +55,7 @@
#include "../vmisc/vabstractapplication.h"
#include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vgraphicssimpletextitem.h"
#include "../vwidgets/scalesceneitems.h"
#include "../../../vabstracttool.h"
#include "../../vdrawtool.h"
#include "../vabstractpoint.h"

View File

@ -201,7 +201,7 @@ void VNodePoint::RefreshDataInFile()
void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *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.
if (not (flags() & ItemIsSelectable) && scene())
@ -223,7 +223,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
emit ChoosedTool(id, SceneObject::Point);
}
QGraphicsEllipseItem::mouseReleaseEvent(event);
VScenePoint::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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);
}
@ -118,7 +118,7 @@ void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPoint
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
++iPoint;
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
++iPoint;

View File

@ -50,10 +50,10 @@ protected:
QVector<quint32> objects;
QColor supportColor2;
QVector<QGraphicsEllipseItem *> points;
QVector<VScaledEllipse *> points;
QVector<VCurvePathItem *> curves;
QGraphicsEllipseItem * GetPoint(quint32 i, const QColor &color);
VScaledEllipse *GetPoint(quint32 i, const QColor &color);
VCurvePathItem *GetCurve(quint32 i, const QColor &color);
template <class Item>

View File

@ -80,13 +80,3 @@ void VisToolFlippingByAxis::SetAxisType(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);
}

View File

@ -48,15 +48,12 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByAxis)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolFlippingByAxis)
AxisType m_axisType;
QGraphicsEllipseItem *point1;
VScaledEllipse *point1;
};
#endif // VISTOOLFLIPPINGBYAXIS_H

View File

@ -72,17 +72,6 @@ void VisToolFlippingByLine::RefreshGeometry()
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)
{

View File

@ -41,8 +41,6 @@ public:
virtual ~VisToolFlippingByLine() = default;
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 SetSecondLinePointId(quint32 value);
@ -52,8 +50,8 @@ public:
private:
Q_DISABLE_COPY(VisToolFlippingByLine)
quint32 object2Id;
QGraphicsEllipseItem *point1;
QGraphicsEllipseItem *point2;
VScaledEllipse *point1;
VScaledEllipse *point2;
};
#endif // VISTOOLFLIPPINGBYLINE_H

View File

@ -128,17 +128,6 @@ void VisToolMove::RefreshGeometry()
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
{
@ -244,7 +233,7 @@ QVector<QGraphicsItem *> VisToolMove::CreateOriginObjects(int &iPoint, int &iCur
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
++iPoint;
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
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);
++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);
break;
}

View File

@ -51,8 +51,6 @@ public:
virtual ~VisToolMove();
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
QString Angle() const;
void SetAngle(const QString &expression);
@ -67,8 +65,8 @@ private:
Q_DISABLE_COPY(VisToolMove)
qreal angle;
qreal length;
QGraphicsEllipseItem *pointOrigin;
QGraphicsEllipseItem *pointFinish;
VScaledEllipse *pointOrigin;
VScaledEllipse *pointFinish;
template <class Item>
QGraphicsPathItem *AddOriginCurve(quint32 id, int &i);

View File

@ -65,7 +65,7 @@ VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
{
point = InitPoint(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);
++iPoint;
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
++iPoint;
@ -190,18 +190,6 @@ void VisToolRotation::RefreshGeometry()
}
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)
{

View File

@ -51,8 +51,6 @@ public:
virtual ~VisToolRotation();
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
void SetOriginPointId(quint32 value);
@ -64,9 +62,9 @@ public:
private:
Q_DISABLE_COPY(VisToolRotation)
qreal angle;
QGraphicsEllipseItem *point;
VScaledEllipse *point;
VCurvePathItem *angleArc;
QGraphicsLineItem *xAxis;
VScaledLine *xAxis;
template <class Item>
int AddCurve(qreal angle, const QPointF &origin, quint32 id, int i);

View File

@ -41,7 +41,7 @@
//---------------------------------------------------------------------------------------------------------------------
VisLine::VisLine(const VContainer *data, QGraphicsItem *parent)
:Visualization(data), QGraphicsLineItem(parent)
:Visualization(data), VScaledLine(parent)
{
this->setZValue(1);// Show on top real tool
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
{
@ -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)
{
SCASSERT (lineItem != nullptr)

View File

@ -43,8 +43,9 @@
#include "../vtools/visualization/visualization.h"
#include "../vmisc/def.h"
#include "../vwidgets/scalesceneitems.h"
class VisLine: public Visualization, public QGraphicsLineItem
class VisLine: public Visualization, public VScaledLine
{
Q_OBJECT
public:
@ -54,10 +55,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::Line)};
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:
QPointF Ray(const QPointF &firstPoint, const qreal &angle) const;
QPointF Ray(const QPointF &firstPoint) const;
@ -66,7 +63,7 @@ protected:
virtual void InitPen() 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);
private:
Q_DISABLE_COPY(VisLine)

View File

@ -53,7 +53,7 @@ VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this); //-V656
line = InitItem<QGraphicsLineItem>(supportColor, this);
line = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this);
}
@ -69,19 +69,6 @@ void VisToolAlongLine::setLength(const QString &expression)
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()
{

View File

@ -51,16 +51,13 @@ public:
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolAlongLine)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolAlongLine)
quint32 object2Id;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *lineP1;
QGraphicsEllipseItem *lineP2;
QGraphicsLineItem *line;
VScaledEllipse *point;
VScaledEllipse *lineP1;
VScaledEllipse *lineP2;
VScaledLine *line;
qreal length;
};

View File

@ -49,10 +49,10 @@ VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
{
line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this); //-V656
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
line1 = InitItem<VScaledLine>(supportColor, this);
line2P2 = InitPoint(supportColor, this);
line2 = InitItem<QGraphicsLineItem>(supportColor, this);
line2 = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this);
}
@ -75,21 +75,6 @@ void VisToolBisector::setLength(const QString &expression)
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()
{

View File

@ -52,19 +52,16 @@ public:
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolBisector)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolBisector)
quint32 object2Id;
quint32 object3Id;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *line1P1;
QGraphicsEllipseItem *line1P2;
QGraphicsLineItem *line1;
QGraphicsEllipseItem *line2P2;
QGraphicsLineItem *line2;
VScaledEllipse *point;
VScaledEllipse *line1P1;
VScaledEllipse *line1P2;
VScaledLine *line1;
VScaledEllipse *line2P2;
VScaledLine *line2;
qreal length;
};

View File

@ -55,8 +55,8 @@ VisToolCurveIntersectAxis::VisToolCurveIntersectAxis(const VContainer *data, QGr
visCurve = InitItem<VCurvePathItem>(Qt::darkGreen, this);
basePoint = InitPoint(supportColor, this);
baseLine = InitItem<QGraphicsLineItem>(supportColor, this);
axisLine = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
baseLine = InitItem<VScaledLine>(supportColor, this);
axisLine = InitItem<VScaledLine>(supportColor, this); //-V656
point = InitPoint(mainColor, this);
}
@ -113,17 +113,3 @@ void VisToolCurveIntersectAxis::setAxisPointId(const quint32 &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);
}

View File

@ -54,17 +54,14 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolCurveIntersectAxis)
quint32 axisPointId;
qreal angle;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *basePoint;
QGraphicsLineItem *baseLine;
QGraphicsLineItem *axisLine;
VScaledEllipse *point;
VScaledEllipse *basePoint;
VScaledLine *baseLine;
VScaledLine *axisLine;
VCurvePathItem *visCurve;
};

View File

@ -110,13 +110,3 @@ void VisToolEndLine::setLength(const QString &expression)
{
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);
}

View File

@ -56,14 +56,11 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolEndLine)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolEndLine)
qreal length;
qreal angle;
QGraphicsEllipseItem *point;
VScaledEllipse *point;
};
#endif // VISTOOLENDLINE_H

View File

@ -50,8 +50,8 @@ VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent)
base_point = InitPoint(supportColor, this);
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this);
line = InitItem<QGraphicsLineItem>(supportColor, this);
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
line = InitItem<VScaledLine>(supportColor, this);
line_intersection = InitItem<VScaledLine>(supportColor, this); //-V656
point = InitPoint(mainColor, this);
}
@ -112,21 +112,6 @@ void VisToolHeight::setLineP2Id(const quint32 &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)
{

View File

@ -53,20 +53,17 @@ public:
void setLineP2Id(const quint32 &value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolHeight)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolHeight)
//base point in parent class
quint32 lineP1Id;//first point of line
quint32 lineP2Id;//second point of line
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *base_point;
QGraphicsEllipseItem *lineP1;
QGraphicsEllipseItem *lineP2;
QGraphicsLineItem *line;
QGraphicsLineItem *line_intersection;
VScaledEllipse *point;
VScaledEllipse *base_point;
VScaledEllipse *lineP1;
VScaledEllipse *lineP2;
VScaledLine *line;
VScaledLine *line_intersection;
void ShowIntersection(const QLineF &height_line, const QLineF &base_line);
};

View File

@ -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)

View File

@ -54,7 +54,7 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLine)};
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;
private:
Q_DISABLE_COPY(VisToolLine)

View File

@ -48,7 +48,7 @@ VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem
{
line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this);
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
line1 = InitItem<VScaledLine>(supportColor, this);
line2P1 = InitPoint(supportColor, this);
line2P2 = InitPoint(supportColor, this);
@ -135,18 +135,3 @@ void VisToolLineIntersect::setLine2P2Id(const quint32 &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);
}

View File

@ -53,20 +53,17 @@ public:
void setLine2P2Id(const quint32 &value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersect)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolLineIntersect)
quint32 line1P2Id;
quint32 line2P1Id;
quint32 line2P2Id;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *line1P1;
QGraphicsEllipseItem *line1P2;
QGraphicsLineItem *line1;
QGraphicsEllipseItem *line2P1;
QGraphicsEllipseItem *line2P2;
VScaledEllipse *point;
VScaledEllipse *line1P1;
VScaledEllipse *line1P2;
VScaledLine *line1;
VScaledEllipse *line2P1;
VScaledEllipse *line2P2;
};
#endif // VISTOOLLINEINTERSECT_H

View File

@ -53,9 +53,9 @@ VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGrap
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this);
basePoint = InitPoint(supportColor, this);
baseLine = InitItem<QGraphicsLineItem>(supportColor, this);
axisLine = InitItem<QGraphicsLineItem>(supportColor, this);
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this);
baseLine = InitItem<VScaledLine>(supportColor, this);
axisLine = InitItem<VScaledLine>(supportColor, this);
line_intersection = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this);
}
@ -133,22 +133,6 @@ void VisToolLineIntersectAxis::setAxisPointId(const quint32 &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)
{

View File

@ -56,21 +56,18 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolLineIntersectAxis)
quint32 point2Id;
quint32 axisPointId;
qreal angle;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *lineP1;
QGraphicsEllipseItem *lineP2;
QGraphicsEllipseItem *basePoint;
QGraphicsLineItem *baseLine;
QGraphicsLineItem *axisLine;
QGraphicsLineItem *line_intersection;
VScaledEllipse *point;
VScaledEllipse *lineP1;
VScaledEllipse *lineP2;
VScaledEllipse *basePoint;
VScaledLine *baseLine;
VScaledLine *axisLine;
VScaledLine *line_intersection;
void ShowIntersection(const QLineF &axis_line, const QLineF &base_line);
};

View File

@ -52,7 +52,7 @@ VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this); //-V656
line = InitItem<QGraphicsLineItem>(supportColor, this);
line = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this);
}
@ -124,16 +124,3 @@ void VisToolNormal::SetAngle(const qreal &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);
}

View File

@ -55,15 +55,13 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolNormal)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolNormal)
quint32 object2Id;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *lineP1;
QGraphicsEllipseItem *lineP2;
QGraphicsLineItem *line;
VScaledEllipse *point;
VScaledEllipse *lineP1;
VScaledEllipse *lineP2;
VScaledLine *line;
qreal length;
qreal angle;

View File

@ -54,7 +54,7 @@ VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *d
arcPath = InitItem<VCurvePathItem>(Qt::darkGreen, this);
point = InitPoint(mainColor, 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;
}
//---------------------------------------------------------------------------------------------------------------------
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)
{

View File

@ -55,17 +55,14 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromArcAndTangent)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointFromArcAndTangent)
quint32 arcId;
CrossCirclesPoint crossPoint;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *tangent;
VScaledEllipse *point;
VScaledEllipse *tangent;
VCurvePathItem *arcPath;
QGraphicsLineItem *tangentLine2;
VScaledLine *tangentLine2;
void FindRays(const QPointF &p, const VArc *arc);
};

View File

@ -47,11 +47,11 @@ VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContai
: VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint),
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);
tangent = InitPoint(supportColor, this);
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;
}
//---------------------------------------------------------------------------------------------------------------------
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 &center, qreal radius)
{

View File

@ -56,19 +56,16 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromCircleAndTangent)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointFromCircleAndTangent)
quint32 object2Id;
qreal cRadius;
CrossCirclesPoint crossPoint;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *tangent;
QGraphicsEllipseItem *cCenter;
QGraphicsEllipseItem *cPath;
QGraphicsLineItem *tangent2;
VScaledEllipse *point;
VScaledEllipse *tangent;
VScaledEllipse *cCenter;
VScaledEllipse *cPath;
VScaledLine *tangent2;
void FindRays(const QPointF &p, const QPointF &center, qreal radius);
};

View File

@ -50,7 +50,7 @@ VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsIt
arc_point = InitPoint(supportColor, this);
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this);
circle = InitItem<QGraphicsEllipseItem>(supportColor, this);
circle = InitItem<VScaledEllipse>(supportColor, this);
point = InitPoint(mainColor, this);
}
@ -114,17 +114,3 @@ void VisToolPointOfContact::setRadius(const QString &expression)
{
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);
}

View File

@ -52,18 +52,15 @@ public:
void setRadius(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfContact)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfContact)
quint32 lineP2Id;
quint32 radiusId;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *lineP1;
QGraphicsEllipseItem *lineP2;
QGraphicsEllipseItem *arc_point;
QGraphicsEllipseItem *circle;
VScaledEllipse *point;
VScaledEllipse *lineP1;
VScaledEllipse *lineP2;
VScaledEllipse *arc_point;
VScaledEllipse *circle;
qreal radius;
};

View File

@ -48,7 +48,7 @@ VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, Q
{
axisP1 = InitPoint(supportColor, this);
axisP2 = InitPoint(supportColor, this); //-V656
axis2 = InitItem<QGraphicsLineItem>(supportColor, this);
axis2 = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this);
}
@ -93,19 +93,6 @@ void VisToolPointOfIntersection::setPoint2Id(const quint32 &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)
{

View File

@ -53,16 +53,13 @@ public:
void setPoint2Id(const quint32 &value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfIntersection)
quint32 point2Id;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *axisP1;//axis1 is class themself
QGraphicsEllipseItem *axisP2;
QGraphicsLineItem *axis2;//axis1 is class themself
VScaledEllipse *point;
VScaledEllipse *axisP1;//axis1 is class themself
VScaledEllipse *axisP2;
VScaledLine *axis2;//axis1 is class themself
void ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color);
};

View File

@ -114,15 +114,3 @@ void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossCirclesPoint &valu
{
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);
}

View File

@ -56,15 +56,12 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionArcs)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfIntersectionArcs)
quint32 arc1Id;
quint32 arc2Id;
CrossCirclesPoint crossPoint;
QGraphicsEllipseItem *point;
VScaledEllipse *point;
VCurvePathItem *arc1Path;
VCurvePathItem *arc2Path;
};

View File

@ -52,8 +52,8 @@ VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VCont
{
this->setPen(QPen(Qt::NoPen)); // don't use parent this time
c1Path = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this);
c2Path = InitItem<QGraphicsEllipseItem>(Qt::darkRed, this);
c1Path = InitItem<VScaledEllipse>(Qt::darkGreen, this);
c2Path = InitItem<VScaledEllipse>(Qt::darkRed, this);
point = InitPoint(mainColor, this);
c1Center = InitPoint(supportColor, this);
c2Center = InitPoint(supportColor, this); //-V656
@ -125,18 +125,3 @@ void VisToolPointOfIntersectionCircles::setCrossPoint(const CrossCirclesPoint &v
{
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);
}

View File

@ -57,20 +57,17 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCircles)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfIntersectionCircles)
quint32 object2Id;
qreal c1Radius;
qreal c2Radius;
CrossCirclesPoint crossPoint;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *c1Center;
QGraphicsEllipseItem *c2Center;
QGraphicsEllipseItem *c1Path;
QGraphicsEllipseItem *c2Path;
VScaledEllipse *point;
VScaledEllipse *c1Center;
VScaledEllipse *c2Center;
VScaledEllipse *c1Path;
VScaledEllipse *c2Path;
};
#endif // VISTOOLPOINTOFINTERSECTIONCIRCLES_H

View File

@ -50,11 +50,11 @@ VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem
{
line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this); //-V656
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
line1 = InitItem<VScaledLine>(supportColor, this);
line2P2 = InitPoint(supportColor, this);
line2 = InitItem<QGraphicsLineItem>(supportColor, this);
line3 = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
line2 = InitItem<VScaledLine>(supportColor, this);
line3 = InitItem<VScaledLine>(supportColor, this); //-V656
point = InitPoint(mainColor, this);
}
@ -131,19 +131,3 @@ void VisToolShoulderPoint::setLength(const QString &expression)
{
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);
}

View File

@ -52,20 +52,17 @@ public:
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolShoulderPoint)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolShoulderPoint)
quint32 lineP1Id;
quint32 lineP2Id;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *line1P1;
QGraphicsEllipseItem *line1P2;
QGraphicsLineItem *line1;
QGraphicsEllipseItem *line2P2;
QGraphicsLineItem *line2;
QGraphicsLineItem *line3;
VScaledEllipse *point;
VScaledEllipse *line1P1;
VScaledEllipse *line1P2;
VScaledLine *line1;
VScaledEllipse *line2P2;
VScaledLine *line2;
VScaledLine *line3;
qreal length;
};

View File

@ -53,11 +53,11 @@ VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent)
{
axisP1 = InitPoint(supportColor, this);
axisP2 = InitPoint(supportColor, this);
axis = InitItem<QGraphicsPathItem>(supportColor, this);
axis = InitItem<VCurvePathItem>(supportColor, this);
hypotenuseP1 = InitPoint(supportColor, this);
hypotenuseP2 = InitPoint(supportColor, this);
foot1 = InitItem<QGraphicsLineItem>(supportColor, this);
foot2 = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
foot1 = InitItem<VScaledLine>(supportColor, this);
foot2 = InitItem<VScaledLine>(supportColor, this); //-V656
point = InitPoint(mainColor, this);
}
@ -144,24 +144,7 @@ void VisToolTriangle::setHypotenuseP2Id(const quint32 &value)
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolTriangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
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,
void VisToolTriangle::DrawAimedAxis(VCurvePathItem *item, const QLineF &line, const QColor &color,
Qt::PenStyle style)
{
SCASSERT (item != nullptr)

View File

@ -57,24 +57,21 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolTriangle)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolTriangle)
quint32 object2Id;//axis second point
quint32 hypotenuseP1Id;
quint32 hypotenuseP2Id;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *axisP1;
QGraphicsEllipseItem *axisP2;
QGraphicsPathItem *axis;
QGraphicsEllipseItem *hypotenuseP1;
QGraphicsEllipseItem *hypotenuseP2;
QGraphicsLineItem *foot1;
QGraphicsLineItem *foot2;
VScaledEllipse *point;
VScaledEllipse *axisP1;
VScaledEllipse *axisP2;
VCurvePathItem *axis;
VScaledEllipse *hypotenuseP1;
VScaledEllipse *hypotenuseP2;
VScaledLine *foot1;
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);
void DrawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size);
};

View File

@ -67,10 +67,10 @@ VisToolTrueDarts::VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent
dartP2 = InitPoint(supportColor, this);
dartP3 = InitPoint(supportColor, this);
lineblP1P1 = InitItem<QGraphicsLineItem>(supportColor, this);
lineblP2P2 = InitItem<QGraphicsLineItem>(supportColor, this);
p1d2 = InitItem<QGraphicsLineItem>(supportColor, this);
d2p2 = InitItem<QGraphicsLineItem>(supportColor, this);
lineblP1P1 = InitItem<VScaledLine>(supportColor, this);
lineblP2P2 = InitItem<VScaledLine>(supportColor, this);
p1d2 = InitItem<VScaledLine>(supportColor, this);
d2p2 = InitItem<VScaledLine>(supportColor, this);
point1 = InitPoint(mainColor, this);
point2 = InitPoint(mainColor, this); //-V656
@ -163,24 +163,3 @@ void VisToolTrueDarts::setD3PointId(const quint32 &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);
}

View File

@ -55,9 +55,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolTrueDarts)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolTrueDarts)
quint32 baseLineP2Id;
@ -65,18 +62,18 @@ private:
quint32 dartP2Id;
quint32 dartP3Id;
QGraphicsEllipseItem *point1;
QGraphicsEllipseItem *point2;
QGraphicsEllipseItem *baseLineP1;
QGraphicsEllipseItem *baseLineP2;
QGraphicsEllipseItem *dartP1;
QGraphicsEllipseItem *dartP2;
QGraphicsEllipseItem *dartP3;
VScaledEllipse *point1;
VScaledEllipse *point2;
VScaledEllipse *baseLineP1;
VScaledEllipse *baseLineP2;
VScaledEllipse *dartP1;
VScaledEllipse *dartP2;
VScaledEllipse *dartP3;
QGraphicsLineItem *lineblP1P1;
QGraphicsLineItem *lineblP2P2;
QGraphicsLineItem *p1d2;
QGraphicsLineItem *d2p2;
VScaledLine *lineblP1P1;
VScaledLine *lineblP2P2;
VScaledLine *p1d2;
VScaledLine *d2p2;
};
#endif // VISTOOLTRUEDARTS_H

View File

@ -45,22 +45,6 @@ VisPath::VisPath(const VContainer *data, QGraphicsItem *parent)
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()
{

View File

@ -51,10 +51,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
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:
virtual void InitPen() Q_DECL_OVERRIDE;
virtual void AddOnScene() Q_DECL_OVERRIDE;

View File

@ -41,6 +41,7 @@
#include "../vpatterndb/vcontainer.h"
#include "../visualization.h"
#include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent)
@ -82,13 +83,3 @@ void VisToolArc::setF2(const QString &expression)
{
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);
}

View File

@ -52,12 +52,9 @@ public:
void setF2(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolArc)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolArc)
QGraphicsEllipseItem *arcCenter;
VScaledEllipse *arcCenter;
qreal radius;
qreal f1;
qreal f2;

View File

@ -82,13 +82,3 @@ void VisToolArcWithLength::setLength(const QString &expression)
{
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);
}

View File

@ -52,12 +52,9 @@ public:
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolArcWithLength)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolArcWithLength)
QGraphicsEllipseItem *arcCenter;
VScaledEllipse *arcCenter;
qreal radius;
qreal f1;
qreal length;

View File

@ -43,6 +43,7 @@
#include "../vpatterndb/vcontainer.h"
#include "../visualization.h"
#include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent)
@ -57,8 +58,8 @@ VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *pa
helpLine1(nullptr),
helpLine2(nullptr)
{
helpLine1 = InitItem<QGraphicsLineItem>(mainColor, this);
helpLine2 = InitItem<QGraphicsLineItem>(mainColor, this);
helpLine1 = InitItem<VScaledLine>(mainColor, this);
helpLine2 = InitItem<VScaledLine>(mainColor, this);
point1 = InitPoint(supportColor, this);
point2 = InitPoint(supportColor, this); //-V656
@ -135,18 +136,3 @@ void VisToolCubicBezier::setObject4Id(const quint32 &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);
}

View File

@ -54,20 +54,17 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolCubicBezier)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
protected:
Q_DISABLE_COPY(VisToolCubicBezier)
quint32 object2Id;
quint32 object3Id;
quint32 object4Id;
QGraphicsEllipseItem *point1;
QGraphicsEllipseItem *point2;
QGraphicsEllipseItem *point3;
QGraphicsEllipseItem *point4;
QGraphicsLineItem *helpLine1;
QGraphicsLineItem *helpLine2;
VScaledEllipse *point1;
VScaledEllipse *point2;
VScaledEllipse *point3;
VScaledEllipse *point4;
VScaledLine *helpLine1;
VScaledLine *helpLine2;
};
#endif // VISTOOLCUBICBEZIER_H

View File

@ -41,6 +41,7 @@
#include "../vgeometry/vspline.h"
#include "../visualization.h"
#include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent)
@ -53,8 +54,8 @@ VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphics
helpLine1(nullptr),
helpLine2(nullptr)
{
helpLine1 = InitItem<QGraphicsLineItem>(mainColor, this);
helpLine2 = InitItem<QGraphicsLineItem>(mainColor, this);
helpLine1 = InitItem<VScaledLine>(mainColor, this);
helpLine2 = InitItem<VScaledLine>(mainColor, this);
newCurveSegment = InitItem<VCurvePathItem>(mainColor, this);
}
@ -77,7 +78,7 @@ void VisToolCubicBezierPath::RefreshGeometry()
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);
}
@ -106,18 +107,18 @@ void VisToolCubicBezierPath::RefreshGeometry()
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())),
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);
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())),
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);
}
}
@ -142,34 +143,7 @@ VCubicBezierPath VisToolCubicBezierPath::getPath()
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolCubicBezierPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
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)
VScaledEllipse *VisToolCubicBezierPath::getPoint(QVector<VScaledEllipse *> &points, quint32 i, qreal z)
{
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)
{
@ -192,7 +166,7 @@ QGraphicsLineItem *VisToolCubicBezierPath::getLine(quint32 i)
}
else
{
auto line = InitItem<QGraphicsLineItem>(mainColor, this);
auto line = InitItem<VScaledLine>(mainColor, this);
lines.append(line);
return line;
}
@ -234,7 +208,7 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
DrawLine(helpLine1, p1p2, mainColor, Qt::DashLine);
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);
}
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);
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);
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);
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);
break;
}

View File

@ -55,22 +55,19 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolCubicBezierPath)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
protected:
Q_DISABLE_COPY(VisToolCubicBezierPath)
QVector<QGraphicsEllipseItem *> mainPoints;
QVector<QGraphicsEllipseItem *> ctrlPoints;
QVector<QGraphicsLineItem *> lines;
QVector<VScaledEllipse *> mainPoints;
QVector<VScaledEllipse *> ctrlPoints;
QVector<VScaledLine *> lines;
VCurvePathItem *newCurveSegment;
VCubicBezierPath path;
QGraphicsLineItem *helpLine1;
QGraphicsLineItem *helpLine2;
VScaledLine *helpLine1;
VScaledLine *helpLine2;
private:
QGraphicsEllipseItem *getPoint(QVector<QGraphicsEllipseItem *> &points, quint32 i, qreal z = 0);
QGraphicsLineItem *getLine(quint32 i);
VScaledEllipse *getPoint(QVector<VScaledEllipse *> &points, quint32 i, qreal z = 0);
VScaledLine *getLine(quint32 i);
void Creating(const QVector<VPointF> &pathPoints , int pointsLeft);
void RefreshToolTip();
};

View File

@ -42,6 +42,7 @@
#include "../vpatterndb/vcontainer.h"
#include "../visualization.h"
#include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
@ -83,15 +84,3 @@ void VisToolCutArc::setLength(const QString &expression)
{
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);
}

View File

@ -50,12 +50,9 @@ public:
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolCutArc)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
protected:
Q_DISABLE_COPY(VisToolCutArc)
QGraphicsEllipseItem *point;
VScaledEllipse *point;
VCurvePathItem *arc1;
VCurvePathItem *arc2;
qreal length;

View File

@ -44,6 +44,7 @@
#include "../vpatterndb/vcontainer.h"
#include "../visualization.h"
#include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent)
@ -91,15 +92,3 @@ void VisToolCutSpline::setLength(const QString &expression)
{
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);
}

View File

@ -50,12 +50,9 @@ public:
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
protected:
Q_DISABLE_COPY(VisToolCutSpline)
QGraphicsEllipseItem *point;
VScaledEllipse *point;
VCurvePathItem *spl1;
VCurvePathItem *spl2;
qreal length;

View File

@ -93,15 +93,3 @@ void VisToolCutSplinePath::setLength(const QString &expression)
{
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);
}

View File

@ -50,12 +50,9 @@ public:
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
protected:
Q_DISABLE_COPY(VisToolCutSplinePath)
QGraphicsEllipseItem *point;
VScaledEllipse *point;
VCurvePathItem *splPath1;
VCurvePathItem *splPath2;
qreal length;

View File

@ -91,13 +91,3 @@ void VisToolEllipticalArc::setRotationAngle(const QString &expression)
{
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);
}

View File

@ -54,12 +54,9 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolEllipticalArc)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolEllipticalArc)
QGraphicsEllipseItem *arcCenter;
VScaledEllipse *arcCenter;
qreal radius1;
qreal radius2;
qreal f1;

View File

@ -29,6 +29,7 @@
#include "vistoolpiece.h"
#include "../vpatterndb/vpiecepath.h"
#include "../vgeometry/vpointf.h"
#include "../vwidgets/scalesceneitems.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
@ -38,8 +39,8 @@ VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
m_line2(nullptr),
m_piece()
{
m_line1 = InitItem<QGraphicsLineItem>(supportColor, this);
m_line2 = InitItem<QGraphicsLineItem>(supportColor, this);
m_line1 = InitItem<VScaledLine>(supportColor, this);
m_line2 = InitItem<VScaledLine>(supportColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
@ -55,7 +56,7 @@ void VisToolPiece::RefreshGeometry()
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);
}
@ -79,23 +80,7 @@ void VisToolPiece::SetPiece(const VPiece &piece)
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPiece::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_line1, scale);
ScalePenWidth(m_line2, scale);
VisPath::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *VisToolPiece::GetPoint(quint32 i, const QColor &color)
VScaledEllipse *VisToolPiece::GetPoint(quint32 i, const QColor &color)
{
return GetPointItem(m_points, i, color, this);
}

View File

@ -46,18 +46,15 @@ public:
void SetPiece(const VPiece &piece);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPiece)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPiece)
QVector<QGraphicsEllipseItem *> m_points;
QVector<VScaledEllipse *> m_points;
QGraphicsLineItem *m_line1;
QGraphicsLineItem *m_line2;
VScaledLine *m_line1;
VScaledLine *m_line2;
VPiece m_piece;
QGraphicsEllipseItem* GetPoint(quint32 i, const QColor &color);
VScaledEllipse* GetPoint(quint32 i, const QColor &color);
void HideAllItems();
};

View File

@ -29,6 +29,7 @@
#include "vistoolpiecepath.h"
#include "../vwidgets/vsimplepoint.h"
#include "../vgeometry/vpointf.h"
#include "../vwidgets/scalesceneitems.h"
#include <QGraphicsSceneMouseEvent>
@ -39,7 +40,7 @@ VisToolPiecePath::VisToolPiecePath(const VContainer *data, QGraphicsItem *parent
m_line(nullptr),
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;
}
//---------------------------------------------------------------------------------------------------------------------
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)
{

View File

@ -48,9 +48,6 @@ public:
void SetPath(const VPiecePath &path);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPiecePath)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
protected:
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
@ -58,7 +55,7 @@ private:
Q_DISABLE_COPY(VisToolPiecePath)
QVector<VSimplePoint *> m_points;
QGraphicsLineItem *m_line;
VScaledLine *m_line;
VPiecePath m_path;

View File

@ -107,14 +107,3 @@ void VisToolPointOfIntersectionCurves::setHCrossPoint(const HCrossCurvesPoint &v
{
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);
}

View File

@ -56,16 +56,12 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCurves)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfIntersectionCurves)
quint32 object2Id;
VCrossCurvesPoint vCrossPoint;
HCrossCurvesPoint hCrossPoint;
QGraphicsEllipseItem *point;
VScaledEllipse *point;
VCurvePathItem *visCurve2;
};

View File

@ -221,17 +221,6 @@ QPointF VisToolSpline::GetP3() const
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()
{

View File

@ -64,9 +64,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolSpline)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
public slots:
void MouseLeftPressed();
void MouseLeftReleased();
@ -74,8 +71,8 @@ public slots:
protected:
Q_DISABLE_COPY(VisToolSpline)
quint32 object4Id;
QGraphicsEllipseItem *point1;
QGraphicsEllipseItem *point4;
VScaledEllipse *point1;
VScaledEllipse *point4;
qreal angle1;
qreal angle2;
qreal kAsm1;

View File

@ -48,10 +48,10 @@
//---------------------------------------------------------------------------------------------------------------------
VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *parent)
: VisPath(data, parent),
points(QVector<QGraphicsEllipseItem *>()),
ctrlPoints(QVector<VControlPointSpline *>()),
points(),
ctrlPoints(),
newCurveSegment(nullptr),
path(VSplinePath()),
path(),
isLeftMousePressed(false),
pointSelected(false),
ctrlPoint()
@ -62,8 +62,6 @@ VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *pare
//---------------------------------------------------------------------------------------------------------------------
VisToolSplinePath::~VisToolSplinePath()
{
qDeleteAll(ctrlPoints);
qDeleteAll(points);
emit ToolTip("");
}
@ -77,7 +75,7 @@ void VisToolSplinePath::RefreshGeometry()
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);
}
@ -139,19 +137,6 @@ VSplinePath VisToolSplinePath::getPath()
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()
{
@ -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)
{

View File

@ -58,9 +58,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolSplinePath)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
signals:
void PathChanged(const VSplinePath &path);
@ -70,7 +67,7 @@ public slots:
protected:
Q_DISABLE_COPY(VisToolSplinePath)
QVector<QGraphicsEllipseItem *> points;
QVector<VScaledEllipse *> points;
QVector<VControlPointSpline *> ctrlPoints;
VCurvePathItem *newCurveSegment;
VSplinePath path;
@ -80,7 +77,7 @@ protected:
QPointF ctrlPoint;
QGraphicsEllipseItem * getPoint(quint32 i);
VScaledEllipse * getPoint(quint32 i);
void Creating(const QPointF &pSpl, int size);
};

View File

@ -53,6 +53,7 @@
#include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../vwidgets/vcurvepathitem.h"
#include "../vwidgets/scalesceneitems.h"
template <class K, class V> class QHash;
@ -136,14 +137,7 @@ void Visualization::MousePos(const QPointF &scenePos)
}
//---------------------------------------------------------------------------------------------------------------------
void Visualization::ScalePoint(QGraphicsEllipseItem *item, qreal scale)
{
ScaleCircleSize(item, scale);
ScalePenWidth(item, scale);
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const
VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const
{
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)
@ -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)
@ -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)
{
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->setBrush(QBrush(Qt::NoBrush));

View File

@ -44,6 +44,9 @@
Q_DECLARE_LOGGING_CATEGORY(vVis)
class VScaledEllipse;
class VScaledLine;
enum class Mode : char {Creation, Show};
class Visualization : public QObject
@ -86,15 +89,10 @@ protected:
virtual void InitPen()=0;
virtual void AddOnScene()=0;
template <typename Item>
void ScalePenWidth(Item *item, qreal scale);
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,
VScaledEllipse *InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) const;
void DrawPoint(VScaledEllipse *point, const QPointF &pos, const QColor &color,
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);
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color,
Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap);
@ -107,12 +105,12 @@ protected:
template <class Item>
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);
private:
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;
}
//---------------------------------------------------------------------------------------------------------------------
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

View 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);
}

View 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

View File

@ -48,6 +48,7 @@
#include "vmaingraphicsscene.h"
#include "vmaingraphicsview.h"
#include "vgraphicssimpletextitem.h"
#include "scalesceneitems.h"
//---------------------------------------------------------------------------------------------------------------------
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)
{
const qreal scale = SceneScale(scene());
ScaleLinePenWidth(controlLine, scale);
QPen lPen = controlLine->pen();
lPen.setColor(CorrectColor(controlLine, Qt::black));
controlLine->setPen(lPen);
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.
@ -267,12 +260,8 @@ void VControlPointSpline::Init()
this->setBrush(QBrush(Qt::NoBrush));
this->setZValue(100);
controlLine = new QGraphicsLineItem(this);
QPen cPen = controlLine->pen();
cPen.setBrush(QBrush(Qt::red));
controlLine->setPen(cPen);
controlLine = new VScaledLine(this);
controlLine->SetBasicWidth(widthHairLine);
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
}

View File

@ -60,7 +60,6 @@ public:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
signals:
/**
* @brief ControlPointChangePosition emit when control point change position.
@ -81,7 +80,7 @@ public slots:
void setEnabledPoint(bool enable);
protected:
/** @brief controlLine pointer to line control point. */
QGraphicsLineItem *controlLine;
VScaledLine *controlLine;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;

View File

@ -27,6 +27,7 @@
*************************************************************************/
#include "vcurvepathitem.h"
#include "../vwidgets/global.h"
#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)
{
ScalePenWidth();
if (m_direction != QPainterPath())
{
painter->save();
@ -62,3 +103,14 @@ void VCurvePathItem::SetDirectionPath(const QPainterPath &path)
{
m_direction = path;
}
//---------------------------------------------------------------------------------------------------------------------
void VCurvePathItem::ScalePenWidth()
{
const qreal width = ScaleWidth(widthMainLine, SceneScale(scene()));
QPen toolPen = pen();
toolPen.setWidthF(width);
setPen(toolPen);
}

View File

@ -38,6 +38,9 @@ class VCurvePathItem : public QGraphicsPathItem
{
public:
explicit VCurvePathItem(QGraphicsItem *parent = nullptr);
virtual ~VCurvePathItem() = default;
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
@ -46,6 +49,8 @@ public:
enum { Type = UserType + static_cast<int>(Vis::CurvePathItem)};
void SetDirectionPath(const QPainterPath &path);
protected:
virtual void ScalePenWidth();
private:
Q_DISABLE_COPY(VCurvePathItem)

View File

@ -31,6 +31,7 @@
#include "../vgeometry/vpointf.h"
#include "global.h"
#include "vgraphicssimpletextitem.h"
#include "scalesceneitems.h"
#include <QBrush>
#include <QFont>
@ -46,7 +47,8 @@ VScenePoint::VScenePoint(QGraphicsItem *parent)
m_baseColor(Qt::black)
{
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->setAcceptHoverEvents(true);
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_lineName->setVisible(true);
ScaleLinePenWidth(m_lineName, scale);
QPen lPen = m_lineName->pen();
lPen.setColor(CorrectColor(m_lineName, Qt::black));
m_lineName->setPen(lPen);
RefreshLine();
}
@ -96,14 +100,6 @@ void VScenePoint::RefreshPointGeometry(const VPointF &point)
RefreshLine();
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VScenePoint::boundingRect() const
{
QRectF recTool = QGraphicsEllipseItem::boundingRect();
recTool = recTool.united(childrenBoundingRect());
return recTool;
}
//---------------------------------------------------------------------------------------------------------------------
void VScenePoint::SetOnlyPoint(bool value)
{
@ -169,13 +165,3 @@ void VScenePoint::ScaleMainPenWidth(qreal scale)
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));
}

View File

@ -34,25 +34,24 @@
class VGraphicsSimpleTextItem;
class VPointF;
class VScaledLine;
class VScenePoint: public QGraphicsEllipseItem
{
public:
explicit VScenePoint(QGraphicsItem *parent = nullptr);
~VScenePoint() = default;
virtual ~VScenePoint() = default;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual void RefreshPointGeometry(const VPointF &point);
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
protected:
/** @brief namePoint point label. */
VGraphicsSimpleTextItem *m_namePoint;
/** @brief lineName line what we see if label moved too away from point. */
QGraphicsLineItem *m_lineName;
VScaledLine *m_lineName;
bool m_onlyPoint;
bool m_isHovered;
@ -64,7 +63,6 @@ protected:
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
void RefreshLine();
void ScaleLinePenWidth(QGraphicsLineItem *line, qreal scale);
void SetOnlyPoint(bool value);
bool IsOnlyPoint() const;

View File

@ -57,30 +57,6 @@ VSimpleCurve::VSimpleCurve(quint32 id, const QSharedPointer<VAbstractCurve> &cur
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)
{
@ -191,3 +167,20 @@ void VSimpleCurve::keyReleaseEvent(QKeyEvent *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())));
}

View File

@ -56,9 +56,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
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);
signals:
/**
@ -80,6 +77,7 @@ protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE;
virtual void ScalePenWidth() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VSimpleCurve)

View File

@ -20,7 +20,8 @@ SOURCES += \
$$PWD/fancytabbar/stylehelper.cpp \
$$PWD/vcurvepathitem.cpp \
$$PWD/global.cpp \
$$PWD/vscenepoint.cpp
$$PWD/vscenepoint.cpp \
$$PWD/scalesceneitems.cpp
win32-msvc*:SOURCES += $$PWD/stable.cpp
@ -44,4 +45,5 @@ HEADERS += \
$$PWD/fancytabbar/stylehelper.h \
$$PWD/vcurvepathitem.h \
$$PWD/global.h \
$$PWD/vscenepoint.h
$$PWD/vscenepoint.h \
$$PWD/scalesceneitems.h