Commit 5614ba00 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: 3D view: Better 3D rendering (fix some artifact issues). Add a realistic rendering mode.

parent 191cc6d1
...@@ -146,11 +146,69 @@ void EDA_3D_CANVAS::Redraw( bool finish ) ...@@ -146,11 +146,69 @@ void EDA_3D_CANVAS::Redraw( bool finish )
SwapBuffers(); SwapBuffers();
} }
// Helper function: initialize the copper color to draw the board
// in realistic mode.
static inline void SetGLCopperColor()
{
// Generates a golden yellow color, near board "copper" color
const double lum = 0.7/255.0;
glColor4f( 255.0*lum, 223.0*lum, 0.0*lum, 1.0 );
}
// Helper function: initialize the color to draw the epoxy layers
// ( body board and solder mask layers) in realistic mode.
static inline void SetGLEpoxyColor( double aTransparency = 1.0 )
{
// Generates an epoxy color, near board color
const double lum = 0.2/255.0;
glColor4f( 100.0*lum, 255.0*lum, 180.0*lum, aTransparency );
}
// Helper function: initialize the color to draw the non copper layers
// in realistic mode and normal mode.
static inline void SetGLTechLayersColor( LAYER_NUM aLayer )
{
// Generates an epoxy color, near board color
// const double lum = 0.2/255.0;
if( g_Parm_3D_Visu.IsRealisticMode() )
{
switch( aLayer )
{
case SOLDERPASTE_N_BACK:
case SOLDERPASTE_N_FRONT:
SetGLColor( DARKGRAY, 0.7 );
break;
case SILKSCREEN_N_BACK:
case SILKSCREEN_N_FRONT:
SetGLColor( LIGHTGRAY, 0.9 );
break;
case SOLDERMASK_N_BACK:
case SOLDERMASK_N_FRONT:
SetGLEpoxyColor( 0.7 );
break;
default:
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( aLayer );
SetGLColor( color, 0.7 );
break;
}
}
else
{
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( aLayer );
SetGLColor( color, 0.7 );
}
}
void EDA_3D_CANVAS::BuildBoard3DView() void EDA_3D_CANVAS::BuildBoard3DView()
{ {
PCB_BASE_FRAME* pcbframe = Parent()->Parent(); PCB_BASE_FRAME* pcbframe = Parent()->Parent();
BOARD* pcb = pcbframe->GetBoard(); BOARD* pcb = pcbframe->GetBoard();
bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();
// Number of segments to draw a circle using segments // Number of segments to draw a circle using segments
const int segcountforcircle = 16; const int segcountforcircle = 16;
...@@ -170,6 +228,8 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -170,6 +228,8 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Build a polygon from edge cut items // Build a polygon from edge cut items
wxString msg; wxString msg;
if( realistic_mode || g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SHOW_BOARD_BODY] )
{
if( ! pcb->GetBoardPolygonOutlines( bufferPcbOutlines, if( ! pcb->GetBoardPolygonOutlines( bufferPcbOutlines,
allLayerHoles, &msg ) ) allLayerHoles, &msg ) )
{ {
...@@ -177,6 +237,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -177,6 +237,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
_("Unable to calculate the board outlines, will use the outlines boundary box"); _("Unable to calculate the board outlines, will use the outlines boundary box");
wxMessageBox( msg ); wxMessageBox( msg );
} }
}
CPOLYGONS_LIST bufferZonesPolys; CPOLYGONS_LIST bufferZonesPolys;
bufferZonesPolys.reserve( 500000 ); // Reserve for large board ( copper zones mainly ) bufferZonesPolys.reserve( 500000 ); // Reserve for large board ( copper zones mainly )
...@@ -192,7 +253,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -192,7 +253,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
&& layer >= g_Parm_3D_Visu.m_CopperLayersCount ) && layer >= g_Parm_3D_Visu.m_CopperLayersCount )
continue; continue;
if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ) if( !Is3DLayerEnabled( layer ) )
continue; continue;
bufferPolys.RemoveAllContours(); bufferPolys.RemoveAllContours();
...@@ -315,11 +376,17 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -315,11 +376,17 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Merge polygons, remove holes // Merge polygons, remove holes
currLayerPolyset -= polysetHoles; currLayerPolyset -= polysetHoles;
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer ); int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer ); int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
if( realistic_mode )
SetGLCopperColor();
else
{
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
SetGLColor( color ); SetGLColor( color );
}
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
bufferPolys.RemoveAllContours(); bufferPolys.RemoveAllContours();
...@@ -350,6 +417,53 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -350,6 +417,53 @@ void EDA_3D_CANVAS::BuildBoard3DView()
Draw3DPadHole( pad ); Draw3DPadHole( pad );
} }
// Draw board substrate:
if( bufferPcbOutlines.GetCornersCount() )
{
int copper_thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
// a small offset between substrate and external copper layer to avoid artifacts
// when drawing copper items on board
int epsilon = Millimeter2iu( 0.01 );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
int board_thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT )
- g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
// items on copper layers and having a thickness = copper_thickness
// are drawn from zpos - copper_thickness/2 to zpos + copper_thickness
// therefore substrate position is copper_thickness/2 to
// substrate_height - copper_thickness/2
zpos += (copper_thickness + epsilon) / 2;
board_thickness -= copper_thickness + epsilon;
if( realistic_mode )
SetGLEpoxyColor();
else
{
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( EDGE_N );
SetGLColor( color, 0.7 );
}
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( LAYER_N_FRONT ) );
KI_POLYGON_SET currLayerPolyset;
KI_POLYGON_SET polysetHoles;
// Add polygons, without holes
bufferPcbOutlines.ExportTo( currLayerPolyset );
// Build holes list
allLayerHoles.ExportTo( polysetHoles );
// remove holes
currLayerPolyset -= polysetHoles;
bufferPcbOutlines.RemoveAllContours();
bufferPcbOutlines.ImportFrom( currLayerPolyset );
// for Draw3D_SolidHorizontalPolyPolygons, zpos it the middle between bottom and top
// sides
Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness/2,
board_thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
}
// draw graphic items, not on copper layers // draw graphic items, not on copper layers
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER; for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER;
layer++ ) layer++ )
...@@ -357,10 +471,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -357,10 +471,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
if( !Is3DLayerEnabled( layer ) ) if( !Is3DLayerEnabled( layer ) )
continue; continue;
if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ) if( layer == EDGE_N && g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SHOW_BOARD_BODY] )
continue;
if( layer == EDGE_N )
continue; continue;
bufferPolys.RemoveAllContours(); bufferPolys.RemoveAllContours();
...@@ -442,47 +553,33 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -442,47 +553,33 @@ void EDA_3D_CANVAS::BuildBoard3DView()
currLayerPolyset += polyset; currLayerPolyset += polyset;
} }
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer ); SetGLTechLayersColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer ); int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer ); int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
SetGLColor( color, 0.7 );
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
bufferPolys.RemoveAllContours(); if( layer == EDGE_N )
bufferPolys.ImportFrom( currLayerPolyset );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
}
// Draw board substrate:
if( bufferPcbOutlines.GetCornersCount() )
{ {
int copper_thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( LAYER_N_BACK ); thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT )
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
int thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT )
- g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK ); - g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
zpos += (thickness/2) + (copper_thickness/2); zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK )
thickness -= copper_thickness; + (thickness / 2);
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( EDGE_N ); }
SetGLColor( color, 0.8 ); else
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( LAYER_N_FRONT ) ); {
KI_POLYGON_SET currLayerPolyset; // for Draw3D_SolidHorizontalPolyPolygons, zpos it the middle between bottom and top
KI_POLYGON_SET polysetHoles; // sides.
// However for top layers, zpos should be the bottom layer pos,
// Add polygons, without holes // and for bottom layers, zpos should be the top layer pos.
bufferPcbOutlines.ExportTo( currLayerPolyset ); if( Get3DLayer_Z_Orientation( layer ) > 0 )
zpos += thickness/2;
// Build holes list else
allLayerHoles.ExportTo( polysetHoles ); zpos -= thickness/2 ;
}
// remove holes
currLayerPolyset -= polysetHoles;
bufferPcbOutlines.RemoveAllContours();
bufferPcbOutlines.ImportFrom( currLayerPolyset );
Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos, bufferPolys.RemoveAllContours();
bufferPolys.ImportFrom( currLayerPolyset );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
} }
...@@ -706,8 +803,14 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA* aVia ) ...@@ -706,8 +803,14 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA* aVia )
aVia->ReturnLayerPair( &top_layer, &bottom_layer ); aVia->ReturnLayerPair( &top_layer, &bottom_layer );
// Drawing via hole: // Drawing via hole:
if( g_Parm_3D_Visu.IsRealisticMode() )
SetGLCopperColor();
else
{
EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetShape() ); EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetShape() );
SetGLColor( color ); SetGLColor( color );
}
int height = g_Parm_3D_Visu.GetLayerZcoordBIU( top_layer ) - int height = g_Parm_3D_Visu.GetLayerZcoordBIU( top_layer ) -
g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) - thickness; g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) - thickness;
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) + thickness / 2; int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) + thickness / 2;
...@@ -773,7 +876,11 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad ) ...@@ -773,7 +876,11 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad )
int height = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT ) - int height = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT ) -
g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK ); g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
if( g_Parm_3D_Visu.IsRealisticMode() )
SetGLCopperColor();
else
SetGLColor( DARKGRAY ); SetGLColor( DARKGRAY );
int holeZpoz = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK ) + thickness / 2; int holeZpoz = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK ) + thickness / 2;
int holeHeight = height - thickness; int holeHeight = height - thickness;
...@@ -815,6 +922,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad ) ...@@ -815,6 +922,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad )
bool Is3DLayerEnabled( LAYER_NUM aLayer ) bool Is3DLayerEnabled( LAYER_NUM aLayer )
{ {
int flg; int flg;
bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();
// see if layer needs to be shown // see if layer needs to be shown
// check the flags // check the flags
...@@ -842,21 +950,37 @@ bool Is3DLayerEnabled( LAYER_NUM aLayer ) ...@@ -842,21 +950,37 @@ bool Is3DLayerEnabled( LAYER_NUM aLayer )
case DRAW_N: case DRAW_N:
case COMMENT_N: case COMMENT_N:
if( realistic_mode )
return false;
flg = g_Parm_3D_Visu.FL_COMMENTS; flg = g_Parm_3D_Visu.FL_COMMENTS;
break; break;
case ECO1_N: case ECO1_N:
case ECO2_N: case ECO2_N:
if( realistic_mode )
return false;
flg = g_Parm_3D_Visu.FL_ECO; flg = g_Parm_3D_Visu.FL_ECO;
break; break;
case LAYER_N_BACK:
case LAYER_N_FRONT:
return g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer )
|| realistic_mode;
break;
default: default:
// the layer was not a layer with a flag, so show it // the layer is an internal copper layer
return true; if( realistic_mode )
return false;
return g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer );
} }
// if the layer has a flag, return the flag // if the layer has a flag, return the flag
return g_Parm_3D_Visu.m_DrawFlags[flg]; return g_Parm_3D_Visu.m_DrawFlags[flg] &&
g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer );
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* @param aThickness = thickness in board internal units * @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value * @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos. * If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness 1 0, a solid object is drawn. * If aThickness > 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2 * The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2 * The bottom side is located at aZpos - aThickness / 2
*/ */
......
...@@ -47,6 +47,7 @@ static const wxString keySizey( wxT( "Size_y" ) ); ...@@ -47,6 +47,7 @@ static const wxString keySizey( wxT( "Size_y" ) );
static const wxString keyBgColor_Red( wxT( "BgColor_Red" ) ); static const wxString keyBgColor_Red( wxT( "BgColor_Red" ) );
static const wxString keyBgColor_Green( wxT( "BgColor_Green" ) ); static const wxString keyBgColor_Green( wxT( "BgColor_Green" ) );
static const wxString keyBgColor_Blue( wxT( "BgColor_Blue" ) ); static const wxString keyBgColor_Blue( wxT( "BgColor_Blue" ) );
static const wxString keyShowRealisticMode( wxT( "ShowRealisticMode" ) );
static const wxString keyShowAxis( wxT( "ShowAxis" ) ); static const wxString keyShowAxis( wxT( "ShowAxis" ) );
static const wxString keyShowZones( wxT( "ShowZones" ) ); static const wxString keyShowZones( wxT( "ShowZones" ) );
static const wxString keyShowFootprints( wxT( "ShowFootprints" ) ); static const wxString keyShowFootprints( wxT( "ShowFootprints" ) );
...@@ -56,6 +57,7 @@ static const wxString keyShowSilkScreenLayers( wxT( "ShowSilkScreenLayers" ) ) ...@@ -56,6 +57,7 @@ static const wxString keyShowSilkScreenLayers( wxT( "ShowSilkScreenLayers" ) )
static const wxString keyShowSolderMaskLayers( wxT( "ShowSolderMasLayers" ) ); static const wxString keyShowSolderMaskLayers( wxT( "ShowSolderMasLayers" ) );
static const wxString keyShowSolderPasteLayers( wxT( "ShowSolderPasteLayers" ) ); static const wxString keyShowSolderPasteLayers( wxT( "ShowSolderPasteLayers" ) );
static const wxString keyShowCommentsLayer( wxT( "ShowCommentsLayers" ) ); static const wxString keyShowCommentsLayer( wxT( "ShowCommentsLayers" ) );
static const wxString keyShowBoardBody( wxT( "ShowBoardBody" ) );
static const wxString keyShowEcoLayers( wxT( "ShowEcoLayers" ) ); static const wxString keyShowEcoLayers( wxT( "ShowEcoLayers" ) );
BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame ) BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame )
...@@ -167,6 +169,8 @@ void EDA_3D_FRAME::GetSettings() ...@@ -167,6 +169,8 @@ void EDA_3D_FRAME::GetSettings()
config->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 ); config->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
config->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 ); config->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
class INFO3D_VISU& prms = g_Parm_3D_Visu; class INFO3D_VISU& prms = g_Parm_3D_Visu;
config->Read( keyShowRealisticMode,
&prms.m_DrawFlags[prms.FL_USE_REALISTIC_MODE], false );
config->Read( keyShowAxis, &prms.m_DrawFlags[prms.FL_AXIS], true ); config->Read( keyShowAxis, &prms.m_DrawFlags[prms.FL_AXIS], true );
config->Read( keyShowFootprints, &prms.m_DrawFlags[prms.FL_MODULE], true ); config->Read( keyShowFootprints, &prms.m_DrawFlags[prms.FL_MODULE], true );
config->Read( keyShowCopperThickness, config->Read( keyShowCopperThickness,
...@@ -179,6 +183,7 @@ void EDA_3D_FRAME::GetSettings() ...@@ -179,6 +183,7 @@ void EDA_3D_FRAME::GetSettings()
config->Read( keyShowSolderPasteLayers, &prms.m_DrawFlags[prms.FL_SOLDERPASTE], true ); config->Read( keyShowSolderPasteLayers, &prms.m_DrawFlags[prms.FL_SOLDERPASTE], true );
config->Read( keyShowCommentsLayer, &prms.m_DrawFlags[prms.FL_COMMENTS], true ); config->Read( keyShowCommentsLayer, &prms.m_DrawFlags[prms.FL_COMMENTS], true );
config->Read( keyShowEcoLayers, &prms.m_DrawFlags[prms.FL_ECO], true ); config->Read( keyShowEcoLayers, &prms.m_DrawFlags[prms.FL_ECO], true );
config->Read( keyShowBoardBody, &prms.m_DrawFlags[prms.FL_SHOW_BOARD_BODY], true );
} }
} }
...@@ -195,6 +200,7 @@ void EDA_3D_FRAME::SaveSettings() ...@@ -195,6 +200,7 @@ void EDA_3D_FRAME::SaveSettings()
config->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green ); config->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
config->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue ); config->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
class INFO3D_VISU& prms = g_Parm_3D_Visu; class INFO3D_VISU& prms = g_Parm_3D_Visu;
config->Write( keyShowRealisticMode, prms.m_DrawFlags[prms.FL_USE_REALISTIC_MODE] );
config->Write( keyShowAxis, prms.m_DrawFlags[prms.FL_AXIS] ); config->Write( keyShowAxis, prms.m_DrawFlags[prms.FL_AXIS] );
config->Write( keyShowFootprints, prms.m_DrawFlags[prms.FL_MODULE] ); config->Write( keyShowFootprints, prms.m_DrawFlags[prms.FL_MODULE] );
config->Write( keyShowCopperThickness, prms.m_DrawFlags[prms.FL_USE_COPPER_THICKNESS] ); config->Write( keyShowCopperThickness, prms.m_DrawFlags[prms.FL_USE_COPPER_THICKNESS] );
...@@ -205,6 +211,7 @@ void EDA_3D_FRAME::SaveSettings() ...@@ -205,6 +211,7 @@ void EDA_3D_FRAME::SaveSettings()
config->Write( keyShowSolderPasteLayers, prms.m_DrawFlags[prms.FL_SOLDERPASTE] ); config->Write( keyShowSolderPasteLayers, prms.m_DrawFlags[prms.FL_SOLDERPASTE] );
config->Write( keyShowCommentsLayer, prms.m_DrawFlags[prms.FL_COMMENTS] ); config->Write( keyShowCommentsLayer, prms.m_DrawFlags[prms.FL_COMMENTS] );
config->Write( keyShowEcoLayers, prms.m_DrawFlags[prms.FL_ECO] ); config->Write( keyShowEcoLayers, prms.m_DrawFlags[prms.FL_ECO] );
config->Write( keyShowBoardBody, prms.m_DrawFlags[prms.FL_SHOW_BOARD_BODY] );
if( IsIconized() ) if( IsIconized() )
return; return;
...@@ -355,6 +362,16 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -355,6 +362,16 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
Set3DBgColor(); Set3DBgColor();
return; return;
case ID_MENU3D_REALISTIC_MODE:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_REALISTIC_MODE] = isChecked;
NewDisplay();
return;
case ID_MENU3D_SHOW_BOARD_BODY:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SHOW_BOARD_BODY] = isChecked;
NewDisplay();
return;
case ID_MENU3D_AXIS_ONOFF: case ID_MENU3D_AXIS_ONOFF:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] = isChecked; g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] = isChecked;
NewDisplay(); NewDisplay();
......
...@@ -158,17 +158,19 @@ void EDA_3D_FRAME::CreateMenuBar() ...@@ -158,17 +158,19 @@ void EDA_3D_FRAME::CreateMenuBar()
menuBar->Append( prefsMenu, _( "&Preferences" ) ); menuBar->Append( prefsMenu, _( "&Preferences" ) );
AddMenuItem( prefsMenu, ID_MENU3D_REALISTIC_MODE,
_( "Realistic Mode" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
prefsMenu->AppendSeparator();
AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION, AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION,
_( "Choose background color" ), KiBitmap( palette_xpm ) ); _( "Choose background color" ), KiBitmap( palette_xpm ) );
wxMenuItem* item; AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
item = AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
_( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK ); _( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS]);
// Creates grid menu // Creates grid menu
wxMenu * gridlistMenu = new wxMenu; wxMenu * gridlistMenu = new wxMenu;
item = AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID, AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID,
_( "3D Grid" ), KiBitmap( grid_xpm ) ); _( "3D Grid" ), KiBitmap( grid_xpm ) );
gridlistMenu->Append( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), wxEmptyString, true ); gridlistMenu->Append( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), wxEmptyString, true );
gridlistMenu->Check( ID_MENU3D_GRID_NOGRID, true ); gridlistMenu->Check( ID_MENU3D_GRID_NOGRID, true );
...@@ -178,32 +180,34 @@ void EDA_3D_FRAME::CreateMenuBar() ...@@ -178,32 +180,34 @@ void EDA_3D_FRAME::CreateMenuBar()
gridlistMenu->Append( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5 mm" ), wxEmptyString, true ); gridlistMenu->Append( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5 mm" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_1_MM, _( "3D Grid 1 mm" ), wxEmptyString, true ); gridlistMenu->Append( ID_MENU3D_GRID_1_MM, _( "3D Grid 1 mm" ), wxEmptyString, true );
item = AddMenuItem( prefsMenu, ID_MENU3D_USE_COPPER_THICKNESS, AddMenuItem( prefsMenu, ID_MENU3D_SHOW_BOARD_BODY,
_( "Show Board Body" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
AddMenuItem( prefsMenu, ID_MENU3D_USE_COPPER_THICKNESS,
_( "Show Copper Thickness" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK ); _( "Show Copper Thickness" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF, AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF,
_( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK ); _( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF, AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF,
_( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK ); _( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF, AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF,
_( "Show &Adhesive Layers" ), KiBitmap( tools_xpm ), wxITEM_CHECK ); _( "Show &Adhesive Layers" ), KiBitmap( tools_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]);
item = AddMenuItem( prefsMenu, ID_MENU3D_SILKSCREEN_ONOFF, AddMenuItem( prefsMenu, ID_MENU3D_SILKSCREEN_ONOFF,
_( "Show &Silkscreen Layer" ), KiBitmap( add_text_xpm ), wxITEM_CHECK ); _( "Show &Silkscreen Layer" ), KiBitmap( add_text_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_MASK_ONOFF, AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_MASK_ONOFF,
_( "Show Solder &Mask Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK ); _( "Show Solder &Mask Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_PASTE_ONOFF, AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_PASTE_ONOFF,
_( "Show Solder &Paste Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK ); _( "Show Solder &Paste Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF, AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
_( "Show &Comments and Drawings Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK ); _( "Show &Comments and Drawings Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_ECO_ONOFF, AddMenuItem( prefsMenu, ID_MENU3D_ECO_ONOFF,
_( "Show &Eco Layers" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK ); _( "Show &Eco Layers" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
SetMenuBar( menuBar ); SetMenuBar( menuBar );
...@@ -219,6 +223,12 @@ void EDA_3D_FRAME::SetMenuBarOptionsState() ...@@ -219,6 +223,12 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
wxMenuItem* item; wxMenuItem* item;
// Set the state of toggle menus according to the current display options // Set the state of toggle menus according to the current display options
item = menuBar->FindItem( ID_MENU3D_REALISTIC_MODE );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_REALISTIC_MODE]);
item = menuBar->FindItem( ID_MENU3D_SHOW_BOARD_BODY );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SHOW_BOARD_BODY]);
item = menuBar->FindItem( ID_MENU3D_USE_COPPER_THICKNESS ); item = menuBar->FindItem( ID_MENU3D_USE_COPPER_THICKNESS );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS]);
...@@ -228,6 +238,9 @@ void EDA_3D_FRAME::SetMenuBarOptionsState() ...@@ -228,6 +238,9 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF ); item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]);
item = menuBar->FindItem( ID_MENU3D_AXIS_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS]);
item = menuBar->FindItem( ID_MENU3D_ADHESIVE_ONOFF ); item = menuBar->FindItem( ID_MENU3D_ADHESIVE_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]);
......
...@@ -39,6 +39,8 @@ enum id_3dview_frm ...@@ -39,6 +39,8 @@ enum id_3dview_frm
ID_MENU3D_SOLDER_MASK_ONOFF, ID_MENU3D_SOLDER_MASK_ONOFF,
ID_MENU3D_COMMENTS_ONOFF, ID_MENU3D_COMMENTS_ONOFF,
ID_MENU3D_ECO_ONOFF, ID_MENU3D_ECO_ONOFF,
ID_MENU3D_SHOW_BOARD_BODY,
ID_MENU3D_REALISTIC_MODE,
ID_END_COMMAND_3D, ID_END_COMMAND_3D,
ID_TOOL_SET_VISIBLE_ITEMS, ID_TOOL_SET_VISIBLE_ITEMS,
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
// Thickness of copper // Thickness of copper
// TODO: define the actual copper thickness by user // TODO: define the actual copper thickness by user
#define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35 µm #define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35 um
#define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM ) #define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM )
#define EPOXY_THICKNESS KiROUND( 1.6 * IU_PER_MM ) // for 1.6 mm #define EPOXY_THICKNESS KiROUND( 1.6 * IU_PER_MM ) // for 1.6 mm
...@@ -124,8 +124,10 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard ) ...@@ -124,8 +124,10 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
m_EpoxyThickness * layer / (copper_layers_cnt - 1); m_EpoxyThickness * layer / (copper_layers_cnt - 1);
} }
double zpos_copper_back = m_LayerZcoord[0]; #define layerThicknessMargin 1.1
double zpos_copper_front = m_EpoxyThickness; double zpos_offset = m_NonCopperLayerThickness * layerThicknessMargin;
double zpos_copper_back = m_LayerZcoord[0] - layerThicknessMargin*m_CopperThickness/2;
double zpos_copper_front = m_EpoxyThickness + layerThicknessMargin*m_CopperThickness/2;
// Fill remaining unused copper layers and front layer zpos // Fill remaining unused copper layers and front layer zpos
// with m_EpoxyThickness // with m_EpoxyThickness
...@@ -138,54 +140,44 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard ) ...@@ -138,54 +140,44 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
for( int layer_id = FIRST_NON_COPPER_LAYER; layer_id < NB_PCB_LAYERS; layer_id++ ) for( int layer_id = FIRST_NON_COPPER_LAYER; layer_id < NB_PCB_LAYERS; layer_id++ )
{ {
double zpos; double zpos;
#define NonCopperLayerThicknessMargin 1.1
switch( layer_id ) switch( layer_id )
{ {
case ADHESIVE_N_BACK: case ADHESIVE_N_BACK:
zpos = zpos_copper_back - zpos = zpos_copper_back - 4 * zpos_offset;
4 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
case ADHESIVE_N_FRONT: case ADHESIVE_N_FRONT:
zpos = zpos_copper_front + zpos = zpos_copper_front + 4 * zpos_offset;
4 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
case SOLDERPASTE_N_BACK: case SOLDERPASTE_N_BACK:
zpos = zpos_copper_back - zpos = zpos_copper_back - 3 * zpos_offset;
3 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
case SOLDERPASTE_N_FRONT: case SOLDERPASTE_N_FRONT:
zpos = zpos_copper_front + zpos = zpos_copper_front + 3 * zpos_offset;
3 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
case SOLDERMASK_N_BACK: case SOLDERMASK_N_BACK:
zpos = zpos_copper_back - zpos = zpos_copper_back - 1 * zpos_offset;
1 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
case SOLDERMASK_N_FRONT: case SOLDERMASK_N_FRONT:
zpos = zpos_copper_front + zpos = zpos_copper_front + 2 * zpos_offset;
1 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
case SILKSCREEN_N_BACK: case SILKSCREEN_N_BACK:
zpos = zpos_copper_back - zpos = zpos_copper_back - 2 * zpos_offset;
2 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
case SILKSCREEN_N_FRONT: case SILKSCREEN_N_FRONT:
zpos = zpos_copper_front + zpos = zpos_copper_front + 2 * zpos_offset;
2 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
default: default:
zpos = zpos_copper_front + zpos = zpos_copper_front +
(layer_id - FIRST_NON_COPPER_LAYER + 5) * (layer_id - FIRST_NON_COPPER_LAYER + 5) * zpos_offset;
m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
} }
......
...@@ -72,6 +72,8 @@ public: ...@@ -72,6 +72,8 @@ public:
FL_COMMENTS, FL_ECO, FL_COMMENTS, FL_ECO,
FL_GRID, FL_GRID,
FL_USE_COPPER_THICKNESS, FL_USE_COPPER_THICKNESS,
FL_SHOW_BOARD_BODY,
FL_USE_REALISTIC_MODE,
FL_LAST FL_LAST
}; };
...@@ -133,11 +135,14 @@ public: INFO3D_VISU(); ...@@ -133,11 +135,14 @@ public: INFO3D_VISU();
* note: the thickness (Z size) of the copper is not the thickness * note: the thickness (Z size) of the copper is not the thickness
* of the layer (the thickness of the layer is the epoxy thickness / layer count) * of the layer (the thickness of the layer is the epoxy thickness / layer count)
* *
* Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0 * Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set,
* and normal mode, returns 0
*/ */
int GetCopperThicknessBIU() const int GetCopperThicknessBIU() const
{ {
return m_DrawFlags[FL_USE_COPPER_THICKNESS] ? bool use_copper_thickness = m_DrawFlags[FL_USE_COPPER_THICKNESS] ||
m_DrawFlags[FL_USE_REALISTIC_MODE];
return use_copper_thickness ?
KiROUND( m_CopperThickness / m_BiuTo3Dunits ) KiROUND( m_CopperThickness / m_BiuTo3Dunits )
: 0; : 0;
} }
...@@ -160,7 +165,9 @@ public: INFO3D_VISU(); ...@@ -160,7 +165,9 @@ public: INFO3D_VISU();
*/ */
int GetNonCopperLayerThicknessBIU() const int GetNonCopperLayerThicknessBIU() const
{ {
return m_DrawFlags[FL_USE_COPPER_THICKNESS] ? bool use_copper_thickness = m_DrawFlags[FL_USE_COPPER_THICKNESS] ||
m_DrawFlags[FL_USE_REALISTIC_MODE];
return use_copper_thickness ?
KiROUND( m_NonCopperLayerThickness / m_BiuTo3Dunits ) KiROUND( m_NonCopperLayerThickness / m_BiuTo3Dunits )
: 0; : 0;
} }
...@@ -178,6 +185,8 @@ public: INFO3D_VISU(); ...@@ -178,6 +185,8 @@ public: INFO3D_VISU();
GetNonCopperLayerThicknessBIU() : GetNonCopperLayerThicknessBIU() :
GetCopperThicknessBIU(); GetCopperThicknessBIU();
} }
bool IsRealisticMode() { return m_DrawFlags[FL_USE_REALISTIC_MODE]; }
}; };
extern INFO3D_VISU g_Parm_3D_Visu; extern INFO3D_VISU g_Parm_3D_Visu;
......
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