Merge with develop.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-06-23 16:21:11 +03:00
commit 146bf98f84
101 changed files with 725 additions and 1112 deletions

View File

@ -83,7 +83,7 @@ defineTest(copyToDestdir) {
for(FILE, files) { for(FILE, files) {
unix{ unix{
QMAKE_POST_LINK += ln -s -f $$quote($$FILE) $$quote($$DDIR/$$basename(FILE)) $$escape_expand(\\n\\t) QMAKE_PRE_LINK += ln -s -f $$quote($$FILE) $$quote($$DDIR/$$basename(FILE)) & $$escape_expand(\\n\\t)
} else { } else {
!exists($$DDIR/$$basename(FILE)) { !exists($$DDIR/$$basename(FILE)) {
# Replace slashes in paths with backslashes for Windows # Replace slashes in paths with backslashes for Windows
@ -91,7 +91,7 @@ defineTest(copyToDestdir) {
FILE ~= s,/,\\,g FILE ~= s,/,\\,g
DDIR ~= s,/,\\,g DDIR ~= s,/,\\,g
} }
QMAKE_POST_LINK += $$VCOPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t) QMAKE_PRE_LINK += $$VCOPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
} }
QMAKE_CLEAN += $$DDIR/$$basename(FILE) QMAKE_CLEAN += $$DDIR/$$basename(FILE)
@ -110,14 +110,14 @@ defineTest(forceCopyToDestdir) {
for(FILE, files) { for(FILE, files) {
unix{ unix{
QMAKE_POST_LINK += ln -s -f $$quote($$FILE) $$quote($$DDIR/$$basename(FILE)) $$escape_expand(\\n\\t) QMAKE_PRE_LINK += ln -s -f $$quote($$FILE) $$quote($$DDIR/$$basename(FILE)) & $$escape_expand(\\n\\t)
} else { } else {
# Replace slashes in paths with backslashes for Windows # Replace slashes in paths with backslashes for Windows
win32{ win32{
FILE ~= s,/,\\,g FILE ~= s,/,\\,g
DDIR ~= s,/,\\,g DDIR ~= s,/,\\,g
} }
QMAKE_POST_LINK += $$VCOPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t) QMAKE_PRE_LINK += $$VCOPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
QMAKE_CLEAN += $$DDIR/$$basename(FILE) QMAKE_CLEAN += $$DDIR/$$basename(FILE)
} }
} }

View File

@ -1191,8 +1191,6 @@ void MainWindow::ZoomFitBestCurrent()
transform.setMatrix(factor, transform.m12(), transform.m13(), transform.m21(), factor, transform.m23(), transform.setMatrix(factor, transform.m12(), transform.m13(), transform.m21(), factor, transform.m23(),
transform.m31(), transform.m32(), transform.m33()); transform.m31(), transform.m32(), transform.m33());
ui->view->setTransform(transform); ui->view->setTransform(transform);
VMainGraphicsView::NewSceneRect(ui->view->scene(), ui->view);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -4653,7 +4651,7 @@ void MainWindow::ZoomFirstShow()
{ {
ActionDraw(true); ActionDraw(true);
} }
ui->view->ZoomFitBest(); ZoomFitBestCurrent();
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view); VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
VMainGraphicsView::NewSceneRect(sceneDetails, ui->view); VMainGraphicsView::NewSceneRect(sceneDetails, ui->view);

View File

@ -64,28 +64,17 @@ VAbstractCubicBezierPath::~VAbstractCubicBezierPath()
{ {
} }
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VAbstractCubicBezierPath::GetDirectionPath() const
{
QPainterPath painterPath;
for (qint32 i = 1; i <= CountSubSpl(); ++i)
{
painterPath.addPath(GetSpline(i).GetDirectionPath());
}
return painterPath;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetPath return QPainterPath which reprezent spline path. * @brief GetPath return QPainterPath which reprezent spline path.
* @return path. * @return path.
*/ */
QPainterPath VAbstractCubicBezierPath::GetPath(PathDirection direction) const QPainterPath VAbstractCubicBezierPath::GetPath() const
{ {
QPainterPath painterPath; QPainterPath painterPath;
for (qint32 i = 1; i <= CountSubSpl(); ++i) for (qint32 i = 1; i <= CountSubSpl(); ++i)
{ {
painterPath.addPath(GetSpline(i).GetPath(direction)); painterPath.addPath(GetSpline(i).GetPath());
} }
return painterPath; return painterPath;
} }
@ -120,6 +109,17 @@ qreal VAbstractCubicBezierPath::GetLength() const
return length; return length;
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<DirectionArrow> VAbstractCubicBezierPath::DirectionArrows() const
{
QVector<DirectionArrow> arrows;
for (qint32 i = 1; i <= CountSubSpl(); ++i)
{
arrows += GetSpline(i).DirectionArrows();
}
return arrows;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VAbstractCubicBezierPath::Segment(const QPointF &p) const int VAbstractCubicBezierPath::Segment(const QPointF &p) const
{ {

View File

@ -59,11 +59,12 @@ public:
virtual VSpline GetSpline(qint32 index) const =0; virtual VSpline GetSpline(qint32 index) const =0;
virtual QVector<VSplinePoint> GetSplinePath() const =0; virtual QVector<VSplinePoint> GetSplinePath() const =0;
virtual QPainterPath GetDirectionPath() const Q_DECL_OVERRIDE; virtual QPainterPath GetPath() const Q_DECL_OVERRIDE;
virtual QPainterPath GetPath(PathDirection direction = PathDirection::Hide) const Q_DECL_OVERRIDE;
virtual QVector<QPointF> GetPoints() const Q_DECL_OVERRIDE; virtual QVector<QPointF> GetPoints() const Q_DECL_OVERRIDE;
virtual qreal GetLength() const Q_DECL_OVERRIDE; virtual qreal GetLength() const Q_DECL_OVERRIDE;
virtual QVector<DirectionArrow> DirectionArrows() const Q_DECL_OVERRIDE;
int Segment(const QPointF &p) const; int Segment(const QPointF &p) const;
QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2,

View File

@ -37,6 +37,8 @@
#include "vabstractcurve_p.h" #include "vabstractcurve_p.h"
const qreal VAbstractCurve::lengthCurveDirectionArrow = 14;
VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode) VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode)
:VGObject(type, idObject, mode), d (new VAbstractCurveData()) :VGObject(type, idObject, mode), d (new VAbstractCurveData())
{} {}
@ -169,13 +171,7 @@ QVector<QPointF> VAbstractCurve::ToEnd(const QVector<QPointF> &points, const QPo
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPainterPath VAbstractCurve::GetDirectionPath() const QPainterPath VAbstractCurve::GetPath() const
{
return ShowDirection(GetPoints());
}
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VAbstractCurve::GetPath(PathDirection direction) const
{ {
QPainterPath path; QPainterPath path;
@ -183,12 +179,6 @@ QPainterPath VAbstractCurve::GetPath(PathDirection direction) const
if (points.count() >= 2) if (points.count() >= 2)
{ {
path.addPolygon(QPolygonF(points)); path.addPolygon(QPolygonF(points));
if (direction == PathDirection::Show)
{
path.addPath(ShowDirection(points));
}
path.setFillRule(Qt::WindingFill);
} }
else else
{ {
@ -323,10 +313,11 @@ QVector<QPointF> VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &poin
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPainterPath VAbstractCurve::ShowDirection(const QVector<QPointF> &points) const QVector<DirectionArrow> VAbstractCurve::DirectionArrows() const
{ {
QPainterPath path; QVector<DirectionArrow> arrows;
const QVector<QPointF> points = GetPoints();
if (points.count() >= 2) if (points.count() >= 2)
{ {
/*Need find coordinate midle of curve. /*Need find coordinate midle of curve.
@ -350,15 +341,45 @@ QPainterPath VAbstractCurve::ShowDirection(const QVector<QPointF> &points) const
//Reverse line because we want start arrow from this point //Reverse line because we want start arrow from this point
arrow = QLineF(arrow.p2(), arrow.p1()); arrow = QLineF(arrow.p2(), arrow.p1());
const qreal angle = arrow.angle();//we each time change line angle, better save original angle value const qreal angle = arrow.angle();//we each time change line angle, better save original angle value
arrow.setLength(14);//arrow length in pixels arrow.setLength(lengthCurveDirectionArrow);//arrow length in pixels
DirectionArrow dArrow;
arrow.setAngle(angle-35); arrow.setAngle(angle-35);
path.moveTo(arrow.p1()); dArrow.first = arrow;
path.lineTo(arrow.p2());
arrow.setAngle(angle+35); arrow.setAngle(angle+35);
path.moveTo(arrow.p1()); dArrow.second = arrow;
path.lineTo(arrow.p2());
arrows.append(dArrow);
}
return arrows;
}
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows, qreal width)
{
QPainterPath path;
for (int i = 0; i < arrows.size(); ++i)
{
const DirectionArrow arrow = arrows.at(i);
if (not arrow.first.isNull() && not arrow.second.isNull())
{
QPainterPath arrowPath;
QLineF line = arrow.first;
line.setLength(width);
arrowPath.moveTo(line.p1());
arrowPath.lineTo(line.p2());
line = arrow.second;
line.setLength(width);
arrowPath.moveTo(line.p1());
arrowPath.lineTo(line.p2());
path.addPath(arrowPath);
}
} }
return path; return path;
} }

View File

@ -42,7 +42,7 @@
#include "vgeometrydef.h" #include "vgeometrydef.h"
#include "vgobject.h" #include "vgobject.h"
enum class PathDirection : char { Hide, Show }; typedef QPair<QLineF, QLineF> DirectionArrow;
class QPainterPath; class QPainterPath;
class VAbstractCurveData; class VAbstractCurveData;
@ -68,8 +68,7 @@ public:
bool reverse = false); bool reverse = false);
QVector<QPointF> GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse = false) const; QVector<QPointF> GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse = false) const;
virtual QPainterPath GetDirectionPath() const; virtual QPainterPath GetPath() const;
virtual QPainterPath GetPath(PathDirection direction = PathDirection::Hide) const;
virtual qreal GetLength() const =0; virtual qreal GetLength() const =0;
qreal GetLengthByPoint(const QPointF &point) const; qreal GetLengthByPoint(const QPointF &point) const;
virtual QVector<QPointF> IntersectLine(const QLineF &line) const; virtual QVector<QPointF> IntersectLine(const QLineF &line) const;
@ -95,7 +94,10 @@ public:
static QVector<QPointF> CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line); static QVector<QPointF> CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line);
virtual QString NameForHistory(const QString &toolName) const=0; virtual QString NameForHistory(const QString &toolName) const=0;
QPainterPath ShowDirection(const QVector<QPointF> &points) const; virtual QVector<DirectionArrow> DirectionArrows() const;
static QPainterPath ShowDirection(const QVector<DirectionArrow> &arrows, qreal width);
static const qreal lengthCurveDirectionArrow;
protected: protected:
virtual void CreateName() =0; virtual void CreateName() =0;
private: private:

View File

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

View File

@ -81,7 +81,9 @@ QPainterPath VAbstractSpline::shape() const
if (m_isHovered || detailsMode) if (m_isHovered || detailsMode)
{ {
path.addPath(curve->GetDirectionPath()); path.addPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(),
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow,
SceneScale(scene()))));
} }
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
@ -131,7 +133,9 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->setPen(arrowPen); painter->setPen(arrowPen);
painter->setBrush(brush()); painter->setBrush(brush());
painter->drawPath(curve->GetDirectionPath()); painter->drawPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(),
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow,
SceneScale(scene()))));
painter->restore(); painter->restore();
} }

View File

@ -48,6 +48,7 @@
#include "../../../../vabstracttool.h" #include "../../../../vabstracttool.h"
#include "../../../vdrawtool.h" #include "../../../vdrawtool.h"
#include "../vtoolsinglepoint.h" #include "../vtoolsinglepoint.h"
#include "../vwidgets/scalesceneitems.h"
template <class T> class QSharedPointer; template <class T> class QSharedPointer;
@ -74,7 +75,8 @@ VToolLinePoint::VToolLinePoint(VAbstractPattern *doc, VContainer *data, const qu
Q_ASSERT_X(basePointId != 0, Q_FUNC_INFO, "basePointId == 0"); //-V654 //-V712 Q_ASSERT_X(basePointId != 0, Q_FUNC_INFO, "basePointId == 0"); //-V654 //-V712
QPointF point1 = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId)); QPointF point1 = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
QPointF point2 = static_cast<QPointF>(*data->GeometricObject<VPointF>(id)); QPointF point2 = static_cast<QPointF>(*data->GeometricObject<VPointF>(id));
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); mainLine = new VScaledLine(QLineF(point1 - point2, QPointF()), this);
mainLine->SetBasicWidth(widthHairLine);
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
} }
@ -87,21 +89,15 @@ VToolLinePoint::~VToolLinePoint()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void VToolLinePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
const qreal width = ScaleWidth(m_isHovered ? widthMainLine : widthHairLine, SceneScale(scene())); QPen mPen = mainLine->pen();
mPen.setColor(CorrectColor(this, lineColor));
mPen.setStyle(LineStyleToPenStyle(m_lineType));
mainLine->setPen(QPen(CorrectColor(this, lineColor), width, LineStyleToPenStyle(m_lineType))); mainLine->setPen(mPen);
VToolSinglePoint::paint(painter, option, widget); VToolSinglePoint::paint(painter, option, widget);
} }
//---------------------------------------------------------------------------------------------------------------------
QRectF VToolLinePoint::boundingRect() const
{
QRectF recTool = VToolSinglePoint::boundingRect();
recTool = recTool.united(childrenBoundingRect());
return recTool;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief RefreshGeometry refresh item on scene. * @brief RefreshGeometry refresh item on scene.
@ -133,6 +129,20 @@ void VToolLinePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrLineColor, lineColor);
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
mainLine->SetBasicWidth(widthMainLine);
VToolSinglePoint::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
mainLine->SetBasicWidth(widthHairLine);
VToolSinglePoint::hoverLeaveEvent(event);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::Disable(bool disable, const QString &namePP) void VToolLinePoint::Disable(bool disable, const QString &namePP)
{ {

View File

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

View File

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

View File

@ -201,7 +201,7 @@ void VNodePoint::RefreshDataInFile()
void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
// Special for not selectable item first need to call standard mousePressEvent then accept event // Special for not selectable item first need to call standard mousePressEvent then accept event
QGraphicsEllipseItem::mousePressEvent(event); VScenePoint::mousePressEvent(event);
// Somehow clicking on notselectable object do not clean previous selections. // Somehow clicking on notselectable object do not clean previous selections.
if (not (flags() & ItemIsSelectable) && scene()) if (not (flags() & ItemIsSelectable) && scene())
@ -223,7 +223,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
emit ChoosedTool(id, SceneObject::Point); emit ChoosedTool(id, SceneObject::Point);
} }
QGraphicsEllipseItem::mouseReleaseEvent(event); VScenePoint::mouseReleaseEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

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

View File

@ -50,11 +50,11 @@ protected:
QVector<quint32> objects; QVector<quint32> objects;
QColor supportColor2; QColor supportColor2;
QVector<QGraphicsEllipseItem *> points; QVector<VScaledEllipse *> points;
QVector<VCurvePathItem *> curves; QVector<VCurvePathItem *> curves;
QGraphicsEllipseItem * GetPoint(quint32 i, const QColor &color); VScaledEllipse *GetPoint(quint32 i, const QColor &color);
VCurvePathItem * GetCurve(quint32 i, const QColor &color); VCurvePathItem *GetCurve(quint32 i, const QColor &color);
template <class Item> template <class Item>
int AddFlippedCurve(const QPointF &firstPoint, const QPointF &secondPoint, quint32 id, int i); int AddFlippedCurve(const QPointF &firstPoint, const QPointF &secondPoint, quint32 id, int i);
@ -72,14 +72,14 @@ int VisOperation::AddFlippedCurve(const QPointF &firstPoint, const QPointF &seco
++i; ++i;
VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor2); VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor2);
DrawPath(path, curve->GetPath(PathDirection::Show), supportColor2, Qt::SolidLine, Qt::RoundCap); DrawPath(path, curve->GetPath(), curve->DirectionArrows(), supportColor2, Qt::SolidLine, Qt::RoundCap);
++i; ++i;
path = GetCurve(static_cast<quint32>(i), supportColor); path = GetCurve(static_cast<quint32>(i), supportColor);
if (object1Id != NULL_ID) if (object1Id != NULL_ID)
{ {
const Item flipped = curve->Flip(QLineF(firstPoint, secondPoint)); const Item flipped = curve->Flip(QLineF(firstPoint, secondPoint));
DrawPath(path, flipped.GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); DrawPath(path, flipped.GetPath(), flipped.DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap);
} }
return i; return i;

View File

@ -80,13 +80,3 @@ void VisToolFlippingByAxis::SetAxisType(AxisType value)
{ {
m_axisType = value; m_axisType = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point1, scale);
VisOperation::paint(painter, option, widget);
}

View File

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

View File

@ -72,17 +72,6 @@ void VisToolFlippingByLine::RefreshGeometry()
RefreshFlippedObjects(firstPoint, secondPoint); RefreshFlippedObjects(firstPoint, secondPoint);
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point1, scale);
ScalePoint(point2, scale);
VisOperation::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::SetFirstLinePointId(quint32 value) void VisToolFlippingByLine::SetFirstLinePointId(quint32 value)
{ {

View File

@ -41,8 +41,6 @@ public:
virtual ~VisToolFlippingByLine() = default; virtual ~VisToolFlippingByLine() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE; virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
void SetFirstLinePointId(quint32 value); void SetFirstLinePointId(quint32 value);
void SetSecondLinePointId(quint32 value); void SetSecondLinePointId(quint32 value);
@ -51,9 +49,9 @@ public:
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByLine)}; enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByLine)};
private: private:
Q_DISABLE_COPY(VisToolFlippingByLine) Q_DISABLE_COPY(VisToolFlippingByLine)
quint32 object2Id; quint32 object2Id;
QGraphicsEllipseItem *point1; VScaledEllipse *point1;
QGraphicsEllipseItem *point2; VScaledEllipse *point2;
}; };
#endif // VISTOOLFLIPPINGBYLINE_H #endif // VISTOOLFLIPPINGBYLINE_H

View File

@ -128,17 +128,6 @@ void VisToolMove::RefreshGeometry()
CreateMovedObjects(iPoint, iCurve, tempLength, tempAngle); CreateMovedObjects(iPoint, iCurve, tempLength, tempAngle);
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(pointOrigin, scale);
ScalePoint(pointFinish, scale);
VisOperation::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VisToolMove::Angle() const QString VisToolMove::Angle() const
{ {
@ -177,7 +166,7 @@ QGraphicsPathItem *VisToolMove::AddOriginCurve(quint32 id, int &i)
++i; ++i;
VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor2); VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor2);
DrawPath(path, curve->GetPath(PathDirection::Show), supportColor2, Qt::SolidLine, Qt::RoundCap); DrawPath(path, curve->GetPath(), curve->DirectionArrows(), supportColor2, Qt::SolidLine, Qt::RoundCap);
return path; return path;
} }
@ -191,7 +180,7 @@ int VisToolMove::AddMovedCurve(qreal angle, qreal length, quint32 id, int i)
++i; ++i;
VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor); VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor);
const Item moved = curve->Move(length, angle); const Item moved = curve->Move(length, angle);
DrawPath(path, moved.GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); DrawPath(path, moved.GetPath(), moved.DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap);
return i; return i;
} }
@ -244,7 +233,7 @@ QVector<QGraphicsItem *> VisToolMove::CreateOriginObjects(int &iPoint, int &iCur
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
++iPoint; ++iPoint;
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2); VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
DrawPoint(point, static_cast<QPointF>(*p), supportColor2); DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
originObjects.append(point); originObjects.append(point);
@ -299,7 +288,7 @@ void VisToolMove::CreateMovedObjects(int &iPoint, int &iCurve, qreal length, qre
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
++iPoint; ++iPoint;
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor); VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor);
DrawPoint(point, static_cast<QPointF>(p->Move(length, angle)), supportColor); DrawPoint(point, static_cast<QPointF>(p->Move(length, angle)), supportColor);
break; break;
} }

View File

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

View File

@ -65,7 +65,7 @@ VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
{ {
point = InitPoint(supportColor2, this); point = InitPoint(supportColor2, this);
angleArc = InitItem<VCurvePathItem>(supportColor2, this); angleArc = InitItem<VCurvePathItem>(supportColor2, this);
xAxis = InitItem<QGraphicsLineItem>(supportColor2, this); xAxis = InitItem<VScaledLine>(supportColor2, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -117,7 +117,7 @@ void VisToolRotation::RefreshGeometry()
Qt::DashLine); Qt::DashLine);
VArc arc(*origin, defPointRadiusPixel*2, 0, tempAngle); VArc arc(*origin, defPointRadiusPixel*2, 0, tempAngle);
DrawPath(angleArc, arc.GetPath(PathDirection::Hide), supportColor2, Qt::SolidLine, Qt::RoundCap); DrawPath(angleArc, arc.GetPath(), supportColor2, Qt::SolidLine, Qt::RoundCap);
Visualization::toolTip = tr("Rotating angle = %1°, <b>Shift</b> - sticking angle, " Visualization::toolTip = tr("Rotating angle = %1°, <b>Shift</b> - sticking angle, "
"<b>Mouse click</b> - finish creation").arg(tempAngle); "<b>Mouse click</b> - finish creation").arg(tempAngle);
@ -140,7 +140,7 @@ void VisToolRotation::RefreshGeometry()
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
++iPoint; ++iPoint;
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2); VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
DrawPoint(point, static_cast<QPointF>(*p), supportColor2); DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
++iPoint; ++iPoint;
@ -190,18 +190,6 @@ void VisToolRotation::RefreshGeometry()
} }
QT_WARNING_POP QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePenWidth(angleArc, scale);
ScalePenWidth(xAxis, scale);
VisOperation::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::SetOriginPointId(quint32 value) void VisToolRotation::SetOriginPointId(quint32 value)
{ {
@ -228,14 +216,14 @@ int VisToolRotation::AddCurve(qreal angle, const QPointF &origin, quint32 id, in
++i; ++i;
VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor2); VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor2);
DrawPath(path, curve->GetPath(PathDirection::Show), supportColor2, Qt::SolidLine, Qt::RoundCap); DrawPath(path, curve->GetPath(), curve->DirectionArrows(), supportColor2, Qt::SolidLine, Qt::RoundCap);
++i; ++i;
path = GetCurve(static_cast<quint32>(i), supportColor); path = GetCurve(static_cast<quint32>(i), supportColor);
if (object1Id != NULL_ID) if (object1Id != NULL_ID)
{ {
const Item rotated = curve->Rotate(origin, angle); const Item rotated = curve->Rotate(origin, angle);
DrawPath(path, rotated.GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); DrawPath(path, rotated.GetPath(), rotated.DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap);
} }
return i; return i;

View File

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

View File

@ -41,7 +41,7 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisLine::VisLine(const VContainer *data, QGraphicsItem *parent) VisLine::VisLine(const VContainer *data, QGraphicsItem *parent)
:Visualization(data), QGraphicsLineItem(parent) :Visualization(data), VScaledLine(parent)
{ {
this->setZValue(1);// Show on top real tool this->setZValue(1);// Show on top real tool
InitPen(); InitPen();
@ -78,22 +78,6 @@ qreal VisLine::CorrectAngle(const qreal &angle)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VisLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
ScalePenWidth(this, SceneScale(scene()));
QGraphicsLineItem::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisLine::boundingRect() const
{
QRectF recTool = QGraphicsLineItem::boundingRect();
recTool = recTool.united(childrenBoundingRect());
return recTool;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
{ {
@ -164,7 +148,7 @@ void VisLine::AddOnScene()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisLine::DrawRay(QGraphicsLineItem *lineItem, const QPointF &p, const QPointF &pTangent, const QColor &color, void VisLine::DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent, const QColor &color,
Qt::PenStyle style) Qt::PenStyle style)
{ {
SCASSERT (lineItem != nullptr) SCASSERT (lineItem != nullptr)

View File

@ -43,8 +43,9 @@
#include "../vtools/visualization/visualization.h" #include "../vtools/visualization/visualization.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vwidgets/scalesceneitems.h"
class VisLine: public Visualization, public QGraphicsLineItem class VisLine: public Visualization, public VScaledLine
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -54,10 +55,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::Line)}; enum { Type = UserType + static_cast<int>(Vis::Line)};
static qreal CorrectAngle(const qreal &angle); static qreal CorrectAngle(const qreal &angle);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
protected: protected:
QPointF Ray(const QPointF &firstPoint, const qreal &angle) const; QPointF Ray(const QPointF &firstPoint, const qreal &angle) const;
QPointF Ray(const QPointF &firstPoint) const; QPointF Ray(const QPointF &firstPoint) const;
@ -66,7 +63,7 @@ protected:
virtual void InitPen() Q_DECL_OVERRIDE; virtual void InitPen() Q_DECL_OVERRIDE;
virtual void AddOnScene() Q_DECL_OVERRIDE; virtual void AddOnScene() Q_DECL_OVERRIDE;
void DrawRay(QGraphicsLineItem *lineItem, const QPointF &p, const QPointF &pTangent, void DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent,
const QColor &color, Qt::PenStyle style); const QColor &color, Qt::PenStyle style);
private: private:
Q_DISABLE_COPY(VisLine) Q_DISABLE_COPY(VisLine)

View File

@ -53,7 +53,7 @@ VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent
lineP1 = InitPoint(supportColor, this); lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this); //-V656 lineP2 = InitPoint(supportColor, this); //-V656
line = InitItem<QGraphicsLineItem>(supportColor, this); line = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -69,19 +69,6 @@ void VisToolAlongLine::setLength(const QString &expression)
length = FindLength(expression, Visualization::data->PlainVariables()); length = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePenWidth(line, scale);
VisLine::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::RefreshGeometry() void VisToolAlongLine::RefreshGeometry()
{ {

View File

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

View File

@ -49,10 +49,10 @@ VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
{ {
line1P1 = InitPoint(supportColor, this); line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this); //-V656 line1P2 = InitPoint(supportColor, this); //-V656
line1 = InitItem<QGraphicsLineItem>(supportColor, this); line1 = InitItem<VScaledLine>(supportColor, this);
line2P2 = InitPoint(supportColor, this); line2P2 = InitPoint(supportColor, this);
line2 = InitItem<QGraphicsLineItem>(supportColor, this); line2 = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -75,21 +75,6 @@ void VisToolBisector::setLength(const QString &expression)
length = FindLength(expression, Visualization::data->PlainVariables()); length = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolBisector::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(line1P1, scale);
ScalePoint(line1P2, scale);
ScalePenWidth(line1, scale);
ScalePoint(line2P2, scale);
ScalePenWidth(line2, scale);
VisLine::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolBisector::RefreshGeometry() void VisToolBisector::RefreshGeometry()
{ {

View File

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

View File

@ -55,8 +55,8 @@ VisToolCurveIntersectAxis::VisToolCurveIntersectAxis(const VContainer *data, QGr
visCurve = InitItem<VCurvePathItem>(Qt::darkGreen, this); visCurve = InitItem<VCurvePathItem>(Qt::darkGreen, this);
basePoint = InitPoint(supportColor, this); basePoint = InitPoint(supportColor, this);
baseLine = InitItem<QGraphicsLineItem>(supportColor, this); baseLine = InitItem<VScaledLine>(supportColor, this);
axisLine = InitItem<QGraphicsLineItem>(supportColor, this); //-V656 axisLine = InitItem<VScaledLine>(supportColor, this); //-V656
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -66,7 +66,7 @@ void VisToolCurveIntersectAxis::RefreshGeometry()
if (object1Id > NULL_ID) if (object1Id > NULL_ID)
{ {
const QSharedPointer<VAbstractCurve> curve = Visualization::data->GeometricObject<VAbstractCurve>(object1Id); const QSharedPointer<VAbstractCurve> curve = Visualization::data->GeometricObject<VAbstractCurve>(object1Id);
DrawPath(visCurve, curve->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); DrawPath(visCurve, curve->GetPath(), curve->DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap);
if (axisPointId > NULL_ID) if (axisPointId > NULL_ID)
{ {
@ -113,17 +113,3 @@ void VisToolCurveIntersectAxis::setAxisPointId(const quint32 &value)
{ {
axisPointId = value; axisPointId = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolCurveIntersectAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(basePoint, scale);
ScalePenWidth(baseLine, scale);
ScalePenWidth(axisLine, scale);
ScalePenWidth(visCurve, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

@ -110,13 +110,3 @@ void VisToolEndLine::setLength(const QString &expression)
{ {
length = FindLength(expression, Visualization::data->PlainVariables()); length = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

@ -50,8 +50,8 @@ VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent)
base_point = InitPoint(supportColor, this); base_point = InitPoint(supportColor, this);
lineP1 = InitPoint(supportColor, this); lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this); lineP2 = InitPoint(supportColor, this);
line = InitItem<QGraphicsLineItem>(supportColor, this); line = InitItem<VScaledLine>(supportColor, this);
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this); //-V656 line_intersection = InitItem<VScaledLine>(supportColor, this); //-V656
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -112,21 +112,6 @@ void VisToolHeight::setLineP2Id(const quint32 &value)
lineP2Id = value; lineP2Id = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolHeight::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(base_point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePenWidth(line, scale);
ScalePenWidth(line_intersection, scale);
VisLine::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line) void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line)
{ {

View File

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

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) SCASSERT (lineItem != nullptr)

View File

@ -54,7 +54,7 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLine)}; enum { Type = UserType + static_cast<int>(Vis::ToolLine)};
protected: protected:
virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color,
Qt::PenStyle style = Qt::SolidLine) Q_DECL_OVERRIDE; Qt::PenStyle style = Qt::SolidLine) Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VisToolLine) Q_DISABLE_COPY(VisToolLine)

View File

@ -48,7 +48,7 @@ VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem
{ {
line1P1 = InitPoint(supportColor, this); line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this); line1P2 = InitPoint(supportColor, this);
line1 = InitItem<QGraphicsLineItem>(supportColor, this); line1 = InitItem<VScaledLine>(supportColor, this);
line2P1 = InitPoint(supportColor, this); line2P1 = InitPoint(supportColor, this);
line2P2 = InitPoint(supportColor, this); line2P2 = InitPoint(supportColor, this);
@ -135,18 +135,3 @@ void VisToolLineIntersect::setLine2P2Id(const quint32 &value)
{ {
line2P2Id = value; line2P2Id = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersect::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(line1P1, scale);
ScalePoint(line1P2, scale);
ScalePenWidth(line1, scale);
ScalePoint(line2P1, scale);
ScalePoint(line2P2, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

@ -53,9 +53,9 @@ VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGrap
lineP1 = InitPoint(supportColor, this); lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this); lineP2 = InitPoint(supportColor, this);
basePoint = InitPoint(supportColor, this); basePoint = InitPoint(supportColor, this);
baseLine = InitItem<QGraphicsLineItem>(supportColor, this); baseLine = InitItem<VScaledLine>(supportColor, this);
axisLine = InitItem<QGraphicsLineItem>(supportColor, this); axisLine = InitItem<VScaledLine>(supportColor, this);
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this); line_intersection = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -133,22 +133,6 @@ void VisToolLineIntersectAxis::setAxisPointId(const quint32 &value)
axisPointId = value; axisPointId = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePoint(basePoint, scale);
ScalePenWidth(baseLine, scale);
ScalePenWidth(axisLine, scale);
ScalePenWidth(line_intersection, scale);
VisLine::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line) void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line)
{ {

View File

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

View File

@ -52,7 +52,7 @@ VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
lineP1 = InitPoint(supportColor, this); lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this); //-V656 lineP2 = InitPoint(supportColor, this); //-V656
line = InitItem<QGraphicsLineItem>(supportColor, this); line = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -124,16 +124,3 @@ void VisToolNormal::SetAngle(const qreal &value)
{ {
angle = value; angle = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolNormal::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePenWidth(line, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

@ -54,7 +54,7 @@ VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *d
arcPath = InitItem<VCurvePathItem>(Qt::darkGreen, this); arcPath = InitItem<VCurvePathItem>(Qt::darkGreen, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
tangent = InitPoint(supportColor, this); tangent = InitPoint(supportColor, this);
tangentLine2 = InitItem<QGraphicsLineItem>(supportColor, this); tangentLine2 = InitItem<VScaledLine>(supportColor, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -68,7 +68,7 @@ void VisToolPointFromArcAndTangent::RefreshGeometry()
if (arcId > NULL_ID)// circle center if (arcId > NULL_ID)// circle center
{ {
const QSharedPointer<VArc> arc = Visualization::data->GeometricObject<VArc>(arcId); const QSharedPointer<VArc> arc = Visualization::data->GeometricObject<VArc>(arcId);
DrawPath(arcPath, arc->GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); DrawPath(arcPath, arc->GetPath(), arc->DirectionArrows(), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap);
FindRays(static_cast<QPointF>(*tan), arc.data()); FindRays(static_cast<QPointF>(*tan), arc.data());
@ -91,19 +91,6 @@ void VisToolPointFromArcAndTangent::setCrossPoint(const CrossCirclesPoint &value
crossPoint = value; crossPoint = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(tangent, scale);
ScalePenWidth(arcPath, scale);
ScalePenWidth(tangentLine2, scale);
VisLine::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc) void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc)
{ {

View File

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

View File

@ -47,11 +47,11 @@ VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContai
: VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint), : VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint),
point(nullptr), tangent(nullptr), cCenter(nullptr), cPath(nullptr), tangent2(nullptr) point(nullptr), tangent(nullptr), cCenter(nullptr), cPath(nullptr), tangent2(nullptr)
{ {
cPath = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this); cPath = InitItem<VScaledEllipse>(Qt::darkGreen, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
tangent = InitPoint(supportColor, this); tangent = InitPoint(supportColor, this);
cCenter = InitPoint(supportColor, this); //-V656 cCenter = InitPoint(supportColor, this); //-V656
tangent2 = InitItem<QGraphicsLineItem>(supportColor, this); tangent2 = InitItem<VScaledLine>(supportColor, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -101,20 +101,6 @@ void VisToolPointFromCircleAndTangent::setCrossPoint(const CrossCirclesPoint &va
crossPoint = value; crossPoint = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromCircleAndTangent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(tangent, scale);
ScalePoint(cCenter, scale);
ScalePoint(cPath, scale);
ScalePenWidth(tangent2, scale);
VisLine::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromCircleAndTangent::FindRays(const QPointF &p, const QPointF &center, qreal radius) 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;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromCircleAndTangent)}; enum { Type = UserType + static_cast<int>(Vis::ToolPointFromCircleAndTangent)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VisToolPointFromCircleAndTangent) Q_DISABLE_COPY(VisToolPointFromCircleAndTangent)
quint32 object2Id; quint32 object2Id;
qreal cRadius; qreal cRadius;
CrossCirclesPoint crossPoint; CrossCirclesPoint crossPoint;
QGraphicsEllipseItem *point; VScaledEllipse *point;
QGraphicsEllipseItem *tangent; VScaledEllipse *tangent;
QGraphicsEllipseItem *cCenter; VScaledEllipse *cCenter;
QGraphicsEllipseItem *cPath; VScaledEllipse *cPath;
QGraphicsLineItem *tangent2; VScaledLine *tangent2;
void FindRays(const QPointF &p, const QPointF &center, qreal radius); 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); arc_point = InitPoint(supportColor, this);
lineP1 = InitPoint(supportColor, this); lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this); lineP2 = InitPoint(supportColor, this);
circle = InitItem<QGraphicsEllipseItem>(supportColor, this); circle = InitItem<VScaledEllipse>(supportColor, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -114,17 +114,3 @@ void VisToolPointOfContact::setRadius(const QString &expression)
{ {
radius = FindLength(expression, Visualization::data->PlainVariables()); radius = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfContact::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePoint(arc_point, scale);
ScalePoint(circle, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

@ -48,7 +48,7 @@ VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, Q
{ {
axisP1 = InitPoint(supportColor, this); axisP1 = InitPoint(supportColor, this);
axisP2 = InitPoint(supportColor, this); //-V656 axisP2 = InitPoint(supportColor, this); //-V656
axis2 = InitItem<QGraphicsLineItem>(supportColor, this); axis2 = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -93,19 +93,6 @@ void VisToolPointOfIntersection::setPoint2Id(const quint32 &value)
point2Id = value; point2Id = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersection::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(axisP1, scale);
ScalePoint(axisP2, scale);
ScalePenWidth(axis2, scale);
VisLine::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color) void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color)
{ {

View File

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

View File

@ -71,12 +71,12 @@ void VisToolPointOfIntersectionArcs::RefreshGeometry()
if (arc1Id > NULL_ID) if (arc1Id > NULL_ID)
{ {
const QSharedPointer<VArc> arc1 = Visualization::data->GeometricObject<VArc>(arc1Id); const QSharedPointer<VArc> arc1 = Visualization::data->GeometricObject<VArc>(arc1Id);
DrawPath(arc1Path, arc1->GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); DrawPath(arc1Path, arc1->GetPath(), arc1->DirectionArrows(), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap);
if (arc2Id > NULL_ID) if (arc2Id > NULL_ID)
{ {
const QSharedPointer<VArc> arc2 = Visualization::data->GeometricObject<VArc>(arc2Id); const QSharedPointer<VArc> arc2 = Visualization::data->GeometricObject<VArc>(arc2Id);
DrawPath(arc2Path, arc2->GetPath(PathDirection::Show), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); DrawPath(arc2Path, arc2->GetPath(), arc2->DirectionArrows(), Qt::darkRed, Qt::SolidLine, Qt::RoundCap);
const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint); const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint);
DrawPoint(point, fPoint, mainColor); DrawPoint(point, fPoint, mainColor);
@ -114,15 +114,3 @@ void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossCirclesPoint &valu
{ {
crossPoint = value; crossPoint = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePenWidth(arc1Path, scale);
ScalePenWidth(arc2Path, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

@ -52,8 +52,8 @@ VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VCont
{ {
this->setPen(QPen(Qt::NoPen)); // don't use parent this time this->setPen(QPen(Qt::NoPen)); // don't use parent this time
c1Path = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this); c1Path = InitItem<VScaledEllipse>(Qt::darkGreen, this);
c2Path = InitItem<QGraphicsEllipseItem>(Qt::darkRed, this); c2Path = InitItem<VScaledEllipse>(Qt::darkRed, this);
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
c1Center = InitPoint(supportColor, this); c1Center = InitPoint(supportColor, this);
c2Center = InitPoint(supportColor, this); //-V656 c2Center = InitPoint(supportColor, this); //-V656
@ -125,18 +125,3 @@ void VisToolPointOfIntersectionCircles::setCrossPoint(const CrossCirclesPoint &v
{ {
crossPoint = value; crossPoint = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionCircles::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(c1Center, scale);
ScalePoint(c2Center, scale);
ScalePoint(c1Path, scale);
ScalePoint(c2Path, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

@ -50,11 +50,11 @@ VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem
{ {
line1P1 = InitPoint(supportColor, this); line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this); //-V656 line1P2 = InitPoint(supportColor, this); //-V656
line1 = InitItem<QGraphicsLineItem>(supportColor, this); line1 = InitItem<VScaledLine>(supportColor, this);
line2P2 = InitPoint(supportColor, this); line2P2 = InitPoint(supportColor, this);
line2 = InitItem<QGraphicsLineItem>(supportColor, this); line2 = InitItem<VScaledLine>(supportColor, this);
line3 = InitItem<QGraphicsLineItem>(supportColor, this); //-V656 line3 = InitItem<VScaledLine>(supportColor, this); //-V656
point = InitPoint(mainColor, this); point = InitPoint(mainColor, this);
} }
@ -131,19 +131,3 @@ void VisToolShoulderPoint::setLength(const QString &expression)
{ {
length = FindLength(expression, Visualization::data->PlainVariables()); length = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolShoulderPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(line1P1, scale);
ScalePoint(line1P2, scale);
ScalePenWidth(line1, scale);
ScalePoint(line2P2, scale);
ScalePenWidth(line2, scale);
ScalePenWidth(line3, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

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

View File

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

View File

@ -67,10 +67,10 @@ VisToolTrueDarts::VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent
dartP2 = InitPoint(supportColor, this); dartP2 = InitPoint(supportColor, this);
dartP3 = InitPoint(supportColor, this); dartP3 = InitPoint(supportColor, this);
lineblP1P1 = InitItem<QGraphicsLineItem>(supportColor, this); lineblP1P1 = InitItem<VScaledLine>(supportColor, this);
lineblP2P2 = InitItem<QGraphicsLineItem>(supportColor, this); lineblP2P2 = InitItem<VScaledLine>(supportColor, this);
p1d2 = InitItem<QGraphicsLineItem>(supportColor, this); p1d2 = InitItem<VScaledLine>(supportColor, this);
d2p2 = InitItem<QGraphicsLineItem>(supportColor, this); d2p2 = InitItem<VScaledLine>(supportColor, this);
point1 = InitPoint(mainColor, this); point1 = InitPoint(mainColor, this);
point2 = InitPoint(mainColor, this); //-V656 point2 = InitPoint(mainColor, this); //-V656
@ -163,24 +163,3 @@ void VisToolTrueDarts::setD3PointId(const quint32 &value)
{ {
dartP3Id = value; dartP3Id = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolTrueDarts::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point1, scale);
ScalePoint(point2, scale);
ScalePoint(baseLineP1, scale);
ScalePoint(baseLineP2, scale);
ScalePoint(dartP1, scale);
ScalePoint(dartP2, scale);
ScalePoint(dartP3, scale);
ScalePenWidth(lineblP1P1, scale);
ScalePenWidth(lineblP2P2, scale);
ScalePenWidth(p1d2, scale);
ScalePenWidth(d2p2, scale);
VisLine::paint(painter, option, widget);
}

View File

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

View File

@ -45,22 +45,6 @@ VisPath::VisPath(const VContainer *data, QGraphicsItem *parent)
InitPen(); InitPen();
} }
//---------------------------------------------------------------------------------------------------------------------
void VisPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
ScalePenWidth(this, SceneScale(scene()));
VCurvePathItem::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisPath::boundingRect() const
{
QRectF recTool = VCurvePathItem::boundingRect();
recTool = recTool.united(childrenBoundingRect());
return recTool;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisPath::InitPen() void VisPath::InitPen()
{ {

View File

@ -51,10 +51,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::Path)}; enum { Type = UserType + static_cast<int>(Vis::Path)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
protected: protected:
virtual void InitPen() Q_DECL_OVERRIDE; virtual void InitPen() Q_DECL_OVERRIDE;
virtual void AddOnScene() Q_DECL_OVERRIDE; virtual void AddOnScene() Q_DECL_OVERRIDE;

View File

@ -41,6 +41,7 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../visualization.h" #include "../visualization.h"
#include "vispath.h" #include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent) VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent)
@ -60,7 +61,7 @@ void VisToolArc::RefreshGeometry()
if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0) if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0)
{ {
VArc arc = VArc (*first, radius, f1, f2); VArc arc = VArc (*first, radius, f1, f2);
DrawPath(this, arc.GetPath(), arc.GetDirectionPath(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
} }
} }
} }
@ -82,13 +83,3 @@ void VisToolArc::setF2(const QString &expression)
{ {
f2 = FindVal(expression, Visualization::data->PlainVariables()); f2 = FindVal(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(arcCenter, scale);
VisPath::paint(painter, option, widget);
}

View File

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

View File

@ -60,7 +60,7 @@ void VisToolArcWithLength::RefreshGeometry()
if (not qFuzzyIsNull(radius) && f1 >= 0 && not qFuzzyIsNull(length)) if (not qFuzzyIsNull(radius) && f1 >= 0 && not qFuzzyIsNull(length))
{ {
VArc arc = VArc (length, *first, radius, f1); VArc arc = VArc (length, *first, radius, f1);
DrawPath(this, arc.GetPath(), arc.GetDirectionPath(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
} }
} }
} }
@ -82,13 +82,3 @@ void VisToolArcWithLength::setLength(const QString &expression)
{ {
length = FindLength(expression, Visualization::data->PlainVariables()); length = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(arcCenter, scale);
VisPath::paint(painter, option, widget);
}

View File

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

View File

@ -43,6 +43,7 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../visualization.h" #include "../visualization.h"
#include "vispath.h" #include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent) VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent)
@ -57,8 +58,8 @@ VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *pa
helpLine1(nullptr), helpLine1(nullptr),
helpLine2(nullptr) helpLine2(nullptr)
{ {
helpLine1 = InitItem<QGraphicsLineItem>(mainColor, this); helpLine1 = InitItem<VScaledLine>(mainColor, this);
helpLine2 = InitItem<QGraphicsLineItem>(mainColor, this); helpLine2 = InitItem<VScaledLine>(mainColor, this);
point1 = InitPoint(supportColor, this); point1 = InitPoint(supportColor, this);
point2 = InitPoint(supportColor, this); //-V656 point2 = InitPoint(supportColor, this); //-V656
@ -89,7 +90,7 @@ void VisToolCubicBezier::RefreshGeometry()
{ {
VCubicBezier spline(*first, *second, VPointF(Visualization::scenePos), VCubicBezier spline(*first, *second, VPointF(Visualization::scenePos),
VPointF(Visualization::scenePos)); VPointF(Visualization::scenePos));
DrawPath(this, spline.GetPath(PathDirection::Hide), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap);
} }
else else
{ {
@ -99,7 +100,7 @@ void VisToolCubicBezier::RefreshGeometry()
if (object4Id <= NULL_ID) if (object4Id <= NULL_ID)
{ {
VCubicBezier spline(*first, *second, *third, VPointF(Visualization::scenePos)); VCubicBezier spline(*first, *second, *third, VPointF(Visualization::scenePos));
DrawPath(this, spline.GetPath(PathDirection::Hide), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap);
DrawLine(helpLine2, QLineF(static_cast<QPointF>(*third), Visualization::scenePos), mainColor, DrawLine(helpLine2, QLineF(static_cast<QPointF>(*third), Visualization::scenePos), mainColor,
Qt::DashLine); Qt::DashLine);
} }
@ -111,7 +112,7 @@ void VisToolCubicBezier::RefreshGeometry()
Qt::DashLine); Qt::DashLine);
VCubicBezier spline(*first, *second, *third, *fourth); VCubicBezier spline(*first, *second, *third, *fourth);
DrawPath(this, spline.GetPath(), spline.GetDirectionPath(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, spline.GetPath(), spline.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
} }
} }
} }
@ -135,18 +136,3 @@ void VisToolCubicBezier::setObject4Id(const quint32 &value)
{ {
object4Id = value; object4Id = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolCubicBezier::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point1, scale);
ScalePoint(point2, scale);
ScalePoint(point3, scale);
ScalePoint(point4, scale);
ScalePenWidth(helpLine1, scale);
ScalePenWidth(helpLine2, scale);
VisPath::paint(painter, option, widget);
}

View File

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

View File

@ -41,6 +41,7 @@
#include "../vgeometry/vspline.h" #include "../vgeometry/vspline.h"
#include "../visualization.h" #include "../visualization.h"
#include "vispath.h" #include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent) VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent)
@ -53,8 +54,8 @@ VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphics
helpLine1(nullptr), helpLine1(nullptr),
helpLine2(nullptr) helpLine2(nullptr)
{ {
helpLine1 = InitItem<QGraphicsLineItem>(mainColor, this); helpLine1 = InitItem<VScaledLine>(mainColor, this);
helpLine2 = InitItem<QGraphicsLineItem>(mainColor, this); helpLine2 = InitItem<VScaledLine>(mainColor, this);
newCurveSegment = InitItem<VCurvePathItem>(mainColor, this); newCurveSegment = InitItem<VCurvePathItem>(mainColor, this);
} }
@ -77,7 +78,7 @@ void VisToolCubicBezierPath::RefreshGeometry()
for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
{ {
QGraphicsEllipseItem *point = this->getPoint(mainPoints, static_cast<unsigned>(i), 1/*zValue*/); VScaledEllipse *point = this->getPoint(mainPoints, static_cast<unsigned>(i), 1/*zValue*/);
DrawPoint(point, static_cast<QPointF>(pathPoints.at(i)), supportColor); DrawPoint(point, static_cast<QPointF>(pathPoints.at(i)), supportColor);
} }
@ -96,8 +97,7 @@ void VisToolCubicBezierPath::RefreshGeometry()
if (countSubSpl >= 1) if (countSubSpl >= 1)
{ {
DrawPath(this, path.GetPath(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, path.GetPath(), path.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
DrawPath(this, path.GetDirectionPath(), mainColor, Qt::SolidLine, Qt::RoundCap);
for (qint32 i = 1; i<=countSubSpl; ++i) for (qint32 i = 1; i<=countSubSpl; ++i)
{ {
@ -106,18 +106,18 @@ void VisToolCubicBezierPath::RefreshGeometry()
const VSpline spl = path.GetSpline(i); const VSpline spl = path.GetSpline(i);
QGraphicsLineItem *ctrlLine1 = this->getLine(static_cast<unsigned>(preLastPoint)); VScaledLine *ctrlLine1 = this->getLine(static_cast<unsigned>(preLastPoint));
DrawLine(ctrlLine1, QLineF(static_cast<QPointF>(spl.GetP1()), static_cast<QPointF>(spl.GetP2())), DrawLine(ctrlLine1, QLineF(static_cast<QPointF>(spl.GetP1()), static_cast<QPointF>(spl.GetP2())),
mainColor, Qt::DashLine); mainColor, Qt::DashLine);
QGraphicsEllipseItem *p2 = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint)); VScaledEllipse *p2 = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
DrawPoint(p2, static_cast<QPointF>(spl.GetP2()), Qt::green); DrawPoint(p2, static_cast<QPointF>(spl.GetP2()), Qt::green);
QGraphicsLineItem *ctrlLine2 = this->getLine(static_cast<unsigned>(lastPoint)); VScaledLine *ctrlLine2 = this->getLine(static_cast<unsigned>(lastPoint));
DrawLine(ctrlLine2, QLineF(static_cast<QPointF>(spl.GetP4()), static_cast<QPointF>(spl.GetP3())), DrawLine(ctrlLine2, QLineF(static_cast<QPointF>(spl.GetP4()), static_cast<QPointF>(spl.GetP3())),
mainColor, Qt::DashLine); mainColor, Qt::DashLine);
QGraphicsEllipseItem *p3 = this->getPoint(ctrlPoints, static_cast<unsigned>(lastPoint)); VScaledEllipse *p3 = this->getPoint(ctrlPoints, static_cast<unsigned>(lastPoint));
DrawPoint(p3, static_cast<QPointF>(spl.GetP3()), Qt::green); DrawPoint(p3, static_cast<QPointF>(spl.GetP3()), Qt::green);
} }
} }
@ -142,34 +142,7 @@ VCubicBezierPath VisToolCubicBezierPath::getPath()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolCubicBezierPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) VScaledEllipse *VisToolCubicBezierPath::getPoint(QVector<VScaledEllipse *> &points, quint32 i, qreal z)
{
const qreal scale = SceneScale(scene());
for (int i=0; i < mainPoints.size(); ++i)
{
ScalePoint(mainPoints[i], scale);
}
for (int i=0; i < ctrlPoints.size(); ++i)
{
ScalePoint(ctrlPoints[i], scale);
}
for (int i=0; i < lines.size(); ++i)
{
ScalePenWidth(lines[i], scale);
}
ScalePenWidth(newCurveSegment, scale);
ScalePenWidth(helpLine1, scale);
ScalePenWidth(helpLine2, scale);
VisPath::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *VisToolCubicBezierPath::getPoint(QVector<QGraphicsEllipseItem *> &points, quint32 i, qreal z)
{ {
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i) if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
{ {
@ -184,7 +157,7 @@ QGraphicsEllipseItem *VisToolCubicBezierPath::getPoint(QVector<QGraphicsEllipseI
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGraphicsLineItem *VisToolCubicBezierPath::getLine(quint32 i) VScaledLine *VisToolCubicBezierPath::getLine(quint32 i)
{ {
if (static_cast<quint32>(lines.size() - 1) >= i && lines.isEmpty() == false) if (static_cast<quint32>(lines.size() - 1) >= i && lines.isEmpty() == false)
{ {
@ -192,7 +165,7 @@ QGraphicsLineItem *VisToolCubicBezierPath::getLine(quint32 i)
} }
else else
{ {
auto line = InitItem<QGraphicsLineItem>(mainColor, this); auto line = InitItem<VScaledLine>(mainColor, this);
lines.append(line); lines.append(line);
return line; return line;
} }
@ -229,12 +202,12 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
const QPointF p2 = p1p2.p2(); const QPointF p2 = p1p2.p2();
VSpline spline(p1, p2, Visualization::scenePos, VPointF(Visualization::scenePos)); VSpline spline(p1, p2, Visualization::scenePos, VPointF(Visualization::scenePos));
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap); DrawPath(newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap);
DrawLine(helpLine1, p1p2, mainColor, Qt::DashLine); DrawLine(helpLine1, p1p2, mainColor, Qt::DashLine);
const int preLastPoint = subSplCount * 2; const int preLastPoint = subSplCount * 2;
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint)); VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
DrawPoint(p2Ctrl, p2, Qt::green); DrawPoint(p2Ctrl, p2, Qt::green);
} }
else else
@ -260,10 +233,10 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
DrawLine(helpLine1, QLineF(static_cast<QPointF>(p1), p2), mainColor, Qt::DashLine); DrawLine(helpLine1, QLineF(static_cast<QPointF>(p1), p2), mainColor, Qt::DashLine);
VSpline spline(p1, p2, Visualization::scenePos, VPointF(Visualization::scenePos)); VSpline spline(p1, p2, Visualization::scenePos, VPointF(Visualization::scenePos));
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap); DrawPath(newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap);
const int preLastPoint = subSplCount * 2; const int preLastPoint = subSplCount * 2;
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint)); VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
DrawPoint(p2Ctrl, p2, Qt::green); DrawPoint(p2Ctrl, p2, Qt::green);
break; break;
} }
@ -286,10 +259,10 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
DrawLine(helpLine2, QLineF(p3, Visualization::scenePos), mainColor, Qt::DashLine); DrawLine(helpLine2, QLineF(p3, Visualization::scenePos), mainColor, Qt::DashLine);
VSpline spline(p1, p2, p3, VPointF(Visualization::scenePos)); VSpline spline(p1, p2, p3, VPointF(Visualization::scenePos));
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap); DrawPath(newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap);
const int preLastPoint = subSplCount * 2; const int preLastPoint = subSplCount * 2;
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint)); VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
DrawPoint(p2Ctrl, p2, Qt::green); DrawPoint(p2Ctrl, p2, Qt::green);
break; break;
} }

View File

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

View File

@ -42,6 +42,7 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../visualization.h" #include "../visualization.h"
#include "vispath.h" #include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent) VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
@ -63,7 +64,7 @@ void VisToolCutArc::RefreshGeometry()
if (object1Id > NULL_ID) if (object1Id > NULL_ID)
{ {
const QSharedPointer<VArc> arc = Visualization::data->GeometricObject<VArc>(object1Id); const QSharedPointer<VArc> arc = Visualization::data->GeometricObject<VArc>(object1Id);
DrawPath(this, arc->GetPath(), arc->GetDirectionPath(), supportColor, lineStyle, Qt::RoundCap); DrawPath(this, arc->GetPath(), arc->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap);
if (not qFuzzyIsNull(length)) if (not qFuzzyIsNull(length))
{ {
@ -72,8 +73,8 @@ void VisToolCutArc::RefreshGeometry()
QPointF p = arc->CutArc(length, ar1, ar2); QPointF p = arc->CutArc(length, ar1, ar2);
DrawPoint(point, p, mainColor); DrawPoint(point, p, mainColor);
DrawPath(arc1, ar1.GetPath(), ar1.GetDirectionPath(), Qt::darkGreen, lineStyle, Qt::RoundCap); DrawPath(arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
DrawPath(arc2, ar2.GetPath(), ar2.GetDirectionPath(), Qt::darkRed, lineStyle, Qt::RoundCap); DrawPath(arc2, ar2.GetPath(), ar2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
} }
} }
} }
@ -83,15 +84,3 @@ void VisToolCutArc::setLength(const QString &expression)
{ {
length = FindLength(expression, Visualization::data->PlainVariables()); length = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePenWidth(arc1, scale);
ScalePenWidth(arc2, scale);
VisPath::paint(painter, option, widget);
}

View File

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

View File

@ -44,6 +44,7 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../visualization.h" #include "../visualization.h"
#include "vispath.h" #include "vispath.h"
#include "../vwidgets/scalesceneitems.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent) VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent)
@ -65,7 +66,7 @@ void VisToolCutSpline::RefreshGeometry()
if (object1Id > NULL_ID) if (object1Id > NULL_ID)
{ {
const auto spl = Visualization::data->GeometricObject<VAbstractCubicBezier>(object1Id); const auto spl = Visualization::data->GeometricObject<VAbstractCubicBezier>(object1Id);
DrawPath(this, spl->GetPath(), spl->GetDirectionPath(), supportColor, lineStyle, Qt::RoundCap); DrawPath(this, spl->GetPath(), spl->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap);
if (not qFuzzyIsNull(length)) if (not qFuzzyIsNull(length))
{ {
@ -80,8 +81,8 @@ void VisToolCutSpline::RefreshGeometry()
DrawPoint(point, p, mainColor); DrawPoint(point, p, mainColor);
DrawPath(spl1, sp1.GetPath(), sp1.GetDirectionPath(), Qt::darkGreen, lineStyle, Qt::RoundCap); DrawPath(spl1, sp1.GetPath(), sp1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
DrawPath(spl2, sp2.GetPath(), sp2.GetDirectionPath(), Qt::darkRed, lineStyle, Qt::RoundCap); DrawPath(spl2, sp2.GetPath(), sp2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
} }
} }
} }
@ -91,15 +92,3 @@ void VisToolCutSpline::setLength(const QString &expression)
{ {
length = FindLength(expression, Visualization::data->PlainVariables()); length = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePenWidth(spl1, scale);
ScalePenWidth(spl2, scale);
VisPath::paint(painter, option, widget);
}

View File

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

View File

@ -65,7 +65,7 @@ void VisToolCutSplinePath::RefreshGeometry()
if (object1Id > NULL_ID) if (object1Id > NULL_ID)
{ {
const auto splPath = Visualization::data->GeometricObject<VAbstractCubicBezierPath>(object1Id); const auto splPath = Visualization::data->GeometricObject<VAbstractCubicBezierPath>(object1Id);
DrawPath(this, splPath->GetPath(), splPath->GetDirectionPath(), supportColor, lineStyle, Qt::RoundCap); DrawPath(this, splPath->GetPath(), splPath->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap);
if (not qFuzzyIsNull(length)) if (not qFuzzyIsNull(length))
{ {
@ -79,8 +79,8 @@ void VisToolCutSplinePath::RefreshGeometry()
DrawPoint(point, static_cast<QPointF>(*p), mainColor); DrawPoint(point, static_cast<QPointF>(*p), mainColor);
delete p; delete p;
DrawPath(splPath1, spPath1->GetPath(), spPath1->GetDirectionPath(), Qt::darkGreen, lineStyle, Qt::RoundCap); DrawPath(splPath1, spPath1->GetPath(), spPath1->DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
DrawPath(splPath2, spPath2->GetPath(), spPath2->GetDirectionPath(), Qt::darkRed, lineStyle, Qt::RoundCap); DrawPath(splPath2, spPath2->GetPath(), spPath2->DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
delete spPath1; delete spPath1;
delete spPath2; delete spPath2;
@ -93,15 +93,3 @@ void VisToolCutSplinePath::setLength(const QString &expression)
{ {
length = FindLength(expression, Visualization::data->PlainVariables()); length = FindLength(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutSplinePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePenWidth(splPath1, scale);
ScalePenWidth(splPath2, scale);
VisPath::paint(painter, option, widget);
}

View File

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

View File

@ -57,7 +57,7 @@ void VisToolEllipticalArc::RefreshGeometry()
if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0) if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0)
{ {
VEllipticalArc elArc = VEllipticalArc(*first, radius1, radius2, f1, f2, rotationAngle); VEllipticalArc elArc = VEllipticalArc(*first, radius1, radius2, f1, f2, rotationAngle);
DrawPath(this, elArc.GetPath(), elArc.GetDirectionPath(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, elArc.GetPath(), elArc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
} }
} }
} }
@ -91,13 +91,3 @@ void VisToolEllipticalArc::setRotationAngle(const QString &expression)
{ {
rotationAngle = FindVal(expression, Visualization::data->PlainVariables()); rotationAngle = FindVal(expression, Visualization::data->PlainVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(arcCenter, scale);
VisPath::paint(painter, option, widget);
}

View File

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

View File

@ -29,6 +29,7 @@
#include "vistoolpiece.h" #include "vistoolpiece.h"
#include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/vpiecepath.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vwidgets/scalesceneitems.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent) VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
@ -38,8 +39,8 @@ VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
m_line2(nullptr), m_line2(nullptr),
m_piece() m_piece()
{ {
m_line1 = InitItem<QGraphicsLineItem>(supportColor, this); m_line1 = InitItem<VScaledLine>(supportColor, this);
m_line2 = InitItem<QGraphicsLineItem>(supportColor, this); m_line2 = InitItem<VScaledLine>(supportColor, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -55,7 +56,7 @@ void VisToolPiece::RefreshGeometry()
for (int i = 0; i < nodes.size(); ++i) for (int i = 0; i < nodes.size(); ++i)
{ {
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(i), supportColor); VScaledEllipse *point = GetPoint(static_cast<quint32>(i), supportColor);
DrawPoint(point, nodes.at(i).toQPointF(), supportColor); DrawPoint(point, nodes.at(i).toQPointF(), supportColor);
} }
@ -79,23 +80,7 @@ void VisToolPiece::SetPiece(const VPiece &piece)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolPiece::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) VScaledEllipse *VisToolPiece::GetPoint(quint32 i, const QColor &color)
{
const qreal scale = SceneScale(scene());
for (int i=0; i < m_points.size(); ++i)
{
ScalePoint(m_points[i], scale);
}
ScalePenWidth(m_line1, scale);
ScalePenWidth(m_line2, scale);
VisPath::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *VisToolPiece::GetPoint(quint32 i, const QColor &color)
{ {
return GetPointItem(m_points, i, color, this); return GetPointItem(m_points, i, color, this);
} }

View File

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

View File

@ -29,6 +29,7 @@
#include "vistoolpiecepath.h" #include "vistoolpiecepath.h"
#include "../vwidgets/vsimplepoint.h" #include "../vwidgets/vsimplepoint.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vwidgets/scalesceneitems.h"
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
@ -39,7 +40,7 @@ VisToolPiecePath::VisToolPiecePath(const VContainer *data, QGraphicsItem *parent
m_line(nullptr), m_line(nullptr),
m_path() m_path()
{ {
m_line = InitItem<QGraphicsLineItem>(supportColor, this); m_line = InitItem<VScaledLine>(supportColor, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -78,21 +79,6 @@ void VisToolPiecePath::SetPath(const VPiecePath &path)
m_path = path; m_path = path;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPiecePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
for (int i=0; i < m_points.size(); ++i)
{
ScalePoint(m_points[i], scale);
}
ScalePenWidth(m_line, scale);
VisPath::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolPiecePath::mousePressEvent(QGraphicsSceneMouseEvent *event) void VisToolPiecePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {

View File

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

View File

@ -63,12 +63,13 @@ void VisToolPointOfIntersectionCurves::RefreshGeometry()
if (object1Id > NULL_ID) if (object1Id > NULL_ID)
{ {
auto curve1 = Visualization::data->GeometricObject<VAbstractCurve>(object1Id); auto curve1 = Visualization::data->GeometricObject<VAbstractCurve>(object1Id);
DrawPath(this, curve1->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); DrawPath(this, curve1->GetPath(), curve1->DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap);
if (object2Id > NULL_ID) if (object2Id > NULL_ID)
{ {
auto curve2 = Visualization::data->GeometricObject<VAbstractCurve>(object2Id); auto curve2 = Visualization::data->GeometricObject<VAbstractCurve>(object2Id);
DrawPath(visCurve2, curve2->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); DrawPath(visCurve2, curve2->GetPath(), curve2->DirectionArrows(), supportColor, Qt::SolidLine,
Qt::RoundCap);
auto p = VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(), vCrossPoint, auto p = VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(), vCrossPoint,
hCrossPoint); hCrossPoint);
@ -107,14 +108,3 @@ void VisToolPointOfIntersectionCurves::setHCrossPoint(const HCrossCurvesPoint &v
{ {
hCrossPoint = value; hCrossPoint = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionCurves::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePenWidth(visCurve2, scale);
VisPath::paint(painter, option, widget);
}

View File

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

View File

@ -122,7 +122,7 @@ void VisToolSpline::RefreshGeometry()
if (object4Id <= NULL_ID) if (object4Id <= NULL_ID)
{ {
VSpline spline(*first, p2, Visualization::scenePos, VPointF(Visualization::scenePos)); VSpline spline(*first, p2, Visualization::scenePos, VPointF(Visualization::scenePos));
DrawPath(this, spline.GetPath(PathDirection::Hide), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap);
} }
else else
{ {
@ -160,12 +160,12 @@ void VisToolSpline::RefreshGeometry()
if (VFuzzyComparePossibleNulls(angle1, EMPTY_ANGLE) || VFuzzyComparePossibleNulls(angle2, EMPTY_ANGLE)) if (VFuzzyComparePossibleNulls(angle1, EMPTY_ANGLE) || VFuzzyComparePossibleNulls(angle2, EMPTY_ANGLE))
{ {
VSpline spline(*first, p2, p3, *second); VSpline spline(*first, p2, p3, *second);
DrawPath(this, spline.GetPath(PathDirection::Hide), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap);
} }
else else
{ {
VSpline spline(*first, *second, angle1, angle2, kAsm1, kAsm2, kCurve); VSpline spline(*first, *second, angle1, angle2, kAsm1, kAsm2, kCurve);
DrawPath(this, spline.GetPath(), spline.GetDirectionPath(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, spline.GetPath(), spline.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
Visualization::toolTip = tr("Use <b>Shift</b> for sticking angle!"); Visualization::toolTip = tr("Use <b>Shift</b> for sticking angle!");
emit ToolTip(Visualization::toolTip); emit ToolTip(Visualization::toolTip);
} }
@ -221,17 +221,6 @@ QPointF VisToolSpline::GetP3() const
return p3; return p3;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point1, scale);
ScalePoint(point4, scale);
VisPath::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolSpline::MouseLeftPressed() void VisToolSpline::MouseLeftPressed()
{ {

View File

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

View File

@ -48,10 +48,10 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *parent) VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *parent)
: VisPath(data, parent), : VisPath(data, parent),
points(QVector<QGraphicsEllipseItem *>()), points(),
ctrlPoints(QVector<VControlPointSpline *>()), ctrlPoints(),
newCurveSegment(nullptr), newCurveSegment(nullptr),
path(VSplinePath()), path(),
isLeftMousePressed(false), isLeftMousePressed(false),
pointSelected(false), pointSelected(false),
ctrlPoint() ctrlPoint()
@ -62,8 +62,6 @@ VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *pare
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolSplinePath::~VisToolSplinePath() VisToolSplinePath::~VisToolSplinePath()
{ {
qDeleteAll(ctrlPoints);
qDeleteAll(points);
emit ToolTip(""); emit ToolTip("");
} }
@ -77,7 +75,7 @@ void VisToolSplinePath::RefreshGeometry()
for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
{ {
QGraphicsEllipseItem *point = this->getPoint(static_cast<unsigned>(i)); VScaledEllipse *point = this->getPoint(static_cast<unsigned>(i));
DrawPoint(point, static_cast<QPointF>(pathPoints.at(i).P()), supportColor); DrawPoint(point, static_cast<QPointF>(pathPoints.at(i).P()), supportColor);
} }
@ -106,7 +104,7 @@ void VisToolSplinePath::RefreshGeometry()
if (size > 1) if (size > 1)
{ {
DrawPath(this, path.GetPath(), path.GetDirectionPath(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, path.GetPath(), path.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
} }
if (path.CountPoints() < 3) if (path.CountPoints() < 3)
@ -139,19 +137,6 @@ VSplinePath VisToolSplinePath::getPath()
return path; return path;
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolSplinePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
for (int i=0; i < points.size(); ++i)
{
ScalePoint(points[i], scale);
}
VisPath::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolSplinePath::MouseLeftPressed() void VisToolSplinePath::MouseLeftPressed()
{ {
@ -172,7 +157,7 @@ void VisToolSplinePath::MouseLeftReleased()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *VisToolSplinePath::getPoint(quint32 i) VScaledEllipse *VisToolSplinePath::getPoint(quint32 i)
{ {
if (static_cast<quint32>(points.size() - 1) >= i && points.isEmpty() == false) if (static_cast<quint32>(points.size() - 1) >= i && points.isEmpty() == false)
{ {
@ -311,6 +296,6 @@ void VisToolSplinePath::Creating(const QPointF &pSpl, int size)
} }
emit PathChanged(path); emit PathChanged(path);
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap); DrawPath(newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap);
} }
} }

View File

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

View File

@ -53,6 +53,7 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
#include "../vwidgets/vcurvepathitem.h" #include "../vwidgets/vcurvepathitem.h"
#include "../vwidgets/scalesceneitems.h"
template <class K, class V> class QHash; template <class K, class V> class QHash;
@ -136,14 +137,7 @@ void Visualization::MousePos(const QPointF &scenePos)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void Visualization::ScalePoint(QGraphicsEllipseItem *item, qreal scale) VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const
{
ScaleCircleSize(item, scale);
ScalePenWidth(item, scale);
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const
{ {
return InitPointItem(color, parent, z); return InitPointItem(color, parent, z);
} }
@ -192,7 +186,7 @@ qreal Visualization::FindVal(const QString &expression, const QHash<QString, qre
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style) void Visualization::DrawPoint(VScaledEllipse *point, const QPointF &pos, const QColor &color, Qt::PenStyle style)
{ {
SCASSERT (point != nullptr) SCASSERT (point != nullptr)
@ -207,7 +201,7 @@ void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, c
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void Visualization::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style) void Visualization::DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style)
{ {
SCASSERT (lineItem != nullptr) SCASSERT (lineItem != nullptr)
@ -224,12 +218,13 @@ void Visualization::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, co
void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color, void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color,
Qt::PenStyle style, Qt::PenCapStyle cap) Qt::PenStyle style, Qt::PenCapStyle cap)
{ {
DrawPath(pathItem, path, QPainterPath(), color, style, cap); DrawPath(pathItem, path, QVector<DirectionArrow>(), color, style, cap);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QPainterPath &direction, void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path,
const QColor &color, Qt::PenStyle style, Qt::PenCapStyle cap) const QVector<DirectionArrow> &directionArrows, const QColor &color, Qt::PenStyle style,
Qt::PenCapStyle cap)
{ {
SCASSERT (pathItem != nullptr) SCASSERT (pathItem != nullptr)
@ -240,13 +235,13 @@ void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path,
pathItem->setPen(visPen); pathItem->setPen(visPen);
pathItem->setPath(path); pathItem->setPath(path);
pathItem->SetDirectionPath(direction); pathItem->SetDirectionArrows(directionArrows);
pathItem->setVisible(true); pathItem->setVisible(true);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *Visualization::GetPointItem(QVector<QGraphicsEllipseItem *> &points, quint32 i, VScaledEllipse *Visualization::GetPointItem(QVector<VScaledEllipse *> &points, quint32 i,
const QColor &color, QGraphicsItem *parent) const QColor &color, QGraphicsItem *parent)
{ {
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i) if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
{ {
@ -262,9 +257,9 @@ QGraphicsEllipseItem *Visualization::GetPointItem(QVector<QGraphicsEllipseItem *
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *Visualization::InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z) VScaledEllipse *Visualization::InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z)
{ {
QGraphicsEllipseItem *point = new QGraphicsEllipseItem(parent); VScaledEllipse *point = new VScaledEllipse(parent);
point->setZValue(1); point->setZValue(1);
point->setBrush(QBrush(Qt::NoBrush)); point->setBrush(QBrush(Qt::NoBrush));

View File

@ -44,6 +44,9 @@
Q_DECLARE_LOGGING_CATEGORY(vVis) Q_DECLARE_LOGGING_CATEGORY(vVis)
class VScaledEllipse;
class VScaledLine;
enum class Mode : char {Creation, Show}; enum class Mode : char {Creation, Show};
class Visualization : public QObject class Visualization : public QObject
@ -86,20 +89,16 @@ protected:
virtual void InitPen()=0; virtual void InitPen()=0;
virtual void AddOnScene()=0; virtual void AddOnScene()=0;
template <typename Item> VScaledEllipse *InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) const;
void ScalePenWidth(Item *item, qreal scale); void DrawPoint(VScaledEllipse *point, const QPointF &pos, const QColor &color,
void ScalePoint(QGraphicsEllipseItem *item, qreal scale);
QGraphicsEllipseItem *InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) const;
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color,
Qt::PenStyle style = Qt::SolidLine); Qt::PenStyle style = Qt::SolidLine);
virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color,
Qt::PenStyle style = Qt::SolidLine); Qt::PenStyle style = Qt::SolidLine);
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color, void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color,
Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap); Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap);
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QPainterPath &direction, void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path,
const QColor &color, Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap); const QVector<DirectionArrow> &directionArrows, const QColor &color,
Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap);
template <typename Item> template <typename Item>
void AddItem(Item *item); void AddItem(Item *item);
@ -107,12 +106,12 @@ protected:
template <class Item> template <class Item>
Item *InitItem(const QColor &color, QGraphicsItem *parent); Item *InitItem(const QColor &color, QGraphicsItem *parent);
static QGraphicsEllipseItem* GetPointItem(QVector<QGraphicsEllipseItem *> &points, quint32 i, const QColor &color, static VScaledEllipse *GetPointItem(QVector<VScaledEllipse *> &points, quint32 i, const QColor &color,
QGraphicsItem *parent); QGraphicsItem *parent);
private: private:
Q_DISABLE_COPY(Visualization) Q_DISABLE_COPY(Visualization)
static QGraphicsEllipseItem* InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0); static VScaledEllipse* InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0);
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -143,18 +142,4 @@ inline Item *Visualization::InitItem(const QColor &color, QGraphicsItem *parent)
return item; return item;
} }
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void Visualization::ScalePenWidth(Item *item, qreal scale)
{
SCASSERT(item != nullptr)
const qreal width = ScaleWidth(widthMainLine, scale);
QPen visPen = item->pen();
visPen.setWidthF(width);
item->setPen(visPen);
}
#endif // VISUALIZATION_H #endif // VISUALIZATION_H

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 "vmaingraphicsscene.h"
#include "vmaingraphicsview.h" #include "vmaingraphicsview.h"
#include "vgraphicssimpletextitem.h" #include "vgraphicssimpletextitem.h"
#include "scalesceneitems.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem *parent) VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem *parent)
@ -100,21 +101,13 @@ VControlPointSpline::~VControlPointSpline()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
const qreal scale = SceneScale(scene()); QPen lPen = controlLine->pen();
lPen.setColor(CorrectColor(controlLine, Qt::black));
ScaleLinePenWidth(controlLine, scale); controlLine->setPen(lPen);
VScenePoint::paint(painter, option, widget); VScenePoint::paint(painter, option, widget);
} }
//---------------------------------------------------------------------------------------------------------------------
QRectF VControlPointSpline::boundingRect() const
{
QRectF recTool = VScenePoint::boundingRect();
recTool = recTool.united(childrenBoundingRect());
return recTool;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief hoverEnterEvent handle hover enter events. * @brief hoverEnterEvent handle hover enter events.
@ -267,12 +260,8 @@ void VControlPointSpline::Init()
this->setBrush(QBrush(Qt::NoBrush)); this->setBrush(QBrush(Qt::NoBrush));
this->setZValue(100); this->setZValue(100);
controlLine = new QGraphicsLineItem(this); controlLine = new VScaledLine(this);
controlLine->SetBasicWidth(widthHairLine);
QPen cPen = controlLine->pen();
cPen.setBrush(QBrush(Qt::red));
controlLine->setPen(cPen);
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
} }

View File

@ -55,12 +55,11 @@ public:
const QPointF &splinePoint, bool freeAngle, bool freeLength, QGraphicsItem * parent = nullptr); const QPointF &splinePoint, bool freeAngle, bool freeLength, QGraphicsItem * parent = nullptr);
virtual ~VControlPointSpline(); virtual ~VControlPointSpline();
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ControlPointSpline)}; enum { Type = UserType + static_cast<int>(Vis::ControlPointSpline)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE; QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
signals: signals:
/** /**
* @brief ControlPointChangePosition emit when control point change position. * @brief ControlPointChangePosition emit when control point change position.
@ -81,7 +80,7 @@ public slots:
void setEnabledPoint(bool enable); void setEnabledPoint(bool enable);
protected: protected:
/** @brief controlLine pointer to line control point. */ /** @brief controlLine pointer to line control point. */
QGraphicsLineItem *controlLine; VScaledLine *controlLine;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;

View File

@ -27,20 +27,68 @@
*************************************************************************/ *************************************************************************/
#include "vcurvepathitem.h" #include "vcurvepathitem.h"
#include "../vwidgets/global.h"
#include "../vgeometry/vabstractcurve.h"
#include <QPainter> #include <QPainter>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCurvePathItem::VCurvePathItem(QGraphicsItem *parent) VCurvePathItem::VCurvePathItem(QGraphicsItem *parent)
: QGraphicsPathItem(parent), : QGraphicsPathItem(parent),
m_direction() m_directionArrows()
{ {
} }
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VCurvePathItem::shape() const
{
QPainterPath itemPath = path();
const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows,
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow,
SceneScale(scene())));
if (arrowsPath != QPainterPath())
{
itemPath.addPath(arrowsPath);
itemPath.setFillRule(Qt::WindingFill);
}
// We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
// if we pass a value of 0.0 to QPainterPathStroker::setWidth()
const qreal penWidthZero = qreal(0.00000001);
if (itemPath == QPainterPath() || pen() == Qt::NoPen)
{
return itemPath;
}
QPainterPathStroker ps;
ps.setCapStyle(pen().capStyle());
if (pen().widthF() <= 0.0)
{
ps.setWidth(penWidthZero);
}
else
{
ps.setWidth(pen().widthF());
}
ps.setJoinStyle(pen().joinStyle());
ps.setMiterLimit(pen().miterLimit());
QPainterPath p = ps.createStroke(itemPath);
p.addPath(itemPath);
return p;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
if (m_direction != QPainterPath()) ScalePenWidth();
const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows,
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow,
SceneScale(scene())));
if (arrowsPath != QPainterPath())
{ {
painter->save(); painter->save();
@ -49,7 +97,7 @@ void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
painter->setPen(arrowPen); painter->setPen(arrowPen);
painter->setBrush(brush()); painter->setBrush(brush());
painter->drawPath(m_direction); painter->drawPath(arrowsPath);
painter->restore(); painter->restore();
} }
@ -58,7 +106,18 @@ void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VCurvePathItem::SetDirectionPath(const QPainterPath &path) void VCurvePathItem::SetDirectionArrows(const QVector<QPair<QLineF, QLineF> > &arrows)
{ {
m_direction = path; m_directionArrows = arrows;
}
//---------------------------------------------------------------------------------------------------------------------
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: public:
explicit VCurvePathItem(QGraphicsItem *parent = nullptr); explicit VCurvePathItem(QGraphicsItem *parent = nullptr);
virtual ~VCurvePathItem() = default;
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE; QWidget *widget = nullptr) Q_DECL_OVERRIDE;
@ -45,11 +48,13 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::CurvePathItem)}; enum { Type = UserType + static_cast<int>(Vis::CurvePathItem)};
void SetDirectionPath(const QPainterPath &path); void SetDirectionArrows(const QVector<QPair<QLineF, QLineF>> &arrows);
protected:
virtual void ScalePenWidth();
private: private:
Q_DISABLE_COPY(VCurvePathItem) Q_DISABLE_COPY(VCurvePathItem)
QPainterPath m_direction; QVector<QPair<QLineF, QLineF>> m_directionArrows;
}; };
#endif // VCURVEPATHITEM_H #endif // VCURVEPATHITEM_H

View File

@ -31,6 +31,7 @@
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "global.h" #include "global.h"
#include "vgraphicssimpletextitem.h" #include "vgraphicssimpletextitem.h"
#include "scalesceneitems.h"
#include <QBrush> #include <QBrush>
#include <QFont> #include <QFont>
@ -46,7 +47,11 @@ VScenePoint::VScenePoint(QGraphicsItem *parent)
m_baseColor(Qt::black) m_baseColor(Qt::black)
{ {
m_namePoint = new VGraphicsSimpleTextItem(this); m_namePoint = new VGraphicsSimpleTextItem(this);
m_lineName = new QGraphicsLineItem(this); m_lineName = new VScaledLine(this);
m_lineName->SetBasicWidth(widthHairLine);
m_lineName->setLine(QLineF(0, 0, 1, 0));
m_lineName->setVisible(false);
this->setBrush(QBrush(Qt::NoBrush)); this->setBrush(QBrush(Qt::NoBrush));
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
@ -70,9 +75,10 @@ void VScenePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
if (not m_onlyPoint) if (not m_onlyPoint)
{ {
m_namePoint->setVisible(true); 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(); RefreshLine();
} }
@ -96,14 +102,6 @@ void VScenePoint::RefreshPointGeometry(const VPointF &point)
RefreshLine(); RefreshLine();
} }
//---------------------------------------------------------------------------------------------------------------------
QRectF VScenePoint::boundingRect() const
{
QRectF recTool = QGraphicsEllipseItem::boundingRect();
recTool = recTool.united(childrenBoundingRect());
return recTool;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VScenePoint::SetOnlyPoint(bool value) void VScenePoint::SetOnlyPoint(bool value)
{ {
@ -145,7 +143,6 @@ void VScenePoint::RefreshLine()
VGObject::LineIntersectCircle(QPointF(), ScaledRadius(SceneScale(scene())), VGObject::LineIntersectCircle(QPointF(), ScaledRadius(SceneScale(scene())),
QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2); QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2);
const QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); const QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
m_lineName->setLine(QLineF(p1, pRec - scenePos()));
if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm)) if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm))
{ {
@ -153,6 +150,7 @@ void VScenePoint::RefreshLine()
} }
else else
{ {
m_lineName->setLine(QLineF(p1, pRec - scenePos()));
m_lineName->setVisible(true); m_lineName->setVisible(true);
} }
} }
@ -169,13 +167,3 @@ void VScenePoint::ScaleMainPenWidth(qreal scale)
setPen(QPen(CorrectColor(this, m_baseColor), width)); setPen(QPen(CorrectColor(this, m_baseColor), width));
} }
//---------------------------------------------------------------------------------------------------------------------
void VScenePoint::ScaleLinePenWidth(QGraphicsLineItem *line, qreal scale)
{
SCASSERT(line != nullptr)
const qreal width = ScaleWidth(widthHairLine, scale);
line->setPen(QPen(CorrectColor(line, Qt::black), width));
}

View File

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

View File

@ -57,30 +57,6 @@ VSimpleCurve::VSimpleCurve(quint32 id, const QSharedPointer<VAbstractCurve> &cur
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
} }
//---------------------------------------------------------------------------------------------------------------------
void VSimpleCurve::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
qreal width = 1;
if (m_isHovered)
{
width = widthMainLine;
}
else
{
width = widthHairLine;
}
const qreal scale = SceneScale(scene());
if (scale > 1)
{
width = qMax(1., width/scale);
}
setPen(QPen(CorrectColor(this, m_curve->GetColor()), width, LineStyleToPenStyle(m_curve->GetPenStyle())));
VCurvePathItem::paint(painter, option, widget);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve) void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
{ {
@ -88,7 +64,7 @@ void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
if (not m_curve.isNull()) if (not m_curve.isNull())
{ {
m_isHovered ? SetDirectionPath(m_curve->GetDirectionPath()) : SetDirectionPath(QPainterPath()); m_isHovered ? SetDirectionArrows(m_curve->DirectionArrows()) : SetDirectionArrows(QVector<DirectionArrow>());
setPath(m_curve->GetPath()); setPath(m_curve->GetPath());
} }
else else
@ -191,3 +167,20 @@ void VSimpleCurve::keyReleaseEvent(QKeyEvent *event)
} }
QGraphicsPathItem::keyReleaseEvent ( event ); QGraphicsPathItem::keyReleaseEvent ( event );
} }
//---------------------------------------------------------------------------------------------------------------------
void VSimpleCurve::ScalePenWidth()
{
qreal width = 1;
if (m_isHovered)
{
width = widthMainLine;
}
else
{
width = widthHairLine;
}
width = ScaleWidth(width, SceneScale(scene()));
setPen(QPen(CorrectColor(this, m_curve->GetColor()), width, LineStyleToPenStyle(m_curve->GetPenStyle())));
}

View File

@ -56,9 +56,6 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::SimpleCurve)}; enum { Type = UserType + static_cast<int>(Vis::SimpleCurve)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
void RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve); void RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve);
signals: signals:
/** /**
@ -80,6 +77,7 @@ protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE; virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE;
virtual void ScalePenWidth() Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VSimpleCurve) Q_DISABLE_COPY(VSimpleCurve)

Some files were not shown because too many files have changed in this diff Show More