Commit 3c7df7b7 authored by stambaughw's avatar stambaughw
Browse files

Complete comment translation of gerbview source.

parent 8b3ffe74
Loading
Loading
Loading
Loading
+92 −97
Original line number Diff line number Diff line
/*****************************************************************/
/* Operations sur Blocks : deplacement, rotation, effacement ... */
/*****************************************************************/
/**********************************************************/
/* Block operations: displacement, rotation, deletion ... */
/**********************************************************/


#include "fctsys.h"
@@ -16,21 +16,18 @@

#define BLOCK_COLOR BROWN

/* Routines Locales */

static void     DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void   DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
                                       wxDC*             DC,
                                       bool              erase );

static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm );

/* Variables locales :*/

/*************************************************/
int WinEDA_GerberFrame::ReturnBlockCommand( int key )
/*************************************************/

/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
 *  the key (ALT, SHIFT ALT ..)
 */
int WinEDA_GerberFrame::ReturnBlockCommand( int key )
{
    int cmd = 0;

@@ -67,17 +64,16 @@ int WinEDA_GerberFrame::ReturnBlockCommand( int key )
}


/*****************************************************/
/* Routine to handle the BLOCK PLACE command */
void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
/*****************************************************/
/* Routine to handle the BLOCK PLACE commande */
{
    bool err = FALSE;

    if( DrawPanel->ManageCurseur == NULL )
    {
        err = TRUE;
        DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) );
        DisplayError( this,
                      wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) );
    }
    GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;

@@ -135,16 +131,13 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
}


/**********************************************/
int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
/**********************************************/

/* Routine de gestion de la commande BLOCK END
 *  returne :
 *  0 si aucun compos ant selectionne
 *  1 sinon
 *  -1 si commande termine et composants trouvs (block delete, block save)
/* Routine management command END BLOCK
 * Returns:
 * 0 if no and selects compounds
 * 1 otherwise
 * -1 If order is completed and components found (block delete, block save)
 */
int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
{
    int  endcommande  = TRUE;
    bool zoom_command = FALSE;
@@ -157,7 +150,8 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
            DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
            break;

        case BLOCK_DRAG:            /* Drag (not used, for future enhancements)*/
        case BLOCK_DRAG:            /* Drag (not used, for future
                                     * enhancements) */
        case BLOCK_MOVE:            /* Move */
        case BLOCK_COPY:            /* Copy */
        case BLOCK_PRESELECT_MOVE:  /* Move with preselection list */
@@ -220,49 +214,57 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
}


/**************************************************************************/
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/**************************************************************************/

/* Retrace le contour du block de repositionnement des structures a dplacer
/* Traces the outline of the block structures of a repositioning move
 */
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
                                     wxDC*             DC,
                                     bool              erase )
{
    int          Color;
    BASE_SCREEN* screen = panel->GetScreen();

    Color = YELLOW;

    /* Effacement ancien cadre */
    if( erase )
    {
        screen->m_BlockLocate.Draw( panel, DC, wxPoint(0,0),g_XorMode, Color );
        if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
        screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode,
                                    Color );
        if( screen->m_BlockLocate.m_MoveVector.x
            || screen->m_BlockLocate.m_MoveVector.y )
        {
            screen->m_BlockLocate.Draw( panel, DC, screen->m_BlockLocate.m_MoveVector,g_XorMode, Color );
            screen->m_BlockLocate.Draw( panel,
                                        DC,
                                        screen->m_BlockLocate.m_MoveVector,
                                        g_XorMode,
                                        Color );
        }
    }

    if( panel->GetScreen()->m_BlockLocate.m_State != STATE_BLOCK_STOP )
    {
        screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->m_BlockLocate.GetRight();
        screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->m_BlockLocate.GetBottom();
        screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x -
                                               screen->m_BlockLocate.GetRight();
        screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y -
                                               screen->m_BlockLocate.GetBottom();
    }

    screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, Color );
    if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
    if( screen->m_BlockLocate.m_MoveVector.x
        || screen->m_BlockLocate.m_MoveVector.y )
    {
        screen->m_BlockLocate.Draw( panel, DC, screen->m_BlockLocate.m_MoveVector,g_XorMode, Color );
        screen->m_BlockLocate.Draw( panel,
                                    DC,
                                    screen->m_BlockLocate.m_MoveVector,
                                    g_XorMode,
                                    Color );
    }
}


/************************************************/
void WinEDA_GerberFrame::Block_Delete( wxDC* DC )
/************************************************/

/*
 *  routine d'effacement du block deja selectionne
 * Erase the selected block.
 */
void WinEDA_GerberFrame::Block_Delete( wxDC* DC )
{
    if( !IsOK( this, _( "Ok to delete block ?" ) ) )
        return;
@@ -271,43 +273,38 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC )
    GetScreen()->m_BlockLocate.Normalize();
    GetScreen()->SetCurItem( NULL );

    /* Effacement des Pistes */
    TRACK* pt_segm, * NextS;
    for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS )
    {
        NextS = pt_segm->Next();
        if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) )
        {
            /* la piste est ici bonne a etre efface */
            /* the track here is good to be cleared */
            pt_segm->Draw( DrawPanel, DC, GR_XOR );
            pt_segm->DeleteStructure();
        }
    }

    /* Effacement des Zones */
    /* Erasing areas. */
    for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
    {
        NextS = pt_segm->Next();
        if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) )
        {
            /* la piste est ici bonne a etre efface */
            /* The track here is good to be cleared. */
            pt_segm->Draw( DrawPanel, DC, GR_XOR );
            pt_segm->DeleteStructure();
        }
    }

    /* Rafraichissement de l'ecran : */
    RedrawActiveWindow( DC, TRUE );
}


/************************************************/
void WinEDA_GerberFrame::Block_Move( wxDC* DC )
/************************************************/

/*
 *  Function to move items in the current selected block
 */
void WinEDA_GerberFrame::Block_Move( wxDC* DC )
{
    wxPoint delta;
    wxPoint oldpos;
@@ -320,7 +317,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
    GetScreen()->SetModify();
    GetScreen()->m_BlockLocate.Normalize();

    /* calcul du vecteur de deplacement pour les deplacements suivants */
    /* Calculate displacement vectors. */
    delta = GetScreen()->m_BlockLocate.m_MoveVector;

    /* Move the Track segments in block */
@@ -333,8 +330,9 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
            track->Draw( DrawPanel, DC, GR_XOR );   // erase the display
            track->m_Start += delta;
            track->m_End   += delta;
            // the two parameters are used in gerbview to store centre coordinates for arcs.
            // move this centre

            // the two parameters are used in gerbview to store center
            // coordinates for arcs.  Move this center.
            track->m_Param += delta.x;
            track->SetSubNet( track->GetSubNet() + delta.y );

@@ -352,11 +350,13 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
            zsegment->Draw( DrawPanel, DC, GR_XOR );   // erase the display
            zsegment->m_Start += delta;
            zsegment->m_End   += delta;
            // the two parameters are used in gerbview to store centre coordinates for arcs.
            // move this centre

            // the two parameters are used in gerbview to store center
            // coordinates for arcs. Move this center
            zsegment->m_Param += delta.x;
            zsegment->SetSubNet( zsegment->GetSubNet() + delta.y );
            zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone zegment
            zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone
                                                    // segment
        }
        zsegment = zsegment->Next();
    }
@@ -365,13 +365,10 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
}


/************************************************/
void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
/************************************************/

/*
 *  Function to mirror items in the current selected block
 */
void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
{
    int     xoffset = 0;
    wxPoint oldpos;
@@ -385,7 +382,8 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
    GetScreen()->m_BlockLocate.Normalize();

    /* Calculate offset to mirror track points from block edges */
    xoffset = GetScreen()->m_BlockLocate.m_Pos.x + GetScreen()->m_BlockLocate.m_Pos.x
    xoffset = GetScreen()->m_BlockLocate.m_Pos.x
              + GetScreen()->m_BlockLocate.m_Pos.x
              + GetScreen()->m_BlockLocate.m_Size.x;

    /* Move the Track segments in block */
@@ -398,15 +396,17 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
            track->m_Start.x = xoffset - track->m_Start.x;
            track->m_End.x   = xoffset - track->m_End.x;

            // the two parameters are used in gerbview to store centre coordinates for arcs.
            // move this centre
            // the two parameters are used in gerbview to store center
            // coordinates for arcs.  Move this center
            track->m_Param = xoffset - track->m_Param;
            track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track
        }
    }

    /* Move the Zone segments in block */
    for( SEGZONE* zsegment = m_Pcb->m_Zone; zsegment; zsegment = zsegment->Next() )
    for( SEGZONE* zsegment = m_Pcb->m_Zone;
        zsegment;
        zsegment = zsegment->Next() )
    {
        if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
        {
@@ -414,10 +414,11 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
            zsegment->m_Start.x = xoffset - zsegment->m_Start.x;
            zsegment->m_End.x   = xoffset - zsegment->m_End.x;

            // the two parameters are used in gerbview to store centre coordinates for arcs.
            // move this centre
            // the two parameters are used in gerbview to store center
            // coordinates for arcs.  Move this center
            zsegment->m_Param = xoffset - zsegment->m_Param;
            zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone zegment
            zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone
                                                    // segment
        }
    }

@@ -425,13 +426,10 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
}


/**************************************************/
void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
/**************************************************/

/*
 *  Function to duplicate items in the current selected block
 */
void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
{
    wxPoint delta;
    wxPoint oldpos;
@@ -444,8 +442,6 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
    GetScreen()->SetModify();
    GetScreen()->m_BlockLocate.Normalize();


    /* calcul du vecteur de deplacement pour les deplacements suivants */
    delta = GetScreen()->m_BlockLocate.m_MoveVector;

    /* Copy selected track segments and move the new track its new location */
@@ -464,7 +460,8 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
            new_track->m_Start += delta;
            new_track->m_End   += delta;

            new_track->Draw( DrawPanel, DC, GR_OR ); // draw the new created segment
            new_track->Draw( DrawPanel, DC, GR_OR ); // draw the new created
                                                     // segment
        }
        track = next_track;
    }
@@ -484,21 +481,19 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
            new_zsegment->m_Start += delta;
            new_zsegment->m_End   += delta;

            new_zsegment->Draw( DrawPanel, DC, GR_OR ); // draw the new created segment
            new_zsegment->Draw( DrawPanel, DC, GR_OR ); // draw the new created
                                                        // segment
        }
        zsegment = next_zsegment;
    }
}


/**************************************************************************/
static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm )
/**************************************************************************/

/* Teste si la structure PtStruct est inscrite dans le block selectionne
 *  Retourne PtSegm si oui
 *          NULL si non
/* Test if the structure PtStruct is listed in the block selects
 * Returns whether PtSegm
 * NULL if not
 */
static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm )
{
    if( blocklocate.Inside( PtSegm->m_Start.x, PtSegm->m_Start.y ) )
        return PtSegm;
+8 −28
Original line number Diff line number Diff line
/********************************************************/
/* Routines generales de gestion des commandes usuelles */
/********************************************************/

/* fichier controle.cpp */

/*
 *  Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ...
 */
/****************/
/* controle.cpp */
/****************/

#include "fctsys.h"
#include "common.h"
@@ -17,25 +11,13 @@
#include "protos.h"


/**********************************************************************/
BOARD_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay()
/**********************************************************************/
{
    return Locate( CURSEUR_OFF_GRILLE );
}


/****************************************************************/
void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/****************************************************************/

/* traitement des touches de fonctions utilisees ds tous les menus
 *  Zoom
 *  Redessin d'ecran
 *  Cht Unites
 *  Cht couches
 *  Remise a 0 de l'origine des coordonnees relatives
 */
{
    wxRealPoint  delta;
    wxPoint curpos, oldpos;
@@ -68,25 +50,25 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )

    switch( g_KeyPressed )
    {
    case WXK_NUMPAD8:       /* Deplacement curseur vers le haut */
    case WXK_NUMPAD8:
    case WXK_UP:
        Mouse.y -= wxRound(delta.y);
        DrawPanel->MouseTo( Mouse );
        break;

    case WXK_NUMPAD2:       /* Deplacement curseur vers le bas */
    case WXK_NUMPAD2:
    case WXK_DOWN:
        Mouse.y += wxRound(delta.y);
        DrawPanel->MouseTo( Mouse );
        break;

    case WXK_NUMPAD4:       /* Deplacement curseur vers la gauche */
    case WXK_NUMPAD4:
    case WXK_LEFT:
        Mouse.x -= wxRound(delta.x);
        DrawPanel->MouseTo( Mouse );
        break;

    case WXK_NUMPAD6:      /* Deplacement curseur vers la droite */
    case WXK_NUMPAD6:
    case WXK_RIGHT:
        Mouse.x += wxRound(delta.x);
        DrawPanel->MouseTo( Mouse );
@@ -97,10 +79,8 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
        break;
    }

    /* Recalcul de la position du curseur schema */
    GetScreen()->m_Curseur = curpos;

    /* Placement sur la grille generale */
    PutOnGrid( &GetScreen()->m_Curseur );

    if( oldpos != GetScreen()->m_Curseur )
@@ -129,5 +109,5 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
    }

    SetToolbars();
    UpdateStatusBar();    /* Affichage des coord curseur */
    UpdateStatusBar();
}
Loading