KiCad PCB EDA Suite
EC_SNAPLINE Class Reference

Class EC_SNAPLINE. More...

#include <edit_constraints.h>

Inheritance diagram for EC_SNAPLINE:
EDIT_CONSTRAINT< EDIT_LINE >

Public Types

typedef boost::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 ()
 
virtual void Apply (EDIT_LINE &aHandle) override
 > More...
 
void Apply ()
 Function Apply() 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

Class EC_SNAPLINE.

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 248 of file edit_constraints.h.

Member Typedef Documentation

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

Typedef for a function that determines snapping point.

Definition at line 252 of file edit_constraints.h.

Constructor & Destructor Documentation

EC_SNAPLINE::EC_SNAPLINE ( EDIT_LINE aLine,
V2D_TRANSFORM_FUN  aSnapFun 
)

Definition at line 180 of file edit_constraints.cpp.

180  :
181  EDIT_CONSTRAINT<EDIT_LINE>( aLine ), m_snapFun( aSnapFun )
182 {}
V2D_TRANSFORM_FUN m_snapFun
Function that determines snapping point.
virtual EC_SNAPLINE::~EC_SNAPLINE ( )
inlinevirtual

Definition at line 256 of file edit_constraints.h.

257  {}

Member Function Documentation

void EDIT_CONSTRAINT< EDIT_LINE >::Apply ( )
inlineinherited

Function Apply()

Corrects coordinates of the constrained edit handle.

Definition at line 66 of file edit_constraints.h.

References EDIT_CONSTRAINT< EDIT_TYPE >::Apply(), and EDIT_CONSTRAINT< EDIT_TYPE >::m_constrained.

67  {
69  }
void Apply()
Function Apply()
EDIT_LINE & m_constrained
Point that is constrained by rules implemented by Apply()
void EC_SNAPLINE::Apply ( EDIT_LINE aHandle)
overridevirtual

>

Function Apply() Corrects coordinates of the constrained edit handle.

Implements EDIT_CONSTRAINT< EDIT_LINE >.

Definition at line 185 of file edit_constraints.cpp.

References delta, EDIT_LINE::GetEnd(), EDIT_LINE::GetOrigin(), EDIT_POINT::GetPosition(), m_snapFun, and EDIT_POINT::SetPosition().

186 {
187  VECTOR2D delta = aHandle.GetEnd().GetPosition() - aHandle.GetOrigin().GetPosition();
188 
189  aHandle.GetOrigin().SetPosition( m_snapFun( aHandle.GetOrigin().GetPosition() ) );
190  aHandle.GetEnd().SetPosition( aHandle.GetOrigin().GetPosition() + delta );
191 }
static const int delta[8][2]
Definition: solve.cpp:112
EDIT_POINT & GetOrigin()
Function GetOrigin()
Definition: edit_points.h:256
EDIT_POINT & GetEnd()
Function GetEnd()
Definition: edit_points.h:271
V2D_TRANSFORM_FUN m_snapFun
Function that determines snapping point.
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()
Definition: edit_points.h:97

Member Data Documentation

EDIT_LINE & EDIT_CONSTRAINT< EDIT_LINE >::m_constrained
protectedinherited

Point that is constrained by rules implemented by Apply()

Definition at line 72 of file edit_constraints.h.

V2D_TRANSFORM_FUN EC_SNAPLINE::m_snapFun
private

Function that determines snapping point.

Definition at line 264 of file edit_constraints.h.

Referenced by Apply().


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