Commit ac1386a5 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix bug 1179877, due a bad default copy constructor, after my...

Pcbnew: fix bug 1179877, due a bad default  copy constructor, after  my changes about CPOLYGONS_LIST class.
More about CPOLYGONS_LIST work.
parent 6fa4f1e6
......@@ -182,9 +182,9 @@ void EDA_3D_CANVAS::BuildBoard3DView()
if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
continue;
bufferPolys.clear();
bufferZonesPolys.clear();
currLayerHoles.clear();
bufferPolys.RemoveAllContours();
bufferZonesPolys.RemoveAllContours();
currLayerHoles.RemoveAllContours();
// Draw tracks:
for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
......@@ -308,7 +308,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
SetGLColor( color );
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
bufferPolys.clear();
bufferPolys.RemoveAllContours();
bufferPolys.ImportFrom( currLayerPolyset );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness,
......@@ -346,7 +346,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
continue;
bufferPolys.clear();
bufferPolys.RemoveAllContours();
for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() )
{
......@@ -429,7 +429,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
SetGLColor( color );
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
bufferPolys.clear();
bufferPolys.RemoveAllContours();
bufferPolys.ImportFrom( currLayerPolyset );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
......@@ -480,7 +480,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
0.0F );
// Draw Board:
// For testing purpose only display calculation time to generate 3D data
// For testing purpose only, display calculation time to generate 3D data
// #define PRINT_CALCULATION_TIME
#ifdef PRINT_CALCULATION_TIME
......
......@@ -496,9 +496,8 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
bool SCH_SCREEN::Save( FILE* aFile ) const
{
// Creates header
if( fprintf( aFile, "%s %s %d", EESCHEMA_FILE_STAMP,
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0
|| fprintf( aFile, " date %s\n", TO_UTF8( DateAndTime() ) ) < 0 )
if( fprintf( aFile, "%s %s %d\n", EESCHEMA_FILE_STAMP,
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0 )
return false;
BOOST_FOREACH( const CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
......
......@@ -139,7 +139,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
corner.y += GetPosition().y;
aCornerBuffer.Append( corner );
}
aCornerBuffer.back().end_contour = true;
aCornerBuffer.CloseLastContour();
break;
default:
......@@ -242,7 +242,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
aCornerBuffer.Append( corners[ii] );
}
aCornerBuffer.back().end_contour = true;
aCornerBuffer.CloseLastContour();
}
......@@ -875,7 +875,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
aCornerBuffer.Append( CPolyPt( cpos.x, cpos.y ) );
}
aCornerBuffer.back().end_contour = true;
aCornerBuffer.CloseLastContour();
angle = AddAngles( angle, 1800 ); // this is calculate hole 3
}
......@@ -900,7 +900,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
aCornerBuffer.Append( CPolyPt( cpos.x, cpos.y ) );
}
aCornerBuffer.back().end_contour = true;
aCornerBuffer.CloseLastContour();
angle = AddAngles( angle, 1800 );
}
}
......
......@@ -90,8 +90,8 @@ ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
m_PadConnection = aZone.m_PadConnection;
m_ThermalReliefGap = aZone.m_ThermalReliefGap;
m_ThermalReliefCopperBridge = aZone.m_ThermalReliefCopperBridge;
m_FilledPolysList = aZone.m_FilledPolysList;
m_FillSegmList = aZone.m_FillSegmList;
m_FilledPolysList.Append( aZone.m_FilledPolysList );
m_FillSegmList = aZone.m_FillSegmList; // vector <> copy
m_isKeepout = aZone.m_isKeepout;
m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
......@@ -123,7 +123,7 @@ bool ZONE_CONTAINER::UnFill()
bool change = ( m_FilledPolysList.GetCornersCount() > 0 ) ||
( m_FillSegmList.size() > 0 );
m_FilledPolysList.clear();
m_FilledPolysList.RemoveAllContours();
m_FillSegmList.clear();
m_IsFilled = false;
......@@ -740,7 +740,7 @@ void ZONE_CONTAINER::Move( const wxPoint& offset )
for( unsigned ic = 0; ic < m_FilledPolysList.GetCornersCount(); ic++ )
{
m_FilledPolysList.SetX( ic, m_FilledPolysList.GetX( ic ) + offset.x );
m_FilledPolysList.SetY( ic, m_FilledPolysList.GetX( ic ) + offset.y );
m_FilledPolysList.SetY( ic, m_FilledPolysList.GetY( ic ) + offset.y );
}
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
......@@ -863,8 +863,8 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
m_Poly->SetHatchStyle( src->m_Poly->GetHatchStyle() );
m_Poly->SetHatchPitch( src->m_Poly->GetHatchPitch() );
m_Poly->m_HatchLines = src->m_Poly->m_HatchLines; // Copy vector <CSegment>
m_FilledPolysList.clear();
m_FilledPolysList = src->m_FilledPolysList;
m_FilledPolysList.RemoveAllContours();
m_FilledPolysList.Append( src->m_FilledPolysList );
m_FillSegmList.clear();
m_FillSegmList = src->m_FillSegmList;
}
......
......@@ -498,7 +498,7 @@ public:
*/
void ClearFilledPolysList()
{
m_FilledPolysList.clear();
m_FilledPolysList.RemoveAllContours();
}
/**
......
......@@ -58,7 +58,7 @@ bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
CPOLYGONS_LIST* aCornerBuffer )
{
if( aCornerBuffer == NULL )
m_FilledPolysList.clear();
m_FilledPolysList.RemoveAllContours();
/* convert outlines + holes to outlines without holes (adding extra segments if necessary)
* m_Poly data is expected normalized, i.e. NormalizeAreaOutlines was used after building
......@@ -121,7 +121,7 @@ bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
CopyPolygonsFromFilledPolysListToKiPolygonList( polyset_zone_solid_areas );
polyset_zone_solid_areas -= margin;
// put solid area in m_FilledPolysList:
m_FilledPolysList.clear();
m_FilledPolysList.RemoveAllContours();
CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
}
if ( m_FillMode ) // if fill mode uses segments, create them:
......
......@@ -188,7 +188,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
// static to avoid unnecessary memory allocation when filling many zones.
static CPOLYGONS_LIST cornerBufferPolysToSubstract;
cornerBufferPolysToSubstract.clear();
cornerBufferPolysToSubstract.RemoveAllContours();
/* Use a dummy pad to calculate hole clerance when a pad is not on all copper layers
* and this pad has a hole
......@@ -423,7 +423,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
}
// put solid areas in m_FilledPolysList:
m_FilledPolysList.clear();
m_FilledPolysList.RemoveAllContours();
CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
// Remove insulated islands:
......@@ -431,7 +431,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
TestForCopperIslandAndRemoveInsulatedIslands( aPcb );
// Now we remove all unused thermal stubs.
cornerBufferPolysToSubstract.clear();
cornerBufferPolysToSubstract.RemoveAllContours();
// Test thermal stubs connections and add polygons to remove unconnected stubs.
// (this is a refinement for thermal relief shapes)
......@@ -449,20 +449,20 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
polyset_zone_solid_areas -= polyset_holes;
// put these areas in m_FilledPolysList
m_FilledPolysList.clear();
m_FilledPolysList.RemoveAllContours();
CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
if( GetNet() > 0 )
TestForCopperIslandAndRemoveInsulatedIslands( aPcb );
}
cornerBufferPolysToSubstract.clear();
cornerBufferPolysToSubstract.RemoveAllContours();
}
void ZONE_CONTAINER::CopyPolygonsFromKiPolygonListToFilledPolysList( KI_POLYGON_SET& aKiPolyList )
{
m_FilledPolysList.clear();
m_FilledPolysList.RemoveAllContours();
m_FilledPolysList.ImportFrom( aKiPolyList );
}
......
......@@ -25,6 +25,12 @@ CPolyLine::CPolyLine()
m_utility = 0;
}
CPolyLine::CPolyLine( const CPolyLine& aCPolyLine)
{
Copy( &aCPolyLine );
m_HatchLines = aCPolyLine.m_HatchLines; // vector <> copy
}
// destructor, removes display elements
//
......@@ -517,11 +523,11 @@ void CPolyLine::RemoveAllContours( void )
/**
* function RemoveAllContours
* removes all corners from the lists.
* Others params are not chnaged
* removes all corners from the list.
* Others params are not changed
*/
{
m_CornersList.clear();
m_CornersList.RemoveAllContours();
}
......@@ -937,27 +943,25 @@ bool CPolyLine::TestPointInside( int px, int py )
}
// copy data from another poly, but don't draw it
//
void CPolyLine::Copy( CPolyLine* src )
// copy data from another CPolyLine, but don't draw it
void CPolyLine::Copy( const CPolyLine* src )
{
UnHatch();
m_layer = src->m_layer;
m_hatchStyle = src->m_hatchStyle;
m_hatchPitch = src->m_hatchPitch;
// copy corners, using vector copy
m_CornersList = src->m_CornersList;
m_CornersList.RemoveAllContours();
m_CornersList.Append( src->m_CornersList );
}
/*******************************************/
bool CPolyLine::IsCutoutContour( int icont )
/*******************************************/
/*
* return true if the corner icont is inside the outline (i.e it is a hole)
* return true if the corner aCornerIdx is on a hole inside the main outline
* and false if it is on the main outline
*/
bool CPolyLine::IsCutoutContour( int aCornerIdx )
{
int ncont = GetContour( icont );
int ncont = GetContour( aCornerIdx );
if( ncont == 0 ) // the first contour is the main outline, not an hole
return false;
......
......@@ -117,8 +117,10 @@ public:
// vector <> methods
void reserve( int aSize ) { m_cornersList.reserve( aSize ); }
void clear() { m_cornersList.clear(); }
CPolyPt& back() { return m_cornersList.back(); }
void RemoveAllContours( void ) { m_cornersList.clear(); }
CPolyPt& GetLastCorner() { return m_cornersList.back(); }
unsigned GetCornersCount() const { return m_cornersList.size(); }
......@@ -206,6 +208,7 @@ public:
// constructors/destructor
CPolyLine();
CPolyLine( const CPolyLine& aCPolyLine);
~CPolyLine();
/**
......@@ -296,9 +299,14 @@ public:
CRect GetBounds();
CRect GetCornerBounds();
CRect GetCornerBounds( int icont );
void Copy( CPolyLine* src );
void Copy( const CPolyLine* src );
bool TestPointInside( int x, int y );
bool IsCutoutContour( int icont );
/**
* @return true if the corner aCornerIdx is on a hole inside the main outline
* and false if it is on the main outline
*/
bool IsCutoutContour( int aCornerIdx );
/**
* Function AppendArc.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment