KiCad PCB EDA Suite
EDIT_POINT Class Reference

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 IsActive () const
 
void SetActive (bool aActive=true)
 
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...
 
bool m_isActive
 

True if this point is being manipulated

More...
 

Detailed Description

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  m_isActive( false )
58  {
59  }
bool m_isActive
True if this point is being manipulated
Definition: edit_points.h:210
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:200
EDA_ITEM * m_connection
An optional item to a connected item.
Definition: edit_points.h:204

◆ ~EDIT_POINT()

virtual EDIT_POINT::~EDIT_POINT ( )
inlinevirtual

Definition at line 61 of file edit_points.h.

61 {}

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

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

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

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

References m_constraint.

◆ GetConnection()

virtual EDA_ITEM* EDIT_POINT::GetConnection ( ) const
inlinevirtual

Definition at line 74 of file edit_points.h.

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

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

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

References m_constraint.

◆ GetPosition()

◆ GetX()

int EDIT_POINT::GetX ( ) const
inline

Function GetX()

Returns X coordinate of an EDIT_POINT.

Definition at line 84 of file edit_points.h.

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

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

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

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

◆ IsActive()

bool EDIT_POINT::IsActive ( ) const
inline

Definition at line 180 of file edit_points.h.

181  {
182  return m_isActive;
183  }
bool m_isActive
True if this point is being manipulated
Definition: edit_points.h:210

References m_isActive.

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

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

References m_constraint, and NULL.

◆ operator==()

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

Definition at line 190 of file edit_points.h.

191  {
192  return m_position == aOther.m_position;
193  }
VECTOR2I m_position
Position of EDIT_POINT
Definition: edit_points.h:200

References m_position.

◆ SetActive()

void EDIT_POINT::SetActive ( bool  aActive = true)
inline

Definition at line 185 of file edit_points.h.

186  {
187  m_isActive = aActive;
188  }
bool m_isActive
True if this point is being manipulated
Definition: edit_points.h:210

References m_isActive.

Referenced by POINT_EDITOR::OnSelectionChange().

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

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

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

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

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

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

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

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

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

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

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

◆ m_isActive

bool EDIT_POINT::m_isActive
private

True if this point is being manipulated

Definition at line 210 of file edit_points.h.

Referenced by IsActive(), and SetActive().

◆ m_position

VECTOR2I EDIT_POINT::m_position
private

Position of EDIT_POINT

Definition at line 200 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 196 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: