Commit 811b8936 authored by dickelbeck's avatar dickelbeck
Browse files

beautify

parent 2f3df174
Loading
Loading
Loading
Loading
+297 −269
Original line number Original line Diff line number Diff line
@@ -20,20 +20,21 @@ static D_PAD* s_CurrentSelectedPad; /* pointeur sur le pad selecte pour edition
static wxPoint Pad_OldPos;
static wxPoint Pad_OldPos;





/************************************************************/
/************************************************************/
static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
/************************************************************/
/************************************************************/

/* Routine de sortie du menu EDIT PADS.
/* Routine de sortie du menu EDIT PADS.
	Sortie simple si pad de pad en mouvement
  * Sortie simple si pad de pad en mouvement
	Remise en etat des conditions initiales avant move si move en cours
  * Remise en etat des conditions initiales avant move si move en cours
 */
 */
{
{
    D_PAD* pad = s_CurrentSelectedPad;
    D_PAD* pad = s_CurrentSelectedPad;


    Panel->ManageCurseur = NULL;
    Panel->ManageCurseur = NULL;
	Panel->ForceCloseManageCurseur = NULL;
    Panel->ForceCloseManageCurseur = NULL;.
	if (pad == NULL) return;
    if( pad == NULL )
        return;


    pad->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
    pad->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
    pad->m_Flags = 0;
    pad->m_Flags = 0;
@@ -70,18 +71,21 @@ DRAG_SEGM * pt_drag;
    BASE_SCREEN* screen = panel->GetScreen();
    BASE_SCREEN* screen = panel->GetScreen();
    D_PAD*       pad    = s_CurrentSelectedPad;
    D_PAD*       pad    = s_CurrentSelectedPad;


	if ( erase ) pad->Draw(panel, DC, wxPoint(0,0), GR_XOR);
    if( erase )
        pad->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR );
    pad->m_Pos = screen->m_Curseur;
    pad->m_Pos = screen->m_Curseur;
    pad->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR );
    pad->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR );


	if( ! g_Drag_Pistes_On ) return;
    if( !g_Drag_Pistes_On )
        return;


    /* Tracage des segments dragges */
    /* Tracage des segments dragges */
    pt_drag = g_DragSegmentList;
    pt_drag = g_DragSegmentList;
    for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
    for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
    {
    {
        Track = pt_drag->m_Segm;
        Track = pt_drag->m_Segm;
		if ( erase ) Track->Draw(panel, DC, GR_XOR);
        if( erase )
            Track->Draw( panel, DC, GR_XOR );
        if( pt_drag->m_Pad_Start )
        if( pt_drag->m_Pad_Start )
        {
        {
            Track->m_Start = pad->m_Pos;
            Track->m_Start = pad->m_Pos;
@@ -98,12 +102,14 @@ D_PAD * pad = s_CurrentSelectedPad;
/*************************************************************/
/*************************************************************/
void WinEDA_BasePcbFrame::Export_Pad_Settings( D_PAD* pt_pad )
void WinEDA_BasePcbFrame::Export_Pad_Settings( D_PAD* pt_pad )
/*************************************************************/
/*************************************************************/

/* Charge en liste des caracteristiques par defaut celles du pad selecte
/* Charge en liste des caracteristiques par defaut celles du pad selecte
 */
 */
{
{
    MODULE* Module;
    MODULE* Module;


	if ( pt_pad == NULL ) return;
    if( pt_pad == NULL )
        return;


    Module = (MODULE*) pt_pad->m_Parent;
    Module = (MODULE*) pt_pad->m_Parent;


@@ -127,13 +133,15 @@ MODULE * Module;
/***********************************************************************/
/***********************************************************************/
void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* pt_pad, wxDC* DC )
void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* pt_pad, wxDC* DC )
/***********************************************************************/
/***********************************************************************/

/* Met a jour les nouvelles valeurs de dimensions du pad pointe par pt_pad
/* Met a jour les nouvelles valeurs de dimensions du pad pointe par pt_pad
	- Source : valeurs choisies des caracteristiques generales
  * - Source : valeurs choisies des caracteristiques generales
	- les dimensions sont modifiees
  * - les dimensions sont modifiees
	- la position et les noms ne sont pas touches
  * - la position et les noms ne sont pas touches
 */
 */
{
{
	if ( DC ) pt_pad->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR);
    if( DC )
        pt_pad->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );


    pt_pad->m_PadShape     = g_Pad_Master.m_PadShape;
    pt_pad->m_PadShape     = g_Pad_Master.m_PadShape;
    pt_pad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer;
    pt_pad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer;
@@ -156,7 +164,6 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings(D_PAD * pt_pad, wxDC * DC)
    case PAD_CIRCLE:
    case PAD_CIRCLE:
        pt_pad->m_Size.y = pt_pad->m_Size.x;
        pt_pad->m_Size.y = pt_pad->m_Size.x;
        break;
        break;

    }
    }


    switch( g_Pad_Master.m_Attribut & 0x7F )
    switch( g_Pad_Master.m_Attribut & 0x7F )
@@ -170,7 +177,8 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings(D_PAD * pt_pad, wxDC * DC)


    pt_pad->ComputeRayon();
    pt_pad->ComputeRayon();


	if ( DC ) pt_pad->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR);
    if( DC )
        pt_pad->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
    ( (MODULE*) pt_pad->m_Parent )->m_LastEdit_Time = time( NULL );
    ( (MODULE*) pt_pad->m_Parent )->m_LastEdit_Time = time( NULL );
}
}


@@ -199,9 +207,11 @@ int rX, rY;
    {
    {
        while( ptliste )
        while( ptliste )
        {
        {
			if( ptliste->Pnext == NULL ) break;
            if( ptliste->Pnext == NULL )
                break;
            ptliste = (D_PAD*) ptliste->Pnext;
            ptliste = (D_PAD*) ptliste->Pnext;
        }
        }

        Pad->Pback     = (EDA_BaseStruct*) ptliste;
        Pad->Pback     = (EDA_BaseStruct*) ptliste;
        ptliste->Pnext = (EDA_BaseStruct*) Pad;
        ptliste->Pnext = (EDA_BaseStruct*) Pad;
    }
    }
@@ -211,19 +221,25 @@ int rX, rY;
    Pad->m_Netname.Empty();
    Pad->m_Netname.Empty();


    Pad->m_Pos = GetScreen()->m_Curseur;
    Pad->m_Pos = GetScreen()->m_Curseur;

    rX = Pad->m_Pos.x - Module->m_Pos.x;
    rX = Pad->m_Pos.x - Module->m_Pos.x;
    rY = Pad->m_Pos.y - Module->m_Pos.y;
    rY = Pad->m_Pos.y - Module->m_Pos.y;

    RotatePoint( &rX, &rY, -Module->m_Orient );
    RotatePoint( &rX, &rY, -Module->m_Orient );
	Pad->m_Pos0.x = rX; Pad->m_Pos0.y = rY;

    Pad->m_Pos0.x = rX;
    Pad->m_Pos0.y = rY;


    /* Increment automatique de la reference courante Current_PadName */
    /* Increment automatique de la reference courante Current_PadName */
    long num = 0; int ponder = 1;
    long num = 0; int ponder = 1;
	while ( g_Current_PadName.Last() >= '0' && g_Current_PadName.Last() <= '9')
    while( g_Current_PadName.Len() && g_Current_PadName.Last() >= '0' &&
           g_Current_PadName.Last() <= '9' )
    {
    {
        num += (g_Current_PadName.Last() - '0') * ponder;
        num += (g_Current_PadName.Last() - '0') * ponder;
        g_Current_PadName.RemoveLast();
        g_Current_PadName.RemoveLast();
        ponder *= 10;
        ponder *= 10;
    }
    }

    num++;
    num++;
    g_Current_PadName << num;
    g_Current_PadName << num;
    Pad->SetPadName( g_Current_PadName );
    Pad->SetPadName( g_Current_PadName );
@@ -232,9 +248,9 @@ int rX, rY;
    Module->Set_Rectangle_Encadrement();
    Module->Set_Rectangle_Encadrement();
    Pad->Display_Infos( this );
    Pad->Display_Infos( this );
    Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
    Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );

}
}



/*********************************************************/
/*********************************************************/
void WinEDA_BasePcbFrame::DeletePad( D_PAD* Pad, wxDC* DC )
void WinEDA_BasePcbFrame::DeletePad( D_PAD* Pad, wxDC* DC )
/*********************************************************/
/*********************************************************/
@@ -243,28 +259,33 @@ void WinEDA_BasePcbFrame::DeletePad(D_PAD* Pad, wxDC * DC)
    MODULE*  Module;
    MODULE*  Module;
    wxString line;
    wxString line;


	if ( Pad == NULL ) return;
    if( Pad == NULL )
        return;


    Module = (MODULE*) Pad->m_Parent;
    Module = (MODULE*) Pad->m_Parent;
    Module->m_LastEdit_Time = time( NULL );
    Module->m_LastEdit_Time = time( NULL );


    line.Printf( _( "Delete Pad (module %s %s) " ),
    line.Printf( _( "Delete Pad (module %s %s) " ),
        Module->m_Reference->m_Text.GetData(), Module->m_Value->m_Text.GetData() );
        Module->m_Reference->m_Text.GetData(), Module->m_Value->m_Text.GetData() );
	if( ! IsOK(this, line) ) return ;
    if( !IsOK( this, line ) )
        return;


    m_Pcb->m_Status_Pcb = 0;
    m_Pcb->m_Status_Pcb = 0;


	if ( DC ) Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR);
    if( DC )
        Pad->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );


    Pad->DeleteStructure();
    Pad->DeleteStructure();


    /* Redessin du module */
    /* Redessin du module */
	if ( DC ) Module->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR);
    if( DC )
        Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
    Module->Set_Rectangle_Encadrement();
    Module->Set_Rectangle_Encadrement();
    GetScreen()->SetModify();
    GetScreen()->SetModify();
    return;
    return;
}
}



/*************************************************************/
/*************************************************************/
void WinEDA_BasePcbFrame::StartMovePad( D_PAD* Pad, wxDC* DC )
void WinEDA_BasePcbFrame::StartMovePad( D_PAD* Pad, wxDC* DC )
/*************************************************************/
/*************************************************************/
@@ -272,7 +293,8 @@ void WinEDA_BasePcbFrame::StartMovePad(D_PAD * Pad, wxDC * DC)
{
{
    MODULE* Module;
    MODULE* Module;


	if(Pad == NULL ) return;
    if( Pad == NULL )
        return;


    Module = (MODULE*) Pad->m_Parent;
    Module = (MODULE*) Pad->m_Parent;


@@ -290,8 +312,8 @@ MODULE * Module;
    /* Build the list of track segments to drag if the command is a drag pad*/
    /* Build the list of track segments to drag if the command is a drag pad*/
    if( g_Drag_Pistes_On )
    if( g_Drag_Pistes_On )
        Build_1_Pad_SegmentsToDrag( DrawPanel, DC, Pad );
        Build_1_Pad_SegmentsToDrag( DrawPanel, DC, Pad );
	else EraseDragListe();
    else

        EraseDragListe();
}
}




@@ -305,7 +327,8 @@ TRACK * Track;
    DRAG_SEGM* pt_drag;
    DRAG_SEGM* pt_drag;
    MODULE*    Module;
    MODULE*    Module;


	if(Pad == NULL ) return;
    if( Pad == NULL )
        return;


    Module = (MODULE*) Pad->m_Parent;
    Module = (MODULE*) Pad->m_Parent;


@@ -320,7 +343,9 @@ MODULE * Module;
    dX = Pad->m_Pos.x - Pad_OldPos.x;
    dX = Pad->m_Pos.x - Pad_OldPos.x;
    dY = Pad->m_Pos.y - Pad_OldPos.y;
    dY = Pad->m_Pos.y - Pad_OldPos.y;
    RotatePoint( &dX, &dY, -Module->m_Orient );
    RotatePoint( &dX, &dY, -Module->m_Orient );
	Pad->m_Pos0.x += dX; s_CurrentSelectedPad->m_Pos0.y += dY;

    Pad->m_Pos0.x += dX;
    s_CurrentSelectedPad->m_Pos0.y += dY;


    Pad->m_Flags = 0;
    Pad->m_Flags = 0;


@@ -337,6 +362,7 @@ MODULE * Module;
        Track->SetState( EDIT, OFF );
        Track->SetState( EDIT, OFF );
        Track->Draw( DrawPanel, DC, GR_OR );
        Track->Draw( DrawPanel, DC, GR_OR );
    }
    }

    EraseDragListe();
    EraseDragListe();


    GetScreen()->SetModify();
    GetScreen()->SetModify();
@@ -345,15 +371,19 @@ MODULE * Module;
    m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK);
    m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK);
}
}



/**********************************************************/
/**********************************************************/
void WinEDA_BasePcbFrame::RotatePad( D_PAD* Pad, wxDC* DC )
void WinEDA_BasePcbFrame::RotatePad( D_PAD* Pad, wxDC* DC )
/**********************************************************/
/**********************************************************/

/* Tourne de 90 degres le pad selectionne :
/* Tourne de 90 degres le pad selectionne :
	c.a.d intervertit dim X et Y et offsets
  * c.a.d intervertit dim X et Y et offsets
 */
 */
{
{
    MODULE* Module;
    MODULE* Module;
	if ( Pad == NULL ) return;

    if( Pad == NULL )
        return;


    Module = (MODULE*) Pad->m_Parent;
    Module = (MODULE*) Pad->m_Parent;
    Module->m_LastEdit_Time = time( NULL );
    Module->m_LastEdit_Time = time( NULL );
@@ -369,12 +399,10 @@ MODULE * Module;


    EXCHG( Pad->m_DeltaSize.x, Pad->m_DeltaSize.y );
    EXCHG( Pad->m_DeltaSize.x, Pad->m_DeltaSize.y );
    Pad->m_DeltaSize.x = -Pad->m_DeltaSize.x; /* ceci est la variation
    Pad->m_DeltaSize.x = -Pad->m_DeltaSize.x; /* ceci est la variation
											de la dim Y sur l'axe X */
                                                * de la dim Y sur l'axe X */


    Module->Set_Rectangle_Encadrement();
    Module->Set_Rectangle_Encadrement();


    Pad->Display_Infos( this );
    Pad->Display_Infos( this );
    Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
    Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
}
}