Merge with develop.
--HG-- branch : feature
This commit is contained in:
commit
146bf98f84
|
@ -83,7 +83,7 @@ defineTest(copyToDestdir) {
|
|||
|
||||
for(FILE, files) {
|
||||
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 {
|
||||
!exists($$DDIR/$$basename(FILE)) {
|
||||
# Replace slashes in paths with backslashes for Windows
|
||||
|
@ -91,7 +91,7 @@ defineTest(copyToDestdir) {
|
|||
FILE ~= 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)
|
||||
|
@ -110,14 +110,14 @@ defineTest(forceCopyToDestdir) {
|
|||
|
||||
for(FILE, files) {
|
||||
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 {
|
||||
# Replace slashes in paths with backslashes for Windows
|
||||
win32{
|
||||
FILE ~= 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1191,8 +1191,6 @@ void MainWindow::ZoomFitBestCurrent()
|
|||
transform.setMatrix(factor, transform.m12(), transform.m13(), transform.m21(), factor, transform.m23(),
|
||||
transform.m31(), transform.m32(), transform.m33());
|
||||
ui->view->setTransform(transform);
|
||||
|
||||
VMainGraphicsView::NewSceneRect(ui->view->scene(), ui->view);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -4653,7 +4651,7 @@ void MainWindow::ZoomFirstShow()
|
|||
{
|
||||
ActionDraw(true);
|
||||
}
|
||||
ui->view->ZoomFitBest();
|
||||
ZoomFitBestCurrent();
|
||||
|
||||
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
||||
VMainGraphicsView::NewSceneRect(sceneDetails, ui->view);
|
||||
|
|
|
@ -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.
|
||||
* @return path.
|
||||
*/
|
||||
QPainterPath VAbstractCubicBezierPath::GetPath(PathDirection direction) const
|
||||
QPainterPath VAbstractCubicBezierPath::GetPath() const
|
||||
{
|
||||
QPainterPath painterPath;
|
||||
for (qint32 i = 1; i <= CountSubSpl(); ++i)
|
||||
{
|
||||
painterPath.addPath(GetSpline(i).GetPath(direction));
|
||||
painterPath.addPath(GetSpline(i).GetPath());
|
||||
}
|
||||
return painterPath;
|
||||
}
|
||||
|
@ -120,6 +109,17 @@ qreal VAbstractCubicBezierPath::GetLength() const
|
|||
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
|
||||
{
|
||||
|
|
|
@ -59,11 +59,12 @@ public:
|
|||
virtual VSpline GetSpline(qint32 index) const =0;
|
||||
virtual QVector<VSplinePoint> GetSplinePath() const =0;
|
||||
|
||||
virtual QPainterPath GetDirectionPath() const Q_DECL_OVERRIDE;
|
||||
virtual QPainterPath GetPath(PathDirection direction = PathDirection::Hide) const Q_DECL_OVERRIDE;
|
||||
virtual QPainterPath GetPath() const Q_DECL_OVERRIDE;
|
||||
virtual QVector<QPointF> GetPoints() 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;
|
||||
|
||||
QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2,
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#include "vabstractcurve_p.h"
|
||||
|
||||
const qreal VAbstractCurve::lengthCurveDirectionArrow = 14;
|
||||
|
||||
VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode)
|
||||
: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
|
||||
{
|
||||
return ShowDirection(GetPoints());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VAbstractCurve::GetPath(PathDirection direction) const
|
||||
QPainterPath VAbstractCurve::GetPath() const
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
|
@ -183,12 +179,6 @@ QPainterPath VAbstractCurve::GetPath(PathDirection direction) const
|
|||
if (points.count() >= 2)
|
||||
{
|
||||
path.addPolygon(QPolygonF(points));
|
||||
|
||||
if (direction == PathDirection::Show)
|
||||
{
|
||||
path.addPath(ShowDirection(points));
|
||||
}
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
}
|
||||
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)
|
||||
{
|
||||
/*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
|
||||
arrow = QLineF(arrow.p2(), arrow.p1());
|
||||
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);
|
||||
path.moveTo(arrow.p1());
|
||||
path.lineTo(arrow.p2());
|
||||
dArrow.first = arrow;
|
||||
|
||||
arrow.setAngle(angle+35);
|
||||
path.moveTo(arrow.p1());
|
||||
path.lineTo(arrow.p2());
|
||||
dArrow.second = arrow;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "vgeometrydef.h"
|
||||
#include "vgobject.h"
|
||||
|
||||
enum class PathDirection : char { Hide, Show };
|
||||
typedef QPair<QLineF, QLineF> DirectionArrow;
|
||||
|
||||
class QPainterPath;
|
||||
class VAbstractCurveData;
|
||||
|
@ -68,8 +68,7 @@ public:
|
|||
bool reverse = false);
|
||||
QVector<QPointF> GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse = false) const;
|
||||
|
||||
virtual QPainterPath GetDirectionPath() const;
|
||||
virtual QPainterPath GetPath(PathDirection direction = PathDirection::Hide) const;
|
||||
virtual QPainterPath GetPath() const;
|
||||
virtual qreal GetLength() const =0;
|
||||
qreal GetLengthByPoint(const QPointF &point) 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);
|
||||
|
||||
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:
|
||||
virtual void CreateName() =0;
|
||||
private:
|
||||
|
|
|
@ -165,6 +165,8 @@ enum class Vis : ToolVisHolderType
|
|||
{
|
||||
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
|
||||
GraphicsSimpleTextItem,
|
||||
ScaledLine,
|
||||
ScaledEllipse,
|
||||
SimplePoint,
|
||||
SimpleCurve,
|
||||
Line,
|
||||
|
|
|
@ -81,7 +81,9 @@ QPainterPath VAbstractSpline::shape() const
|
|||
|
||||
if (m_isHovered || detailsMode)
|
||||
{
|
||||
path.addPath(curve->GetDirectionPath());
|
||||
path.addPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(),
|
||||
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow,
|
||||
SceneScale(scene()))));
|
||||
}
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
|
||||
|
@ -131,7 +133,9 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
|||
painter->setPen(arrowPen);
|
||||
painter->setBrush(brush());
|
||||
|
||||
painter->drawPath(curve->GetDirectionPath());
|
||||
painter->drawPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(),
|
||||
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow,
|
||||
SceneScale(scene()))));
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "../../../../vabstracttool.h"
|
||||
#include "../../../vdrawtool.h"
|
||||
#include "../vtoolsinglepoint.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
|
@ -74,7 +75,8 @@ VToolLinePoint::VToolLinePoint(VAbstractPattern *doc, VContainer *data, const qu
|
|||
Q_ASSERT_X(basePointId != 0, Q_FUNC_INFO, "basePointId == 0"); //-V654 //-V712
|
||||
QPointF point1 = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
|
||||
QPointF point2 = static_cast<QPointF>(*data->GeometricObject<VPointF>(id));
|
||||
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
|
||||
mainLine = new VScaledLine(QLineF(point1 - point2, QPointF()), this);
|
||||
mainLine->SetBasicWidth(widthHairLine);
|
||||
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
}
|
||||
|
||||
|
@ -87,21 +89,15 @@ VToolLinePoint::~VToolLinePoint()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLinePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal width = ScaleWidth(m_isHovered ? widthMainLine : widthHairLine, SceneScale(scene()));
|
||||
QPen mPen = mainLine->pen();
|
||||
mPen.setColor(CorrectColor(this, lineColor));
|
||||
mPen.setStyle(LineStyleToPenStyle(m_lineType));
|
||||
|
||||
mainLine->setPen(QPen(CorrectColor(this, lineColor), width, LineStyleToPenStyle(m_lineType)));
|
||||
mainLine->setPen(mPen);
|
||||
|
||||
VToolSinglePoint::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VToolLinePoint::boundingRect() const
|
||||
{
|
||||
QRectF recTool = VToolSinglePoint::boundingRect();
|
||||
recTool = recTool.united(childrenBoundingRect());
|
||||
return recTool;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RefreshGeometry refresh item on scene.
|
||||
|
@ -133,6 +129,20 @@ void VToolLinePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
|
|||
doc->SetAttribute(tag, AttrLineColor, lineColor);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLinePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
mainLine->SetBasicWidth(widthMainLine);
|
||||
VToolSinglePoint::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLinePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
mainLine->SetBasicWidth(widthHairLine);
|
||||
VToolSinglePoint::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLinePoint::Disable(bool disable, const QString &namePP)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
||||
|
||||
VFormula GetFormulaLength() const;
|
||||
void SetFormulaLength(const VFormula &value);
|
||||
|
@ -88,7 +87,7 @@ protected:
|
|||
quint32 basePointId;
|
||||
|
||||
/** @brief mainLine line item. */
|
||||
QGraphicsLineItem *mainLine;
|
||||
VScaledLine *mainLine;
|
||||
|
||||
/** @brief lineColor color of a line. */
|
||||
QString lineColor;
|
||||
|
@ -96,6 +95,8 @@ protected:
|
|||
virtual void RefreshGeometry();
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolLinePoint)
|
||||
};
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vwidgets/vgraphicssimpletextitem.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
#include "../../../vabstracttool.h"
|
||||
#include "../../vdrawtool.h"
|
||||
#include "../vabstractpoint.h"
|
||||
|
|
|
@ -201,7 +201,7 @@ void VNodePoint::RefreshDataInFile()
|
|||
void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
// Special for not selectable item first need to call standard mousePressEvent then accept event
|
||||
QGraphicsEllipseItem::mousePressEvent(event);
|
||||
VScenePoint::mousePressEvent(event);
|
||||
|
||||
// Somehow clicking on notselectable object do not clean previous selections.
|
||||
if (not (flags() & ItemIsSelectable) && scene())
|
||||
|
@ -223,7 +223,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
emit ChoosedTool(id, SceneObject::Point);
|
||||
}
|
||||
QGraphicsEllipseItem::mouseReleaseEvent(event);
|
||||
VScenePoint::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -75,7 +75,7 @@ void VisOperation::VisualMode(const quint32 &pointId)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *VisOperation::GetPoint(quint32 i, const QColor &color)
|
||||
VScaledEllipse *VisOperation::GetPoint(quint32 i, const QColor &color)
|
||||
{
|
||||
return GetPointItem(points, i, color, this);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPoint
|
|||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||
|
||||
++iPoint;
|
||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
||||
|
||||
++iPoint;
|
||||
|
|
|
@ -50,11 +50,11 @@ protected:
|
|||
QVector<quint32> objects;
|
||||
QColor supportColor2;
|
||||
|
||||
QVector<QGraphicsEllipseItem *> points;
|
||||
QVector<VScaledEllipse *> points;
|
||||
QVector<VCurvePathItem *> curves;
|
||||
|
||||
QGraphicsEllipseItem * GetPoint(quint32 i, const QColor &color);
|
||||
VCurvePathItem * GetCurve(quint32 i, const QColor &color);
|
||||
VScaledEllipse *GetPoint(quint32 i, const QColor &color);
|
||||
VCurvePathItem *GetCurve(quint32 i, const QColor &color);
|
||||
|
||||
template <class Item>
|
||||
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;
|
||||
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;
|
||||
path = GetCurve(static_cast<quint32>(i), supportColor);
|
||||
if (object1Id != NULL_ID)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -80,13 +80,3 @@ void VisToolFlippingByAxis::SetAxisType(AxisType value)
|
|||
{
|
||||
m_axisType = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolFlippingByAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point1, scale);
|
||||
|
||||
VisOperation::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -48,15 +48,12 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByAxis)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolFlippingByAxis)
|
||||
|
||||
AxisType m_axisType;
|
||||
|
||||
QGraphicsEllipseItem *point1;
|
||||
VScaledEllipse *point1;
|
||||
};
|
||||
|
||||
#endif // VISTOOLFLIPPINGBYAXIS_H
|
||||
|
|
|
@ -72,17 +72,6 @@ void VisToolFlippingByLine::RefreshGeometry()
|
|||
RefreshFlippedObjects(firstPoint, secondPoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolFlippingByLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point1, scale);
|
||||
ScalePoint(point2, scale);
|
||||
|
||||
VisOperation::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolFlippingByLine::SetFirstLinePointId(quint32 value)
|
||||
{
|
||||
|
|
|
@ -41,8 +41,6 @@ public:
|
|||
virtual ~VisToolFlippingByLine() = default;
|
||||
|
||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
|
||||
void SetFirstLinePointId(quint32 value);
|
||||
void SetSecondLinePointId(quint32 value);
|
||||
|
@ -52,8 +50,8 @@ public:
|
|||
private:
|
||||
Q_DISABLE_COPY(VisToolFlippingByLine)
|
||||
quint32 object2Id;
|
||||
QGraphicsEllipseItem *point1;
|
||||
QGraphicsEllipseItem *point2;
|
||||
VScaledEllipse *point1;
|
||||
VScaledEllipse *point2;
|
||||
};
|
||||
|
||||
#endif // VISTOOLFLIPPINGBYLINE_H
|
||||
|
|
|
@ -128,17 +128,6 @@ void VisToolMove::RefreshGeometry()
|
|||
CreateMovedObjects(iPoint, iCurve, tempLength, tempAngle);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolMove::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(pointOrigin, scale);
|
||||
ScalePoint(pointFinish, scale);
|
||||
|
||||
VisOperation::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VisToolMove::Angle() const
|
||||
{
|
||||
|
@ -177,7 +166,7 @@ QGraphicsPathItem *VisToolMove::AddOriginCurve(quint32 id, int &i)
|
|||
|
||||
++i;
|
||||
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;
|
||||
}
|
||||
|
@ -191,7 +180,7 @@ int VisToolMove::AddMovedCurve(qreal angle, qreal length, quint32 id, int i)
|
|||
++i;
|
||||
VCurvePathItem *path = GetCurve(static_cast<quint32>(i), supportColor);
|
||||
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;
|
||||
}
|
||||
|
@ -244,7 +233,7 @@ QVector<QGraphicsItem *> VisToolMove::CreateOriginObjects(int &iPoint, int &iCur
|
|||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||
|
||||
++iPoint;
|
||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
||||
originObjects.append(point);
|
||||
|
||||
|
@ -299,7 +288,7 @@ void VisToolMove::CreateMovedObjects(int &iPoint, int &iCurve, qreal length, qre
|
|||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||
|
||||
++iPoint;
|
||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor);
|
||||
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor);
|
||||
DrawPoint(point, static_cast<QPointF>(p->Move(length, angle)), supportColor);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -51,8 +51,6 @@ public:
|
|||
virtual ~VisToolMove();
|
||||
|
||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
|
||||
QString Angle() const;
|
||||
void SetAngle(const QString &expression);
|
||||
|
@ -67,8 +65,8 @@ private:
|
|||
Q_DISABLE_COPY(VisToolMove)
|
||||
qreal angle;
|
||||
qreal length;
|
||||
QGraphicsEllipseItem *pointOrigin;
|
||||
QGraphicsEllipseItem *pointFinish;
|
||||
VScaledEllipse *pointOrigin;
|
||||
VScaledEllipse *pointFinish;
|
||||
|
||||
template <class Item>
|
||||
QGraphicsPathItem *AddOriginCurve(quint32 id, int &i);
|
||||
|
|
|
@ -65,7 +65,7 @@ VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
|
|||
{
|
||||
point = InitPoint(supportColor2, this);
|
||||
angleArc = InitItem<VCurvePathItem>(supportColor2, this);
|
||||
xAxis = InitItem<QGraphicsLineItem>(supportColor2, this);
|
||||
xAxis = InitItem<VScaledLine>(supportColor2, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -117,7 +117,7 @@ void VisToolRotation::RefreshGeometry()
|
|||
Qt::DashLine);
|
||||
|
||||
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, "
|
||||
"<b>Mouse click</b> - finish creation").arg(tempAngle);
|
||||
|
@ -140,7 +140,7 @@ void VisToolRotation::RefreshGeometry()
|
|||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||
|
||||
++iPoint;
|
||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||
VScaledEllipse *point = GetPoint(static_cast<quint32>(iPoint), supportColor2);
|
||||
DrawPoint(point, static_cast<QPointF>(*p), supportColor2);
|
||||
|
||||
++iPoint;
|
||||
|
@ -190,18 +190,6 @@ void VisToolRotation::RefreshGeometry()
|
|||
}
|
||||
QT_WARNING_POP
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolRotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePenWidth(angleArc, scale);
|
||||
ScalePenWidth(xAxis, scale);
|
||||
|
||||
VisOperation::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolRotation::SetOriginPointId(quint32 value)
|
||||
{
|
||||
|
@ -228,14 +216,14 @@ int VisToolRotation::AddCurve(qreal angle, const QPointF &origin, quint32 id, in
|
|||
|
||||
++i;
|
||||
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;
|
||||
path = GetCurve(static_cast<quint32>(i), supportColor);
|
||||
if (object1Id != NULL_ID)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -51,8 +51,6 @@ public:
|
|||
virtual ~VisToolRotation();
|
||||
|
||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
|
||||
void SetOriginPointId(quint32 value);
|
||||
|
||||
|
@ -64,9 +62,9 @@ public:
|
|||
private:
|
||||
Q_DISABLE_COPY(VisToolRotation)
|
||||
qreal angle;
|
||||
QGraphicsEllipseItem *point;
|
||||
VScaledEllipse *point;
|
||||
VCurvePathItem *angleArc;
|
||||
QGraphicsLineItem *xAxis;
|
||||
VScaledLine *xAxis;
|
||||
|
||||
template <class Item>
|
||||
int AddCurve(qreal angle, const QPointF &origin, quint32 id, int i);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisLine::VisLine(const VContainer *data, QGraphicsItem *parent)
|
||||
:Visualization(data), QGraphicsLineItem(parent)
|
||||
:Visualization(data), VScaledLine(parent)
|
||||
{
|
||||
this->setZValue(1);// Show on top real tool
|
||||
InitPen();
|
||||
|
@ -78,22 +78,6 @@ qreal VisLine::CorrectAngle(const qreal &angle)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
ScalePenWidth(this, SceneScale(scene()));
|
||||
|
||||
QGraphicsLineItem::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VisLine::boundingRect() const
|
||||
{
|
||||
QRectF recTool = QGraphicsLineItem::boundingRect();
|
||||
recTool = recTool.united(childrenBoundingRect());
|
||||
return recTool;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
|
||||
{
|
||||
|
@ -164,7 +148,7 @@ void VisLine::AddOnScene()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisLine::DrawRay(QGraphicsLineItem *lineItem, const QPointF &p, const QPointF &pTangent, const QColor &color,
|
||||
void VisLine::DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent, const QColor &color,
|
||||
Qt::PenStyle style)
|
||||
{
|
||||
SCASSERT (lineItem != nullptr)
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
|
||||
#include "../vtools/visualization/visualization.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
class VisLine: public Visualization, public QGraphicsLineItem
|
||||
class VisLine: public Visualization, public VScaledLine
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -54,10 +55,6 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::Line)};
|
||||
static qreal CorrectAngle(const qreal &angle);
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
QPointF Ray(const QPointF &firstPoint, const qreal &angle) const;
|
||||
QPointF Ray(const QPointF &firstPoint) const;
|
||||
|
@ -66,7 +63,7 @@ protected:
|
|||
virtual void InitPen() Q_DECL_OVERRIDE;
|
||||
virtual void AddOnScene() Q_DECL_OVERRIDE;
|
||||
|
||||
void DrawRay(QGraphicsLineItem *lineItem, const QPointF &p, const QPointF &pTangent,
|
||||
void DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent,
|
||||
const QColor &color, Qt::PenStyle style);
|
||||
private:
|
||||
Q_DISABLE_COPY(VisLine)
|
||||
|
|
|
@ -53,7 +53,7 @@ VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent
|
|||
|
||||
lineP1 = InitPoint(supportColor, this);
|
||||
lineP2 = InitPoint(supportColor, this); //-V656
|
||||
line = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line = InitItem<VScaledLine>(supportColor, this);
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
||||
|
@ -69,19 +69,6 @@ void VisToolAlongLine::setLength(const QString &expression)
|
|||
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolAlongLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(lineP1, scale);
|
||||
ScalePoint(lineP2, scale);
|
||||
ScalePenWidth(line, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolAlongLine::RefreshGeometry()
|
||||
{
|
||||
|
|
|
@ -51,16 +51,13 @@ public:
|
|||
void setLength(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolAlongLine)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolAlongLine)
|
||||
quint32 object2Id;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *lineP1;
|
||||
QGraphicsEllipseItem *lineP2;
|
||||
QGraphicsLineItem *line;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *lineP1;
|
||||
VScaledEllipse *lineP2;
|
||||
VScaledLine *line;
|
||||
qreal length;
|
||||
};
|
||||
|
||||
|
|
|
@ -49,10 +49,10 @@ VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
|
|||
{
|
||||
line1P1 = InitPoint(supportColor, this);
|
||||
line1P2 = InitPoint(supportColor, this); //-V656
|
||||
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line1 = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
line2P2 = InitPoint(supportColor, this);
|
||||
line2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line2 = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
@ -75,21 +75,6 @@ void VisToolBisector::setLength(const QString &expression)
|
|||
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolBisector::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(line1P1, scale);
|
||||
ScalePoint(line1P2, scale);
|
||||
ScalePenWidth(line1, scale);
|
||||
ScalePoint(line2P2, scale);
|
||||
ScalePenWidth(line2, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolBisector::RefreshGeometry()
|
||||
{
|
||||
|
|
|
@ -52,19 +52,16 @@ public:
|
|||
void setLength(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolBisector)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolBisector)
|
||||
quint32 object2Id;
|
||||
quint32 object3Id;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *line1P1;
|
||||
QGraphicsEllipseItem *line1P2;
|
||||
QGraphicsLineItem *line1;
|
||||
QGraphicsEllipseItem *line2P2;
|
||||
QGraphicsLineItem *line2;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *line1P1;
|
||||
VScaledEllipse *line1P2;
|
||||
VScaledLine *line1;
|
||||
VScaledEllipse *line2P2;
|
||||
VScaledLine *line2;
|
||||
qreal length;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ VisToolCurveIntersectAxis::VisToolCurveIntersectAxis(const VContainer *data, QGr
|
|||
|
||||
visCurve = InitItem<VCurvePathItem>(Qt::darkGreen, this);
|
||||
basePoint = InitPoint(supportColor, this);
|
||||
baseLine = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
axisLine = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
|
||||
baseLine = InitItem<VScaledLine>(supportColor, this);
|
||||
axisLine = InitItem<VScaledLine>(supportColor, this); //-V656
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ void VisToolCurveIntersectAxis::RefreshGeometry()
|
|||
if (object1Id > NULL_ID)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -113,17 +113,3 @@ void VisToolCurveIntersectAxis::setAxisPointId(const quint32 &value)
|
|||
{
|
||||
axisPointId = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolCurveIntersectAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(basePoint, scale);
|
||||
ScalePenWidth(baseLine, scale);
|
||||
ScalePenWidth(axisLine, scale);
|
||||
ScalePenWidth(visCurve, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -54,17 +54,14 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolCurveIntersectAxis)
|
||||
quint32 axisPointId;
|
||||
qreal angle;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *basePoint;
|
||||
QGraphicsLineItem *baseLine;
|
||||
QGraphicsLineItem *axisLine;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *basePoint;
|
||||
VScaledLine *baseLine;
|
||||
VScaledLine *axisLine;
|
||||
VCurvePathItem *visCurve;
|
||||
};
|
||||
|
||||
|
|
|
@ -110,13 +110,3 @@ void VisToolEndLine::setLength(const QString &expression)
|
|||
{
|
||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolEndLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -56,14 +56,11 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolEndLine)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolEndLine)
|
||||
qreal length;
|
||||
qreal angle;
|
||||
QGraphicsEllipseItem *point;
|
||||
VScaledEllipse *point;
|
||||
};
|
||||
|
||||
#endif // VISTOOLENDLINE_H
|
||||
|
|
|
@ -50,8 +50,8 @@ VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent)
|
|||
base_point = InitPoint(supportColor, this);
|
||||
lineP1 = InitPoint(supportColor, this);
|
||||
lineP2 = InitPoint(supportColor, this);
|
||||
line = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
|
||||
line = InitItem<VScaledLine>(supportColor, this);
|
||||
line_intersection = InitItem<VScaledLine>(supportColor, this); //-V656
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
@ -112,21 +112,6 @@ void VisToolHeight::setLineP2Id(const quint32 &value)
|
|||
lineP2Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolHeight::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(base_point, scale);
|
||||
ScalePoint(lineP1, scale);
|
||||
ScalePoint(lineP2, scale);
|
||||
ScalePenWidth(line, scale);
|
||||
ScalePenWidth(line_intersection, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line)
|
||||
{
|
||||
|
|
|
@ -53,20 +53,17 @@ public:
|
|||
void setLineP2Id(const quint32 &value);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolHeight)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolHeight)
|
||||
//base point in parent class
|
||||
quint32 lineP1Id;//first point of line
|
||||
quint32 lineP2Id;//second point of line
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *base_point;
|
||||
QGraphicsEllipseItem *lineP1;
|
||||
QGraphicsEllipseItem *lineP2;
|
||||
QGraphicsLineItem *line;
|
||||
QGraphicsLineItem *line_intersection;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *base_point;
|
||||
VScaledEllipse *lineP1;
|
||||
VScaledEllipse *lineP2;
|
||||
VScaledLine *line;
|
||||
VScaledLine *line_intersection;
|
||||
void ShowIntersection(const QLineF &height_line, const QLineF &base_line);
|
||||
};
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolLine)};
|
||||
protected:
|
||||
virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
|
||||
virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color,
|
||||
Qt::PenStyle style = Qt::SolidLine) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolLine)
|
||||
|
|
|
@ -48,7 +48,7 @@ VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem
|
|||
{
|
||||
line1P1 = InitPoint(supportColor, this);
|
||||
line1P2 = InitPoint(supportColor, this);
|
||||
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line1 = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
line2P1 = InitPoint(supportColor, this);
|
||||
line2P2 = InitPoint(supportColor, this);
|
||||
|
@ -135,18 +135,3 @@ void VisToolLineIntersect::setLine2P2Id(const quint32 &value)
|
|||
{
|
||||
line2P2Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolLineIntersect::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(line1P1, scale);
|
||||
ScalePoint(line1P2, scale);
|
||||
ScalePenWidth(line1, scale);
|
||||
ScalePoint(line2P1, scale);
|
||||
ScalePoint(line2P2, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -53,20 +53,17 @@ public:
|
|||
void setLine2P2Id(const quint32 &value);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersect)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolLineIntersect)
|
||||
quint32 line1P2Id;
|
||||
quint32 line2P1Id;
|
||||
quint32 line2P2Id;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *line1P1;
|
||||
QGraphicsEllipseItem *line1P2;
|
||||
QGraphicsLineItem *line1;
|
||||
QGraphicsEllipseItem *line2P1;
|
||||
QGraphicsEllipseItem *line2P2;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *line1P1;
|
||||
VScaledEllipse *line1P2;
|
||||
VScaledLine *line1;
|
||||
VScaledEllipse *line2P1;
|
||||
VScaledEllipse *line2P2;
|
||||
};
|
||||
|
||||
#endif // VISTOOLLINEINTERSECT_H
|
||||
|
|
|
@ -53,9 +53,9 @@ VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGrap
|
|||
lineP1 = InitPoint(supportColor, this);
|
||||
lineP2 = InitPoint(supportColor, this);
|
||||
basePoint = InitPoint(supportColor, this);
|
||||
baseLine = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
axisLine = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
baseLine = InitItem<VScaledLine>(supportColor, this);
|
||||
axisLine = InitItem<VScaledLine>(supportColor, this);
|
||||
line_intersection = InitItem<VScaledLine>(supportColor, this);
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
||||
|
@ -133,22 +133,6 @@ void VisToolLineIntersectAxis::setAxisPointId(const quint32 &value)
|
|||
axisPointId = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolLineIntersectAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(lineP1, scale);
|
||||
ScalePoint(lineP2, scale);
|
||||
ScalePoint(basePoint, scale);
|
||||
ScalePenWidth(baseLine, scale);
|
||||
ScalePenWidth(axisLine, scale);
|
||||
ScalePenWidth(line_intersection, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line)
|
||||
{
|
||||
|
|
|
@ -56,21 +56,18 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolLineIntersectAxis)
|
||||
quint32 point2Id;
|
||||
quint32 axisPointId;
|
||||
qreal angle;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *lineP1;
|
||||
QGraphicsEllipseItem *lineP2;
|
||||
QGraphicsEllipseItem *basePoint;
|
||||
QGraphicsLineItem *baseLine;
|
||||
QGraphicsLineItem *axisLine;
|
||||
QGraphicsLineItem *line_intersection;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *lineP1;
|
||||
VScaledEllipse *lineP2;
|
||||
VScaledEllipse *basePoint;
|
||||
VScaledLine *baseLine;
|
||||
VScaledLine *axisLine;
|
||||
VScaledLine *line_intersection;
|
||||
void ShowIntersection(const QLineF &axis_line, const QLineF &base_line);
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
|
|||
|
||||
lineP1 = InitPoint(supportColor, this);
|
||||
lineP2 = InitPoint(supportColor, this); //-V656
|
||||
line = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
@ -124,16 +124,3 @@ void VisToolNormal::SetAngle(const qreal &value)
|
|||
{
|
||||
angle = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolNormal::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(lineP1, scale);
|
||||
ScalePoint(lineP2, scale);
|
||||
ScalePenWidth(line, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -55,15 +55,13 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolNormal)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolNormal)
|
||||
quint32 object2Id;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *lineP1;
|
||||
QGraphicsEllipseItem *lineP2;
|
||||
QGraphicsLineItem *line;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *lineP1;
|
||||
VScaledEllipse *lineP2;
|
||||
VScaledLine *line;
|
||||
qreal length;
|
||||
qreal angle;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *d
|
|||
arcPath = InitItem<VCurvePathItem>(Qt::darkGreen, this);
|
||||
point = InitPoint(mainColor, this);
|
||||
tangent = InitPoint(supportColor, this);
|
||||
tangentLine2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
tangentLine2 = InitItem<VScaledLine>(supportColor, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -68,7 +68,7 @@ void VisToolPointFromArcAndTangent::RefreshGeometry()
|
|||
if (arcId > NULL_ID)// circle center
|
||||
{
|
||||
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());
|
||||
|
||||
|
@ -91,19 +91,6 @@ void VisToolPointFromArcAndTangent::setCrossPoint(const CrossCirclesPoint &value
|
|||
crossPoint = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointFromArcAndTangent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(tangent, scale);
|
||||
ScalePenWidth(arcPath, scale);
|
||||
ScalePenWidth(tangentLine2, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc)
|
||||
{
|
||||
|
|
|
@ -55,17 +55,14 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromArcAndTangent)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointFromArcAndTangent)
|
||||
quint32 arcId;
|
||||
CrossCirclesPoint crossPoint;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *tangent;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *tangent;
|
||||
VCurvePathItem *arcPath;
|
||||
QGraphicsLineItem *tangentLine2;
|
||||
VScaledLine *tangentLine2;
|
||||
|
||||
void FindRays(const QPointF &p, const VArc *arc);
|
||||
};
|
||||
|
|
|
@ -47,11 +47,11 @@ VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContai
|
|||
: VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint),
|
||||
point(nullptr), tangent(nullptr), cCenter(nullptr), cPath(nullptr), tangent2(nullptr)
|
||||
{
|
||||
cPath = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this);
|
||||
cPath = InitItem<VScaledEllipse>(Qt::darkGreen, this);
|
||||
point = InitPoint(mainColor, this);
|
||||
tangent = InitPoint(supportColor, this);
|
||||
cCenter = InitPoint(supportColor, this); //-V656
|
||||
tangent2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
tangent2 = InitItem<VScaledLine>(supportColor, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -101,20 +101,6 @@ void VisToolPointFromCircleAndTangent::setCrossPoint(const CrossCirclesPoint &va
|
|||
crossPoint = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointFromCircleAndTangent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(tangent, scale);
|
||||
ScalePoint(cCenter, scale);
|
||||
ScalePoint(cPath, scale);
|
||||
ScalePenWidth(tangent2, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointFromCircleAndTangent::FindRays(const QPointF &p, const QPointF ¢er, qreal radius)
|
||||
{
|
||||
|
|
|
@ -56,19 +56,16 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromCircleAndTangent)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointFromCircleAndTangent)
|
||||
quint32 object2Id;
|
||||
qreal cRadius;
|
||||
CrossCirclesPoint crossPoint;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *tangent;
|
||||
QGraphicsEllipseItem *cCenter;
|
||||
QGraphicsEllipseItem *cPath;
|
||||
QGraphicsLineItem *tangent2;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *tangent;
|
||||
VScaledEllipse *cCenter;
|
||||
VScaledEllipse *cPath;
|
||||
VScaledLine *tangent2;
|
||||
|
||||
void FindRays(const QPointF &p, const QPointF ¢er, qreal radius);
|
||||
};
|
||||
|
|
|
@ -50,7 +50,7 @@ VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsIt
|
|||
arc_point = InitPoint(supportColor, this);
|
||||
lineP1 = InitPoint(supportColor, this);
|
||||
lineP2 = InitPoint(supportColor, this);
|
||||
circle = InitItem<QGraphicsEllipseItem>(supportColor, this);
|
||||
circle = InitItem<VScaledEllipse>(supportColor, this);
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
@ -114,17 +114,3 @@ void VisToolPointOfContact::setRadius(const QString &expression)
|
|||
{
|
||||
radius = FindLength(expression, Visualization::data->PlainVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfContact::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(lineP1, scale);
|
||||
ScalePoint(lineP2, scale);
|
||||
ScalePoint(arc_point, scale);
|
||||
ScalePoint(circle, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -52,18 +52,15 @@ public:
|
|||
void setRadius(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfContact)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointOfContact)
|
||||
quint32 lineP2Id;
|
||||
quint32 radiusId;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *lineP1;
|
||||
QGraphicsEllipseItem *lineP2;
|
||||
QGraphicsEllipseItem *arc_point;
|
||||
QGraphicsEllipseItem *circle;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *lineP1;
|
||||
VScaledEllipse *lineP2;
|
||||
VScaledEllipse *arc_point;
|
||||
VScaledEllipse *circle;
|
||||
qreal radius;
|
||||
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, Q
|
|||
{
|
||||
axisP1 = InitPoint(supportColor, this);
|
||||
axisP2 = InitPoint(supportColor, this); //-V656
|
||||
axis2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
axis2 = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
@ -93,19 +93,6 @@ void VisToolPointOfIntersection::setPoint2Id(const quint32 &value)
|
|||
point2Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersection::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(axisP1, scale);
|
||||
ScalePoint(axisP2, scale);
|
||||
ScalePenWidth(axis2, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color)
|
||||
{
|
||||
|
|
|
@ -53,16 +53,13 @@ public:
|
|||
void setPoint2Id(const quint32 &value);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointOfIntersection)
|
||||
quint32 point2Id;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *axisP1;//axis1 is class themself
|
||||
QGraphicsEllipseItem *axisP2;
|
||||
QGraphicsLineItem *axis2;//axis1 is class themself
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *axisP1;//axis1 is class themself
|
||||
VScaledEllipse *axisP2;
|
||||
VScaledLine *axis2;//axis1 is class themself
|
||||
|
||||
void ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color);
|
||||
};
|
||||
|
|
|
@ -71,12 +71,12 @@ void VisToolPointOfIntersectionArcs::RefreshGeometry()
|
|||
if (arc1Id > NULL_ID)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
DrawPoint(point, fPoint, mainColor);
|
||||
|
@ -114,15 +114,3 @@ void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossCirclesPoint &valu
|
|||
{
|
||||
crossPoint = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionArcs::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePenWidth(arc1Path, scale);
|
||||
ScalePenWidth(arc2Path, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -56,15 +56,12 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionArcs)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointOfIntersectionArcs)
|
||||
quint32 arc1Id;
|
||||
quint32 arc2Id;
|
||||
CrossCirclesPoint crossPoint;
|
||||
QGraphicsEllipseItem *point;
|
||||
VScaledEllipse *point;
|
||||
VCurvePathItem *arc1Path;
|
||||
VCurvePathItem *arc2Path;
|
||||
};
|
||||
|
|
|
@ -52,8 +52,8 @@ VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VCont
|
|||
{
|
||||
this->setPen(QPen(Qt::NoPen)); // don't use parent this time
|
||||
|
||||
c1Path = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this);
|
||||
c2Path = InitItem<QGraphicsEllipseItem>(Qt::darkRed, this);
|
||||
c1Path = InitItem<VScaledEllipse>(Qt::darkGreen, this);
|
||||
c2Path = InitItem<VScaledEllipse>(Qt::darkRed, this);
|
||||
point = InitPoint(mainColor, this);
|
||||
c1Center = InitPoint(supportColor, this);
|
||||
c2Center = InitPoint(supportColor, this); //-V656
|
||||
|
@ -125,18 +125,3 @@ void VisToolPointOfIntersectionCircles::setCrossPoint(const CrossCirclesPoint &v
|
|||
{
|
||||
crossPoint = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionCircles::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(c1Center, scale);
|
||||
ScalePoint(c2Center, scale);
|
||||
ScalePoint(c1Path, scale);
|
||||
ScalePoint(c2Path, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -57,20 +57,17 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCircles)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointOfIntersectionCircles)
|
||||
quint32 object2Id;
|
||||
qreal c1Radius;
|
||||
qreal c2Radius;
|
||||
CrossCirclesPoint crossPoint;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *c1Center;
|
||||
QGraphicsEllipseItem *c2Center;
|
||||
QGraphicsEllipseItem *c1Path;
|
||||
QGraphicsEllipseItem *c2Path;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *c1Center;
|
||||
VScaledEllipse *c2Center;
|
||||
VScaledEllipse *c1Path;
|
||||
VScaledEllipse *c2Path;
|
||||
};
|
||||
|
||||
#endif // VISTOOLPOINTOFINTERSECTIONCIRCLES_H
|
||||
|
|
|
@ -50,11 +50,11 @@ VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem
|
|||
{
|
||||
line1P1 = InitPoint(supportColor, this);
|
||||
line1P2 = InitPoint(supportColor, this); //-V656
|
||||
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line1 = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
line2P2 = InitPoint(supportColor, this);
|
||||
line2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
line3 = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
|
||||
line2 = InitItem<VScaledLine>(supportColor, this);
|
||||
line3 = InitItem<VScaledLine>(supportColor, this); //-V656
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
@ -131,19 +131,3 @@ void VisToolShoulderPoint::setLength(const QString &expression)
|
|||
{
|
||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolShoulderPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(line1P1, scale);
|
||||
ScalePoint(line1P2, scale);
|
||||
ScalePenWidth(line1, scale);
|
||||
ScalePoint(line2P2, scale);
|
||||
ScalePenWidth(line2, scale);
|
||||
ScalePenWidth(line3, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -52,20 +52,17 @@ public:
|
|||
void setLength(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolShoulderPoint)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolShoulderPoint)
|
||||
quint32 lineP1Id;
|
||||
quint32 lineP2Id;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *line1P1;
|
||||
QGraphicsEllipseItem *line1P2;
|
||||
QGraphicsLineItem *line1;
|
||||
QGraphicsEllipseItem *line2P2;
|
||||
QGraphicsLineItem *line2;
|
||||
QGraphicsLineItem *line3;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *line1P1;
|
||||
VScaledEllipse *line1P2;
|
||||
VScaledLine *line1;
|
||||
VScaledEllipse *line2P2;
|
||||
VScaledLine *line2;
|
||||
VScaledLine *line3;
|
||||
qreal length;
|
||||
};
|
||||
|
||||
|
|
|
@ -53,11 +53,11 @@ VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent)
|
|||
{
|
||||
axisP1 = InitPoint(supportColor, this);
|
||||
axisP2 = InitPoint(supportColor, this);
|
||||
axis = InitItem<QGraphicsPathItem>(supportColor, this);
|
||||
axis = InitItem<VCurvePathItem>(supportColor, this);
|
||||
hypotenuseP1 = InitPoint(supportColor, this);
|
||||
hypotenuseP2 = InitPoint(supportColor, this);
|
||||
foot1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
foot2 = InitItem<QGraphicsLineItem>(supportColor, this); //-V656
|
||||
foot1 = InitItem<VScaledLine>(supportColor, this);
|
||||
foot2 = InitItem<VScaledLine>(supportColor, this); //-V656
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
@ -144,24 +144,7 @@ void VisToolTriangle::setHypotenuseP2Id(const quint32 &value)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolTriangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePoint(axisP1, scale);
|
||||
ScalePoint(axisP2, scale);
|
||||
ScalePenWidth(axis, scale);
|
||||
ScalePoint(hypotenuseP1, scale);
|
||||
ScalePoint(hypotenuseP2, scale);
|
||||
ScalePenWidth(foot1, scale);
|
||||
ScalePenWidth(foot2, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolTriangle::DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line, const QColor &color,
|
||||
void VisToolTriangle::DrawAimedAxis(VCurvePathItem *item, const QLineF &line, const QColor &color,
|
||||
Qt::PenStyle style)
|
||||
{
|
||||
SCASSERT (item != nullptr)
|
||||
|
|
|
@ -57,24 +57,21 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolTriangle)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolTriangle)
|
||||
quint32 object2Id;//axis second point
|
||||
quint32 hypotenuseP1Id;
|
||||
quint32 hypotenuseP2Id;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *axisP1;
|
||||
QGraphicsEllipseItem *axisP2;
|
||||
QGraphicsPathItem *axis;
|
||||
QGraphicsEllipseItem *hypotenuseP1;
|
||||
QGraphicsEllipseItem *hypotenuseP2;
|
||||
QGraphicsLineItem *foot1;
|
||||
QGraphicsLineItem *foot2;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *axisP1;
|
||||
VScaledEllipse *axisP2;
|
||||
VCurvePathItem *axis;
|
||||
VScaledEllipse *hypotenuseP1;
|
||||
VScaledEllipse *hypotenuseP2;
|
||||
VScaledLine *foot1;
|
||||
VScaledLine *foot2;
|
||||
|
||||
void DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line, const QColor &color,
|
||||
void DrawAimedAxis(VCurvePathItem *item, const QLineF &line, const QColor &color,
|
||||
Qt::PenStyle style = Qt::SolidLine);
|
||||
void DrawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size);
|
||||
};
|
||||
|
|
|
@ -67,10 +67,10 @@ VisToolTrueDarts::VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent
|
|||
dartP2 = InitPoint(supportColor, this);
|
||||
dartP3 = InitPoint(supportColor, this);
|
||||
|
||||
lineblP1P1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
lineblP2P2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
p1d2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
d2p2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
lineblP1P1 = InitItem<VScaledLine>(supportColor, this);
|
||||
lineblP2P2 = InitItem<VScaledLine>(supportColor, this);
|
||||
p1d2 = InitItem<VScaledLine>(supportColor, this);
|
||||
d2p2 = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
point1 = InitPoint(mainColor, this);
|
||||
point2 = InitPoint(mainColor, this); //-V656
|
||||
|
@ -163,24 +163,3 @@ void VisToolTrueDarts::setD3PointId(const quint32 &value)
|
|||
{
|
||||
dartP3Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolTrueDarts::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point1, scale);
|
||||
ScalePoint(point2, scale);
|
||||
ScalePoint(baseLineP1, scale);
|
||||
ScalePoint(baseLineP2, scale);
|
||||
ScalePoint(dartP1, scale);
|
||||
ScalePoint(dartP2, scale);
|
||||
ScalePoint(dartP3, scale);
|
||||
|
||||
ScalePenWidth(lineblP1P1, scale);
|
||||
ScalePenWidth(lineblP2P2, scale);
|
||||
ScalePenWidth(p1d2, scale);
|
||||
ScalePenWidth(d2p2, scale);
|
||||
|
||||
VisLine::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -55,9 +55,6 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolTrueDarts)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolTrueDarts)
|
||||
quint32 baseLineP2Id;
|
||||
|
@ -65,18 +62,18 @@ private:
|
|||
quint32 dartP2Id;
|
||||
quint32 dartP3Id;
|
||||
|
||||
QGraphicsEllipseItem *point1;
|
||||
QGraphicsEllipseItem *point2;
|
||||
QGraphicsEllipseItem *baseLineP1;
|
||||
QGraphicsEllipseItem *baseLineP2;
|
||||
QGraphicsEllipseItem *dartP1;
|
||||
QGraphicsEllipseItem *dartP2;
|
||||
QGraphicsEllipseItem *dartP3;
|
||||
VScaledEllipse *point1;
|
||||
VScaledEllipse *point2;
|
||||
VScaledEllipse *baseLineP1;
|
||||
VScaledEllipse *baseLineP2;
|
||||
VScaledEllipse *dartP1;
|
||||
VScaledEllipse *dartP2;
|
||||
VScaledEllipse *dartP3;
|
||||
|
||||
QGraphicsLineItem *lineblP1P1;
|
||||
QGraphicsLineItem *lineblP2P2;
|
||||
QGraphicsLineItem *p1d2;
|
||||
QGraphicsLineItem *d2p2;
|
||||
VScaledLine *lineblP1P1;
|
||||
VScaledLine *lineblP2P2;
|
||||
VScaledLine *p1d2;
|
||||
VScaledLine *d2p2;
|
||||
};
|
||||
|
||||
#endif // VISTOOLTRUEDARTS_H
|
||||
|
|
|
@ -45,22 +45,6 @@ VisPath::VisPath(const VContainer *data, QGraphicsItem *parent)
|
|||
InitPen();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
ScalePenWidth(this, SceneScale(scene()));
|
||||
|
||||
VCurvePathItem::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VisPath::boundingRect() const
|
||||
{
|
||||
QRectF recTool = VCurvePathItem::boundingRect();
|
||||
recTool = recTool.united(childrenBoundingRect());
|
||||
return recTool;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisPath::InitPen()
|
||||
{
|
||||
|
|
|
@ -51,10 +51,6 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::Path)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void InitPen() Q_DECL_OVERRIDE;
|
||||
virtual void AddOnScene() Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../visualization.h"
|
||||
#include "vispath.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -60,7 +61,7 @@ void VisToolArc::RefreshGeometry()
|
|||
if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(arcCenter, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -52,12 +52,9 @@ public:
|
|||
void setF2(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolArc)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolArc)
|
||||
QGraphicsEllipseItem *arcCenter;
|
||||
VScaledEllipse *arcCenter;
|
||||
qreal radius;
|
||||
qreal f1;
|
||||
qreal f2;
|
||||
|
|
|
@ -60,7 +60,7 @@ void VisToolArcWithLength::RefreshGeometry()
|
|||
if (not qFuzzyIsNull(radius) && f1 >= 0 && not qFuzzyIsNull(length))
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolArcWithLength::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(arcCenter, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -52,12 +52,9 @@ public:
|
|||
void setLength(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolArcWithLength)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolArcWithLength)
|
||||
QGraphicsEllipseItem *arcCenter;
|
||||
VScaledEllipse *arcCenter;
|
||||
qreal radius;
|
||||
qreal f1;
|
||||
qreal length;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../visualization.h"
|
||||
#include "vispath.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -57,8 +58,8 @@ VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *pa
|
|||
helpLine1(nullptr),
|
||||
helpLine2(nullptr)
|
||||
{
|
||||
helpLine1 = InitItem<QGraphicsLineItem>(mainColor, this);
|
||||
helpLine2 = InitItem<QGraphicsLineItem>(mainColor, this);
|
||||
helpLine1 = InitItem<VScaledLine>(mainColor, this);
|
||||
helpLine2 = InitItem<VScaledLine>(mainColor, this);
|
||||
|
||||
point1 = InitPoint(supportColor, this);
|
||||
point2 = InitPoint(supportColor, this); //-V656
|
||||
|
@ -89,7 +90,7 @@ void VisToolCubicBezier::RefreshGeometry()
|
|||
{
|
||||
VCubicBezier spline(*first, *second, 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
|
||||
{
|
||||
|
@ -99,7 +100,7 @@ void VisToolCubicBezier::RefreshGeometry()
|
|||
if (object4Id <= NULL_ID)
|
||||
{
|
||||
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,
|
||||
Qt::DashLine);
|
||||
}
|
||||
|
@ -111,7 +112,7 @@ void VisToolCubicBezier::RefreshGeometry()
|
|||
Qt::DashLine);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolCubicBezier::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point1, scale);
|
||||
ScalePoint(point2, scale);
|
||||
ScalePoint(point3, scale);
|
||||
ScalePoint(point4, scale);
|
||||
ScalePenWidth(helpLine1, scale);
|
||||
ScalePenWidth(helpLine2, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -54,20 +54,17 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolCubicBezier)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
Q_DISABLE_COPY(VisToolCubicBezier)
|
||||
quint32 object2Id;
|
||||
quint32 object3Id;
|
||||
quint32 object4Id;
|
||||
QGraphicsEllipseItem *point1;
|
||||
QGraphicsEllipseItem *point2;
|
||||
QGraphicsEllipseItem *point3;
|
||||
QGraphicsEllipseItem *point4;
|
||||
QGraphicsLineItem *helpLine1;
|
||||
QGraphicsLineItem *helpLine2;
|
||||
VScaledEllipse *point1;
|
||||
VScaledEllipse *point2;
|
||||
VScaledEllipse *point3;
|
||||
VScaledEllipse *point4;
|
||||
VScaledLine *helpLine1;
|
||||
VScaledLine *helpLine2;
|
||||
};
|
||||
|
||||
#endif // VISTOOLCUBICBEZIER_H
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "../vgeometry/vspline.h"
|
||||
#include "../visualization.h"
|
||||
#include "vispath.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -53,8 +54,8 @@ VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphics
|
|||
helpLine1(nullptr),
|
||||
helpLine2(nullptr)
|
||||
{
|
||||
helpLine1 = InitItem<QGraphicsLineItem>(mainColor, this);
|
||||
helpLine2 = InitItem<QGraphicsLineItem>(mainColor, this);
|
||||
helpLine1 = InitItem<VScaledLine>(mainColor, this);
|
||||
helpLine2 = InitItem<VScaledLine>(mainColor, this);
|
||||
|
||||
newCurveSegment = InitItem<VCurvePathItem>(mainColor, this);
|
||||
}
|
||||
|
@ -77,7 +78,7 @@ void VisToolCubicBezierPath::RefreshGeometry()
|
|||
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
QGraphicsEllipseItem *point = this->getPoint(mainPoints, static_cast<unsigned>(i), 1/*zValue*/);
|
||||
VScaledEllipse *point = this->getPoint(mainPoints, static_cast<unsigned>(i), 1/*zValue*/);
|
||||
DrawPoint(point, static_cast<QPointF>(pathPoints.at(i)), supportColor);
|
||||
}
|
||||
|
||||
|
@ -96,8 +97,7 @@ void VisToolCubicBezierPath::RefreshGeometry()
|
|||
|
||||
if (countSubSpl >= 1)
|
||||
{
|
||||
DrawPath(this, path.GetPath(), mainColor, lineStyle, Qt::RoundCap);
|
||||
DrawPath(this, path.GetDirectionPath(), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||
DrawPath(this, path.GetPath(), path.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
|
||||
|
||||
for (qint32 i = 1; i<=countSubSpl; ++i)
|
||||
{
|
||||
|
@ -106,18 +106,18 @@ void VisToolCubicBezierPath::RefreshGeometry()
|
|||
|
||||
const VSpline spl = path.GetSpline(i);
|
||||
|
||||
QGraphicsLineItem *ctrlLine1 = this->getLine(static_cast<unsigned>(preLastPoint));
|
||||
VScaledLine *ctrlLine1 = this->getLine(static_cast<unsigned>(preLastPoint));
|
||||
DrawLine(ctrlLine1, QLineF(static_cast<QPointF>(spl.GetP1()), static_cast<QPointF>(spl.GetP2())),
|
||||
mainColor, Qt::DashLine);
|
||||
|
||||
QGraphicsEllipseItem *p2 = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||
VScaledEllipse *p2 = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||
DrawPoint(p2, static_cast<QPointF>(spl.GetP2()), Qt::green);
|
||||
|
||||
QGraphicsLineItem *ctrlLine2 = this->getLine(static_cast<unsigned>(lastPoint));
|
||||
VScaledLine *ctrlLine2 = this->getLine(static_cast<unsigned>(lastPoint));
|
||||
DrawLine(ctrlLine2, QLineF(static_cast<QPointF>(spl.GetP4()), static_cast<QPointF>(spl.GetP3())),
|
||||
mainColor, Qt::DashLine);
|
||||
|
||||
QGraphicsEllipseItem *p3 = this->getPoint(ctrlPoints, static_cast<unsigned>(lastPoint));
|
||||
VScaledEllipse *p3 = this->getPoint(ctrlPoints, static_cast<unsigned>(lastPoint));
|
||||
DrawPoint(p3, static_cast<QPointF>(spl.GetP3()), Qt::green);
|
||||
}
|
||||
}
|
||||
|
@ -142,34 +142,7 @@ VCubicBezierPath VisToolCubicBezierPath::getPath()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolCubicBezierPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
for (int i=0; i < mainPoints.size(); ++i)
|
||||
{
|
||||
ScalePoint(mainPoints[i], scale);
|
||||
}
|
||||
|
||||
for (int i=0; i < ctrlPoints.size(); ++i)
|
||||
{
|
||||
ScalePoint(ctrlPoints[i], scale);
|
||||
}
|
||||
|
||||
for (int i=0; i < lines.size(); ++i)
|
||||
{
|
||||
ScalePenWidth(lines[i], scale);
|
||||
}
|
||||
|
||||
ScalePenWidth(newCurveSegment, scale);
|
||||
ScalePenWidth(helpLine1, scale);
|
||||
ScalePenWidth(helpLine2, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *VisToolCubicBezierPath::getPoint(QVector<QGraphicsEllipseItem *> &points, quint32 i, qreal z)
|
||||
VScaledEllipse *VisToolCubicBezierPath::getPoint(QVector<VScaledEllipse *> &points, quint32 i, qreal z)
|
||||
{
|
||||
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
||||
{
|
||||
|
@ -184,7 +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)
|
||||
{
|
||||
|
@ -192,7 +165,7 @@ QGraphicsLineItem *VisToolCubicBezierPath::getLine(quint32 i)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto line = InitItem<QGraphicsLineItem>(mainColor, this);
|
||||
auto line = InitItem<VScaledLine>(mainColor, this);
|
||||
lines.append(line);
|
||||
return line;
|
||||
}
|
||||
|
@ -229,12 +202,12 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
|
|||
const QPointF p2 = p1p2.p2();
|
||||
|
||||
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);
|
||||
|
||||
const int preLastPoint = subSplCount * 2;
|
||||
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||
VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||
DrawPoint(p2Ctrl, p2, Qt::green);
|
||||
}
|
||||
else
|
||||
|
@ -260,10 +233,10 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
|
|||
DrawLine(helpLine1, QLineF(static_cast<QPointF>(p1), p2), mainColor, Qt::DashLine);
|
||||
|
||||
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;
|
||||
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||
VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||
DrawPoint(p2Ctrl, p2, Qt::green);
|
||||
break;
|
||||
}
|
||||
|
@ -286,10 +259,10 @@ void VisToolCubicBezierPath::Creating(const QVector<VPointF> &pathPoints, int po
|
|||
DrawLine(helpLine2, QLineF(p3, Visualization::scenePos), mainColor, Qt::DashLine);
|
||||
|
||||
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;
|
||||
QGraphicsEllipseItem *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||
VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast<unsigned>(preLastPoint));
|
||||
DrawPoint(p2Ctrl, p2, Qt::green);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -55,22 +55,19 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolCubicBezierPath)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
Q_DISABLE_COPY(VisToolCubicBezierPath)
|
||||
QVector<QGraphicsEllipseItem *> mainPoints;
|
||||
QVector<QGraphicsEllipseItem *> ctrlPoints;
|
||||
QVector<QGraphicsLineItem *> lines;
|
||||
QVector<VScaledEllipse *> mainPoints;
|
||||
QVector<VScaledEllipse *> ctrlPoints;
|
||||
QVector<VScaledLine *> lines;
|
||||
VCurvePathItem *newCurveSegment;
|
||||
VCubicBezierPath path;
|
||||
QGraphicsLineItem *helpLine1;
|
||||
QGraphicsLineItem *helpLine2;
|
||||
VScaledLine *helpLine1;
|
||||
VScaledLine *helpLine2;
|
||||
|
||||
private:
|
||||
QGraphicsEllipseItem *getPoint(QVector<QGraphicsEllipseItem *> &points, quint32 i, qreal z = 0);
|
||||
QGraphicsLineItem *getLine(quint32 i);
|
||||
VScaledEllipse *getPoint(QVector<VScaledEllipse *> &points, quint32 i, qreal z = 0);
|
||||
VScaledLine *getLine(quint32 i);
|
||||
void Creating(const QVector<VPointF> &pathPoints , int pointsLeft);
|
||||
void RefreshToolTip();
|
||||
};
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../visualization.h"
|
||||
#include "vispath.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -63,7 +64,7 @@ void VisToolCutArc::RefreshGeometry()
|
|||
if (object1Id > NULL_ID)
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
@ -72,8 +73,8 @@ void VisToolCutArc::RefreshGeometry()
|
|||
QPointF p = arc->CutArc(length, ar1, ar2);
|
||||
DrawPoint(point, p, mainColor);
|
||||
|
||||
DrawPath(arc1, ar1.GetPath(), ar1.GetDirectionPath(), Qt::darkGreen, lineStyle, Qt::RoundCap);
|
||||
DrawPath(arc2, ar2.GetPath(), ar2.GetDirectionPath(), Qt::darkRed, lineStyle, Qt::RoundCap);
|
||||
DrawPath(arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, 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());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolCutArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePenWidth(arc1, scale);
|
||||
ScalePenWidth(arc2, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -50,12 +50,9 @@ public:
|
|||
void setLength(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolCutArc)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
Q_DISABLE_COPY(VisToolCutArc)
|
||||
QGraphicsEllipseItem *point;
|
||||
VScaledEllipse *point;
|
||||
VCurvePathItem *arc1;
|
||||
VCurvePathItem *arc2;
|
||||
qreal length;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../visualization.h"
|
||||
#include "vispath.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -65,7 +66,7 @@ void VisToolCutSpline::RefreshGeometry()
|
|||
if (object1Id > NULL_ID)
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
@ -80,8 +81,8 @@ void VisToolCutSpline::RefreshGeometry()
|
|||
|
||||
DrawPoint(point, p, mainColor);
|
||||
|
||||
DrawPath(spl1, sp1.GetPath(), sp1.GetDirectionPath(), Qt::darkGreen, lineStyle, Qt::RoundCap);
|
||||
DrawPath(spl2, sp2.GetPath(), sp2.GetDirectionPath(), Qt::darkRed, lineStyle, Qt::RoundCap);
|
||||
DrawPath(spl1, sp1.GetPath(), sp1.DirectionArrows(), Qt::darkGreen, 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());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolCutSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePenWidth(spl1, scale);
|
||||
ScalePenWidth(spl2, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -50,12 +50,9 @@ public:
|
|||
void setLength(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
Q_DISABLE_COPY(VisToolCutSpline)
|
||||
QGraphicsEllipseItem *point;
|
||||
VScaledEllipse *point;
|
||||
VCurvePathItem *spl1;
|
||||
VCurvePathItem *spl2;
|
||||
qreal length;
|
||||
|
|
|
@ -65,7 +65,7 @@ void VisToolCutSplinePath::RefreshGeometry()
|
|||
if (object1Id > NULL_ID)
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
@ -79,8 +79,8 @@ void VisToolCutSplinePath::RefreshGeometry()
|
|||
DrawPoint(point, static_cast<QPointF>(*p), mainColor);
|
||||
delete p;
|
||||
|
||||
DrawPath(splPath1, spPath1->GetPath(), spPath1->GetDirectionPath(), Qt::darkGreen, lineStyle, Qt::RoundCap);
|
||||
DrawPath(splPath2, spPath2->GetPath(), spPath2->GetDirectionPath(), Qt::darkRed, lineStyle, Qt::RoundCap);
|
||||
DrawPath(splPath1, spPath1->GetPath(), spPath1->DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
|
||||
DrawPath(splPath2, spPath2->GetPath(), spPath2->DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
|
||||
|
||||
delete spPath1;
|
||||
delete spPath2;
|
||||
|
@ -93,15 +93,3 @@ void VisToolCutSplinePath::setLength(const QString &expression)
|
|||
{
|
||||
length = FindLength(expression, Visualization::data->PlainVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolCutSplinePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePenWidth(splPath1, scale);
|
||||
ScalePenWidth(splPath2, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -50,12 +50,9 @@ public:
|
|||
void setLength(const QString &expression);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
Q_DISABLE_COPY(VisToolCutSplinePath)
|
||||
QGraphicsEllipseItem *point;
|
||||
VScaledEllipse *point;
|
||||
VCurvePathItem *splPath1;
|
||||
VCurvePathItem *splPath2;
|
||||
qreal length;
|
||||
|
|
|
@ -57,7 +57,7 @@ void VisToolEllipticalArc::RefreshGeometry()
|
|||
if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolEllipticalArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(arcCenter, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -54,12 +54,9 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolEllipticalArc)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolEllipticalArc)
|
||||
QGraphicsEllipseItem *arcCenter;
|
||||
VScaledEllipse *arcCenter;
|
||||
qreal radius1;
|
||||
qreal radius2;
|
||||
qreal f1;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "vistoolpiece.h"
|
||||
#include "../vpatterndb/vpiecepath.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -38,8 +39,8 @@ VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
|||
m_line2(nullptr),
|
||||
m_piece()
|
||||
{
|
||||
m_line1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
m_line2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
m_line1 = InitItem<VScaledLine>(supportColor, this);
|
||||
m_line2 = InitItem<VScaledLine>(supportColor, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -55,7 +56,7 @@ void VisToolPiece::RefreshGeometry()
|
|||
|
||||
for (int i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(i), supportColor);
|
||||
VScaledEllipse *point = GetPoint(static_cast<quint32>(i), supportColor);
|
||||
DrawPoint(point, nodes.at(i).toQPointF(), supportColor);
|
||||
}
|
||||
|
||||
|
@ -79,23 +80,7 @@ void VisToolPiece::SetPiece(const VPiece &piece)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPiece::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
for (int i=0; i < m_points.size(); ++i)
|
||||
{
|
||||
ScalePoint(m_points[i], scale);
|
||||
}
|
||||
|
||||
ScalePenWidth(m_line1, scale);
|
||||
ScalePenWidth(m_line2, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *VisToolPiece::GetPoint(quint32 i, const QColor &color)
|
||||
VScaledEllipse *VisToolPiece::GetPoint(quint32 i, const QColor &color)
|
||||
{
|
||||
return GetPointItem(m_points, i, color, this);
|
||||
}
|
||||
|
|
|
@ -46,18 +46,15 @@ public:
|
|||
void SetPiece(const VPiece &piece);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPiece)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPiece)
|
||||
QVector<QGraphicsEllipseItem *> m_points;
|
||||
QVector<VScaledEllipse *> m_points;
|
||||
|
||||
QGraphicsLineItem *m_line1;
|
||||
QGraphicsLineItem *m_line2;
|
||||
VScaledLine *m_line1;
|
||||
VScaledLine *m_line2;
|
||||
VPiece m_piece;
|
||||
|
||||
QGraphicsEllipseItem* GetPoint(quint32 i, const QColor &color);
|
||||
VScaledEllipse* GetPoint(quint32 i, const QColor &color);
|
||||
|
||||
void HideAllItems();
|
||||
};
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "vistoolpiecepath.h"
|
||||
#include "../vwidgets/vsimplepoint.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
|
@ -39,7 +40,7 @@ VisToolPiecePath::VisToolPiecePath(const VContainer *data, QGraphicsItem *parent
|
|||
m_line(nullptr),
|
||||
m_path()
|
||||
{
|
||||
m_line = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
m_line = InitItem<VScaledLine>(supportColor, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -78,21 +79,6 @@ void VisToolPiecePath::SetPath(const VPiecePath &path)
|
|||
m_path = path;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPiecePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
for (int i=0; i < m_points.size(); ++i)
|
||||
{
|
||||
ScalePoint(m_points[i], scale);
|
||||
}
|
||||
|
||||
ScalePenWidth(m_line, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPiecePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
|
|
|
@ -48,9 +48,6 @@ public:
|
|||
void SetPath(const VPiecePath &path);
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPiecePath)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -58,7 +55,7 @@ private:
|
|||
Q_DISABLE_COPY(VisToolPiecePath)
|
||||
QVector<VSimplePoint *> m_points;
|
||||
|
||||
QGraphicsLineItem *m_line;
|
||||
VScaledLine *m_line;
|
||||
|
||||
VPiecePath m_path;
|
||||
|
||||
|
|
|
@ -63,12 +63,13 @@ void VisToolPointOfIntersectionCurves::RefreshGeometry()
|
|||
if (object1Id > NULL_ID)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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,
|
||||
hCrossPoint);
|
||||
|
@ -107,14 +108,3 @@ void VisToolPointOfIntersectionCurves::setHCrossPoint(const HCrossCurvesPoint &v
|
|||
{
|
||||
hCrossPoint = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionCurves::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point, scale);
|
||||
ScalePenWidth(visCurve2, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -56,16 +56,12 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCurves)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointOfIntersectionCurves)
|
||||
quint32 object2Id;
|
||||
VCrossCurvesPoint vCrossPoint;
|
||||
HCrossCurvesPoint hCrossPoint;
|
||||
|
||||
QGraphicsEllipseItem *point;
|
||||
VScaledEllipse *point;
|
||||
VCurvePathItem *visCurve2;
|
||||
|
||||
};
|
||||
|
|
|
@ -122,7 +122,7 @@ void VisToolSpline::RefreshGeometry()
|
|||
if (object4Id <= NULL_ID)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -160,12 +160,12 @@ void VisToolSpline::RefreshGeometry()
|
|||
if (VFuzzyComparePossibleNulls(angle1, EMPTY_ANGLE) || VFuzzyComparePossibleNulls(angle2, EMPTY_ANGLE))
|
||||
{
|
||||
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
|
||||
{
|
||||
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!");
|
||||
emit ToolTip(Visualization::toolTip);
|
||||
}
|
||||
|
@ -221,17 +221,6 @@ QPointF VisToolSpline::GetP3() const
|
|||
return p3;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScalePoint(point1, scale);
|
||||
ScalePoint(point4, scale);
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolSpline::MouseLeftPressed()
|
||||
{
|
||||
|
|
|
@ -64,9 +64,6 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolSpline)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
public slots:
|
||||
void MouseLeftPressed();
|
||||
void MouseLeftReleased();
|
||||
|
@ -74,8 +71,8 @@ public slots:
|
|||
protected:
|
||||
Q_DISABLE_COPY(VisToolSpline)
|
||||
quint32 object4Id;
|
||||
QGraphicsEllipseItem *point1;
|
||||
QGraphicsEllipseItem *point4;
|
||||
VScaledEllipse *point1;
|
||||
VScaledEllipse *point4;
|
||||
qreal angle1;
|
||||
qreal angle2;
|
||||
qreal kAsm1;
|
||||
|
|
|
@ -48,10 +48,10 @@
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *parent)
|
||||
: VisPath(data, parent),
|
||||
points(QVector<QGraphicsEllipseItem *>()),
|
||||
ctrlPoints(QVector<VControlPointSpline *>()),
|
||||
points(),
|
||||
ctrlPoints(),
|
||||
newCurveSegment(nullptr),
|
||||
path(VSplinePath()),
|
||||
path(),
|
||||
isLeftMousePressed(false),
|
||||
pointSelected(false),
|
||||
ctrlPoint()
|
||||
|
@ -62,8 +62,6 @@ VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *pare
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolSplinePath::~VisToolSplinePath()
|
||||
{
|
||||
qDeleteAll(ctrlPoints);
|
||||
qDeleteAll(points);
|
||||
emit ToolTip("");
|
||||
}
|
||||
|
||||
|
@ -77,7 +75,7 @@ void VisToolSplinePath::RefreshGeometry()
|
|||
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
QGraphicsEllipseItem *point = this->getPoint(static_cast<unsigned>(i));
|
||||
VScaledEllipse *point = this->getPoint(static_cast<unsigned>(i));
|
||||
DrawPoint(point, static_cast<QPointF>(pathPoints.at(i).P()), supportColor);
|
||||
}
|
||||
|
||||
|
@ -106,7 +104,7 @@ void VisToolSplinePath::RefreshGeometry()
|
|||
|
||||
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)
|
||||
|
@ -139,19 +137,6 @@ VSplinePath VisToolSplinePath::getPath()
|
|||
return path;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolSplinePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
for (int i=0; i < points.size(); ++i)
|
||||
{
|
||||
ScalePoint(points[i], scale);
|
||||
}
|
||||
|
||||
VisPath::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolSplinePath::MouseLeftPressed()
|
||||
{
|
||||
|
@ -172,7 +157,7 @@ void VisToolSplinePath::MouseLeftReleased()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *VisToolSplinePath::getPoint(quint32 i)
|
||||
VScaledEllipse *VisToolSplinePath::getPoint(quint32 i)
|
||||
{
|
||||
if (static_cast<quint32>(points.size() - 1) >= i && points.isEmpty() == false)
|
||||
{
|
||||
|
@ -311,6 +296,6 @@ void VisToolSplinePath::Creating(const QPointF &pSpl, int size)
|
|||
}
|
||||
emit PathChanged(path);
|
||||
|
||||
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||
DrawPath(newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,9 +58,6 @@ public:
|
|||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolSplinePath)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
signals:
|
||||
void PathChanged(const VSplinePath &path);
|
||||
|
||||
|
@ -70,7 +67,7 @@ public slots:
|
|||
|
||||
protected:
|
||||
Q_DISABLE_COPY(VisToolSplinePath)
|
||||
QVector<QGraphicsEllipseItem *> points;
|
||||
QVector<VScaledEllipse *> points;
|
||||
QVector<VControlPointSpline *> ctrlPoints;
|
||||
VCurvePathItem *newCurveSegment;
|
||||
VSplinePath path;
|
||||
|
@ -80,7 +77,7 @@ protected:
|
|||
|
||||
QPointF ctrlPoint;
|
||||
|
||||
QGraphicsEllipseItem * getPoint(quint32 i);
|
||||
VScaledEllipse * getPoint(quint32 i);
|
||||
void Creating(const QPointF &pSpl, int size);
|
||||
};
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../vwidgets/vcurvepathitem.h"
|
||||
#include "../vwidgets/scalesceneitems.h"
|
||||
|
||||
template <class K, class V> class QHash;
|
||||
|
||||
|
@ -136,14 +137,7 @@ void Visualization::MousePos(const QPointF &scenePos)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void Visualization::ScalePoint(QGraphicsEllipseItem *item, qreal scale)
|
||||
{
|
||||
ScaleCircleSize(item, scale);
|
||||
ScalePenWidth(item, scale);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const
|
||||
VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const
|
||||
{
|
||||
return InitPointItem(color, parent, z);
|
||||
}
|
||||
|
@ -192,7 +186,7 @@ qreal Visualization::FindVal(const QString &expression, const QHash<QString, qre
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style)
|
||||
void Visualization::DrawPoint(VScaledEllipse *point, const QPointF &pos, const QColor &color, Qt::PenStyle style)
|
||||
{
|
||||
SCASSERT (point != nullptr)
|
||||
|
||||
|
@ -207,7 +201,7 @@ void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, c
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void Visualization::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style)
|
||||
void Visualization::DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style)
|
||||
{
|
||||
SCASSERT (lineItem != nullptr)
|
||||
|
||||
|
@ -224,12 +218,13 @@ void Visualization::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, co
|
|||
void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color,
|
||||
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,
|
||||
const QColor &color, Qt::PenStyle style, Qt::PenCapStyle cap)
|
||||
void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path,
|
||||
const QVector<DirectionArrow> &directionArrows, const QColor &color, Qt::PenStyle style,
|
||||
Qt::PenCapStyle cap)
|
||||
{
|
||||
SCASSERT (pathItem != nullptr)
|
||||
|
||||
|
@ -240,12 +235,12 @@ void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path,
|
|||
|
||||
pathItem->setPen(visPen);
|
||||
pathItem->setPath(path);
|
||||
pathItem->SetDirectionPath(direction);
|
||||
pathItem->SetDirectionArrows(directionArrows);
|
||||
pathItem->setVisible(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *Visualization::GetPointItem(QVector<QGraphicsEllipseItem *> &points, quint32 i,
|
||||
VScaledEllipse *Visualization::GetPointItem(QVector<VScaledEllipse *> &points, quint32 i,
|
||||
const QColor &color, QGraphicsItem *parent)
|
||||
{
|
||||
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
||||
|
@ -262,9 +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->setBrush(QBrush(Qt::NoBrush));
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
|
||||
Q_DECLARE_LOGGING_CATEGORY(vVis)
|
||||
|
||||
class VScaledEllipse;
|
||||
class VScaledLine;
|
||||
|
||||
enum class Mode : char {Creation, Show};
|
||||
|
||||
class Visualization : public QObject
|
||||
|
@ -86,20 +89,16 @@ protected:
|
|||
virtual void InitPen()=0;
|
||||
virtual void AddOnScene()=0;
|
||||
|
||||
template <typename Item>
|
||||
void ScalePenWidth(Item *item, qreal scale);
|
||||
|
||||
void ScalePoint(QGraphicsEllipseItem *item, qreal scale);
|
||||
|
||||
QGraphicsEllipseItem *InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) const;
|
||||
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color,
|
||||
VScaledEllipse *InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) const;
|
||||
void DrawPoint(VScaledEllipse *point, const QPointF &pos, const QColor &color,
|
||||
Qt::PenStyle style = Qt::SolidLine);
|
||||
virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
|
||||
virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color,
|
||||
Qt::PenStyle style = Qt::SolidLine);
|
||||
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color,
|
||||
Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap);
|
||||
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QPainterPath &direction,
|
||||
const QColor &color, Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap);
|
||||
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path,
|
||||
const QVector<DirectionArrow> &directionArrows, const QColor &color,
|
||||
Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap);
|
||||
|
||||
template <typename Item>
|
||||
void AddItem(Item *item);
|
||||
|
@ -107,12 +106,12 @@ protected:
|
|||
template <class Item>
|
||||
Item *InitItem(const QColor &color, QGraphicsItem *parent);
|
||||
|
||||
static QGraphicsEllipseItem* GetPointItem(QVector<QGraphicsEllipseItem *> &points, quint32 i, const QColor &color,
|
||||
static VScaledEllipse *GetPointItem(QVector<VScaledEllipse *> &points, quint32 i, const QColor &color,
|
||||
QGraphicsItem *parent);
|
||||
private:
|
||||
Q_DISABLE_COPY(Visualization)
|
||||
|
||||
static QGraphicsEllipseItem* InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0);
|
||||
static VScaledEllipse* InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -143,18 +142,4 @@ inline Item *Visualization::InitItem(const QColor &color, QGraphicsItem *parent)
|
|||
return item;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class Item>
|
||||
void Visualization::ScalePenWidth(Item *item, qreal scale)
|
||||
{
|
||||
SCASSERT(item != nullptr)
|
||||
|
||||
const qreal width = ScaleWidth(widthMainLine, scale);
|
||||
|
||||
QPen visPen = item->pen();
|
||||
visPen.setWidthF(width);
|
||||
|
||||
item->setPen(visPen);
|
||||
}
|
||||
|
||||
#endif // VISUALIZATION_H
|
||||
|
|
86
src/libs/vwidgets/scalesceneitems.cpp
Normal file
86
src/libs/vwidgets/scalesceneitems.cpp
Normal file
|
@ -0,0 +1,86 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 6, 2017
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2017 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "scalesceneitems.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPen>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VScaledLine::VScaledLine(QGraphicsItem *parent)
|
||||
: QGraphicsLineItem(parent),
|
||||
basicWidth(widthMainLine)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VScaledLine::VScaledLine(const QLineF &line, QGraphicsItem *parent)
|
||||
: QGraphicsLineItem(line, parent),
|
||||
basicWidth(widthMainLine)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VScaledLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QPen lPen = pen();
|
||||
lPen.setWidthF(ScaleWidth(basicWidth, SceneScale(scene())));
|
||||
setPen(lPen);
|
||||
|
||||
QGraphicsLineItem::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VScaledLine::GetBasicWidth() const
|
||||
{
|
||||
return basicWidth;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VScaledLine::SetBasicWidth(const qreal &value)
|
||||
{
|
||||
basicWidth = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VScaledEllipse::VScaledEllipse(QGraphicsItem *parent)
|
||||
: QGraphicsEllipseItem(parent)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VScaledEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
const qreal width = ScaleWidth(widthMainLine, scale);
|
||||
|
||||
QPen visPen = pen();
|
||||
visPen.setWidthF(width);
|
||||
|
||||
setPen(visPen);
|
||||
ScaleCircleSize(this, scale);
|
||||
|
||||
QGraphicsEllipseItem::paint(painter, option, widget);
|
||||
}
|
73
src/libs/vwidgets/scalesceneitems.h
Normal file
73
src/libs/vwidgets/scalesceneitems.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 6, 2017
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2017 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef SCALESCENEITEMS_H
|
||||
#define SCALESCENEITEMS_H
|
||||
|
||||
#include <QGraphicsLineItem>
|
||||
|
||||
#include "../vmisc/def.h"
|
||||
|
||||
class VScaledLine : public QGraphicsLineItem
|
||||
{
|
||||
public:
|
||||
explicit VScaledLine(QGraphicsItem * parent = nullptr);
|
||||
VScaledLine(const QLineF &line, QGraphicsItem * parent = nullptr);
|
||||
virtual ~VScaledLine() = default;
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ScaledLine)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
|
||||
qreal GetBasicWidth() const;
|
||||
void SetBasicWidth(const qreal &value);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VScaledLine)
|
||||
|
||||
qreal basicWidth;
|
||||
};
|
||||
|
||||
class VScaledEllipse : public QGraphicsEllipseItem
|
||||
{
|
||||
public:
|
||||
explicit VScaledEllipse(QGraphicsItem * parent = nullptr);
|
||||
virtual ~VScaledEllipse() = default;
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ScaledEllipse)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VScaledEllipse)
|
||||
};
|
||||
|
||||
#endif // SCALESCENEITEMS_H
|
|
@ -48,6 +48,7 @@
|
|||
#include "vmaingraphicsscene.h"
|
||||
#include "vmaingraphicsview.h"
|
||||
#include "vgraphicssimpletextitem.h"
|
||||
#include "scalesceneitems.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem *parent)
|
||||
|
@ -100,21 +101,13 @@ VControlPointSpline::~VControlPointSpline()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
ScaleLinePenWidth(controlLine, scale);
|
||||
QPen lPen = controlLine->pen();
|
||||
lPen.setColor(CorrectColor(controlLine, Qt::black));
|
||||
controlLine->setPen(lPen);
|
||||
|
||||
VScenePoint::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VControlPointSpline::boundingRect() const
|
||||
{
|
||||
QRectF recTool = VScenePoint::boundingRect();
|
||||
recTool = recTool.united(childrenBoundingRect());
|
||||
return recTool;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief hoverEnterEvent handle hover enter events.
|
||||
|
@ -267,12 +260,8 @@ void VControlPointSpline::Init()
|
|||
this->setBrush(QBrush(Qt::NoBrush));
|
||||
this->setZValue(100);
|
||||
|
||||
controlLine = new QGraphicsLineItem(this);
|
||||
|
||||
QPen cPen = controlLine->pen();
|
||||
cPen.setBrush(QBrush(Qt::red));
|
||||
|
||||
controlLine->setPen(cPen);
|
||||
controlLine = new VScaledLine(this);
|
||||
controlLine->SetBasicWidth(widthHairLine);
|
||||
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ public:
|
|||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
||||
signals:
|
||||
/**
|
||||
* @brief ControlPointChangePosition emit when control point change position.
|
||||
|
@ -81,7 +80,7 @@ public slots:
|
|||
void setEnabledPoint(bool enable);
|
||||
protected:
|
||||
/** @brief controlLine pointer to line control point. */
|
||||
QGraphicsLineItem *controlLine;
|
||||
VScaledLine *controlLine;
|
||||
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -27,20 +27,68 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vcurvepathitem.h"
|
||||
#include "../vwidgets/global.h"
|
||||
#include "../vgeometry/vabstractcurve.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurvePathItem::VCurvePathItem(QGraphicsItem *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)
|
||||
{
|
||||
if (m_direction != QPainterPath())
|
||||
ScalePenWidth();
|
||||
|
||||
const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows,
|
||||
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow,
|
||||
SceneScale(scene())));
|
||||
|
||||
if (arrowsPath != QPainterPath())
|
||||
{
|
||||
painter->save();
|
||||
|
||||
|
@ -49,7 +97,7 @@ void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
|||
|
||||
painter->setPen(arrowPen);
|
||||
painter->setBrush(brush());
|
||||
painter->drawPath(m_direction);
|
||||
painter->drawPath(arrowsPath);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ class VCurvePathItem : public QGraphicsPathItem
|
|||
{
|
||||
public:
|
||||
explicit VCurvePathItem(QGraphicsItem *parent = nullptr);
|
||||
virtual ~VCurvePathItem() = default;
|
||||
|
||||
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
|
@ -45,11 +48,13 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
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:
|
||||
Q_DISABLE_COPY(VCurvePathItem)
|
||||
|
||||
QPainterPath m_direction;
|
||||
QVector<QPair<QLineF, QLineF>> m_directionArrows;
|
||||
};
|
||||
|
||||
#endif // VCURVEPATHITEM_H
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "../vgeometry/vpointf.h"
|
||||
#include "global.h"
|
||||
#include "vgraphicssimpletextitem.h"
|
||||
#include "scalesceneitems.h"
|
||||
|
||||
#include <QBrush>
|
||||
#include <QFont>
|
||||
|
@ -46,7 +47,11 @@ VScenePoint::VScenePoint(QGraphicsItem *parent)
|
|||
m_baseColor(Qt::black)
|
||||
{
|
||||
m_namePoint = new VGraphicsSimpleTextItem(this);
|
||||
m_lineName = new QGraphicsLineItem(this);
|
||||
m_lineName = new VScaledLine(this);
|
||||
m_lineName->SetBasicWidth(widthHairLine);
|
||||
m_lineName->setLine(QLineF(0, 0, 1, 0));
|
||||
m_lineName->setVisible(false);
|
||||
|
||||
this->setBrush(QBrush(Qt::NoBrush));
|
||||
this->setAcceptHoverEvents(true);
|
||||
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)
|
||||
{
|
||||
m_namePoint->setVisible(true);
|
||||
m_lineName->setVisible(true);
|
||||
|
||||
ScaleLinePenWidth(m_lineName, scale);
|
||||
QPen lPen = m_lineName->pen();
|
||||
lPen.setColor(CorrectColor(m_lineName, Qt::black));
|
||||
m_lineName->setPen(lPen);
|
||||
|
||||
RefreshLine();
|
||||
}
|
||||
|
@ -96,14 +102,6 @@ void VScenePoint::RefreshPointGeometry(const VPointF &point)
|
|||
RefreshLine();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VScenePoint::boundingRect() const
|
||||
{
|
||||
QRectF recTool = QGraphicsEllipseItem::boundingRect();
|
||||
recTool = recTool.united(childrenBoundingRect());
|
||||
return recTool;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VScenePoint::SetOnlyPoint(bool value)
|
||||
{
|
||||
|
@ -145,7 +143,6 @@ void VScenePoint::RefreshLine()
|
|||
VGObject::LineIntersectCircle(QPointF(), ScaledRadius(SceneScale(scene())),
|
||||
QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2);
|
||||
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))
|
||||
{
|
||||
|
@ -153,6 +150,7 @@ void VScenePoint::RefreshLine()
|
|||
}
|
||||
else
|
||||
{
|
||||
m_lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||
m_lineName->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
@ -169,13 +167,3 @@ void VScenePoint::ScaleMainPenWidth(qreal scale)
|
|||
|
||||
setPen(QPen(CorrectColor(this, m_baseColor), width));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VScenePoint::ScaleLinePenWidth(QGraphicsLineItem *line, qreal scale)
|
||||
{
|
||||
SCASSERT(line != nullptr)
|
||||
const qreal width = ScaleWidth(widthHairLine, scale);
|
||||
|
||||
line->setPen(QPen(CorrectColor(line, Qt::black), width));
|
||||
}
|
||||
|
||||
|
|
|
@ -34,25 +34,24 @@
|
|||
|
||||
class VGraphicsSimpleTextItem;
|
||||
class VPointF;
|
||||
class VScaledLine;
|
||||
|
||||
class VScenePoint: public QGraphicsEllipseItem
|
||||
{
|
||||
public:
|
||||
explicit VScenePoint(QGraphicsItem *parent = nullptr);
|
||||
~VScenePoint() = default;
|
||||
virtual ~VScenePoint() = default;
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void RefreshPointGeometry(const VPointF &point);
|
||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
||||
|
||||
protected:
|
||||
/** @brief namePoint point label. */
|
||||
VGraphicsSimpleTextItem *m_namePoint;
|
||||
|
||||
/** @brief lineName line what we see if label moved too away from point. */
|
||||
QGraphicsLineItem *m_lineName;
|
||||
VScaledLine *m_lineName;
|
||||
|
||||
bool m_onlyPoint;
|
||||
bool m_isHovered;
|
||||
|
@ -64,7 +63,6 @@ protected:
|
|||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
void RefreshLine();
|
||||
void ScaleLinePenWidth(QGraphicsLineItem *line, qreal scale);
|
||||
|
||||
void SetOnlyPoint(bool value);
|
||||
bool IsOnlyPoint() const;
|
||||
|
|
|
@ -57,30 +57,6 @@ VSimpleCurve::VSimpleCurve(quint32 id, const QSharedPointer<VAbstractCurve> &cur
|
|||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
qreal width = 1;
|
||||
if (m_isHovered)
|
||||
{
|
||||
width = widthMainLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = widthHairLine;
|
||||
}
|
||||
|
||||
const qreal scale = SceneScale(scene());
|
||||
if (scale > 1)
|
||||
{
|
||||
width = qMax(1., width/scale);
|
||||
}
|
||||
|
||||
setPen(QPen(CorrectColor(this, m_curve->GetColor()), width, LineStyleToPenStyle(m_curve->GetPenStyle())));
|
||||
|
||||
VCurvePathItem::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
|
||||
{
|
||||
|
@ -88,7 +64,7 @@ void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
|
|||
|
||||
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());
|
||||
}
|
||||
else
|
||||
|
@ -191,3 +167,20 @@ void VSimpleCurve::keyReleaseEvent(QKeyEvent *event)
|
|||
}
|
||||
QGraphicsPathItem::keyReleaseEvent ( event );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::ScalePenWidth()
|
||||
{
|
||||
qreal width = 1;
|
||||
if (m_isHovered)
|
||||
{
|
||||
width = widthMainLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = widthHairLine;
|
||||
}
|
||||
|
||||
width = ScaleWidth(width, SceneScale(scene()));
|
||||
setPen(QPen(CorrectColor(this, m_curve->GetColor()), width, LineStyleToPenStyle(m_curve->GetPenStyle())));
|
||||
}
|
||||
|
|
|
@ -56,9 +56,6 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::SimpleCurve)};
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
|
||||
|
||||
void RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve);
|
||||
signals:
|
||||
/**
|
||||
|
@ -80,6 +77,7 @@ protected:
|
|||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void ScalePenWidth() Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VSimpleCurve)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user