KiCad PCB EDA Suite
EDIT_POINT Class Reference

Represent a single point that can be used for modifying items. More...

#include <edit_points.h>

Inheritance diagram for EDIT_POINT:
EDIT_LINE

Public Member Functions

 EDIT_POINT (const VECTOR2I &aPoint, std::pair< EDA_ITEM *, int > aConnected={ nullptr, 0 })
 
virtual ~EDIT_POINT ()
 
virtual VECTOR2I GetPosition () const
 Return coordinates of an EDIT_POINT. More...
 
virtual std::pair< EDA_ITEM *, int > GetConnected () const
 Return a connected item record comprising an EDA_ITEM* and a STARTPOINT/ENDPOINT flag. More...
 
int GetX () const
 Return X coordinate of an EDIT_POINT. More...
 
int GetY () const
 Return Y coordinate of an EDIT_POINT. More...
 
virtual void SetPosition (const VECTOR2I &aPosition)
 Set new coordinates for an EDIT_POINT. More...
 
virtual void SetPosition (int x, int y)
 
bool WithinPoint (const VECTOR2I &aPoint, unsigned int aSize) const
 Check if given point is within a square centered in the EDIT_POINT position. More...
 
void SetConstraint (EDIT_CONSTRAINT< EDIT_POINT > *aConstraint)
 Set a constraint for and EDIT_POINT. More...
 
EDIT_CONSTRAINT< EDIT_POINT > * GetConstraint () const
 Return the constraint imposed on an EDIT_POINT. More...
 
void ClearConstraint ()
 Remove previously set constraint. More...
 
bool IsConstrained () const
 Check if point is constrained. More...
 
virtual void ApplyConstraint ()
 Correct coordinates of an EDIT_POINT by applying previously set constraint. More...
 
bool IsActive () const
 
void SetActive (bool aActive=true)
 
bool IsHover () const
 
void SetHover (bool aHover=true)
 
GRID_CONSTRAINT_TYPE GetGridConstraint () const
 
void SetGridConstraint (GRID_CONSTRAINT_TYPE aConstraint)
 
bool operator== (const EDIT_POINT &aOther) const
 Single point size in pixels. More...
 

Static Public Attributes

static const int POINT_SIZE = 10
 Border size when not hovering. More...
 
static const int BORDER_SIZE = 2
 Border size when hovering. More...
 
static const int HOVER_SIZE = 5
 

Private Attributes

VECTOR2I m_position
 Position of EDIT_POINT. More...
 
bool m_isActive
 True if this point is being manipulated. More...
 
bool m_isHover
 True if this point is being hovered over. More...
 
GRID_CONSTRAINT_TYPE m_gridConstraint
 Describe the grid snapping behavior. More...
 
std::pair< EDA_ITEM *, int > m_connected
 Constraint for the point, NULL if none. More...
 
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
 

Detailed Description

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

Constructor & Destructor Documentation

◆ EDIT_POINT()

EDIT_POINT::EDIT_POINT ( const VECTOR2I aPoint,
std::pair< EDA_ITEM *, int >  aConnected = { nullptr, 0 } 
)
inline
Parameters
aPointstores coordinates for EDIT_POINT.

Definition at line 53 of file edit_points.h.

53  { nullptr, 0 } ) :
54  m_position( aPoint ),
55  m_isActive( false ),
56  m_isHover( false ),
58  m_connected( aConnected )
59  {
60  }
bool m_isHover
True if this point is being hovered over.
Definition: edit_points.h:197
bool m_isActive
True if this point is being manipulated.
Definition: edit_points.h:196
VECTOR2I m_position
Position of EDIT_POINT.
Definition: edit_points.h:195
std::pair< EDA_ITEM *, int > m_connected
Constraint for the point, NULL if none.
Definition: edit_points.h:202
GRID_CONSTRAINT_TYPE m_gridConstraint
Describe the grid snapping behavior.
Definition: edit_points.h:198

◆ ~EDIT_POINT()

virtual EDIT_POINT::~EDIT_POINT ( )
inlinevirtual

Definition at line 62 of file edit_points.h.

62 {}

Member Function Documentation

◆ ApplyConstraint()

virtual void EDIT_POINT::ApplyConstraint ( )
inlinevirtual

Correct coordinates of an EDIT_POINT by applying previously set constraint.

Reimplemented in EDIT_LINE.

Definition at line 165 of file edit_points.h.

166  {
167  if( m_constraint )
168  m_constraint->Apply();
169  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Definition: edit_points.h:205

References m_constraint.

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

◆ ClearConstraint()

void EDIT_POINT::ClearConstraint ( )
inline

Remove previously set constraint.

Definition at line 147 of file edit_points.h.

148  {
149  m_constraint.reset();
150  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Definition: edit_points.h:205

References m_constraint.

◆ GetConnected()

virtual std::pair<EDA_ITEM*, int> EDIT_POINT::GetConnected ( ) const
inlinevirtual

Return a connected item record comprising an EDA_ITEM* and a STARTPOINT/ENDPOINT flag.

Definition at line 78 of file edit_points.h.

79  {
80  return m_connected;
81  }
std::pair< EDA_ITEM *, int > m_connected
Constraint for the point, NULL if none.
Definition: edit_points.h:202

References m_connected.

◆ GetConstraint()

EDIT_CONSTRAINT<EDIT_POINT>* EDIT_POINT::GetConstraint ( ) const
inline

Return the constraint imposed on an EDIT_POINT.

If there are no constraints, NULL is returned.

Definition at line 139 of file edit_points.h.

140  {
141  return m_constraint.get();
142  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Definition: edit_points.h:205

References m_constraint.

◆ GetGridConstraint()

GRID_CONSTRAINT_TYPE EDIT_POINT::GetGridConstraint ( ) const
inline

Definition at line 177 of file edit_points.h.

177 { return m_gridConstraint; }
GRID_CONSTRAINT_TYPE m_gridConstraint
Describe the grid snapping behavior.
Definition: edit_points.h:198

References m_gridConstraint.

Referenced by PCB_POINT_EDITOR::OnSelectionChange().

◆ GetPosition()

◆ GetX()

int EDIT_POINT::GetX ( ) const
inline

Return X coordinate of an EDIT_POINT.

Definition at line 86 of file edit_points.h.

87  {
88  return GetPosition().x;
89  }
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:70

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

◆ GetY()

int EDIT_POINT::GetY ( ) const
inline

Return 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
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:70

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

◆ IsActive()

bool EDIT_POINT::IsActive ( ) const
inline

Definition at line 171 of file edit_points.h.

171 { return m_isActive; }
bool m_isActive
True if this point is being manipulated.
Definition: edit_points.h:196

References m_isActive.

Referenced by EDIT_POINTS::ViewDraw().

◆ IsConstrained()

bool EDIT_POINT::IsConstrained ( ) const
inline

Check if point is constrained.

Returns
True is point is constrained, false otherwise.

Definition at line 157 of file edit_points.h.

158  {
159  return m_constraint != nullptr;
160  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Definition: edit_points.h:205

References m_constraint.

◆ IsHover()

bool EDIT_POINT::IsHover ( ) const
inline

Definition at line 174 of file edit_points.h.

174 { return m_isHover; }
bool m_isHover
True if this point is being hovered over.
Definition: edit_points.h:197

References m_isHover.

Referenced by EDIT_POINTS::ViewDraw().

◆ operator==()

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

Single point size in pixels.

Definition at line 180 of file edit_points.h.

References m_position.

◆ SetActive()

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

Definition at line 172 of file edit_points.h.

172 { m_isActive = aActive; }
bool m_isActive
True if this point is being manipulated.
Definition: edit_points.h:196

References m_isActive.

Referenced by PCB_POINT_EDITOR::OnSelectionChange().

◆ SetConstraint()

void EDIT_POINT::SetConstraint ( EDIT_CONSTRAINT< EDIT_POINT > *  aConstraint)
inline

Set a constraint for and EDIT_POINT.

Parameters
aConstraintis the constraint to be set.

Definition at line 130 of file edit_points.h.

131  {
132  m_constraint.reset( aConstraint );
133  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Definition: edit_points.h:205

References m_constraint.

◆ SetGridConstraint()

void EDIT_POINT::SetGridConstraint ( GRID_CONSTRAINT_TYPE  aConstraint)
inline

Definition at line 178 of file edit_points.h.

178 { m_gridConstraint = aConstraint; }
GRID_CONSTRAINT_TYPE m_gridConstraint
Describe the grid snapping behavior.
Definition: edit_points.h:198

References m_gridConstraint.

Referenced by EDIT_LINE::EDIT_LINE().

◆ SetHover()

void EDIT_POINT::SetHover ( bool  aHover = true)
inline

Definition at line 175 of file edit_points.h.

175 { m_isHover = aHover; }
bool m_isHover
True if this point is being hovered over.
Definition: edit_points.h:197

References m_isHover.

Referenced by PCB_POINT_EDITOR::updateEditedPoint().

◆ SetPosition() [1/2]

virtual void EDIT_POINT::SetPosition ( const VECTOR2I aPosition)
inlinevirtual

Set 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:195

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(), EC_PERPLINE::Apply(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), PCB_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:195

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

◆ WithinPoint()

bool EDIT_POINT::WithinPoint ( const VECTOR2I aPoint,
unsigned int  aSize 
) const

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

34 {
35  // Corners of the EDIT_POINT square
36  VECTOR2I topLeft = GetPosition() - aSize;
37  VECTOR2I bottomRight = GetPosition() + aSize;
38 
39  return ( aPoint.x > topLeft.x && aPoint.y > topLeft.y &&
40  aPoint.x < bottomRight.x && aPoint.y < bottomRight.y );
41 }
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:70

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

Member Data Documentation

◆ BORDER_SIZE

const int EDIT_POINT::BORDER_SIZE = 2
static

Border size when hovering.

Definition at line 189 of file edit_points.h.

Referenced by EDIT_POINTS::ViewDraw().

◆ HOVER_SIZE

const int EDIT_POINT::HOVER_SIZE = 5
static

Definition at line 192 of file edit_points.h.

Referenced by EDIT_POINTS::ViewDraw().

◆ m_connected

std::pair<EDA_ITEM*, int> EDIT_POINT::m_connected
private

Constraint for the point, NULL if none.

Definition at line 202 of file edit_points.h.

Referenced by GetConnected().

◆ m_constraint

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

◆ m_gridConstraint

GRID_CONSTRAINT_TYPE EDIT_POINT::m_gridConstraint
private

Describe the grid snapping behavior.

An optional connected item record used to mimic polyLine behavior with individual line segments.

Definition at line 198 of file edit_points.h.

Referenced by GetGridConstraint(), and SetGridConstraint().

◆ m_isActive

bool EDIT_POINT::m_isActive
private

True if this point is being manipulated.

Definition at line 196 of file edit_points.h.

Referenced by IsActive(), and SetActive().

◆ m_isHover

bool EDIT_POINT::m_isHover
private

True if this point is being hovered over.

Definition at line 197 of file edit_points.h.

Referenced by IsHover(), and SetHover().

◆ m_position

VECTOR2I EDIT_POINT::m_position
private

Position of EDIT_POINT.

Definition at line 195 of file edit_points.h.

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

◆ POINT_SIZE

const int EDIT_POINT::POINT_SIZE = 10
static

Border size when not hovering.

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