Seamly2D
Code documentation
VGObject Class Reference

The VGObject class keep information graphical objects. More...

#include <vgobject.h>

Inheritance diagram for VGObject:
Collaboration diagram for VGObject:

Public Member Functions

 VGObject ()
 VGObject default constructor. More...
 
 VGObject (const GOType &type, const quint32 &idObject=0, const Draw &mode=Draw::Calculation)
 VGObject constructor. More...
 
 VGObject (const VGObject &obj)
 VGObject copy constructor. More...
 
virtual ~VGObject ()
 
VGObjectoperator= (const VGObject &obj)
 operator = assignment operator. More...
 
void Swap (VGObject &obj) Q_DECL_NOTHROW
 
quint32 getIdObject () const
 getIdObject return parent id. More...
 
void setIdObject (const quint32 &value)
 setIdObject set parent id. More...
 
virtual QString name () const
 name return name graphical object. More...
 
void setName (const QString &name)
 setName set name graphical object. More...
 
Draw getMode () const
 getMode return mode creation. More...
 
void setMode (const Draw &value)
 setMode set mode creation. More...
 
GOType getType () const
 getType return object type. More...
 
void setType (const GOType &type)
 
quint32 id () const
 id return id object. More...
 
virtual void setId (const quint32 &id)
 setId set id object. More...
 
quint32 getIdTool () const
 

Static Public Member Functions

static QLineF BuildLine (const QPointF &p1, const qreal &length, const qreal &angle)
 
static QPointF BuildRay (const QPointF &firstPoint, const qreal &angle, const QRectF &scRect)
 
static QLineF BuildAxis (const QPointF &p, const qreal &angle, const QRectF &scRect)
 
static QLineF BuildAxis (const QPointF &p1, const QPointF &p2, const QRectF &scRect)
 
static int ContactPoints (const QPointF &p, const QPointF &center, qreal radius, QPointF &p1, QPointF &p2)
 
static QPointF LineIntersectRect (const QRectF &rec, const QLineF &line)
 LineIntersectRect find point intersection line and rect. More...
 
static int IntersectionCircles (const QPointF &c1, double r1, const QPointF &c2, double r2, QPointF &p1, QPointF &p2)
 
static qint32 LineIntersectCircle (const QPointF &center, qreal radius, const QLineF &line, QPointF &p1, QPointF &p2)
 LineIntersectCircle find point intersection line and circle. More...
 
static QPointF ClosestPoint (const QLineF &line, const QPointF &point)
 ClosestPoint find point projection of point onto line. More...
 
static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k)
 
static void LineCoefficients (const QLineF &line, qreal *a, qreal *b, qreal *c)
 LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0. More...
 
static bool IsPointOnLineSegment (const QPointF &t, const QPointF &p1, const QPointF &p2)
 IsPointOnLineSegment Check if the point is on the line segment. More...
 
static bool IsPointOnLineviaPDP (const QPointF &t, const QPointF &p1, const QPointF &p2)
 IsPointOnLineviaPDP use the perp dot product (PDP) way. More...
 
template<typename T >
static QVector< T > GetReversePoints (const QVector< T > &points)
 GetReversePoint return revers container of points. More...
 
static int GetLengthContour (const QVector< QPointF > &contour, const QVector< QPointF > &newPoints)
 GetLengthContour return length of contour. More...
 

Static Public Attributes

static const double accuracyPointOnLine = (0.1555 / 25.4) * 96.0
 

Static Protected Member Functions

static QTransform flipTransform (const QLineF &axis)
 

Static Private Member Functions

static double PerpDotProduct (const QPointF &p1, const QPointF &p2, const QPointF &t)
 PerpDotProduct Calculates the area of the parallelogram of the three points. This is actually the same as the area of the triangle defined by the three points, multiplied by 2. More...
 
static double GetEpsilon (const QPointF &p1, const QPointF &p2)
 GetEpsilon solve the floating-point accuraccy problem. More...
 
static int PointInCircle (const QPointF &p, const QPointF &center, qreal radius)
 

Private Attributes

QSharedDataPointer< VGObjectDatad
 

Detailed Description

The VGObject class keep information graphical objects.

Definition at line 73 of file vgobject.h.

Constructor & Destructor Documentation

◆ VGObject() [1/3]

VGObject::VGObject ( )

VGObject default constructor.

Definition at line 79 of file vgobject.cpp.

◆ VGObject() [2/3]

VGObject::VGObject ( const GOType type,
const quint32 &  idObject = 0,
const Draw mode = Draw::Calculation 
)
explicit

VGObject constructor.

Parameters
typetype graphical object.
idObjectid parent object.
modemode creation. Used in modeling mode.

Definition at line 90 of file vgobject.cpp.

◆ VGObject() [3/3]

VGObject::VGObject ( const VGObject obj)

VGObject copy constructor.

Parameters
objobject.

Definition at line 99 of file vgobject.cpp.

◆ ~VGObject()

VGObject::~VGObject ( )
virtual

Definition at line 120 of file vgobject.cpp.

Member Function Documentation

◆ addVector()

QPointF VGObject::addVector ( const QPointF &  p,
const QPointF &  p1,
const QPointF &  p2,
qreal  k 
)
static

Definition at line 456 of file vgobject.cpp.

Referenced by LineIntersectCircle().

◆ BuildAxis() [1/2]

QLineF VGObject::BuildAxis ( const QPointF &  p,
const qreal &  angle,
const QRectF &  scRect 
)
static

Definition at line 271 of file vgobject.cpp.

References BuildRay().

Referenced by BuildAxis().

◆ BuildAxis() [2/2]

QLineF VGObject::BuildAxis ( const QPointF &  p1,
const QPointF &  p2,
const QRectF &  scRect 
)
static

Definition at line 279 of file vgobject.cpp.

References BuildAxis().

◆ BuildLine()

QLineF VGObject::BuildLine ( const QPointF &  p1,
const qreal &  length,
const qreal &  angle 
)
static

◆ BuildRay()

QPointF VGObject::BuildRay ( const QPointF &  firstPoint,
const qreal &  angle,
const QRectF &  scRect 
)
static

Definition at line 251 of file vgobject.cpp.

References BuildLine(), and LineIntersectRect().

Referenced by BuildAxis(), VToolCurveIntersectAxis::FindPoint(), and VisLine::Ray().

◆ ClosestPoint()

QPointF VGObject::ClosestPoint ( const QLineF &  line,
const QPointF &  point 
)
static

ClosestPoint find point projection of point onto line.

Parameters
lineline.
Returns
point on line or extended line if origin size too small.

Definition at line 436 of file vgobject.cpp.

References LineCoefficients().

Referenced by VToolHeight::FindPoint(), LineIntersectCircle(), and DialogHeight::PointNameChanged().

◆ ContactPoints()

int VGObject::ContactPoints ( const QPointF &  p,
const QPointF &  center,
qreal  radius,
QPointF &  p1,
QPointF &  p2 
)
static

◆ flipTransform()

QTransform VGObject::flipTransform ( const QLineF &  axis)
staticprotected

Definition at line 591 of file vgobject.cpp.

Referenced by VEllipticalArc::Flip(), and VPointF::FlipPF().

◆ GetEpsilon()

double VGObject::GetEpsilon ( const QPointF &  p1,
const QPointF &  p2 
)
staticprivate

GetEpsilon solve the floating-point accuraccy problem.

There is the floating-point accuraccy problem, so instead of checking against zero, some epsilon value has to be used. Because the size of the pdp value depends on the length of the vectors, no static value can be used. One approach is to compare the pdp/area value to the fraction of another area which also depends on the length of the line e1=(p1, p2), e.g. the minimal area calucalted with PerpDotProduc() if point still not on the line. This distance is controled by variable accuracyPointOnLine

Definition at line 545 of file vgobject.cpp.

References accuracyPointOnLine, and PerpDotProduct().

Referenced by IsPointOnLineviaPDP().

◆ getIdObject()

quint32 VGObject::getIdObject ( ) const

getIdObject return parent id.

Returns
parent id or 0 if object don't have parent.

Definition at line 128 of file vgobject.cpp.

References d.

Referenced by VEllipticalArc::CutArc(), VArc::CutArc(), and MainWindow::zoomToPoint().

◆ getIdTool()

◆ GetLengthContour()

int VGObject::GetLengthContour ( const QVector< QPointF > &  contour,
const QVector< QPointF > &  newPoints 
)
static

GetLengthContour return length of contour.

Parameters
contourcontainer with points of contour.
newPointspoint whos we try to add to contour.
Returns
length length of contour.

Definition at line 577 of file vgobject.cpp.

◆ getMode()

Draw VGObject::getMode ( ) const

getMode return mode creation.

Returns
mode.

Definition at line 168 of file vgobject.cpp.

References d.

Referenced by VEllipticalArc::CutArc(), and VArc::CutArc().

◆ GetReversePoints()

template<typename T >
QVector< T > VGObject::GetReversePoints ( const QVector< T > &  points)
static

GetReversePoint return revers container of points.

Parameters
pointscontainer with points.
Returns
reverced points.

Definition at line 145 of file vgobject.h.

Referenced by VAbstractCurve::GetSegmentPoints(), VPiece::GetUnitedPath(), VPiecePath::SeamAllowancePoints(), and VAbstractCurve::ToEnd().

◆ getType()

GOType VGObject::getType ( ) const

getType return object type.

Returns
type.

Definition at line 188 of file vgobject.cpp.

References d.

◆ id()

◆ IntersectionCircles()

int VGObject::IntersectionCircles ( const QPointF &  c1,
double  r1,
const QPointF &  c2,
double  r2,
QPointF &  p1,
QPointF &  p2 
)
static

◆ IsPointOnLineSegment()

bool VGObject::IsPointOnLineSegment ( const QPointF &  t,
const QPointF &  p1,
const QPointF &  p2 
)
static

IsPointOnLineSegment Check if the point is on the line segment.

Original idea http://www.sunshine2k.de/coding/java/PointOnLine/PointOnLine.html

Definition at line 484 of file vgobject.cpp.

References accuracyPointOnLine, and IsPointOnLineviaPDP().

Referenced by VToolPointOfContact::FindPoint(), VAbstractCurve::FromBegin(), and VAbstractCurve::isPointOnCurve().

◆ IsPointOnLineviaPDP()

bool VGObject::IsPointOnLineviaPDP ( const QPointF &  t,
const QPointF &  p1,
const QPointF &  p2 
)
static

IsPointOnLineviaPDP use the perp dot product (PDP) way.

The pdp is zero only if the t lies on the line e1 = vector from p1 to p2.

Returns
true if point is on line

Definition at line 516 of file vgobject.cpp.

References GetEpsilon(), PerpDotProduct(), and VFuzzyComparePossibleNulls().

Referenced by VAbstractPiece::CheckLoops(), VAbstractPiece::IsEkvPointOnLine(), and IsPointOnLineSegment().

◆ LineCoefficients()

void VGObject::LineCoefficients ( const QLineF &  line,
qreal *  a,
qreal *  b,
qreal *  c 
)
static

LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0.

Parameters
lineline
aa value
bb value
cc value

Definition at line 469 of file vgobject.cpp.

Referenced by ClosestPoint(), and LineIntersectCircle().

◆ LineIntersectCircle()

qint32 VGObject::LineIntersectCircle ( const QPointF &  center,
qreal  radius,
const QLineF &  line,
QPointF &  p1,
QPointF &  p2 
)
static

LineIntersectCircle find point intersection line and circle.

Parameters
centerarc center.
radiusarc radius.
lineline
p1first intersection point.
p2second intersection point.
Returns
0 - intersection doesn't exist, 1 - one intersection point, 2 - two intersection points.

Definition at line 391 of file vgobject.cpp.

References addVector(), ClosestPoint(), d, LineCoefficients(), and VFuzzyComparePossibleNulls().

Referenced by VToolShoulderPoint::FindPoint(), VToolPointOfContact::FindPoint(), VScenePoint::refreshLeader(), and VControlPointSpline::setCtrlLine().

◆ LineIntersectRect()

QPointF VGObject::LineIntersectRect ( const QRectF &  rec,
const QLineF &  line 
)
static

LineIntersectRect find point intersection line and rect.

Parameters
recrect.
lineline.
Returns
point intersection.

Definition at line 313 of file vgobject.cpp.

Referenced by BuildRay(), and VScenePoint::refreshLeader().

◆ name()

QString VGObject::name ( ) const
virtual

name return name graphical object.

Returns
name

Definition at line 148 of file vgobject.cpp.

References d.

Referenced by VContainer::AddGObject(), VToolPointFromArcAndTangent::Create(), VAbstractCubicBezier::CreateName(), VAbstractCubicBezierPath::CreateName(), VArc::CreateName(), VEllipticalArc::CreateName(), DialogCubicBezierPath::currentPointChanged(), DialogSplinePath::currentPointChanged(), DialogSplinePath::EvalAngle1(), DialogSplinePath::EvalAngle2(), DialogSplinePath::EvalLength1(), DialogSplinePath::EvalLength2(), VToolCubicBezier::FirstPointName(), VArc::Flip(), VCubicBezier::Flip(), VCubicBezierPath::Flip(), VEllipticalArc::Flip(), VPointF::Flip(), VSpline::Flip(), VSplinePath::Flip(), VToolCubicBezier::ForthPointName(), VToolCurveIntersectAxis::InitSegments(), VToolCutSpline::makeToolTip(), VToolCutSplinePath::makeToolTip(), VArc::Move(), VCubicBezier::Move(), VCubicBezierPath::Move(), VEllipticalArc::Move(), VPointF::Move(), VSpline::Move(), VSplinePath::Move(), VAbstractArc::NameForHistory(), VAbstractCubicBezier::NameForHistory(), VAbstractCubicBezierPath::NameForHistory(), DialogCubicBezierPath::NewItem(), DialogSplinePath::NewItem(), DialogArc::pointNameChanged(), DialogArcWithLength::pointNameChanged(), DialogEllipticalArc::pointNameChanged(), DialogCubicBezier::PointNameChanged(), DialogSpline::PointNameChanged(), VScenePoint::refreshPointGeometry(), VArc::Rotate(), VCubicBezier::Rotate(), VCubicBezierPath::Rotate(), VPointF::Rotate(), VSpline::Rotate(), VSplinePath::Rotate(), VEllipticalArc::Rotate(), VToolDoublePoint::SaveOptions(), VToolCubicBezier::SecondPointName(), DialogArc::setArc(), DialogArcWithLength::setArc(), DialogEllipticalArc::setArc(), setName(), DialogCubicBezierPath::SetPath(), DialogSplinePath::SetPath(), DialogCubicBezier::SetSpline(), DialogSpline::SetSpline(), DialogCubicBezierPath::ShowDialog(), DialogSpline::ShowDialog(), DialogSplinePath::ShowDialog(), VToolCubicBezier::ThirdPointName(), VToolOptionsPropertyBrowser::updateOptionsToolSpline(), VArcRadius::VArcRadius(), VCurveAngle::VCurveAngle(), VCurveCLength::VCurveCLength(), VCurveLength::VCurveLength(), VLengthLine::VLengthLine(), VLineAngle::VLineAngle(), and VPointF::VPointF().

◆ operator=()

VGObject & VGObject::operator= ( const VGObject obj)

operator = assignment operator.

Parameters
objobject
Returns
object

Definition at line 109 of file vgobject.cpp.

References d.

Referenced by VAbstractCurve::operator=(), and VPointF::operator=().

◆ PerpDotProduct()

double VGObject::PerpDotProduct ( const QPointF &  p1,
const QPointF &  p2,
const QPointF &  t 
)
staticprivate

PerpDotProduct Calculates the area of the parallelogram of the three points. This is actually the same as the area of the triangle defined by the three points, multiplied by 2.

Returns
2 * triangleArea(a,b,c)

Definition at line 530 of file vgobject.cpp.

Referenced by GetEpsilon(), and IsPointOnLineviaPDP().

◆ PointInCircle()

int VGObject::PointInCircle ( const QPointF &  p,
const QPointF &  center,
qreal  radius 
)
staticprivate

Definition at line 555 of file vgobject.cpp.

References d, and VFuzzyComparePossibleNulls().

Referenced by ContactPoints().

◆ setId()

void VGObject::setId ( const quint32 &  id)
virtual

setId set id object.

Parameters
idid.

Reimplemented in VAbstractArc.

Definition at line 215 of file vgobject.cpp.

References d, and id().

Referenced by VContainer::GetFakeGObject(), and VAbstractArc::setId().

◆ setIdObject()

void VGObject::setIdObject ( const quint32 &  value)

setIdObject set parent id.

Parameters
valueparent id.

Definition at line 138 of file vgobject.cpp.

References d.

Referenced by VPattern::ParseNodeArc(), VPattern::ParseNodeEllipticalArc(), VPattern::ParseNodeSpline(), and VPattern::ParseNodeSplinePath().

◆ setMode()

void VGObject::setMode ( const Draw value)

◆ setName()

◆ setType()

void VGObject::setType ( const GOType type)

Definition at line 195 of file vgobject.cpp.

References d.

◆ Swap()

void VGObject::Swap ( VGObject obj)

Definition at line 72 of file vgobject.cpp.

Referenced by VAbstractCurve::Swap(), and VPointF::Swap().

Member Data Documentation

◆ accuracyPointOnLine

const double VGObject::accuracyPointOnLine = (0.1555 / 25.4) * 96.0
static

◆ d


The documentation for this class was generated from the following files: