KiCad PCB EDA Suite
EC_PERPLINE Class Reference

EDIT_CONSTRAINT for a EDIT_LINE, that constrains the line to move perpendicular to the line itself. More...

#include <edit_constraints.h>

Inheritance diagram for EC_PERPLINE:
EDIT_CONSTRAINT< EDIT_LINE >

Public Member Functions

 EC_PERPLINE (EDIT_LINE &aLine)
 
virtual ~EC_PERPLINE ()
 Correct coordinates of the constrained edit handle. More...
 
virtual void Apply (EDIT_LINE &aHandle) override
 Correct coordinates of the constrained edit handle. More...
 
void Apply ()
 Correct coordinates of the constrained edit handle. More...
 

Protected Attributes

EDIT_LINEm_constrained
 Point that is constrained by rules implemented by Apply(). More...
 

Private Attributes

VECTOR2I m_mid
 
VECTOR2I m_line
 

Detailed Description

EDIT_CONSTRAINT for a EDIT_LINE, that constrains the line to move perpendicular to the line itself.

Definition at line 255 of file edit_constraints.h.

Constructor & Destructor Documentation

◆ EC_PERPLINE()

EC_PERPLINE::EC_PERPLINE ( EDIT_LINE aLine)

Definition at line 199 of file edit_constraints.cpp.

199  :
201 {
202  m_mid = aLine.GetPosition();
203  m_line = ( aLine.GetEnd().GetPosition() - aLine.GetOrigin().GetPosition() ).Perpendicular();
204 }
virtual VECTOR2I GetPosition() const override
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:231
EDIT_POINT & GetOrigin()
Return the origin EDIT_POINT.
Definition: edit_points.h:277
EDIT_POINT & GetEnd()
Return the end EDIT_POINT.
Definition: edit_points.h:290
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:70

References EDIT_LINE::GetEnd(), EDIT_LINE::GetOrigin(), EDIT_POINT::GetPosition(), EDIT_LINE::GetPosition(), m_line, and m_mid.

◆ ~EC_PERPLINE()

virtual EC_PERPLINE::~EC_PERPLINE ( )
inlinevirtual

Correct coordinates of the constrained edit handle.

Definition at line 261 of file edit_constraints.h.

Member Function Documentation

◆ Apply() [1/2]

void EDIT_CONSTRAINT< EDIT_LINE >::Apply ( )
inlineinherited

Correct coordinates of the constrained edit handle.

Definition at line 71 of file edit_constraints.h.

72  {
74  }
void Apply()
Correct coordinates of the constrained edit handle.
EDIT_LINE & m_constrained
Point that is constrained by rules implemented by Apply().

◆ Apply() [2/2]

void EC_PERPLINE::Apply ( EDIT_LINE aHandle)
overridevirtual

Correct coordinates of the constrained edit handle.

Implements EDIT_CONSTRAINT< EDIT_LINE >.

Definition at line 207 of file edit_constraints.cpp.

208 {
209  SEG main( m_mid, m_mid + m_line );
210  SEG projection( aHandle.GetPosition(), aHandle.GetPosition() + m_line.Perpendicular() );
211 
212  if( OPT_VECTOR2I intersect = projection.IntersectLines( main ) )
213  aHandle.SetPosition( *intersect );
214 
215  VECTOR2D delta = aHandle.GetEnd().GetPosition() - aHandle.GetOrigin().GetPosition();
216 
217  aHandle.GetOrigin().SetPosition( aHandle.GetOrigin().GetPosition() );
218  aHandle.GetEnd().SetPosition( aHandle.GetOrigin().GetPosition() + delta );
219 }
main()
VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
Definition: vector2d.h:314
virtual VECTOR2I GetPosition() const override
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:231
static bool intersect(const SEGMENT_WITH_NORMALS &aSeg, const SFVEC2F &aStart, const SFVEC2F &aEnd)
Definition: polygon_2d.cpp:273
EDIT_POINT & GetOrigin()
Return the origin EDIT_POINT.
Definition: edit_points.h:277
EDIT_POINT & GetEnd()
Return the end EDIT_POINT.
Definition: edit_points.h:290
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:70
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:38
virtual void SetPosition(const VECTOR2I &aPosition) override
Correct coordinates of an EDIT_POINT by applying previously set constraint.
Definition: edit_points.h:237
Definition: seg.h:40
constexpr int delta
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
Definition: edit_points.h:106

References delta, EDIT_LINE::GetEnd(), EDIT_LINE::GetOrigin(), EDIT_POINT::GetPosition(), EDIT_LINE::GetPosition(), intersect(), m_line, m_mid, main(), VECTOR2< T >::Perpendicular(), EDIT_POINT::SetPosition(), and EDIT_LINE::SetPosition().

Member Data Documentation

◆ m_constrained

EDIT_LINE & EDIT_CONSTRAINT< EDIT_LINE >::m_constrained
protectedinherited

Point that is constrained by rules implemented by Apply().

Definition at line 77 of file edit_constraints.h.

◆ m_line

VECTOR2I EC_PERPLINE::m_line
private

Definition at line 269 of file edit_constraints.h.

Referenced by Apply(), and EC_PERPLINE().

◆ m_mid

VECTOR2I EC_PERPLINE::m_mid
private

Definition at line 268 of file edit_constraints.h.

Referenced by Apply(), and EC_PERPLINE().


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