Commit 7c482f68 authored by CHARRAS's avatar CHARRAS
Browse files

Added Jonas Diemer's patch (3D display: enhanced movings from mouse and tools)

parent 56ef4d3b
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -282,6 +282,8 @@ void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event )
    }

    if( event.Dragging() )
    {
        if( event.LeftIsDown() )
        {
            /* drag in progress, simulate trackball */
            trackball( spin_quat,
@@ -291,6 +293,15 @@ void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event )
                       ( size.y - 2.0 * event.GetY() ) / size.y );

            add_quats( spin_quat, g_Parm_3D_Visu.m_Quat, g_Parm_3D_Visu.m_Quat );
        }
        else if( event.MiddleIsDown() )
        {
            /* middle button drag -> pan */
            /* Current zoom and an additional factor are taken into account for the amount of panning. */
            const float PAN_FACTOR = 8.0 * g_Parm_3D_Visu.m_Zoom;
            g_Draw3d_dx -= PAN_FACTOR * ( g_Parm_3D_Visu.m_Beginx - event.GetX() ) / size.x;
            g_Draw3d_dy -= PAN_FACTOR * (event.GetY() - g_Parm_3D_Visu.m_Beginy) / size.y;
        }

        /* orientation has changed, redraw mesh */
        DisplayStatus();
+740 −703
Original line number Diff line number Diff line
//////////////////////////////////////

// Name:        3d_draw.cpp
//////////////////////////////////////

@@ -33,14 +34,20 @@ static void Draw3D_FilledSegment(double startx, double starty,
                                  double endx, double endy, double width, double zpos );
static void Draw3D_FilledCylinder( double posx, double posy,
                                   double rayon, double height, double zpos );
static void Draw3D_FilledSegmentWithHole(double startx, double starty,
				double endx, double endy,double width,
				double holex, double holey, double holeradius, double zpos);


/**********************************/
static void Draw3D_FilledSegmentWithHole( double startx,
                                          double starty,
                                          double endx,
                                          double endy,
                                          double width,
                                          double holex,
                                          double holey,
                                          double holeradius,
                                          double zpos );


/******************************************/
void Pcb3D_GLCanvas::Redraw( bool finish )
/**********************************/
/******************************************/
{
    SetCurrent();

@@ -50,11 +57,12 @@ void Pcb3D_GLCanvas::Redraw( bool finish )
    /* transformations */
    GLfloat mat[4][4];

    // Translatory motion first, so rotations don't mess up the orientation...
    glTranslatef( g_Draw3d_dx, g_Draw3d_dy, 0.0F );

    build_rotmatrix( mat, g_Parm_3D_Visu.m_Quat );
    glMultMatrixf( &mat[0][0] );

	glTranslatef(g_Draw3d_dx, g_Draw3d_dy, 0.0F);

    glRotatef( g_Parm_3D_Visu.m_Rot[0], 1.0, 0.0, 0.0 );
    glRotatef( g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0 );
    glRotatef( g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0 );
@@ -64,6 +72,7 @@ void Pcb3D_GLCanvas::Redraw( bool finish )
    else
    {
        m_gllist = CreateDrawGL_List();

//		m_gllist = DisplayCubeforTest();	// Only for test
    }

@@ -77,6 +86,7 @@ void Pcb3D_GLCanvas::Redraw( bool finish )
/**********************************************/
GLuint Pcb3D_GLCanvas::CreateDrawGL_List()
/**********************************************/

/* Creation de la liste des elements a afficher
 */
{
@@ -94,7 +104,8 @@ int ii;
    g_Parm_3D_Visu.m_BoardPos   = pcb->m_BoundaryBox.Centre();
    g_Parm_3D_Visu.m_BoardPos.y = -g_Parm_3D_Visu.m_BoardPos.y;
    g_Parm_3D_Visu.m_Layers     = pcb->m_BoardSettings->m_CopperLayerCount;
	g_Parm_3D_Visu.m_BoardScale = 2.0 / MAX(g_Parm_3D_Visu.m_BoardSize.x, g_Parm_3D_Visu.m_BoardSize.y);
    g_Parm_3D_Visu.m_BoardScale = 2.0 / MAX( g_Parm_3D_Visu.m_BoardSize.x,
                                             g_Parm_3D_Visu.m_BoardSize.y );
    float epoxy_width = 1.6;    // epoxy width in mm
    g_Parm_3D_Visu.m_Epoxy_Width = epoxy_width / 2.54 * 1000
                                   * g_Parm_3D_Visu.m_BoardScale;
@@ -108,6 +119,7 @@ int ii;
        else
            g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width;
    }

    GLfloat zpos_cu  = 500 * g_Parm_3D_Visu.m_BoardScale;
    GLfloat zpos_cmp = g_Parm_3D_Visu.m_Epoxy_Width + zpos_cu;
    g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CU]    = -zpos_cu * 2;
@@ -141,6 +153,7 @@ int ii;
#if 0
    glEnable( GL_FOG );
    GLfloat param;

//	param = GL_LINEAR;
//	glFogfv(GL_FOG_MODE, & param);
    param = 0.2;
@@ -200,6 +213,7 @@ MODULE * Module = (MODULE*) pcb->m_Modules;
    {
        Module->Draw3D( this );
    }

    glEndList();

    /* Test for errors */
@@ -241,6 +255,7 @@ double w;
/********************************************/
void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via )
/*********************************************/

/* 3D drawing for a VIA (cylinder + filled circles)
 */
{
@@ -273,6 +288,7 @@ int color;
        if( layer >= top_layer )
            break;
    }

    // Drawing hole:
    SetGLColor( DARKGRAY );
    height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer];
@@ -308,7 +324,6 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->GetLayer()];
            Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos );
        }
    }

    else
    {
        zpos = g_Parm_3D_Visu.m_LayerZcoord[segment->GetLayer()];
@@ -370,6 +385,7 @@ bool As3dShape = FALSE;
            Struct3D->ReadData();
        }
    }

    glPopMatrix();

    if( !As3dShape )
@@ -416,6 +432,7 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer];
    dy   = m_End.y;
    zpos = g_Parm_3D_Visu.m_LayerZcoord[m_Layer];
    w    = m_Width * g_Parm_3D_Visu.m_BoardScale;

    switch( m_Shape )
    {
    case S_SEGMENT:
@@ -444,6 +461,7 @@ int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer];
/***********************************************/
void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
/***********************************************/

/* Dessin 3D des pads avec leur trou de percage
 */
{
@@ -494,6 +512,7 @@ int color;
    Oncu  = (m_Masque_Layer & CUIVRE_LAYER) ? TRUE : FALSE;
    Oncmp = (m_Masque_Layer & CMP_LAYER) ? TRUE : FALSE;
    Both  = Oncu && Oncmp;

    switch( m_PadShape & 0x7F )
    {
    case PAD_CIRCLE:
@@ -518,6 +537,7 @@ int color;
            zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
            Draw3D_FilledCircle( x, -y, r, hole, zpos );
        }

        break;

    case PAD_OVAL:
@@ -565,6 +585,7 @@ int color;
        break;

    case PAD_RECT:

//	case SPECIAL_PAD:
    case PAD_TRAPEZOID:
    {
@@ -635,6 +656,7 @@ int color;
                glVertex3f( f_hole_coord[ii][0], -f_hole_coord[ii][1], zpos );
                glVertex3f( fcoord[ii][0], -fcoord[ii][1], zpos );
            }

            glVertex3f( f_hole_coord[0][0], -f_hole_coord[0][1], zpos );
            glVertex3f( fcoord[0][0], -fcoord[0][1], zpos );
            glEnd();
@@ -682,6 +704,7 @@ double x, y;
        RotatePoint( &x, &y, ii * 225 );
        glVertex3f( x + posx, y + posy, zpos );
    }

    glEnd();
}

@@ -693,6 +716,7 @@ static void Draw3D_FilledCylinder(double posx, double posy,
{
    int        ii;
    double     x, y;

#define NB_SEGM 12
    S3D_Vertex coords[4];
    double     tmp = DataScale3D;
@@ -716,6 +740,7 @@ double tmp = DataScale3D;
        coords[1].x = coords[3].x;
        coords[1].y = coords[3].y;
    }

    glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
    DataScale3D = tmp;
}
@@ -725,6 +750,7 @@ double tmp = DataScale3D;
static void Draw3D_FilledSegment( double startx, double starty,
                                  double endx, double endy, double width, double zpos )
/*****************************************************************/

/* trace un polygone semblable a un segment a bouts ronds
 */
{
@@ -743,6 +769,7 @@ int ii, angle;
    width /= 2;

    glBegin( GL_POLYGON );

    // trac de l'arrondi a droite (1er demi polygone a la fin du segment)
    for( ii = 0; ii <= 8; ii++ )
    {
@@ -758,6 +785,7 @@ int ii, angle;
            firsty = starty + y;
        }
    }

    // trac de l'arrondi a gauche (2ieme demi polygone a l'origine du segment)
    for( ii = 0; ii <= 8; ii++ )
    {
@@ -774,10 +802,17 @@ int ii, angle;


/*****************************************************************/
static void Draw3D_FilledSegmentWithHole(double startx, double starty,
				double endx, double endy, double width,
				double holex, double holey, double holeradius, double zpos)
static void Draw3D_FilledSegmentWithHole( double startx,
                                          double starty,
                                          double endx,
                                          double endy,
                                          double width,
                                          double holex,
                                          double holey,
                                          double holeradius,
                                          double zpos )
/*****************************************************************/

/* trace un polygone semblable a un segment a bouts ronds avec trou
 */
{
@@ -801,6 +836,7 @@ int ii, angle, theta;
    width /= 2;

    glBegin( GL_QUAD_STRIP );

    // trac de l'arrondi a droite (1er demi polygone a la fin du segment)
    // autour du demi-trou de percage
    for( ii = 0; ii <= 8; ii++ )
@@ -826,6 +862,7 @@ int ii, angle, theta;
            firstyin = starty + yin;
        }
    }

    // trac de l'arrondi a gauche (2ieme demi polygone a l'origine du segment)
    for( ii = 0; ii <= 8; ii++ )
    {
+6 −0
Original line number Diff line number Diff line
@@ -5,6 +5,12 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.


2008-mars-03 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
3d display:
	Added Jonas Diemer's patch (enhanced movings from mouse and tools)

2008-Mar-1 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew