Loading 3d-viewer/3d_draw.cpp +176 −52 Original line number Original line Diff line number Diff line Loading @@ -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; Loading @@ -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 ) ) { { Loading @@ -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 ) Loading @@ -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(); Loading Loading @@ -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(); Loading Loading @@ -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++ ) Loading @@ -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(); Loading Loading @@ -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 ); } } Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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 ); } } Loading 3d-viewer/3d_draw_basic_functions.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -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 */ */ Loading 3d-viewer/3d_frame.cpp +17 −0 Original line number Original line Diff line number Diff line Loading @@ -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" ) ); Loading @@ -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 ) Loading Loading @@ -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, Loading @@ -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 ); } } } } Loading @@ -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] ); Loading @@ -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; Loading Loading @@ -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(); Loading 3d-viewer/3d_toolbar.cpp +27 −14 Original line number Original line Diff line number Diff line Loading @@ -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 ); Loading @@ -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 ); Loading @@ -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]); Loading @@ -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]); Loading 3d-viewer/3d_viewer_id.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -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, Loading Loading
3d-viewer/3d_draw.cpp +176 −52 Original line number Original line Diff line number Diff line Loading @@ -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; Loading @@ -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 ) ) { { Loading @@ -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 ) Loading @@ -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(); Loading Loading @@ -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(); Loading Loading @@ -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++ ) Loading @@ -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(); Loading Loading @@ -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 ); } } Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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 ); } } Loading
3d-viewer/3d_draw_basic_functions.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -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 */ */ Loading
3d-viewer/3d_frame.cpp +17 −0 Original line number Original line Diff line number Diff line Loading @@ -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" ) ); Loading @@ -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 ) Loading Loading @@ -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, Loading @@ -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 ); } } } } Loading @@ -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] ); Loading @@ -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; Loading Loading @@ -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(); Loading
3d-viewer/3d_toolbar.cpp +27 −14 Original line number Original line Diff line number Diff line Loading @@ -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 ); Loading @@ -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 ); Loading @@ -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]); Loading @@ -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]); Loading
3d-viewer/3d_viewer_id.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -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, Loading