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

3D viewer: fix (the fix is not perfect) a minor issue in zone rendering:...

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.
parent cec0a956
...@@ -793,7 +793,11 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList, ...@@ -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, ...@@ -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,41 +870,40 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList, ...@@ -866,41 +870,40 @@ 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,
GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
if( isEnabled( FL_USE_COPPER_THICKNESS ) == true )
{
thickness -= ( 0.04 * IU_PER_MM );
}
// 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 ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, thickness,
GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
// 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() ) if( bufferZonesPolys.GetCornersCount() )
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos, {
thickness, glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos, thickness,
GetPrm3DVisu().m_BiuTo3Dunits, useTextures ); 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)
for( const MODULE* module = pcb->m_Modules; module; module = module->Next() ) for( const MODULE* module = pcb->m_Modules; module; module = module->Next() )
......
...@@ -245,12 +245,11 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, ...@@ -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 );
} }
......
...@@ -435,16 +435,15 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet() ...@@ -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() ...@@ -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() ...@@ -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() ...@@ -524,7 +525,7 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
} }
} }
if( ii >= list.size() ) if( !item )
break; break;
netcode = item->GetNet(); netcode = item->GetNet();
......
...@@ -260,6 +260,7 @@ public: ...@@ -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()
......
...@@ -119,6 +119,12 @@ public: ...@@ -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.
......
...@@ -1677,6 +1677,7 @@ void PCB_BASE_EDIT_FRAME::createArray() ...@@ -1677,6 +1677,7 @@ 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 );
if( text )
text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) ); text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) );
break; break;
......
...@@ -67,6 +67,7 @@ public: ...@@ -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 ) ;
......
...@@ -35,7 +35,11 @@ class PNS_VIA : public PNS_ITEM ...@@ -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 ) :
......
...@@ -950,6 +950,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) ...@@ -950,6 +950,7 @@ 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 );
if( text )
text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) ); text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) );
originalItemsModified = true; originalItemsModified = true;
......
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