KiCad PCB EDA Suite
EDIT_LINE Class Reference

Class EDIT_LINE. More...

#include <edit_points.h>

Inheritance diagram for EDIT_LINE:
EDIT_POINT

Public Member Functions

 EDIT_LINE (EDIT_POINT &aOrigin, EDIT_POINT &aEnd)
 Constructor. More...
 
virtual VECTOR2I GetPosition () const override
 

More...
 
virtual void SetPosition (const VECTOR2I &aPosition) override
 

More...
 
virtual void ApplyConstraint () override
 

More...
 
void SetConstraint (EDIT_CONSTRAINT< EDIT_LINE > *aConstraint)
 Function SetConstraint() More...
 
EDIT_CONSTRAINT< EDIT_LINE > * GetConstraint () const
 Function GetConstraint() More...
 
EDIT_POINTGetOrigin ()
 Function GetOrigin() More...
 
const EDIT_POINTGetOrigin () const
 
EDIT_POINTGetEnd ()
 Function GetEnd() More...
 
const EDIT_POINTGetEnd () const
 
bool operator== (const EDIT_POINT &aOther) const
 
bool operator== (const EDIT_LINE &aOther) const
 
virtual EDA_ITEMGetConnection () const
 
int GetX () const
 Function GetX() More...
 
int GetY () const
 Function GetY() 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...
 
void ClearConstraint ()
 Function ClearConstraint() More...
 
bool IsConstrained () const
 Function IsConstrained() More...
 

Static Public Attributes

static const int POINT_SIZE = 10
 

Single point size in pixels

More...
 

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
 

Constraint for the point, NULL if none

More...
 

Detailed Description

Class EDIT_LINE.

Represents a line connecting two EDIT_POINTs. That allows one to move them both by dragging the EDIT_POINT in the middle. As it uses references to EDIT_POINTs, all coordinates are automatically synchronized.

Definition at line 207 of file edit_points.h.

Constructor & Destructor Documentation

◆ EDIT_LINE()

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

Constructor.

Parameters
aOriginis the origin of EDIT_LINE.
aEndis the end of EDIT_LINE.

Definition at line 216 of file edit_points.h.

216  :
217  EDIT_POINT( aOrigin.GetPosition() + ( aEnd.GetPosition() - aOrigin.GetPosition() ) / 2 ),
218  m_origin( aOrigin ), m_end( aEnd )
219  {
220  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:311
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68
EDIT_POINT(const VECTOR2I &aPoint, EDA_ITEM *aConnection=nullptr)
Constructor.
Definition: edit_points.h:54
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:310

Member Function Documentation

◆ ApplyConstraint()

virtual void EDIT_LINE::ApplyConstraint ( )
inlineoverridevirtual

Function ApplyConstraint() Corrects coordinates of an EDIT_POINT by applying previously set constraint.

Reimplemented from EDIT_POINT.

Definition at line 238 of file edit_points.h.

239  {
242 
243  if( m_constraint )
244  m_constraint->Apply();
245  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:314
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:311
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:310
virtual void ApplyConstraint()
Function ApplyConstraint()
Definition: edit_points.h:173

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

◆ ClearConstraint()

void EDIT_POINT::ClearConstraint ( )
inlineinherited

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

◆ GetConnection()

virtual EDA_ITEM* EDIT_POINT::GetConnection ( ) const
inlinevirtualinherited

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

◆ GetConstraint()

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

Function GetConstraint()

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

Definition at line 264 of file edit_points.h.

265  {
266  return m_constraint.get();
267  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:314

References m_constraint.

◆ GetEnd() [1/2]

EDIT_POINT& EDIT_LINE::GetEnd ( )
inline

Function GetEnd()

Returns the end EDIT_POINT.

Definition at line 289 of file edit_points.h.

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

References m_end.

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

◆ GetEnd() [2/2]

const EDIT_POINT& EDIT_LINE::GetEnd ( ) const
inline

Definition at line 294 of file edit_points.h.

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

References m_end.

◆ GetOrigin() [1/2]

EDIT_POINT& EDIT_LINE::GetOrigin ( )
inline

Function GetOrigin()

Returns the origin EDIT_POINT.

Definition at line 274 of file edit_points.h.

275  {
276  return m_origin;
277  }
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:310

References m_origin.

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

◆ GetOrigin() [2/2]

const EDIT_POINT& EDIT_LINE::GetOrigin ( ) const
inline

Definition at line 279 of file edit_points.h.

280  {
281  return m_origin;
282  }
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:310

References m_origin.

◆ GetPosition()

virtual VECTOR2I EDIT_LINE::GetPosition ( ) const
inlineoverridevirtual

Reimplemented from EDIT_POINT.

Definition at line 223 of file edit_points.h.

224  {
225  return ( m_origin.GetPosition() + m_end.GetPosition() ) / 2;
226  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:311
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:310

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

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

◆ GetX()

int EDIT_POINT::GetX ( ) const
inlineinherited

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

◆ GetY()

int EDIT_POINT::GetY ( ) const
inlineinherited

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

◆ IsConstrained()

bool EDIT_POINT::IsConstrained ( ) const
inlineinherited

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

◆ operator==() [1/2]

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

Definition at line 299 of file edit_points.h.

300  {
301  return GetPosition() == aOther.GetPosition();
302  }
virtual VECTOR2I GetPosition() const override
Definition: edit_points.h:223
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68

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

◆ operator==() [2/2]

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

Definition at line 304 of file edit_points.h.

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

References m_end, and m_origin.

◆ SetConstraint() [1/2]

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

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

◆ SetConstraint() [2/2]

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

Function SetConstraint()

Sets a constraint for and EDIT_POINT.

Parameters
aConstraintis the constraint to be set.

Definition at line 253 of file edit_points.h.

254  {
255  m_constraint.reset( aConstraint );
256  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:314

References m_constraint.

◆ SetPosition() [1/2]

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

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

◆ SetPosition() [2/2]

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

Reimplemented from EDIT_POINT.

Definition at line 229 of file edit_points.h.

230  {
231  VECTOR2I difference = aPosition - GetPosition();
232 
233  m_origin.SetPosition( m_origin.GetPosition() + difference );
234  m_end.SetPosition( m_end.GetPosition() + difference );
235  }
virtual VECTOR2I GetPosition() const override
Definition: edit_points.h:223
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:311
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:310
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()
Definition: edit_points.h:105

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

◆ WithinPoint()

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

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

Referenced by EDIT_POINTS::FindPoint().

Member Data Documentation

◆ m_constraint

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

Constraint for the point, NULL if none

Definition at line 314 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.

Definition at line 311 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 310 of file edit_points.h.

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

◆ POINT_SIZE

const int EDIT_POINT::POINT_SIZE = 10
staticinherited

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