KiCad PCB EDA Suite
EC_CONVERGING Class Reference

Class EC_CONVERGING. More...

#include <edit_constraints.h>

Inheritance diagram for EC_CONVERGING:
EDIT_CONSTRAINT< EDIT_LINE >

Public Member Functions

 EC_CONVERGING (EDIT_LINE &aLine, EDIT_POINTS &aPoints)
 
virtual ~EC_CONVERGING ()
 
virtual void Apply (EDIT_LINE &aHandle) override
 > More...
 
void Apply ()
 Function Apply() More...
 

Protected Attributes

EDIT_LINEm_constrained
 Point that is constrained by rules implemented by Apply() More...
 

Private Attributes

EDIT_CONSTRAINT< EDIT_POINT > * m_originSideConstraint
 

Constraint for origin side segment.

More...
 
EDIT_CONSTRAINT< EDIT_POINT > * m_endSideConstraint
 

Constraint for end side segment.

More...
 
EDIT_CONSTRAINT< EDIT_POINT > * m_colinearConstraint
 

Additional constriant, applied when at least two points are collinear.

More...
 
EDIT_POINTSm_editPoints
 

EDIT_POINTS instance that stores currently modified lines.

More...
 
VECTOR2I m_draggedVector
 

Vector that represents the initial direction of the dragged segment.

More...
 

Detailed Description

Class EC_CONVERGING.

EDIT_CONSTRAINT for 3 segments: dragged and two adjacent ones, enforcing to keep their slopes and allows only to change ending points. Applied to zones.

Definition at line 212 of file edit_constraints.h.

Constructor & Destructor Documentation

EC_CONVERGING::EC_CONVERGING ( EDIT_LINE aLine,
EDIT_POINTS aPoints 
)

Definition at line 94 of file edit_constraints.cpp.

References EDIT_LINE::GetEnd(), EDIT_LINE::GetOrigin(), EDIT_POINT::GetPosition(), m_colinearConstraint, m_draggedVector, m_endSideConstraint, m_originSideConstraint, EDIT_POINTS::Next(), and EDIT_POINTS::Previous().

94  :
96  m_colinearConstraint( NULL ), m_editPoints( aPoints )
97 {
98  // Dragged segment endings
99  EDIT_POINT& origin = aLine.GetOrigin();
100  EDIT_POINT& end = aLine.GetEnd();
101 
102  // Previous and next points, to make constraining lines (adjacent to the dragged line)
103  EDIT_POINT& prevOrigin = *aPoints.Previous( origin, false );
104  EDIT_POINT& nextEnd = *aPoints.Next( end, false );
105 
106  // Constraints for segments adjacent to the dragged one
107  m_originSideConstraint = new EC_LINE( origin, prevOrigin );
108  m_endSideConstraint = new EC_LINE( end, nextEnd );
109 
110  // Store the current vector of the line
111  m_draggedVector = end.GetPosition() - origin.GetPosition();
112 
113  // Check for colinearity
114  SEG originSide( origin.GetPosition(), prevOrigin.GetPosition() );
115  SEG endSide( end.GetPosition(), nextEnd.GetPosition() );
116  SEG dragged( origin.GetPosition(), end.GetPosition() );
117 
118  if( dragged.Collinear( originSide ) )
120  else if( dragged.Collinear( endSide ) )
122 }
EDIT_POINT * Next(const EDIT_POINT &aPoint, bool aTraverseContours=true)
Function Next()
EDIT_CONSTRAINT< EDIT_POINT > * m_colinearConstraint
Additional constriant, applied when at least two points are collinear.
Class EC_LINE.
EDIT_POINT & GetOrigin()
Function GetOrigin()
Definition: edit_points.h:256
EDIT_POINT & GetEnd()
Function GetEnd()
Definition: edit_points.h:271
EDIT_CONSTRAINT< EDIT_POINT > * m_endSideConstraint
Constraint for end side segment.
EDIT_CONSTRAINT< EDIT_POINT > * m_originSideConstraint
Constraint for origin side segment.
Definition: seg.h:37
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
VECTOR2I m_draggedVector
Vector that represents the initial direction of the dragged segment.
EDIT_POINTS & m_editPoints
EDIT_POINTS instance that stores currently modified lines.
EDIT_POINT * Previous(const EDIT_POINT &aPoint, bool aTraverseContours=true)
Function Previous()
Class EDIT_POINT.
Definition: edit_points.h:46
EC_CONVERGING::~EC_CONVERGING ( )
virtual

Definition at line 125 of file edit_constraints.cpp.

References m_endSideConstraint, and m_originSideConstraint.

126 {
127  delete m_originSideConstraint;
128  delete m_endSideConstraint;
129  // m_colinearConstraint should not be freed, it is a pointer to one of the above
130 }
EDIT_CONSTRAINT< EDIT_POINT > * m_endSideConstraint
Constraint for end side segment.
EDIT_CONSTRAINT< EDIT_POINT > * m_originSideConstraint
Constraint for origin side segment.

Member Function Documentation

void EDIT_CONSTRAINT< EDIT_LINE >::Apply ( )
inlineinherited

Function Apply()

Corrects coordinates of the constrained edit handle.

Definition at line 66 of file edit_constraints.h.

References EDIT_CONSTRAINT< EDIT_TYPE >::Apply(), and EDIT_CONSTRAINT< EDIT_TYPE >::m_constrained.

67  {
69  }
void Apply()
Function Apply()
EDIT_LINE & m_constrained
Point that is constrained by rules implemented by Apply()
void EC_CONVERGING::Apply ( EDIT_LINE aHandle)
overridevirtual

>

Function Apply() Corrects coordinates of the constrained edit handle.

Implements EDIT_CONSTRAINT< EDIT_LINE >.

Definition at line 133 of file edit_constraints.cpp.

References EDIT_CONSTRAINT< EDIT_TYPE >::Apply(), EDIT_LINE::GetEnd(), EDIT_LINE::GetOrigin(), EDIT_POINT::GetPosition(), SEG::Intersect(), m_colinearConstraint, m_draggedVector, m_editPoints, m_endSideConstraint, m_originSideConstraint, EDIT_POINTS::Next(), EDIT_POINTS::Previous(), and EDIT_POINT::SetPosition().

134 {
135  // The dragged segment endpoints
136  EDIT_POINT& origin = aHandle.GetOrigin();
137  EDIT_POINT& end = aHandle.GetEnd();
138 
140  {
141  m_colinearConstraint->Apply( origin );
142  m_colinearConstraint->Apply( end );
143  }
144 
145  // The dragged segment
146  SEG dragged( origin.GetPosition(), origin.GetPosition() + m_draggedVector );
147 
148  // Do not allow points on the adjacent segments move freely
151 
152  EDIT_POINT& prevOrigin = *m_editPoints.Previous( origin, false );
153  EDIT_POINT& nextEnd = *m_editPoints.Next( end, false );
154 
155  // Two segments adjacent to the dragged segment
156  SEG originSide = SEG( origin.GetPosition(), prevOrigin.GetPosition() );
157  SEG endSide = SEG( end.GetPosition(), nextEnd.GetPosition() );
158 
159  // First intersection point (dragged segment against origin side)
160  if( OPT_VECTOR2I originIntersect = dragged.IntersectLines( originSide ) )
161  origin.SetPosition( *originIntersect );
162 
163  // Second intersection point (dragged segment against end side)
164  if( OPT_VECTOR2I endIntersect = dragged.IntersectLines( endSide ) )
165  end.SetPosition( *endIntersect );
166 
167  // Check if adjacent segments intersect (did we dragged the line to the point that it may
168  // create a selfintersecting polygon?)
169  originSide = SEG( origin.GetPosition(), prevOrigin.GetPosition() );
170  endSide = SEG( end.GetPosition(), nextEnd.GetPosition() );
171 
172  if( OPT_VECTOR2I originEndIntersect = endSide.Intersect( originSide ) )
173  {
174  origin.SetPosition( *originEndIntersect );
175  end.SetPosition( *originEndIntersect );
176  }
177 }
EDIT_POINT * Next(const EDIT_POINT &aPoint, bool aTraverseContours=true)
Function Next()
EDIT_CONSTRAINT< EDIT_POINT > * m_colinearConstraint
Additional constriant, applied when at least two points are collinear.
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Function Intersect()
Definition: seg.cpp:99
EDIT_POINT & GetOrigin()
Function GetOrigin()
Definition: edit_points.h:256
EDIT_POINT & GetEnd()
Function GetEnd()
Definition: edit_points.h:271
EDIT_CONSTRAINT< EDIT_POINT > * m_endSideConstraint
Constraint for end side segment.
EDIT_CONSTRAINT< EDIT_POINT > * m_originSideConstraint
Constraint for origin side segment.
Definition: seg.h:37
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
VECTOR2I m_draggedVector
Vector that represents the initial direction of the dragged segment.
virtual void Apply(EDIT_TYPE &aHandle)=0
Function Apply()
EDIT_POINTS & m_editPoints
EDIT_POINTS instance that stores currently modified lines.
EDIT_POINT * Previous(const EDIT_POINT &aPoint, bool aTraverseContours=true)
Function Previous()
Class EDIT_POINT.
Definition: edit_points.h:46
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()
Definition: edit_points.h:97

Member Data Documentation

EDIT_CONSTRAINT<EDIT_POINT>* EC_CONVERGING::m_colinearConstraint
private

Additional constriant, applied when at least two points are collinear.

It is a pointer to

m_[origin/end]SideConstraint, so it should not be freed.

Definition at line 231 of file edit_constraints.h.

Referenced by Apply(), and EC_CONVERGING().

EDIT_LINE & EDIT_CONSTRAINT< EDIT_LINE >::m_constrained
protectedinherited

Point that is constrained by rules implemented by Apply()

Definition at line 72 of file edit_constraints.h.

VECTOR2I EC_CONVERGING::m_draggedVector
private

Vector that represents the initial direction of the dragged segment.

Definition at line 237 of file edit_constraints.h.

Referenced by Apply(), and EC_CONVERGING().

EDIT_POINTS& EC_CONVERGING::m_editPoints
private

EDIT_POINTS instance that stores currently modified lines.

Definition at line 234 of file edit_constraints.h.

Referenced by Apply().

EDIT_CONSTRAINT<EDIT_POINT>* EC_CONVERGING::m_endSideConstraint
private

Constraint for end side segment.

Definition at line 227 of file edit_constraints.h.

Referenced by Apply(), EC_CONVERGING(), and ~EC_CONVERGING().

EDIT_CONSTRAINT<EDIT_POINT>* EC_CONVERGING::m_originSideConstraint
private

Constraint for origin side segment.

Definition at line 224 of file edit_constraints.h.

Referenced by Apply(), EC_CONVERGING(), and ~EC_CONVERGING().


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