KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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)
 
virtual VECTOR2I GetPosition () const override
 Return coordinates of an EDIT_POINT.
 
virtual void SetPosition (const VECTOR2I &aPosition) override
 Return coordinates of an EDIT_POINT.
 
virtual void ApplyRelation (const GRID_HELPER &aGrid) override
 Correct coordinates of an EDIT_POINT by applying its relation.
 
void SetRelation (std::unique_ptr< EDIT_RELATION > aRelation)
 Set a relation for an EDIT_LINE.
 
EDIT_RELATIONGetRelation () const
 Return the relation imposed on an EDIT_LINE.
 
void SetDragPolicy (std::unique_ptr< POLYGON_EDGE_DRAG_POLICY > aPolicy)
 
POLYGON_EDGE_DRAG_POLICYGetDragPolicy () const
 
bool IsConstrained () const override
 Check if line is constrained.
 
EDIT_POINTGetOrigin ()
 Return the origin EDIT_POINT.
 
const EDIT_POINTGetOrigin () const
 
EDIT_POINTGetEnd ()
 Return the end EDIT_POINT.
 
const EDIT_POINTGetEnd () const
 
bool HasCenterPoint () const
 Is the center-point of the line useful to be shown?
 
void SetHasCenterPoint (bool aHasCenterPoint)
 Set if the center-point of the line should be shown.
 
bool DrawLine () const
 Should the line itself be drawn, or just the end and/or center points?
 
void SetDrawLine (bool aShowLine)
 Set if the line itself should be drawn.
 
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.
 
int GetX () const
 Return X coordinate of an EDIT_POINT.
 
int GetY () const
 Return Y coordinate of an EDIT_POINT.
 
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.
 
bool IsActive () const
 
void SetActive (bool aActive=true)
 
bool IsHover () const
 
void SetHover (bool aHover=true)
 
bool DrawCircle () const
 
void SetDrawCircle (bool aDrawCircle=true)
 
GRID_CONSTRAINT_TYPE GetGridConstraint () const
 
void SetGridConstraint (GRID_CONSTRAINT_TYPE aConstraint)
 
SNAP_CONSTRAINT_TYPE GetSnapConstraint () const
 
void SetSnapConstraint (SNAP_CONSTRAINT_TYPE aConstraint)
 

Static Public Attributes

static const int POINT_SIZE = 8
 Single point size in pixels.
 
static const int BORDER_SIZE = 2
 Border size when not hovering.
 
static const int HOVER_SIZE = 5
 Border size when hovering.
 

Private Attributes

EDIT_POINTm_origin
 Origin point for a line.
 
EDIT_POINTm_end
 End point for a line.
 
bool m_hasCenterPoint = true
 True if the line has a (useful) center point.
 
bool m_showLine = false
 True if the line itself should be drawn.
 
std::shared_ptr< EDIT_RELATIONm_relation
 Relation and geometry policy for the line, NULL if absent.
 
std::shared_ptr< POLYGON_EDGE_DRAG_POLICYm_dragPolicy
 
VECTOR2I m_position
 Position of EDIT_POINT.
 
bool m_isActive
 True if this point is being manipulated.
 
bool m_isHover
 True if this point is being hovered over.
 
bool m_drawCircle
 True if the point is drawn circular.
 
GRID_CONSTRAINT_TYPE m_gridConstraint
 Describe the grid snapping behavior.
 
SNAP_CONSTRAINT_TYPE m_snapConstraint
 Describe the object snapping behavior.
 
std::pair< EDA_ITEM *, int > m_connected
 An optional connected item record used to mimic polyLine behavior with individual line segments.
 

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
Parameters
aOriginis the origin of EDIT_LINE.
aEndis the end of EDIT_LINE.

Definition at line 222 of file edit_points.h.

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

Referenced by operator==().

Member Function Documentation

◆ ApplyRelation()

virtual void EDIT_LINE::ApplyRelation ( const GRID_HELPER & aGrid)
inlineoverridevirtual

Correct coordinates of an EDIT_POINT by applying its relation.

Reimplemented from EDIT_POINT.

Definition at line 246 of file edit_points.h.

References m_dragPolicy, m_end, m_origin, and m_relation.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ DrawCircle()

bool EDIT_POINT::DrawCircle ( ) const
inlineinherited

Definition at line 167 of file edit_points.h.

References m_drawCircle.

◆ DrawLine()

bool EDIT_LINE::DrawLine ( ) const
inline

Should the line itself be drawn, or just the end and/or center points?

Definition at line 331 of file edit_points.h.

References m_showLine.

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

References m_connected.

Referenced by LINE_POINT_EDIT_BEHAVIOR::UpdateItem().

◆ GetDragPolicy()

POLYGON_EDGE_DRAG_POLICY * EDIT_LINE::GetDragPolicy ( ) const
inline

◆ GetEnd() [1/2]

◆ GetEnd() [2/2]

const EDIT_POINT & EDIT_LINE::GetEnd ( ) const
inline

Definition at line 313 of file edit_points.h.

References EDIT_POINT::EDIT_POINT(), and m_end.

◆ GetGridConstraint()

GRID_CONSTRAINT_TYPE EDIT_POINT::GetGridConstraint ( ) const
inlineinherited

Definition at line 170 of file edit_points.h.

References m_gridConstraint.

Referenced by EDIT_RELATION::Apply().

◆ GetOrigin() [1/2]

◆ GetOrigin() [2/2]

const EDIT_POINT & EDIT_LINE::GetOrigin ( ) const
inline

Definition at line 300 of file edit_points.h.

References EDIT_POINT::EDIT_POINT(), and m_origin.

◆ GetPosition()

virtual VECTOR2I EDIT_LINE::GetPosition ( ) const
inlineoverridevirtual

◆ GetRelation()

EDIT_RELATION * EDIT_LINE::GetRelation ( ) const
inline

Return the relation imposed on an EDIT_LINE.

If there is no relation, NULL is returned.

Definition at line 272 of file edit_points.h.

References m_relation.

◆ GetSnapConstraint()

SNAP_CONSTRAINT_TYPE EDIT_POINT::GetSnapConstraint ( ) const
inlineinherited

Definition at line 173 of file edit_points.h.

References m_snapConstraint.

◆ GetX()

int EDIT_POINT::GetX ( ) const
inlineinherited

◆ GetY()

int EDIT_POINT::GetY ( ) const
inlineinherited

◆ HasCenterPoint()

bool EDIT_LINE::HasCenterPoint ( ) const
inline

Is the center-point of the line useful to be shown?

Definition at line 321 of file edit_points.h.

References m_hasCenterPoint.

◆ IsActive()

bool EDIT_POINT::IsActive ( ) const
inlineinherited

◆ IsConstrained()

bool EDIT_LINE::IsConstrained ( ) const
inlineoverridevirtual

Check if line is constrained.

Reimplemented from EDIT_POINT.

Definition at line 287 of file edit_points.h.

References m_dragPolicy, and m_relation.

◆ IsHover()

bool EDIT_POINT::IsHover ( ) const
inlineinherited

Definition at line 164 of file edit_points.h.

References m_isHover.

Referenced by KIGFX::PREVIEW::ANGLE_ITEM::drawPreviewShape(), and EDIT_POINTS::ViewDraw().

◆ operator==() [1/2]

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

Definition at line 343 of file edit_points.h.

References EDIT_LINE(), m_end, and m_origin.

◆ operator==() [2/2]

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

Definition at line 338 of file edit_points.h.

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

◆ SetActive()

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

Definition at line 162 of file edit_points.h.

References m_isActive.

Referenced by PCB_POINT_EDITOR::OnSelectionChange().

◆ SetDragPolicy()

void EDIT_LINE::SetDragPolicy ( std::unique_ptr< POLYGON_EDGE_DRAG_POLICY > aPolicy)
inline

◆ SetDrawCircle()

void EDIT_POINT::SetDrawCircle ( bool aDrawCircle = true)
inlineinherited

◆ SetDrawLine()

void EDIT_LINE::SetDrawLine ( bool aShowLine)
inline

Set if the line itself should be drawn.

Definition at line 336 of file edit_points.h.

References m_showLine.

Referenced by EDIT_POINTS::AddIndicatorLine().

◆ SetGridConstraint()

void EDIT_POINT::SetGridConstraint ( GRID_CONSTRAINT_TYPE aConstraint)
inlineinherited

Definition at line 171 of file edit_points.h.

References m_gridConstraint.

Referenced by EDIT_LINE::EDIT_LINE(), and PCB_TUNING_PATTERN::MakeEditPoints().

◆ SetHasCenterPoint()

void EDIT_LINE::SetHasCenterPoint ( bool aHasCenterPoint)
inline

Set if the center-point of the line should be shown.

Definition at line 326 of file edit_points.h.

References m_hasCenterPoint.

Referenced by EDIT_POINTS::AddIndicatorLine().

◆ SetHover()

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

Definition at line 165 of file edit_points.h.

References m_isHover.

◆ SetPosition() [1/2]

virtual void EDIT_LINE::SetPosition ( const VECTOR2I & aPosition)
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 237 of file edit_points.h.

References GetPosition(), m_end, and m_origin.

Referenced by EDIT_RELATION::Apply(), POLYGON_EDGE_DRAG_POLICY::Apply(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ SetPosition() [2/2]

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

Definition at line 109 of file edit_points.h.

References m_position.

◆ SetRelation()

void EDIT_LINE::SetRelation ( std::unique_ptr< EDIT_RELATION > aRelation)
inline

◆ SetSnapConstraint()

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

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

Member Data Documentation

◆ BORDER_SIZE

const int EDIT_POINT::BORDER_SIZE = 2
staticinherited

Border size when not hovering.

Definition at line 188 of file edit_points.h.

Referenced by KIGFX::PREVIEW::ANGLE_ITEM::drawPreviewShape(), and EDIT_POINTS::ViewDraw().

◆ HOVER_SIZE

const int EDIT_POINT::HOVER_SIZE = 5
staticinherited

Border size when hovering.

Definition at line 189 of file edit_points.h.

Referenced by EDIT_POINTS::ViewDraw().

◆ m_connected

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

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

Definition at line 202 of file edit_points.h.

Referenced by GetConnected().

◆ m_dragPolicy

std::shared_ptr<POLYGON_EDGE_DRAG_POLICY> EDIT_LINE::m_dragPolicy
private

Definition at line 357 of file edit_points.h.

Referenced by ApplyRelation(), GetDragPolicy(), IsConstrained(), and SetDragPolicy().

◆ m_drawCircle

bool EDIT_POINT::m_drawCircle
privateinherited

True if the point is drawn circular.

Definition at line 196 of file edit_points.h.

Referenced by DrawCircle(), and SetDrawCircle().

◆ m_end

EDIT_POINT& EDIT_LINE::m_end
private

End point for a line.

Definition at line 350 of file edit_points.h.

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

◆ m_gridConstraint

GRID_CONSTRAINT_TYPE EDIT_POINT::m_gridConstraint
privateinherited

Describe the grid snapping behavior.

Definition at line 197 of file edit_points.h.

Referenced by GetGridConstraint(), and SetGridConstraint().

◆ m_hasCenterPoint

bool EDIT_LINE::m_hasCenterPoint = true
private

True if the line has a (useful) center point.

Definition at line 352 of file edit_points.h.

Referenced by HasCenterPoint(), and SetHasCenterPoint().

◆ m_isActive

bool EDIT_POINT::m_isActive
privateinherited

True if this point is being manipulated.

Definition at line 194 of file edit_points.h.

Referenced by IsActive(), and SetActive().

◆ m_isHover

bool EDIT_POINT::m_isHover
privateinherited

True if this point is being hovered over.

Definition at line 195 of file edit_points.h.

Referenced by IsHover(), and SetHover().

◆ m_origin

EDIT_POINT& EDIT_LINE::m_origin
private

Origin point for a line.

Definition at line 349 of file edit_points.h.

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

◆ m_position

VECTOR2I EDIT_POINT::m_position
privateinherited

Position of EDIT_POINT.

Definition at line 193 of file edit_points.h.

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

◆ m_relation

std::shared_ptr<EDIT_RELATION> EDIT_LINE::m_relation
private

Relation and geometry policy for the line, NULL if absent.

Definition at line 356 of file edit_points.h.

Referenced by ApplyRelation(), GetRelation(), IsConstrained(), and SetRelation().

◆ m_showLine

bool EDIT_LINE::m_showLine = false
private

True if the line itself should be drawn.

Definition at line 353 of file edit_points.h.

Referenced by DrawLine(), and SetDrawLine().

◆ m_snapConstraint

SNAP_CONSTRAINT_TYPE EDIT_POINT::m_snapConstraint
privateinherited

Describe the object snapping behavior.

Definition at line 198 of file edit_points.h.

Referenced by GetSnapConstraint(), and SetSnapConstraint().

◆ POINT_SIZE

const int EDIT_POINT::POINT_SIZE = 8
staticinherited

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