|
|
@ -39,17 +39,17 @@ bool POLYGON_GEOM_MANAGER::AddPoint( const VECTOR2I& aPt ) |
|
|
|
if( !IsPolygonInProgress() && !m_client.OnFirstPoint( *this ) ) |
|
|
|
return false; |
|
|
|
|
|
|
|
if( m_leaderPts.size() > 1 ) |
|
|
|
if( m_leaderPts.PointCount() > 1 ) |
|
|
|
{ |
|
|
|
// there are enough leader points - the next
|
|
|
|
// locked-in point is the end of the first leader
|
|
|
|
// segment
|
|
|
|
m_lockedPoints.push_back( m_leaderPts[1] ); |
|
|
|
m_lockedPoints.Append( m_leaderPts.CPoint( 1 ) ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// no leader lines, directly add the cursor
|
|
|
|
m_lockedPoints.push_back( aPt ); |
|
|
|
m_lockedPoints.Append( aPt ); |
|
|
|
} |
|
|
|
|
|
|
|
m_client.OnGeometryChange( *this ); |
|
|
@ -77,28 +77,28 @@ void POLYGON_GEOM_MANAGER::SetCursorPosition( const VECTOR2I& aPos, LEADER_MODE |
|
|
|
|
|
|
|
bool POLYGON_GEOM_MANAGER::IsPolygonInProgress() const |
|
|
|
{ |
|
|
|
return m_lockedPoints.size() > 0; |
|
|
|
return m_lockedPoints.PointCount() > 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool POLYGON_GEOM_MANAGER::NewPointClosesOutline( const VECTOR2I& aPt ) const |
|
|
|
{ |
|
|
|
return m_lockedPoints.size() && m_lockedPoints[0] == aPt; |
|
|
|
return m_lockedPoints.PointCount() > 0 && m_lockedPoints.CPoint( 0 ) == aPt; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void POLYGON_GEOM_MANAGER::DeleteLastCorner() |
|
|
|
{ |
|
|
|
if( m_lockedPoints.size() > 0 ) |
|
|
|
if( m_lockedPoints.PointCount() > 0 ) |
|
|
|
{ |
|
|
|
m_lockedPoints.pop_back(); |
|
|
|
m_lockedPoints.Remove( m_lockedPoints.PointCount() - 1 ); |
|
|
|
} |
|
|
|
|
|
|
|
// update the new last segment (was previously
|
|
|
|
// locked in), reusing last constraints
|
|
|
|
if( m_lockedPoints.size() > 0 ) |
|
|
|
if( m_lockedPoints.PointCount() > 0 ) |
|
|
|
{ |
|
|
|
updateLeaderPoints( m_leaderPts.back() ); |
|
|
|
updateLeaderPoints( m_leaderPts.CLastPoint() ); |
|
|
|
} |
|
|
|
|
|
|
|
m_client.OnGeometryChange( *this ); |
|
|
@ -107,8 +107,8 @@ void POLYGON_GEOM_MANAGER::DeleteLastCorner() |
|
|
|
|
|
|
|
void POLYGON_GEOM_MANAGER::Reset() |
|
|
|
{ |
|
|
|
m_lockedPoints.clear(); |
|
|
|
m_leaderPts.clear(); |
|
|
|
m_lockedPoints.Clear(); |
|
|
|
m_leaderPts.Clear(); |
|
|
|
|
|
|
|
m_client.OnGeometryChange( *this ); |
|
|
|
} |
|
|
@ -116,13 +116,16 @@ void POLYGON_GEOM_MANAGER::Reset() |
|
|
|
|
|
|
|
void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint, LEADER_MODE aModifier ) |
|
|
|
{ |
|
|
|
wxCHECK( m_lockedPoints.PointCount() > 0, /*void*/ ); |
|
|
|
SHAPE_LINE_CHAIN newChain; |
|
|
|
|
|
|
|
const VECTOR2I& lastPt = m_lockedPoints.CLastPoint(); |
|
|
|
|
|
|
|
if( m_leaderMode == LEADER_MODE::DEG45 || aModifier == LEADER_MODE::DEG45 ) |
|
|
|
{ |
|
|
|
// get a restricted 45/H/V line from the last fixed point to the cursor
|
|
|
|
DIRECTION_45 direction( m_lockedPoints.back() - aEndPoint ); |
|
|
|
newChain = direction.BuildInitialTrace( m_lockedPoints.back(), aEndPoint ); |
|
|
|
DIRECTION_45 direction( lastPt - aEndPoint ); |
|
|
|
m_leaderPts = direction.BuildInitialTrace( lastPt, aEndPoint ); |
|
|
|
|
|
|
|
// Can also add chain back to start, but this rearely produces
|
|
|
|
// usable result
|
|
|
@ -132,28 +135,8 @@ void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint, LEADER |
|
|
|
else |
|
|
|
{ |
|
|
|
// direct segment
|
|
|
|
newChain = SHAPE_LINE_CHAIN( m_lockedPoints.back(), aEndPoint ); |
|
|
|
} |
|
|
|
|
|
|
|
// rebuild leader point list from the chain
|
|
|
|
m_leaderPts.clear(); |
|
|
|
|
|
|
|
for( int i = 0; i < newChain.PointCount(); ++i ) |
|
|
|
{ |
|
|
|
m_leaderPts.push_back( newChain.Point( i ) ); |
|
|
|
m_leaderPts = SHAPE_LINE_CHAIN( lastPt, aEndPoint ); |
|
|
|
} |
|
|
|
|
|
|
|
m_client.OnGeometryChange( *this ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const std::vector<VECTOR2I>& POLYGON_GEOM_MANAGER::GetLockedInPoints() const |
|
|
|
{ |
|
|
|
return m_lockedPoints; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const std::vector<VECTOR2I>& POLYGON_GEOM_MANAGER::GetLeaderLinePoints() const |
|
|
|
{ |
|
|
|
return m_leaderPts; |
|
|
|
} |