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, EDA_ITEM *aConnection=nullptr)
 Constructor. More...
 
virtual ~EDIT_POINT ()
 
virtual VECTOR2I GetPosition () const
 Function GetPosition() More...
 
virtual EDA_ITEMGetConnection () const
 
int GetX () const
 Function GetX() More...
 
int GetY () const
 Function GetY() More...
 
virtual void SetPosition (const VECTOR2I &aPosition)
 Function SetPosition() More...
 
virtual void SetPosition (int x, int y)
 
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...
 
EDA_ITEMm_connection
 

An optional item to a connected item.

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::EDIT_POINT ( const VECTOR2I aPoint,
EDA_ITEM aConnection = nullptr 
)
inline

Constructor.

Parameters
aPointstores coordinates for EDIT_POINT.

Definition at line 54 of file edit_points.h.

54  :
55  m_position( aPoint ),
56  m_connection( aConnection )
57  {
58  }
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:189
EDA_ITEM * m_connection
An optional item to a connected item.
Definition: edit_points.h:193

◆ ~EDIT_POINT()

virtual EDIT_POINT::~EDIT_POINT ( )
inlinevirtual

Definition at line 60 of file edit_points.h.

60 {}

Member Function Documentation

◆ ApplyConstraint()

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 173 of file edit_points.h.

174  {
175  if( m_constraint )
176  m_constraint->Apply();
177  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:196

References m_constraint.

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

◆ ClearConstraint()

void EDIT_POINT::ClearConstraint ( )
inline

Function ClearConstraint()

Removes previously set constraint.

Definition at line 152 of file edit_points.h.

153  {
154  m_constraint.reset();
155  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:196

References m_constraint.

◆ GetConnection()

virtual EDA_ITEM* EDIT_POINT::GetConnection ( ) const
inlinevirtual

Definition at line 73 of file edit_points.h.

74  {
75  return m_connection;
76  }
EDA_ITEM * m_connection
An optional item to a connected item.
Definition: edit_points.h:193

References m_connection.

◆ GetConstraint()

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 142 of file edit_points.h.

143  {
144  return m_constraint.get();
145  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:196

References m_constraint.

◆ GetPosition()

◆ GetX()

int EDIT_POINT::GetX ( ) const
inline

Function GetX()

Returns X coordinate of an EDIT_POINT.

Definition at line 83 of file edit_points.h.

84  {
85  return GetPosition().x;
86  }
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68

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

◆ GetY()

int EDIT_POINT::GetY ( ) const
inline

Function GetY()

Returns Y coordinate of an EDIT_POINT.

Definition at line 93 of file edit_points.h.

94  {
95  return GetPosition().y;
96  }
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68

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

◆ IsConstrained()

bool EDIT_POINT::IsConstrained ( ) const
inline

Function IsConstrained()

Checks if point is constrained.

Returns
True is point is constrained, false otherwise.

Definition at line 163 of file edit_points.h.

164  {
165  return m_constraint != NULL;
166  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:196

References m_constraint.

◆ operator==()

bool EDIT_POINT::operator== ( const EDIT_POINT aOther) const
inline

Definition at line 179 of file edit_points.h.

180  {
181  return m_position == aOther.m_position;
182  }
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:189

References m_position.

◆ SetConstraint()

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 131 of file edit_points.h.

132  {
133  m_constraint.reset( aConstraint );
134  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:196

References m_constraint.

◆ SetPosition() [1/2]

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 105 of file edit_points.h.

106  {
107  m_position = aPosition;
108  }
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:189

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(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), POINT_EDITOR::OnSelectionChange(), and EDIT_LINE::SetPosition().

◆ SetPosition() [2/2]

virtual void EDIT_POINT::SetPosition ( int  x,
int  y 
)
inlinevirtual

Definition at line 110 of file edit_points.h.

111  {
112  m_position.x = x;
113  m_position.y = y;
114  }
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:189

References m_position, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ WithinPoint()

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 29 of file edit_points.cpp.

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

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

Referenced by EDIT_POINTS::FindPoint().

Member Data Documentation

◆ m_connection

EDA_ITEM* EDIT_POINT::m_connection
private

An optional item to a connected item.

Used to mimic polyLine behaviour with individual line segments.

Definition at line 193 of file edit_points.h.

Referenced by GetConnection().

◆ m_constraint

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

Constraint for the point, NULL if none

Definition at line 196 of file edit_points.h.

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

◆ m_position

VECTOR2I EDIT_POINT::m_position
private

Position of EDIT_POINT

Definition at line 189 of file edit_points.h.

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

◆ POINT_SIZE

const int EDIT_POINT::POINT_SIZE = 10
static

Single point size in pixels

Definition at line 185 of file edit_points.h.

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


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