Commit f3230893 authored by charras's avatar charras
Browse files

Solved minor problems in eeschema, and code cleaning.

parent ae0768c3
Loading
Loading
Loading
Loading
+292 −271
Original line number Diff line number Diff line
//////////////////////////////////////

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

@@ -88,12 +89,14 @@ void Pcb3D_GLCanvas::Redraw( bool finish )
/**********************************************/
GLuint Pcb3D_GLCanvas::CreateDrawGL_List()
/**********************************************/

/* Create the draw list items
 */
{
    WinEDA_BasePcbFrame* pcbframe = m_Parent->m_Parent;
    BOARD*       pcb = pcbframe->m_Pcb;
    TRACK*               pt_piste;
    TRACK*       track;
    SEGZONE*     segzone;
    int          ii;

    wxBusyCursor dummy;
@@ -138,8 +141,9 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List()

    glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );

    /* draw axes */
	if (g_Parm_3D_Visu.m_Draw3DAxis){
    /* draw axis */
    if( g_Parm_3D_Visu.m_Draw3DAxis )
    {
        glEnable( GL_COLOR_MATERIAL );
        SetGLColor( WHITE );
        glBegin( GL_LINES );
@@ -187,51 +191,52 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List()
    glEnd();
#endif

    /* Translation du trac du BOARD pour placer son centre en 0, 0 */
    /* move the board in order to draw it with its centre at 0,0 3D coordinates */
    glTranslatef( -g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BoardScale,
        -g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale,
        0.0F );

    glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
    /* Trac des pistes : */
    for( pt_piste = pcb->m_Track; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )
    /* draw tracks and vias : */
    for( track = pcb->m_Track; track != NULL; track = track->Next() )
    {
        if( pt_piste->Type() == TYPEVIA )
            Draw3D_Via( (SEGVIA*) pt_piste );
        if( track->Type() == TYPEVIA )
            Draw3D_Via( (SEGVIA*) track );
        else
            Draw3D_Track( pt_piste );
            Draw3D_Track( track );
    }
	if (g_Parm_3D_Visu.m_Draw3DZone){
		for( pt_piste = pcb->m_Zone; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )

    if( g_Parm_3D_Visu.m_Draw3DZone )
    {
        for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() )
        {
			if( pt_piste->Type() == TYPEZONE )
				Draw3D_Track( pt_piste );
            if( segzone->Type() == TYPEZONE )
                Draw3D_Track( segzone );
        }
    }

    /* Trac des edges */
    /* draw graphic items */
    EDA_BaseStruct* PtStruct;
    for( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext )
    {
        //if( PtStruct->Type() != TYPEDRAWSEGMENT )
        //    continue;
		if( PtStruct->Type() == TYPEDRAWSEGMENT )
        switch( PtStruct->Type() )
        {
			#undef STRUCT
			#define STRUCT ( (DRAWSEGMENT*) PtStruct )
        	Draw3D_DrawSegment( STRUCT );
		}	
		if( PtStruct->Type() == TYPETEXTE )
		{
			#undef STRUCT
            #define STRUCT ( (TEXTE_PCB*) PtStruct )
            Draw3D_DrawText( STRUCT );
        case TYPEDRAWSEGMENT:
            Draw3D_DrawSegment( (DRAWSEGMENT*) PtStruct );
            break;

        case TYPETEXTE:
            Draw3D_DrawText( (TEXTE_PCB*) PtStruct );
            break;

        default:
            break;
        }
    }

    /* trac des modules */
    MODULE*         Module = (MODULE*) pcb->m_Modules;
    for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
    /* draw footprints */
    MODULE*         Module = pcb->m_Modules;
    for( ; Module != NULL; Module = Module->Next() )
    {
        Module->Draw3D( this );
    }
@@ -304,18 +309,22 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via )
            color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N];
        if( color & ITEM_NOT_SHOW )
            continue;
		//SetGLColor( color );	
		SetGLColor( LIGHTGRAY );

        SetGLColor( color );
        // SetGLColor( LIGHTGRAY );
        glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
        if (layer == COPPER_LAYER_N) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
		else 						 zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;			
        if( layer == COPPER_LAYER_N )
            zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
        else
            zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
        Draw3D_FilledCircle( x, -y, r, hole, zpos );
        if( layer >= top_layer )
            break;
    }

    // Drawing hole:
    SetGLColor( DARKGRAY );
    color = g_Parm_3D_Visu.m_BoardSettings->m_ViaColor[via->m_Shape];
    SetGLColor( color );
    height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer];
    Draw3D_FilledCylinder( x, -y, hole, height, g_Parm_3D_Visu.m_LayerZcoord[bottom_layer] );
}
@@ -346,14 +355,17 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment )
        {
            glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
            zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];

            switch( segment->m_Shape )
            {
            case S_ARC:
                Draw3D_ArcSegment( x, -y, xf, -yf, w, zpos );
                break;

            case S_CIRCLE:
                Draw3D_CircleSegment( x, -y, xf, -yf, w, zpos );
                break;

            default:
                Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos );
                break;
@@ -372,9 +384,11 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment )
            case S_ARC:
                Draw3D_ArcSegment( x, -y, xf, -yf, w, zpos );
                break;

            case S_CIRCLE:
                Draw3D_CircleSegment( x, -y, xf, -yf, w, zpos );
                break;

            default:
                Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos );
                break;
@@ -383,6 +397,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment )
    }
}


/*************************************************************/
void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text )
/*************************************************************/
@@ -432,6 +447,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text )
    }
}


/*********************************************/
void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas )
/*********************************************/
@@ -462,14 +478,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas )
    /* Draw module shape: 3D shape if exists (or module edge if not exists) */
    Struct3D_Master* Struct3D  = m_3D_Drawings;
    bool             As3dShape = FALSE;
	bool	Place3D;
	if ( (Struct3D->m_Shape3DName.Find(wxString(wxT("placa"))) != -1) ||
	     (Struct3D->m_Shape3DName.Find(wxString(wxT("place"))) != -1) )
	   Place3D = TRUE;
	else Place3D = FALSE;   
	
	if ( (g_Parm_3D_Visu.m_Draw3DModule && !Place3D) ||
	     (g_Parm_3D_Visu.m_Draw3DPlace && Place3D) )
    if( g_Parm_3D_Visu.m_Draw3DModule )
    {
        glPushMatrix();
        glTranslatef( m_Pos.x * g_Parm_3D_Visu.m_BoardScale,
@@ -494,10 +503,11 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas )
                Struct3D->ReadData();
            }
        }

        glPopMatrix();
    }

    if( !As3dShape )
    if( !As3dShape )    // The footprint does not have a 3D shape, draw its 2D shape instead
    {
        EDA_BaseStruct* Struct = m_Drawings;
        glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
@@ -642,12 +652,14 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
            color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
            if( color & ITEM_NOT_SHOW )
                continue;
            //SetGLColor( color );
			SetGLColor( LIGHTGRAY );

            SetGLColor( color );
            glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
            zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
			if (layer == COPPER_LAYER_N) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
			else 						 zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
            if( layer == COPPER_LAYER_N )
                zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
            else
                zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
            Draw3D_FilledCircle( x, -y, r, hole, zpos );
        }

@@ -690,11 +702,13 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
                glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
                if( color & ITEM_NOT_SHOW )
                    continue;
                //SetGLColor( color );
				SetGLColor( LIGHTGRAY );

                SetGLColor( color );
                zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
				if (layer == COPPER_LAYER_N) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
				else 						 zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
                if( layer == COPPER_LAYER_N )
                    zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
                else
                    zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
                Draw3D_FilledSegmentWithHole( ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos );
            }
        }
@@ -702,7 +716,6 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )

    case PAD_RECT:

//	case SPECIAL_PAD:
    case PAD_TRAPEZOID:
    {
        int ddx, ddy;
@@ -764,11 +777,13 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
            glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 );
            if( color & ITEM_NOT_SHOW )
                continue;
            //SetGLColor( color );
			SetGLColor( LIGHTGRAY );

            SetGLColor( color );
            zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
			if (layer == COPPER_LAYER_N) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
			else 						 zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;			
            if( layer == COPPER_LAYER_N )
                zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
            else
                zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
            glBegin( GL_QUAD_STRIP );
            for( ii = 0; ii < 8; ii++ )
            {
@@ -1003,6 +1018,7 @@ static void Draw3D_FilledSegmentWithHole( double startx,
    glEnd();
}


/********************************************************/
static void Draw3D_ArcSegment( double startx, double starty,
                               double endx, double endy, double width, double zpos )
@@ -1025,9 +1041,11 @@ int angle;
        RotatePoint( &x, &y, angle + (ii * 3600 / slice) );
        glVertex3f( x + startx, y + starty, zpos );
    }

    glEnd();
}


/*******************************************************************/
static void Draw3D_CircleSegment( double startx, double starty,
                                  double endx, double endy, double width, double zpos )
@@ -1049,9 +1067,11 @@ double x, y, hole, rayon;
        RotatePoint( &x, &y, ii * 3600 / slice );
        glVertex3f( x + startx, y + starty, zpos );
    }

    glEnd();
}


/******************************************/
static int Get3DLayerEnable( int act_layer )
/******************************************/
@@ -1071,20 +1091,21 @@ static int Get3DLayerEnable(int act_layer)
    return enablelayer;
}


/******************************************/
static GLfloat Get3DLayerSide( int act_layer )
/******************************************/
{
    GLfloat nZ;

    nZ = 1.0;
    if(
		 (act_layer <= LAST_COPPER_LAYER-1) ||
		 (act_layer == ADHESIVE_N_CU) ||
		 (act_layer == SOLDERPASTE_N_CU) ||
		 (act_layer == SILKSCREEN_N_CU) ||
		 (act_layer == SOLDERMASK_N_CU)
        (act_layer <= LAST_COPPER_LAYER - 1)
        || (act_layer == ADHESIVE_N_CU)
        || (act_layer == SOLDERPASTE_N_CU)
        || (act_layer == SILKSCREEN_N_CU)
        || (act_layer == SOLDERMASK_N_CU)
        )
        nZ = -1.0;
    return nZ;

}
+19 −8
Original line number Diff line number Diff line
@@ -103,6 +103,12 @@ void WinEDA3D_DrawFrame::ReCreateVToolbar()
void WinEDA3D_DrawFrame::ReCreateMenuBar()
/**********************************************/
{
bool full_options = true;

    // If called from the display frame of cvpcb, only some options are relevant
    if ( m_Parent->m_FrameName == wxT( "CmpFrame" ) )   // Called from cvpcb !
        full_options =  false;  // Do not display all options

    wxMenuBar* menuBar = new wxMenuBar;

    wxMenu*    fileMenu = new wxMenu;
@@ -121,28 +127,33 @@ void WinEDA3D_DrawFrame::ReCreateMenuBar()
                  _( "Choose background color" ), palette_xpm );

    ADD_MENUITEM( referencesMenu, ID_MENU3D_AXIS_ONOFF,
                  _( "Axis On/Off" ), axis3d_front_xpm );
                  _( "3D Axis On/Off" ), axis3d_front_xpm );

    if ( full_options )
    {
    ADD_MENUITEM( referencesMenu, ID_MENU3D_MODULE_ONOFF,
                  _( "Module 3D On/Off" ), add_component_xpm );
                  _( "3D Footprints Shapes On/Off" ), add_component_xpm );

#if 0
    ADD_MENUITEM( referencesMenu, ID_MENU3D_PLACE_ONOFF,
                  _( "PCB place 3D On/off" ), select_w_layer_xpm );
#endif

    ADD_MENUITEM( referencesMenu, ID_MENU3D_ZONE_ONOFF,
                  _( "Zone On/Off" ), add_zone_xpm );
                  _( "Zone Filling On/Off" ), add_zone_xpm );

    ADD_MENUITEM( referencesMenu, ID_MENU3D_COMMENTS_ONOFF,
                  _( "Comments On/Off" ), edit_sheet_xpm );
                  _( "Comments Layer On/Off" ), edit_sheet_xpm );

    ADD_MENUITEM( referencesMenu, ID_MENU3D_DRAWINGS_ONOFF,
                  _( "Drawings On/Off" ), options_text_xpm );
                  _( "Drawings Layer On/Off" ), add_polygon_xpm );

    ADD_MENUITEM( referencesMenu, ID_MENU3D_ECO1_ONOFF,
                  _( "Eco1 On/Off" ), options_text_xpm );
                  _( "Eco1 Layer On/Off" ), tools_xpm );

    ADD_MENUITEM( referencesMenu, ID_MENU3D_ECO2_ONOFF,
                  _( "Eco2 On/Off" ), options_text_xpm );
                  _( "Eco2 Layer On/Off" ), tools_xpm );
              }

    SetMenuBar( menuBar );
}
+6 −6
Original line number Diff line number Diff line
@@ -44,17 +44,17 @@ void InitKiCadAbout(wxAboutDialogInfo& info)

    /* Add developers */
    info.AddDeveloper(_T("Dick Hollenbeck <dick@softplc.com>"));
    info.AddDeveloper(_T("Jean-Pierre Charras <jean-pierre.charras@inpg.fr>"));
    info.AddDeveloper(_T("\nJean-Pierre Charras <jean-pierre.charras@inpg.fr>"));

    /* Add document writers */
    info.AddDocWriter(_T("Jean-Pierre Charras <jean-pierre.charras@inpg.fr>"));
    info.AddDocWriter(_T("Igor Plyatov <plyatov@gmail.com>"));
    info.AddDocWriter(_T("\nIgor Plyatov <plyatov@gmail.com>"));

    /* Add translators */
    info.AddTranslator(_T("Czech (CZ) Milan Horák <stranger@tiscali.cz>"));
    info.AddTranslator(_T("Dutch (NL) Jerry Jacobs <jerkejacobs@gmail.com>"));
    info.AddTranslator(_T("French (FR) Jean-Pierre Charras <jean-pierre.charras@inpg.fr>"));
    info.AddTranslator(_T("Polish (PL) Mateusz Skowroński <skowri@gmail.com>"));
    info.AddTranslator(_T("Russian (RU) Igor Plyatov <plyatov@gmail.com>"));
    info.AddTranslator(_T("\nDutch (NL) Jerry Jacobs <jerkejacobs@gmail.com>"));
    info.AddTranslator(_T("\nFrench (FR) Jean-Pierre Charras <jean-pierre.charras@inpg.fr>"));
    info.AddTranslator(_T("\nPolish (PL) Mateusz Skowroński <skowri@gmail.com>"));
    info.AddTranslator(_T("\nRussian (RU) Igor Plyatov <plyatov@gmail.com>"));

}
+6 −0
Original line number Diff line number Diff line
@@ -226,6 +226,8 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPi
    wxPoint         curpos, oldpos;
    int             hotkey = 0;

    ActiveScreen = screen;

    curpos = screen->m_MousePosition;
    oldpos = screen->m_Curseur;

@@ -355,6 +357,8 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
    wxPoint         curpos, oldpos;
    int             hotkey = 0;

    ActiveScreen = screen;

    curpos = screen->m_MousePosition;
    oldpos = screen->m_Curseur;

@@ -483,6 +487,8 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
    wxPoint         curpos, oldpos;
    int             hotkey = 0;

    ActiveScreen = screen;

    curpos = screen->m_MousePosition;
    oldpos = screen->m_Curseur;

+3 −3
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
    LibEDA_BaseStruct* DrawEntry = CurrentDrawItem;

    if( CurrentLibEntry == NULL )
    if( CurrentLibEntry == NULL )   // No component loaded !
        return;

    if( m_ID_current_state == 0 )
@@ -107,11 +107,11 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
        case ID_LIBEDIT_BODY_CIRCLE_BUTT:
        case ID_LIBEDIT_BODY_RECT_BUTT:
        case ID_LIBEDIT_BODY_TEXT_BUTT:
            if( CurrentDrawItem == NULL )
            if( CurrentDrawItem == NULL || CurrentDrawItem->m_Flags == 0 )
            {
                CurrentDrawItem = CreateGraphicItem( DC );
            }
            else
            else if( CurrentDrawItem )
            {
                if( CurrentDrawItem->m_Flags & IS_NEW )
                    GraphicItemBeginDraw( DC );
Loading