KiCad PCB EDA Suite
EC_SNAPLINE Class Reference

EDIT_CONSTRAINT for a EDIT_LINE, one of the ends is snapped to a spot determined by a transform function passed as parameter (e.g. More...

#include <edit_constraints.h>

Inheritance diagram for EC_SNAPLINE:
EDIT_CONSTRAINT< EDIT_LINE >

Public Types

typedef std::function< VECTOR2D(const VECTOR2D &)> V2D_TRANSFORM_FUN
 < Typedef for a function that determines snapping point. More...
 

Public Member Functions

 EC_SNAPLINE (EDIT_LINE &aLine, V2D_TRANSFORM_FUN aSnapFun)
 
virtual ~EC_SNAPLINE ()
 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

V2D_TRANSFORM_FUN m_snapFun
 < Function that determines snapping point. More...
 

Detailed Description

EDIT_CONSTRAINT for a EDIT_LINE, one of the ends is snapped to a spot determined by a transform function passed as parameter (e.g.

it can be snapped to a grid), instead of having the line center snapped to a point.

Definition at line 231 of file edit_constraints.h.

Member Typedef Documentation

◆ V2D_TRANSFORM_FUN

typedef std::function<VECTOR2D( const VECTOR2D& )> EC_SNAPLINE::V2D_TRANSFORM_FUN

< Typedef for a function that determines snapping point.

Definition at line 235 of file edit_constraints.h.

Constructor & Destructor Documentation

◆ EC_SNAPLINE()

EC_SNAPLINE::EC_SNAPLINE ( EDIT_LINE aLine,
V2D_TRANSFORM_FUN  aSnapFun 
)

Definition at line 185 of file edit_constraints.cpp.

185  :
186  EDIT_CONSTRAINT<EDIT_LINE>( aLine ), m_snapFun( std::move(aSnapFun) )
187 {}
V2D_TRANSFORM_FUN m_snapFun
< Function that determines snapping point.

References move.

◆ ~EC_SNAPLINE()

virtual EC_SNAPLINE::~EC_SNAPLINE ( )
inlinevirtual

Correct coordinates of the constrained edit handle.

Definition at line 239 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_SNAPLINE::Apply ( EDIT_LINE aHandle)
overridevirtual

Correct coordinates of the constrained edit handle.

Implements EDIT_CONSTRAINT< EDIT_LINE >.

Definition at line 190 of file edit_constraints.cpp.

191 {
192  VECTOR2D delta = aHandle.GetEnd().GetPosition() - aHandle.GetOrigin().GetPosition();
193 
194  aHandle.GetOrigin().SetPosition( m_snapFun( aHandle.GetOrigin().GetPosition() ) );
195  aHandle.GetEnd().SetPosition( aHandle.GetOrigin().GetPosition() + delta );
196 }
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
V2D_TRANSFORM_FUN m_snapFun
< Function that determines snapping point.
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(), m_snapFun, and EDIT_POINT::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_snapFun

V2D_TRANSFORM_FUN EC_SNAPLINE::m_snapFun
private

< Function that determines snapping point.

Definition at line 247 of file edit_constraints.h.

Referenced by Apply().


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