PNS: Fix some off-by-one errors with arc dragging

This commit is contained in:
Jon Evans 2021-04-11 22:12:53 -04:00
parent f5ef60c2f2
commit 1c431d9929
4 changed files with 10 additions and 4 deletions

View File

@ -307,6 +307,7 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const SHAPE_LINE
// We only process lines in order in this house
wxASSERT( aStartIndex <= aEndIndex );
wxASSERT( aEndIndex < m_points.size() );
SHAPE_LINE_CHAIN newLine = aLine;

View File

@ -89,7 +89,7 @@ bool DRAGGER::startDragSegment( const VECTOR2D& aP, SEGMENT* aSeg )
else if( distB <= w2 )
{
//todo (snh) Adjust segment for arcs
if( ( m_draggedSegmentIndex < m_draggedLine.PointCount() - 1 ) &&
if( ( m_draggedSegmentIndex < m_draggedLine.PointCount() - 2 ) &&
( m_draggedLine.CLine().CShapes()[ m_draggedSegmentIndex + 1 ] < 0 ) )
{
m_draggedSegmentIndex++;
@ -100,7 +100,7 @@ bool DRAGGER::startDragSegment( const VECTOR2D& aP, SEGMENT* aSeg )
else if( m_freeAngleMode )
{
if( distB < distA &&
( m_draggedSegmentIndex < m_draggedLine.PointCount() - 1 ) &&
( m_draggedSegmentIndex < m_draggedLine.PointCount() - 2 ) &&
( m_draggedLine.CLine().CShapes()[ m_draggedSegmentIndex + 1 ] < 0 ) )
{
m_draggedSegmentIndex++;

View File

@ -723,6 +723,8 @@ void LINE::dragSegment45( const VECTOR2I& aP, int aIndex )
SHAPE_LINE_CHAIN path( m_line );
VECTOR2I target( aP );
wxASSERT( aIndex < m_line.PointCount() );
SEG guideA[2], guideB[2];
int index = aIndex;

View File

@ -970,8 +970,9 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex,
segIdxIncrement = line.PointCount() - nSegs - 1;
// Are we adding an arc after an arc? add the hidden segment
if( lastShape >= 0 )
// Are we adding an arc after an arc? add the hidden segment if the arcs overlap.
// If they don't overlap, don't add this, as it will have been added as a segment.
if( lastShape >= 0 && last == line.CPoint( nSegs ) )
segIdxIncrement++;
}
@ -980,6 +981,8 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex,
// latter condition to avoid loops
if( li == aSeg && aOriginSegmentIndex && !originSet )
{
wxASSERT( n < line.SegmentCount() ||
( n == line.SegmentCount() && li->Kind() == ITEM::SEGMENT_T ) );
*aOriginSegmentIndex = n;
originSet = true;
}