KiCad PCB EDA Suite
EDIT_POINT Class Reference

Class EDIT_POINT. More...

#include <edit_points.h>

Inheritance diagram for EDIT_POINT:
EDIT_LINE

Public Member Functions

 EDIT_POINT (const VECTOR2I &aPoint)
 Constructor. More...
 
virtual ~EDIT_POINT ()
 
virtual VECTOR2I GetPosition () const
 Function GetPosition() More...
 
int GetX () const
 Function GetX() More...
 
int GetY () const
 Function GetY() More...
 
virtual void SetPosition (const VECTOR2I &aPosition)
 Function SetPosition() More...
 
bool WithinPoint (const VECTOR2I &aPoint, unsigned int aSize) const
 Function WithinPoint() More...
 
void SetConstraint (EDIT_CONSTRAINT< EDIT_POINT > *aConstraint)
 Function SetConstraint() More...
 
EDIT_CONSTRAINT< EDIT_POINT > * GetConstraint () const
 Function GetConstraint() More...
 
void ClearConstraint ()
 Function ClearConstraint() More...
 
bool IsConstrained () const
 Function IsConstrained() More...
 
virtual void ApplyConstraint ()
 Function ApplyConstraint() More...
 
bool operator== (const EDIT_POINT &aOther) const
 

Static Public Attributes

static const int POINT_SIZE = 10
 

Single point size in pixels

More...
 

Private Attributes

VECTOR2I m_position
 

Position of EDIT_POINT

More...
 
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
 

Constraint for the point, NULL if none

More...
 

Detailed Description

Class EDIT_POINT.

Represents a single point that can be used for modifying items. It is directly related to one of points in a graphical item (e.g. vertex of a zone or center of a circle).

Definition at line 46 of file edit_points.h.

Constructor & Destructor Documentation

EDIT_POINT::EDIT_POINT ( const VECTOR2I aPoint)
inline

Constructor.

Parameters
aPointstores coordinates for EDIT_POINT.

Definition at line 54 of file edit_points.h.

54  :
55  m_position( aPoint ) {};
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:175
virtual EDIT_POINT::~EDIT_POINT ( )
inlinevirtual

Definition at line 57 of file edit_points.h.

57 {}

Member Function Documentation

virtual void EDIT_POINT::ApplyConstraint ( )
inlinevirtual

Function ApplyConstraint()

Corrects coordinates of an EDIT_POINT by applying previously set constraint.

Reimplemented in EDIT_LINE.

Definition at line 159 of file edit_points.h.

References m_constraint.

Referenced by EDIT_LINE::ApplyConstraint(), and POINT_EDITOR::OnSelectionChange().

160  {
161  if( m_constraint )
162  m_constraint->Apply();
163  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:178
void EDIT_POINT::ClearConstraint ( )
inline

Function ClearConstraint()

Removes previously set constraint.

Definition at line 138 of file edit_points.h.

References m_constraint.

139  {
140  m_constraint.reset();
141  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:178
EDIT_CONSTRAINT<EDIT_POINT>* EDIT_POINT::GetConstraint ( ) const
inline

Function GetConstraint()

Returns the constraint imposed on an EDIT_POINT. If there are no constraints, NULL is returned.

Definition at line 128 of file edit_points.h.

References m_constraint.

129  {
130  return m_constraint.get();
131  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:178
virtual VECTOR2I EDIT_POINT::GetPosition ( ) const
inlinevirtual
int EDIT_POINT::GetX ( ) const
inline

Function GetX()

Returns X coordinate of an EDIT_POINT.

Definition at line 75 of file edit_points.h.

References GetPosition(), and VECTOR2< T >::x.

76  {
77  return GetPosition().x;
78  }
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
int EDIT_POINT::GetY ( ) const
inline

Function GetY()

Returns Y coordinate of an EDIT_POINT.

Definition at line 85 of file edit_points.h.

References GetPosition(), and VECTOR2< T >::y.

86  {
87  return GetPosition().y;
88  }
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
bool EDIT_POINT::IsConstrained ( ) const
inline

Function IsConstrained()

Checks if point is constrained.

Returns
True is point is constrained, false otherwise.

Definition at line 149 of file edit_points.h.

References m_constraint.

150  {
151  return m_constraint != NULL;
152  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:178
bool EDIT_POINT::operator== ( const EDIT_POINT aOther) const
inline

Definition at line 165 of file edit_points.h.

References m_position.

166  {
167  return m_position == aOther.m_position;
168  }
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:175
void EDIT_POINT::SetConstraint ( EDIT_CONSTRAINT< EDIT_POINT > *  aConstraint)
inline

Function SetConstraint()

Sets a constraint for and EDIT_POINT.

Parameters
aConstraintis the constraint to be set.

Definition at line 117 of file edit_points.h.

References m_constraint.

118  {
119  m_constraint.reset( aConstraint );
120  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:178
virtual void EDIT_POINT::SetPosition ( const VECTOR2I aPosition)
inlinevirtual

Function SetPosition()

Sets new coordinates for an EDIT_POINT. It does not change the coordinates of a graphical item.

Parameters
aPositionare new coordinates.

Reimplemented in EDIT_LINE.

Definition at line 97 of file edit_points.h.

References m_position.

Referenced by EC_VERTICAL::Apply(), EC_HORIZONTAL::Apply(), EC_45DEGREE::Apply(), EC_LINE::Apply(), EC_CIRCLE::Apply(), EC_CONVERGING::Apply(), EC_SNAPLINE::Apply(), POINT_EDITOR::OnSelectionChange(), and EDIT_LINE::SetPosition().

98  {
99  m_position = aPosition;
100  }
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:175
bool EDIT_POINT::WithinPoint ( const VECTOR2I aPoint,
unsigned int  aSize 
) const

Function WithinPoint()

Checks if given point is within a square centered in the EDIT_POINT position.

Parameters
aPointis point to be checked.
aSizeis length of the square side.

Definition at line 28 of file edit_points.cpp.

References GetPosition(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EDIT_POINTS::FindPoint().

29 {
30  // Corners of the EDIT_POINT square
31  VECTOR2I topLeft = GetPosition() - aSize;
32  VECTOR2I bottomRight = GetPosition() + aSize;
33 
34  return ( aPoint.x > topLeft.x && aPoint.y > topLeft.y &&
35  aPoint.x < bottomRight.x && aPoint.y < bottomRight.y );
36 }
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65

Member Data Documentation

std::shared_ptr<EDIT_CONSTRAINT<EDIT_POINT> > EDIT_POINT::m_constraint
private

Constraint for the point, NULL if none

Definition at line 178 of file edit_points.h.

Referenced by ApplyConstraint(), ClearConstraint(), GetConstraint(), IsConstrained(), and SetConstraint().

VECTOR2I EDIT_POINT::m_position
private

Position of EDIT_POINT

Definition at line 175 of file edit_points.h.

Referenced by GetPosition(), operator==(), and SetPosition().

const int EDIT_POINT::POINT_SIZE = 10
static

Single point size in pixels

Definition at line 171 of file edit_points.h.

Referenced by EDIT_POINTS::FindPoint(), and EDIT_POINTS::ViewDraw().


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