Commit 38027eb9 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

3d viewer: Add high quality mode option is realistic mode (Shows holes in...

3d viewer: Add high quality mode option is realistic mode (Shows holes in copper zones, but with longer calculation time)
Gal: fix a very minor issue: the keys to switch between copper layers are now - and + (according to the doc and the normall mode), instead of - and =
parent 2f7b9bcd
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -188,12 +188,21 @@ static inline void SetGLCopperColor()
    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.
// Helper function: initialize the color to draw the epoxy
// body board 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( 255.0*lum, 218.0*lum, 110.0*lum, aTransparency );
}

// Helper function: initialize the color to draw the
// solder mask layers in realistic mode.
static inline void SetGLSolderMaskColor( double aTransparency = 1.0 )
{
    // Generates a solder mask color
    const double lum = 0.2/255.0;
    glColor4f( 100.0*lum, 255.0*lum, 180.0*lum, aTransparency );
}

@@ -217,7 +226,7 @@ static inline void SetGLTechLayersColor( LAYER_NUM aLayer )

        case B_Mask:
        case F_Mask:
            SetGLEpoxyColor( 0.7 );
            SetGLSolderMaskColor( 0.7 );
            break;

        default:
@@ -237,6 +246,12 @@ static inline void SetGLTechLayersColor( LAYER_NUM aLayer )
void EDA_3D_CANVAS::BuildBoard3DView()
{
    BOARD* pcb = GetBoard();

    // If hightQualityMode is true, holes are correctly removed from copper zones areas.
    // If hightQualityMode is false, holes are not removed from copper zones areas,
    // but the calculation time is twice shorter.
    bool hightQualityMode = g_Parm_3D_Visu.HightQualityMode();

    bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();

    // Number of segments to convert a circle to polygon
@@ -276,7 +291,6 @@ void EDA_3D_CANVAS::BuildBoard3DView()

    CPOLYGONS_LIST  currLayerHoles;                 // Contains holes for the current layer
    bool            throughHolesListBuilt = false;  // flag to build the through hole polygon list only once
    bool            hightQualityMode = false;

    LSET            cu_set = LSET::AllCuMask( g_Parm_3D_Visu.m_CopperLayersCount );

@@ -520,7 +534,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
    BOARD* pcb = GetBoard();

    // Number of segments to draw a circle using segments
    const int       segcountforcircle   = 16;
    const int       segcountforcircle   = 18;
    double          correctionFactor    = 1.0 / cos( M_PI / (segcountforcircle * 2) );
    const int       segcountLowQuality  = 12;   // segments to draw a circle with low quality
                                                // to reduce time calculations
@@ -736,7 +750,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
 */
void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
{
    const int   segcountforcircle   = 16;
    const int   segcountforcircle   = 18;
    double      correctionFactor    = 1.0 / cos( M_PI / (segcountforcircle * 2) );
    BOARD*      pcb = GetBoard();

+10 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
static const wxChar keyBgColor_Green[] =        wxT( "BgColor_Green" );
static const wxChar keyBgColor_Blue[] =         wxT( "BgColor_Blue" );
static const wxChar keyShowRealisticMode[] =    wxT( "ShowRealisticMode" );
static const wxChar keyUseHQinRealisticMode[] = wxT( "UseHQinRealisticMode" );
static const wxChar keyShowAxis[] =             wxT( "ShowAxis" );
static const wxChar keyShowGrid[] =             wxT( "ShowGrid3D" );
static const wxChar keyShowGridSize[] =         wxT( "Grid3DSize" );
@@ -159,6 +160,9 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
    aCfg->Read( keyShowRealisticMode, &tmp, false );
    prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );

    aCfg->Read( keyUseHQinRealisticMode, &tmp, false );
    prms.SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, tmp );

    aCfg->Read( keyShowAxis, &tmp, true );
    prms.SetFlag( FL_AXIS, tmp );

@@ -210,6 +214,7 @@ void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
    aCfg->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
    aCfg->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
    aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE )  );
    aCfg->Write( keyUseHQinRealisticMode, prms.GetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE )  );
    aCfg->Write( keyShowAxis, prms.GetFlag( FL_AXIS )  );
    aCfg->Write( keyShowGrid, prms.GetFlag( FL_GRID )  );
    aCfg->Write( keyShowGridSize, prms.m_3D_Grid  );
@@ -363,6 +368,11 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
        NewDisplay();
        return;

    case ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE:
        g_Parm_3D_Visu.SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, isChecked );
        NewDisplay();
        return;

    case ID_MENU3D_SHOW_BOARD_BODY:
        g_Parm_3D_Visu.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
        NewDisplay();
+26 −15
Original line number Diff line number Diff line
@@ -153,11 +153,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 );
                 _( "Realistic Mode" ),
                 KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );

    AddMenuItem( prefsMenu, ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE,
                 _( "Max Quality in Realistic Mode" ),
                 _( "When using max quality, holes are removed from copper zones, "
                    "but the calculation time is longer" ),
                 KiBitmap( green_xpm ), wxITEM_CHECK );

    prefsMenu->AppendSeparator();

    AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION,
                 _( "Choose background color" ), KiBitmap( palette_xpm ) );
                _( "Choose Background Color" ), KiBitmap( palette_xpm ) );

    AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
                 _( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK );
@@ -231,7 +239,10 @@ 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.GetFlag( FL_USE_REALISTIC_MODE ) );
    item->Check( g_Parm_3D_Visu.IsRealisticMode() );

    item = menuBar->FindItem( ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE );
    item->Check( g_Parm_3D_Visu.HightQualityMode() );

    item = menuBar->FindItem( ID_MENU3D_SHOW_BOARD_BODY );
    item->Check( g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) );
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ enum id_3dview_frm
    ID_MENU3D_ECO_ONOFF,
    ID_MENU3D_SHOW_BOARD_BODY,
    ID_MENU3D_REALISTIC_MODE,
    ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE,
    ID_END_COMMAND_3D,

    ID_TOOL_SET_VISIBLE_ITEMS,
+20 −19
Original line number Diff line number Diff line
@@ -62,9 +62,9 @@ INFO3D_VISU::INFO3D_VISU()

    m_CopperLayersCount = 2;
    m_BoardSettings     = NULL;
    m_CopperThickness   = 0;
    m_EpoxyThickness    = 0;
    m_NonCopperLayerThickness = 0;
    m_copperThickness   = 0;
    m_epoxyThickness    = 0;
    m_nonCopperLayerThickness = 0;

    // default all special item layers Visible
    for( ii = 0; ii < FL_LAST; ii++ )
@@ -72,6 +72,7 @@ INFO3D_VISU::INFO3D_VISU()

    SetFlag( FL_GRID, false );
    SetFlag( FL_USE_COPPER_THICKNESS, false );
    SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, false );
}


@@ -107,36 +108,36 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )

    m_BiuTo3Dunits = 2.0 / std::max( m_BoardSize.x, m_BoardSize.y );

    m_EpoxyThickness = aBoard->GetDesignSettings().GetBoardThickness() * m_BiuTo3Dunits;
    m_epoxyThickness = aBoard->GetDesignSettings().GetBoardThickness() * m_BiuTo3Dunits;

    // TODO use value defined by user (currently use default values by ctor
    m_CopperThickness   = COPPER_THICKNESS * m_BiuTo3Dunits;
    m_NonCopperLayerThickness = TECH_LAYER_THICKNESS * m_BiuTo3Dunits;
    m_copperThickness   = COPPER_THICKNESS * m_BiuTo3Dunits;
    m_nonCopperLayerThickness = TECH_LAYER_THICKNESS * m_BiuTo3Dunits;

    // Init  Z position of each layer
    // calculate z position for each copper layer
    // Z = 0 is the z position of the back (bottom) layer (layer id = 31)
    // Z = m_EpoxyThickness is the z position of the front (top) layer (layer id = 0)
    // Z = m_epoxyThickness is the z position of the front (top) layer (layer id = 0)
    // all unused copper layer z position are set to 0
    int layer;
    int copper_layers_cnt = m_CopperLayersCount;

    for( layer = 0; layer < copper_layers_cnt; layer++ )
    {
        m_LayerZcoord[layer] =
            m_EpoxyThickness - (m_EpoxyThickness * layer / (copper_layers_cnt - 1));
        m_layerZcoord[layer] =
            m_epoxyThickness - (m_epoxyThickness * layer / (copper_layers_cnt - 1));
    }

    #define layerThicknessMargin 1.1
    double zpos_offset = m_NonCopperLayerThickness * layerThicknessMargin;
    double  zpos_copper_back    = - layerThicknessMargin*m_CopperThickness/2;
    double  zpos_copper_front   = m_EpoxyThickness + layerThicknessMargin*m_CopperThickness/2;
    double zpos_offset = m_nonCopperLayerThickness * layerThicknessMargin;
    double  zpos_copper_back    = - layerThicknessMargin*m_copperThickness/2;
    double  zpos_copper_front   = m_epoxyThickness + layerThicknessMargin*m_copperThickness/2;

    // Fill remaining unused copper layers and back layer zpos
    // with 0
    for( ; layer < MAX_CU_LAYERS; layer++ )
    {
        m_LayerZcoord[layer] = 0;
        m_layerZcoord[layer] = 0;
    }

    // calculate z position for each non copper layer
@@ -184,22 +185,22 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
            break;
        }

        m_LayerZcoord[layer_id] = zpos;
        m_layerZcoord[layer_id] = zpos;
    }
}

/* return the Z position of 3D shapes, in 3D Units
 * aIsFlipped: true for modules on Front (top) layer, false
 * if on back (bottom) layer
 * Note: in draw functions, the copper has a thickness = m_CopperThickness
 * Vias and tracks are draw with the top side position = m_CopperThickness/2
 * and the bottom side position = -m_CopperThickness/2 from the Z layer position
 * Note: in draw functions, the copper has a thickness = m_copperThickness
 * Vias and tracks are draw with the top side position = m_copperThickness/2
 * and the bottom side position = -m_copperThickness/2 from the Z layer position
 */
double INFO3D_VISU::GetModulesZcoord3DIU( bool aIsFlipped )
{
    if(  aIsFlipped )
        return m_LayerZcoord[B_Cu] - ( m_CopperThickness / 2 );
        return m_layerZcoord[B_Cu] - ( m_copperThickness / 2 );
    else
        return m_LayerZcoord[F_Cu] + ( m_CopperThickness / 2 );
        return m_layerZcoord[F_Cu] + ( m_copperThickness / 2 );
}
Loading