Commit 5f63becf authored by jean-pierre charras's avatar jean-pierre charras
Browse files

3D viewer: move helper functions from 3d_draw.cpp to...

3D viewer: move helper functions from 3d_draw.cpp to 3d_draw_helper_functions.cpp. Add comments in .h sources. Better management of background color. coding style fixes.
parent 64a9ebc7
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -53,7 +53,8 @@ void CheckGLError(const char *aFileName, int aLineNumber)


        errLast = err;
        errLast = err;


        wxLogError( wxT( "OpenGL error %d At: %s, line: %d" ), err,  GetChars( FROM_UTF8( aFileName ) ), aLineNumber );
        wxLogError( wxT( "OpenGL error %d At: %s, line: %d" ), err,
                    GetChars( FROM_UTF8( aFileName ) ), aLineNumber );
    }
    }
}
}


@@ -625,7 +626,7 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
        wxYield();
        wxYield();
    }
    }


    struct vieport_params
    struct viewport_params
    {
    {
        GLint originx;
        GLint originx;
        GLint originy;
        GLint originy;
@@ -633,6 +634,10 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
        GLint y;
        GLint y;
    } viewport;
    } viewport;


    // Be sure we have the latest 3D view (remember 3D view is buffered)
    Refresh();
    wxYield();

    // Build image from the 3D buffer
    // Build image from the 3D buffer
    wxWindowUpdateLocker noUpdates( this );
    wxWindowUpdateLocker noUpdates( this );
    glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport );
    glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport );
+50 −0
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@


class BOARD_DESIGN_SETTINGS;
class BOARD_DESIGN_SETTINGS;
class EDA_3D_FRAME;
class EDA_3D_FRAME;
class CPOLYGONS_LIST;


class VIA;
class VIA;
class D_PAD;
class D_PAD;
@@ -134,15 +135,40 @@ public:
    void   CreateDrawGL_List();
    void   CreateDrawGL_List();
    void   InitGL();
    void   InitGL();
    void   SetLights();
    void   SetLights();

    void   SetOffset(double aPosX, double aPosY)
    void   SetOffset(double aPosX, double aPosY)
    {
    {
        m_draw3dOffset.x = aPosX;
        m_draw3dOffset.x = aPosX;
        m_draw3dOffset.y = aPosY;
        m_draw3dOffset.y = aPosY;
    }
    }

private:
    /**
     * Helper function SetGLTechLayersColor
     * Initialize the color to draw the non copper layers
     * in realistic mode and normal mode.
     */
    void SetGLTechLayersColor( LAYER_NUM aLayer );
    void SetGLTechLayersColor( LAYER_NUM aLayer );

    /**
     * Helper function SetGLCopperColor
     * Initialize the copper color to draw the board
     * in realistic mode (a golden yellow color )
     */
    void SetGLCopperColor();
    void SetGLCopperColor();

    /**
     * Helper function SetGLEpoxyColor
     * Initialize the color to draw the epoxy body board in realistic mode.
     */
    void SetGLEpoxyColor( double aTransparency = 1.0 );
    void SetGLEpoxyColor( double aTransparency = 1.0 );


    /**
     * Helper function SetGLSolderMaskColor
     * Initialize the color to draw the solder mask layers in realistic mode.
     */
    void SetGLSolderMaskColor( double aTransparency = 1.0 );

    /**
    /**
     * Function BuildBoard3DView
     * Function BuildBoard3DView
     * Called by CreateDrawGL_List()
     * Called by CreateDrawGL_List()
@@ -187,7 +213,31 @@ public:
    void   Draw3DGrid( double aGriSizeMM );
    void   Draw3DGrid( double aGriSizeMM );
    void   Draw3DAxis();
    void   Draw3DAxis();


    /**
     * Helper function BuildPadShapeThickOutlineAsPolygon:
     * Build a pad outline as non filled polygon, to draw pads on silkscreen layer
     * with a line thickness = aWidth
     * Used only to draw pads outlines on silkscreen layers.
     */
    void BuildPadShapeThickOutlineAsPolygon( const D_PAD*          aPad,
                                             CPOLYGONS_LIST& aCornerBuffer,
                                             int             aWidth,
                                             int             aCircleToSegmentsCount,
                                             double          aCorrectionFactor );


    /**
     * Helper function Draw3DViaHole:
     * Draw the via hole:
     * Build a vertical hole (a cylinder) between the first and the last via layers
     */
    void   Draw3DViaHole( const VIA * aVia );
    void   Draw3DViaHole( const VIA * aVia );

    /**
     * Helper function Draw3DPadHole:
     * Draw the pad hole:
     * Build a vertical hole (round or oblong) between the front and back layers
     */
    void   Draw3DPadHole( const D_PAD * aPad );
    void   Draw3DPadHole( const D_PAD * aPad );


    void   GenerateFakeShadowsTextures();
    void   GenerateFakeShadowsTextures();
+35 −373
Original line number Original line Diff line number Diff line
@@ -65,44 +65,9 @@ static bool Is3DLayerEnabled( LAYER_ID aLayer );
 */
 */
static GLfloat  Get3DLayer_Z_Orientation( LAYER_NUM aLayer );
static GLfloat  Get3DLayer_Z_Orientation( LAYER_NUM aLayer );


/* Helper function BuildPadShapeThickOutlineAsPolygon:
 * Build a pad shape outline as polygon, to draw pads on silkscreen layer
 * with a line thickness = aWidth
 * Used only to draw pads outlines on silkscreen layers.
 */
static void BuildPadShapeThickOutlineAsPolygon( D_PAD*          aPad,
                                                CPOLYGONS_LIST& aCornerBuffer,
                                                int             aWidth,
                                                int             aCircleToSegmentsCount,
                                                double          aCorrectionFactor )
{
    if( aPad->GetShape() == PAD_CIRCLE )    // Draw a ring
    {
        TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
                                aPad->GetSize().x / 2, aCircleToSegmentsCount, aWidth );
        return;
    }

    // For other shapes, draw polygon outlines
    CPOLYGONS_LIST corners;
    aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
                                aCircleToSegmentsCount, aCorrectionFactor );


    // Add outlines as thick segments in polygon buffer
/* Based on the tutorial http://www.ulrichmierendorff.com/software/opengl_blur.html
    for( unsigned ii = 0, jj = corners.GetCornersCount() - 1;
 * It will blur a openGL texture
         ii < corners.GetCornersCount(); jj = ii, ii++ )
    {
        TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
                                              corners.GetPos( jj ),
                                              corners.GetPos( ii ),
                                              aCircleToSegmentsCount, aWidth );
    }
}


// Based on the tutorial by http://www.ulrichmierendorff.com/software/opengl_blur.html
/* It will blur a openGL texture
 *
 */
 */
static void blur_tex( GLuint aTex, int aPasses, GLuint aTexture_size )
static void blur_tex( GLuint aTex, int aPasses, GLuint aTexture_size )
{
{
@@ -297,20 +262,23 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
    {
    {
        return;
        return;
    }
    }
    m_shadow_init = true;


    // Init info 3d parameters and create gl lists:
    CreateDrawGL_List();
    CreateDrawGL_List();


    m_shadow_init = true;

    glClearColor( 0, 0, 0, 1 );
    glClearColor( 0, 0, 0, 1 );


    glMatrixMode( GL_PROJECTION );
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glLoadIdentity();

    const double ZDIST_MAX = Millimeter2iu( 3.5 ) * g_Parm_3D_Visu.m_BiuTo3Dunits;
    glOrtho( -g_Parm_3D_Visu.m_BoardSize.x * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
    glOrtho( -g_Parm_3D_Visu.m_BoardSize.x * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             g_Parm_3D_Visu.m_BoardSize.x * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             g_Parm_3D_Visu.m_BoardSize.x * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             -g_Parm_3D_Visu.m_BoardSize.y * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             -g_Parm_3D_Visu.m_BoardSize.y * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             g_Parm_3D_Visu.m_BoardSize.y * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             g_Parm_3D_Visu.m_BoardSize.y * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             0.0, 3500000 * g_Parm_3D_Visu.m_BiuTo3Dunits );
             0.0, ZDIST_MAX );



    // Render FRONT shadow
    // Render FRONT shadow
    glMatrixMode( GL_MODELVIEW );
    glMatrixMode( GL_MODELVIEW );
@@ -336,7 +304,7 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
             g_Parm_3D_Visu.m_BoardSize.x * SHADOW_BOARD_SCALE * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             g_Parm_3D_Visu.m_BoardSize.x * SHADOW_BOARD_SCALE * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             -g_Parm_3D_Visu.m_BoardSize.y * SHADOW_BOARD_SCALE * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             -g_Parm_3D_Visu.m_BoardSize.y * SHADOW_BOARD_SCALE * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             g_Parm_3D_Visu.m_BoardSize.y * SHADOW_BOARD_SCALE * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             g_Parm_3D_Visu.m_BoardSize.y * SHADOW_BOARD_SCALE * g_Parm_3D_Visu.m_BiuTo3Dunits / 2.0f,
             0.0, 6.0f * 3500000 * g_Parm_3D_Visu.m_BiuTo3Dunits );
             0.0, 6.0f * ZDIST_MAX );


    glMatrixMode( GL_MODELVIEW );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glLoadIdentity();
@@ -392,18 +360,29 @@ void EDA_3D_CANVAS::Redraw()
    glDisable( GL_DEPTH_TEST );
    glDisable( GL_DEPTH_TEST );
    glDisable( GL_TEXTURE_2D );
    glDisable( GL_TEXTURE_2D );


    // Draw the background ( rectangle with color gradient)
    glBegin( GL_QUADS );
    glBegin( GL_QUADS );
    glColor4f( 0.95, 0.95, 1.0, 1.0 );
    #define BGCOLOR1(x) (x)
    glVertex2f( -1.0, 0.85 );
    #define BGCOLOR2(x) (x * 0.3)

    glColor4f( BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Red ),
    glColor4f( g_Parm_3D_Visu.m_BgColor.m_Red,
               BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Green ),
               g_Parm_3D_Visu.m_BgColor.m_Green,
               BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Blue  ),
               g_Parm_3D_Visu.m_BgColor.m_Blue, 1.0 );
               1.0 );
    glVertex2f( -1.0,-1.0 );
    glVertex2f( -1.0, 1.0 );    // Top left corner
    glVertex2f( 1.0,-1.0 );

    glColor4f( BGCOLOR2( g_Parm_3D_Visu.m_BgColor.m_Red ),
               BGCOLOR2( g_Parm_3D_Visu.m_BgColor.m_Green ),
               BGCOLOR2( g_Parm_3D_Visu.m_BgColor.m_Blue ),
               1.0 );
    glVertex2f( -1.0,-1.0 );    // bottom left corner
    glVertex2f( 1.0,-1.0 );     // bottom right corner

    glColor4f( BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Red ),
               BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Green ),
               BGCOLOR1( g_Parm_3D_Visu.m_BgColor.m_Blue  ),
               1.0 );
    glVertex2f( 1.0, 1.0 );     // top right corner


    glColor4f( 0.95, 0.95, 1.0, 1.0 );
    glVertex2f( 1.0, 0.85 );
    glEnd();
    glEnd();
    glEnable( GL_DEPTH_TEST );
    glEnable( GL_DEPTH_TEST );


@@ -579,82 +558,8 @@ void EDA_3D_CANVAS::Redraw()
            glDisable( GL_CULL_FACE );
            glDisable( GL_CULL_FACE );
        }
        }
    }
    }
    SwapBuffers();
}

// Helper function: initialize the copper color to draw the board
// in realistic mode.
void EDA_3D_CANVAS::SetGLCopperColor()
{
    glDisable( GL_TEXTURE_2D );

    // 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
// body board in realistic mode.
void EDA_3D_CANVAS::SetGLEpoxyColor( double aTransparency )
{
    // 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 );
}

// Helper function: initialize the color to draw the non copper layers
// in realistic mode and normal mode.
void EDA_3D_CANVAS::SetGLTechLayersColor( LAYER_NUM aLayer )
{
    EDA_COLOR_T color;

    if( g_Parm_3D_Visu.IsRealisticMode() )
    {
        switch( aLayer )
        {
        case B_Paste:
        case F_Paste:
            SetGLColor( DARKGRAY, 0.7 );
            break;

        case B_SilkS:
        case F_SilkS:
            SetGLColor( LIGHTGRAY, 0.9 );
            if( g_Parm_3D_Visu.HightQualityMode() )
            {
                SetGLTexture( m_text_silk, 50.0f );
            }
            break;

        case B_Mask:
        case F_Mask:
            SetGLSolderMaskColor( 0.7 );
            if( g_Parm_3D_Visu.HightQualityMode() )
            {
                SetGLTexture( m_text_pcb, 35.0f );
            }
            break;


        default:
    SwapBuffers();
            color = g_ColorsSettings.GetLayerColor( aLayer );
            SetGLColor( color, 0.7 );
            break;
        }
    }
    else
    {
        color = g_ColorsSettings.GetLayerColor( aLayer );
        SetGLColor( color, 0.7 );
    }
}
}




@@ -1037,12 +942,14 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)




    glNewList( aBodyOnlyList, GL_COMPILE );
    glNewList( aBodyOnlyList, GL_COMPILE );

    if( bufferPcbOutlines.GetCornersCount() )
    if( bufferPcbOutlines.GetCornersCount() )
    {
    {
        glColor4f( 1.0, 1.0, 1.0, 1.0 );
        glColor4f( 1.0, 1.0, 1.0, 1.0 );
        Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness/2.0,
        Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness/2.0,
                                    board_thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
                                    board_thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
    }
    }

    glEndList();
    glEndList();
}
}


@@ -1481,192 +1388,6 @@ void EDA_3D_CANVAS::BuildFootprintShape3DList( GLuint aOpaqueList,
        glEndList();
        glEndList();
}
}


void EDA_3D_CANVAS::Draw3DAxis()
{
    if( ! m_glLists[GL_ID_AXIS] )
    {
        m_glLists[GL_ID_AXIS] = glGenLists( 1 );
        glNewList( m_glLists[GL_ID_AXIS], GL_COMPILE );

        glEnable( GL_COLOR_MATERIAL );
        SetGLColor( WHITE );
        glBegin( GL_LINES );
        glNormal3f( 0.0f, 0.0f, 1.0f );     // Normal is Z axis
        glVertex3f( 0.0f, 0.0f, 0.0f );
        glVertex3f( 1.0f, 0.0f, 0.0f );     // X axis
        glVertex3f( 0.0f, 0.0f, 0.0f );
        glVertex3f( 0.0f, -1.0f, 0.0f );    // Y axis
        glNormal3f( 1.0f, 0.0f, 0.0f );     // Normal is Y axis
        glVertex3f( 0.0f, 0.0f, 0.0f );
        glVertex3f( 0.0f, 0.0f, 0.3f );     // Z axis
        glEnd();

        glEndList();
    }
}

// draw a 3D grid: an horizontal grid (XY plane and Z = 0,
// and a vertical grid (XZ plane and Y = 0)
void EDA_3D_CANVAS::Draw3DGrid( double aGriSizeMM )
{
    double      zpos = 0.0;
    EDA_COLOR_T gridcolor = DARKGRAY;           // Color of grid lines
    EDA_COLOR_T gridcolor_marker = LIGHTGRAY;   // Color of grid lines every 5 lines
    const double scale = g_Parm_3D_Visu.m_BiuTo3Dunits;
    const double transparency = 0.3;

    glNormal3f( 0.0, 0.0, 1.0 );

    wxSize  brd_size = g_Parm_3D_Visu.m_BoardSize;
    wxPoint brd_center_pos = g_Parm_3D_Visu.m_BoardPos;
    NEGATE( brd_center_pos.y );

    int     xsize   = std::max( brd_size.x, Millimeter2iu( 100 ) );
    int     ysize   = std::max( brd_size.y, Millimeter2iu( 100 ) );

    // Grid limits, in 3D units
    double  xmin    = (brd_center_pos.x - xsize / 2) * scale;
    double  xmax    = (brd_center_pos.x + xsize / 2) * scale;
    double  ymin    = (brd_center_pos.y - ysize / 2) * scale;
    double  ymax    = (brd_center_pos.y + ysize / 2) * scale;
    double  zmin    = Millimeter2iu( -50 ) * scale;
    double  zmax    = Millimeter2iu( 100 ) * scale;

    // Draw horizontal grid centered on 3D origin (center of the board)
    for( int ii = 0; ; ii++ )
    {
        if( (ii % 5) )
            SetGLColor( gridcolor, transparency );
        else
            SetGLColor( gridcolor_marker, transparency );

        int delta = KiROUND( ii * aGriSizeMM * IU_PER_MM );

        if( delta <= xsize / 2 )    // Draw grid lines parallel to X axis
        {
            glBegin( GL_LINES );
            glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
            glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
            glEnd();

            if( ii != 0 )
            {
                glBegin( GL_LINES );
                glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
                glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
                glEnd();
            }
        }

        if( delta <= ysize / 2 )    // Draw grid lines parallel to Y axis
        {
            glBegin( GL_LINES );
            glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
            glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
            glEnd();

            if( ii != 0 )
            {
                glBegin( GL_LINES );
                glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
                glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
                glEnd();
            }
        }

        if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
            break;
    }

    // Draw vertical grid n Z axis
    glNormal3f( 0.0, -1.0, 0.0 );

    // Draw vertical grid lines (parallel to Z axis)
    for( int ii = 0; ; ii++ )
    {
        if( (ii % 5) )
            SetGLColor( gridcolor, transparency );
        else
            SetGLColor( gridcolor_marker, transparency );

        double delta = ii * aGriSizeMM * IU_PER_MM;

        glBegin( GL_LINES );
        glVertex3f( (brd_center_pos.x + delta) * scale, -brd_center_pos.y * scale, zmin );
        glVertex3f( (brd_center_pos.x + delta) * scale, -brd_center_pos.y * scale, zmax );
        glEnd();

        if( ii != 0 )
        {
            glBegin( GL_LINES );
            glVertex3f( (brd_center_pos.x - delta) * scale, -brd_center_pos.y * scale, zmin );
            glVertex3f( (brd_center_pos.x - delta) * scale, -brd_center_pos.y * scale, zmax );
            glEnd();
        }

        if( delta > xsize / 2 )
            break;
    }

    // Draw horizontal grid lines on Z axis
    for( int ii = 0; ; ii++ )
    {
        if( (ii % 5) )
            SetGLColor( gridcolor, transparency);
        else
            SetGLColor( gridcolor_marker, transparency );

        double delta = ii * aGriSizeMM * IU_PER_MM * scale;

        if( delta <= zmax )
        {
            // Draw grid lines on Z axis (positive Z axis coordinates)
            glBegin( GL_LINES );
            glVertex3f( xmin, -brd_center_pos.y * scale, delta );
            glVertex3f( xmax, -brd_center_pos.y * scale, delta );
            glEnd();
        }

        if( delta <= -zmin && ( ii != 0 ) )
        {
            // Draw grid lines on Z axis (negative Z axis coordinates)
            glBegin( GL_LINES );
            glVertex3f( xmin, -brd_center_pos.y * scale, -delta );
            glVertex3f( xmax, -brd_center_pos.y * scale, -delta );
            glEnd();
        }

        if( ( delta > zmax ) && ( delta > -zmin ) )
            break;
    }
}


void EDA_3D_CANVAS::Draw3DViaHole( const VIA* aVia )
{
    LAYER_ID    top_layer, bottom_layer;
    int         inner_radius    = aVia->GetDrillValue() / 2;
    int         thickness       = g_Parm_3D_Visu.GetCopperThicknessBIU();

    aVia->LayerPair( &top_layer, &bottom_layer );

    // Drawing via hole:
    if( g_Parm_3D_Visu.IsRealisticMode() )
        SetGLCopperColor();
    else
    {
        EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetViaType() );
        SetGLColor( color );
    }

    int         height = g_Parm_3D_Visu.GetLayerZcoordBIU( top_layer ) -
                         g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) - thickness;
    int         zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) + thickness / 2;

    Draw3D_ZaxisCylinder( aVia->GetStart(), inner_radius + thickness / 2, height,
                          thickness, zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
}



void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas,
void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas,
                                    bool aAllowNonTransparentObjects,
                                    bool aAllowNonTransparentObjects,
@@ -1706,65 +1427,6 @@ void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas,
}
}




// Draw 3D pads.
void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
{
    // Draw the pad hole
    wxSize  drillsize   = aPad->GetDrillSize();
    bool    hasHole     = drillsize.x && drillsize.y;

    if( !hasHole )
        return;

    // Store here the points to approximate hole by segments
    CPOLYGONS_LIST  holecornersBuffer;
    int             thickness   = g_Parm_3D_Visu.GetCopperThicknessBIU();
    int             height      = g_Parm_3D_Visu.GetLayerZcoordBIU( F_Cu ) -
                                  g_Parm_3D_Visu.GetLayerZcoordBIU( B_Cu );

    if( g_Parm_3D_Visu.IsRealisticMode() )
        SetGLCopperColor();
    else
        SetGLColor( DARKGRAY );

    int holeZpoz    = g_Parm_3D_Visu.GetLayerZcoordBIU( B_Cu ) + thickness / 2;
    int holeHeight  = height - thickness;

    if( drillsize.x == drillsize.y )    // usual round hole
    {
        Draw3D_ZaxisCylinder( aPad->GetPosition(),
                              (drillsize.x + thickness) / 2, holeHeight,
                              thickness, holeZpoz, g_Parm_3D_Visu.m_BiuTo3Dunits );
    }
    else    // Oblong hole
    {
        wxPoint ends_offset;
        int     width;

        if( drillsize.x > drillsize.y )    // Horizontal oval
        {
            ends_offset.x = ( drillsize.x - drillsize.y ) / 2;
            width = drillsize.y;
        }
        else    // Vertical oval
        {
            ends_offset.y = ( drillsize.y - drillsize.x ) / 2;
            width = drillsize.x;
        }

        RotatePoint( &ends_offset, aPad->GetOrientation() );

        wxPoint start   = aPad->GetPosition() + ends_offset;
        wxPoint end     = aPad->GetPosition() - ends_offset;
        int     hole_radius = ( width + thickness ) / 2;

        // Draw the hole
        Draw3D_ZaxisOblongCylinder( start, end, hole_radius, holeHeight,
                                    thickness, holeZpoz, g_Parm_3D_Visu.m_BiuTo3Dunits );
    }
}


static bool Is3DLayerEnabled( LAYER_ID aLayer )
static bool Is3DLayerEnabled( LAYER_ID aLayer )
{
{
    DISPLAY3D_FLG flg;
    DISPLAY3D_FLG flg;
+395 −0

File added.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Original line Diff line number Diff line
@@ -522,7 +522,7 @@ void EDA_3D_FRAME::Set3DBgColor()


    newcolor = wxGetColourFromUser( this, oldcolor );
    newcolor = wxGetColourFromUser( this, oldcolor );


    if( !newcolor.IsOk() )     // Happens on cancel dialog
    if( !newcolor.IsOk() )     // Cancel command
        return;
        return;


    if( newcolor != oldcolor )
    if( newcolor != oldcolor )
@@ -530,7 +530,7 @@ void EDA_3D_FRAME::Set3DBgColor()
        g_Parm_3D_Visu.m_BgColor.m_Red      = (double) newcolor.Red() / 255.0;
        g_Parm_3D_Visu.m_BgColor.m_Red      = (double) newcolor.Red() / 255.0;
        g_Parm_3D_Visu.m_BgColor.m_Green    = (double) newcolor.Green() / 255.0;
        g_Parm_3D_Visu.m_BgColor.m_Green    = (double) newcolor.Green() / 255.0;
        g_Parm_3D_Visu.m_BgColor.m_Blue     = (double) newcolor.Blue() / 255.0;
        g_Parm_3D_Visu.m_BgColor.m_Blue     = (double) newcolor.Blue() / 255.0;
        NewDisplay();
        m_canvas->Redraw();
    }
    }
}
}


Loading