KiCad PCB EDA Suite
EC_45DEGREE Class Reference

EDIT_CONSTRAINT that imposes a constraint that two points have to be located at angle of 45 degree multiplicity. More...

#include <edit_constraints.h>

Inheritance diagram for EC_45DEGREE:
EDIT_CONSTRAINT< EDIT_POINT >

Public Member Functions

 EC_45DEGREE (EDIT_POINT &aConstrained, const EDIT_POINT &aConstrainer)
 Correct coordinates of the constrained edit handle. More...
 
virtual void Apply (EDIT_POINT &aHandle) override
 Correct coordinates of the constrained edit handle. More...
 
void Apply ()
 Correct coordinates of the constrained edit handle. More...
 

Protected Attributes

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

Private Attributes

const EDIT_POINTm_constrainer
 Point that imposes the constraint. More...
 

Detailed Description

EDIT_CONSTRAINT that imposes a constraint that two points have to be located at angle of 45 degree multiplicity.

Definition at line 129 of file edit_constraints.h.

Constructor & Destructor Documentation

◆ EC_45DEGREE()

EC_45DEGREE::EC_45DEGREE ( EDIT_POINT aConstrained,
const EDIT_POINT aConstrainer 
)
inline

Correct coordinates of the constrained edit handle.

Parameters
aConstrainedis the point that is put under constrain.
aConstraineris the point that is the source of the constrain.

Definition at line 136 of file edit_constraints.h.

Member Function Documentation

◆ Apply() [1/2]

void EDIT_CONSTRAINT< EDIT_POINT >::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_POINT & m_constrained
Point that is constrained by rules implemented by Apply().

◆ Apply() [2/2]

void EC_45DEGREE::Apply ( EDIT_POINT aHandle)
overridevirtual

Correct coordinates of the constrained edit handle.

Implements EDIT_CONSTRAINT< EDIT_POINT >.

Definition at line 54 of file edit_constraints.cpp.

55 {
56  VECTOR2I lineVector( aHandle.GetPosition() - m_constrainer.GetPosition() );
57  VECTOR2I newLineVector = GetVectorSnapped45( lineVector );
58 
59  aHandle.SetPosition( m_constrainer.GetPosition() + newLineVector );
60 }
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:70
const EDIT_POINT & m_constrainer
Point that imposes the constraint.
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
Definition: edit_points.h:106

References EDIT_POINT::GetPosition(), GetVectorSnapped45(), m_constrainer, and EDIT_POINT::SetPosition().

Member Data Documentation

◆ m_constrained

EDIT_POINT & EDIT_CONSTRAINT< EDIT_POINT >::m_constrained
protectedinherited

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

Definition at line 77 of file edit_constraints.h.

◆ m_constrainer

const EDIT_POINT& EC_45DEGREE::m_constrainer
private

Point that imposes the constraint.

Definition at line 144 of file edit_constraints.h.

Referenced by Apply().


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