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
This diff is collapsed.
......@@ -37,7 +37,7 @@
* @param aThickness = thickness in board internal units
* @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 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 bottom side is located at aZpos - aThickness / 2
*/
......
......@@ -47,6 +47,7 @@ static const wxString keySizey( wxT( "Size_y" ) );
static const wxString keyBgColor_Red( wxT( "BgColor_Red" ) );
static const wxString keyBgColor_Green( wxT( "BgColor_Green" ) );
static const wxString keyBgColor_Blue( wxT( "BgColor_Blue" ) );
static const wxString keyShowRealisticMode( wxT( "ShowRealisticMode" ) );
static const wxString keyShowAxis( wxT( "ShowAxis" ) );
static const wxString keyShowZones( wxT( "ShowZones" ) );
static const wxString keyShowFootprints( wxT( "ShowFootprints" ) );
......@@ -56,6 +57,7 @@ static const wxString keyShowSilkScreenLayers( wxT( "ShowSilkScreenLayers" ) )
static const wxString keyShowSolderMaskLayers( wxT( "ShowSolderMasLayers" ) );
static const wxString keyShowSolderPasteLayers( wxT( "ShowSolderPasteLayers" ) );
static const wxString keyShowCommentsLayer( wxT( "ShowCommentsLayers" ) );
static const wxString keyShowBoardBody( wxT( "ShowBoardBody" ) );
static const wxString keyShowEcoLayers( wxT( "ShowEcoLayers" ) );
BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame )
......@@ -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_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
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( keyShowFootprints, &prms.m_DrawFlags[prms.FL_MODULE], true );
config->Read( keyShowCopperThickness,
......@@ -179,6 +183,7 @@ void EDA_3D_FRAME::GetSettings()
config->Read( keyShowSolderPasteLayers, &prms.m_DrawFlags[prms.FL_SOLDERPASTE], true );
config->Read( keyShowCommentsLayer, &prms.m_DrawFlags[prms.FL_COMMENTS], 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()
config->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
config->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
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( keyShowFootprints, prms.m_DrawFlags[prms.FL_MODULE] );
config->Write( keyShowCopperThickness, prms.m_DrawFlags[prms.FL_USE_COPPER_THICKNESS] );
......@@ -205,6 +211,7 @@ void EDA_3D_FRAME::SaveSettings()
config->Write( keyShowSolderPasteLayers, prms.m_DrawFlags[prms.FL_SOLDERPASTE] );
config->Write( keyShowCommentsLayer, prms.m_DrawFlags[prms.FL_COMMENTS] );
config->Write( keyShowEcoLayers, prms.m_DrawFlags[prms.FL_ECO] );
config->Write( keyShowBoardBody, prms.m_DrawFlags[prms.FL_SHOW_BOARD_BODY] );
if( IsIconized() )
return;
......@@ -355,6 +362,16 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
Set3DBgColor();
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:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] = isChecked;
NewDisplay();
......
......@@ -158,17 +158,19 @@ void EDA_3D_FRAME::CreateMenuBar()
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,
_( "Choose background color" ), KiBitmap( palette_xpm ) );
wxMenuItem* item;
item = AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
_( "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
wxMenu * gridlistMenu = new wxMenu;
item = AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID,
AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID,
_( "3D Grid" ), KiBitmap( grid_xpm ) );
gridlistMenu->Append( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), wxEmptyString, true );
gridlistMenu->Check( ID_MENU3D_GRID_NOGRID, true );
......@@ -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_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 );
item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF,
AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF,
_( "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 );
item = AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF,
AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF,
_( "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 );
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 );
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 );
item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
_( "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 );
SetMenuBar( menuBar );
......@@ -219,6 +223,12 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
wxMenuItem* item;
// 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->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS]);
......@@ -228,6 +238,9 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF );
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->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]);
......
......@@ -39,6 +39,8 @@ enum id_3dview_frm
ID_MENU3D_SOLDER_MASK_ONOFF,
ID_MENU3D_COMMENTS_ONOFF,
ID_MENU3D_ECO_ONOFF,
ID_MENU3D_SHOW_BOARD_BODY,
ID_MENU3D_REALISTIC_MODE,
ID_END_COMMAND_3D,
ID_TOOL_SET_VISIBLE_ITEMS,
......
......@@ -39,7 +39,7 @@
// Thickness of copper
// 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 EPOXY_THICKNESS KiROUND( 1.6 * IU_PER_MM ) // for 1.6 mm
......@@ -124,8 +124,10 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
m_EpoxyThickness * layer / (copper_layers_cnt - 1);
}
double zpos_copper_back = m_LayerZcoord[0];
double zpos_copper_front = m_EpoxyThickness;
#define layerThicknessMargin 1.1
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
// with m_EpoxyThickness
......@@ -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++ )
{
double zpos;
#define NonCopperLayerThicknessMargin 1.1
switch( layer_id )
{
case ADHESIVE_N_BACK:
zpos = zpos_copper_back -
4 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
zpos = zpos_copper_back - 4 * zpos_offset;
break;
case ADHESIVE_N_FRONT:
zpos = zpos_copper_front +
4 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
zpos = zpos_copper_front + 4 * zpos_offset;
break;
case SOLDERPASTE_N_BACK:
zpos = zpos_copper_back -
3 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
zpos = zpos_copper_back - 3 * zpos_offset;
break;
case SOLDERPASTE_N_FRONT:
zpos = zpos_copper_front +
3 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
zpos = zpos_copper_front + 3 * zpos_offset;
break;
case SOLDERMASK_N_BACK:
zpos = zpos_copper_back -
1 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
zpos = zpos_copper_back - 1 * zpos_offset;
break;
case SOLDERMASK_N_FRONT:
zpos = zpos_copper_front +
1 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
zpos = zpos_copper_front + 2 * zpos_offset;
break;
case SILKSCREEN_N_BACK:
zpos = zpos_copper_back -
2 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
zpos = zpos_copper_back - 2 * zpos_offset;
break;
case SILKSCREEN_N_FRONT:
zpos = zpos_copper_front +
2 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
zpos = zpos_copper_front + 2 * zpos_offset;
break;
default:
zpos = zpos_copper_front +
(layer_id - FIRST_NON_COPPER_LAYER + 5) *
m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
(layer_id - FIRST_NON_COPPER_LAYER + 5) * zpos_offset;
break;
}
......
......@@ -72,6 +72,8 @@ public:
FL_COMMENTS, FL_ECO,
FL_GRID,
FL_USE_COPPER_THICKNESS,
FL_SHOW_BOARD_BODY,
FL_USE_REALISTIC_MODE,
FL_LAST
};
......@@ -133,11 +135,14 @@ public: INFO3D_VISU();
* 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)
*
* 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
{
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 )
: 0;
}
......@@ -160,7 +165,9 @@ public: INFO3D_VISU();
*/
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 )
: 0;
}
......@@ -178,6 +185,8 @@ public: INFO3D_VISU();
GetNonCopperLayerThicknessBIU() :
GetCopperThicknessBIU();
}
bool IsRealisticMode() { return m_DrawFlags[FL_USE_REALISTIC_MODE]; }
};
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