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
 
int GetX () const
 Function GetX() More...
 
int GetY () const
 Function GetY() More...
 
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 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 189 of file edit_points.h.

Constructor & Destructor Documentation

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

198  :
199  EDIT_POINT( aOrigin.GetPosition() + ( aEnd.GetPosition() - aOrigin.GetPosition() ) / 2 ),
200  m_origin( aOrigin ), m_end( aEnd )
201  {
202  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:293
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:292
EDIT_POINT(const VECTOR2I &aPoint)
Constructor.
Definition: edit_points.h:54

Member Function Documentation

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

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

221  {
224 
225  if( m_constraint )
226  m_constraint->Apply();
227  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:296
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:293
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:292
virtual void ApplyConstraint()
Function ApplyConstraint()
Definition: edit_points.h:159
void EDIT_POINT::ClearConstraint ( )
inlineinherited

Function ClearConstraint()

Removes previously set constraint.

Definition at line 138 of file edit_points.h.

References EDIT_POINT::m_constraint.

139  {
140  m_constraint.reset();
141  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:178
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 246 of file edit_points.h.

References m_constraint.

247  {
248  return m_constraint.get();
249  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:296
EDIT_POINT& EDIT_LINE::GetEnd ( )
inline

Function GetEnd()

Returns the end EDIT_POINT.

Definition at line 271 of file edit_points.h.

References m_end.

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

272  {
273  return m_end;
274  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:293
const EDIT_POINT& EDIT_LINE::GetEnd ( ) const
inline

Definition at line 276 of file edit_points.h.

References m_end.

277  {
278  return m_end;
279  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:293
EDIT_POINT& EDIT_LINE::GetOrigin ( )
inline

Function GetOrigin()

Returns the origin EDIT_POINT.

Definition at line 256 of file edit_points.h.

References m_origin.

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

257  {
258  return m_origin;
259  }
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:292
const EDIT_POINT& EDIT_LINE::GetOrigin ( ) const
inline

Definition at line 261 of file edit_points.h.

References m_origin.

262  {
263  return m_origin;
264  }
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:292
virtual VECTOR2I EDIT_LINE::GetPosition ( ) const
inlineoverridevirtual

>

Function GetPosition() Returns coordinates of an EDIT_POINT. Note that it may be different than coordinates of a graphical item that is bound to the EDIT_POINT.

Reimplemented from EDIT_POINT.

Definition at line 205 of file edit_points.h.

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

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

206  {
207  return ( m_origin.GetPosition() + m_end.GetPosition() ) / 2;
208  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:293
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:292
int EDIT_POINT::GetX ( ) const
inlineinherited

Function GetX()

Returns X coordinate of an EDIT_POINT.

Definition at line 75 of file edit_points.h.

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

76  {
77  return GetPosition().x;
78  }
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
int EDIT_POINT::GetY ( ) const
inlineinherited

Function GetY()

Returns Y coordinate of an EDIT_POINT.

Definition at line 85 of file edit_points.h.

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

86  {
87  return GetPosition().y;
88  }
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
bool EDIT_POINT::IsConstrained ( ) const
inlineinherited

Function IsConstrained()

Checks if point is constrained.

Returns
True is point is constrained, false otherwise.

Definition at line 149 of file edit_points.h.

References EDIT_POINT::m_constraint.

150  {
151  return m_constraint != NULL;
152  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:178
bool EDIT_LINE::operator== ( const EDIT_POINT aOther) const
inline

Definition at line 281 of file edit_points.h.

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

282  {
283  return GetPosition() == aOther.GetPosition();
284  }
virtual VECTOR2I GetPosition() const override
>
Definition: edit_points.h:205
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
bool EDIT_LINE::operator== ( const EDIT_LINE aOther) const
inline

Definition at line 286 of file edit_points.h.

References m_end, and m_origin.

287  {
288  return m_origin == aOther.m_origin && m_end == aOther.m_end;
289  }
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:293
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:292
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 117 of file edit_points.h.

References EDIT_POINT::m_constraint.

118  {
119  m_constraint.reset( aConstraint );
120  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:178
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 235 of file edit_points.h.

References m_constraint.

236  {
237  m_constraint.reset( aConstraint );
238  }
std::shared_ptr< EDIT_CONSTRAINT< EDIT_LINE > > m_constraint
Constraint for the point, NULL if none
Definition: edit_points.h:296
virtual void EDIT_LINE::SetPosition ( const VECTOR2I aPosition)
inlineoverridevirtual

>

Function GetPosition() Returns coordinates of an EDIT_POINT. Note that it may be different than coordinates of a graphical item that is bound to the EDIT_POINT.

Reimplemented from EDIT_POINT.

Definition at line 211 of file edit_points.h.

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

212  {
213  VECTOR2I difference = aPosition - GetPosition();
214 
215  m_origin.SetPosition( m_origin.GetPosition() + difference );
216  m_end.SetPosition( m_end.GetPosition() + difference );
217  }
virtual VECTOR2I GetPosition() const override
>
Definition: edit_points.h:205
EDIT_POINT & m_end
End point for a line.
Definition: edit_points.h:293
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
EDIT_POINT & m_origin
Origin point for a line.
Definition: edit_points.h:292
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()
Definition: edit_points.h:97
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 28 of file edit_points.cpp.

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

Referenced by EDIT_POINTS::FindPoint().

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

Member Data Documentation

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

Constraint for the point, NULL if none

Definition at line 296 of file edit_points.h.

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

EDIT_POINT& EDIT_LINE::m_end
private

End point for a line.

Definition at line 293 of file edit_points.h.

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

EDIT_POINT& EDIT_LINE::m_origin
private

Origin point for a line.

Definition at line 292 of file edit_points.h.

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

const int EDIT_POINT::POINT_SIZE = 10
staticinherited

Single point size in pixels

Definition at line 171 of file edit_points.h.

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


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