Commit 3c7df7b7 authored by stambaughw's avatar stambaughw

Complete comment translation of gerbview source.

parent 8b3ffe74
/*****************************************************************/ /**********************************************************/
/* Operations sur Blocks : deplacement, rotation, effacement ... */ /* Block operations: displacement, rotation, deletion ... */
/*****************************************************************/ /**********************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -16,21 +16,18 @@ ...@@ -16,21 +16,18 @@
#define BLOCK_COLOR BROWN #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 ); 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 /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the key (ALT, SHIFT ALT ..) * the key (ALT, SHIFT ALT ..)
*/ */
int WinEDA_GerberFrame::ReturnBlockCommand( int key )
{ {
int cmd = 0; int cmd = 0;
...@@ -67,23 +64,22 @@ int WinEDA_GerberFrame::ReturnBlockCommand( int key ) ...@@ -67,23 +64,22 @@ int WinEDA_GerberFrame::ReturnBlockCommand( int key )
} }
/*****************************************************/ /* Routine to handle the BLOCK PLACE command */
void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
/*****************************************************/
/* Routine to handle the BLOCK PLACE commande */
{ {
bool err = FALSE; bool err = FALSE;
if( DrawPanel->ManageCurseur == NULL ) if( DrawPanel->ManageCurseur == NULL )
{ {
err = TRUE; 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; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
switch( GetScreen()->m_BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
err = TRUE; err = TRUE;
break; break;
...@@ -121,7 +117,7 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) ...@@ -121,7 +117,7 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
GetScreen()->SetModify(); GetScreen()->SetModify();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->m_BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
...@@ -135,16 +131,13 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) ...@@ -135,16 +131,13 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
} }
/**********************************************/ /* Routine management command END BLOCK
int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) * Returns:
/**********************************************/ * 0 if no and selects compounds
* 1 otherwise
/* Routine de gestion de la commande BLOCK END * -1 If order is completed and components found (block delete, block save)
* returne :
* 0 si aucun compos ant selectionne
* 1 sinon
* -1 si commande termine et composants trouvs (block delete, block save)
*/ */
int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
{ {
int endcommande = TRUE; int endcommande = TRUE;
bool zoom_command = FALSE; bool zoom_command = FALSE;
...@@ -153,14 +146,15 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -153,14 +146,15 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
switch( GetScreen()->m_BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
break; 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_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list */
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
endcommande = FALSE; endcommande = FALSE;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
...@@ -220,49 +214,57 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -220,49 +214,57 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
} }
/**************************************************************************/ /* Traces the outline of the block structures of a repositioning move
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/**************************************************************************/
/* Retrace le contour du block de repositionnement des structures a dplacer
*/ */
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase )
{ {
int Color; int Color;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
Color = YELLOW; Color = YELLOW;
/* Effacement ancien cadre */
if( erase ) if( erase )
{ {
screen->m_BlockLocate.Draw( panel, DC, wxPoint(0,0),g_XorMode, Color ); screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode,
if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y ) 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 ) 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.x = screen->m_Curseur.x -
screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->m_BlockLocate.GetBottom(); 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 ); 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 ?" ) ) ) if( !IsOK( this, _( "Ok to delete block ?" ) ) )
return; return;
...@@ -271,43 +273,38 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC ) ...@@ -271,43 +273,38 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC )
GetScreen()->m_BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
/* Effacement des Pistes */
TRACK* pt_segm, * NextS; TRACK* pt_segm, * NextS;
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS ) for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS )
{ {
NextS = pt_segm->Next(); NextS = pt_segm->Next();
if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) ) 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->Draw( DrawPanel, DC, GR_XOR );
pt_segm->DeleteStructure(); pt_segm->DeleteStructure();
} }
} }
/* Effacement des Zones */ /* Erasing areas. */
for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS ) for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
{ {
NextS = pt_segm->Next(); NextS = pt_segm->Next();
if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) ) 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->Draw( DrawPanel, DC, GR_XOR );
pt_segm->DeleteStructure(); pt_segm->DeleteStructure();
} }
} }
/* Rafraichissement de l'ecran : */
RedrawActiveWindow( DC, TRUE ); RedrawActiveWindow( DC, TRUE );
} }
/************************************************/
void WinEDA_GerberFrame::Block_Move( wxDC* DC )
/************************************************/
/* /*
* Function to move items in the current selected block * Function to move items in the current selected block
*/ */
void WinEDA_GerberFrame::Block_Move( wxDC* DC )
{ {
wxPoint delta; wxPoint delta;
wxPoint oldpos; wxPoint oldpos;
...@@ -320,7 +317,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) ...@@ -320,7 +317,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* calcul du vecteur de deplacement pour les deplacements suivants */ /* Calculate displacement vectors. */
delta = GetScreen()->m_BlockLocate.m_MoveVector; delta = GetScreen()->m_BlockLocate.m_MoveVector;
/* Move the Track segments in block */ /* Move the Track segments in block */
...@@ -333,9 +330,10 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) ...@@ -333,9 +330,10 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
track->Draw( DrawPanel, DC, GR_XOR ); // erase the display track->Draw( DrawPanel, DC, GR_XOR ); // erase the display
track->m_Start += delta; track->m_Start += delta;
track->m_End += 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
track->m_Param += delta.x; // coordinates for arcs. Move this center.
track->m_Param += delta.x;
track->SetSubNet( track->GetSubNet() + delta.y ); track->SetSubNet( track->GetSubNet() + delta.y );
track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track
...@@ -344,7 +342,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) ...@@ -344,7 +342,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
} }
/* Move the Zone segments in block */ /* Move the Zone segments in block */
SEGZONE * zsegment= m_Pcb->m_Zone; SEGZONE* zsegment = m_Pcb->m_Zone;
while( zsegment ) while( zsegment )
{ {
if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
...@@ -352,11 +350,13 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) ...@@ -352,11 +350,13 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display
zsegment->m_Start += delta; zsegment->m_Start += delta;
zsegment->m_End += 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
zsegment->m_Param += delta.x; // coordinates for arcs. Move this center
zsegment->m_Param += delta.x;
zsegment->SetSubNet( zsegment->GetSubNet() + delta.y ); 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(); zsegment = zsegment->Next();
} }
...@@ -365,13 +365,10 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) ...@@ -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 * Function to mirror items in the current selected block
*/ */
void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
{ {
int xoffset = 0; int xoffset = 0;
wxPoint oldpos; wxPoint oldpos;
...@@ -385,11 +382,12 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC ) ...@@ -385,11 +382,12 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
GetScreen()->m_BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* Calculate offset to mirror track points from block edges */ /* 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; + GetScreen()->m_BlockLocate.m_Size.x;
/* Move the Track segments in block */ /* Move the Track segments in block */
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{ {
if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) )
{ {
...@@ -398,15 +396,17 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC ) ...@@ -398,15 +396,17 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
track->m_Start.x = xoffset - track->m_Start.x; track->m_Start.x = xoffset - track->m_Start.x;
track->m_End.x = xoffset - track->m_End.x; track->m_End.x = xoffset - track->m_End.x;
// the two parameters are used in gerbview to store centre coordinates for arcs. // the two parameters are used in gerbview to store center
// move this centre // coordinates for arcs. Move this center
track->m_Param = xoffset - track->m_Param; track->m_Param = xoffset - track->m_Param;
track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track
} }
} }
/* Move the Zone segments in block */ /* 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 ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
{ {
...@@ -414,10 +414,11 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC ) ...@@ -414,10 +414,11 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
zsegment->m_Start.x = xoffset - zsegment->m_Start.x; zsegment->m_Start.x = xoffset - zsegment->m_Start.x;
zsegment->m_End.x = xoffset - zsegment->m_End.x; zsegment->m_End.x = xoffset - zsegment->m_End.x;
// the two parameters are used in gerbview to store centre coordinates for arcs. // the two parameters are used in gerbview to store center
// move this centre // coordinates for arcs. Move this center
zsegment->m_Param = xoffset - zsegment->m_Param; 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,15 +426,12 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC ) ...@@ -425,15 +426,12 @@ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
} }
/**************************************************/
void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
/**************************************************/
/* /*
* Function to duplicate items in the current selected block * Function to duplicate items in the current selected block
*/ */
void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
{ {
wxPoint delta; wxPoint delta;
wxPoint oldpos; wxPoint oldpos;
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
...@@ -444,8 +442,6 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) ...@@ -444,8 +442,6 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* calcul du vecteur de deplacement pour les deplacements suivants */
delta = GetScreen()->m_BlockLocate.m_MoveVector; delta = GetScreen()->m_BlockLocate.m_MoveVector;
/* Copy selected track segments and move the new track its new location */ /* Copy selected track segments and move the new track its new location */
...@@ -464,41 +460,40 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) ...@@ -464,41 +460,40 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
new_track->m_Start += delta; new_track->m_Start += delta;
new_track->m_End += 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; track = next_track;
} }
/* Copy the Zone segments and move the new segment to its new location */ /* Copy the Zone segments and move the new segment to its new location */
SEGZONE * zsegment= m_Pcb->m_Zone; SEGZONE* zsegment = m_Pcb->m_Zone;
while( zsegment ) while( zsegment )
{ {
SEGZONE * next_zsegment = zsegment->Next(); SEGZONE* next_zsegment = zsegment->Next();
if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
{ {
/* this zone segment must be duplicated */ /* this zone segment must be duplicated */
SEGZONE * new_zsegment = (SEGZONE*) zsegment->Copy(); SEGZONE* new_zsegment = (SEGZONE*) zsegment->Copy();
m_Pcb->Add( new_zsegment ); m_Pcb->Add( new_zsegment );
new_zsegment->m_Start += delta; new_zsegment->m_Start += delta;
new_zsegment->m_End += 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; zsegment = next_zsegment;
} }
} }
/**************************************************************************/ /* Test if the structure PtStruct is listed in the block selects
static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm ) * Returns whether PtSegm
/**************************************************************************/ * NULL if not
/* Teste si la structure PtStruct est inscrite dans le block selectionne
* Retourne PtSegm si oui
* NULL si non
*/ */
static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm )
{ {
if( blocklocate.Inside( PtSegm->m_Start.x, PtSegm->m_Start.y ) ) if( blocklocate.Inside( PtSegm->m_Start.x, PtSegm->m_Start.y ) )
return PtSegm; return PtSegm;
......
/********************************************************/ /****************/
/* Routines generales de gestion des commandes usuelles */ /* controle.cpp */
/********************************************************/ /****************/
/* fichier controle.cpp */
/*
* Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ...
*/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -17,25 +11,13 @@ ...@@ -17,25 +11,13 @@
#include "protos.h" #include "protos.h"
/**********************************************************************/
BOARD_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay() BOARD_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay()
/**********************************************************************/
{ {
return Locate( CURSEUR_OFF_GRILLE ); return Locate( CURSEUR_OFF_GRILLE );
} }
/****************************************************************/
void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) 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; wxRealPoint delta;
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
...@@ -68,25 +50,25 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -68,25 +50,25 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
switch( g_KeyPressed ) switch( g_KeyPressed )
{ {
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_NUMPAD8:
case WXK_UP: case WXK_UP:
Mouse.y -= wxRound(delta.y); Mouse.y -= wxRound(delta.y);
DrawPanel->MouseTo( Mouse ); DrawPanel->MouseTo( Mouse );
break; break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_NUMPAD2:
case WXK_DOWN: case WXK_DOWN:
Mouse.y += wxRound(delta.y); Mouse.y += wxRound(delta.y);
DrawPanel->MouseTo( Mouse ); DrawPanel->MouseTo( Mouse );
break; break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_NUMPAD4:
case WXK_LEFT: case WXK_LEFT:
Mouse.x -= wxRound(delta.x); Mouse.x -= wxRound(delta.x);
DrawPanel->MouseTo( Mouse ); DrawPanel->MouseTo( Mouse );
break; break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_NUMPAD6:
case WXK_RIGHT: case WXK_RIGHT:
Mouse.x += wxRound(delta.x); Mouse.x += wxRound(delta.x);
DrawPanel->MouseTo( Mouse ); DrawPanel->MouseTo( Mouse );
...@@ -97,10 +79,8 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -97,10 +79,8 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
break; break;
} }
/* Recalcul de la position du curseur schema */
GetScreen()->m_Curseur = curpos; GetScreen()->m_Curseur = curpos;
/* Placement sur la grille generale */
PutOnGrid( &GetScreen()->m_Curseur ); PutOnGrid( &GetScreen()->m_Curseur );
if( oldpos != GetScreen()->m_Curseur ) if( oldpos != GetScreen()->m_Curseur )
...@@ -129,5 +109,5 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -129,5 +109,5 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
} }
SetToolbars(); SetToolbars();
UpdateStatusBar(); /* Affichage des coord curseur */ UpdateStatusBar();
} }
/********************************************************/ /***************************/
/**** Routine de lecture et visu d'un fichier GERBER ****/ /**** Read GERBER files ****/
/********************************************************/ /***************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -14,61 +14,57 @@ ...@@ -14,61 +14,57 @@
#define DEFAULT_SIZE 100 #define DEFAULT_SIZE 100
/* Format Gerber : NOTES :
Fonctions preparatoires: /* Format Gerber: NOTES:
Gn = * Features history:
G01 interpolation lineaire ( trace de droites ) * Gn =
G02,G20,G21 Interpolation circulaire , sens trigo < 0 * G01 linear interpolation (right trace)
G03,G30,G31 Interpolation circulaire , sens trigo > 0 * G02, G20, G21 Circular interpolation, meaning trig < 0
G04 commentaire * G03, G30, G31 Circular interpolation, meaning trig > 0
G06 Interpolation parabolique * G04 review
G07 Interpolation cubique * G06 parabolic interpolation
G10 interpolation lineaire ( echelle 10x ) * G07 Cubic Interpolation
G11 interpolation lineaire ( echelle 0.1x ) * G10 linear interpolation (scale x10)
G12 interpolation lineaire ( echelle 0.01x ) * G11 linear interpolation (0.1x range)
G52 plot symbole reference par Dnn code * G12 linear interpolation (0.01x scale)
G53 plot symbole reference par Dnn ; symbole tourne de -90 degres * G52 plot symbol reference code by Dnn
G54 Selection d'outil * G53 plot symbol reference by Dnn; symbol rotates from -90 degrees
G55 Mode exposition photo * G54 Selection Tool
G56 plot symbole reference par Dnn A code * G55 Fashion photo exhibition
G57 affiche le symbole reference sur la console * G56 plot symbol reference code for DNN
G58 plot et affiche le symbole reference sur la console * G57 displays the symbol link to the console
G60 interpolation lineaire ( echelle 100x ) * G58 plot displays the symbol and link to the console
G70 Unites = Inches * G60 linear interpolation (scale x100)
G71 Unites = Millimetres * G70 Units = Inches
G74 supprime interpolation circulaire sur 360 degre, revient a G01 * G71 Units = Millimeters
G75 Active interpolation circulaire sur 360 degre * G74 circular interpolation removes 360 degree, has returned G01
G90 Mode Coordonnees absolues * G75 circular interpolation Active 360 degree
G91 Mode Coordonnees Relatives * G90 mode absolute coordinates
* G91 Fashion Related Contacts
Coordonnees X,Y *
X,Y sont suivies de + ou - et de m+n chiffres (non separes) * Coordinates X, Y
m = partie entiere * X and Y are followed by + or - and m + n digits (not separated)
n = partie apres la virgule * m = integer part
formats classiques : m = 2, n = 3 (format 2.3) * n = part after the comma
m = 3, n = 4 (format 3.4) * conventional formats: m = 2, n = 3 (size 2.3)
ex: * m = 3, n = 4 (size 3.4)
G__ X00345Y-06123 D__* * eg
* G__ X00345Y-06123 * D__
Outils et D_CODES *
numero d'outil ( identification des formes ) * Tools and D_CODES
1 a 99 (classique) * tool number (identification of shapes)
1 a 999 * 1 to 99 (Classical)
D_CODES: * 1 to 999
*
D01 ... D9 = codes d'action: * D_CODES:
D01 = activation de lumiere (baisser de plume) lors du d�placement * D01 ... D9 = action codes:
D02 = extinction de lumiere (lever de plume) lors du d�placement * D01 = activating light (lower pen) when di placement
D03 = Flash * D02 = light extinction (lift pen) when di placement
D09 = VAPE Flash * D03 Flash
* D09 = VAPE Flash
D10 ... = Indentification d'outils ( d'ouvertures ) * D10 ... = Indentification Tool (Opening)
*/ */
/*********************************/
/* class GERBER : Methodes */
/*********************************/
GERBER::GERBER( int aLayer ) GERBER::GERBER( int aLayer )
{ {
...@@ -78,7 +74,7 @@ GERBER::GERBER( int aLayer ) ...@@ -78,7 +74,7 @@ GERBER::GERBER( int aLayer )
ResetDefaultValues(); ResetDefaultValues();
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ ) for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
m_Aperture_List[ii] = 0; m_Aperture_List[ii] = 0;
m_Pcb = 0; m_Pcb = 0;
...@@ -87,9 +83,10 @@ GERBER::GERBER( int aLayer ) ...@@ -87,9 +83,10 @@ GERBER::GERBER( int aLayer )
GERBER::~GERBER() GERBER::~GERBER()
{ {
for( unsigned ii = 0; ii < DIM(m_Aperture_List); ii++ ) for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
{ {
delete m_Aperture_List[ii]; delete m_Aperture_List[ii];
// m_Aperture_List[ii] = NULL; // m_Aperture_List[ii] = NULL;
} }
...@@ -101,7 +98,7 @@ D_CODE* GERBER::GetDCODE( int aDCODE, bool create ) ...@@ -101,7 +98,7 @@ D_CODE* GERBER::GetDCODE( int aDCODE, bool create )
{ {
unsigned ndx = aDCODE - FIRST_DCODE; unsigned ndx = aDCODE - FIRST_DCODE;
if( ndx < (unsigned) DIM(m_Aperture_List) ) if( ndx < (unsigned) DIM( m_Aperture_List ) )
{ {
// lazily create the D_CODE if it does not exist. // lazily create the D_CODE if it does not exist.
if( create ) if( create )
...@@ -130,20 +127,20 @@ APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup ) ...@@ -130,20 +127,20 @@ APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup )
} }
/******************************************/
void GERBER::ResetDefaultValues() void GERBER::ResetDefaultValues()
/******************************************/
{ {
m_FileName.Empty(); m_FileName.Empty();
m_Name = wxT( "no name" ); // Layer name m_Name = wxT( "no name" ); // Layer name
m_LayerNegative = FALSE; // TRUE = Negative Layer m_LayerNegative = FALSE; // TRUE = Negative Layer
m_ImageNegative = FALSE; // TRUE = Negative image m_ImageNegative = FALSE; // TRUE = Negative image
m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric
m_Relative = FALSE; // FALSE = absolute Coord, RUE = relative Coord m_Relative = FALSE; // FALSE = absolute Coord, RUE =
m_NoTrailingZeros = FALSE; // True: zeros a droite supprim�s // relative Coord
m_MirorA = FALSE; // True: miror / axe A (X) m_NoTrailingZeros = FALSE; // True: trailing zeros deleted
m_MirorB = FALSE; // True: miror / axe B (Y) m_MirorA = FALSE; // True: miror / axe A (X)
m_Has_DCode = FALSE; // TRUE = DCodes in file (FALSE = no DCode-> m_MirorB = FALSE; // True: miror / axe B (Y)
m_Has_DCode = FALSE; // TRUE = DCodes in file (FALSE = no
// DCode->
// separate DCode file // separate DCode file
m_Offset.x = m_Offset.y = 0; // Coord Offset m_Offset.x = m_Offset.y = 0; // Coord Offset
...@@ -151,43 +148,47 @@ void GERBER::ResetDefaultValues() ...@@ -151,43 +148,47 @@ void GERBER::ResetDefaultValues()
m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10; m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10;
m_FmtLen.x = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10); m_FmtLen.x = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10);
m_LayerScale.x = m_LayerScale.y = 1.0; // scale (X et Y) pour cette layer m_LayerScale.x = m_LayerScale.y = 1.0; // scale (X and Y) this
// layer
m_Rotation = 0; m_Rotation = 0;
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ.
m_360Arc_enbl = FALSE; // 360 deg circular interpolation disable m_360Arc_enbl = FALSE; // 360 deg circular
m_Current_Tool = 0; // Current Tool (Dcode) number selected // interpolation disable
m_CommandState = 0; // donne l'etat de l'analyse des commandes gerber m_Current_Tool = 0; // Current Tool (Dcode)
m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord for plot // number selected
m_PreviousPos.x = m_PreviousPos.y = 0; // old current specified coord for plot m_CommandState = 0; // gives tate of the
m_IJPos.x = m_IJPos.y = 0; // current centre coord for plot arcs & circles // stacking order analysis
m_Current_File = NULL; // File to read m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord
m_FilesPtr = 0; // for plot
m_Transform[0][0] = m_Transform[1][1] = 1; m_PreviousPos.x = m_PreviousPos.y = 0; // old current specified
m_Transform[0][1] = m_Transform[1][0] = 0; // Rotation/mirror = Normal // coord for plot
m_PolygonFillMode = FALSE; m_IJPos.x = m_IJPos.y = 0; // current centre coord for
// plot arcs & circles
m_Current_File = NULL; // File to read
m_FilesPtr = 0;
m_Transform[0][0] = m_Transform[1][1] = 1;
m_Transform[0][1] = m_Transform[1][0] = 0; // Rotation/mirror = Normal
m_PolygonFillMode = FALSE;
m_PolygonFillModeState = 0; m_PolygonFillModeState = 0;
} }
/********************************************/
int GERBER::ReturnUsedDcodeNumber() int GERBER::ReturnUsedDcodeNumber()
/********************************************/
{ {
int count = 0; int count = 0;
for( unsigned ii = 0; ii < DIM(m_Aperture_List); ii++ ) for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
{ {
if( m_Aperture_List[ii] ) if( m_Aperture_List[ii] )
if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined ) if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined )
++count; ++count;
} }
return count; return count;
} }
/******************************/
void GERBER::InitToolTable() void GERBER::InitToolTable()
/******************************/
{ {
for( int count = 0; count < MAX_TOOLS; count++ ) for( int count = 0; count < MAX_TOOLS; count++ )
{ {
...@@ -200,13 +201,9 @@ void GERBER::InitToolTable() ...@@ -200,13 +201,9 @@ void GERBER::InitToolTable()
} }
/*************************/ /***************/
/* Class DCODE: methodes */ /* Class DCODE */
/*************************/ /***************/
/* Variables locales : */
/* Routines Locales */
D_CODE::D_CODE( int num_dcode ) D_CODE::D_CODE( int num_dcode )
...@@ -228,33 +225,45 @@ void D_CODE::Clear_D_CODE_Data() ...@@ -228,33 +225,45 @@ void D_CODE::Clear_D_CODE_Data()
m_Shape = APT_CIRCLE; m_Shape = APT_CIRCLE;
m_Drill.x = m_Drill.y = 0; m_Drill.x = m_Drill.y = 0;
m_DrillShape = 0; m_DrillShape = 0;
m_InUse = FALSE; m_InUse = FALSE;
m_Defined = FALSE; m_Defined = FALSE;
m_Macro = 0; m_Macro = 0;
} }
const wxChar* D_CODE::ShowApertureType( APERTURE_T aType ) const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
{ {
const wxChar* ret; const wxChar* ret;
switch( aType ) switch( aType )
{ {
case APT_CIRCLE: ret = wxT( "Round" ); break; case APT_CIRCLE:
case APT_LINE: ret = wxT( "Line" ); break; ret = wxT( "Round" ); break;
case APT_RECT: ret = wxT( "Rect" ); break;
case APT_OVAL: ret = wxT( "Oval" ); break; case APT_LINE:
case APT_POLYGON: ret = wxT( "Poly" ); break; ret = wxT( "Line" ); break;
case APT_MACRO: ret = wxT( "Macro" ); break;
default: ret = wxT( "???" ); break; case APT_RECT:
ret = wxT( "Rect" ); break;
case APT_OVAL:
ret = wxT( "Oval" ); break;
case APT_POLYGON:
ret = wxT( "Poly" ); break;
case APT_MACRO:
ret = wxT( "Macro" ); break;
default:
ret = wxT( "???" ); break;
} }
return ret; return ret;
} }
/******************************************************************************/
int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
/******************************************************************************/
{ {
int current_Dcode, ii, dcode_scale; int current_Dcode, ii, dcode_scale;
char* ptcar; char* ptcar;
...@@ -276,9 +285,9 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) ...@@ -276,9 +285,9 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
GERBER* gerber = g_GERBER_List[layer]; GERBER* gerber = g_GERBER_List[layer];
/* Mise a jour de l'echelle gerber : */ /* Updating gerber scale: */
dcode_scale = 10; /* ici unit dcode = mil, unit interne = 0.1 mil dcode_scale = 10; /* By uniting dCode = mil, internal unit = 0.1 mil
* -> 1 unite dcode = 10 unit PCB */ * -> 1 unite dcode = 10 unit PCB */
current_Dcode = 0; current_Dcode = 0;
if( D_Code_FullFileName.IsEmpty() ) if( D_Code_FullFileName.IsEmpty() )
...@@ -297,17 +306,17 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) ...@@ -297,17 +306,17 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
while( fgets( line, sizeof(line) - 1, dest ) != NULL ) while( fgets( line, sizeof(line) - 1, dest ) != NULL )
{ {
if( *line == ';' ) if( *line == ';' )
continue; /* Commentaire */ continue;
if( strlen( line ) < 10 ) if( strlen( line ) < 10 )
continue; /* Probablemant ligne vide */ continue; /* Skip blank line. */
dcode = NULL; dcode = NULL;
current_Dcode = 0; current_Dcode = 0;
/* Determination du type de fichier D_Code */ /* Determine of the type of file from D_Code. */
ptcar = line; ptcar = line;
ii = 0; ii = 0;
while( *ptcar ) while( *ptcar )
if( *(ptcar++) == ',' ) if( *(ptcar++) == ',' )
ii++; ii++;
...@@ -315,9 +324,9 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) ...@@ -315,9 +324,9 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
if( ii >= 6 ) /* valeurs en mils */ if( ii >= 6 ) /* valeurs en mils */
{ {
sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii, sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii,
&dimH, &dimV, &drill, &dimH, &dimV, &drill,
&dummy, &dummy, &dummy, &dummy,
&type_outil ); &type_outil );
dimH = (int) ( (dimH * dcode_scale) + 0.5 ); dimH = (int) ( (dimH * dcode_scale) + 0.5 );
dimV = (int) ( (dimV * dcode_scale) + 0.5 ); dimV = (int) ( (dimV * dcode_scale) + 0.5 );
...@@ -326,7 +335,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) ...@@ -326,7 +335,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
ii = 1; ii = 1;
current_Dcode = ii - 1 + FIRST_DCODE; current_Dcode = ii - 1 + FIRST_DCODE;
} }
else /* valeurs en inches a convertir en mils */ else /* Values in inches are converted to mils. */
{ {
fdrill = 0; fdrill = 0;
current_Dcode = 0; current_Dcode = 0;
...@@ -344,9 +353,9 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) ...@@ -344,9 +353,9 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
ptcar++; ptcar++;
} }
dimH = (int) ( (fdimH * dcode_scale * 1000) + 0.5 ); dimH = (int) ( (fdimH * dcode_scale * 1000) + 0.5 );
dimV = (int) ( (fdimV * dcode_scale * 1000) + 0.5 ); dimV = (int) ( (fdimV * dcode_scale * 1000) + 0.5 );
drill = (int) ( (fdrill * dcode_scale * 1000) + 0.5 ); drill = (int) ( (fdrill * dcode_scale * 1000) + 0.5 );
if( strchr( "CLROP", c_type_outil[0] ) ) if( strchr( "CLROP", c_type_outil[0] ) )
type_outil = (APERTURE_T) c_type_outil[0]; type_outil = (APERTURE_T) c_type_outil[0];
...@@ -357,7 +366,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) ...@@ -357,7 +366,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
} }
} }
/* Mise a jour de la liste des d_codes si valeurs lues coherentes*/ /* Update the list of d_codes if consistant. */
if( current_Dcode < FIRST_DCODE ) if( current_Dcode < FIRST_DCODE )
continue; continue;
...@@ -378,33 +387,32 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) ...@@ -378,33 +387,32 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
} }
/***************************************************/
void WinEDA_GerberFrame::CopyDCodesSizeToItems()
/***************************************************/
/* Set Size Items (Lines, Flashes) from DCodes List /* Set Size Items (Lines, Flashes) from DCodes List
*/ */
void WinEDA_GerberFrame::CopyDCodesSizeToItems()
{ {
static D_CODE dummy(999); //Used if D_CODE not found in list static D_CODE dummy( 999 ); //Used if D_CODE not found in list
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
{ {
GERBER* gerber = g_GERBER_List[track->GetLayer()]; GERBER* gerber = g_GERBER_List[track->GetLayer()];
wxASSERT( gerber ); wxASSERT( gerber );
D_CODE* dcode = gerber->GetDCODE( track->GetNet(), false ); D_CODE* dcode = gerber->GetDCODE( track->GetNet(), false );
wxASSERT( dcode ); wxASSERT( dcode );
if ( dcode == NULL ) if( dcode == NULL )
dcode = &dummy; dcode = &dummy;
dcode->m_InUse = TRUE; dcode->m_InUse = TRUE;
if( // Line Item if( // Line Item
(track->m_Shape == S_SEGMENT ) /* segment rectiligne */ (track->m_Shape == S_SEGMENT ) /* rectilinear segment */
|| (track->m_Shape == S_RECT ) /* segment forme rect (i.e. bouts non arrondis) */ || (track->m_Shape == S_RECT ) /* rect segment form (i.e.
|| (track->m_Shape == S_ARC ) /* segment en arc de cercle (bouts arrondis)*/ * non-rounded ends) */
|| (track->m_Shape == S_CIRCLE ) /* segment en cercle (anneau)*/ || (track->m_Shape == S_ARC ) /* segment arc (rounded tips) */
|| (track->m_Shape == S_ARC_RECT ) /* segment en arc de cercle (bouts droits) (GERBER)*/ || (track->m_Shape == S_CIRCLE ) /* segment in a circle (ring) */
|| (track->m_Shape == S_ARC_RECT ) /* segment arc (stretches)
* (GERBER)*/
) )
{ {
track->m_Width = dcode->m_Size.x; track->m_Width = dcode->m_Size.x;
...@@ -421,12 +429,13 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems() ...@@ -421,12 +429,13 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
track->m_Start.x = (track->m_Start.x + track->m_End.x) / 2; track->m_Start.x = (track->m_Start.x + track->m_End.x) / 2;
track->m_Start.y = (track->m_Start.y + track->m_End.y) / 2; track->m_Start.y = (track->m_Start.y + track->m_End.y) / 2;
track->m_End = track->m_Start; // m_Start = m_End = Spot center track->m_End = track->m_Start; // m_Start = m_End = Spot center
switch( dcode->m_Shape ) switch( dcode->m_Shape )
{ {
case APT_LINE: // might not appears here, but some broken gerber files use it case APT_LINE: // might not appears here, but some broken
case APT_CIRCLE: /* spot round (for GERBER)*/ // gerber files use it
case APT_CIRCLE: /* spot round (for GERBER) */
track->m_Shape = S_SPOT_CIRCLE; track->m_Shape = S_SPOT_CIRCLE;
break; break;
...@@ -455,18 +464,15 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems() ...@@ -455,18 +464,15 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
} }
/************************************************/
void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC ) void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC )
/************************************************/
{ {
int ii, jj; int ii, jj;
D_CODE* pt_D_code; D_CODE* pt_D_code;
wxString Line; wxString Line;
WinEDA_TextFrame* List; WinEDA_TextFrame* List;
int scale = 10000; int scale = 10000;
int curr_layer = GetScreen()->m_Active_Layer; int curr_layer = GetScreen()->m_Active_Layer;
/* Construction de la liste des messages */
List = new WinEDA_TextFrame( this, _( "List D codes" ) ); List = new WinEDA_TextFrame( this, _( "List D codes" ) );
for( int layer = 0; layer < 32; layer++ ) for( int layer = 0; layer < 32; layer++ )
...@@ -494,13 +500,13 @@ void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC ) ...@@ -494,13 +500,13 @@ void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC )
continue; continue;
Line.Printf( wxT( Line.Printf( wxT(
"tool %2.2d: D%2.2d V %2.4f H %2.4f %s" ), "tool %2.2d: D%2.2d V %2.4f H %2.4f %s" ),
jj, jj,
pt_D_code->m_Num_Dcode, pt_D_code->m_Num_Dcode,
(float) pt_D_code->m_Size.y / scale, (float) pt_D_code->m_Size.y / scale,
(float) pt_D_code->m_Size.x / scale, (float) pt_D_code->m_Size.x / scale,
D_CODE::ShowApertureType( pt_D_code->m_Shape ) D_CODE::ShowApertureType( pt_D_code->m_Shape )
); );
if( !pt_D_code->m_Defined ) if( !pt_D_code->m_Defined )
Line += wxT( " ?" ); Line += wxT( " ?" );
...@@ -520,7 +526,7 @@ void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC ) ...@@ -520,7 +526,7 @@ void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC )
#if 0 #if 0
// Mise en surbrillance des �l�ments correspondant au DCode s�lectionn� // Highlight segment corresponding to dCode selected.
if( Etat_Surbrillance ) if( Etat_Surbrillance )
Hight_Light( DrawPanel, DC ); Hight_Light( DrawPanel, DC );
net_code_Surbrillance = (GetScreen()->m_Active_Layer << 16) + ii; net_code_Surbrillance = (GetScreen()->m_Active_Layer << 16) + ii;
......
/*********************************************/ /*********************************************/
/* Edition des pistes: Routines d'effacement */ /* Edit Track: Erase Routines */
/* Effacement de segment, piste, net et zone */ /* Drop the segment, track, and net area */
/*********************************************/ /*********************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -10,22 +10,16 @@ ...@@ -10,22 +10,16 @@
#include "gerbview.h" #include "gerbview.h"
#include "protos.h" #include "protos.h"
/* Routines externes : */
/* Routines Locales */ void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC,
int dcode_value,
/* Variables locales */ int layer_number )
/****************************************************************************************/
void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number )
/****************************************************************************************/
{ {
if( dcode_value < FIRST_DCODE ) // No tool selected if( dcode_value < FIRST_DCODE ) // No tool selected
return; return;
TRACK* next; TRACK* next;
for( TRACK* track = GetBoard()->m_Track; track; track = next ) for( TRACK* track = GetBoard()->m_Track; track; track = next )
{ {
next = track->Next(); next = track->Next();
...@@ -42,28 +36,26 @@ void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC, int dcode_value, int laye ...@@ -42,28 +36,26 @@ void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC, int dcode_value, int laye
} }
/*****************************************************************/ /* Removes 1 segment of track.
TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track ) *
/*****************************************************************/ * If There is evidence of new track: erase segment
* Otherwise: Delete segment under the cursor.
/* Supprime 1 segment de piste.
* 2 Cas possibles:
* Si On est en trace de nouvelle piste: Effacement du segment en
* cours de trace
* Sinon : Effacment du segment sous le curseur.
*/ */
TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track )
{ {
if( Track == NULL ) if( Track == NULL )
return NULL; return NULL;
if( Track->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment if( Track->m_Flags & IS_NEW ) // Trace in progress, delete the last
// segment
{ {
if( g_CurrentTrackList.GetCount() > 0 ) if( g_CurrentTrackList.GetCount() > 0 )
{ {
// modification du trace // Change track.
delete g_CurrentTrackList.PopBack(); delete g_CurrentTrackList.PopBack();
if( g_CurrentTrackList.GetCount() && g_CurrentTrackSegment->Type() == TYPE_VIA ) if( g_CurrentTrackList.GetCount()
&& g_CurrentTrackSegment->Type() == TYPE_VIA )
{ {
delete g_CurrentTrackList.PopBack(); delete g_CurrentTrackList.PopBack();
} }
...@@ -85,12 +77,11 @@ TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track ) ...@@ -85,12 +77,11 @@ TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track )
} }
return NULL; return NULL;
} // Fin traitement si trace en cours }
Trace_Segment( DrawPanel, DC, Track, GR_XOR ); Trace_Segment( DrawPanel, DC, Track, GR_XOR );
DLIST<TRACK>* container = (DLIST<TRACK>*) Track->GetList(); DLIST<TRACK>* container = (DLIST<TRACK>*)Track->GetList();
wxASSERT( container ); wxASSERT( container );
container->Remove( Track ); container->Remove( Track );
......
/******************************************************/ /***********************************/
/* edit.cpp: fonctions generales de l'edition du PCB */ /* edit.cpp: PCB editing functions */
/******************************************************/ /***********************************/
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
...@@ -13,21 +13,17 @@ ...@@ -13,21 +13,17 @@
#include "protos.h" #include "protos.h"
/* Process the command triggered by the left button of the mouse when a tool
/************************************************************************/ * is already selected.
void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/************************************************************************/
/* Traite les commandes declench�e par le bouton gauche de la souris,
* quand un outil est deja selectionn�
*/ */
void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem(); BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg; wxString msg;
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
{ {
if( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours if( DrawStruct && DrawStruct->m_Flags )
{ {
msg.Printf( wxT( "WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X" ), msg.Printf( wxT( "WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X" ),
(unsigned) DrawStruct->Type(), (unsigned) DrawStruct->Type(),
...@@ -70,18 +66,15 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -70,18 +66,15 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
/********************************************************************************/ /* Handles the selection of tools, menu, and popup menu commands.
void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
/********************************************************************************/
/* Traite les selections d'outils et les commandes appelees du menu POPUP
*/ */
void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
int layer = GetScreen()->m_Active_Layer; int layer = GetScreen()->m_Active_Layer;
GERBER* gerber_layer = g_GERBER_List[layer]; GERBER* gerber_layer = g_GERBER_List[layer];
wxPoint pos; wxPoint pos;
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc ); DrawPanel->PrepareGraphicContext( &dc );
...@@ -89,7 +82,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -89,7 +82,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
pos.y += 20; pos.y += 20;
switch( id ) // Arret eventuel de la commande de d�placement en cours switch( id )
{ {
case wxID_CUT: case wxID_CUT:
case wxID_COPY: case wxID_COPY:
...@@ -108,7 +101,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -108,7 +101,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
} }
/* ne devrait pas etre execute, sauf bug */ /* Should not be executed, except bug */
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
...@@ -121,7 +114,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -121,7 +114,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
break; break;
default: // Arret dea commande de d�placement en cours default:
if( DrawPanel->ManageCurseur if( DrawPanel->ManageCurseur
&& DrawPanel->ForceCloseManageCurseur ) && DrawPanel->ForceCloseManageCurseur )
{ {
...@@ -131,7 +124,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -131,7 +124,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
} }
switch( id ) // Traitement des commandes switch( id )
{ {
case ID_EXIT: case ID_EXIT:
Close( TRUE ); Close( TRUE );
...@@ -147,10 +140,12 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -147,10 +140,12 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_GET_TOOLS: case ID_GET_TOOLS:
// InstallToolsFrame(this, wxPoint(-1,-1) ); // InstallToolsFrame(this, wxPoint(-1,-1) );
break; break;
case ID_FIND_ITEMS: case ID_FIND_ITEMS:
// InstallFindFrame(this, pos); // InstallFindFrame(this, pos);
break; break;
...@@ -249,7 +244,8 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -249,7 +244,8 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS: case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS:
if( gerber_layer ) if( gerber_layer )
Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool,
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
break; break;
default: default:
...@@ -261,12 +257,9 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -261,12 +257,9 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
} }
/**************************************************************************/ /* Called on a double click of left mouse button.
void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/**************************************************************************/
/* Called on a double click:
*/ */
void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{ {
EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem();
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
...@@ -281,7 +274,7 @@ void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -281,7 +274,7 @@ void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = GerberGeneralLocateAndDisplay(); DrawStruct = GerberGeneralLocateAndDisplay();
} }
break; // end case 0 break;
default: default:
break; break;
......
...@@ -15,21 +15,15 @@ ...@@ -15,21 +15,15 @@
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "protos.h" #include "protos.h"
/* Routines Locales : */
static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, static int SavePcbFormatAscii( WinEDA_GerberFrame* frame,
FILE* File, int* LayerLookUpTable ); FILE* File, int* LayerLookUpTable );
/* Variables Locales */
/************************************************************************/
void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event )
/************************************************************************/
/* Export data in pcbnew format /* Export data in pcbnew format
*/ */
void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event )
{ {
int ii = 0; int ii = 0;
bool no_used_layers = true; // Changed to false if any used layer found bool no_used_layers = true; // Changed to false if any used layer found
// Check whether any of the Gerber layers are actually currently used // Check whether any of the Gerber layers are actually currently used
...@@ -42,7 +36,8 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event ) ...@@ -42,7 +36,8 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event )
if( no_used_layers ) if( no_used_layers )
{ {
DisplayInfoMessage( this, _( "None of the Gerber layers contain any data" ) ); DisplayInfoMessage( this,
_( "None of the Gerber layers contain any data" ) );
return; return;
} }
...@@ -50,14 +45,14 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event ) ...@@ -50,14 +45,14 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event )
wxString PcbExt( wxT( ".brd" ) ); wxString PcbExt( wxT( ".brd" ) );
FILE* dest; FILE* dest;
msg = wxT( "*" ) + PcbExt; msg = wxT( "*" ) + PcbExt;
FullFileName = EDA_FileSelector( _( "Board file name:" ), FullFileName = EDA_FileSelector( _( "Board file name:" ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString,
wxEmptyString, /* nom fichier par defaut */ wxEmptyString,
PcbExt, /* extension par defaut */ PcbExt,
msg, /* Masque d'affichage */ msg,
this, this,
wxFD_SAVE, wxFD_SAVE,
FALSE FALSE
...@@ -87,9 +82,7 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event ) ...@@ -87,9 +82,7 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event )
} }
/***************************************************************/
static int WriteSetup( FILE* File, BOARD* Pcb ) static int WriteSetup( FILE* File, BOARD* Pcb )
/***************************************************************/
{ {
char text[1024]; char text[1024];
...@@ -97,22 +90,21 @@ static int WriteSetup( FILE* File, BOARD* Pcb ) ...@@ -97,22 +90,21 @@ static int WriteSetup( FILE* File, BOARD* Pcb )
sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT ); sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
fprintf( File, "%s", text ); fprintf( File, "%s", text );
Pcb->m_BoardSettings->SetCopperLayerCount( g_DesignSettings.GetCopperLayerCount( ) ); Pcb->m_BoardSettings->SetCopperLayerCount(
fprintf( File, "Layers %d\n", g_DesignSettings.GetCopperLayerCount( ) ); g_DesignSettings.GetCopperLayerCount() );
fprintf( File, "Layers %d\n", g_DesignSettings.GetCopperLayerCount() );
fprintf( File, "$EndSETUP\n\n" ); fprintf( File, "$EndSETUP\n\n" );
return 1; return 1;
} }
/******************************************************/
static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File ) static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File )
/******************************************************/
{ {
int NbLayers; int NbLayers;
/* Print the copper layer count */ /* Print the copper layer count */
NbLayers = Pcb->m_BoardSettings->GetCopperLayerCount( ); NbLayers = Pcb->m_BoardSettings->GetCopperLayerCount();
fprintf( File, "$GENERAL\n" ); fprintf( File, "$GENERAL\n" );
fprintf( File, "LayerCount %d\n", NbLayers ); fprintf( File, "LayerCount %d\n", NbLayers );
...@@ -128,29 +120,26 @@ static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File ) ...@@ -128,29 +120,26 @@ static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File )
} }
/*******************************************************************/
static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
int* LayerLookUpTable )
/*******************************************************************/
/* Routine to save the board /* Routine to save the board
* @param frame = pointer to the main frame * @param frame = pointer to the main frame
* @param File = FILE * pointer to an already opened file * @param File = FILE * pointer to an already opened file
* @param LayerLookUpTable = look up table: pcbnew layer for each gerber layer * @param LayerLookUpTable = look up table: pcbnew layer for each gerber layer
* @return 1 if OK, 0 if fail * @return 1 if OK, 0 if fail
*/ */
static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
int* LayerLookUpTable )
{ {
char line[256]; char line[256];
TRACK* track; TRACK* track;
BOARD* gerberPcb = frame->GetBoard(); BOARD* gerberPcb = frame->GetBoard();
BOARD* pcb; BOARD* pcb;
wxBeginBusyCursor(); wxBeginBusyCursor();
// create an image of gerber data // create an image of gerber data
pcb = new BOARD( NULL, frame ); pcb = new BOARD( NULL, frame );
for( track = gerberPcb->m_Track; track; track = track->Next() ) for( track = gerberPcb->m_Track; track; track = track->Next() )
{ {
int layer = track->GetLayer(); int layer = track->GetLayer();
int pcb_layer_number = LayerLookUpTable[layer]; int pcb_layer_number = LayerLookUpTable[layer];
...@@ -170,29 +159,32 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -170,29 +159,32 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
{ {
double cx = track->m_Param; double cx = track->m_Param;
double cy = track->GetSubNet(); double cy = track->GetSubNet();
double a = atan2( track->m_Start.y-cy, track->m_Start.x-cx ); double a = atan2( track->m_Start.y - cy,
double b = atan2( track->m_End.y-cy, track->m_End.x-cx ); track->m_Start.x - cx );
double b = atan2( track->m_End.y - cy, track->m_End.x - cx );
drawitem->m_Shape = S_ARC;
drawitem->m_Angle = (int)fmod( (a-b)/M_PI*1800.0+3600.0, 3600.0 ); drawitem->m_Shape = S_ARC;
drawitem->m_Start.x = (int)cx; drawitem->m_Angle = (int) fmod(
drawitem->m_Start.y = (int)cy; (a - b) / M_PI * 1800.0 + 3600.0, 3600.0 );
drawitem->m_Start.x = (int) cx;
drawitem->m_Start.y = (int) cy;
} }
pcb->Add( drawitem ); pcb->Add( drawitem );
} }
else else
{ {
TRACK* newtrack; TRACK* newtrack;
// replace spots with vias when possible // replace spots with vias when possible
if( track->m_Shape == S_SPOT_CIRCLE if( track->m_Shape == S_SPOT_CIRCLE
|| track->m_Shape == S_SPOT_RECT || track->m_Shape == S_SPOT_RECT
|| track->m_Shape == S_SPOT_OVALE ) || track->m_Shape == S_SPOT_OVALE )
{ {
newtrack = new SEGVIA( (const SEGVIA&) *track ); newtrack = new SEGVIA( (const SEGVIA &) * track );
// A spot is found, and can be a via: change it to via, and delete other // A spot is found, and can be a via: change it to via, and
// delete other
// spots at same location // spots at same location
newtrack->m_Shape = VIA_THROUGH; newtrack->m_Shape = VIA_THROUGH;
...@@ -200,10 +192,13 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -200,10 +192,13 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
newtrack->SetDrillDefault(); newtrack->SetDrillDefault();
// Compute the via position from track position ( Via position is the // Compute the via position from track position ( Via position
// is the
// position of the middle of the track segment ) // position of the middle of the track segment )
newtrack->m_Start.x = (newtrack->m_Start.x + newtrack->m_End.x) / 2; newtrack->m_Start.x =
newtrack->m_Start.y = (newtrack->m_Start.y + newtrack->m_End.y) / 2; (newtrack->m_Start.x + newtrack->m_End.x) / 2;
newtrack->m_Start.y =
(newtrack->m_Start.y + newtrack->m_End.y) / 2;
newtrack->m_End = newtrack->m_Start; newtrack->m_End = newtrack->m_Start;
} }
else // a true TRACK else // a true TRACK
...@@ -217,7 +212,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -217,7 +212,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
} }
// delete redundant vias // delete redundant vias
for( track = pcb->m_Track; track; track = track->Next() ) for( track = pcb->m_Track; track; track = track->Next() )
{ {
if( track->m_Shape != VIA_THROUGH ) if( track->m_Shape != VIA_THROUGH )
continue; continue;
...@@ -225,7 +220,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -225,7 +220,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
// Search and delete others vias // Search and delete others vias
TRACK* next_track; TRACK* next_track;
TRACK* alt_track = track->Next(); TRACK* alt_track = track->Next();
for( ; alt_track; alt_track = next_track ) for( ; alt_track; alt_track = next_track )
{ {
next_track = alt_track->Next(); next_track = alt_track->Next();
if( alt_track->m_Shape != VIA_THROUGH ) if( alt_track->m_Shape != VIA_THROUGH )
...@@ -240,8 +235,9 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -240,8 +235,9 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
} }
} }
// Switch the locale to standard C (needed to print floating point numbers like 1.3) // Switch the locale to standard C (needed to print floating point numbers
SetLocaleTo_C_standard( ); // like 1.3)
SetLocaleTo_C_standard();
// write the PCB heading // write the PCB heading
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB, fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
...@@ -255,7 +251,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -255,7 +251,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
// the destructor should destroy all owned sub-objects // the destructor should destroy all owned sub-objects
delete pcb; delete pcb;
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
wxEndBusyCursor(); wxEndBusyCursor();
return 1; return 1;
} }
/******************************************************/ /*************/
/* Files.cp: Lecture / Sauvegarde des fichiers gerber */ /* files.cpp */
/******************************************************/ /*************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -13,8 +13,9 @@ ...@@ -13,8 +13,9 @@
#include "protos.h" #include "protos.h"
/* Routines locales */ static void LoadDCodeFile( WinEDA_GerberFrame* frame,
static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileName, wxDC* DC ); const wxString& FullFileName,
wxDC* DC );
void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event ) void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event )
...@@ -33,15 +34,11 @@ void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event ) ...@@ -33,15 +34,11 @@ void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event )
} }
} }
/***************
***************************************/
void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
/********************************************************/
/* Gestion generale des commandes de lecture de fichiers /* File commands. */
*/ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
...@@ -58,17 +55,17 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event ) ...@@ -58,17 +55,17 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
case ID_MENU_INC_LAYER_AND_APPEND_FILE: case ID_MENU_INC_LAYER_AND_APPEND_FILE:
case ID_INC_LAYER_AND_APPEND_FILE: case ID_INC_LAYER_AND_APPEND_FILE:
{ {
int origLayer = GetScreen()->m_Active_Layer; int origLayer = GetScreen()->m_Active_Layer;
GetScreen()->m_Active_Layer++; GetScreen()->m_Active_Layer++;
if( !LoadOneGerberFile( wxEmptyString, &dc, 0 ) ) if( !LoadOneGerberFile( wxEmptyString, &dc, 0 ) )
GetScreen()->m_Active_Layer = origLayer; GetScreen()->m_Active_Layer = origLayer;
SetToolbars(); SetToolbars();
} }
break; break;
case ID_APPEND_FILE: case ID_APPEND_FILE:
LoadOneGerberFile( wxEmptyString, &dc, 0 ); LoadOneGerberFile( wxEmptyString, &dc, 0 );
...@@ -106,52 +103,49 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event ) ...@@ -106,52 +103,49 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
} }
/*******************************************************************************************/
bool
WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
wxDC* DC,
int mode )
/*******************************************************************************************/
/* /*
* Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s * Load a PCB file.
* retourne: *
* 0 si fichier non lu ( annulation de commande ... ) * Returns:
* 1 si OK * 0 if file not read (cancellation of order ...)
* 1 if OK
*/ */
bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
wxDC* DC,
int mode )
{ {
wxString filetypes; wxString filetypes;
wxFileName filename = FullFileName; wxFileName filename = FullFileName;
ActiveScreen = GetScreen(); ActiveScreen = GetScreen();
if( !filename.IsOk() ) if( !filename.IsOk() )
{ {
wxString current_path = filename.GetPath(); wxString current_path = filename.GetPath();
/* Standard gerber filetypes */ /* Standard gerber filetypes */
filetypes += _("Gerber files (.gbr .gbx .lgr .ger .pho)| \ filetypes += _( "Gerber files (.gbr .gbx .lgr .ger .pho)| \
*.gbr;*.GBR;*.gbx;*.GBX;*.lgr;*.LGR;*.ger;*.GER;*.pho;*.PHO|"); .gbr;*.GBR;*.gbx;*.GBX;*.lgr;*.LGR;*.ger;*.GER;*.pho;*.PHO|" );
/* Special gerber filetypes */ /* Special gerber filetypes */
filetypes += _("Top layer (*.GTL)|*.GTL;*.gtl|"); filetypes += _( "Top layer (*.GTL)|*.GTL;*.gtl|" );
filetypes += _("Bottom layer (*.GBL)|*.GBL;*.gbl|"); filetypes += _( "Bottom layer (*.GBL)|*.GBL;*.gbl|" );
filetypes += _("Bottom solder resist (*.GBS)|*.GBS;*.gbs|"); filetypes += _( "Bottom solder resist (*.GBS)|*.GBS;*.gbs|" );
filetypes += _("Top solder resist (*.GTS)|*.GTS;*.gts|"); filetypes += _( "Top solder resist (*.GTS)|*.GTS;*.gts|" );
filetypes += _("Bottom overlay (*.GBO)|*.GBO;*.gbo|"); filetypes += _( "Bottom overlay (*.GBO)|*.GBO;*.gbo|" );
filetypes += _("Top overlay (*.GTO)|*.GTO;*.gto|"); filetypes += _( "Top overlay (*.GTO)|*.GTO;*.gto|" );
filetypes += _("Bottom paste (*.GBP)|*.GBP;*.gbp|"); filetypes += _( "Bottom paste (*.GBP)|*.GBP;*.gbp|" );
filetypes += _("Top paste (*.GTP)|*.GTP;*.gtp|"); filetypes += _( "Top paste (*.GTP)|*.GTP;*.gtp|" );
filetypes += _("Keep-out layer (*.GKO)|*.GKO;*.gko|"); filetypes += _( "Keep-out layer (*.GKO)|*.GKO;*.gko|" );
filetypes += _("Mechanical layers (*.GMx)|*.GM1;*.gm1;*.GM2;*.gm2;*.GM3;*.gm3|"); filetypes += _( "Mechanical layers (*.GMx)|*.GM1;*.gm1;*.GM2;*.gm2;*.GM3;*.gm3|" );
filetypes += _("Top Pad Master (*.GPT)|*.GPT;*.gpt|"); filetypes += _( "Top Pad Master (*.GPT)|*.GPT;*.gpt|" );
filetypes += _("Bottom Pad Master (*.GPB)|*.GPB;*.gpb|"); filetypes += _( "Bottom Pad Master (*.GPB)|*.GPB;*.gpb|" );
/* All filetypes */ /* All filetypes */
filetypes += AllFilesWildcard; filetypes += AllFilesWildcard;
/* Get current path if emtpy */ /* Get current path if emtpy */
if ( current_path.IsEmpty() ) if( current_path.IsEmpty() )
current_path = wxGetCwd(); current_path = wxGetCwd();
wxFileDialog dlg( this, wxFileDialog dlg( this,
...@@ -182,18 +176,18 @@ WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName, ...@@ -182,18 +176,18 @@ WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
} }
/**********************************************************************************************/
static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileName, wxDC* DC )
/**********************************************************************************************/
/* /*
* Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s * Read a PCB file.
* retourne: *
* 0 si fichier non lu ( annulation de commande ... ) * Returns:
* 1 si OK * 0 if file not read (cancellation of order ...)
* 1 if OK
*/ */
static void LoadDCodeFile( WinEDA_GerberFrame* frame,
const wxString& FullFileName,
wxDC* DC )
{ {
wxString wildcard; wxString wildcard;
wxFileName fn = FullFileName; wxFileName fn = FullFileName;
ActiveScreen = frame->GetScreen(); ActiveScreen = frame->GetScreen();
...@@ -201,11 +195,12 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileNa ...@@ -201,11 +195,12 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileNa
if( !fn.IsOk() ) if( !fn.IsOk() )
{ {
wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ),
GetChars( g_PenFilenameExt ), GetChars( g_PenFilenameExt )); GetChars( g_PenFilenameExt ),
GetChars( g_PenFilenameExt ) );
wildcard += AllFilesWildcard; wildcard += AllFilesWildcard;
fn = frame->GetScreen()->m_FileName; fn = frame->GetScreen()->m_FileName;
fn.SetExt( g_PenFilenameExt ); fn.SetExt( g_PenFilenameExt );
wxFileDialog dlg( ( wxWindow* )frame, _( "Load GERBER DCODE File" ), wxFileDialog dlg( (wxWindow*) frame, _( "Load GERBER DCODE File" ),
fn.GetPath(), fn.GetFullName(), wildcard, fn.GetPath(), fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST ); wxFD_OPEN | wxFD_FILE_MUST_EXIST );
...@@ -221,14 +216,12 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileNa ...@@ -221,14 +216,12 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileNa
} }
/*******************************************************************************/ /* Save the file in ASCII PCB.
bool WinEDA_GerberFrame::SaveGerberFile( const wxString& FullFileName, wxDC* DC )
/*******************************************************************************/
/* Sauvegarde du fichier PCB en format ASCII
*/ */
bool WinEDA_GerberFrame::SaveGerberFile( const wxString& FullFileName,
wxDC* DC )
{ {
wxString wildcard; wxString wildcard;
wxFileName fn = FullFileName; wxFileName fn = FullFileName;
if( !fn.IsOk() ) if( !fn.IsOk() )
...@@ -236,7 +229,8 @@ bool WinEDA_GerberFrame::SaveGerberFile( const wxString& FullFileName, wxDC* DC ...@@ -236,7 +229,8 @@ bool WinEDA_GerberFrame::SaveGerberFile( const wxString& FullFileName, wxDC* DC
fn = GetScreen()->m_FileName; fn = GetScreen()->m_FileName;
wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ),
GetChars( g_PenFilenameExt ), GetChars( g_PenFilenameExt )); GetChars( g_PenFilenameExt ),
GetChars( g_PenFilenameExt ) );
wxFileDialog dlg( this, _( "Save Gerber File" ), fn.GetPath(), wxFileDialog dlg( this, _( "Save Gerber File" ), fn.GetPath(),
fn.GetFullName(), wildcard, fn.GetFullName(), wildcard,
......
/******************************************************************/ /*******************/
/* gerberframe.cpp - fonctions des classes du type WinEDA_GerberFrame */ /* gerberframe.cpp */
/******************************************************************/ /*******************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -94,15 +94,13 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame ) ...@@ -94,15 +94,13 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBER_SELECT_TOOL, EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBER_SELECT_TOOL,
WinEDA_GerberFrame::Process_Special_Functions ) WinEDA_GerberFrame::Process_Special_Functions )
// Vertical toolbar: // Vertical toolbar:
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions ) EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_TRACK_BUTT, WinEDA_GerberFrame::Process_Special_Functions ) EVT_TOOL( ID_TRACK_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_PCB_ZONES_BUTT, WinEDA_GerberFrame::Process_Special_Functions ) EVT_TOOL( ID_PCB_ZONES_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_PCB_DELETE_ITEM_BUTT, EVT_TOOL( ID_PCB_DELETE_ITEM_BUTT,
WinEDA_GerberFrame::Process_Special_Functions ) WinEDA_GerberFrame::Process_Special_Functions )
// Annulation de commande en cours
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_GerberFrame::Process_Special_Functions ) WinEDA_GerberFrame::Process_Special_Functions )
...@@ -116,11 +114,6 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame ) ...@@ -116,11 +114,6 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
END_EVENT_TABLE() END_EVENT_TABLE()
/****************/
/* Constructeur */
/****************/
WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxPoint& pos,
...@@ -130,8 +123,8 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, ...@@ -130,8 +123,8 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
{ {
m_FrameName = wxT( "GerberFrame" ); m_FrameName = wxT( "GerberFrame" );
m_Draw_Axis = true; // true to show X and Y axis on screen m_Draw_Axis = true; // true to show X and Y axis on screen
m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin� m_Draw_Sheet_Ref = FALSE; // TRUE for reference drawings.
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE; DrawPanel->m_Block_Enable = TRUE;
...@@ -146,6 +139,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, ...@@ -146,6 +139,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
ActiveScreen = ScreenPcb; ActiveScreen = ScreenPcb;
LoadSettings(); LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
...@@ -153,36 +147,37 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, ...@@ -153,36 +147,37 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
ReCreateOptToolbar(); ReCreateOptToolbar();
#if defined(KICAD_AUIMANAGER) #if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow(this); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
horiz.Gripper(false); horiz.Gripper( false );
horiz.DockFixed(true); horiz.DockFixed( true );
horiz.Movable(false); horiz.Movable( false );
horiz.Floatable(false); horiz.Floatable( false );
horiz.CloseButton(false); horiz.CloseButton( false );
horiz.CaptionVisible(false); horiz.CaptionVisible( false );
wxAuiPaneInfo vert(horiz); wxAuiPaneInfo vert( horiz );
vert.TopDockable(false).BottomDockable(false); vert.TopDockable( false ).BottomDockable( false );
horiz.LeftDockable(false).RightDockable(false); horiz.LeftDockable( false ).RightDockable( false );
m_auimgr.AddPane(m_HToolBar, m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo(horiz).Name(wxT("m_HToolBar")).Top().Row(0)); wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
m_auimgr.AddPane(m_VToolBar, m_auimgr.AddPane( m_VToolBar,
wxAuiPaneInfo(vert).Name(wxT("m_VToolBar")).Right()); wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
m_auimgr.AddPane(m_OptionsToolBar, m_auimgr.AddPane( m_OptionsToolBar,
wxAuiPaneInfo(vert).Name(wxT("m_OptionsToolBar")).Left()); wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() );
m_auimgr.AddPane(DrawPanel, m_auimgr.AddPane( DrawPanel,
wxAuiPaneInfo().Name(wxT("DrawFrame")).CentrePane()); wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
m_auimgr.AddPane(MsgPanel, m_auimgr.AddPane( MsgPanel,
wxAuiPaneInfo(horiz).Name(wxT("MsgPanel")).Bottom()); wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update(); m_auimgr.Update();
#endif #endif
...@@ -194,13 +189,10 @@ WinEDA_GerberFrame::~WinEDA_GerberFrame() ...@@ -194,13 +189,10 @@ WinEDA_GerberFrame::~WinEDA_GerberFrame()
SetBaseScreen( ScreenPcb ); SetBaseScreen( ScreenPcb );
extern PARAM_CFG_BASE* ParamCfgList[]; extern PARAM_CFG_BASE* ParamCfgList[];
wxGetApp().SaveCurrentSetupValues( ParamCfgList ); wxGetApp().SaveCurrentSetupValues( ParamCfgList );
} }
/***********************************************************/
void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event ) void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event )
/***********************************************************/
{ {
PCB_SCREEN* screen = ScreenPcb; PCB_SCREEN* screen = ScreenPcb;
...@@ -221,7 +213,8 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -221,7 +213,8 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event )
} }
} }
#endif #endif
while( screen ) // suppression flag modify pour eviter d'autres message
while( screen ) // Modify delete flag to prevent further message.
{ {
screen->ClrModify(); screen->ClrModify();
screen = screen->Next(); screen = screen->Next();
...@@ -234,13 +227,10 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -234,13 +227,10 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event )
} }
/*******************************************/
void WinEDA_GerberFrame::SetToolbars()
/*******************************************/
/** Function SetToolbars() /** Function SetToolbars()
* Set the tools state for the toolbars, accordint to display options * Set the tools state for the toolbars, according to display options
*/ */
void WinEDA_GerberFrame::SetToolbars()
{ {
int layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer; int layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
GERBER* gerber = g_GERBER_List[layer]; GERBER* gerber = g_GERBER_List[layer];
...@@ -263,7 +253,7 @@ void WinEDA_GerberFrame::SetToolbars() ...@@ -263,7 +253,7 @@ void WinEDA_GerberFrame::SetToolbars()
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ) ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer )
{ {
m_SelLayerBox->SetSelection( m_SelLayerBox->SetSelection(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ); ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
} }
if( gerber ) if( gerber )
...@@ -318,16 +308,15 @@ void WinEDA_GerberFrame::SetToolbars() ...@@ -318,16 +308,15 @@ void WinEDA_GerberFrame::SetToolbars()
} }
DisplayUnitsMsg(); DisplayUnitsMsg();
#if defined(KICAD_AUIMANAGER) #if defined(KICAD_AUIMANAGER)
if(m_auimgr.GetManagedWindow()) if( m_auimgr.GetManagedWindow() )
m_auimgr.Update(); m_auimgr.Update();
#endif #endif
} }
/*************************************/
int WinEDA_GerberFrame::BestZoom() int WinEDA_GerberFrame::BestZoom()
/*************************************/
{ {
double x, y; double x, y;
wxSize size; wxSize size;
...@@ -340,5 +329,5 @@ int WinEDA_GerberFrame::BestZoom() ...@@ -340,5 +329,5 @@ int WinEDA_GerberFrame::BestZoom()
GetScreen()->GetGridSize().y ) / (double) size.y; GetScreen()->GetGridSize().y ) / (double) size.y;
GetScreen()->m_Curseur = GetBoard()->m_BoundaryBox.Centre(); GetScreen()->m_Curseur = GetBoard()->m_BoundaryBox.Centre();
return wxRound( MAX( x, y ) * (double)GetScreen()->m_ZoomScalar ); return wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar );
} }
...@@ -26,7 +26,7 @@ wxString g_PenFilenameExt; ...@@ -26,7 +26,7 @@ wxString g_PenFilenameExt;
int g_DCodesColor; int g_DCodesColor;
int g_Default_GERBER_Format; int g_Default_GERBER_Format;
int g_Plot_Spot_Mini; /* Diametre mini de l'ouverture pour */ int g_Plot_Spot_Mini; /* Diameter of the opening mini-track for GERBER. */
int g_DisplayPolygonsModeSketch; int g_DisplayPolygonsModeSketch;
GERBER* g_GERBER_List[32]; GERBER* g_GERBER_List[32];
...@@ -37,7 +37,7 @@ IMPLEMENT_APP( WinEDA_App ) ...@@ -37,7 +37,7 @@ IMPLEMENT_APP( WinEDA_App )
bool WinEDA_App::OnInit() bool WinEDA_App::OnInit()
{ {
wxFileName fn; wxFileName fn;
WinEDA_GerberFrame* frame = NULL; WinEDA_GerberFrame* frame = NULL;
InitEDA_Appl( wxT( "GerbView" ), APP_TYPE_GERBVIEW ); InitEDA_Appl( wxT( "GerbView" ), APP_TYPE_GERBVIEW );
...@@ -47,9 +47,10 @@ bool WinEDA_App::OnInit() ...@@ -47,9 +47,10 @@ bool WinEDA_App::OnInit()
ActiveScreen = ScreenPcb; ActiveScreen = ScreenPcb;
// read current setup and reopen last directory if no filename to open in command line // read current setup and reopen last directory if no filename to open in
// command line
bool reopenLastUsedDirectory = argc == 1; bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory); GetSettings( reopenLastUsedDirectory );
extern PARAM_CFG_BASE* ParamCfgList[]; extern PARAM_CFG_BASE* ParamCfgList[];
wxGetApp().ReadCurrentSetupValues( ParamCfgList ); wxGetApp().ReadCurrentSetupValues( ParamCfgList );
...@@ -62,25 +63,28 @@ bool WinEDA_App::OnInit() ...@@ -62,25 +63,28 @@ bool WinEDA_App::OnInit()
g_DrawBgColor = BLACK; g_DrawBgColor = BLACK;
Read_Hotkey_Config( frame, false ); /* Must be called before creating the main frame Read_Hotkey_Config( frame, false ); /* Must be called before creating the
* in order to display the real hotkeys * main frame in order to display the
* in menus or tool tips */ * real hotkeys in menus or tool tips
*/
frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ), frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ),
wxPoint( 0, 0 ), wxPoint( 0, 0 ),
wxSize( 600, 400 ) ); wxSize( 600, 400 ) );
/* Gerbview mainframe title */ /* Gerbview mainframe title */
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
frame->SetBoard( new BOARD( NULL, frame ) ); frame->SetBoard( new BOARD( NULL, frame ) );
// Initialize some display options // Initialize some display options
DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning here DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning
DisplayOpt.ShowTrackClearanceMode = 0; // tracks and vias clearance has no meaning here // here
DisplayOpt.ShowTrackClearanceMode = 0; // tracks and vias clearance has no
SetTopWindow( frame ); // Set GerbView mainframe on top // meaning here
frame->Show( TRUE ); // Show GerbView mainframe
frame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame SetTopWindow( frame ); // Set GerbView mainframe on top
frame->Show( TRUE ); // Show GerbView mainframe
frame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame
Read_Config(); Read_Config();
......
/*******************************************************/ /**************/
/* Menu General de Trace (PLOT): Fichier inclus PLOT.H */ /* gerbview.h */
/*******************************************************/ /**************/
#ifndef GERBVIEW_H #ifndef GERBVIEW_H
#define GERBVIEW_H #define GERBVIEW_H
...@@ -12,13 +12,14 @@ ...@@ -12,13 +12,14 @@
class WinEDA_GerberFrame; class WinEDA_GerberFrame;
class BOARD; class BOARD;
// Type d'action du phototraceur: // Type of photoplotter action:
#define GERB_ACTIVE_DRAW 1 // activation de lumiere ( baisser de plume) #define GERB_ACTIVE_DRAW 1 // Activate light (lower pen)
#define GERB_STOP_DRAW 2 // extinction de lumiere ( lever de plume) #define GERB_STOP_DRAW 2 // Extinguish light (lift pen)
#define GERB_FLASH 3 // Flash #define GERB_FLASH 3 // Flash
typedef enum { typedef enum
{
FORMAT_HPGL, FORMAT_HPGL,
FORMAT_GERBER, FORMAT_GERBER,
FORMAT_POST FORMAT_POST
...@@ -32,13 +33,9 @@ extern wxString g_PenFilenameExt; ...@@ -32,13 +33,9 @@ extern wxString g_PenFilenameExt;
extern int g_DCodesColor; extern int g_DCodesColor;
extern int g_Default_GERBER_Format; extern int g_Default_GERBER_Format;
/* Gestion des ouvertures GERBER */ extern int g_Plot_Spot_Mini; /* Diameter of the opening mini-track for
extern int g_Plot_Spot_Mini; /* Diametre mini de l'ouverture pour trace GERBER */ * GERBER */
/*************************************/
/* Constantes utiles en trace GERBER */
/*************************************/
/** /**
* Enum APERTURE_T * Enum APERTURE_T
...@@ -57,7 +54,8 @@ enum APERTURE_T ...@@ -57,7 +54,8 @@ enum APERTURE_T
// Interpolation type // Interpolation type
enum Gerb_Interpolation { enum Gerb_Interpolation
{
GERB_INTERPOL_LINEAR_1X = 0, GERB_INTERPOL_LINEAR_1X = 0,
GERB_INTERPOL_LINEAR_10X, GERB_INTERPOL_LINEAR_10X,
GERB_INTERPOL_LINEAR_01X, GERB_INTERPOL_LINEAR_01X,
...@@ -68,20 +66,21 @@ enum Gerb_Interpolation { ...@@ -68,20 +66,21 @@ enum Gerb_Interpolation {
// Command Type (GCodes) // Command Type (GCodes)
enum Gerb_GCommand { enum Gerb_GCommand
GC_MOVE = 0, {
GC_LINEAR_INTERPOL_1X = 1, GC_MOVE = 0,
GC_CIRCLE_NEG_INTERPOL = 2, GC_LINEAR_INTERPOL_1X = 1,
GC_CIRCLE_POS_INTERPOL = 3, GC_CIRCLE_NEG_INTERPOL = 2,
GC_COMMENT = 4, GC_CIRCLE_POS_INTERPOL = 3,
GC_LINEAR_INTERPOL_10X = 10, GC_COMMENT = 4,
GC_LINEAR_INTERPOL_0P1X = 11, GC_LINEAR_INTERPOL_10X = 10,
GC_LINEAR_INTERPOL_0P01X = 12, GC_LINEAR_INTERPOL_0P1X = 11,
GC_LINEAR_INTERPOL_0P01X = 12,
GC_TURN_ON_POLY_FILL = 36, GC_TURN_ON_POLY_FILL = 36,
GC_TURN_OFF_POLY_FILL = 37, GC_TURN_OFF_POLY_FILL = 37,
GC_SELECT_TOOL = 54, GC_SELECT_TOOL = 54,
GC_PHOTO_MODE = 55, // can starts a D03 flash command: redundant with D03 GC_PHOTO_MODE = 55, // can start a D03 flash command: redundant with D03
GC_SPECIFY_INCHES = 70, GC_SPECIFY_INCHES = 70,
GC_SPECIFY_MILLIMETERS = 71, GC_SPECIFY_MILLIMETERS = 71,
GC_TURN_OFF_360_INTERPOL = 74, GC_TURN_OFF_360_INTERPOL = 74,
GC_TURN_ON_360_INTERPOL = 75, GC_TURN_ON_360_INTERPOL = 75,
...@@ -93,7 +92,8 @@ enum Gerb_GCommand { ...@@ -93,7 +92,8 @@ enum Gerb_GCommand {
#define MAX_TOOLS 2048 #define MAX_TOOLS 2048
#define FIRST_DCODE 10 #define FIRST_DCODE 10
enum Gerb_Analyse_Cmd { enum Gerb_Analyse_Cmd
{
CMD_IDLE = 0, CMD_IDLE = 0,
END_BLOCK, END_BLOCK,
ENTER_RS274X_CMD ENTER_RS274X_CMD
...@@ -104,10 +104,11 @@ class D_CODE; ...@@ -104,10 +104,11 @@ class D_CODE;
/** /**
* Class DCODE_PARAM * Class DCODE_PARAM
* holds a parameter for a DCODE or an "aperture macro" as defined within standard RS274X. * holds a parameter for a DCODE or an "aperture macro" as defined within
* The \a value field can be a constant, i.e. "immediate" parameter or it may not be used * standard RS274X. The \a value field can be a constant, i.e. "immediate"
* if this param is going to defer to the referencing aperture macro. In that case, the * parameter or it may not be used if this param is going to defer to the
* \a index field is an index into the aperture macro's paramters. * referencing aperture macro. In that case, the \a index field is an index
* into the aperture macro's parameters.
*/ */
class DCODE_PARAM class DCODE_PARAM
{ {
...@@ -126,8 +127,8 @@ public: ...@@ -126,8 +127,8 @@ public:
/** /**
* Function IsImmediate * Function IsImmediate
* tests if this DCODE_PARAM holds an immediate parameter or is a pointer into * tests if this DCODE_PARAM holds an immediate parameter or is a pointer
* a parameter held by an owning D_CODE. * into a parameter held by an owning D_CODE.
*/ */
bool IsImmediate() const { return index == -1; } bool IsImmediate() const { return index == -1; }
...@@ -142,8 +143,11 @@ public: ...@@ -142,8 +143,11 @@ public:
} }
private: private:
int index; ///< if -1, then \a value field is an immediate value, else this is an index into parent's D_CODE.m_am_params. int index; ///< if -1, then \a value field is an immediate value,
double value; ///< if IsImmediate()==true then use the value, else not used. // else this is an index into parent's
// D_CODE.m_am_params.
double value; ///< if IsImmediate()==true then use the value, else
// not used.
}; };
...@@ -177,7 +181,8 @@ typedef std::vector<DCODE_PARAM> DCODE_PARAMS; ...@@ -177,7 +181,8 @@ typedef std::vector<DCODE_PARAM> DCODE_PARAMS;
struct AM_PRIMITIVE struct AM_PRIMITIVE
{ {
AM_PRIMITIVE_ID primitive_id; ///< The primitive type AM_PRIMITIVE_ID primitive_id; ///< The primitive type
DCODE_PARAMS params; ///< A sequence of parameters used by the primitive DCODE_PARAMS params; ///< A sequence of parameters used by
// the primitive
/** /**
* Function GetExposure * Function GetExposure
...@@ -186,7 +191,8 @@ struct AM_PRIMITIVE ...@@ -186,7 +191,8 @@ struct AM_PRIMITIVE
*/ */
int GetExposure() const int GetExposure() const
{ {
wxASSERT( params.size() && params[0].IsImmediate() ); // we have no D_CODE* for GetValue() // No D_CODE* for GetValue()
wxASSERT( params.size() && params[0].IsImmediate() );
return (int) params[0].GetValue( NULL ); return (int) params[0].GetValue( NULL );
} }
}; };
...@@ -207,7 +213,8 @@ struct APERTURE_MACRO ...@@ -207,7 +213,8 @@ struct APERTURE_MACRO
/** /**
* Struct APERTURE_MACRO_less_than * Struct APERTURE_MACRO_less_than
* is used by std:set<APERTURE_MACRO> instantiation which uses APERTURE_MACRO.name as its key. * is used by std:set<APERTURE_MACRO> instantiation which uses
* APERTURE_MACRO.name as its key.
*/ */
struct APERTURE_MACRO_less_than struct APERTURE_MACRO_less_than
{ {
...@@ -236,7 +243,8 @@ class D_CODE ...@@ -236,7 +243,8 @@ class D_CODE
{ {
friend class DCODE_PARAM; friend class DCODE_PARAM;
APERTURE_MACRO* m_Macro; ///< no ownership, points to GERBER.m_aperture_macros element APERTURE_MACRO* m_Macro; ///< no ownership, points to
// GERBER.m_aperture_macros element
/** /**
* parameters used only when this D_CODE holds a reference to an aperture * parameters used only when this D_CODE holds a reference to an aperture
...@@ -245,13 +253,13 @@ class D_CODE ...@@ -245,13 +253,13 @@ class D_CODE
DCODE_PARAMS m_am_params; DCODE_PARAMS m_am_params;
public: public:
wxSize m_Size; /* Dimensions horiz et Vert */ wxSize m_Size; /* Horizontal and vertical dimensions. */
APERTURE_T m_Shape; /* shape ( Line, rect , circulaire , ovale .. ) */ APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */
int m_Num_Dcode; /* numero de code ( >= 10 ) */ int m_Num_Dcode; /* D code ( >= 10 ) */
wxSize m_Drill; /* dimension du trou central (s'il existe) */ wxSize m_Drill; /* dimension of the hole (if any) */
int m_DrillShape; /* forme du trou central ( rond = 1, rect = 2 ) */ int m_DrillShape; /* shape of the hole (round = 1, rect = 2) */
bool m_InUse; /* FALSE si non utilis */ bool m_InUse; /* FALSE if not used */
bool m_Defined; /* FALSE si non defini */ bool m_Defined; /* FALSE if not defined */
wxString m_SpecialDescr; wxString m_SpecialDescr;
public: public:
...@@ -310,49 +318,49 @@ inline double DCODE_PARAM::GetValue( const D_CODE* aDcode ) const ...@@ -310,49 +318,49 @@ inline double DCODE_PARAM::GetValue( const D_CODE* aDcode ) const
*/ */
class GERBER class GERBER
{ {
D_CODE* m_Aperture_List[MAX_TOOLS]; ///< Dcode (Aperture) List for this layer D_CODE* m_Aperture_List[MAX_TOOLS]; ///< Dcode (Aperture) List for this layer
bool m_Exposure; ///< whether an aperture macro tool is flashed on or off bool m_Exposure; ///< whether an aperture macro tool is flashed on or off
BOARD* m_Pcb; BOARD* m_Pcb;
public: public:
wxString m_FileName; // Full File Name for this layer wxString m_FileName; // Full File Name for this layer
wxString m_Name; // Layer name wxString m_Name; // Layer name
int m_Layer; // Layer Number int m_Layer; // Layer Number
bool m_LayerNegative; // TRUE = Negative Layer bool m_LayerNegative; // TRUE = Negative Layer
bool m_GerbMetric; // FALSE = Inches, TRUE = metric bool m_GerbMetric; // FALSE = Inches, TRUE = metric
bool m_Relative; // FALSE = absolute Coord, RUE = relative Coord bool m_Relative; // FALSE = absolute Coord, RUE = relative Coord
bool m_NoTrailingZeros; // True: zeros a droite supprims bool m_NoTrailingZeros; // True: remove tailing zeros.
bool m_MirorA; // True: miror / axe A (X) bool m_MirorA; // True: miror / axe A (X)
bool m_MirorB; // True: miror / axe B (Y) bool m_MirorB; // True: miror / axe B (Y)
bool m_Has_DCode; // TRUE = DCodes in file (FALSE = no DCode-> bool m_Has_DCode; // TRUE = DCodes in file (FALSE = no DCode->
// separate DCode file // separate DCode file
wxPoint m_Offset; // Coord Offset wxPoint m_Offset; // Coord Offset
wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4 wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4
wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5 wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5
wxRealPoint m_LayerScale; // scale (X et Y) pour cette layer wxRealPoint m_LayerScale; // scale (X and Y) of layer.
int m_Rotation; int m_Rotation;
int m_Iterpolation; // Linear, 90 arc, Circ. int m_Iterpolation; // Linear, 90 arc, Circ.
bool m_ImageNegative; // TRUE = Negative image bool m_ImageNegative; // TRUE = Negative image
int m_Current_Tool; // Current Tool (Dcode) number selected int m_Current_Tool; // Current Tool (Dcode) number selected
int m_Last_Pen_Command; // Current or last pen state (0..9, set by Dn option with n <10 int m_Last_Pen_Command; // Current or last pen state (0..9, set by Dn option with n <10
int m_CommandState; // donne l'etat de l'analyse des commandes gerber int m_CommandState; // state of gerber analysis command.
wxPoint m_CurrentPos; // current specified coord for plot wxPoint m_CurrentPos; // current specified coord for plot
wxPoint m_PreviousPos; // old current specified coord for plot wxPoint m_PreviousPos; // old current specified coord for plot
wxPoint m_IJPos; // IJ coord (for arcs & circles ) wxPoint m_IJPos; // IJ coord (for arcs & circles )
FILE* m_Current_File; // Current file to read FILE* m_Current_File; // Current file to read
FILE* m_FilesList[12]; // Files list FILE* m_FilesList[12]; // Files list
int m_FilesPtr; // Stack pointer for files list int m_FilesPtr; // Stack pointer for files list
int m_Selected_Tool; // Pour editions: Tool (Dcode) selectionn int m_Selected_Tool; // Pour editions: Tool (Dcode) selectionn
int m_Transform[2][2]; // The rotation/mirror transformation matrix. int m_Transform[2][2]; // The rotation/mirror transformation matrix.
bool m_360Arc_enbl; // Enbl 360 deg circular interpolation bool m_360Arc_enbl; // Enbl 360 deg circular interpolation
bool m_PolygonFillMode; // Enbl polygon mode (read coord as a polygone descr) bool m_PolygonFillMode; // Enbl polygon mode (read coord as a polygon descr)
int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm
APERTURE_MACRO_SET m_aperture_macros; ///< a collection of APERTURE_MACROS, sorted by name APERTURE_MACRO_SET m_aperture_macros; ///< a collection of APERTURE_MACROS, sorted by name
public: public:
GERBER( int layer ); GERBER( int layer );
...@@ -367,7 +375,6 @@ public: ...@@ -367,7 +375,6 @@ public:
*/ */
void InitToolTable(); void InitToolTable();
// Routines utilises en lecture de ficher gerber
wxPoint ReadXYCoord( char*& Text ); wxPoint ReadXYCoord( char*& Text );
wxPoint ReadIJCoord( char*& Text ); wxPoint ReadIJCoord( char*& Text );
int ReturnGCodeNumber( char*& Text ); int ReturnGCodeNumber( char*& Text );
...@@ -391,9 +398,10 @@ public: ...@@ -391,9 +398,10 @@ public:
/** /**
* Function ExecuteRS274XCommand * Function ExecuteRS274XCommand
* executes 1 commande * executes 1 command
*/ */
bool ExecuteRS274XCommand( int command, char aBuff[GERBER_BUFZ], char*& text ); bool ExecuteRS274XCommand( int command, char aBuff[GERBER_BUFZ],
char*& text );
/** /**
...@@ -401,11 +409,13 @@ public: ...@@ -401,11 +409,13 @@ public:
* reads in an aperture macro and saves it in m_aperture_macros. * reads in an aperture macro and saves it in m_aperture_macros.
* @param aBuff a character buffer at least GERBER_BUFZ long that can be * @param aBuff a character buffer at least GERBER_BUFZ long that can be
* used to read successive lines from the gerber file. * used to read successive lines from the gerber file.
* @param text A reference to a character pointer which gives the initial text to read from. * @param text A reference to a character pointer which gives the initial
* text to read from.
* @param gerber_file Which file to read from for continuation. * @param gerber_file Which file to read from for continuation.
* @return bool - true if a macro was read in successfully, else false. * @return bool - true if a macro was read in successfully, else false.
*/ */
bool ReadApertureMacro( char aBuff[GERBER_BUFZ], char*& text, FILE* gerber_file ); bool ReadApertureMacro( char aBuff[GERBER_BUFZ], char*& text,
FILE* gerber_file );
/** /**
...@@ -413,7 +423,8 @@ public: ...@@ -413,7 +423,8 @@ public:
* returns a pointer to the D_CODE within this GERBER for the given * returns a pointer to the D_CODE within this GERBER for the given
* \a aDCODE. * \a aDCODE.
* @param aDCODE The numeric value of the D_CODE to look up. * @param aDCODE The numeric value of the D_CODE to look up.
* @param createIfNoExist If true, then create the D_CODE if it does not exist. * @param createIfNoExist If true, then create the D_CODE if it does not
* exist.
* @return D_CODE* - the one implied by the given \a aDCODE, or NULL * @return D_CODE* - the one implied by the given \a aDCODE, or NULL
* if the requested \a aDCODE is out of range. * if the requested \a aDCODE is out of range.
*/ */
...@@ -423,13 +434,13 @@ public: ...@@ -423,13 +434,13 @@ public:
* Function FindApertureMacro * Function FindApertureMacro
* looks up a previously read in aperture macro. * looks up a previously read in aperture macro.
* @param aLookup A dummy APERTURE_MACRO with [only] the name field set. * @param aLookup A dummy APERTURE_MACRO with [only] the name field set.
* @return APERTURE_MACRO* - the one with a matching name, or NULL if not found. * @return APERTURE_MACRO* - the one with a matching name, or NULL if
* not found.
*/ */
APERTURE_MACRO* FindApertureMacro( const APERTURE_MACRO& aLookup ); APERTURE_MACRO* FindApertureMacro( const APERTURE_MACRO& aLookup );
}; };
/**************/ /**************/
/* rs274x.cpp */ /* rs274x.cpp */
/**************/ /**************/
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
/** gerbview_config.cpp : Gerbview configuration*/ /** gerbview_config.cpp : Gerbview configuration*/
/************************************************/ /************************************************/
/* Functions to handle Gerbview configuration */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
...@@ -27,9 +25,7 @@ const wxString GerbviewProjectFileExt( wxT( "cnf" ) ); ...@@ -27,9 +25,7 @@ const wxString GerbviewProjectFileExt( wxT( "cnf" ) );
const wxString GerbviewProjectFileWildcard( _( "GerbView project files (.cnf)|*.cnf" ) ); const wxString GerbviewProjectFileWildcard( _( "GerbView project files (.cnf)|*.cnf" ) );
/*************************************************************/
void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
/*************************************************************/
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
...@@ -45,7 +41,7 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) ...@@ -45,7 +41,7 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
DisplayColorSetupFrame( this, pos ); DisplayColorSetupFrame( this, pos );
break; break;
case ID_CONFIG_REQ: // Creation de la fenetre de configuration case ID_CONFIG_REQ:
{ {
InstallConfigFrame( pos ); InstallConfigFrame( pos );
break; break;
...@@ -91,7 +87,7 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) ...@@ -91,7 +87,7 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
HandleHotkeyConfigMenuSelection( this, id ); HandleHotkeyConfigMenuSelection( this, id );
break; break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display Current hotkey list for gerbview case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr ); DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr );
break; break;
...@@ -102,22 +98,16 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) ...@@ -102,22 +98,16 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
} }
/*****************************************************/ /* Read configuration, if it has not already read.
bool Read_Config() * 1 - bed gerbview.cnf
/*****************************************************/ * 2 - if no bed is path> gerbview.exe> / gerbview.cnf
* 3 - If not found: init variables to default values
/* lit la configuration, si elle n'a pas deja etee lue
* 1 - lit gerbview.cnf
* 2 - si non trouve lit <chemin de gerbview.exe>/gerbview.cnf
* 3 - si non trouve: init des variables aux valeurs par defaut
*
* Retourne un pointeur su le message d'erreur a afficher
*/ */
bool Read_Config()
{ {
wxGetApp().ReadProjectConfig( wxT( "gerbview.cnf" ), GROUP, ParamCfgList, wxGetApp().ReadProjectConfig( wxT( "gerbview.cnf" ), GROUP, ParamCfgList,
FALSE ); FALSE );
/* Inits autres variables */
if( g_PhotoFilenameExt.IsEmpty() ) if( g_PhotoFilenameExt.IsEmpty() )
g_PhotoFilenameExt = wxT( "pho" ); g_PhotoFilenameExt = wxT( "pho" );
if( g_DrillFilenameExt.IsEmpty() ) if( g_DrillFilenameExt.IsEmpty() )
...@@ -129,13 +119,7 @@ bool Read_Config() ...@@ -129,13 +119,7 @@ bool Read_Config()
} }
/******************************************/
void WinEDA_GerberFrame::Update_config() void WinEDA_GerberFrame::Update_config()
/******************************************/
/*
* creation du fichier de config
*/
{ {
wxFileName fn = wxFileName( wxEmptyString, wxT( "gerbview" ), wxFileName fn = wxFileName( wxEmptyString, wxT( "gerbview" ),
GerbviewProjectFileExt ); GerbviewProjectFileExt );
...@@ -147,21 +131,17 @@ void WinEDA_GerberFrame::Update_config() ...@@ -147,21 +131,17 @@ void WinEDA_GerberFrame::Update_config()
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
/* ecriture de la configuration */
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList ); wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList );
} }
/***************************************************************/
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
/***************************************************************/
/* /*
* Read the hotkey files config for pcbnew and module_edit * Read the hotkey files config for pcbnew and module_edit
*/ */
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
{ {
wxString FullFileName = ReturnHotkeyConfigFilePath( wxString FullFileName =
g_ConfigFileLocationChoice ); ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME; FullFileName += HOTKEY_FILENAME;
FullFileName += wxT("."); FullFileName += wxT(".");
......
/**********************************************************/ /*************************/
/** cfg.h : configuration: definition des structures **/ /** gerberview_config.h **/
/**********************************************************/ /*************************/
#include "param_config.h" #include "param_config.h"
...@@ -13,382 +13,382 @@ ...@@ -13,382 +13,382 @@
static PARAM_CFG_WXSTRING PhotoExtBufCfg static PARAM_CFG_WXSTRING PhotoExtBufCfg
( (
wxT("PhoExt"), /* identification */ wxT("PhoExt"),
&g_PhotoFilenameExt /* Adresse du parametre */ &g_PhotoFilenameExt
); );
static PARAM_CFG_WXSTRING PenExtBufCfg static PARAM_CFG_WXSTRING PenExtBufCfg
( (
wxT("PenExt"), /* identification */ wxT("PenExt"),
&g_PenFilenameExt /* Adresse du parametre */ &g_PenFilenameExt
); );
static PARAM_CFG_WXSTRING DrillExtBufCfg static PARAM_CFG_WXSTRING DrillExtBufCfg
( (
wxT("DrilExt"), /* identification */ wxT("DrilExt"),
&g_DrillFilenameExt /* Adresse du parametre */ &g_DrillFilenameExt
); );
static PARAM_CFG_INT UnitCfg // Unites; 0 inche, 1 mm static PARAM_CFG_INT UnitCfg // Units; 0 inches, 1 mm
( (
wxT("Unite"), /* identification */ wxT("Unite"),
&g_UnitMetric, /* Adresse du parametre */ &g_UnitMetric,
FALSE /* Valeur par defaut */ FALSE
); );
static PARAM_CFG_INT GerberScaleCfg // default scale; 0 2.3, 1 3.4 static PARAM_CFG_INT GerberScaleCfg // default scale; 0 2.3, 1 3.4
( (
wxT("Def_fmt"), /* identification */ wxT("Def_fmt"),
&g_Default_GERBER_Format, /* Adresse du parametre */ &g_Default_GERBER_Format,
23, /* Valeur par defaut */ 23,
23, 66 /* Valeurs extremes */ 23, 66
); );
static PARAM_CFG_BOOL SegmFillCfg static PARAM_CFG_BOOL SegmFillCfg
( (
INSETUP, INSETUP,
wxT("SegFill"), /* identification */ wxT("SegFill"),
&DisplayOpt.DisplayPcbTrackFill, /* Adresse du parametre */ &DisplayOpt.DisplayPcbTrackFill,
TRUE /* Valeur par defaut */ TRUE
); );
static PARAM_CFG_INT PadFillCfg static PARAM_CFG_INT PadFillCfg
( (
INSETUP, INSETUP,
wxT("PadFill"), /* identification */ wxT("PadFill"),
(int*)&DisplayOpt.DisplayPadFill, /* Adresse du parametre */ (int*)&DisplayOpt.DisplayPadFill,
TRUE /* Valeur par defaut */ TRUE
); );
static PARAM_CFG_INT ViaFillCfg static PARAM_CFG_INT ViaFillCfg
( (
INSETUP, INSETUP,
wxT("ViaFill"), /* identification */ wxT("ViaFill"),
(int*)&DisplayOpt.DisplayViaFill, /* Adresse du parametre */ (int*)&DisplayOpt.DisplayViaFill,
TRUE /* Valeur par defaut */ TRUE
); );
static PARAM_CFG_BOOL PadShowNumCfg // Affiche DCodes static PARAM_CFG_BOOL PadShowNumCfg // Show DCodes
( (
INSETUP, INSETUP,
wxT("PadSNum"), /* identification */ wxT("PadSNum"),
&DisplayOpt.DisplayPadNum, /* Adresse du parametre */ &DisplayOpt.DisplayPadNum,
TRUE /* Valeur par defaut */ TRUE
); );
static PARAM_CFG_SETCOLOR ColorLayer0Cfg static PARAM_CFG_SETCOLOR ColorLayer0Cfg
( (
INSETUP, INSETUP,
wxT("ColLay0"), /* identification */ wxT("ColLay0"),
&g_DesignSettings.m_LayerColor[0], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[0],
GREEN /* Valeur par defaut */ GREEN
); );
static PARAM_CFG_SETCOLOR ColorLayer1Cfg static PARAM_CFG_SETCOLOR ColorLayer1Cfg
( (
INSETUP, INSETUP,
wxT("ColLay1"), /* identification */ wxT("ColLay1"),
&g_DesignSettings.m_LayerColor[1], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[1],
BLUE /* Valeur par defaut */ BLUE
); );
static PARAM_CFG_SETCOLOR ColorLayer2Cfg static PARAM_CFG_SETCOLOR ColorLayer2Cfg
( (
INSETUP, INSETUP,
wxT("ColLay2"), /* identification */ wxT("ColLay2"),
&g_DesignSettings.m_LayerColor[2], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[2],
LIGHTGRAY /* Valeur par defaut */ LIGHTGRAY
); );
static PARAM_CFG_SETCOLOR ColorLayer3Cfg static PARAM_CFG_SETCOLOR ColorLayer3Cfg
( (
INSETUP, INSETUP,
wxT("ColLay3"), /* identification */ wxT("ColLay3"),
&g_DesignSettings.m_LayerColor[3], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[3],
5 /* Valeur par defaut */ 5
); );
static PARAM_CFG_SETCOLOR ColorLayer4Cfg static PARAM_CFG_SETCOLOR ColorLayer4Cfg
( (
INSETUP, INSETUP,
wxT("ColLay4"), /* identification */ wxT("ColLay4"),
&g_DesignSettings.m_LayerColor[4], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[4],
4 /* Valeur par defaut */ 4
); );
static PARAM_CFG_SETCOLOR ColorLayer5Cfg static PARAM_CFG_SETCOLOR ColorLayer5Cfg
( (
INSETUP, INSETUP,
wxT("ColLay5"), /* identification */ wxT("ColLay5"),
&g_DesignSettings.m_LayerColor[5], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[5],
5 /* Valeur par defaut */ 5
); );
static PARAM_CFG_SETCOLOR ColorLayer6Cfg static PARAM_CFG_SETCOLOR ColorLayer6Cfg
( (
INSETUP, INSETUP,
wxT("ColLay6"), /* identification */ wxT("ColLay6"),
&g_DesignSettings.m_LayerColor[6], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[6],
6 /* Valeur par defaut */ 6
); );
static PARAM_CFG_SETCOLOR ColorLayer7Cfg static PARAM_CFG_SETCOLOR ColorLayer7Cfg
( (
INSETUP, INSETUP,
wxT("ColLay7"), /* identification */ wxT("ColLay7"),
&g_DesignSettings.m_LayerColor[7], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[7],
5 /* Valeur par defaut */ 5
); );
static PARAM_CFG_SETCOLOR ColorLayer8Cfg static PARAM_CFG_SETCOLOR ColorLayer8Cfg
( (
INSETUP, INSETUP,
wxT("ColLay8"), /* identification */ wxT("ColLay8"),
&g_DesignSettings.m_LayerColor[8], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[8],
7 /* Valeur par defaut */ 7
); );
static PARAM_CFG_SETCOLOR ColorLayer9Cfg static PARAM_CFG_SETCOLOR ColorLayer9Cfg
( (
INSETUP, INSETUP,
wxT("ColLay9"), /* identification */ wxT("ColLay9"),
&g_DesignSettings.m_LayerColor[9], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[9],
1 /* Valeur par defaut */ 1
); );
static PARAM_CFG_SETCOLOR ColorLayer10Cfg static PARAM_CFG_SETCOLOR ColorLayer10Cfg
( (
INSETUP, INSETUP,
wxT("ColLayA"), /* identification */ wxT("ColLayA"),
&g_DesignSettings.m_LayerColor[10], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[10],
2 /* Valeur par defaut */ 2
); );
static PARAM_CFG_SETCOLOR ColorLayer11Cfg static PARAM_CFG_SETCOLOR ColorLayer11Cfg
( (
INSETUP, INSETUP,
wxT("ColLayB"), /* identification */ wxT("ColLayB"),
&g_DesignSettings.m_LayerColor[11], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[11],
3 /* Valeur par defaut */ 3
); );
static PARAM_CFG_SETCOLOR ColorLayer12Cfg static PARAM_CFG_SETCOLOR ColorLayer12Cfg
( (
INSETUP, INSETUP,
wxT("ColLayC"), /* identification */ wxT("ColLayC"),
&g_DesignSettings.m_LayerColor[12], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[12],
12 /* Valeur par defaut */ 12
); );
static PARAM_CFG_SETCOLOR ColorLayer13Cfg static PARAM_CFG_SETCOLOR ColorLayer13Cfg
( (
INSETUP, INSETUP,
wxT("ColLayD"), /* identification */ wxT("ColLayD"),
&g_DesignSettings.m_LayerColor[13], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[13],
13 /* Valeur par defaut */ 13
); );
static PARAM_CFG_SETCOLOR ColorLayer14Cfg static PARAM_CFG_SETCOLOR ColorLayer14Cfg
( (
INSETUP, INSETUP,
wxT("ColLayE"), /* identification */ wxT("ColLayE"),
&g_DesignSettings.m_LayerColor[14], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[14],
14 /* Valeur par defaut */ 14
); );
static PARAM_CFG_SETCOLOR ColorLayer15Cfg static PARAM_CFG_SETCOLOR ColorLayer15Cfg
( (
INSETUP, INSETUP,
wxT("ColLayF"), /* identification */ wxT("ColLayF"),
&g_DesignSettings.m_LayerColor[15], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[15],
RED /* Valeur par defaut */ RED
); );
static PARAM_CFG_SETCOLOR ColorLayer16Cfg static PARAM_CFG_SETCOLOR ColorLayer16Cfg
( (
INSETUP, INSETUP,
wxT("ColLayG"), /* identification */ wxT("ColLayG"),
&g_DesignSettings.m_LayerColor[16], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[16],
1 /* Valeur par defaut */ 1
); );
static PARAM_CFG_SETCOLOR ColorLayer17Cfg static PARAM_CFG_SETCOLOR ColorLayer17Cfg
( (
INSETUP, INSETUP,
wxT("ColLayH"), /* identification */ wxT("ColLayH"),
&g_DesignSettings.m_LayerColor[17], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[17],
5 /* Valeur par defaut */ 5
); );
static PARAM_CFG_SETCOLOR ColorLayer18Cfg static PARAM_CFG_SETCOLOR ColorLayer18Cfg
( (
INSETUP, INSETUP,
wxT("ColLayI"), /* identification */ wxT("ColLayI"),
&g_DesignSettings.m_LayerColor[18], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[18],
11 /* Valeur par defaut */ 11
); );
static PARAM_CFG_SETCOLOR ColorLayer19Cfg static PARAM_CFG_SETCOLOR ColorLayer19Cfg
( (
INSETUP, INSETUP,
wxT("ColLayJ"), /* identification */ wxT("ColLayJ"),
&g_DesignSettings.m_LayerColor[19], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[19],
4 /* Valeur par defaut */ 4
); );
static PARAM_CFG_SETCOLOR ColorLayer20Cfg static PARAM_CFG_SETCOLOR ColorLayer20Cfg
( (
INSETUP, INSETUP,
wxT("ColLayK"), /* identification */ wxT("ColLayK"),
&g_DesignSettings.m_LayerColor[20], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[20],
5 /* Valeur par defaut */ 5
); );
static PARAM_CFG_SETCOLOR ColorLayer21Cfg static PARAM_CFG_SETCOLOR ColorLayer21Cfg
( (
INSETUP, INSETUP,
wxT("ColLayL"), /* identification */ wxT("ColLayL"),
&g_DesignSettings.m_LayerColor[21], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[21],
3 /* Valeur par defaut */ 3
); );
static PARAM_CFG_SETCOLOR ColorLayer22Cfg static PARAM_CFG_SETCOLOR ColorLayer22Cfg
( (
INSETUP, INSETUP,
wxT("ColLayM"), /* identification */ wxT("ColLayM"),
&g_DesignSettings.m_LayerColor[22], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[22],
6 /* Valeur par defaut */ 6
); );
static PARAM_CFG_SETCOLOR ColorLayer23Cfg static PARAM_CFG_SETCOLOR ColorLayer23Cfg
( (
INSETUP, INSETUP,
wxT("ColLayN"), /* identification */ wxT("ColLayN"),
&g_DesignSettings.m_LayerColor[23], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[23],
5 /* Valeur par defaut */ 5
); );
static PARAM_CFG_SETCOLOR ColorLayer24Cfg static PARAM_CFG_SETCOLOR ColorLayer24Cfg
( (
INSETUP, INSETUP,
wxT("ColLayO"), /* identification */ wxT("ColLayO"),
&g_DesignSettings.m_LayerColor[24], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[24],
LIGHTGRAY /* Valeur par defaut */ LIGHTGRAY
); );
static PARAM_CFG_SETCOLOR ColorLayer25Cfg static PARAM_CFG_SETCOLOR ColorLayer25Cfg
( (
INSETUP, INSETUP,
wxT("ColLayP"), /* identification */ wxT("ColLayP"),
&g_DesignSettings.m_LayerColor[25], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[25],
1 /* Valeur par defaut */ 1
); );
static PARAM_CFG_SETCOLOR ColorLayer26Cfg static PARAM_CFG_SETCOLOR ColorLayer26Cfg
( (
INSETUP, INSETUP,
wxT("ColLayQ"), /* identification */ wxT("ColLayQ"),
&g_DesignSettings.m_LayerColor[26], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[26],
2 /* Valeur par defaut */ 2
); );
static PARAM_CFG_SETCOLOR ColorLayer27Cfg static PARAM_CFG_SETCOLOR ColorLayer27Cfg
( (
INSETUP, INSETUP,
wxT("ColLayR"), /* identification */ wxT("ColLayR"),
&g_DesignSettings.m_LayerColor[27], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[27],
14 /* Valeur par defaut */ 14
); );
static PARAM_CFG_SETCOLOR ColorLayer28Cfg static PARAM_CFG_SETCOLOR ColorLayer28Cfg
( (
INSETUP, INSETUP,
wxT("ColLayS"), /* identification */ wxT("ColLayS"),
&g_DesignSettings.m_LayerColor[28], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[28],
YELLOW /* Valeur par defaut */ YELLOW
); );
static PARAM_CFG_SETCOLOR ColorLayer29Cfg static PARAM_CFG_SETCOLOR ColorLayer29Cfg
( (
INSETUP, INSETUP,
wxT("ColLayT"), /* identification */ wxT("ColLayT"),
&g_DesignSettings.m_LayerColor[29], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[29],
13 /* Valeur par defaut */ 13
); );
static PARAM_CFG_SETCOLOR ColorLayer30Cfg static PARAM_CFG_SETCOLOR ColorLayer30Cfg
( (
INSETUP, INSETUP,
wxT("ColLayU"), /* identification */ wxT("ColLayU"),
&g_DesignSettings.m_LayerColor[30], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[30],
14 /* Valeur par defaut */ 14
); );
static PARAM_CFG_SETCOLOR ColorLayer31Cfg static PARAM_CFG_SETCOLOR ColorLayer31Cfg
( (
INSETUP, INSETUP,
wxT("ColLayV"), /* identification */ wxT("ColLayV"),
&g_DesignSettings.m_LayerColor[31], /* Adresse du parametre */ &g_DesignSettings.m_LayerColor[31],
7 /* Valeur par defaut */ 7
); );
static PARAM_CFG_SETCOLOR ColorpcbGrilleCfg static PARAM_CFG_SETCOLOR ColorpcbGrilleCfg
( (
INSETUP, INSETUP,
wxT("CoPcbGr"), /* identification */ wxT("CoPcbGr"),
//@@IMB: Wrong object &g_DesignSettings.m_PcbGridColor, /* Adresse du parametre */ //@@IMB: Wrong object &g_DesignSettings.m_PcbGridColor, /* Adresse du parametre */
&g_GridColor, //@@IMB: This is the real variable. &g_GridColor, //@@IMB: This is the real variable.
DARKGRAY /* Valeur par defaut */ DARKGRAY
); );
static PARAM_CFG_SETCOLOR ColorDCodesCfg static PARAM_CFG_SETCOLOR ColorDCodesCfg
( (
INSETUP, INSETUP,
wxT("CoDCode"), /* identification */ wxT("CoDCode"),
&g_DCodesColor, /* Adresse du parametre */ &g_DCodesColor,
WHITE /* Valeur par defaut */ WHITE
); );
static PARAM_CFG_INT GERBERSpotMiniCfg static PARAM_CFG_INT GERBERSpotMiniCfg
( (
wxT("GERBmin"), /* identification */ wxT("GERBmin"),
&g_Plot_Spot_Mini, /* Adresse du parametre */ &g_Plot_Spot_Mini,
15, /* Valeur par defaut */ 15,
2,0xFFFF /* Valeurs extremes */ 2,0xFFFF
); );
static PARAM_CFG_INT DrawSegmLargeurCfg static PARAM_CFG_INT DrawSegmLargeurCfg
( (
wxT("DrawLar"), /* identification */ wxT("DrawLar"),
&g_DesignSettings.m_DrawSegmentWidth, /* Adresse du parametre */ &g_DesignSettings.m_DrawSegmentWidth,
120, /* Valeur par defaut */ 120,
0,10000 /* Valeurs extremes */ 0,10000
); );
static PARAM_CFG_INT EdgeSegmLargeurCfg static PARAM_CFG_INT EdgeSegmLargeurCfg
( (
wxT("EdgeLar"), /* identification */ wxT("EdgeLar"),
&g_DesignSettings.m_EdgeSegmentWidth, /* Adresse du parametre */ &g_DesignSettings.m_EdgeSegmentWidth,
120, /* Valeur par defaut */ 120,
0,10000 /* Valeurs extremes */ 0,10000
); );
static PARAM_CFG_INT TimeOutCfg static PARAM_CFG_INT TimeOutCfg
( (
wxT("TimeOut"), /* identification */ wxT("TimeOut"),
&g_TimeOut, /* Adresse du parametre */ &g_TimeOut,
600, /* Valeur par defaut */ 600,
0,60000 /* Valeurs extremes */ 0,60000
); );
static PARAM_CFG_BOOL DisplPolairCfg static PARAM_CFG_BOOL DisplPolairCfg
( (
INSETUP, INSETUP,
wxT("DPolair"), /* identification */ wxT("DPolair"),
&DisplayOpt.DisplayPolarCood, /* Adresse du parametre */ &DisplayOpt.DisplayPolarCood,
FALSE /* Valeur par defaut */ FALSE
); );
PARAM_CFG_BASE * ParamCfgList[] = PARAM_CFG_BASE * ParamCfgList[] =
......
/**********************************************/ /****************************************/
/* GERBVIEW : Routines d'initialisation globale */ /******* initpcb.cpp ********************/
/******* Fichier INITPCB.C ********************/ /****************************************/
/**********************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -12,16 +11,8 @@ ...@@ -12,16 +11,8 @@
#include "gerbview.h" #include "gerbview.h"
#include "protos.h" #include "protos.h"
/* Routines Locales */
/********************************************************/
bool WinEDA_GerberFrame::Clear_Pcb( bool query ) bool WinEDA_GerberFrame::Clear_Pcb( bool query )
/********************************************************/
/* Realise les init des pointeurs et variables
* Si Item == NULL, il n'y aura pas de confirmation
*/
{ {
int layer; int layer;
...@@ -30,9 +21,10 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) ...@@ -30,9 +21,10 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
if( query ) if( query )
{ {
if( GetBoard()->m_Drawings || GetBoard()->m_Track || GetBoard()->m_Zone ) if( GetBoard()->m_Drawings || GetBoard()->m_Track
|| GetBoard()->m_Zone )
{ {
if( !IsOK( this, _( "Current Data will be lost ?" ) ) ) if( !IsOK( this, _( "Current data will be lost?" ) ) )
return FALSE; return FALSE;
} }
} }
...@@ -43,21 +35,18 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) ...@@ -43,21 +35,18 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
GetBoard()->m_Zone.DeleteAll(); GetBoard()->m_Zone.DeleteAll();
/* init pointeurs et variables */
for( layer = 0; layer < 32; layer++ ) for( layer = 0; layer < 32; layer++ )
{ {
if( g_GERBER_List[layer] ) if( g_GERBER_List[layer] )
g_GERBER_List[layer]->InitToolTable(); g_GERBER_List[layer]->InitToolTable();
} }
/* remise a 0 ou a une valeur initiale des variables de la structure */
GetBoard()->m_BoundaryBox.SetOrigin( 0, 0 ); GetBoard()->m_BoundaryBox.SetOrigin( 0, 0 );
GetBoard()->m_BoundaryBox.SetSize( 0, 0 ); GetBoard()->m_BoundaryBox.SetSize( 0, 0 );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_NbNodes = 0; GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbNoconnect = 0; GetBoard()->m_NbNoconnect = 0;
/* Init parametres de gestion des ecrans PAD et PCB */
SetBaseScreen( ActiveScreen = ScreenPcb ); SetBaseScreen( ActiveScreen = ScreenPcb );
GetScreen()->Init(); GetScreen()->Init();
...@@ -65,11 +54,9 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) ...@@ -65,11 +54,9 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
} }
/*********************************************************/
void WinEDA_GerberFrame::Erase_Zones( bool query ) void WinEDA_GerberFrame::Erase_Zones( bool query )
/*********************************************************/
{ {
if( query && !IsOK( this, _( "Delete zones ?" ) ) ) if( query && !IsOK( this, _( "Delete zones?" ) ) )
return; return;
GetBoard()->m_Zone.DeleteAll(); GetBoard()->m_Zone.DeleteAll();
...@@ -78,17 +65,15 @@ void WinEDA_GerberFrame::Erase_Zones( bool query ) ...@@ -78,17 +65,15 @@ void WinEDA_GerberFrame::Erase_Zones( bool query )
} }
/************************************************************************/
void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query ) void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query )
/************************************************************************/
{ {
int layer = GetScreen()->m_Active_Layer; int layer = GetScreen()->m_Active_Layer;
if( all_layers ) if( all_layers )
layer = -1; layer = -1;
BOARD_ITEM* next; BOARD_ITEM* next;
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = next ) for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = next )
{ {
next = item->Next(); next = item->Next();
...@@ -103,7 +88,7 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query ) ...@@ -103,7 +88,7 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query )
break; break;
default: default:
DisplayError( this, wxT( "Type Draw inconnu/inattendu" ) ); DisplayError( this, wxT( "Draw type unknown." ) );
break; break;
} }
} }
...@@ -112,24 +97,23 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query ) ...@@ -112,24 +97,23 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query )
} }
/******************************************************************/ /* Delete track segments.
void WinEDA_GerberFrame::Erase_Pistes( int masque_type, bool query ) * masque_type mask options selection:
/******************************************************************/ * SEGM_FIXE, SEGM_AR
* If a bit is 1, segment is not erased.
/* Efface les segments de piste, selon les autorisations affichees
* masque_type = masque des options de selection:
* SEGM_FIXE, SEGM_AR
* Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1
*/ */
void WinEDA_GerberFrame::Erase_Pistes( int masque_type, bool query )
{ {
TRACK* pt_segm; TRACK* pt_segm;
BOARD_ITEM* PtNext; BOARD_ITEM* PtNext;
if( query && !IsOK( this, _( "Delete Tracks?" ) ) ) if( query && !IsOK( this, _( "Delete tracks?" ) ) )
return; return;
/* Marquage des pistes a effacer */ /* Mark tracks to clear. */
for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext ) for( pt_segm = GetBoard()->m_Track;
pt_segm != NULL;
pt_segm = (TRACK*) PtNext )
{ {
PtNext = pt_segm->Next(); PtNext = pt_segm->Next();
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type ) if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
...@@ -141,14 +125,12 @@ void WinEDA_GerberFrame::Erase_Pistes( int masque_type, bool query ) ...@@ -141,14 +125,12 @@ void WinEDA_GerberFrame::Erase_Pistes( int masque_type, bool query )
} }
/*****************************************************************/
void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query ) void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query )
/*****************************************************************/
{ {
BOARD_ITEM* PtStruct; BOARD_ITEM* PtStruct;
BOARD_ITEM* PtNext; BOARD_ITEM* PtNext;
if( query && !IsOK( this, _( "Delete Pcb Texts" ) ) ) if( query && !IsOK( this, _( "Delete pcb text?" ) ) )
return; return;
PtStruct = GetBoard()->m_Drawings; PtStruct = GetBoard()->m_Drawings;
...@@ -163,20 +145,20 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query ) ...@@ -163,20 +145,20 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query )
} }
/*********************************************************/
void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
/*********************************************************/
{ {
int layer = GetScreen()->m_Active_Layer; int layer = GetScreen()->m_Active_Layer;
wxString msg; wxString msg;
msg.Printf( _( "Delete Layer %d" ), layer + 1 ); msg.Printf( _( "Delete layer %d?" ), layer + 1 );
if( query && !IsOK( this, msg ) ) if( query && !IsOK( this, msg ) )
return; return;
/* Delete tracks (spots and lines) */ /* Delete tracks (spots and lines) */
TRACK* PtNext; TRACK* PtNext;
for( TRACK* pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext ) for( TRACK* pt_segm = GetBoard()->m_Track;
pt_segm != NULL;
pt_segm = (TRACK*) PtNext )
{ {
PtNext = pt_segm->Next(); PtNext = pt_segm->Next();
if( pt_segm->GetLayer() != layer ) if( pt_segm->GetLayer() != layer )
...@@ -185,7 +167,7 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) ...@@ -185,7 +167,7 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
} }
/* Delete polygons */ /* Delete polygons */
SEGZONE* Nextzone; SEGZONE* Nextzone;
for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = Nextzone ) for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = Nextzone )
{ {
Nextzone = zone->Next(); Nextzone = zone->Next();
...@@ -193,6 +175,7 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) ...@@ -193,6 +175,7 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
continue; continue;
zone->DeleteStructure(); zone->DeleteStructure();
} }
ScreenPcb->SetModify(); ScreenPcb->SetModify();
ScreenPcb->SetRefreshReq(); ScreenPcb->SetRefreshReq();
} }
/**********************************************/ /****************/
/* Routine de selection de couches pour trace */ /* lay2plot.cpp */
/**********************************************/ /****************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -10,14 +10,8 @@ ...@@ -10,14 +10,8 @@
#include "protos.h" #include "protos.h"
/* Variables locales : */ /* Routine to plot the pcb, by selected layers. */
/* Routines Locales */
/*******************************************************************************/
void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer) void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer)
/*******************************************************************************/
/* routine de trace du pcb, avec selection des couches */
{ {
DISPLAY_OPTIONS save_opt; DISPLAY_OPTIONS save_opt;
TRACK * pt_piste; TRACK * pt_piste;
...@@ -33,16 +27,12 @@ void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer) ...@@ -33,16 +27,12 @@ void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer)
DisplayOpt.DisplayDrawItems = FILLED; DisplayOpt.DisplayDrawItems = FILLED;
DisplayOpt.DisplayZonesMode = 0; DisplayOpt.DisplayZonesMode = 0;
/* trace des pistes */
pt_piste = Pcb->m_Track; pt_piste = Pcb->m_Track;
for( ; pt_piste != NULL ; pt_piste = pt_piste->Next() ) for( ; pt_piste != NULL ; pt_piste = pt_piste->Next() )
{ {
// if( (printmasklayer & ReturnMaskLayer(pt_piste) ) == 0 ) continue; // if( (printmasklayer & ReturnMaskLayer(pt_piste) ) == 0 ) continue;
Trace_Segment(NULL, DC, pt_piste, drawmode); Trace_Segment(NULL, DC, pt_piste, drawmode);
} }
DisplayOpt = save_opt; DisplayOpt = save_opt;
} }
/***************************************************/ /************************************************/
/* Localisation des elements pointes par la souris */ /* Locate items at the current cursor position. */
/***************************************************/ /************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -12,50 +12,48 @@ ...@@ -12,50 +12,48 @@
#include "protos.h" #include "protos.h"
/* variables locales */ int ux0, uy0, dx, dy, spot_cX, spot_cY;
int ux0, uy0, dx, dy, spot_cX, spot_cY; /* Variables utilisees pour
* la localisation des segments */
/* fonctions locales */
static TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ); static TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc );
static TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ); static TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer );
static TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc ); static TRACK* Locate_Pistes( TRACK* start_adresse,
static TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer ); int Layer,
int typeloc );
static TRACK* Locate_Pistes( TRACK* start_adresse,
wxPoint ref,
int Layer );
static DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ); static DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc );
static TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ); static TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc );
static int distance( int seuil ); static int distance( int seuil );
/**/
/* Macro de calcul de la coord de pointage selon le curseur /* Macro for calculating the coordinates of the cursor position.
* (ON/OFF grille) choisi
*/ */
#define SET_REF_POS( ref ) if( typeloc == CURSEUR_ON_GRILLE ) \ #define SET_REF_POS( ref ) if( typeloc == CURSEUR_ON_GRILLE ) \
{ ref = ActiveScreen->m_Curseur; } \ { ref = ActiveScreen->m_Curseur; } \
else { ref = ActiveScreen->m_MousePosition; } else { ref = ActiveScreen->m_MousePosition; }
/*************************************************************/ /* Display the character of the localized STRUCTURE and return a pointer
BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc ) * to it.
/*************************************************************/
/* Fonction de localisation generale
* Affiche les caract de la stucture localis�e et retourne un pointeur
* sur celle-ci
*/ */
BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc )
{ {
TEXTE_PCB* pt_texte_pcb; TEXTE_PCB* pt_texte_pcb;
TRACK* Track, * TrackLocate; TRACK* Track, * TrackLocate;
DRAWSEGMENT* DrawSegm; DRAWSEGMENT* DrawSegm;
int layer; int layer;
/* Localistion des pistes et vias, avec priorite aux vias */ /* Locate tracks and vias, with priority to vias */
layer = GetScreen()->m_Active_Layer; layer = GetScreen()->m_Active_Layer;
Track = Locate_Pistes( GetBoard()->m_Track, -1, typeloc ); Track = Locate_Pistes( GetBoard()->m_Track, -1, typeloc );
if( Track != NULL ) if( Track != NULL )
{ {
TrackLocate = Track; /* Reperage d'une piste ou via */ TrackLocate = Track;
/* recherche de 1 via eventuelle */
while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL ) while( ( TrackLocate = Locate_Pistes( TrackLocate,
layer, typeloc ) ) != NULL )
{ {
Track = TrackLocate; Track = TrackLocate;
if( TrackLocate->Type() == TYPE_VIA ) if( TrackLocate->Type() == TYPE_VIA )
...@@ -68,8 +66,10 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc ) ...@@ -68,8 +66,10 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc )
} }
pt_texte_pcb = Locate_Texte_Pcb( (TEXTE_PCB*) GetBoard()->m_Drawings.GetFirst(), typeloc ); pt_texte_pcb = Locate_Texte_Pcb(
if( pt_texte_pcb ) // texte type PCB localise (TEXTE_PCB*) GetBoard()->m_Drawings.GetFirst(), typeloc );
if( pt_texte_pcb )
{ {
pt_texte_pcb->DisplayInfo( this ); pt_texte_pcb->DisplayInfo( this );
return pt_texte_pcb; return pt_texte_pcb;
...@@ -81,7 +81,8 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc ) ...@@ -81,7 +81,8 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc )
} }
if( ( TrackLocate = Locate_Zone( GetBoard()->m_Zone, if( ( TrackLocate = Locate_Zone( GetBoard()->m_Zone,
GetScreen()->m_Active_Layer, typeloc ) ) != NULL ) GetScreen()->m_Active_Layer,
typeloc ) ) != NULL )
{ {
TrackLocate->DisplayInfo( this ); TrackLocate->DisplayInfo( this );
return TrackLocate; return TrackLocate;
...@@ -92,21 +93,17 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc ) ...@@ -92,21 +93,17 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc )
} }
/********************************************************/ /* Locate of segments of pcb edge or draw as active layer.
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) * Returns:
/********************************************************/ * Pointer to START segment if found
* NULL if nothing found
/* Localisation de segments de contour du type edge pcb ou draw
* (selon couche active)
* Retourne:
* Pointeur sur DEBUT du segment localise
* NULL si rien trouve
*/ */
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc )
{ {
BOARD_ITEM* PtStruct; BOARD_ITEM* PtStruct;
DRAWSEGMENT* pts; DRAWSEGMENT* pts;
wxPoint ref; wxPoint ref;
PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen; PCB_SCREEN* screen = (PCB_SCREEN*) ActiveScreen;
SET_REF_POS( ref ); SET_REF_POS( ref );
...@@ -116,25 +113,27 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) ...@@ -116,25 +113,27 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc )
if( PtStruct->Type() != TYPE_DRAWSEGMENT ) if( PtStruct->Type() != TYPE_DRAWSEGMENT )
continue; continue;
pts = (DRAWSEGMENT*) PtStruct; pts = (DRAWSEGMENT*) PtStruct;
ux0 = pts->m_Start.x; uy0 = pts->m_Start.y; ux0 = pts->m_Start.x;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ uy0 = pts->m_Start.y;
dx = pts->m_End.x - ux0; dy = pts->m_End.y - uy0;
spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; dx = pts->m_End.x - ux0;
dy = pts->m_End.y - uy0;
spot_cX = ref.x - ux0;
spot_cY = ref.y - uy0;
/* detection : */
if( pts->GetLayer() != screen->m_Active_Layer ) if( pts->GetLayer() != screen->m_Active_Layer )
continue; continue;
if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) ) if( ( pts->m_Shape == S_CIRCLE ) || ( pts->m_Shape == S_ARC ) )
{ {
int rayon, dist, StAngle, EndAngle, MouseAngle; int rayon, dist, StAngle, EndAngle, MouseAngle;
rayon = (int) hypot( (double) (dx), (double) (dy) ); rayon = (int) hypot( (double) (dx), (double) (dy) );
dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) ); dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) );
if( abs( rayon - dist ) <= (pts->m_Width / 2) ) if( abs( rayon - dist ) <= ( pts->m_Width / 2 ) )
{ {
if( pts->m_Shape == S_CIRCLE ) if( pts->m_Shape == S_CIRCLE )
return pts; return pts;
/* pour un arc, controle complementaire */
MouseAngle = (int) ArcTangente( spot_cY, spot_cX ); MouseAngle = (int) ArcTangente( spot_cY, spot_cX );
StAngle = (int) ArcTangente( dy, dx ); StAngle = (int) ArcTangente( dy, dx );
EndAngle = StAngle + pts->m_Angle; EndAngle = StAngle + pts->m_Angle;
...@@ -143,7 +142,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) ...@@ -143,7 +142,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc )
{ {
StAngle -= 3600; EndAngle -= 3600; StAngle -= 3600; EndAngle -= 3600;
} }
if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) ) if( ( MouseAngle >= StAngle ) && ( MouseAngle <= EndAngle ) )
return pts; return pts;
} }
} }
...@@ -158,19 +157,13 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) ...@@ -158,19 +157,13 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc )
} }
/****************************************************************************/
/* TRACK *Locate_Pistes(TRACK * start_adresse, int MasqueLayer,int typeloc) */
/* TRACK *Locate_Pistes(TRACK * start_adresse, wxPoint ref, int MasqueLayer)*/
/****************************************************************************/
/* /*
* 1 - routine de localisation du segment de piste pointe par la souris. * 1 - Locate segment of track at current cursor position.
* 2 - routine de localisation du segment de piste pointe par le point * 2 - Locate segment of track point by point.
* ref_pX , ref_pY.r * Ref_pX, ref_pY.r
* *
* La recherche commence a l'adresse start_adresse * The search begins to address start_adresse
*/ */
TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc ) TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc )
{ {
wxPoint ref; wxPoint ref;
...@@ -183,25 +176,28 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc ) ...@@ -183,25 +176,28 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int Layer, int typeloc )
TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer ) TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer )
{ {
TRACK* Track; /* pointeur sur les pistes */ TRACK* Track;
int l_piste; /* demi-largeur de la piste */ int l_piste; /* half-width of the track */
for( Track = start_adresse; Track != NULL; Track = Track->Next() ) for( Track = start_adresse; Track != NULL; Track = Track->Next() )
{ {
if( Track->GetState( BUSY | DELETED ) ) if( Track->GetState( BUSY | DELETED ) )
continue; continue;
/* calcul des coordonnees du segment teste */ /* Calculate coordinates of the test segment. */
l_piste = Track->m_Width >> 1; /* l_piste = demi largeur piste */ l_piste = Track->m_Width >> 1;
ux0 = Track->m_Start.x; uy0 = Track->m_Start.y; /* coord de depart */ ux0 = Track->m_Start.x;
dx = Track->m_End.x; dy = Track->m_End.y; /* coord d'arrivee */ uy0 = Track->m_Start.y;
dx = Track->m_End.x;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ dy = Track->m_End.y;
dx -= ux0; dy -= uy0;
spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; dx -= ux0;
dy -= uy0;
if( Track->Type() == TYPE_VIA ) /* VIA rencontree */ spot_cX = ref.x - ux0;
spot_cY = ref.y - uy0;
if( Track->Type() == TYPE_VIA )
{ {
if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) ) if( ( abs( spot_cX ) <= l_piste ) && ( abs( spot_cY ) <=l_piste ) )
{ {
return Track; return Track;
} }
...@@ -210,7 +206,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer ) ...@@ -210,7 +206,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer )
if( Layer >= 0 ) if( Layer >= 0 )
if( Track->GetLayer() != Layer ) if( Track->GetLayer() != Layer )
continue;/* Segments sur couches differentes */ continue;
if( distance( l_piste ) ) if( distance( l_piste ) )
return Track; return Track;
} }
...@@ -219,22 +215,11 @@ TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer ) ...@@ -219,22 +215,11 @@ TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer )
} }
/****************************************************************/
/* TRACK * Locate_Zone(TRACK * start_adresse, int layer, */
/* int typeloc) */
/* TRACK * Locate_Zone(TRACK * start_adresse,wxPoint ref, int layer) */
/****************************************************************/
/* /*
* 1 - routine de localisation du segment de zone pointe par la souris. * Locate zone area at the cursor position.
* 2 - routine de localisation du segment de zone pointe par le point
* ref_pX , ref_pY.r
*
* Si layer == -1 , le tst de la couche n'est pas fait
* *
* La recherche commence a l'adresse start_adresse * The search begins to address start_adresse
*/ */
TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ) TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc )
{ {
wxPoint ref; wxPoint ref;
...@@ -245,23 +230,30 @@ TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ) ...@@ -245,23 +230,30 @@ TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc )
} }
/*
* Locate zone area at point.
*
* The search begins to address start_adresse
*/
TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ) TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer )
{ {
TRACK* Zone; /* pointeur sur les pistes */ TRACK* Zone;
int l_segm; /* demi-largeur de la piste */ int l_segm;
for( Zone = start_adresse; Zone != NULL; Zone = Zone->Next() ) for( Zone = start_adresse; Zone != NULL; Zone = Zone->Next() )
{ {
/* calcul des coordonnees du segment teste */ l_segm = Zone->m_Width >> 1;
l_segm = Zone->m_Width >> 1; /* l_piste = demi largeur piste */ ux0 = Zone->m_Start.x;
ux0 = Zone->m_Start.x; uy0 = Zone->m_Start.y; /* coord de depart */ uy0 = Zone->m_Start.y;
dx = Zone->m_End.x; dy = Zone->m_End.y; /* coord d'arrivee */ dx = Zone->m_End.x;
dy = Zone->m_End.y;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
dx -= ux0; dy -= uy0; dx -= ux0;
spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; dy -= uy0;
spot_cX = ref.x - ux0;
if( (layer != -1) && (Zone->GetLayer() != layer) ) spot_cY = ref.y - uy0;
if( ( layer != -1 ) && ( Zone->GetLayer() != layer ) )
continue; continue;
if( distance( l_segm ) ) if( distance( l_segm ) )
return Zone; return Zone;
...@@ -271,15 +263,10 @@ TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer ) ...@@ -271,15 +263,10 @@ TRACK* Locate_Zone( TRACK* start_adresse, wxPoint ref, int layer )
} }
/***************************************************************/ /* Location of text on the PCB:
/* TEXTE_PCB * Locate_Texte_Pcb(char * pt_txt_pcb,int typeloc) */ * INPUT: char pointer to the beginning of the search area
/***************************************************************/ * Return: pointer to the text description located.
/* localisation des inscriptions sur le Pcb:
* entree : char pointeur sur le debut de la zone de recherche
* retour : pointeur sur la description du texte localise
*/ */
TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc )
{ {
int angle; int angle;
...@@ -295,14 +282,17 @@ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) ...@@ -295,14 +282,17 @@ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc )
pt_txt_pcb = (TEXTE_PCB*) PtStruct; pt_txt_pcb = (TEXTE_PCB*) PtStruct;
angle = pt_txt_pcb->m_Orient; angle = pt_txt_pcb->m_Orient;
ux0 = pt_txt_pcb->m_Pos.x; uy0 = pt_txt_pcb->m_Pos.y; ux0 = pt_txt_pcb->m_Pos.x;
uy0 = pt_txt_pcb->m_Pos.y;
dx = ( pt_txt_pcb->m_Size.x * pt_txt_pcb->GetLength() ) / 2; dx = ( pt_txt_pcb->m_Size.x * pt_txt_pcb->GetLength() ) / 2;
dy = pt_txt_pcb->m_Size.y / 2; dy = pt_txt_pcb->m_Size.y / 2;
dx *= 13; dx /= 9; /* Facteur de forme des lettres : 13/9 */ dx *= 13;
dx /= 9; /* Character for factor 13/9. */
/* la souris est-elle dans ce rectangle autour du centre */ /* Cursor in the rectangle around the center. */
spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; spot_cX = ref.x - ux0;
spot_cY = ref.y - uy0;
RotatePoint( &spot_cX, &spot_cY, -angle ); RotatePoint( &spot_cX, &spot_cY, -angle );
if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) ) if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) )
return pt_txt_pcb; return pt_txt_pcb;
...@@ -312,155 +302,164 @@ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) ...@@ -312,155 +302,164 @@ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc )
} }
/*****************************/
/* int distance(int seuil) */
/*****************************/
/* /*
* Calcul de la distance du curseur souris a un segment de droite : * Calculate the distance from the cursor to a line segment:
* ( piste, edge, contour module .. * (Track, edge, contour module ..
* retourne: * Returns:
* 0 si distance > seuil * 0 if distance > threshold
* 1 si distance <= seuil * 1 if distance <= threshold
* Variables utilisees ( doivent etre initialisees avant appel , et * Variables used (must be initialized before use, and
* sont ramenees au repere centre sur l'origine du segment) * are brought to the mark center on the origin of the segment)
* dx, dy = coord de l'extremite segment. * dx, dy = coord of extremity segment.
* spot_cX,spot_cY = coord du curseur souris * spot_cX, spot_cY = coord of mouse cursor
* la recherche se fait selon 4 cas: * Search 4 cases:
* segment horizontal * Horizontal segment
* segment vertical * Vertical segment
* segment 45 * Segment 45
* segment quelconque * Any segment
*/ */
int distance( int seuil ) int distance( int seuil )
{ {
int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */ int cXrot, cYrot, segX, segY;
segX, segY; /* coord extremite segment tj >= 0 */ int pointX, pointY;
int pointX, pointY;/* coord point a tester dans repere modifie dans lequel
* segX et segY sont >=0 */
segX = dx; segY = dy; pointX = spot_cX; pointY = spot_cY; segX = dx;
segY = dy;
pointX = spot_cX;
pointY = spot_cY;
/*Recalcul coord pour que le segment soit dans 1er quadrant (coord >= 0)*/ /* Reroute coordinate for the segment in 1st quadrant (coord> = 0). */
if( segX < 0 ) /* mise en >0 par symetrie par rapport a l'axe Y */ if( segX < 0 ) /* Set > 0 if symmetrical about the axis Y. */
{ {
segX = -segX; pointX = -pointX; segX = -segX;
pointX = -pointX;
} }
if( segY < 0 ) /* mise en > 0 par symetrie par rapport a l'axe X */ if( segY < 0 ) /* Set > 0 if symmetrical about the axis X. */
{ {
segY = -segY; pointY = -pointY; segY = -segY;
pointY = -pointY;
} }
if( segY == 0 ) /* piste Horizontale */ if( segY == 0 ) /* Horizontal track. */
{ {
if( abs( pointY ) <= seuil ) if( abs( pointY ) <= seuil )
{ {
if( (pointX >= 0) && (pointX <= segX) ) if( ( pointX >= 0 ) && ( pointX <= segX ) )
return 1; return 1;
/* Etude des extremites : cercle de rayon seuil */
if( (pointX < 0) && (pointX >= -seuil) ) if( ( pointX < 0 ) && ( pointX >= -seuil ) )
{ {
if( ( (pointX * pointX) + (pointY * pointY) ) <= (seuil * seuil) ) if( ( ( pointX * pointX ) + ( pointY * pointY ) ) <=
( seuil * seuil ) )
return 1; return 1;
} }
if( (pointX > segX) && ( pointX <= (segX + seuil) ) ) if( ( pointX > segX ) && ( pointX <= ( segX + seuil ) ) )
{ {
if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <= if( ( ( ( pointX - segX ) * ( pointX - segX ) ) +
(seuil * seuil) ) ( pointY * pointY ) ) <= ( seuil * seuil ) )
return 1; return 1;
} }
} }
} }
else if( segX == 0 ) /* piste verticale */ else if( segX == 0 ) /* Vertical track. */
{ {
if( abs( pointX ) <= seuil ) if( abs( pointX ) <= seuil )
{ {
if( (pointY >= 0 ) && (pointY <= segY) ) if( ( pointY >= 0 ) && ( pointY <= segY ) )
return 1; return 1;
if( (pointY < 0) && (pointY >= -seuil) ) if( ( pointY < 0 ) && ( pointY >= -seuil ) )
{ {
if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) ) if( ( (pointY * pointY ) + ( pointX * pointX ) ) <=
( seuil * seuil ) )
return 1; return 1;
} }
if( (pointY > segY) && ( pointY <= (segY + seuil) ) ) if( ( pointY > segY ) && ( pointY <= ( segY + seuil ) ) )
{ {
if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <= if( ( ( ( pointY - segY ) * ( pointY - segY ) ) +
(seuil * seuil) ) ( pointX * pointX ) ) <= ( seuil * seuil ) )
return 1; return 1;
} }
} }
} }
else if( segX == segY ) /* piste a 45 degre */ else if( segX == segY ) /* 45 degree track. */
{ {
/* on fait tourner les axes de 45 degre. la souris a alors les /* You spin axes of 45 degrees. mouse was then
* coord : x1 = x*cos45 + y*sin45 * coord: x1 = x * y * cos45 + sin45
* y1 = y*cos45 - x*sin45 * y1 = y * cos45 - sin45 x *
* et le segment de piste est alors horizontal. * And the segment of track is horizontal.
* recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 * coord recalculation of the mouse (sin45 = cos45 = .707 = 7 / 10
* remarque : sin ou cos45 = .707, et lors du recalcul des coord * Note: sin or cos45 = .707, and when recalculating coord
* dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois * dX45 and dy45, lect coeff .707 is neglected, dx and dy are both
* trop grands. (c.a.d trop petits) * actually .707
* spot_cX,Y doit etre * par .707 * .707 = 0.5 */ * too big. (security hole too small)
* spot_cX *, Y * must be by .707 * .707 = 0.5
*/
cXrot = (pointX + pointY) >> 1; cXrot = (pointX + pointY) >> 1;
cYrot = (pointY - pointX) >> 1; cYrot = (pointY - pointX) >> 1;
/* recalcul des coord de l'extremite du segment , qui sera vertical /* Recalculate coordinates of extremity segment, which will be vertical
* suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY) * following the orientation of axes on the screen: DX45 = pointx
* et est en fait 1,414 plus grand , et dy45 = 0 */ * (or pointy) and 1.414 is actually greater, and dy45 = 0
*
// seuil doit etre * .707 pour tenir compte du coeff de reduction sur dx,dy * Threshold should be .707 to reflect the difference in coeff dx, dy
*/
seuil *= 7; seuil /= 10; seuil *= 7; seuil /= 10;
if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */ if( abs( cYrot ) <= seuil )
{ {
if( (cXrot >= 0) && (cXrot <= segX) ) if( ( cXrot >= 0 ) && ( cXrot <= segX ) )
return 1; return 1;
/* Etude des extremites : cercle de rayon seuil */ if( ( cXrot < 0 ) && ( cXrot >= -seuil ) )
if( (cXrot < 0) && (cXrot >= -seuil) )
{ {
if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( ( cXrot * cXrot ) + ( cYrot * cYrot ) )
<= ( seuil * seuil ) )
return 1; return 1;
} }
if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) if( ( cXrot > segX ) && ( cXrot <= ( segX + seuil ) ) )
{ {
if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( ( ( cXrot - segX ) * ( cXrot - segX ) ) +
( cYrot * cYrot ) ) <= ( seuil * seuil ) )
return 1; return 1;
} }
} }
} }
else /* orientation quelconque */ else /* Any orientation. */
{ {
/* On fait un changement d'axe (rotation) de facon a ce que le segment /* There is a change of axis (rotation), so that the segment
* de piste soit horizontal dans le nouveau repere */ * track is horizontal in the new reference, */
int angle; int angle;
angle = (int) ( atan2( (double) segY, (double) segX ) * 1800 / M_PI); angle = (int) ( atan2( (double) segY, (double) segX ) * 1800 / M_PI);
cXrot = pointX; cYrot = pointY; cXrot = pointX;
RotatePoint( &cXrot, &cYrot, angle ); /* Rotation du point a tester */ cYrot = pointY;
RotatePoint( &segX, &segY, angle ); /* Rotation du segment */ RotatePoint( &cXrot, &cYrot, angle ); /* Rotate test point. */
RotatePoint( &segX, &segY, angle ); /* Rotate segment. */
/*la piste est Horizontale , par suite des modifs de coordonnes /* The track is horizontal, following the changes to coordinate
* et d'axe, donc segX = longueur du segment */ * axis and, therefore segX = length of segment
*/
if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */ if( abs( cYrot ) <= seuil )
{ {
if( (cXrot >= 0) && (cXrot <= segX) ) if( ( cXrot >= 0 ) && ( cXrot <= segX ) )
return 1; return 1;
/* Etude des extremites : cercle de rayon seuil */
if( (cXrot < 0) && (cXrot >= -seuil) ) if( ( cXrot < 0 ) && ( cXrot >= -seuil ) )
{ {
if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( ( cXrot * cXrot ) + ( cYrot * cYrot ) )
<= ( seuil * seuil ) )
return 1; return 1;
} }
if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) ) if( ( cXrot > segX ) && ( cXrot <= ( segX + seuil ) ) )
{ {
if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) ) if( ( ( ( cXrot - segX ) * ( cXrot - segX ) ) +
( cYrot * cYrot ) ) <= ( seuil * seuil ) )
return 1; return 1;
} }
} }
} }
return 0; return 0;
} }
/******************************************************/ /********************/
/* edit.cpp: fonctions generales de l'edition du PCB */ /* onrightclick.cpp */
/******************************************************/ /********************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -11,27 +11,28 @@ ...@@ -11,27 +11,28 @@
#include "pcbplot.h" #include "pcbplot.h"
#include "protos.h" #include "protos.h"
/********************************************************************************/
bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
/********************************************************************************/
/* Prepare the right-click pullup menu. /* Prepare the right-click pullup menu.
* The menu already has a list of zoom commands. * The menu already has a list of zoom commands.
*/ */
bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu )
{ {
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem(); BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg; wxString msg;
bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive =
(GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu // Do not initiate a start block validation on menu.
DrawPanel->m_CanStartBlock = -1;
// Simple localisation des elements si possible // Simple location of elements where possible.
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) )
{ {
DrawStruct = GerberGeneralLocateAndDisplay(); DrawStruct = GerberGeneralLocateAndDisplay();
} }
// Si commande en cours: affichage fin de commande // If command in progress, end command.
if( m_ID_current_state ) if( m_ID_current_state )
{ {
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
...@@ -46,16 +47,21 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -46,16 +47,21 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
{ {
if( BlockActive ) if( BlockActive )
{ {
PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ) ); PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND,
PopMenu->Append( ID_POPUP_ZOOM_BLOCK, _( "Zoom Block (drag middle mouse)" ) ); _( "Cancel Block" ) );
PopMenu->Append( ID_POPUP_ZOOM_BLOCK,
_( "Zoom Block (drag middle mouse)" ) );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
PopMenu->Append( ID_POPUP_PLACE_BLOCK, _( "Place Block" ) ); PopMenu->Append( ID_POPUP_PLACE_BLOCK, _( "Place Block" ) );
PopMenu->Append( ID_POPUP_COPY_BLOCK, _( "Copy Block (shift mouse)" ) ); PopMenu->Append( ID_POPUP_COPY_BLOCK,
PopMenu->Append( ID_POPUP_DELETE_BLOCK, _( "Delete Block (ctrl + drag mouse)" ) ); _( "Copy Block (shift mouse)" ) );
PopMenu->Append( ID_POPUP_DELETE_BLOCK,
_( "Delete Block (ctrl + drag mouse)" ) );
PopMenu->Append( ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block" ) ); PopMenu->Append( ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block" ) );
} }
else else
PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ) ); PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ) );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
} }
...@@ -63,7 +69,8 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -63,7 +69,8 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
if( BlockActive ) if( BlockActive )
return true; return true;
PopMenu->Append( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, _( "Delete Dcode items" ) ); PopMenu->Append( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
_( "Delete Dcode items" ) );
if( DrawStruct == NULL ) if( DrawStruct == NULL )
return true; return true;
...@@ -81,9 +88,8 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -81,9 +88,8 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
default: default:
msg.Printf( msg.Printf( wxT( "WinEDA_GerberFrame::OnRightClick Error: illegal or unknown DrawType %d" ),
wxT( "WinEDA_GerberFrame::OnRightClick Error: illegal or unknown DrawType %d" ), DrawStruct->Type() );
DrawStruct->Type() );
DisplayError( this, msg ); DisplayError( this, msg );
break; break;
} }
......
/********************************************/ /************************/
/* GERBVIEW - Gestion des Options et Reglages */ /* File options.cpp */
/********************************************/ /************************/
/* File options.cpp */
/* /*
* Set the display options for Gerbview * Set the display options for Gerbview
...@@ -21,13 +19,10 @@ ...@@ -21,13 +19,10 @@
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
/*****************************************************************/
void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event )
/*****************************************************************/
/** Function OnSelectOptionToolbar /** Function OnSelectOptionToolbar
* called to validate current choices * called to validate current choices
*/ */
void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
...@@ -112,7 +107,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -112,7 +107,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event )
default: default:
DisplayError( this, DisplayError( this,
wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error" ) ); wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error" ) );
break; break;
} }
...@@ -120,9 +115,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -120,9 +115,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event )
} }
/******************************************************/
class WinEDA_GerberGeneralOptionsFrame : public wxDialog class WinEDA_GerberGeneralOptionsFrame : public wxDialog
/******************************************************/
{ {
private: private:
...@@ -132,7 +125,6 @@ private: ...@@ -132,7 +125,6 @@ private:
wxRadioBox* m_CursorShape; wxRadioBox* m_CursorShape;
wxRadioBox* m_GerberDefaultScale; wxRadioBox* m_GerberDefaultScale;
// Constructor and destructor
public: public:
WinEDA_GerberGeneralOptionsFrame( WinEDA_BasePcbFrame* parent, WinEDA_GerberGeneralOptionsFrame( WinEDA_BasePcbFrame* parent,
const wxPoint& pos ); const wxPoint& pos );
...@@ -145,25 +137,19 @@ private: ...@@ -145,25 +137,19 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/* Events table for WinEDA_GerberGeneralOptionsFrame */
BEGIN_EVENT_TABLE( WinEDA_GerberGeneralOptionsFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_GerberGeneralOptionsFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_GerberGeneralOptionsFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_GerberGeneralOptionsFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_GerberGeneralOptionsFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_GerberGeneralOptionsFrame::OnCancelClick )
END_EVENT_TABLE() END_EVENT_TABLE()
/**********************************************************************************************/
WinEDA_GerberGeneralOptionsFrame::WinEDA_GerberGeneralOptionsFrame( WinEDA_GerberGeneralOptionsFrame::WinEDA_GerberGeneralOptionsFrame(
WinEDA_BasePcbFrame* parent, WinEDA_BasePcbFrame* parent,
const const wxPoint& framepos ) :
wxPoint& framepos ) :
wxDialog( parent, -1, _( "Gerbview Options" ), wxDialog( parent, -1, _( "Gerbview Options" ),
framepos, wxSize( 300, 240 ), framepos, wxSize( 300, 240 ),
wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT ) wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT )
/**********************************************************************************************/
/** WinEDA_GerberGeneralOptionsFrame Constructor
*/
{ {
m_Parent = parent; m_Parent = parent;
...@@ -228,18 +214,14 @@ WinEDA_GerberGeneralOptionsFrame::WinEDA_GerberGeneralOptionsFrame( ...@@ -228,18 +214,14 @@ WinEDA_GerberGeneralOptionsFrame::WinEDA_GerberGeneralOptionsFrame(
} }
/************************************************************************/
void WinEDA_GerberGeneralOptionsFrame::OnCancelClick( void WinEDA_GerberGeneralOptionsFrame::OnCancelClick(
wxCommandEvent& WXUNUSED(event) ) wxCommandEvent& WXUNUSED(event) )
/************************************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/*****************************************************************************/
void WinEDA_GerberGeneralOptionsFrame::OnOkClick( wxCommandEvent& event ) void WinEDA_GerberGeneralOptionsFrame::OnOkClick( wxCommandEvent& event )
/*****************************************************************************/
{ {
DisplayOpt.DisplayPolarCood = DisplayOpt.DisplayPolarCood =
(m_PolarDisplay->GetSelection() == 0) ? FALSE : TRUE; (m_PolarDisplay->GetSelection() == 0) ? FALSE : TRUE;
...@@ -253,7 +235,7 @@ void WinEDA_GerberGeneralOptionsFrame::OnOkClick( wxCommandEvent& event ) ...@@ -253,7 +235,7 @@ void WinEDA_GerberGeneralOptionsFrame::OnOkClick( wxCommandEvent& event )
/*******************************************/ /*******************************************/
/* Dialog frame to select deisplay options */ /* Dialog frame to select display options */
/*******************************************/ /*******************************************/
class WinEDA_LookFrame : public wxDialog class WinEDA_LookFrame : public wxDialog
{ {
...@@ -261,14 +243,13 @@ private: ...@@ -261,14 +243,13 @@ private:
WinEDA_BasePcbFrame* m_Parent; WinEDA_BasePcbFrame* m_Parent;
wxRadioBox* m_OptDisplayLines; wxRadioBox* m_OptDisplayLines;
wxRadioBox* m_OptDisplayFlashes; wxRadioBox* m_OptDisplayFlashes;
wxRadioBox* m_OptDisplayVias; //@@@@TODO: Does it belong here? wxRadioBox* m_OptDisplayVias; //@@@@TODO: Does it belong here?
wxRadioBox* m_OptDisplayPolygons; wxRadioBox* m_OptDisplayPolygons;
wxCheckBox* m_OptDisplayDCodes; wxCheckBox* m_OptDisplayDCodes;
wxRadioBox* m_OptDisplayDrawings; wxRadioBox* m_OptDisplayDrawings;
public: public:
// Constructor and destructor
WinEDA_LookFrame( WinEDA_BasePcbFrame* parent, const wxPoint& pos ); WinEDA_LookFrame( WinEDA_BasePcbFrame* parent, const wxPoint& pos );
~WinEDA_LookFrame() {}; ~WinEDA_LookFrame() {};
...@@ -279,20 +260,17 @@ private: ...@@ -279,20 +260,17 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/* Construction de la table des evenements pour WinEDA_LookFrame */
BEGIN_EVENT_TABLE( WinEDA_LookFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_LookFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_LookFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_LookFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_LookFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_LookFrame::OnCancelClick )
END_EVENT_TABLE() END_EVENT_TABLE()
/*******************************************************************************/
WinEDA_LookFrame::WinEDA_LookFrame( WinEDA_BasePcbFrame* parent, WinEDA_LookFrame::WinEDA_LookFrame( WinEDA_BasePcbFrame* parent,
const wxPoint& framepos ) : const wxPoint& framepos ) :
wxDialog( parent, -1, _( "Gerbview Draw Options" ), framepos, wxDialog( parent, -1, _( "Gerbview Draw Options" ), framepos,
wxSize( 350, 200 ), wxSize( 350, 200 ),
wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT ) wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT )
/*******************************************************************************/
{ {
m_Parent = parent; m_Parent = parent;
...@@ -362,20 +340,13 @@ WinEDA_LookFrame::WinEDA_LookFrame( WinEDA_BasePcbFrame* parent, ...@@ -362,20 +340,13 @@ WinEDA_LookFrame::WinEDA_LookFrame( WinEDA_BasePcbFrame* parent,
} }
/**************************************************************/
void WinEDA_LookFrame::OnCancelClick( wxCommandEvent& WXUNUSED(event) ) void WinEDA_LookFrame::OnCancelClick( wxCommandEvent& WXUNUSED(event) )
/**************************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/*************************************************************/
void WinEDA_LookFrame::OnOkClick( wxCommandEvent& event ) void WinEDA_LookFrame::OnOkClick( wxCommandEvent& event )
/*************************************************************/
/* Met a jour les options
*/
{ {
if( m_OptDisplayLines->GetSelection() == 1 ) if( m_OptDisplayLines->GetSelection() == 1 )
DisplayOpt.DisplayPcbTrackFill = TRUE; DisplayOpt.DisplayPcbTrackFill = TRUE;
...@@ -412,9 +383,7 @@ void WinEDA_LookFrame::OnOkClick( wxCommandEvent& event ) ...@@ -412,9 +383,7 @@ void WinEDA_LookFrame::OnOkClick( wxCommandEvent& event )
} }
/***************************************************************************/
void WinEDA_GerberFrame::InstallGerberOptionsFrame( const wxPoint& pos, int id ) void WinEDA_GerberFrame::InstallGerberOptionsFrame( const wxPoint& pos, int id )
/***************************************************************************/
{ {
switch( id ) switch( id )
{ {
......
/************************************************/ /***************/
/* Menu General de Trace (PLOT) fichier PLOT.CC */ /* pcbplot.cpp */
/************************************************/ /***************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -15,13 +15,9 @@ ...@@ -15,13 +15,9 @@
PCB_Plot_Options g_pcb_plot_options; PCB_Plot_Options g_pcb_plot_options;
/* variables locale : */ /**************************************************************/
/* void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event) */
/* Routines Locales */ /***************************************************************/
/**************************************************************/
/* void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event) */
/***************************************************************/
void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event) void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event)
{ {
......
...@@ -13,30 +13,32 @@ ...@@ -13,30 +13,32 @@
#define OPTKEY_PRINT_SCALE wxT( "PrintScale" ) #define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
/* Plot Options : */ /* Plot Options : */
struct PCB_Plot_Options { struct PCB_Plot_Options
{
bool Exclude_Edges_Pcb; bool Exclude_Edges_Pcb;
int PlotLine_Width; int PlotLine_Width;
bool Plot_Frame_Ref; // True to plot/print frame references bool Plot_Frame_Ref; // True to plot/print frame references
bool DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask) bool DrawViaOnMaskLayer; // True if vias are drawn on Mask layer
// (ie protected by mask)
int Plot_Mode; int Plot_Mode;
bool Plot_Set_MIROIR; bool Plot_Set_MIROIR;
bool Sel_Rotate_Window; bool Sel_Rotate_Window;
int HPGL_Pen_Num; int HPGL_Pen_Num;
int HPGL_Pen_Speed; int HPGL_Pen_Speed;
int HPGL_Pen_Diam; int HPGL_Pen_Diam;
int HPGL_Pen_Recouvrement; int HPGL_Pen_Recouvrement;
bool HPGL_Org_Centre; // TRUE si en HPGL, l'origine le centre de la feuille bool HPGL_Org_Centre; // TRUE if, HPGL originally the center of the node
int PlotPSColorOpt; // True for color Postscript output int PlotPSColorOpt; // True for color Postscript output
bool Plot_PS_Negative; // True to create a negative board ps plot bool Plot_PS_Negative; // True to create a negative board ps plot
/* Autorisation de trace des divers items en serigraphie */ /* Settings to trace the various items in silkscreen. */
bool Sel_Texte_Reference; bool Sel_Texte_Reference;
bool Sel_Texte_Valeur; bool Sel_Texte_Valeur;
bool Sel_Texte_Divers; bool Sel_Texte_Divers;
bool Sel_Texte_Invisible; bool Sel_Texte_Invisible;
bool PlotPadsOnSilkLayer; bool PlotPadsOnSilkLayer;
bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la /* Plot pads even outside the layer (useful for silkscreen) */
couche ( utile pour serigraphie) */ bool Plot_Pads_All_Layers;
/* id for plot format (see enum PlotFormat in plot_common.h) */ /* id for plot format (see enum PlotFormat in plot_common.h) */
int PlotFormat; int PlotFormat;
...@@ -49,4 +51,3 @@ struct PCB_Plot_Options { ...@@ -49,4 +51,3 @@ struct PCB_Plot_Options {
extern PCB_Plot_Options g_pcb_plot_options; extern PCB_Plot_Options g_pcb_plot_options;
#endif // ifndef PCBPLOT_H #endif // ifndef PCBPLOT_H
/********************************************************/ /**********************/
/**** Routine de lecture et visu d'un fichier GERBER ****/ /**** readgerb.cpp ****/
/********************************************************/ /**********************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -11,121 +11,113 @@ ...@@ -11,121 +11,113 @@
#include "pcbplot.h" #include "pcbplot.h"
#include "protos.h" #include "protos.h"
/* Format Gerber : NOTES : /* Format Gerber: NOTES:
* Fonctions preparatoires: * Functions history:
* Gn = * Gn =
* G01 interpolation lineaire ( trace de droites ) * G01 linear interpolation (right trace)
* G02,G20,G21 Interpolation circulaire , sens trigo < 0 * G02, G20, G21 Circular interpolation, meaning trig <0
* G03,G30,G31 Interpolation circulaire , sens trigo > 0 * G03, G30, G31 Circular interpolation, meaning trigo> 0
* G04 commentaire * G04 review
* G06 Interpolation parabolique * G06 parabolic interpolation
* G07 Interpolation cubique * G07 Cubic Interpolation
* G10 interpolation lineaire ( echelle 10x ) * G10 linear interpolation (scale x10)
* G11 interpolation lineaire ( echelle 0.1x ) * G11 linear interpolation (0.1x range)
* G12 interpolation lineaire ( echelle 0.01x ) * G12 linear interpolation (0.01x scale)
* G52 plot symbole reference par Dnn code * G52 plot symbol reference code by Dnn
* G53 plot symbole reference par Dnn ; symbole tourne de -90 degres * G53 plot symbol reference by Dnn; symbol rotates from -90 degrees
* G54 Selection d'outil * G54 Selection Tool
* G55 Mode exposition photo * G55 Fashion photo exhibition
* G56 plot symbole reference par Dnn A code * G56 plot symbol reference code for DNN
* G57 affiche le symbole reference sur la console * G57 displays the symbol link to the console
* G58 plot et affiche le symbole reference sur la console * G58 plot displays the symbol and link to the console
* G60 interpolation lineaire ( echelle 100x ) * G60 linear interpolation (scale x100)
* G70 Unites = Inches * G70 Units = Inches
* G71 Unites = Millimetres * G71 Units = Millimeters
* G74 supprime interpolation circulaire sur 360 degre, revient a G01 * G74 circular interpolation removes 360 degree, has returned G01
* G75 Active interpolation circulaire sur 360 degre * G75 Active circular interpolation on 360 degree
* G90 Mode Coordonnees absolues * G90 mode absolute coordinates
* G91 Mode Coordonnees Relatives * G91 Fashion Related Contacts
* *
* Coordonnees X,Y * X, Y coordinates
* X,Y sont suivies de + ou - et de m+n chiffres (non separes) * X and Y are followed by + or - and m + n digits (not separated)
* m = partie entiere * m = integer part
* n = partie apres la virgule * n = part after the comma
* formats classiques : m = 2, n = 3 (format 2.3) * Classic formats: m = 2, n = 3 (size 2.3)
* m = 3, n = 4 (format 3.4) * m = 3, n = 4 (size 3.4)
* ex: * eg
* G__ X00345Y-06123 D__* * G__ X00345Y-06123 * D__
* *
* Outils et D_CODES * Tools and D_CODES
* numero d'outil ( identification des formes ) * Tool number (identification of shapes)
* 1 a 99 (classique) * 1 to 99 (Classical)
* 1 a 999 * 1 to 999
* D_CODES: * D_CODES:
* *
* D01 ... D9 = codes d'action: * D01 ... D9 = action codes:
* D01 = activation de lumiere (baisser de plume) lors du d�placement * D01 = activating light (lower pen) when placement
* D02 = extinction de lumiere (lever de plume) lors du d�placement * D02 = light extinction (lift pen) when placement
* D03 = Flash * D03 = Flash
* D09 = VAPE Flash * D09 = VAPE Flash
* D51 = precede par G54 -> Select VAPE * D51 = G54 preceded by -> Select VAPE
* *
* D10 ... D255 = Indentification d'outils ( d'ouvertures ) * D10 ... D255 = Identification Tool (Opening)
* Ne sont pas tj dans l'ordre ( voir tableau dans PCBPLOT.H) * Not in order (see table in PCBPLOT.H)
*/ */
/* Variables locales : */ /* Routine to Read a file D Codes.
* Accepts standard format or ALSPCB
/* Routines Locales */ * A ';' starts a comment.
/* Routine de Lecture d'un fichier de D Codes.
* Accepte format standard ou ALSPCB
* un ';' demarre un commentaire.
* *
* Format Standard: * Standard Format:
* tool, Horiz, Vert, drill, vitesse, acc. ,Type ; [DCODE (commentaire)] * Tool, Horiz, Vert, drill, speed, acc. Type; [dCode (comment)]
* ex: 1, 12, 12, 0, 0, 0, 3 ; D10 * Ex: 1, 12, 12, 0, 0, 0, 3; D10
* *
* Format ALSPCB: * Format: ALSPCB
* Ver , Hor , Type , Tool [,Drill] * Ver, Hor, Type, Tool, [Drill]
* ex: 0.012, 0.012, L , D10 * Eg 0012, 0012, L, D10
* *
* Classe les caract en buf_tmp sous forme de tableau de structures D_CODE. * Rank the characters in buf_tmp tabular structures D_CODE.
* Retourne: * Returns:
* < 0 si erreur: * <0 if error:
* -1 = Fichier non trouve * -1 = File not found
* -2 = Erreur lecture fichier * -2 = Error reading file
* Rang de D_code maxi lu ( nbr de dcodes ) * Rank D_code max lu (nbr of dCode)
* *
* Internal Representation:
* *
* Representation interne: * Lines are represented as standard TRACKS
* * The flash is represented as DRAWSEGMENTS
* Les lignes sont repr�sent�es par des TRACKS standards * - Round or oval: DRAWSEGMENTS
* Les Flash sont repr�sent�es par des DRAWSEGMENTS * - Rectangles DRAWSEGMENTS
* - ronds ou ovales: DRAWSEGMENTS * Reference to the D-CODE is set in the member Getnet()
* - rectangles: DRAWSEGMENTS
* la reference aux D-CODES est plac�e dans le membre GetNet()
*/ */
/********************************************************/ /* Read a gerber file (RS274D gold RS274X format).
* Normal size:
* Imperial
* Absolute
* End of block = *
* CrLf after each command
* G codes BROKE
*/
bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
const wxString& GERBER_FullFileName, const wxString& GERBER_FullFileName,
const wxString& D_Code_FullFileName ) const wxString& D_Code_FullFileName )
/********************************************************/
/* Read a gerber file (RS274D or RS274X format).
* Normal format:
* Imperial
* Absolute
* end of block = *
* CrLf after each command
* G codes repetes
*/
{ {
int G_commande = 0, int G_commande = 0,
D_commande = 0; /* command number for G et D commands (like G04 or D02) */ D_commande = 0; /* command number for G or D commands
* (like G04 or D02) */
char line[GERBER_BUFZ]; char line[GERBER_BUFZ];
wxString msg; wxString msg;
char* text; char* text;
int layer; /* current layer used in gerbview */ int layer; /* current layer used in gerbview */
GERBER* gerber; GERBER* gerber;
wxPoint pos; wxPoint pos;
int error = 0; int error = 0;
layer = GetScreen()->m_Active_Layer; layer = GetScreen()->m_Active_Layer;
...@@ -155,11 +147,11 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, ...@@ -155,11 +147,11 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
wxSetWorkingDirectory( path ); wxSetWorkingDirectory( path );
wxBusyCursor show_wait; wxBusyCursor show_wait;
SetLocaleTo_C_standard( ); SetLocaleTo_C_standard();
while( TRUE ) while( TRUE )
{ {
if( fgets( line, sizeof(line), gerber->m_Current_File ) == NULL ) // E.O.F if( fgets( line, sizeof(line), gerber->m_Current_File ) == NULL )
{ {
if( gerber->m_FilesPtr == 0 ) if( gerber->m_FilesPtr == 0 )
break; break;
...@@ -185,7 +177,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, ...@@ -185,7 +177,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
text++; text++;
break; break;
case '*': // End commande case '*': // End command
gerber->m_CommandState = END_BLOCK; gerber->m_CommandState = END_BLOCK;
text++; text++;
break; break;
...@@ -202,7 +194,8 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, ...@@ -202,7 +194,8 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
gerber->Execute_G_Command( text, G_commande ); gerber->Execute_G_Command( text, G_commande );
break; break;
case 'D': /* Line type Dxx : Tool selection (xx > 0) or command if xx = 0..9*/ case 'D': /* Line type Dxx : Tool selection (xx > 0) or
* command if xx = 0..9 */
D_commande = gerber->ReturnDCodeNumber( text ); D_commande = gerber->ReturnDCodeNumber( text );
gerber->Execute_DCODE_Command( this, DC, text, D_commande ); gerber->Execute_DCODE_Command( this, DC, text, D_commande );
break; break;
...@@ -251,15 +244,16 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, ...@@ -251,15 +244,16 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
if( error ) if( error )
{ {
msg.Printf( _( "%d errors while reading Gerber file [%s]" ), msg.Printf( _( "%d errors while reading Gerber file [%s]" ),
error, GERBER_FullFileName.GetData() ); error, GERBER_FullFileName.GetData() );
DisplayError( this, msg ); DisplayError( this, msg );
} }
fclose( gerber->m_Current_File ); fclose( gerber->m_Current_File );
SetLocaleTo_Default( ); SetLocaleTo_Default();
/* Init DCodes list and perhaps read a DCODES file, /* Init DCodes list and perhaps read a DCODES file,
* if the gerber file is only a RS274D file (without any aperture information) * if the gerber file is only a RS274D file (without any aperture
* information)
*/ */
if( !gerber->m_Has_DCode ) if( !gerber->m_Has_DCode )
{ {
...@@ -272,7 +266,8 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, ...@@ -272,7 +266,8 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
fn = GERBER_FullFileName; fn = GERBER_FullFileName;
fn.SetExt( g_PenFilenameExt ); fn.SetExt( g_PenFilenameExt );
wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ),
GetChars( g_PenFilenameExt ), GetChars( g_PenFilenameExt )); GetChars( g_PenFilenameExt ),
GetChars( g_PenFilenameExt ) );
wildcard += AllFilesWildcard; wildcard += AllFilesWildcard;
wxFileDialog dlg( this, _( "Load GERBER DCODE File" ), wxFileDialog dlg( this, _( "Load GERBER DCODE File" ),
......
/**********************************************/ /***************/
/* GERBVIEW - Gestion des Options et Reglages */ /* reglage.cpp */
/**********************************************/ /***************/
/* Fichier reglage.cpp */
/* /*
* Options for file extensions * Options for file extensions
...@@ -16,13 +14,12 @@ ...@@ -16,13 +14,12 @@
#include "pcbplot.h" #include "pcbplot.h"
#include "protos.h" #include "protos.h"
/***********/
enum { enum
{
ID_SAVE_CFG = 1000 ID_SAVE_CFG = 1000
}; };
/* Routines Locales */
class WinEDA_ConfigFrame : public wxDialog class WinEDA_ConfigFrame : public wxDialog
{ {
...@@ -36,7 +33,6 @@ private: ...@@ -36,7 +33,6 @@ private:
WinEDA_EnterText* TextPhotoExt; WinEDA_EnterText* TextPhotoExt;
WinEDA_EnterText* TextPenExt; WinEDA_EnterText* TextPenExt;
// Constructor and destructor
public: public:
WinEDA_ConfigFrame( WinEDA_GerberFrame* parent, const wxPoint& pos ); WinEDA_ConfigFrame( WinEDA_GerberFrame* parent, const wxPoint& pos );
~WinEDA_ConfigFrame() { }; ~WinEDA_ConfigFrame() { };
...@@ -48,7 +44,8 @@ private: ...@@ -48,7 +44,8 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/* Construction de la table des evenements pour WinEDA_ConfigFrame */
BEGIN_EVENT_TABLE( WinEDA_ConfigFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_ConfigFrame, wxDialog )
EVT_BUTTON( ID_SAVE_CFG, WinEDA_ConfigFrame::SaveCfg ) EVT_BUTTON( ID_SAVE_CFG, WinEDA_ConfigFrame::SaveCfg )
EVT_BUTTON( wxID_OK, WinEDA_ConfigFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_ConfigFrame::OnOkClick )
...@@ -56,14 +53,11 @@ BEGIN_EVENT_TABLE( WinEDA_ConfigFrame, wxDialog ) ...@@ -56,14 +53,11 @@ BEGIN_EVENT_TABLE( WinEDA_ConfigFrame, wxDialog )
END_EVENT_TABLE() END_EVENT_TABLE()
/*****************************************************************/
void WinEDA_GerberFrame::InstallConfigFrame( const wxPoint& pos )
/*****************************************************************/
/** Function InstallConfigFrame /** Function InstallConfigFrame
* install the dialog box to configure some gerbview options * install the dialog box to configure some gerbview options
* manly the default file extensions * mainly the default file extensions
*/ */
void WinEDA_GerberFrame::InstallConfigFrame( const wxPoint& pos )
{ {
WinEDA_ConfigFrame* CfgFrame = new WinEDA_ConfigFrame( this, pos ); WinEDA_ConfigFrame* CfgFrame = new WinEDA_ConfigFrame( this, pos );
...@@ -72,19 +66,17 @@ void WinEDA_GerberFrame::InstallConfigFrame( const wxPoint& pos ) ...@@ -72,19 +66,17 @@ void WinEDA_GerberFrame::InstallConfigFrame( const wxPoint& pos )
} }
/************************************************************/
WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent, WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent,
const wxPoint& framepos ) : const wxPoint& framepos ) :
wxDialog( parent, -1, wxEmptyString, framepos, wxSize( 300, 180 ), wxDialog( parent, -1, wxEmptyString, framepos, wxSize( 300, 180 ),
wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT ) wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT )
/************************************************************/
{ {
const int LEN_EXT = 100; const int LEN_EXT = 100;
wxString title; wxString title;
m_Parent = parent; m_Parent = parent;
/* Shows the config filename currently used : */ /* Shows the config filename currently used : */
title = _( "from " ) + wxGetApp().m_CurrentOptionFile; title = _( "from " ) + wxGetApp().m_CurrentOptionFile;
SetTitle( title ); SetTitle( title );
...@@ -132,9 +124,7 @@ WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent, ...@@ -132,9 +124,7 @@ WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent,
} }
/******************************************************************/
void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) ) void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) )
/******************************************************************/
{ {
g_DrillFilenameExt = TextDrillExt->GetValue(); g_DrillFilenameExt = TextDrillExt->GetValue();
g_PhotoFilenameExt = TextPhotoExt->GetValue(); g_PhotoFilenameExt = TextPhotoExt->GetValue();
...@@ -144,17 +134,13 @@ void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) ) ...@@ -144,17 +134,13 @@ void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) )
} }
/******************************************************************/
void WinEDA_ConfigFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) ) void WinEDA_ConfigFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/******************************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/******************************************************/
void WinEDA_ConfigFrame::SaveCfg( wxCommandEvent& event ) void WinEDA_ConfigFrame::SaveCfg( wxCommandEvent& event )
/******************************************************/
{ {
m_Parent->Update_config(); m_Parent->Update_config();
} }
/********************************************************/ /********************/
/**** Routine de lecture et visu d'un fichier GERBER ****/ /**** rs274d.cpp ****/
/********************************************************/ /********************/
#include "fctsys.h" #include "fctsys.h"
...@@ -14,74 +14,75 @@ ...@@ -14,74 +14,75 @@
#define IsNumber( x ) ( ( ( (x) >= '0' ) && ( (x) <='9' ) ) \ #define IsNumber( x ) ( ( ( (x) >= '0' ) && ( (x) <='9' ) ) \
|| ( (x) == '-' ) || ( (x) == '+' ) || ( (x) == '.' ) ) || ( (x) == '-' ) || ( (x) == '+' ) || ( (x) == '.' ) )
/* Format Gerber : NOTES : /* Format Gerber: NOTES:
* Fonctions preparatoires: * Functions history:
* Gn = * Gn =
* G01 interpolation lineaire ( trace de droites ) * G01 linear interpolation (right trace)
* G02,G20,G21 Interpolation circulaire , sens trigo < 0 * G02, G20, G21 Circular interpolation, meaning trig <0
* G03,G30,G31 Interpolation circulaire , sens trigo > 0 * G03, G30, G31 Circular interpolation, meaning trigo> 0
* G04 commentaire * G04 review
* G06 Interpolation parabolique * G06 parabolic interpolation
* G07 Interpolation cubique * G07 Cubic Interpolation
* G10 interpolation lineaire ( echelle 10x ) * G10 linear interpolation (scale x10)
* G11 interpolation lineaire ( echelle 0.1x ) * G11 linear interpolation (0.1x range)
* G12 interpolation lineaire ( echelle 0.01x ) * G12 linear interpolation (0.01x scale)
* G52 plot symbole reference par Dnn code * G52 plot symbol reference code by Dnn
* G53 plot symbole reference par Dnn ; symbole tourne de -90 degres * G53 plot symbol reference by Dnn; symbol rotates from -90 degrees
* G54 Selection d'outil * G54 Selection Tool
* G55 Mode exposition photo * G55 Fashion photo exhibition
* G56 plot symbole reference par Dnn A code * G56 plot symbol reference code for DNN
* G57 affiche le symbole reference sur la console * G57 displays the symbol link to the console
* G58 plot et affiche le symbole reference sur la console * G58 plot displays the symbol and link to the console
* G60 interpolation lineaire ( echelle 100x ) * G60 linear interpolation (scale x100)
* G70 Unites = Inches * G70 Units = Inches
* G71 Unites = Millimetres * G71 Units = Millimeters
* G74 supprime interpolation circulaire sur 360 degre, revient a G01 * G74 circular interpolation removes 360 degree, has returned G01
* G75 Active interpolation circulaire sur 360 degre * Active G75 circular interpolation on 360 degree
* G90 Mode Coordonnees absolues * G90 mode absolute coordinates
* G91 Mode Coordonnees Relatives * G91 Fashion Related Contacts
* *
* Coordonnees X,Y * X, Y
* X,Y sont suivies de + ou - et de m+n chiffres (non separes) * X and Y are followed by + or - and m + n digits (not separated)
* m = partie entiere * m = integer part
* n = partie apres la virgule * n = part after the comma
* formats classiques : m = 2, n = 3 (format 2.3) * Classic formats: m = 2, n = 3 (size 2.3)
* m = 3, n = 4 (format 3.4) * m = 3, n = 4 (size 3.4)
* ex: * eg
* G__ X00345Y-06123 D__* * G__ X00345Y-06123 * D__
* *
* Outils et D_CODES * Tools and D_CODES
* numero d'outil ( identification des formes ) * Tool number (identification of shapes)
* 1 a 99 (classique) * 1 to 99 (Classical)
* 1 a 999 * 1 to 999
* D_CODES: * D_CODES:
* *
* D01 ... D9 = codes d'action: * D01 ... D9 = action codes:
* D01 = activation de lumiere (baisser de plume) lors du d�placement * D01 = activating light (lower pen) when placement
* D02 = extinction de lumiere (lever de plume) lors du d�placement * D02 = light extinction (lift pen) when placement
* D03 = Flash * D03 = Flash
* D09 = VAPE Flash * D09 = VAPE Flash
* D51 = precede par G54 -> Select VAPE * D51 = G54 preceded by -> Select VAPE
* *
* D10 ... D255 = Indentification d'outils ( d'ouvertures ) * D10 ... D255 = Identification Tool (Opening)
* Ne sont pas tj dans l'ordre ( voir tableau dans PCBPLOT.H) * Not tj in order (see table in PCBPLOT.H)
*/ */
// Type d'action du phototraceur: // Photoplot actions:
#define GERB_ACTIVE_DRAW 1 // activation de lumiere ( baisser de plume) #define GERB_ACTIVE_DRAW 1 // Activate light (lower pen)
#define GERB_STOP_DRAW 2 // extinction de lumiere ( lever de plume) #define GERB_STOP_DRAW 2 // Extinguish light (lift pen)
#define GERB_FLASH 3 // Flash #define GERB_FLASH 3 // Flash
/* Variables locales : */
static wxPoint LastPosition; static wxPoint LastPosition;
/* Local Functions (are lower case since they are private to this source file) */ /* Local Functions (are lower case since they are private to this source file)
**/
/** /**
* Function fillCircularTRACK * Function fillCircularTRACK
* initializes a given TRACK so that it can draw a circle which is not filled and * initializes a given TRACK so that it can draw a circle which is not filled
* and
* has a given pen width (\a aPenWidth ). * has a given pen width (\a aPenWidth ).
* *
* @param aTrack The TRACK to fill in. * @param aTrack The TRACK to fill in.
...@@ -89,7 +90,8 @@ static wxPoint LastPosition; ...@@ -89,7 +90,8 @@ static wxPoint LastPosition;
* @param aLayer The layer index to set into the TRACK * @param aLayer The layer index to set into the TRACK
* @param aPos The center point of the flash * @param aPos The center point of the flash
* @param aDiameter The diameter of the round flash * @param aDiameter The diameter of the round flash
* @param aPenWidth The width of the pen used to draw the circle's circumfrance. * @param aPenWidth The width of the pen used to draw the circle's
* circumference.
* @param isDark True if flash is positive and should use a drawing * @param isDark True if flash is positive and should use a drawing
* color other than the background color, else use the background color * color other than the background color, else use the background color
* when drawing so that an erasure happens. * when drawing so that an erasure happens.
...@@ -260,8 +262,8 @@ static void fillLineTRACK( TRACK* aTrack, ...@@ -260,8 +262,8 @@ static void fillLineTRACK( TRACK* aTrack,
* Function fillArcTRACK * Function fillArcTRACK
* initializes a given TRACK so that it can draw an arc G code. * initializes a given TRACK so that it can draw an arc G code.
* <p> * <p>
* if multiquadrant == true : arc can be 0 to 360 degres * if multiquadrant == true : arc can be 0 to 360 degrees
* and \a rel_center is the center coordiante relative to startpoint. * and \a rel_center is the center coordinate relative to start point.
* <p> * <p>
* if multiquadrant == false arc can be only 0 to 90 deg, * if multiquadrant == false arc can be only 0 to 90 deg,
* and only in the same quadrant : * and only in the same quadrant :
...@@ -276,9 +278,10 @@ static void fillLineTRACK( TRACK* aTrack, ...@@ -276,9 +278,10 @@ static void fillLineTRACK( TRACK* aTrack,
* @param aLayer is the layer index to set into the TRACK * @param aLayer is the layer index to set into the TRACK
* @param aStart is the starting point * @param aStart is the starting point
* @param aEnd is the ending point * @param aEnd is the ending point
* @param rel_center is the center coordiante relative to startpoint, * @param rel_center is the center coordinate relative to start point,
* given in ABSOLUE VALUE and the signe of values x et y de rel_center * given in ABSOLUTE VALUE and the sign of values x et y de rel_center
* must be calculated from the previously given constraint: arc only in the same quadrant. * must be calculated from the previously given constraint: arc only in the
* same quadrant.
* @param aDiameter The diameter of the round flash * @param aDiameter The diameter of the round flash
* @param aWidth is the pen width. * @param aWidth is the pen width.
* @param isDark True if flash is positive and should use a drawing * @param isDark True if flash is positive and should use a drawing
...@@ -314,7 +317,7 @@ static void fillArcTRACK( TRACK* aTrack, int Dcode_index, int aLayer, ...@@ -314,7 +317,7 @@ static void fillArcTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
} }
else else
{ {
center = rel_center; center = rel_center;
delta.x = aEnd.x - aStart.x; delta.x = aEnd.x - aStart.x;
delta.y = aEnd.y - aStart.y; delta.y = aEnd.y - aStart.y;
...@@ -370,20 +373,15 @@ static void fillArcTRACK( TRACK* aTrack, int Dcode_index, int aLayer, ...@@ -370,20 +373,15 @@ static void fillArcTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
} }
/**************************************************/ /* These routines read the text string point from Text.
/* Routines utilis�es en lecture de ficher gerber */ * After use, advanced Text the beginning of the sequence unread
/**************************************************/
/* ces routines lisent la chaine de texte point�e par Text.
* Apres appel, Text pointe le debut de la sequence non lue
*/ */
/***********************************************/
/* Returns the current coord pointed to by Text (XnnnnYmmmm)
*/
wxPoint GERBER::ReadXYCoord( char*& Text ) wxPoint GERBER::ReadXYCoord( char*& Text )
{ {
/***********************************************/
/* Retourne la coord courante pointee par Text (XnnnnYmmmm)
*/
wxPoint pos = m_CurrentPos; wxPoint pos = m_CurrentPos;
int type_coord = 0, current_coord, nbchar; int type_coord = 0, current_coord, nbchar;
bool is_float = false; bool is_float = false;
...@@ -514,14 +512,12 @@ wxPoint GERBER::ReadXYCoord( char*& Text ) ...@@ -514,14 +512,12 @@ wxPoint GERBER::ReadXYCoord( char*& Text )
} }
/************************************************/ /* Returns the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
* These coordinates are relative, so if coordinate is absent, it's value
* defaults to 0
*/
wxPoint GERBER::ReadIJCoord( char*& Text ) wxPoint GERBER::ReadIJCoord( char*& Text )
{ {
/************************************************/
/* Retourne la coord type InnJnn courante pointee par Text (InnnnJmmmm)
* Ces coordonn�es sont relatives, donc si une coord est absente, sa valeur
* par defaut est 0
*/
wxPoint pos( 0, 0 ); wxPoint pos( 0, 0 );
int type_coord = 0, current_coord, nbchar; int type_coord = 0, current_coord, nbchar;
...@@ -638,12 +634,10 @@ wxPoint GERBER::ReadIJCoord( char*& Text ) ...@@ -638,12 +634,10 @@ wxPoint GERBER::ReadIJCoord( char*& Text )
} }
/*****************************************************/ /* Read the Gnn sequence and returns the value nn.
*/
int GERBER::ReturnGCodeNumber( char*& Text ) int GERBER::ReturnGCodeNumber( char*& Text )
{ {
/*****************************************************/
/* Lit la sequence Gnn et retourne la valeur nn
*/
int ii = 0; int ii = 0;
char* text; char* text;
char line[1024]; char line[1024];
...@@ -663,12 +657,10 @@ int GERBER::ReturnGCodeNumber( char*& Text ) ...@@ -663,12 +657,10 @@ int GERBER::ReturnGCodeNumber( char*& Text )
} }
/**************************************************/ /* Get the sequence Dnn and returns the value nn
*/
int GERBER::ReturnDCodeNumber( char*& Text ) int GERBER::ReturnDCodeNumber( char*& Text )
{ {
/**************************************************/
/* Lit la sequence Dnn et retourne la valeur nn
*/
int ii = 0; int ii = 0;
char* text; char* text;
char line[1024]; char line[1024];
...@@ -687,15 +679,14 @@ int GERBER::ReturnDCodeNumber( char*& Text ) ...@@ -687,15 +679,14 @@ int GERBER::ReturnDCodeNumber( char*& Text )
} }
/******************************************************************/
bool GERBER::Execute_G_Command( char*& text, int G_commande ) bool GERBER::Execute_G_Command( char*& text, int G_commande )
{ {
/******************************************************************/
D( printf( "%22s: G_CODE<%d>\n", __func__, G_commande ); ) D( printf( "%22s: G_CODE<%d>\n", __func__, G_commande ); )
switch( G_commande ) switch( G_commande )
{ {
case GC_PHOTO_MODE: // can starts a D03 flash command: redundant, can be safely ignored case GC_PHOTO_MODE: // can starts a D03 flash command: redundant, can
// be safely ignored
break; break;
case GC_LINEAR_INTERPOL_1X: case GC_LINEAR_INTERPOL_1X:
...@@ -757,11 +748,13 @@ bool GERBER::Execute_G_Command( char*& text, int G_commande ) ...@@ -757,11 +748,13 @@ bool GERBER::Execute_G_Command( char*& text, int G_commande )
break; break;
case GC_SPECIFY_ABSOLUES_COORD: case GC_SPECIFY_ABSOLUES_COORD:
m_Relative = false; // false = absolute Coord, RUE = relative Coord m_Relative = false; // false = absolute Coord, RUE = relative
// Coord
break; break;
case GC_SPECIFY_RELATIVEES_COORD: case GC_SPECIFY_RELATIVEES_COORD:
m_Relative = true; // false = absolute Coord, RUE = relative Coord m_Relative = true; // false = absolute Coord, RUE = relative
// Coord
break; break;
case GC_TURN_ON_POLY_FILL: case GC_TURN_ON_POLY_FILL:
...@@ -773,7 +766,7 @@ bool GERBER::Execute_G_Command( char*& text, int G_commande ) ...@@ -773,7 +766,7 @@ bool GERBER::Execute_G_Command( char*& text, int G_commande )
m_PolygonFillModeState = 0; m_PolygonFillModeState = 0;
break; break;
case GC_MOVE: // Non existant case GC_MOVE: // Non existent
default: default:
{ {
wxString msg; msg.Printf( wxT( "G%0.2d command not handled" ), wxString msg; msg.Printf( wxT( "G%0.2d command not handled" ),
...@@ -814,7 +807,7 @@ static int scale( double aCoord, bool isMetric ) ...@@ -814,7 +807,7 @@ static int scale( double aCoord, bool isMetric )
static wxPoint mapPt( double x, double y, bool isMetric ) static wxPoint mapPt( double x, double y, bool isMetric )
{ {
wxPoint ret( scale( x, isMetric ), wxPoint ret( scale( x, isMetric ),
scale( y, isMetric ) ); scale( y, isMetric ) );
return ret; return ret;
} }
...@@ -822,12 +815,14 @@ static wxPoint mapPt( double x, double y, bool isMetric ) ...@@ -822,12 +815,14 @@ static wxPoint mapPt( double x, double y, bool isMetric )
/** /**
* Function mapExposure * Function mapExposure
* translates the first parameter from an aperture macro into a current exposure * translates the first parameter from an aperture macro into a current
* exposure
* setting. * setting.
* @param curExposure A dynamic setting which can change throughout the * @param curExposure A dynamic setting which can change throughout the
* reading of the gerber file, and it indicates whether the current tool * reading of the gerber file, and it indicates whether the current tool
* is lit or not. * is lit or not.
* @param isNegative A dynamic setting which can change throughout the reading of * @param isNegative A dynamic setting which can change throughout the reading
* of
* the gerber file, and it indicates whether the current D codes are to * the gerber file, and it indicates whether the current D codes are to
* be interpreted as erasures or not. * be interpreted as erasures or not.
*/ */
...@@ -854,11 +849,9 @@ static bool mapExposure( int param1, bool curExposure, bool isNegative ) ...@@ -854,11 +849,9 @@ static bool mapExposure( int param1, bool curExposure, bool isNegative )
} }
/*****************************************************************************/
bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
char*& text, int D_commande ) char*& text, int D_commande )
{ {
/*****************************************************************************/
wxSize size( 15, 15 ); wxSize size( 15, 15 );
APERTURE_T aperture = APT_CIRCLE; APERTURE_T aperture = APT_CIRCLE;
...@@ -878,7 +871,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -878,7 +871,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
if( D_commande > (MAX_TOOLS - 1) ) if( D_commande > (MAX_TOOLS - 1) )
D_commande = MAX_TOOLS - 1; D_commande = MAX_TOOLS - 1;
// remember which tool is selected, nothing is done with it in this call // remember which tool is selected, nothing is done with it in this
// call
m_Current_Tool = D_commande; m_Current_Tool = D_commande;
D_CODE* pt_Dcode = GetDCODE( D_commande, false ); D_CODE* pt_Dcode = GetDCODE( D_commande, false );
...@@ -887,7 +881,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -887,7 +881,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
return true; return true;
} }
else // D_commande = 0..9: this is a pen command (usualy D1, D2 or D3) else // D_commande = 0..9: this is a pen command (usually D1, D2 or D3)
{ {
m_Last_Pen_Command = D_commande; m_Last_Pen_Command = D_commande;
} }
...@@ -916,7 +910,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -916,7 +910,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
edge_poly->SetNet( m_PolygonFillModeState ); edge_poly->SetNet( m_PolygonFillModeState );
// the first track of each polygon has a netcode of zero, // the first track of each polygon has a netcode of zero,
// otherwise one. Sset the erasure flag in that special track, // otherwise one. Set the erasure flag in that special track,
// if a negative polygon. // if a negative polygon.
if( !m_PolygonFillModeState ) if( !m_PolygonFillModeState )
{ {
...@@ -977,7 +971,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -977,7 +971,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
D( printf( "R:%p\n", track ); ) D( printf( "R:%p\n", track ); )
fillArcTRACK( track, dcode, activeLayer, m_PreviousPos, fillArcTRACK( track, dcode, activeLayer, m_PreviousPos,
m_CurrentPos, m_IJPos, size.x, m_CurrentPos, m_IJPos, size.x,
( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? ( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ?
false : true, m_360Arc_enbl, false : true, m_360Arc_enbl,
!(m_LayerNegative ^ m_ImageNegative) ); !(m_LayerNegative ^ m_ImageNegative) );
...@@ -1009,7 +1003,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1009,7 +1003,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
switch( aperture ) switch( aperture )
{ {
case APT_LINE: // APT_LINE is not in the spec, don't know why it's here case APT_LINE: // APT_LINE is not in the spec, don't know why it's
// here
case APT_CIRCLE: case APT_CIRCLE:
track = new TRACK( pcb ); track = new TRACK( pcb );
pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
...@@ -1036,7 +1031,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1036,7 +1031,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
APERTURE_MACRO* macro = tool->GetMacro(); APERTURE_MACRO* macro = tool->GetMacro();
wxASSERT( macro ); wxASSERT( macro );
// split the macro primitives up into multiple normal TRACK elements // split the macro primitives up into multiple normal TRACK
// elements
for( AM_PRIMITIVES::iterator p = macro->primitives.begin(); for( AM_PRIMITIVES::iterator p = macro->primitives.begin();
p!=macro->primitives.end(); p!=macro->primitives.end();
++p ) ++p )
...@@ -1050,9 +1046,9 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1050,9 +1046,9 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
{ {
exposure = mapExposure( p->GetExposure(), m_Exposure, exposure = mapExposure( p->GetExposure(), m_Exposure,
m_ImageNegative ); m_ImageNegative );
curPos += mapPt( p->params[2].GetValue( tool ), curPos += mapPt( p->params[2].GetValue( tool ),
p->params[3].GetValue( tool ), p->params[3].GetValue( tool ),
m_GerbMetric ); m_GerbMetric );
int diameter = scale( p->params[1].GetValue( tool ), int diameter = scale( p->params[1].GetValue( tool ),
m_GerbMetric ); m_GerbMetric );
...@@ -1074,9 +1070,9 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1074,9 +1070,9 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
wxPoint start = mapPt( p->params[2].GetValue( tool ), wxPoint start = mapPt( p->params[2].GetValue( tool ),
p->params[3].GetValue( tool ), p->params[3].GetValue( tool ),
m_GerbMetric ); m_GerbMetric );
wxPoint end = mapPt( p->params[4].GetValue( tool ), wxPoint end = mapPt( p->params[4].GetValue( tool ),
p->params[5].GetValue( tool ), p->params[5].GetValue( tool ),
m_GerbMetric ); m_GerbMetric );
if( start.x == end.x ) if( start.x == end.x )
{ {
...@@ -1089,8 +1085,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1089,8 +1085,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
size.y = width; size.y = width;
} }
wxPoint midPoint( (start.x + end.x) / 2, wxPoint midPoint( ( start.x + end.x ) / 2,
(start.y + end.y) / 2 ); ( start.y + end.y ) / 2 );
curPos += midPoint; curPos += midPoint;
track = new TRACK( pcb ); track = new TRACK( pcb );
pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
...@@ -1113,7 +1109,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1113,7 +1109,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
curPos += mapPt( p->params[3].GetValue( tool ), curPos += mapPt( p->params[3].GetValue( tool ),
p->params[4].GetValue( tool ), p->params[4].GetValue( tool ),
m_GerbMetric ); m_GerbMetric );
track = new TRACK( pcb ); track = new TRACK( pcb );
pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
D( printf( "R:%p\n", track ); ) D( printf( "R:%p\n", track ); )
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
...@@ -1164,14 +1160,14 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1164,14 +1160,14 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
D( printf( "R:%p\n", track ); ) D( printf( "R:%p\n", track ); )
fillRoundFlashTRACK( track, dcode, activeLayer, fillRoundFlashTRACK( track, dcode, activeLayer,
curPos, outerDiam, curPos, outerDiam,
!(m_LayerNegative ^ m_ImageNegative) ); !( m_LayerNegative ^ m_ImageNegative ) );
track = new TRACK( pcb ); track = new TRACK( pcb );
pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
D( printf( "R:%p\n", track ); ) D( printf( "R:%p\n", track ); )
fillRoundFlashTRACK( track, dcode, activeLayer, curPos, fillRoundFlashTRACK( track, dcode, activeLayer, curPos,
innerDiam, innerDiam,
(m_LayerNegative ^ m_ImageNegative) ); ( m_LayerNegative ^ m_ImageNegative ) );
// @todo: draw the cross hairs, see page 23 of rs274 // @todo: draw the cross hairs, see page 23 of rs274
// spec. this might be done with two lines, thickness // spec. this might be done with two lines, thickness
...@@ -1187,21 +1183,21 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1187,21 +1183,21 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
m_GerbMetric ); m_GerbMetric );
// e.g.: "6,0,0,0.125,.01,0.01,3,0.003,0.150,0" // e.g.: "6,0,0,0.125,.01,0.01,3,0.003,0.150,0"
int outerDiam = scale( p->params[2].GetValue( tool ), int outerDiam = scale( p->params[2].GetValue( tool ),
m_GerbMetric ); m_GerbMetric );
int penThickness = scale( p->params[3].GetValue( tool ), int penThickness = scale( p->params[3].GetValue( tool ),
m_GerbMetric ); m_GerbMetric );
int gap = scale( p->params[4].GetValue( tool ), int gap = scale( p->params[4].GetValue( tool ),
m_GerbMetric ); m_GerbMetric );
int numCircles = (int)p->params[5].GetValue( tool ); int numCircles = (int) p->params[5].GetValue( tool );
int crossHairThickness = int crossHairThickness =
scale( p->params[6].GetValue( tool ), m_GerbMetric ); scale( p->params[6].GetValue( tool ), m_GerbMetric );
int crossHairLength = int crossHairLength =
scale( p->params[7].GetValue( tool ), m_GerbMetric ); scale( p->params[7].GetValue( tool ), m_GerbMetric );
// ignore rotation, not supported // ignore rotation, not supported
// adjust outerDiam by this on each nested circle
int diamAdjust = 2 * (gap + penThickness); // adjust outerDiam by this on each nested circle int diamAdjust = 2 * (gap + penThickness);
for( int i = 0; for( int i = 0;
i < numCircles; i < numCircles;
++i, outerDiam -= diamAdjust ) ++i, outerDiam -= diamAdjust )
...@@ -1212,19 +1208,18 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1212,19 +1208,18 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
fillCircularTRACK( track, dcode, activeLayer, fillCircularTRACK( track, dcode, activeLayer,
curPos, outerDiam, curPos, outerDiam,
penThickness, penThickness,
!(m_LayerNegative ^ m_ImageNegative) ); !( m_LayerNegative ^ m_ImageNegative ) );
} }
track = new TRACK( pcb ); track = new TRACK( pcb );
pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
D( printf( "R:%p\n", track ); ) D( printf( "R:%p\n", track ); )
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, curPos,
wxSize( crossHairThickness, wxSize( crossHairThickness,
crossHairLength ), crossHairLength ),
S_SPOT_RECT, S_SPOT_RECT,
!(m_LayerNegative ^ !( m_LayerNegative ^ m_ImageNegative ) );
m_ImageNegative) );
track = new TRACK( pcb ); track = new TRACK( pcb );
pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
...@@ -1232,12 +1227,11 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1232,12 +1227,11 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
// swap x and y in wxSize() for this one // swap x and y in wxSize() for this one
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, curPos,
wxSize( crossHairLength, wxSize( crossHairLength,
crossHairThickness ), crossHairThickness ),
S_SPOT_RECT, S_SPOT_RECT,
!(m_LayerNegative ^ !( m_LayerNegative ^ m_ImageNegative ) );
m_ImageNegative) );
} }
break; break;
......
/********************************************************/ /**************/
/* Routine de lecture d'un fichier GERBER format RS274X */ /* rs274x.cpp */
/********************************************************/ /**************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -20,9 +20,9 @@ enum RS274X_PARAMETERS { ...@@ -20,9 +20,9 @@ enum RS274X_PARAMETERS {
INCH = CODE( 'I', 'N' ), INCH = CODE( 'I', 'N' ),
MILLIMETER = CODE( 'M', 'M' ), MILLIMETER = CODE( 'M', 'M' ),
OFFSET = CODE( 'O', 'F' ), OFFSET = CODE( 'O', 'F' ),
SCALE_FACTOR = CODE( 'S', 'F' ), SCALE_FACTOR = CODE( 'S', 'F' ),
IMAGE_NAME = CODE( 'I', 'N' ), IMAGE_NAME = CODE( 'I', 'N' ),
IMAGE_JUSTIFY = CODE( 'I', 'J' ), IMAGE_JUSTIFY = CODE( 'I', 'J' ),
IMAGE_OFFSET = CODE( 'I', 'O' ), IMAGE_OFFSET = CODE( 'I', 'O' ),
IMAGE_POLARITY = CODE( 'I', 'P' ), IMAGE_POLARITY = CODE( 'I', 'P' ),
...@@ -41,9 +41,6 @@ enum RS274X_PARAMETERS { ...@@ -41,9 +41,6 @@ enum RS274X_PARAMETERS {
}; };
/* Local Functions */
/** /**
* Function ReadXCommand * Function ReadXCommand
* reads in two bytes of data and assembles them into an int with the first * reads in two bytes of data and assembles them into an int with the first
...@@ -109,11 +106,9 @@ static double ReadDouble( char*& text ) ...@@ -109,11 +106,9 @@ static double ReadDouble( char*& text )
} }
/****************************************************************************/
bool GERBER::ReadRS274XCommand( WinEDA_GerberFrame* frame, wxDC* DC, bool GERBER::ReadRS274XCommand( WinEDA_GerberFrame* frame, wxDC* DC,
char buff[GERBER_BUFZ], char*& text ) char buff[GERBER_BUFZ], char*& text )
{ {
/****************************************************************************/
bool ok = true; bool ok = true;
int code_command; int code_command;
...@@ -165,12 +160,10 @@ exit: ...@@ -165,12 +160,10 @@ exit:
} }
/*******************************************************************************/
bool GERBER::ExecuteRS274XCommand( int command, bool GERBER::ExecuteRS274XCommand( int command,
char buff[GERBER_BUFZ], char buff[GERBER_BUFZ],
char*& text ) char*& text )
{ {
/*******************************************************************************/
int code; int code;
int xy_seq_len, xy_seq_char; int xy_seq_len, xy_seq_char;
bool ok = TRUE; bool ok = TRUE;
...@@ -206,17 +199,18 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -206,17 +199,18 @@ bool GERBER::ExecuteRS274XCommand( int command,
text++; text++;
break; break;
case 'A': // Absolute coord case 'A': // Absolute coord
m_Relative = FALSE; m_Relative = FALSE;
text++; text++;
break; break;
case 'I': // Absolute coord case 'I': // Absolute coord
m_Relative = TRUE; m_Relative = TRUE;
text++; text++;
break; break;
case 'N': // Sequence code (followed by the number of digits for the X,Y command case 'N': // Sequence code (followed by the number of digits
// for the X,Y command
text++; text++;
xy_seq_char = *text++; xy_seq_char = *text++;
if( (xy_seq_char >= '0') && (xy_seq_char <= '9') ) if( (xy_seq_char >= '0') && (xy_seq_char <= '9') )
...@@ -224,14 +218,16 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -224,14 +218,16 @@ bool GERBER::ExecuteRS274XCommand( int command,
break; break;
case 'X': case 'X':
case 'Y': // Valeurs transmises :2 (really xy_seq_len : FIX ME) digits case 'Y': // Values transmitted :2 (really xy_seq_len : FIX
// ME) digits
{ {
code = *(text++); code = *(text++);
char ctmp = *(text++) - '0'; char ctmp = *(text++) - '0';
if( code == 'X' ) if( code == 'X' )
{ {
m_FmtScale.x = *text - '0'; // = nb chiffres apres la virgule // number of digits after the decimal point
m_FmtLen.x = ctmp + m_FmtScale.x; // = nb total de chiffres m_FmtScale.x = *text - '0';
m_FmtLen.x = ctmp + m_FmtScale.x;
} }
else else
{ {
...@@ -275,13 +271,13 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -275,13 +271,13 @@ bool GERBER::ExecuteRS274XCommand( int command,
{ {
switch( *text ) switch( *text )
{ {
case 'A': // A axis offset in current unit (inch ou mm) case 'A': // A axis offset in current unit (inch or mm)
text++; text++;
fcoord = ReadDouble( text ); fcoord = ReadDouble( text );
m_Offset.x = wxRound( fcoord * conv_scale ); m_Offset.x = wxRound( fcoord * conv_scale );
break; break;
case 'B': // B axis offset in current unit (inch ou mm) case 'B': // B axis offset in current unit (inch or mm)
text++; text++;
fcoord = ReadDouble( text ); fcoord = ReadDouble( text );
m_Offset.y = wxRound( fcoord * conv_scale ); m_Offset.y = wxRound( fcoord * conv_scale );
...@@ -348,7 +344,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -348,7 +344,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
if( m_Current_File == 0 ) if( m_Current_File == 0 )
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "fichier <%s> non trouve" ), line ); msg.Printf( wxT( "file <%s> not found." ), line );
DisplayError( NULL, msg, 10 ); DisplayError( NULL, msg, 10 );
ok = FALSE; ok = FALSE;
m_Current_File = m_FilesList[m_FilesPtr]; m_Current_File = m_FilesList[m_FilesPtr];
...@@ -393,7 +389,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -393,7 +389,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
text += 2; // skip "C," for example text += 2; // skip "C," for example
dcode->m_Size.x = dcode->m_Size.y = dcode->m_Size.x = dcode->m_Size.y =
wxRound( ReadDouble( text ) * conv_scale ); wxRound( ReadDouble( text ) * conv_scale );
switch( stdAperture ) switch( stdAperture )
{ {
...@@ -493,7 +489,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -493,7 +489,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
{ {
// @todo not found, don't know how to report an error // @todo not found, don't know how to report an error
D( printf( "aperture macro %s not found\n", D( printf( "aperture macro %s not found\n",
CONV_TO_UTF8( am_lookup.name ) ); ) CONV_TO_UTF8( am_lookup.name ) ); )
ok = false; ok = false;
break; break;
} }
...@@ -514,10 +510,8 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -514,10 +510,8 @@ bool GERBER::ExecuteRS274XCommand( int command,
} }
/*****************************************************************/
bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file ) bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file )
{ {
/*****************************************************************/
for( ; ; ) for( ; ; )
{ {
while( (text < buff + GERBER_BUFZ) && *text ) while( (text < buff + GERBER_BUFZ) && *text )
...@@ -541,12 +535,10 @@ bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file ) ...@@ -541,12 +535,10 @@ bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file )
} }
/*******************************************************************/
bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
char*& text, char*& text,
FILE* gerber_file ) FILE* gerber_file )
{ {
/*******************************************************************/
APERTURE_MACRO am; APERTURE_MACRO am;
// read macro name // read macro name
...@@ -633,7 +625,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -633,7 +625,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
} }
int i; int i;
for( i = 0; i < paramCount && *text && *text != '*'; ++i ) for( i = 0; i < paramCount && *text && *text != '*'; ++i )
{ {
prim.params.push_back( DCODE_PARAM() ); prim.params.push_back( DCODE_PARAM() );
...@@ -648,7 +640,8 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -648,7 +640,8 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
param.SetValue( ReadDouble( text ) ); param.SetValue( ReadDouble( text ) );
} }
if( i < paramCount ) // maybe some day we can throw an exception and track a line number if( i < paramCount ) // maybe some day we can throw an exception and
// track a line number
printf( "i=%d, insufficient parameters\n", i ); printf( "i=%d, insufficient parameters\n", i );
// there are more parameters to read if this is an AMP_OUTLINE // there are more parameters to read if this is an AMP_OUTLINE
...@@ -660,7 +653,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -660,7 +653,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
paramCount = (int) prim.params[1].GetValue( 0 ) * 2 + 1; paramCount = (int) prim.params[1].GetValue( 0 ) * 2 + 1;
for( int i = 0; i < paramCount && *text && *text != '*'; ++i ) for( int i = 0; i < paramCount && *text && *text != '*'; ++i )
{ {
prim.params.push_back( DCODE_PARAM() ); prim.params.push_back( DCODE_PARAM() );
......
...@@ -13,12 +13,11 @@ ...@@ -13,12 +13,11 @@
#include "wx/statline.h" #include "wx/statline.h"
/* Variables locales */
#define LAYER_UNSELECTED NB_LAYERS #define LAYER_UNSELECTED NB_LAYERS
static int ButtonTable[32]; // Indexes buttons to Gerber layers static int ButtonTable[32]; // Indexes buttons to Gerber layers
static int LayerLookUpTable[32]; // Indexes Gerber layers to PCB file layers static int LayerLookUpTable[32]; // Indexes Gerber layers to PCB file layers
wxStaticText* layer_list[32]; // Indexes text strings to buttons wxStaticText* layer_list[32]; // Indexes text strings to buttons
enum swap_layer_id { enum swap_layer_id {
ID_WINEDA_SWAPLAYERFRAME = 1800, ID_WINEDA_SWAPLAYERFRAME = 1800,
...@@ -27,10 +26,6 @@ enum swap_layer_id { ...@@ -27,10 +26,6 @@ enum swap_layer_id {
}; };
/***********************************************/
/* classe pour la frame de selection de layers */
/***********************************************/
class WinEDA_SwapLayerFrame : public wxDialog class WinEDA_SwapLayerFrame : public wxDialog
{ {
private: private:
...@@ -46,7 +41,6 @@ private: ...@@ -46,7 +41,6 @@ private:
public: public:
// Constructor and destructor
WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ); WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent );
~WinEDA_SwapLayerFrame() {}; ~WinEDA_SwapLayerFrame() {};
...@@ -58,7 +52,7 @@ private: ...@@ -58,7 +52,7 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/* Table des evenements pour WinEDA_SwapLayerFrame */
BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31, EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
wxEVT_COMMAND_BUTTON_CLICKED, wxEVT_COMMAND_BUTTON_CLICKED,
...@@ -68,13 +62,12 @@ BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog ) ...@@ -68,13 +62,12 @@ BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog )
END_EVENT_TABLE() END_EVENT_TABLE()
/*************************************************************/
int* InstallDialogLayerPairChoice( WinEDA_GerberFrame * parent ) {
/*************************************************************/
/* Install a dialog frame to choose the equivalence /* Install a dialog frame to choose the equivalence
* between gerber layers and pcbnew layers * between gerber layers and pcbnew layers
* return the "lookup table" if ok, or NULL * return the "lookup table" if ok, or NULL
*/ */
int* InstallDialogLayerPairChoice( WinEDA_GerberFrame * parent )
{
WinEDA_SwapLayerFrame* frame = new WinEDA_SwapLayerFrame( parent ); WinEDA_SwapLayerFrame* frame = new WinEDA_SwapLayerFrame( parent );
int ii = frame->ShowModal(); int ii = frame->ShowModal();
...@@ -87,12 +80,10 @@ int* InstallDialogLayerPairChoice( WinEDA_GerberFrame * parent ) { ...@@ -87,12 +80,10 @@ int* InstallDialogLayerPairChoice( WinEDA_GerberFrame * parent ) {
} }
/*************************************************************************/
WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) : WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) :
wxDialog( parent, -1, _( "Layer selection:" ), wxPoint( -1, -1 ), wxDialog( parent, -1, _( "Layer selection:" ), wxPoint( -1, -1 ),
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER ) wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER )
{ {
/*************************************************************************/
OuterBoxSizer = NULL; OuterBoxSizer = NULL;
MainBoxSizer = NULL; MainBoxSizer = NULL;
FlexColumnBoxSizer = NULL; FlexColumnBoxSizer = NULL;
...@@ -184,7 +175,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) : ...@@ -184,7 +175,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) :
// of those items are placed into the left hand column, middle // of those items are placed into the left hand column, middle
// column, and right hand column (respectively) of the Flexgrid // column, and right hand column (respectively) of the Flexgrid
// sizer, and the color of the second text string is set to // sizer, and the color of the second text string is set to
// fushia or blue (to respectively indicate whether the Gerber // fuchsia or blue (to respectively indicate whether the Gerber
// layer has been mapped to a pcbnew layer or is not being // layer has been mapped to a pcbnew layer or is not being
// exported at all). (Experimentation has shown that if a text // exported at all). (Experimentation has shown that if a text
// control is used to depict which pcbnew layer that each Gerber // control is used to depict which pcbnew layer that each Gerber
...@@ -249,7 +240,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) : ...@@ -249,7 +240,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) :
// Provide another text string to specify which pcbnew layer that this // Provide another text string to specify which pcbnew layer that this
// Gerber layer is initially mapped to, and set the initial text to // Gerber layer is initially mapped to, and set the initial text to
// specify the appropriate pcbnew layer, and set the foreground color // specify the appropriate pcbnew layer, and set the foreground color
// of the text to fushia (to indicate that the layer is being exported). // of the text to fuchsia (to indicate that the layer is being exported).
item_ID = ID_TEXT_0 + ii; item_ID = ID_TEXT_0 + ii;
// When the first of these text strings is being added, determine what // When the first of these text strings is being added, determine what
...@@ -367,7 +358,7 @@ void WinEDA_SwapLayerFrame::OnSelectLayer( wxCommandEvent& event ) ...@@ -367,7 +358,7 @@ void WinEDA_SwapLayerFrame::OnSelectLayer( wxCommandEvent& event )
{ {
layer_list[ii]->SetLabel( ReturnPcbLayerName( jj ) ); layer_list[ii]->SetLabel( ReturnPcbLayerName( jj ) );
// Change the text color to fushia (to highlight // Change the text color to fuchsia (to highlight
// that this layer *is* being exported) // that this layer *is* being exported)
layer_list[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) ); layer_list[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
} }
...@@ -375,18 +366,14 @@ void WinEDA_SwapLayerFrame::OnSelectLayer( wxCommandEvent& event ) ...@@ -375,18 +366,14 @@ void WinEDA_SwapLayerFrame::OnSelectLayer( wxCommandEvent& event )
} }
/*********************************************************/
void WinEDA_SwapLayerFrame::OnCancelClick( wxCommandEvent& event ) void WinEDA_SwapLayerFrame::OnCancelClick( wxCommandEvent& event )
/*********************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/*********************************************************/
void WinEDA_SwapLayerFrame::OnOkClick( wxCommandEvent& event ) void WinEDA_SwapLayerFrame::OnOkClick( wxCommandEvent& event )
{ {
/*********************************************************/
int ii; int ii;
bool AsCmpLayer = false; bool AsCmpLayer = false;
......
/***************************************************/ /***************************************************/
/* tool_gerber.cpp: Build tool bars and main menu */ /* tool_gerber.cpp: Build tool bars and main menu */
/***************************************************/ /***************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -12,12 +12,8 @@ ...@@ -12,12 +12,8 @@
#include "bitmaps.h" #include "bitmaps.h"
#include "hotkeys.h" #include "hotkeys.h"
/***********************************************/
void WinEDA_GerberFrame::ReCreateMenuBar( void )
/***********************************************/
/* Cree ou reinitialise le menu du haut d'ecran void WinEDA_GerberFrame::ReCreateMenuBar( void )
*/
{ {
wxMenuBar *menuBar = GetMenuBar(); wxMenuBar *menuBar = GetMenuBar();
...@@ -34,7 +30,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) ...@@ -34,7 +30,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
FALSE ); FALSE );
filesMenu->Append( ID_APPEND_FILE, _( "Load Gerber File" ), filesMenu->Append( ID_APPEND_FILE, _( "Load Gerber File" ),
_( "Load new Gerber file on currrent layer" ), _( "Load new Gerber file on current layer" ),
FALSE ); FALSE );
filesMenu->Append( ID_MENU_INC_LAYER_AND_APPEND_FILE, filesMenu->Append( ID_MENU_INC_LAYER_AND_APPEND_FILE,
...@@ -79,15 +75,16 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) ...@@ -79,15 +75,16 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
// Configuration: // Configuration:
wxMenu* configmenu = new wxMenu; wxMenu* configmenu = new wxMenu;
ADD_MENUITEM_WITH_HELP( configmenu, ID_CONFIG_REQ, _( "&File Ext" ), ADD_MENUITEM_WITH_HELP( configmenu, ID_CONFIG_REQ, _( "&File Ext" ),
_( "Setting Files extension" ), config_xpm ); _( "Set files extensions" ), config_xpm );
ADD_MENUITEM_WITH_HELP( configmenu, ID_COLORS_SETUP, _( "&Colors" ), ADD_MENUITEM_WITH_HELP( configmenu, ID_COLORS_SETUP, _( "&Colors" ),
_( "Select Colors and Display for layers" ), _( "Select colors and display for layers" ),
palette_xpm ); palette_xpm );
ADD_MENUITEM_WITH_HELP( configmenu, ID_OPTIONS_SETUP, _( "&Options" ), ADD_MENUITEM_WITH_HELP( configmenu, ID_OPTIONS_SETUP, _( "&Options" ),
_( " Select general options" ), preference_xpm ); _( "Select general options" ), preference_xpm );
ADD_MENUITEM_WITH_HELP( configmenu, ID_PCB_DISPLAY_OPTIONS_SETUP, _( "Display" ), ADD_MENUITEM_WITH_HELP( configmenu, ID_PCB_DISPLAY_OPTIONS_SETUP,
_( " Select how items are displayed" ), _( "Display" ),
_( "Select how items are displayed" ),
display_options_xpm ); display_options_xpm );
wxGetApp().AddMenuLanguageList( configmenu ); wxGetApp().AddMenuLanguageList( configmenu );
...@@ -100,14 +97,11 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) ...@@ -100,14 +97,11 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
configmenu->AppendSeparator(); configmenu->AppendSeparator();
AddHotkeyConfigMenu( configmenu ); AddHotkeyConfigMenu( configmenu );
// Menu drill ( generation fichiers percage) /* wxMenu *drill_menu = new wxMenu;
/* wxMenu *drill_menu = new wxMenu;
* postprocess_menu->Append(ID_PCB_GEN_DRILL_FILE, "Create &Drill file", * postprocess_menu->Append(ID_PCB_GEN_DRILL_FILE, "Create &Drill file",
* "Gen Drill (EXCELLON] file and/or Drill sheet"); * "Gen Drill (EXCELLON] file and/or Drill sheet");
*/ */
// Menu d'outils divers
wxMenu* miscellaneous_menu = new wxMenu; wxMenu* miscellaneous_menu = new wxMenu;
ADD_MENUITEM_WITH_HELP( miscellaneous_menu, ID_GERBVIEW_SHOW_LIST_DCODES, ADD_MENUITEM_WITH_HELP( miscellaneous_menu, ID_GERBVIEW_SHOW_LIST_DCODES,
_( "&List DCodes" ), _( "&List DCodes" ),
...@@ -133,7 +127,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) ...@@ -133,7 +127,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
menuBar->Append( configmenu, _( "&Preferences" ) ); menuBar->Append( configmenu, _( "&Preferences" ) );
menuBar->Append( miscellaneous_menu, _( "&Miscellaneous" ) ); menuBar->Append( miscellaneous_menu, _( "&Miscellaneous" ) );
// menuBar->Append(drill_menu, _("&Drill")); // menuBar->Append(drill_menu, _("&Drill"));
menuBar->Append( helpMenu, _( "&Help" ) ); menuBar->Append( helpMenu, _( "&Help" ) );
// Associate the menu bar with the frame // Associate the menu bar with the frame
...@@ -141,9 +135,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) ...@@ -141,9 +135,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
} }
/***********************************************/
void WinEDA_GerberFrame::ReCreateHToolbar( void ) void WinEDA_GerberFrame::ReCreateHToolbar( void )
/***********************************************/
{ {
int layer = 0; int layer = 0;
GERBER* gerber = NULL; GERBER* gerber = NULL;
...@@ -151,7 +143,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) ...@@ -151,7 +143,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
wxString msg; wxString msg;
// delete and recreate the toolbar // delete and recreate the toolbar
if( m_HToolBar != NULL ) if( m_HToolBar != NULL )
return; return;
if( GetScreen() ) if( GetScreen() )
...@@ -161,13 +153,15 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) ...@@ -161,13 +153,15 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
} }
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
#if !defined(KICAD_AUIMANAGER) #if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*)m_HToolBar ); SetToolBar( (wxToolBar*)m_HToolBar );
#endif #endif
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, m_HToolBar->AddTool( ID_NEW_BOARD, wxEmptyString,
wxBitmap( new_xpm ), wxBitmap( new_xpm ),
_( "New World" ) ); _( "New world" ) );
m_HToolBar->AddTool( ID_LOAD_FILE, wxEmptyString, m_HToolBar->AddTool( ID_LOAD_FILE, wxEmptyString,
wxBitmap( open_xpm ), wxBitmap( open_xpm ),
...@@ -208,7 +202,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) ...@@ -208,7 +202,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_GEN_PRINT, wxEmptyString, m_HToolBar->AddTool( ID_GEN_PRINT, wxEmptyString,
wxBitmap( print_button ), wxBitmap( print_button ),
_( "Print World" ) ); _( "Print world" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "Zoom in" ), s_Gerbview_Hokeys_Descr, HK_ZOOM_IN ); msg = AddHotkeyName( _( "Zoom in" ), s_Gerbview_Hokeys_Descr, HK_ZOOM_IN );
...@@ -227,7 +221,8 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) ...@@ -227,7 +221,8 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
wxBitmap( zoom_redraw_xpm ), wxBitmap( zoom_redraw_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "Zoom auto" ), s_Gerbview_Hokeys_Descr, HK_ZOOM_AUTO ); msg = AddHotkeyName( _( "Zoom auto" ), s_Gerbview_Hokeys_Descr,
HK_ZOOM_AUTO );
m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
wxBitmap( zoom_auto_xpm ), wxBitmap( zoom_auto_xpm ),
msg ); msg );
...@@ -256,6 +251,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) ...@@ -256,6 +251,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
choices.Clear(); choices.Clear();
choices.Add( _( "No tool" ) ); choices.Add( _( "No tool" ) );
for( ii = 0; ii < MAX_TOOLS; ii++ ) for( ii = 0; ii < MAX_TOOLS; ii++ )
{ {
wxString msg; wxString msg;
...@@ -277,12 +273,10 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) ...@@ -277,12 +273,10 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
} }
/**********************************************/
void WinEDA_GerberFrame::ReCreateVToolbar( void )
/**********************************************/
/** /**
create or update the right vertical toolbar * Create or update the right vertical toolbar
*/ */
void WinEDA_GerberFrame::ReCreateVToolbar( void )
{ {
if( m_VToolBar ) if( m_VToolBar )
return; return;
...@@ -298,11 +292,11 @@ create or update the right vertical toolbar ...@@ -298,11 +292,11 @@ create or update the right vertical toolbar
m_VToolBar->AddSeparator(); m_VToolBar->AddSeparator();
m_VToolBar->AddTool( ID_COMPONENT_BUTT, wxEmptyString, m_VToolBar->AddTool( ID_COMPONENT_BUTT, wxEmptyString,
wxBitmap( component_button ), wxBitmap( component_button ),
_( "Add Flashes" ) ); _( "Add flashes" ) );
m_VToolBar->AddTool( ID_BUS_BUTT, wxEmptyString, m_VToolBar->AddTool( ID_BUS_BUTT, wxEmptyString,
wxBitmap( bus_button ), wxBitmap( bus_button ),
_( "Add Lines" ) ); _( "Add lines" ) );
m_VToolBar->AddTool( ID_JUNCTION_BUTT, wxEmptyString, m_VToolBar->AddTool( ID_JUNCTION_BUTT, wxEmptyString,
wxBitmap( junction_xpm ), wxBitmap( junction_xpm ),
...@@ -311,7 +305,7 @@ create or update the right vertical toolbar ...@@ -311,7 +305,7 @@ create or update the right vertical toolbar
m_VToolBar->AddSeparator(); m_VToolBar->AddSeparator();
m_VToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString, m_VToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString,
wxBitmap( tool_text_xpm ), wxBitmap( tool_text_xpm ),
_( "Add Text" ) ); _( "Add text" ) );
#endif #endif
m_VToolBar->AddSeparator(); m_VToolBar->AddSeparator();
...@@ -324,52 +318,51 @@ create or update the right vertical toolbar ...@@ -324,52 +318,51 @@ create or update the right vertical toolbar
} }
/************************************************/
void WinEDA_GerberFrame::ReCreateOptToolbar( void )
/************************************************/
/** /**
create or update the left vertical toolbar (option toolbar * Create or update the left vertical toolbar (option toolbar
*/ */
void WinEDA_GerberFrame::ReCreateOptToolbar( void )
{ {
if( m_OptionsToolBar ) if( m_OptionsToolBar )
return; return;
// creation du tool bar options // creation of tool bar options
m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this, m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this,
ID_OPT_TOOLBAR, FALSE ); ID_OPT_TOOLBAR, FALSE );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
wxBitmap( grid_xpm ), wxBitmap( grid_xpm ),
_( "Display Grid OFF" ), wxITEM_CHECK ); _( "Turn grid off" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
wxBitmap( polar_coord_xpm ), wxBitmap( polar_coord_xpm ),
_( "Display Polar Coord ON" ), wxITEM_CHECK ); _( "Turn polar coordinate on" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
wxBitmap( unit_inch_xpm ), wxBitmap( unit_inch_xpm ),
_( "Units in inches" ), wxITEM_CHECK ); _( "Set units to inches" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
wxBitmap( unit_mm_xpm ), wxBitmap( unit_mm_xpm ),
_( "Units in millimeters" ), wxITEM_CHECK ); _( "Set units to millimeters" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
wxBitmap( cursor_shape_xpm ), wxBitmap( cursor_shape_xpm ),
_( "Change Cursor Shape" ), wxITEM_CHECK ); _( "Change cursor shape" ), wxITEM_CHECK );
m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddSeparator();
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
wxBitmap( pad_sketch_xpm ), wxBitmap( pad_sketch_xpm ),
_( "Show Spots in Sketch Mode" ), wxITEM_CHECK ); _( "Show spots in sketch mode" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
wxBitmap( showtrack_xpm ), wxBitmap( showtrack_xpm ),
_( "Show Lines in Sketch Mode" ), wxITEM_CHECK ); _( "Show lines in sketch mode" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, wxEmptyString,
wxBitmap( opt_show_polygon_xpm ), wxBitmap( opt_show_polygon_xpm ),
_( "Show Polygons in Sketch Mode" ), wxITEM_CHECK ); _( "Show polygons in sketch mode" ),
wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_DCODES, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_DCODES, wxEmptyString,
wxBitmap( show_dcodenumber_xpm ), wxBitmap( show_dcodenumber_xpm ),
......
...@@ -18,41 +18,44 @@ ...@@ -18,41 +18,44 @@
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
/************************************************************************************************************/
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmasklayer, bool aPrintMirrorMode )
/*************************************************************************************************************/
/* Draw gerbview layers, for printing /* Draw gerbview layers, for printing
*/ */
void WinEDA_DrawPanel::PrintPage( wxDC* DC,
bool Print_Sheet_Ref,
int printmasklayer,
bool aPrintMirrorMode )
{ {
DISPLAY_OPTIONS save_opt; DISPLAY_OPTIONS save_opt;
int DisplayPolygonsModeImg; int DisplayPolygonsModeImg;
save_opt = DisplayOpt; save_opt = DisplayOpt;
if( printmasklayer & ALL_CU_LAYERS ) if( printmasklayer & ALL_CU_LAYERS )
{ {
DisplayOpt.DisplayPadFill = true; DisplayOpt.DisplayPadFill = true;
DisplayOpt.DisplayViaFill = true; DisplayOpt.DisplayViaFill = true;
} }
else else
{ {
DisplayOpt.DisplayPadFill = false; DisplayOpt.DisplayPadFill = false;
DisplayOpt.DisplayViaFill = false; DisplayOpt.DisplayViaFill = false;
} }
DisplayOpt.DisplayPadNum = 0; DisplayOpt.DisplayPadNum = 0;
DisplayOpt.DisplayPadNoConn = 0; DisplayOpt.DisplayPadNoConn = 0;
DisplayOpt.DisplayPadIsol = 0; DisplayOpt.DisplayPadIsol = 0;
DisplayOpt.DisplayModEdge = FILLED; DisplayOpt.DisplayModEdge = FILLED;
DisplayOpt.DisplayModText = FILLED; DisplayOpt.DisplayModText = FILLED;
DisplayOpt.DisplayPcbTrackFill = FILLED; DisplayOpt.DisplayPcbTrackFill = FILLED;
DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE;
DisplayOpt.DisplayDrawItems = FILLED; DisplayOpt.DisplayDrawItems = FILLED;
DisplayOpt.DisplayZonesMode = 0; DisplayOpt.DisplayZonesMode = 0;
DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch; DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch;
g_DisplayPolygonsModeSketch = 0; g_DisplayPolygonsModeSketch = 0;
m_PrintIsMirrored = aPrintMirrorMode; m_PrintIsMirrored = aPrintMirrorMode;
( (WinEDA_GerberFrame*) m_Parent )->Trace_Gerber( DC, GR_COPY, printmasklayer ); ( (WinEDA_GerberFrame*) m_Parent )->Trace_Gerber( DC,
GR_COPY,
printmasklayer );
if( Print_Sheet_Ref ) if( Print_Sheet_Ref )
m_Parent->TraceWorkSheet( DC, GetScreen(), 0 ); m_Parent->TraceWorkSheet( DC, GetScreen(), 0 );
...@@ -64,14 +67,11 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl ...@@ -64,14 +67,11 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
} }
/*******************************************************************/ /* Trace the PCB, and additional elements (axis, grid ..)
void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*******************************************************************/
/* Trace le PCB, et les elements complementaires ( axes, grille .. )
*/ */
void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{ {
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen();
if( !GetBoard() ) if( !GetBoard() )
return; return;
...@@ -92,62 +92,67 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -92,62 +92,67 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->Trace_Curseur( DC ); DrawPanel->Trace_Curseur( DC );
} }
/********************************************************************/
void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC,
int aDrawMode, const wxPoint& offset )
/********************************************************************/
/* Redraw the BOARD items but not cursors, axis or grid */ /* Redraw the BOARD items but not cursors, axis or grid */
// @todo: replace WinEDA_GerberFrame::Trace_Gerber() by this function // @todo: replace WinEDA_GerberFrame::Trace_Gerber() by this function
void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC,
int aDrawMode, const wxPoint& offset )
{ {
} }
/***********************************************************************************/
void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer )
/***********************************************************************************/
/* /*
* Trace l'ensemble des elements du PCB sur l'ecran actif * Trace all elements of PCBs on the active screen.
* @param DC = device context to draw *
* @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR ..) * @param DC = device context to draw
* @param printmasklayer = mask for allowed layer (=-1 to draw all layers) * @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR
*/ * ..)
* @param printmasklayer = mask for allowed layer (=-1 to draw all layers)
*/
void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC,
int draw_mode,
int printmasklayer )
{ {
if( !GetBoard() ) if( !GetBoard() )
return; return;
bool erase = false; bool erase = false;
int Color; int Color;
bool filled; bool filled;
// Draw filled polygons // Draw filled polygons
std::vector<wxPoint> points; std::vector<wxPoint> points;
// minimize reallocations of the vector's internal array by starting with a good sized one. // minimize reallocations of the vector's internal array by starting with a
points.reserve(10000); // good sized one.
points.reserve( 10000 );
for( TRACK* track = GetBoard()->m_Zone; track; track = track->Next() ) for( TRACK* track = GetBoard()->m_Zone; track; track = track->Next() )
{ {
if( !(track->ReturnMaskLayer() & printmasklayer) ) if( !(track->ReturnMaskLayer() & printmasklayer) )
continue; continue;
D(printf("D:%p\n", track );) D( printf( "D:%p\n", track ); )
if( track->GetNet() == 0 ) // StartPoint if( track->GetNet() == 0 ) // StartPoint
{ {
if( points.size() ) // we have found a new polygon: Draw the old polygon if( points.size() ) // we have found a new polygon: Draw the
// old polygon
{ {
if( erase ) if( erase )
{ {
Color = g_DrawBgColor; Color = g_DrawBgColor;
filled = true; filled = true;
} }
else else
{ {
Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
filled = (g_DisplayPolygonsModeSketch == 0); filled = (g_DisplayPolygonsModeSketch == 0);
} }
GRClosedPoly( &DrawPanel->m_ClipBox, DC, points.size(), &points[0], GRClosedPoly( &DrawPanel->m_ClipBox, DC,
points.size(), &points[0],
filled, Color, Color ); filled, Color, Color );
} }
...@@ -166,13 +171,13 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay ...@@ -166,13 +171,13 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
{ {
if( erase ) if( erase )
{ {
Color = g_DrawBgColor; Color = g_DrawBgColor;
filled = true; filled = true;
} }
else else
{ {
Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
filled = (g_DisplayPolygonsModeSketch == 0); filled = ( g_DisplayPolygonsModeSketch == 0 );
} }
GRClosedPoly( &DrawPanel->m_ClipBox, DC, points.size(), &points[0], GRClosedPoly( &DrawPanel->m_ClipBox, DC, points.size(), &points[0],
...@@ -180,7 +185,8 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay ...@@ -180,7 +185,8 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
} }
} }
// Draw tracks and flashes down here. This will probably not be a final solution to drawing order issues // Draw tracks and flashes down here. This will probably not be a final
// solution to drawing order issues
Draw_Track_Buffer( DrawPanel, DC, GetBoard(), draw_mode, printmasklayer ); Draw_Track_Buffer( DrawPanel, DC, GetBoard(), draw_mode, printmasklayer );
if( DisplayOpt.DisplayPadNum ) if( DisplayOpt.DisplayPadNum )
...@@ -189,32 +195,34 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay ...@@ -189,32 +195,34 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
GetScreen()->ClrRefreshReq(); GetScreen()->ClrRefreshReq();
} }
/***************************************************************************************************/
void Draw_Track_Buffer( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int draw_mode,
int printmasklayer )
/***************************************************************************************************/
/* Function to draw the tracks (i.e Spots or lines) in gerbview /* Function to draw the tracks (i.e Spots or lines) in gerbview
* Polygons are not handled here (there are in Pcb->m_Zone) * Polygons are not handled here (there are in Pcb->m_Zone)
* @param DC = device context to draw * @param DC = device context to draw
* @param Pcb = Board to draw (only Pcb->m_Track is used) * @param Pcb = Board to draw (only Pcb->m_Track is used)
* @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR ..) * @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR
* ..)
* @param printmasklayer = mask for allowed layer (=-1 to draw all layers) * @param printmasklayer = mask for allowed layer (=-1 to draw all layers)
*/ */
void Draw_Track_Buffer( WinEDA_DrawPanel* panel,
wxDC* DC,
BOARD* Pcb,
int draw_mode,
int printmasklayer )
{ {
int layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; int layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
GERBER* gerber = g_GERBER_List[layer]; GERBER* gerber = g_GERBER_List[layer];
int dcode_hightlight = 0; int dcode_hightlight = 0;
if( gerber ) if( gerber )
dcode_hightlight = gerber->m_Selected_Tool; dcode_hightlight = gerber->m_Selected_Tool;
for( TRACK* track = Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = Pcb->m_Track; track; track = track->Next() )
{ {
if( !(track->ReturnMaskLayer() & printmasklayer) ) if( !(track->ReturnMaskLayer() & printmasklayer) )
continue; continue;
D(printf("D:%p\n", track );) D( printf( "D:%p\n", track ); )
if( dcode_hightlight == track->GetNet() && track->GetLayer()==layer ) if( dcode_hightlight == track->GetNet() && track->GetLayer()==layer )
Trace_Segment( panel, DC, track, draw_mode | GR_SURBRILL ); Trace_Segment( panel, DC, track, draw_mode | GR_SURBRILL );
...@@ -226,15 +234,16 @@ void Draw_Track_Buffer( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int draw_ ...@@ -226,15 +234,16 @@ void Draw_Track_Buffer( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int draw_
#if 1 #if 1
/***********************************************************************************/
void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mode )
/***********************************************************************************/
/* routine de trace de 1 segment de piste. /* Trace 1 segment of track.
* Parametres : * Parameters:
* track = adresse de la description de la piste en buflib * Track = address of the description of the track buflib
* draw_mode = mode ( GR_XOR, GR_OR..) * Draw_mode = mode (GR_XOR, GR_OR ..)
*/ */
void Trace_Segment( WinEDA_DrawPanel* panel,
wxDC* DC,
TRACK* track,
int draw_mode )
{ {
int l_piste; int l_piste;
int color; int color;
...@@ -243,7 +252,8 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -243,7 +252,8 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
int halfPenWidth; int halfPenWidth;
static bool show_err; static bool show_err;
if( track->m_Flags & DRAW_ERASED ) // draw in background color, used by classs TRACK in gerbview if( track->m_Flags & DRAW_ERASED ) // draw in background color, used by
// class TRACK in gerbview
{ {
color = g_DrawBgColor; color = g_DrawBgColor;
} }
...@@ -267,7 +277,6 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -267,7 +277,6 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
GRSetDrawMode( DC, draw_mode ); GRSetDrawMode( DC, draw_mode );
fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH;
switch( track->m_Shape ) switch( track->m_Shape )
...@@ -285,16 +294,32 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -285,16 +294,32 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
if( fillopt == SKETCH ) if( fillopt == SKETCH )
{ {
// draw the border of the pen's path using two circles, each as narrow as possible // draw the border of the pen's path using two circles, each as
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, // narrow as possible
radius - halfPenWidth, 0, color ); GRCircle( &panel->m_ClipBox,
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, DC,
radius + halfPenWidth, 0, color ); track->m_Start.x,
track->m_Start.y,
radius - halfPenWidth,
0,
color );
GRCircle( &panel->m_ClipBox,
DC,
track->m_Start.x,
track->m_Start.y,
radius + halfPenWidth,
0,
color );
} }
else else
{ {
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRCircle( &panel->m_ClipBox,
radius, track->m_Width, color ); DC,
track->m_Start.x,
track->m_Start.y,
radius,
track->m_Width,
color );
} }
break; break;
...@@ -402,12 +427,14 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -402,12 +427,14 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
} }
} }
#endif #endif
/*****************************************************************************************/ void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel,
void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int drawmode ) wxDC* DC,
/*****************************************************************************************/ BOARD* Pcb,
int drawmode )
{ {
TRACK* track; TRACK* track;
wxPoint pos; wxPoint pos;
...@@ -418,24 +445,24 @@ void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int d ...@@ -418,24 +445,24 @@ void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int d
track = Pcb->m_Track; track = Pcb->m_Track;
for( ; track != NULL; track = track->Next() ) for( ; track != NULL; track = track->Next() )
{ {
if( (track->m_Shape == S_ARC) if( ( track->m_Shape == S_ARC )
|| (track->m_Shape == S_CIRCLE) || ( track->m_Shape == S_CIRCLE )
|| (track->m_Shape == S_ARC_RECT) ) || ( track->m_Shape == S_ARC_RECT ) )
{ {
pos.x = track->m_Start.x; pos.x = track->m_Start.x;
pos.y = track->m_Start.y; pos.y = track->m_Start.y;
} }
else else
{ {
pos.x = (track->m_Start.x + track->m_End.x) / 2; pos.x = ( track->m_Start.x + track->m_End.x ) / 2;
pos.y = (track->m_Start.y + track->m_End.y) / 2; pos.y = ( track->m_Start.y + track->m_End.y ) / 2;
} }
Line.Printf( wxT( "D%d" ), track->GetNet() ); Line.Printf( wxT( "D%d" ), track->GetNet() );
width = track->m_Width; width = track->m_Width;
orient = TEXT_ORIENT_HORIZ; orient = TEXT_ORIENT_HORIZ;
if( track->m_Shape >= S_SPOT_CIRCLE ) // forme flash if( track->m_Shape >= S_SPOT_CIRCLE ) // form flash
{ {
width /= 3; width /= 3;
} }
...@@ -449,20 +476,19 @@ void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int d ...@@ -449,20 +476,19 @@ void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int d
width /= 2; width /= 2;
} }
DrawGraphicText( panel, DC, DrawGraphicText( panel, DC, pos, (EDA_Colors) g_DCodesColor, Line,
pos, (EDA_Colors) g_DCodesColor, Line,
orient, wxSize( width, width ), orient, wxSize( width, width ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
0, false, false, false); 0, false, false, false );
} }
} }
/* Virtual fonction needed by the PCB_SCREEN class derived from BASE_SCREEN /* Virtual function needed by the PCB_SCREEN class derived from BASE_SCREEN
* this is a virtual pure function in BASE_SCREEN * this is a virtual pure function in BASE_SCREEN
* do nothing in gerbview * do nothing in gerbview
* could be removed later * could be removed later
*/ */
void PCB_SCREEN::ClearUndoORRedoList(UNDO_REDO_CONTAINER&, int ) void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
{ {
} }
/***********************************************************/ /***********************************************************/
/* wxGerberStruct.h: */ /* wxGerberStruct.h: */
/***********************************************************/ /***********************************************************/
#ifndef WX_GERBER_STRUCT_H #ifndef WX_GERBER_STRUCT_H
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
int BestZoom(); // Retourne le meilleur zoom int BestZoom();
void OnSelectOptionToolbar( wxCommandEvent& event ); void OnSelectOptionToolbar( wxCommandEvent& event );
void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
...@@ -176,7 +176,6 @@ public: ...@@ -176,7 +176,6 @@ public:
void CopyDCodesSizeToItems(); void CopyDCodesSizeToItems();
void Liste_D_Codes( wxDC* DC ); void Liste_D_Codes( wxDC* DC );
/* Fonctions specifiques */
void Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer ); void Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer );
// Copper texts // Copper texts
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment