Fixes Pcbnew bug: Drag Zone Outlines no longer working in legacy view
This commit is contained in:
parent
50fd7a27cf
commit
88105f891f
|
@ -325,16 +325,50 @@ const VECTOR2I& SHAPE_POLY_SET::CVertex( SHAPE_POLY_SET::VERTEX_INDEX index ) co
|
|||
return CVertex( index.m_vertex, index.m_polygon, index.m_contour - 1 );
|
||||
}
|
||||
|
||||
|
||||
SEG SHAPE_POLY_SET::Edge( int aGlobalIndex )
|
||||
bool SHAPE_POLY_SET::GetNeighbourIndexes( int aGlobalIndex, int* aPrevious, int* aNext )
|
||||
{
|
||||
SHAPE_POLY_SET::VERTEX_INDEX indices;
|
||||
SHAPE_POLY_SET::VERTEX_INDEX index;
|
||||
|
||||
// If the edge does not exist, throw an exception, it is an illegal access memory error
|
||||
if( !GetRelativeIndices( aGlobalIndex, &indices ) )
|
||||
throw( std::out_of_range( "aGlobalIndex-th edge does not exist" ) );
|
||||
if( !GetRelativeIndices( aGlobalIndex, &index ) )
|
||||
return false;
|
||||
|
||||
return m_polys[indices.m_polygon][indices.m_contour].Segment( indices.m_vertex );
|
||||
// Calculate the previous and next index of aGlobalIndex, corresponding to
|
||||
// the same contour;
|
||||
VERTEX_INDEX inext = index;
|
||||
int lastpoint = m_polys[index.m_polygon][index.m_contour].SegmentCount();
|
||||
|
||||
if( index.m_vertex == 0 )
|
||||
{
|
||||
index.m_vertex = lastpoint;
|
||||
inext.m_vertex = 1;
|
||||
}
|
||||
else if( index.m_vertex == lastpoint )
|
||||
{
|
||||
index.m_vertex--;
|
||||
inext.m_vertex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
inext.m_vertex++;
|
||||
index.m_vertex--;
|
||||
}
|
||||
|
||||
if( aPrevious )
|
||||
{
|
||||
int previous;
|
||||
GetGlobalIndex( index, previous );
|
||||
*aPrevious = previous;
|
||||
}
|
||||
|
||||
if( aNext )
|
||||
{
|
||||
int next;
|
||||
GetGlobalIndex( inext, next );
|
||||
*aNext = next;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -392,7 +392,7 @@ class SHAPE_POLY_SET : public SHAPE
|
|||
* vertex.
|
||||
* @param aRelativeIndices is the set of relative indices.
|
||||
* @param aGlobalIdx [out] is the computed global index.
|
||||
* @return bool - true if the relative indices are correct; false otherwise. The cmoputed
|
||||
* @return bool - true if the relative indices are correct; false otherwise. The computed
|
||||
* global index is returned in the \p aGlobalIdx reference.
|
||||
*/
|
||||
bool GetGlobalIndex( VERTEX_INDEX aRelativeIndices, int& aGlobalIdx );
|
||||
|
@ -462,15 +462,17 @@ class SHAPE_POLY_SET : public SHAPE
|
|||
const VECTOR2I& CVertex( VERTEX_INDEX aIndex ) const;
|
||||
|
||||
/**
|
||||
* Function Edge
|
||||
* Returns a reference to the aGlobalIndex-th segment in the polygon set. Modifying the
|
||||
* points in the returned object will modify the corresponding vertices on the polygon set.
|
||||
* @param aGlobalIndex is index of the edge, globally indexed between all edges in all
|
||||
* Returns the global indexes of the previous and the next corner
|
||||
* of the aGlobalIndex-th corner of a contour in the polygon set.
|
||||
* they are often aGlobalIndex-1 and aGlobalIndex+1, but not for the first and last
|
||||
* corner of the contour.
|
||||
* @param aGlobalIndex is index of the corner, globally indexed between all edges in all
|
||||
* contours
|
||||
* @return SEG - the aGlobalIndex-th segment, whose points are references to the polygon
|
||||
* points.
|
||||
* @param aPrevious - the globalIndex of the previous corner of the same contour.
|
||||
* @param aNext - the globalIndex of the next corner of the same contour.
|
||||
* @return true if OK, false if aGlobalIndex is out of range
|
||||
*/
|
||||
SEG Edge( int aGlobalIndex );
|
||||
bool GetNeighbourIndexes( int aGlobalIndex, int* aPrevious, int* aNext );
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -729,10 +729,14 @@ void ZONE_CONTAINER::Move( const wxPoint& offset )
|
|||
|
||||
void ZONE_CONTAINER::MoveEdge( const wxPoint& offset, int aEdge )
|
||||
{
|
||||
m_Poly->Edge( aEdge ).A += VECTOR2I( offset );
|
||||
m_Poly->Edge( aEdge ).B += VECTOR2I( offset );
|
||||
int next_corner;
|
||||
|
||||
Hatch();
|
||||
if( m_Poly->GetNeighbourIndexes( aEdge, nullptr, &next_corner ) )
|
||||
{
|
||||
m_Poly->Vertex( aEdge ) += VECTOR2I( offset );
|
||||
m_Poly->Vertex( next_corner ) += VECTOR2I( offset );
|
||||
Hatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue