KiCad PCB EDA Suite
EDIT_LINE Class Reference

Represent a line connecting two EDIT_POINTs. More...

#include <edit_points.h>

Inheritance diagram for EDIT_LINE:
EDIT_POINT

Public Member Functions

 EDIT_LINE (EDIT_POINT &aOrigin, EDIT_POINT &aEnd)
 Return coordinates of an EDIT_POINT. More...
 
virtual VECTOR2I GetPosition () const override
 Return coordinates of an EDIT_POINT. More...
 
virtual void SetPosition (const VECTOR2I &aPosition) override
 Correct coordinates of an EDIT_POINT by applying previously set constraint. More...
 
virtual void ApplyConstraint () override
 Correct coordinates of an EDIT_POINT by applying previously set constraint. More...
 
void SetConstraint (EDIT_CONSTRAINT< EDIT_LINE > *aConstraint)
 Set a constraint for and EDIT_POINT. More...
 
EDIT_CONSTRAINT< EDIT_LINE > * GetConstraint () const
 Return the constraint imposed on an EDIT_POINT. More...
 
EDIT_POINTGetOrigin ()
 Return the origin EDIT_POINT. More...
 
const EDIT_POINTGetOrigin () const
 
EDIT_POINTGetEnd ()
 Return the end EDIT_POINT. More...
 
const EDIT_POINTGetEnd () const
 
bool operator== (const EDIT_POINT &aOther) const
 
bool operator== (const EDIT_LINE &aOther) const
 
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 (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...
 
void ClearConstraint ()
 Remove previously set constraint. More...
 
bool IsConstrained () const
 Check if point is constrained. 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)
 

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

EDIT_POINTm_origin
 Origin point for a line. More...
 
EDIT_POINTm_end
 End point for a line. More...
 
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
 

Detailed Description

Represent a line connecting two EDIT_POINTs.

This allows one to move them both by dragging the EDIT_POINT in the middle. It uses references to EDIT_POINTs, all coordinates are automatically synchronized.

Definition at line 215 of file edit_points.h.

Constructor & Destructor Documentation

◆ EDIT_LINE()

EDIT_LINE::EDIT_LINE ( EDIT_POINT aOrigin,
EDIT_POINT aEnd 
)
inline

Return coordinates of an EDIT_POINT.

Parameters
aOriginis the origin of EDIT_LINE.
aEndis the end of EDIT_LINE.
Note
It may be different than coordinates of a graphical item that is bound to the EDIT_POINT.

Definition at line 222 of file edit_points.h.

References EDIT_POINT::SetGridConstraint(), and SNAP_BY_GRID.

Member Function Documentation

◆ ApplyConstraint()

virtual void EDIT_LINE::ApplyConstraint ( )
inlineoverridevirtual

Correct coordinates of an EDIT_POINT by applying previously set constraint.

Reimplemented from EDIT_POINT.

Definition at line 246 of file edit_points.h.

247  {
248  if( m_constraint )
249  m_constraint->Apply();
250 
253  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Definition: edit_points.h:315
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:312
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:311
virtual void ApplyConstraint()
Correct coordinates of an EDIT_POINT by applying previously set constraint.
Definition: edit_points.h:165

References EDIT_POINT::ApplyConstraint(), m_constraint, m_end, and m_origin.

◆ ClearConstraint()

void EDIT_POINT::ClearConstraint ( )
inlineinherited

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 EDIT_POINT::m_constraint.

◆ GetConnected()

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

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 EDIT_POINT::m_connected.

◆ GetConstraint()

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

Return the constraint imposed on an EDIT_POINT.

If there are no constraints, NULL is returned.

Definition at line 269 of file edit_points.h.

270  {
271  return m_constraint.get();
272  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Definition: edit_points.h:315

References m_constraint.

◆ GetEnd() [1/2]

EDIT_POINT& EDIT_LINE::GetEnd ( )
inline

Return the end EDIT_POINT.

Definition at line 290 of file edit_points.h.

291  {
292  return m_end;
293  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:312

References m_end.

Referenced by EC_CONVERGING::Apply(), EC_SNAPLINE::Apply(), EC_PERPLINE::Apply(), EC_CONVERGING::EC_CONVERGING(), and EC_PERPLINE::EC_PERPLINE().

◆ GetEnd() [2/2]

const EDIT_POINT& EDIT_LINE::GetEnd ( ) const
inline

Definition at line 295 of file edit_points.h.

296  {
297  return m_end;
298  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:312

References m_end.

◆ GetGridConstraint()

GRID_CONSTRAINT_TYPE EDIT_POINT::GetGridConstraint ( ) const
inlineinherited

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 EDIT_POINT::m_gridConstraint.

Referenced by PCB_POINT_EDITOR::OnSelectionChange().

◆ GetOrigin() [1/2]

EDIT_POINT& EDIT_LINE::GetOrigin ( )
inline

Return the origin EDIT_POINT.

Definition at line 277 of file edit_points.h.

278  {
279  return m_origin;
280  }
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:311

References m_origin.

Referenced by EC_CONVERGING::Apply(), EC_SNAPLINE::Apply(), EC_PERPLINE::Apply(), EC_CONVERGING::EC_CONVERGING(), and EC_PERPLINE::EC_PERPLINE().

◆ GetOrigin() [2/2]

const EDIT_POINT& EDIT_LINE::GetOrigin ( ) const
inline

Definition at line 282 of file edit_points.h.

283  {
284  return m_origin;
285  }
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:311

References m_origin.

◆ GetPosition()

virtual VECTOR2I EDIT_LINE::GetPosition ( ) const
inlineoverridevirtual

Return coordinates of an EDIT_POINT.

Note
It may be different than coordinates of a graphical item that is bound to the EDIT_POINT.

Reimplemented from EDIT_POINT.

Definition at line 231 of file edit_points.h.

References EDIT_POINT::GetPosition(), m_end, and m_origin.

Referenced by EC_PERPLINE::Apply(), EC_PERPLINE::EC_PERPLINE(), operator==(), and SetPosition().

◆ GetX()

int EDIT_POINT::GetX ( ) const
inlineinherited

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 EDIT_POINT::GetPosition(), and VECTOR2< T >::x.

◆ GetY()

int EDIT_POINT::GetY ( ) const
inlineinherited

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 EDIT_POINT::GetPosition(), and VECTOR2< T >::y.

◆ IsActive()

bool EDIT_POINT::IsActive ( ) const
inlineinherited

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 EDIT_POINT::m_isActive.

Referenced by EDIT_POINTS::ViewDraw().

◆ IsConstrained()

bool EDIT_POINT::IsConstrained ( ) const
inlineinherited

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 != NULL;
160  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Definition: edit_points.h:205
#define NULL

References EDIT_POINT::m_constraint, and NULL.

◆ IsHover()

bool EDIT_POINT::IsHover ( ) const
inlineinherited

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 EDIT_POINT::m_isHover.

Referenced by EDIT_POINTS::ViewDraw().

◆ operator==() [1/2]

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

Definition at line 300 of file edit_points.h.

301  {
302  return GetPosition() == aOther.GetPosition();
303  }
virtual VECTOR2I GetPosition() const override
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:231
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:70

References EDIT_POINT::GetPosition(), and GetPosition().

◆ operator==() [2/2]

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

Definition at line 305 of file edit_points.h.

306  {
307  return m_origin == aOther.m_origin && m_end == aOther.m_end;
308  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:312
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:311

References m_end, and m_origin.

◆ SetActive()

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

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 EDIT_POINT::m_isActive.

Referenced by PCB_POINT_EDITOR::OnSelectionChange().

◆ SetConstraint() [1/2]

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

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 EDIT_POINT::m_constraint.

◆ SetConstraint() [2/2]

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

Set a constraint for and EDIT_POINT.

Parameters
aConstraintis the constraint to be set.

Definition at line 260 of file edit_points.h.

261  {
262  m_constraint.reset( aConstraint );
263  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Definition: edit_points.h:315

References m_constraint.

◆ SetGridConstraint()

void EDIT_POINT::SetGridConstraint ( GRID_CONSTRAINT_TYPE  aConstraint)
inlineinherited

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 EDIT_POINT::m_gridConstraint.

Referenced by EDIT_LINE().

◆ SetHover()

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

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 EDIT_POINT::m_isHover.

Referenced by PCB_POINT_EDITOR::updateEditedPoint().

◆ SetPosition() [1/2]

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

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 EDIT_POINT::m_position, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SetPosition() [2/2]

virtual void EDIT_LINE::SetPosition ( const VECTOR2I aPosition)
inlineoverridevirtual

Correct coordinates of an EDIT_POINT by applying previously set constraint.

Reimplemented from EDIT_POINT.

Definition at line 237 of file edit_points.h.

References EDIT_POINT::GetPosition(), GetPosition(), m_end, m_origin, and EDIT_POINT::SetPosition().

Referenced by EC_PERPLINE::Apply().

◆ WithinPoint()

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

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

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

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

Member Data Documentation

◆ BORDER_SIZE

const int EDIT_POINT::BORDER_SIZE = 2
staticinherited

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
staticinherited

Definition at line 192 of file edit_points.h.

Referenced by EDIT_POINTS::ViewDraw().

◆ m_constraint

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

Definition at line 315 of file edit_points.h.

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

◆ m_end

EDIT_POINT& EDIT_LINE::m_end
private

End point for a line.

Constraint for the point, NULL if none

Definition at line 312 of file edit_points.h.

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

◆ m_origin

EDIT_POINT& EDIT_LINE::m_origin
private

Origin point for a line.

Definition at line 311 of file edit_points.h.

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

◆ POINT_SIZE

const int EDIT_POINT::POINT_SIZE = 10
staticinherited

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 file: