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

Pcbnew: Fix bug 1042394 and very minor code cleaning.

parent bff11cea
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits
    /* draw polygon/triangle/quad */
    for( ii = 0; ii < aVertices.size(); ii++ )
    {
        glVertex3f( aVertices[ii].x * aBiuTo3DUnits,
        glVertex3d( aVertices[ii].x * aBiuTo3DUnits,
                    aVertices[ii].y * aBiuTo3DUnits,
                    aVertices[ii].z * aBiuTo3DUnits );
    }
+3 −2
Original line number Diff line number Diff line
@@ -499,8 +499,9 @@ void EDA_3D_CANVAS::InitGL()
        /* speedups */
        glEnable( GL_DITHER );
        glShadeModel( GL_SMOOTH );
        glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
        glHint( GL_POLYGON_SMOOTH_HINT, GL_FASTEST );
        glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE );
        glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
        glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );    // can be GL_FASTEST

        /* blend */
        glEnable( GL_BLEND );
+10 −14
Original line number Diff line number Diff line
@@ -154,8 +154,6 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
                  -g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BiuTo3Dunits,
                  0.0F );

    glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis

    // draw tracks and vias :
    for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
    {
@@ -463,7 +461,7 @@ void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack )
    int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );

    SetGLColor( color );
    glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
    glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );

    Draw3D_SolidSegment( aTrack->m_Start, aTrack->m_End,
                         aTrack->m_Width, thickness, zpos,
@@ -503,13 +501,11 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
        }

        SetGLColor( color );

        if( thickness == 0 )
            glNormal3f( 0.0, 0.0, layer == LAYER_N_BACK ? -1.0 : 1.0 );
        glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );

        Draw3D_ZaxisCylinder( via->m_Start, (outer_radius + inner_radius)/2,
                                  thickness, outer_radius - inner_radius,
                                  zpos - (thickness/2), biu_to_3Dunits );
                                  zpos, biu_to_3Dunits );
        if( layer >= top_layer )
            break;
    }
@@ -518,7 +514,7 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
    color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->m_Shape );
    SetGLColor( color );
    int height = g_Parm_3D_Visu.GetLayerZcoordBIU(top_layer) -
                 g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) - thickness;
                 g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer );
    int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(bottom_layer) + thickness/2;

    Draw3D_ZaxisCylinder( via->m_Start, inner_radius + thickness/2, height,
@@ -538,7 +534,7 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
    {
        for( layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ )
        {
            glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
            glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
            int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(layer);

            switch( segment->GetShape() )
@@ -784,7 +780,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
    {
        for( int layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ )
        {
            glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
            glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
            int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
            int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( m_Layer );

@@ -827,7 +823,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
    else
    {
        int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( m_Layer );
        glNormal3f( 0.0, 0.0, (m_Layer == LAYER_N_BACK) ? -1.0 : 1.0 );
        glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( m_Layer ) );
        int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(m_Layer);

        switch( m_Shape )
@@ -970,7 +966,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
            int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
            int ring_radius = (m_Size.x + m_Drill.x) / 4;
            if( thickness == 0 )
                glNormal3f( 0.0, 0.0, layer == LAYER_N_BACK ? -1.0 : 1.0 );
                glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );

            Draw3D_ZaxisCylinder(shape_pos, ring_radius,
                                  thickness, ( m_Size.x - m_Drill.x) / 2,
@@ -1047,7 +1043,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
            SetGLColor( color );

            if( thickness == 0 )
                glNormal3f( 0.0, 0.0, layer == LAYER_N_BACK ? -1.0 : 1.0 );
                glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );

            // If not hole: draw a single polygon
            int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
+21 −11
Original line number Diff line number Diff line
@@ -52,6 +52,18 @@ static void CALLBACK tessEndCB();
static void CALLBACK    tessErrorCB( GLenum errorCode );
static void CALLBACK    tessCPolyPt2Vertex( const GLvoid* data );

// 2 helper functions to set the current normal vector for gle items
static inline void SetNormalZpos()
{
    glNormal3f( 0.0, 0.0, 1.0 );
}

static inline void SetNormalZneg()
{
    glNormal3f( 0.0, 0.0, -1.0 );
}


/* Draw3D_VerticalPolygonalCylinder is a helper function.
 *
 * draws a "vertical cylinder" having a polygon shape
@@ -147,7 +159,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList,

    // Set normal to toward positive Z axis, for a solid object only (to draw the top side)
    if( aThickness )
        glNormal3f( 0.0, 0.0, 1.0 );
        SetNormalZpos();

    // gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);

@@ -191,7 +203,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList,
        g_Parm_3D_Visu.m_CurrentZpos = zpos;
        v_data[2] = zpos;
        // Now;, set normal to toward negative Z axis, for the solid object bottom side
        glNormal3f( 0.0, 0.0, -1.0 );
        SetNormalZneg();
    }

    gluDeleteTess( tess );
@@ -201,8 +213,6 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList,

    // Build the 3D data : vertical side
    Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos, false, aBiuTo3DUnits );

    glNormal3f( 0.0, 0.0, 1.0 );
}


@@ -258,7 +268,7 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
    if( aThickness )
    {
        // draw top (front) and bottom (back) horizontal sides (rings)
        glNormal3f( 0.0, 0.0, 1.0 );
        SetNormalZpos();
        outer_cornerBuffer.insert( outer_cornerBuffer.end(),
                             inner_cornerBuffer.begin(), inner_cornerBuffer.end() );
        std::vector<CPolyPt> polygon;
@@ -270,12 +280,12 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
        if( aHeight )
        {
            // draw bottom (back) horizontal ring
            glNormal3f( 0.0, 0.0, -1.0 );
            SetNormalZneg();
            Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, 0, aBiuTo3DUnits );
        }
    }

    glNormal3f( 0.0, 0.0, 1.0 );    // Normal is Z axis
    SetNormalZpos();
}


@@ -326,18 +336,18 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
        ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon );

        // draw top (front) horizontal side (ring)
        glNormal3f( 0.0, 0.0, 1.0 );
        SetNormalZpos();
        Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos + aHeight, 0, aBiuTo3DUnits );

        if( aHeight )
        {
            // draw bottom (back) horizontal side (ring)
            glNormal3f( 0.0, 0.0, -1.0 );
            SetNormalZneg();
            Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, 0, aBiuTo3DUnits );
        }
    }

    glNormal3f( 0.0, 0.0, 1.0 );    // Normal is Z axis
    SetNormalZpos();
}


@@ -395,7 +405,7 @@ void CALLBACK tessCPolyPt2Vertex( const GLvoid* data )
    // cast back to double type
    const CPolyPt* ptr = (const CPolyPt*) data;

    glVertex3f( ptr->x * g_Parm_3D_Visu.m_BiuTo3Dunits,
    glVertex3d( ptr->x * g_Parm_3D_Visu.m_BiuTo3Dunits,
                -ptr->y * g_Parm_3D_Visu.m_BiuTo3Dunits,
                g_Parm_3D_Visu.m_CurrentZpos );
}
+7 −7
Original line number Diff line number Diff line
@@ -45,8 +45,8 @@
#include <menus_helpers.h>

//external functions used here:
extern bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame,
                       int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos );
extern bool Magnetize( PCB_EDIT_FRAME* frame, int aCurrentTool,
                       wxSize aGridSize, wxPoint on_grid, wxPoint* curpos );


/**
@@ -323,11 +323,11 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH

    wxPoint curs_pos = pos;

    wxSize grid;
    grid.x = KiROUND( GetScreen()->GetGridSize().x );
    grid.y = KiROUND( GetScreen()->GetGridSize().y );
    wxSize igridsize;
    igridsize.x = KiROUND( gridSize.x );
    igridsize.y = KiROUND( gridSize.y );

    if( Magnetize( m_Pcb, this, GetToolId(), grid, curs_pos, &pos ) )
    if( Magnetize( this, GetToolId(), igridsize, curs_pos, &pos ) )
    {
        GetScreen()->SetCrossHairPosition( pos, false );
    }
@@ -350,7 +350,7 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
        pos = GetScreen()->GetCrossHairPosition();
        GetScreen()->SetCrossHairPosition( oldpos, false );
        m_canvas->CrossHairOff( aDC );
        GetScreen()->SetCrossHairPosition( pos, snapToGrid );
        GetScreen()->SetCrossHairPosition( pos, false );
        m_canvas->CrossHairOn( aDC );

        if( m_canvas->IsMouseCaptured() )
Loading