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 );
|
return CVertex( index.m_vertex, index.m_polygon, index.m_contour - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SHAPE_POLY_SET::GetNeighbourIndexes( int aGlobalIndex, int* aPrevious, int* aNext )
|
||||||
SEG SHAPE_POLY_SET::Edge( int aGlobalIndex )
|
|
||||||
{
|
{
|
||||||
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 the edge does not exist, throw an exception, it is an illegal access memory error
|
||||||
if( !GetRelativeIndices( aGlobalIndex, &indices ) )
|
if( !GetRelativeIndices( aGlobalIndex, &index ) )
|
||||||
throw( std::out_of_range( "aGlobalIndex-th edge does not exist" ) );
|
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.
|
* vertex.
|
||||||
* @param aRelativeIndices is the set of relative indices.
|
* @param aRelativeIndices is the set of relative indices.
|
||||||
* @param aGlobalIdx [out] is the computed global index.
|
* @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.
|
* global index is returned in the \p aGlobalIdx reference.
|
||||||
*/
|
*/
|
||||||
bool GetGlobalIndex( VERTEX_INDEX aRelativeIndices, int& aGlobalIdx );
|
bool GetGlobalIndex( VERTEX_INDEX aRelativeIndices, int& aGlobalIdx );
|
||||||
|
@ -462,15 +462,17 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
const VECTOR2I& CVertex( VERTEX_INDEX aIndex ) const;
|
const VECTOR2I& CVertex( VERTEX_INDEX aIndex ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Edge
|
* Returns the global indexes of the previous and the next corner
|
||||||
* Returns a reference to the aGlobalIndex-th segment in the polygon set. Modifying the
|
* of the aGlobalIndex-th corner of a contour in the polygon set.
|
||||||
* points in the returned object will modify the corresponding vertices on the polygon set.
|
* they are often aGlobalIndex-1 and aGlobalIndex+1, but not for the first and last
|
||||||
* @param aGlobalIndex is index of the edge, globally indexed between all edges in all
|
* corner of the contour.
|
||||||
|
* @param aGlobalIndex is index of the corner, globally indexed between all edges in all
|
||||||
* contours
|
* contours
|
||||||
* @return SEG - the aGlobalIndex-th segment, whose points are references to the polygon
|
* @param aPrevious - the globalIndex of the previous corner of the same contour.
|
||||||
* points.
|
* @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 )
|
void ZONE_CONTAINER::MoveEdge( const wxPoint& offset, int aEdge )
|
||||||
{
|
{
|
||||||
m_Poly->Edge( aEdge ).A += VECTOR2I( offset );
|
int next_corner;
|
||||||
m_Poly->Edge( aEdge ).B += VECTOR2I( offset );
|
|
||||||
|
|
||||||
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