32 auto relation = std::unique_ptr<EDIT_RELATION>(
new EDIT_RELATION( aKind ) );
33 relation->m_reference = &aReference;
74 relation->m_secondaryReference = &aEnd;
144 point.
y = gridPoint.
y;
146 point.
x = gridPoint.
x;
179 m_prevOrigin( aPoints.Previous( aLine.GetOrigin(), false ) ),
180 m_nextEnd( aPoints.Next( aLine.GetEnd(), false ) )
196 constexpr int alignAngle = 10;
198 m_endCollinear = dragged.Angle( endSide ).AsDegrees() < alignAngle;
200 if(
OPT_VECTOR2I intersection = originSide.IntersectLines( endSide ) )
214 newCenter = *intersection;
222 if( denominator != 0 &&
double( centerToNew.
Dot(
m_perpVector ) ) /
double( denominator ) > 1.0 )
248 point->SetPosition( line.
LineProject( point->GetPosition() ) );
262 end.SetPosition( *intersection );
272 end.SetPosition( *intersection );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Represent a line connecting two EDIT_POINTs.
virtual void SetPosition(const VECTOR2I &aPosition) override
Return coordinates of an EDIT_POINT.
EDIT_POINT & GetEnd()
Return the end EDIT_POINT.
EDIT_POINT & GetOrigin()
Return the origin EDIT_POINT.
virtual VECTOR2I GetPosition() const override
Return coordinates of an EDIT_POINT.
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
Represent a single point that can be used for modifying items.
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
GRID_CONSTRAINT_TYPE GetGridConstraint() const
static std::unique_ptr< EDIT_RELATION > Angle90(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > Angle45(const EDIT_POINT &aReference)
EDIT_RELATION(EDIT_RELATION_KIND aKind)
const EDIT_POINT * m_secondaryReference
static std::unique_ptr< EDIT_RELATION > SameY(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > PerpendicularTranslation(const EDIT_LINE &aLine)
const EDIT_POINT * m_reference
EDIT_RELATION_KIND m_kind
void Apply(EDIT_POINT &aHandle, const GRID_HELPER &aGrid) const
static std::unique_ptr< EDIT_RELATION > PointOnCircle(const EDIT_POINT &aCenter, const EDIT_POINT &aEnd)
static std::unique_ptr< EDIT_RELATION > SameX(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > make(EDIT_RELATION_KIND aKind, const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > PointOnLine(const EDIT_POINT &aConstrained, const EDIT_POINT &aReference)
virtual VECTOR2I AlignGrid(const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
void Apply(EDIT_LINE &aHandle, const GRID_HELPER &aGrid)
EDIT_POINTS & m_editPoints
VECTOR2I m_endSideDirection
void applyFixedLength(EDIT_LINE &aHandle)
VECTOR2I m_originalCenter
POLYGON_EDGE_DRAG_POLICY(EDIT_LINE &aLine, EDIT_POINTS &aPoints, POLYGON_LINE_MODE aMode=POLYGON_LINE_MODE::CONVERGING)
VECTOR2I m_originSideDirection
EDIT_POINT * m_prevOrigin
VECTOR2I m_convergencePoint
void applyConverging(EDIT_LINE &aHandle)
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
constexpr VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
@ PERPENDICULAR_TRANSLATION
a few functions useful in geometry calculations.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
VECTOR2< T > GetVectorSnapped90(const VECTOR2< T > &aVec)
Snap a vector onto the nearest horizontal or vertical line.
std::optional< VECTOR2I > OPT_VECTOR2I
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D