3D viewer: fix (the fix is not perfect) a minor issue in zone rendering: copper thickness was not good when the option 'Show Holes in Zones" was OFF, and "Show Copper Thickness" ON.

Fix a few coverity minor warnings.
This commit is contained in:
jean-pierre charras 2015-04-12 19:44:46 +02:00
parent cec0a956bd
commit c519eea12b
9 changed files with 51 additions and 34 deletions

View File

@ -793,7 +793,11 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
} }
} }
// Draw copper zones // Draw copper zones. Note:
// * if the holes are removed from copper zones
// the polygons are stored in bufferPolys (which contains all other polygons)
// * if the holes are NOT removed from copper zones
// the polygons are stored in bufferZonesPolys
if( isEnabled( FL_ZONE ) ) if( isEnabled( FL_ZONE ) )
{ {
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
@ -844,13 +848,13 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
// Add polygons, without holes // Add polygons, without holes
bufferPolys.ExportTo( currLayerPolyset ); bufferPolys.ExportTo( currLayerPolyset );
// Add holes in polygon list // Add through holes (created only once) in current polygon holes list
currLayerHoles.Append( allLayerHoles ); currLayerHoles.Append( allLayerHoles );
if( currLayerHoles.GetCornersCount() > 0 ) if( currLayerHoles.GetCornersCount() > 0 )
currLayerHoles.ExportTo( polysetHoles ); currLayerHoles.ExportTo( polysetHoles );
// Merge polygons, remove holes // Merge polygons, and remove holes
currLayerPolyset -= polysetHoles; currLayerPolyset -= polysetHoles;
int thickness = GetPrm3DVisu().GetLayerObjectThicknessBIU( layer ); int thickness = GetPrm3DVisu().GetLayerObjectThicknessBIU( layer );
@ -866,40 +870,39 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
SetGLColor( color ); SetGLColor( color );
} }
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
bufferPolys.RemoveAllContours(); bufferPolys.RemoveAllContours();
bufferPolys.ImportFrom( currLayerPolyset ); bufferPolys.ImportFrom( currLayerPolyset );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, // If holes are removed from copper zones, bufferPolys contains all polygons
// to draw (tracks+zones+texts).
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, thickness,
GetPrm3DVisu().m_BiuTo3Dunits, useTextures ); GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
if( isEnabled( FL_USE_COPPER_THICKNESS ) == true ) // If holes are not removed from copper zones (for calculation time reasons,
// the zone polygons are stored in bufferZonesPolys and have to be drawn now:
if( bufferZonesPolys.GetCornersCount() )
{ {
thickness -= ( 0.04 * IU_PER_MM ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos, thickness,
GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
} }
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
if( bufferZonesPolys.GetCornersCount() )
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos,
thickness,
GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
throughHolesListBuilt = true; throughHolesListBuilt = true;
} }
if ( !isEnabled( FL_SHOW_BOARD_BODY ) || if( !isEnabled( FL_SHOW_BOARD_BODY ) || isEnabled( FL_USE_COPPER_THICKNESS ) )
isEnabled( FL_USE_COPPER_THICKNESS ) )
{ {
setGLCopperColor(); setGLCopperColor();
// Draw vias holes (vertical cylinders) // Draw vias holes (vertical cylinders)
for( const TRACK* track = pcb->m_Track; track; track = track->Next() ) for( const TRACK* track = pcb->m_Track; track; track = track->Next() )
{ {
const VIA *via = dynamic_cast<const VIA*>(track); if( track->Type() == PCB_VIA_T )
{
if( via ) const VIA *via = static_cast<const VIA*>(track);
draw3DViaHole( via ); draw3DViaHole( via );
}
} }
// Draw pads holes (vertical cylinders) // Draw pads holes (vertical cylinders)

View File

@ -245,12 +245,11 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
gluDeleteTess( tess ); gluDeleteTess( tess );
if( aThickness == 0 ) if( aThickness == 0 )
{
return; return;
}
// Build the 3D data : vertical side // Build the 3D data : vertical side
Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0), true, aBiuTo3DUnits ); Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0),
true, aBiuTo3DUnits );
} }
@ -294,7 +293,7 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
if( aHeight ) if( aHeight )
{ {
// Draw the vertical outer side // Draw the vertical outer side
Draw3D_VerticalPolygonalCylinder( outer_cornerBuffer, Draw3D_VerticalPolygonalCylinder( outer_cornerBuffer,
aHeight, aZpos, false, aBiuTo3DUnits ); aHeight, aZpos, false, aBiuTo3DUnits );

View File

@ -435,16 +435,15 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
NETLIST_OBJECT* candidate; NETLIST_OBJECT* candidate;
// Pass 1: find the best name for labelled nets: // Pass 1: find the best name for labelled nets:
item = NULL;
candidate = NULL; candidate = NULL;
for( unsigned ii = 0; ii <= size(); ii++ ) for( unsigned ii = 0; ii <= size(); ii++ )
{ {
if( ii == size() ) // last item already found if( ii == size() ) // last item already tested
netcode = -2; item = NULL;
else else
item = GetItem( ii ); item = GetItem( ii );
if( netcode != item->GetNet() ) // End of net found if( !item || netcode != item->GetNet() ) // End of net found
{ {
if( candidate ) // One or more labels exists, find the best if( candidate ) // One or more labels exists, find the best
{ {
@ -452,7 +451,7 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
GetItem( jj )->SetNetNameCandidate( candidate ); GetItem( jj )->SetNetNameCandidate( candidate );
} }
if( netcode == -2 ) if( item == NULL )
break; break;
netcode = item->GetNet(); netcode = item->GetNet();
@ -512,8 +511,10 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
{ {
if( ii < list.size() ) if( ii < list.size() )
item = list.GetItem( ii ); item = list.GetItem( ii );
else
item = NULL;
if( netcode != item->GetNet() || ii >= list.size() ) // End of net found if( !item || netcode != item->GetNet() ) // End of net found
{ {
if( candidate ) if( candidate )
{ {
@ -524,7 +525,7 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
} }
} }
if( ii >= list.size() ) if( !item )
break; break;
netcode = item->GetNet(); netcode = item->GetNet();

View File

@ -260,6 +260,7 @@ public:
m_foundIndex = 0; m_foundIndex = 0;
SetForceSearch( false ); SetForceSearch( false );
m_sheetPath = NULL; m_sheetPath = NULL;
m_lib_hash = 0;
} }
void Empty() void Empty()

View File

@ -119,6 +119,12 @@ public:
class NETINFO_MAPPING class NETINFO_MAPPING
{ {
public: public:
NETINFO_MAPPING()
{
m_board = NULL;
}
/** /**
* Function SetBoard * Function SetBoard
* Sets a BOARD object that is used to prepare the net code map. * Sets a BOARD object that is used to prepare the net code map.

View File

@ -1677,7 +1677,8 @@ void PCB_BASE_EDIT_FRAME::createArray()
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( new_item ); EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( new_item );
text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) ); if( text )
text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) );
break; break;
} }

View File

@ -67,6 +67,7 @@ public:
{ {
m_segmentRefs = NULL; m_segmentRefs = NULL;
m_hasVia = false; m_hasVia = false;
m_width = 1; // Dummy value
} }
PNS_LINE( const PNS_LINE& aOther ) ; PNS_LINE( const PNS_LINE& aOther ) ;

View File

@ -35,7 +35,11 @@ class PNS_VIA : public PNS_ITEM
public: public:
PNS_VIA() : PNS_VIA() :
PNS_ITEM( VIA ) PNS_ITEM( VIA )
{} {
m_diameter = 2; // Dummy value
m_drill = 0;
m_viaType = VIA_THROUGH;
}
PNS_VIA( const VECTOR2I& aPos, const PNS_LAYERSET& aLayers, PNS_VIA( const VECTOR2I& aPos, const PNS_LAYERSET& aLayers,
int aDiameter, int aDrill, int aNet = -1, VIATYPE_T aViaType = VIA_THROUGH ) : int aDiameter, int aDrill, int aNet = -1, VIATYPE_T aViaType = VIA_THROUGH ) :

View File

@ -950,7 +950,8 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( newItem ); EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( newItem );
text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) ); if( text )
text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) );
originalItemsModified = true; originalItemsModified = true;
break; break;