Commit 506a73c3 authored by stambaughw's avatar stambaughw

More comment translation work.

* Translate source files D through L in pcbnew.
* Add translate tag for comments that did not translate correctly.
parent ab66f9ec
...@@ -902,7 +902,7 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC ) ...@@ -902,7 +902,7 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
/* Draw keep out area of a module. */ /* Draw keep out area of a module. */
/***********************************/ /***********************************/
/* ??? /* TRANSLATE
* les cellules ( du plan des Distances ) du rectangle x0,y0 a x1,y1 sont * les cellules ( du plan des Distances ) du rectangle x0,y0 a x1,y1 sont
* incrementees de la valeur Penalite * incrementees de la valeur Penalite
* celles qui sont externes au rectangle, mais internes au rectangle * celles qui sont externes au rectangle, mais internes au rectangle
......
...@@ -344,7 +344,7 @@ int Build_Work( BOARD* Pcb ) ...@@ -344,7 +344,7 @@ int Build_Work( BOARD* Pcb )
for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); ii++ )
{ {
pt_rats = &Pcb->m_FullRatsnest[ii]; pt_rats = &Pcb->m_FullRatsnest[ii];
/* ??? On ne route que les chevelus actifs et routables */ /* TRANSLATE On ne route que les chevelus actifs et routables */
if( (pt_rats->m_Status & CH_ACTIF) == 0 ) if( (pt_rats->m_Status & CH_ACTIF) == 0 )
continue; continue;
if( pt_rats->m_Status & CH_UNROUTABLE ) if( pt_rats->m_Status & CH_UNROUTABLE )
......
/*********************************************/ /******************************************/
/* Edition des pistes: Routines d'effacement */ /* Edit Track: Erase Routines */
/* Effacement de segment, piste, net et zone */ /* Delete segments, tracks, and net areas */
/*********************************************/ /******************************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -14,16 +13,12 @@ ...@@ -14,16 +13,12 @@
#include "protos.h" #include "protos.h"
/***************************************************************/ /* Removes 1 segment of track.
TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) * 2 cases:
/***************************************************************/ * If There is evidence of new track: delete new 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_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
{ {
int current_net_code; int current_net_code;
...@@ -36,7 +31,8 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -36,7 +31,8 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
return NULL; return NULL;
} }
if( aTrack->m_Flags & IS_NEW ) // Trace in progress, erase the last segment if( aTrack->m_Flags & IS_NEW ) // Trace in progress, erase the last
// segment
{ {
if( g_CurrentTrackList.GetCount() > 0 ) if( g_CurrentTrackList.GetCount() > 0 )
{ {
...@@ -44,7 +40,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -44,7 +40,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
D( g_CurrentTrackList.VerifyListIntegrity(); ) D( g_CurrentTrackList.VerifyListIntegrity(); )
// effacement de la piste en cours // Delete the current trace
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE );
// delete the most recently entered // delete the most recently entered
...@@ -52,32 +48,37 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -52,32 +48,37 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
// if in 2 track mode, and the next most recent is a segment not a via, // if in 2 track mode, and the next most recent is a segment
// and the one previous to that is a via, then delete up to the via. // not a via, and the one previous to that is a via, then
// delete up to the via.
if( g_CurrentTrackList.GetCount() >= 2 if( g_CurrentTrackList.GetCount() >= 2
&& g_CurrentTrackSegment->Type() != TYPE_VIA && g_CurrentTrackSegment->Type() != TYPE_VIA
&& g_CurrentTrackSegment->Back()->Type() == TYPE_VIA ) && g_CurrentTrackSegment->Back()->Type() == TYPE_VIA )
{ {
delete g_CurrentTrackList.PopBack(); delete g_CurrentTrackList.PopBack();
} }
} }
while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() == TYPE_VIA ) while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() ==
TYPE_VIA )
{ {
delete g_CurrentTrackList.PopBack(); delete g_CurrentTrackList.PopBack();
if( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() != TYPE_VIA ) if( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() !=
TYPE_VIA )
previous_layer = g_CurrentTrackSegment->GetLayer(); previous_layer = g_CurrentTrackSegment->GetLayer();
} }
// Rectification couche active qui a pu changer si une via // Correct active layer which could change if a via
// a ete effacee // has been erased
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer; ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer;
UpdateStatusBar(); UpdateStatusBar();
if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more,
// or 0
{ {
if( g_CurrentTrackList.GetCount()==1 && g_CurrentTrackSegment->Type() != TYPE_VIA ) if( g_CurrentTrackList.GetCount() == 1
&& g_CurrentTrackSegment->Type() != TYPE_VIA )
{ {
delete g_CurrentTrackList.PopBack(); delete g_CurrentTrackList.PopBack();
} }
...@@ -107,9 +108,10 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -107,9 +108,10 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
current_net_code = aTrack->GetNet(); current_net_code = aTrack->GetNet();
DLIST<TRACK>* container = (DLIST<TRACK>*) aTrack->GetList(); DLIST<TRACK>* container = (DLIST<TRACK>*)aTrack->GetList();
wxASSERT( container ); wxASSERT( container );
container->Remove( aTrack ); container->Remove( aTrack );
// redraw the area where the track was // redraw the area where the track was
DrawPanel->PostDirtyRect( aTrack->GetBoundingBox() ); DrawPanel->PostDirtyRect( aTrack->GetBoundingBox() );
...@@ -122,9 +124,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -122,9 +124,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
} }
/**********************************************************/
void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* aTrack ) void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* aTrack )
/**********************************************************/
{ {
if( aTrack != NULL ) if( aTrack != NULL )
{ {
...@@ -136,18 +136,16 @@ void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* aTrack ) ...@@ -136,18 +136,16 @@ void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* aTrack )
} }
/********************************************************/
void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack ) void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
/********************************************************/
{ {
if( aTrack == NULL ) if( aTrack == NULL )
return; return;
if( !IsOK( this, _( "Delete NET ?" ) ) ) if( !IsOK( this, _( "Delete NET?" ) ) )
return; return;
PICKED_ITEMS_LIST itemsList; PICKED_ITEMS_LIST itemsList;
ITEM_PICKER picker(NULL,UR_DELETED); ITEM_PICKER picker( NULL, UR_DELETED );
int net_code_delete = aTrack->GetNet(); int net_code_delete = aTrack->GetNet();
/* Search the first item for the given net code */ /* Search the first item for the given net code */
...@@ -155,7 +153,7 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack ) ...@@ -155,7 +153,7 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
/* Remove all segments having the given net code */ /* Remove all segments having the given net code */
int ii = 0; int ii = 0;
TRACK * next_track; TRACK* next_track;
for( TRACK* segm = trackList; segm; segm = next_track, ++ii ) for( TRACK* segm = trackList; segm; segm = next_track, ++ii )
{ {
next_track = segm->Next(); next_track = segm->Next();
...@@ -163,64 +161,63 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack ) ...@@ -163,64 +161,63 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
break; break;
GetBoard()->m_Track.Remove( segm ); GetBoard()->m_Track.Remove( segm );
// redraw the area where the track was // redraw the area where the track was
DrawPanel->PostDirtyRect( segm->GetBoundingBox() ); DrawPanel->PostDirtyRect( segm->GetBoundingBox() );
picker.m_PickedItem = segm; picker.m_PickedItem = segm;
picker.m_PickedItemType = segm->Type(); picker.m_PickedItemType = segm->Type();
itemsList.PushItem(picker); itemsList.PushItem( picker );
} }
SaveCopyInUndoList( itemsList, UR_DELETED ); SaveCopyInUndoList( itemsList, UR_DELETED );
GetScreen()->SetModify(); GetScreen()->SetModify();
test_1_net_connexion( DC, net_code_delete ); test_1_net_connexion( DC, net_code_delete );
GetBoard()->DisplayInfo( this ); GetBoard()->DisplayInfo( this );
} }
/********************************************************************/ /* Remove 1 track:
void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) * The leading segment is removed and all adjacent segments
/********************************************************************/ * until a pad or a junction point of more than 2 segments is found
/* Routine de suppression de 1 piste:
* le segment pointe est supprime puis les segments adjacents
* jusqu'a un pad ou un point de jonction de plus de 2 segments
*/ */
void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
{ {
int segments_to_delete_count; int segments_to_delete_count;
if( pt_segm == NULL ) if( pt_segm == NULL )
return; return;
TRACK* trackList = Marque_Une_Piste( GetBoard(), pt_segm, &segments_to_delete_count, NULL, true ); TRACK* trackList = Marque_Une_Piste( GetBoard(), pt_segm,
&segments_to_delete_count, NULL, true );
if( segments_to_delete_count == 0 ) if( segments_to_delete_count == 0 )
return; return;
int net_code = pt_segm->GetNet(); int net_code = pt_segm->GetNet();
PICKED_ITEMS_LIST itemsList; PICKED_ITEMS_LIST itemsList;
ITEM_PICKER picker(NULL,UR_DELETED); ITEM_PICKER picker( NULL, UR_DELETED );
int ii = 0; int ii = 0;
TRACK* tracksegment = trackList; TRACK* tracksegment = trackList;
TRACK * next_track; TRACK* next_track;
for( ; ii < segments_to_delete_count; ii++, tracksegment = next_track ) for( ; ii < segments_to_delete_count; ii++, tracksegment = next_track )
{ {
next_track = tracksegment->Next(); next_track = tracksegment->Next();
tracksegment->SetState( BUSY, OFF ); tracksegment->SetState( BUSY, OFF );
D(printf("%s: track %p status=\"%s\"\n", __func__, tracksegment, D( printf( "%s: track %p status=\"%s\"\n", __func__, tracksegment,
CONV_TO_UTF8( TRACK::ShowState( tracksegment->GetState(-1)) ) CONV_TO_UTF8( TRACK::ShowState( tracksegment->GetState( -1 ) ) )
);) ); )
GetBoard()->m_Track.Remove( tracksegment ); GetBoard()->m_Track.Remove( tracksegment );
// redraw the area where the track was // redraw the area where the track was
DrawPanel->PostDirtyRect( tracksegment->GetBoundingBox() ); DrawPanel->PostDirtyRect( tracksegment->GetBoundingBox() );
picker.m_PickedItem = tracksegment; picker.m_PickedItem = tracksegment;
picker.m_PickedItemType = tracksegment->Type(); picker.m_PickedItemType = tracksegment->Type();
itemsList.PushItem(picker); itemsList.PushItem( picker );
} }
SaveCopyInUndoList( itemsList, UR_DELETED ); SaveCopyInUndoList( itemsList, UR_DELETED );
if ( net_code > 0 ) if( net_code > 0 )
test_1_net_connexion( DC, net_code ); test_1_net_connexion( DC, net_code );
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: dialog_svg_print.cpp // Name: dialog_svg_print.cpp
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
...@@ -28,7 +27,7 @@ ...@@ -28,7 +27,7 @@
#define WIDTH_MIN_VALUE 1 #define WIDTH_MIN_VALUE 1
// Local variables: // Local variables:
static int s_PrintPenMinWidth = 1; static int s_PrintPenMinWidth = 1;
static bool s_Print_Frame_Ref = true; static bool s_Print_Frame_Ref = true;
static int s_PlotBlackAndWhite = 0; static int s_PlotBlackAndWhite = 0;
static long s_SelectedLayers = CUIVRE_LAYER | CMP_LAYER | static long s_SelectedLayers = CUIVRE_LAYER | CMP_LAYER |
...@@ -56,16 +55,15 @@ private: ...@@ -56,16 +55,15 @@ private:
void OnSetColorModeSelected( wxCommandEvent& event ); void OnSetColorModeSelected( wxCommandEvent& event );
void SetPenWidth(); void SetPenWidth();
void PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref ); void PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref );
bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen, bool aPrint_Framet_Ref ); bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen,
bool aPrint_Framet_Ref );
}; };
/*******************************************************/
void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
/*******************************************************/
/* Prepare les structures de donnees de gestion de l'impression /* Prepare the data structures of print management
* et affiche la fenetre de dialogue de gestion de l'impression des feuilles * And displays the dialog window management of printing sheets
*/ */
void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
{ {
DIALOG_SVG_PRINT frame( this ); DIALOG_SVG_PRINT frame( this );
...@@ -84,9 +82,7 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent ) : ...@@ -84,9 +82,7 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent ) :
} }
/*************************************************************/
void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
/*************************************************************/
{ {
SetFocus(); // Make ESC key working SetFocus(); // Make ESC key working
...@@ -99,7 +95,8 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) ...@@ -99,7 +95,8 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
AddUnitSymbol( *m_TextPenWidth, g_UnitMetric ); AddUnitSymbol( *m_TextPenWidth, g_UnitMetric );
m_DialogPenWidth->SetValue( m_DialogPenWidth->SetValue(
ReturnStringFromValue( g_UnitMetric, s_PrintPenMinWidth, m_Parent->m_InternalUnits ) ); ReturnStringFromValue( g_UnitMetric, s_PrintPenMinWidth,
m_Parent->m_InternalUnits ) );
m_Print_Frame_Ref_Ctrl->SetValue( s_Print_Frame_Ref ); m_Print_Frame_Ref_Ctrl->SetValue( s_Print_Frame_Ref );
...@@ -108,15 +105,22 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) ...@@ -108,15 +105,22 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
int mask = 1; int mask = 1;
for( int layer = 0; layer<NB_LAYERS; layer++, mask <<= 1 ) for( int layer = 0; layer<NB_LAYERS; layer++, mask <<= 1 )
{ {
m_BoxSelectLayer[layer] = new wxCheckBox( this, -1, board->GetLayerName( layer ) ); m_BoxSelectLayer[layer] =
new wxCheckBox( this, -1, board->GetLayerName( layer ) );
if( mask & s_SelectedLayers ) if( mask & s_SelectedLayers )
m_BoxSelectLayer[layer]->SetValue( true ); m_BoxSelectLayer[layer]->SetValue( true );
if( layer < 16 ) if( layer < 16 )
m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer], 0, wxGROW | wxALL, 1 ); m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer],
0,
wxGROW | wxALL,
1 );
else else
m_TechnicalBoxSizer->Add( m_BoxSelectLayer[layer], 0, wxGROW | wxALL, 1 ); m_TechnicalBoxSizer->Add( m_BoxSelectLayer[layer],
0,
wxGROW | wxALL,
1 );
} }
if( m_Config ) if( m_Config )
...@@ -141,11 +145,10 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) ...@@ -141,11 +145,10 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
} }
/***********************************/
void DIALOG_SVG_PRINT::SetPenWidth() void DIALOG_SVG_PRINT::SetPenWidth()
/***********************************/
{ {
s_PrintPenMinWidth = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits ); s_PrintPenMinWidth = ReturnValueFromTextCtrl( *m_DialogPenWidth,
m_Parent->m_InternalUnits );
if( s_PrintPenMinWidth > WIDTH_MAX_VALUE ) if( s_PrintPenMinWidth > WIDTH_MAX_VALUE )
{ {
...@@ -158,16 +161,15 @@ void DIALOG_SVG_PRINT::SetPenWidth() ...@@ -158,16 +161,15 @@ void DIALOG_SVG_PRINT::SetPenWidth()
} }
m_DialogPenWidth->SetValue( m_DialogPenWidth->SetValue(
ReturnStringFromValue( g_UnitMetric, s_PrintPenMinWidth, m_Parent->m_InternalUnits ) ); ReturnStringFromValue( g_UnitMetric, s_PrintPenMinWidth,
m_Parent->m_InternalUnits ) );
} }
/***************************************************************************/
void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref ) void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref )
/***************************************************************************/
{ {
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
SetPenWidth(); SetPenWidth();
...@@ -176,9 +178,9 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref ) ...@@ -176,9 +178,9 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref )
if( aPrintAll ) if( aPrintAll )
m_PrintMaskLayer = 0xFFFFFFFF; m_PrintMaskLayer = 0xFFFFFFFF;
for ( int layer = 0; layer<NB_LAYERS; layer++ ) for( int layer = 0; layer<NB_LAYERS; layer++ )
{ {
if ( ! aPrintAll && ! m_BoxSelectLayer[layer]->GetValue( ) ) if( !aPrintAll && !m_BoxSelectLayer[layer]->GetValue() )
continue; continue;
fn = m_FileNameCtrl->GetValue(); fn = m_FileNameCtrl->GetValue();
...@@ -188,16 +190,15 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref ) ...@@ -188,16 +190,15 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref )
} }
if( aPrintAll ) if( aPrintAll )
fn.SetName( fn.GetName() + wxT("-brd") ); fn.SetName( fn.GetName() + wxT( "-brd" ) );
else else
{ {
fn.SetName( fn.GetName() + wxT("-") + fn.SetName( fn.GetName() + wxT( "-" ) +
m_BoxSelectLayer[layer]->GetLabel( ) ); m_BoxSelectLayer[layer]->GetLabel() );
m_PrintMaskLayer = 1 << layer; m_PrintMaskLayer = 1 << layer;
if ( m_PrintBoardEdgesCtrl->IsChecked() ) if( m_PrintBoardEdgesCtrl->IsChecked() )
m_PrintMaskLayer |= EDGE_LAYER; m_PrintMaskLayer |= EDGE_LAYER;
} }
fn.SetExt( wxT( "svg" ) ); fn.SetExt( wxT( "svg" ) );
...@@ -209,20 +210,18 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref ) ...@@ -209,20 +210,18 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref )
msg += wxT( "\n" ); msg += wxT( "\n" );
m_MessagesBox->AppendText( msg ); m_MessagesBox->AppendText( msg );
if ( aPrintAll ) if( aPrintAll )
break; break;
} }
} }
/**********************************************************************************/
bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* screen,
bool aPrint_Framet_Ref )
/***********************************************************************************/
/* /*
* Routine effective d'impression * Routine actual print
*/ */
bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
BASE_SCREEN* screen,
bool aPrint_Framet_Ref )
{ {
int tmpzoom; int tmpzoom;
wxPoint tmp_startvisu; wxPoint tmp_startvisu;
...@@ -231,7 +230,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre ...@@ -231,7 +230,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre
float dpi; float dpi;
bool success = true; bool success = true;
/* modification des cadrages et reglages locaux */ /* Change frames and local settings */
tmp_startvisu = screen->m_StartVisu; tmp_startvisu = screen->m_StartVisu;
tmpzoom = screen->GetZoom(); tmpzoom = screen->GetZoom();
old_org = screen->m_DrawOrg; old_org = screen->m_DrawOrg;
...@@ -248,22 +247,26 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre ...@@ -248,22 +247,26 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y, dpi ); wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y, dpi );
EDA_Rect tmp = panel->m_ClipBox; EDA_Rect tmp = panel->m_ClipBox;
GRResetPenAndBrush( &dc ); GRResetPenAndBrush( &dc );
s_PrintPenMinWidth = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits ); s_PrintPenMinWidth = ReturnValueFromTextCtrl( *m_DialogPenWidth,
m_Parent->m_InternalUnits );
SetPenMinWidth( s_PrintPenMinWidth ); SetPenMinWidth( s_PrintPenMinWidth );
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : true ); GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : true );
panel->m_ClipBox.SetX( 0 ); panel->m_ClipBox.SetY( 0 ); panel->m_ClipBox.SetX( 0 ); panel->m_ClipBox.SetY( 0 );
panel->m_ClipBox.SetWidth( 0x7FFFFF0 ); panel->m_ClipBox.SetHeight( 0x7FFFFF0 ); panel->m_ClipBox.SetWidth( 0x7FFFFF0 ); panel->m_ClipBox.SetHeight(
0x7FFFFF0 );
screen->m_IsPrinting = true; screen->m_IsPrinting = true;
SetLocaleTo_C_standard(); // Switch the locale to standard C (needed to print floating point numbers like 1.3) SetLocaleTo_C_standard(); // Switch the locale to standard C (needed
// to print floating point numbers like
// 1.3)
panel->PrintPage( &dc, aPrint_Framet_Ref, m_PrintMaskLayer, false ); panel->PrintPage( &dc, aPrint_Framet_Ref, m_PrintMaskLayer, false );
SetLocaleTo_Default(); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
screen->m_IsPrinting = false; screen->m_IsPrinting = false;
panel->m_ClipBox = tmp; panel->m_ClipBox = tmp;
GRForceBlackPen( FALSE ); GRForceBlackPen( FALSE );
SetPenMinWidth( 1 ); SetPenMinWidth( 1 );
...@@ -276,35 +279,27 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre ...@@ -276,35 +279,27 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre
} }
/********************************************************************/
void DIALOG_SVG_PRINT::OnButtonPrintBoardClick( wxCommandEvent& event ) void DIALOG_SVG_PRINT::OnButtonPrintBoardClick( wxCommandEvent& event )
/********************************************************************/
{ {
s_Print_Frame_Ref = m_Print_Frame_Ref_Ctrl->IsChecked( ); s_Print_Frame_Ref = m_Print_Frame_Ref_Ctrl->IsChecked();
PrintSVGDoc( true, s_Print_Frame_Ref ); PrintSVGDoc( true, s_Print_Frame_Ref );
} }
/********************************************************************/
void DIALOG_SVG_PRINT::OnButtonPrintSelectedClick( wxCommandEvent& event ) void DIALOG_SVG_PRINT::OnButtonPrintSelectedClick( wxCommandEvent& event )
/********************************************************************/
{ {
s_Print_Frame_Ref = m_Print_Frame_Ref_Ctrl->IsChecked( ); s_Print_Frame_Ref = m_Print_Frame_Ref_Ctrl->IsChecked();
PrintSVGDoc( false, s_Print_Frame_Ref ); PrintSVGDoc( false, s_Print_Frame_Ref );
} }
/******************************************************************/
void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event ) void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event )
/******************************************************************/
{ {
Close(); Close();
} }
/***********************************************************/
void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
/***********************************************************/
{ {
SetPenWidth(); SetPenWidth();
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
...@@ -323,12 +318,9 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) ...@@ -323,12 +318,9 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
} }
/*********************************************************************/
void DIALOG_SVG_PRINT::OnSetColorModeSelected( wxCommandEvent& event )
/*********************************************************************/
/* called on radiobox color/black and white selection /* called on radiobox color/black and white selection
*/ */
void DIALOG_SVG_PRINT::OnSetColorModeSelected( wxCommandEvent& event )
{ {
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
} }
/************************************************ /******************************************************************************
* Module editor: Dialog box for editing module * Module editor: Dialog box for editing module properties in the pcb editor. *
* properties for the Board Editor ******************************************************************************/
************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -17,11 +16,11 @@ ...@@ -17,11 +16,11 @@
#include "dialog_edit_module_for_BoardEditor.h" #include "dialog_edit_module_for_BoardEditor.h"
/**************************************************************************************/ DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR(
DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR( WinEDA_PcbFrame* aParent, WinEDA_PcbFrame* aParent,
MODULE* aModule, wxDC* aDC ) : MODULE* aModule,
wxDC* aDC ) :
DIALOG_MODULE_BOARD_EDITOR_BASE( aParent ) DIALOG_MODULE_BOARD_EDITOR_BASE( aParent )
/**************************************************************************************/
{ {
m_Parent = aParent; m_Parent = aParent;
m_DC = aDC; m_DC = aDC;
...@@ -53,20 +52,19 @@ DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR() ...@@ -53,20 +52,19 @@ DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR()
} }
/***************************************************************************/ /* Creation of the panel properties of the module editor. */
void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
/***************************************************************************/
/* creation du panel d'edition des proprietes du module
*/
{ {
PutValueInLocalUnits( *m_ModPositionX, m_CurrentModule->GetPosition().x, PCB_INTERNAL_UNIT ); PutValueInLocalUnits( *m_ModPositionX,
m_CurrentModule->GetPosition().x, PCB_INTERNAL_UNIT );
AddUnitSymbol( *XPositionStatic, g_UnitMetric ); AddUnitSymbol( *XPositionStatic, g_UnitMetric );
PutValueInLocalUnits( *m_ModPositionY, m_CurrentModule->GetPosition().y, PCB_INTERNAL_UNIT ); PutValueInLocalUnits( *m_ModPositionY,
m_CurrentModule->GetPosition().y, PCB_INTERNAL_UNIT );
AddUnitSymbol( *YPositionStatic, g_UnitMetric ); AddUnitSymbol( *YPositionStatic, g_UnitMetric );
m_LayerCtrl->SetSelection( (m_CurrentModule->GetLayer() == COPPER_LAYER_N) ? 1 : 0 ); m_LayerCtrl->SetSelection(
(m_CurrentModule->GetLayer() == COPPER_LAYER_N) ? 1 : 0 );
bool select = FALSE; bool select = FALSE;
switch( m_CurrentModule->m_Orient ) switch( m_CurrentModule->m_Orient )
...@@ -76,16 +74,16 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() ...@@ -76,16 +74,16 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
break; break;
case 900: case 900:
case - 2700: case -2700:
m_OrientCtrl->SetSelection( 1 ); m_OrientCtrl->SetSelection( 1 );
break; break;
case - 900: case -900:
case 2700: case 2700:
m_OrientCtrl->SetSelection( 2 ); m_OrientCtrl->SetSelection( 2 );
break; break;
case - 1800: case -1800:
case 1800: case 1800:
m_OrientCtrl->SetSelection( 3 ); m_OrientCtrl->SetSelection( 3 );
break; break;
...@@ -112,33 +110,35 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() ...@@ -112,33 +110,35 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, PutValueInLocalUnits( *m_SolderMaskMarginCtrl,
m_CurrentModule->m_LocalSolderMaskMargin, m_CurrentModule->m_LocalSolderMaskMargin,
internalUnit ); internalUnit );
// These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0
// These 2 parameters are usually < 0, so prepare entering a negative
// value, if current is 0
PutValueInLocalUnits( *m_SolderPasteMarginCtrl, PutValueInLocalUnits( *m_SolderPasteMarginCtrl,
m_CurrentModule->m_LocalSolderPasteMargin, m_CurrentModule->m_LocalSolderPasteMargin,
internalUnit ); internalUnit );
if( m_CurrentModule->m_LocalSolderPasteMargin == 0 ) if( m_CurrentModule->m_LocalSolderPasteMargin == 0 )
m_SolderPasteMarginCtrl->SetValue( wxT("-") + m_SolderPasteMarginCtrl->GetValue() ); m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) +
m_SolderPasteMarginCtrl->GetValue() );
if( m_CurrentModule->m_LocalSolderPasteMarginRatio == 0.0 ) if( m_CurrentModule->m_LocalSolderPasteMarginRatio == 0.0 )
msg.Printf( wxT( "-%.1f" ), m_CurrentModule->m_LocalSolderPasteMarginRatio * 100.0 ); msg.Printf( wxT( "-%.1f" ),
m_CurrentModule->m_LocalSolderPasteMarginRatio * 100.0 );
else else
msg.Printf( wxT( "%.1f" ), m_CurrentModule->m_LocalSolderPasteMarginRatio * 100.0 ); msg.Printf( wxT( "%.1f" ),
m_CurrentModule->m_LocalSolderPasteMarginRatio * 100.0 );
m_SolderPasteMarginRatioCtrl->SetValue( msg ); m_SolderPasteMarginRatioCtrl->SetValue( msg );
} }
/**********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED( event ) ) void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
/**********************************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event )
/************************************************************************/
{ {
if( m_CurrentModule->m_TimeStamp == 0 ) // Module Editor needs a non null timestamp if( m_CurrentModule->m_TimeStamp == 0 ) // Module Editor needs a non
// null timestamp
{ {
m_CurrentModule->m_TimeStamp = GetTimeStamp(); m_CurrentModule->m_TimeStamp = GetTimeStamp();
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
...@@ -148,9 +148,7 @@ void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event ) ...@@ -148,9 +148,7 @@ void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event )
} }
/**********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event )
/**********************************************************************/
{ {
m_Parent->InstallExchangeModuleFrame( m_CurrentModule ); m_Parent->InstallExchangeModuleFrame( m_CurrentModule );
...@@ -160,9 +158,7 @@ void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event ) ...@@ -160,9 +158,7 @@ void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event )
} }
/*************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event )
/*************************************************************************/
{ {
switch( m_OrientCtrl->GetSelection() ) switch( m_OrientCtrl->GetSelection() )
{ {
...@@ -194,9 +190,7 @@ void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event ) ...@@ -194,9 +190,7 @@ void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event )
} }
/*******************************************************/
void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
/*******************************************************/
{ {
SetFocus(); SetFocus();
...@@ -226,13 +220,12 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() ...@@ -226,13 +220,12 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
#if wxCHECK_VERSION( 2, 8, 0 ) #if wxCHECK_VERSION( 2, 8, 0 )
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) ); m_AttributsCtrl->SetItemToolTip( 0,
_( "Use this attribute for most non smd components" ) );
m_AttributsCtrl->SetItemToolTip( 1, m_AttributsCtrl->SetItemToolTip( 1,
_( _( "Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file" ) );
"Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file" ) );
m_AttributsCtrl->SetItemToolTip( 2, m_AttributsCtrl->SetItemToolTip( 2,
_( _( "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
"Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
#endif #endif
/* Controls on right side of the dialog */ /* Controls on right side of the dialog */
...@@ -258,8 +251,10 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() ...@@ -258,8 +251,10 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
m_AutoPlaceCtrl->SetSelection( m_AutoPlaceCtrl->SetSelection(
(m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 ); (m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 );
#if wxCHECK_VERSION( 2, 8, 0 ) #if wxCHECK_VERSION( 2, 8, 0 )
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) ); m_AutoPlaceCtrl->SetItemToolTip( 0,
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) ); _( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1,
_( "Disable hotkey move commands and Auto Placement" ) );
#endif #endif
m_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 ); m_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 );
...@@ -268,22 +263,26 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() ...@@ -268,22 +263,26 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
// Initialize 3D parameters // Initialize 3D parameters
wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ), BoxSizer, 2, 1 ); m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ),
BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL ); BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ), BoxSizer, 2, 1 ); m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ),
BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL ); BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ), BoxSizer, 2, 1 ); m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ),
BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
} }
/* Initialize 3D info displayed in dialog box from values in aStruct3DSource /* Initialize 3D info displayed in dialog box from values in aStruct3DSource
*/ */
void DIALOG_MODULE_BOARD_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER* aStruct3DSource ) void DIALOG_MODULE_BOARD_EDITOR::Transfert3DValuesToDisplay(
S3D_MASTER* aStruct3DSource )
{ {
if( aStruct3DSource ) if( aStruct3DSource )
{ {
...@@ -305,7 +304,8 @@ void DIALOG_MODULE_BOARD_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER* aStruct ...@@ -305,7 +304,8 @@ void DIALOG_MODULE_BOARD_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER* aStruct
/** Copy 3D info displayed in dialog box to values in a item in m_Shapes3D_list /** Copy 3D info displayed in dialog box to values in a item in m_Shapes3D_list
* @param aIndexSelection = item index in m_Shapes3D_list * @param aIndexSelection = item index in m_Shapes3D_list
*/ */
void DIALOG_MODULE_BOARD_EDITOR::TransfertDisplayTo3DValues( int aIndexSelection ) void DIALOG_MODULE_BOARD_EDITOR::TransfertDisplayTo3DValues(
int aIndexSelection )
{ {
if( aIndexSelection >= (int) m_Shapes3D_list.size() ) if( aIndexSelection >= (int) m_Shapes3D_list.size() )
return; return;
...@@ -317,15 +317,15 @@ void DIALOG_MODULE_BOARD_EDITOR::TransfertDisplayTo3DValues( int aIndexSelection ...@@ -317,15 +317,15 @@ void DIALOG_MODULE_BOARD_EDITOR::TransfertDisplayTo3DValues( int aIndexSelection
} }
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event )
/***********************************************************/
{ {
if( m_LastSelected3DShapeIndex >= 0 ) if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex ); TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection(); m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection();
if( m_LastSelected3DShapeIndex < 0 ) // happens under wxGTK when deleting an item in m_3D_ShapeNameListBox wxListBox if( m_LastSelected3DShapeIndex < 0 ) // happens under wxGTK when
// deleting an item in
// m_3D_ShapeNameListBox wxListBox
return; return;
if( m_LastSelected3DShapeIndex >= (int) m_Shapes3D_list.size() ) if( m_LastSelected3DShapeIndex >= (int) m_Shapes3D_list.size() )
...@@ -338,17 +338,13 @@ void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event ) ...@@ -338,17 +338,13 @@ void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event )
} }
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::Add3DShape( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::Add3DShape( wxCommandEvent& event )
/***********************************************************/
{ {
Browse3DLib( event ); Browse3DLib( event );
} }
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event )
/***********************************************************/
{ {
if( m_LastSelected3DShapeIndex >= 0 ) if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex ); TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
...@@ -366,14 +362,13 @@ void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event ) ...@@ -366,14 +362,13 @@ void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event )
{ {
m_LastSelected3DShapeIndex = 0; m_LastSelected3DShapeIndex = 0;
m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex ); m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex );
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] ); Transfert3DValuesToDisplay(
m_Shapes3D_list[m_LastSelected3DShapeIndex] );
} }
} }
/*********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
/*********************************************************************/
{ {
wxString fullfilename, shortfilename; wxString fullfilename, shortfilename;
wxString fullpath; wxString fullpath;
...@@ -385,10 +380,10 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) ...@@ -385,10 +380,10 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif #endif
fullfilename = EDA_FileSelector( _( "3D Shape:" ), fullfilename = EDA_FileSelector( _( "3D Shape:" ),
fullpath, /* Chemin par defaut */ fullpath,
wxEmptyString, /* nom fichier par defaut */ wxEmptyString,
g_Shapes3DExtBuffer, /* extension par defaut */ g_Shapes3DExtBuffer,
mask, /* Masque d'affichage */ mask,
this, this,
wxFD_OPEN, wxFD_OPEN,
TRUE TRUE
...@@ -404,9 +399,11 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) ...@@ -404,9 +399,11 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
* list, just add the library name to the list. Otherwise, add * list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path. * the library name with the full or relative path.
* the relative path, when possible is preferable, * the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths * because it preserve use of default libraries paths, when the path is a
* sub path of these default paths
*/ */
shortfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fullfilename ); shortfilename =
wxGetApp().ReturnFilenameWithRelativePathInLibPath( fullfilename );
S3D_MASTER* new3DShape = new S3D_MASTER( NULL ); S3D_MASTER* new3DShape = new S3D_MASTER( NULL );
new3DShape->m_Shape3DName = shortfilename; new3DShape->m_Shape3DName = shortfilename;
m_Shapes3D_list.push_back( new3DShape ); m_Shapes3D_list.push_back( new3DShape );
...@@ -421,15 +418,14 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) ...@@ -421,15 +418,14 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
} }
/******************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
/******************************************************************************/
{ {
bool change_layer = FALSE; bool change_layer = FALSE;
wxPoint modpos; wxPoint modpos;
wxString msg; wxString msg;
if( m_CurrentModule->m_Flags == 0 ) // this is a simple edition, we must create an undo entry if( m_CurrentModule->m_Flags == 0 ) // this is a simple edition, we
// must create an undo entry
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_CHANGED ); m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_CHANGED );
if( m_DC ) if( m_DC )
...@@ -440,15 +436,20 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) ...@@ -440,15 +436,20 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
// Initialize masks clearances // Initialize masks clearances
m_CurrentModule->m_LocalClearance = m_CurrentModule->m_LocalClearance =
ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl,
m_Parent->m_InternalUnits );
m_CurrentModule->m_LocalSolderMaskMargin = m_CurrentModule->m_LocalSolderMaskMargin =
ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl,
m_Parent->m_InternalUnits );
m_CurrentModule->m_LocalSolderPasteMargin = m_CurrentModule->m_LocalSolderPasteMargin =
ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl,
double dtmp; m_Parent->m_InternalUnits );
double dtmp;
msg = m_SolderPasteMarginRatioCtrl->GetValue(); msg = m_SolderPasteMarginRatioCtrl->GetValue();
msg.ToDouble( &dtmp ); msg.ToDouble( &dtmp );
// A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
// A margin ratio de -50% means no paste on a pad, the ratio must be >= 50
// %
if( dtmp < -50 ) if( dtmp < -50 )
dtmp = -50; dtmp = -50;
m_CurrentModule->m_LocalSolderPasteMarginRatio = dtmp / 100; m_CurrentModule->m_LocalSolderPasteMarginRatio = dtmp / 100;
...@@ -459,11 +460,12 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) ...@@ -459,11 +460,12 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
m_CurrentModule->SetPosition( modpos ); m_CurrentModule->SetPosition( modpos );
// Set orientation // Set orientation
long orient = 0; long orient = 0;
msg = m_OrientValue->GetValue(); msg = m_OrientValue->GetValue();
msg.ToLong( &orient ); msg.ToLong( &orient );
if( m_CurrentModule->m_Orient != orient ) if( m_CurrentModule->m_Orient != orient )
m_CurrentModule->Rotate( m_CurrentModule->m_Pos, orient - m_CurrentModule->m_Orient ); m_CurrentModule->Rotate( m_CurrentModule->m_Pos,
orient - m_CurrentModule->m_Orient );
if( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT if( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT
{ {
...@@ -554,9 +556,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) ...@@ -554,9 +556,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
} }
/***********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event )
/***********************************************************************/
{ {
wxPoint tmp = m_Parent->GetScreen()->m_Curseur; wxPoint tmp = m_Parent->GetScreen()->m_Curseur;
...@@ -568,9 +568,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event ) ...@@ -568,9 +568,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event )
} }
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event )
/***********************************************************/
{ {
wxPoint tmp = m_Parent->GetScreen()->m_Curseur; wxPoint tmp = m_Parent->GetScreen()->m_Curseur;
......
...@@ -257,10 +257,10 @@ void DIALOG_MODULE_MODULE_EDITOR::Browse3DLib( wxCommandEvent& event ) ...@@ -257,10 +257,10 @@ void DIALOG_MODULE_MODULE_EDITOR::Browse3DLib( wxCommandEvent& event )
fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif #endif
fullfilename = EDA_FileSelector( _( "3D Shape:" ), fullfilename = EDA_FileSelector( _( "3D Shape:" ),
fullpath, /* Chemin par defaut */ fullpath,
wxEmptyString, /* nom fichier par defaut */ wxEmptyString,
g_Shapes3DExtBuffer, /* extension par defaut */ g_Shapes3DExtBuffer,
mask, /* Masque d'affichage */ mask,
this, this,
wxFD_OPEN, wxFD_OPEN,
TRUE TRUE
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Name: dialog_general_options.cpp // Name: dialog_general_options.cpp
// Author: jean-pierre Charras // Author: jean-pierre Charras
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/* functions relatives to the dialogs opened from the main menu : /* functions relatives to the dialogs opened from the main menu :
Preferences/general * Preferences/general
Preferences/display * Preferences/display
*/ */
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
...@@ -18,20 +19,17 @@ ...@@ -18,20 +19,17 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
/***********************************************************************************/ Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent,
Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent, wxDC* DC ) : wxDC* DC ) :
DialogGeneralOptionsBoardEditor_base( parent ) DialogGeneralOptionsBoardEditor_base( parent )
/***********************************************************************************/
{ {
m_Parent = parent; m_Parent = parent;
m_DC = DC; m_DC = DC;
init(); init();
} }
/********************************************************************/
void Dialog_GeneralOptions::init() void Dialog_GeneralOptions::init()
/********************************************************************/
{ {
SetFocus(); SetFocus();
...@@ -43,17 +41,18 @@ void Dialog_GeneralOptions::init() ...@@ -43,17 +41,18 @@ void Dialog_GeneralOptions::init()
wxString timevalue; wxString timevalue;
timevalue << g_TimeOut / 60; timevalue << g_TimeOut / 60;
m_SaveTime->SetValue( timevalue ); m_SaveTime->SetValue( timevalue );
/* /*
int layer_count[] = {1,2,4,6,8,10,12,14,16}; * int layer_count[] = {1,2,4,6,8,10,12,14,16};
m_LayerNumber->SetSelection(1); * m_LayerNumber->SetSelection(1);
for ( unsigned ii = 0; ii < sizeof(layer_count); ii++ ) * for ( unsigned ii = 0; ii < sizeof(layer_count); ii++ )
{ * {
if ( g_DesignSettings.m_CopperLayerCount != layer_count[ii] ) * if ( g_DesignSettings.m_CopperLayerCount != layer_count[ii] )
continue; * continue;
m_LayerNumber->SetSelection(ii); * m_LayerNumber->SetSelection(ii);
break; * break;
} * }
*/ */
m_MaxShowLinks->SetValue( g_MaxLinksShowed ); m_MaxShowLinks->SetValue( g_MaxLinksShowed );
m_DrcOn->SetValue( Drc_On ); m_DrcOn->SetValue( Drc_On );
...@@ -76,39 +75,34 @@ void Dialog_GeneralOptions::init() ...@@ -76,39 +75,34 @@ void Dialog_GeneralOptions::init()
} }
/*****************************************************************/
void Dialog_GeneralOptions::OnCancelClick( wxCommandEvent& event ) void Dialog_GeneralOptions::OnCancelClick( wxCommandEvent& event )
/*****************************************************************/
{ {
event.Skip(); event.Skip();
} }
/**************************************************************************/
void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
/**************************************************************************/
{ {
int ii; int ii;
DisplayOpt.DisplayPolarCood = DisplayOpt.DisplayPolarCood =
(m_PolarDisplay->GetSelection() == 0) ? FALSE : true; ( m_PolarDisplay->GetSelection() == 0 ) ? FALSE : true;
ii = g_UnitMetric; ii = g_UnitMetric;
g_UnitMetric = (m_UnitsSelection->GetSelection() == 0) ? 0 : 1; g_UnitMetric = ( m_UnitsSelection->GetSelection() == 0 ) ? 0 : 1;
if( ii != g_UnitMetric ) if( ii != g_UnitMetric )
m_Parent->ReCreateAuxiliaryToolbar(); m_Parent->ReCreateAuxiliaryToolbar();
m_Parent->m_CursorShape = m_CursorShape->GetSelection(); m_Parent->m_CursorShape = m_CursorShape->GetSelection();
g_TimeOut = 60 * m_SaveTime->GetValue(); g_TimeOut = 60 * m_SaveTime->GetValue();
/* Mise a jour de la combobox d'affichage de la couche active */ /* Updating the combobox to display the active layer. */
g_MaxLinksShowed = m_MaxShowLinks->GetValue(); g_MaxLinksShowed = m_MaxShowLinks->GetValue();
Drc_On = m_DrcOn->GetValue(); Drc_On = m_DrcOn->GetValue();
if( g_Show_Ratsnest != m_ShowGlobalRatsnest->GetValue() ) if( g_Show_Ratsnest != m_ShowGlobalRatsnest->GetValue() )
{ {
g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue(); g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue();
m_Parent->Ratsnest_On_Off( m_DC ); m_Parent->Ratsnest_On_Off( m_DC );
m_Parent->RedrawActiveWindow( m_DC, true); m_Parent->RedrawActiveWindow( m_DC, true );
} }
g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue();
g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); g_AutoDeleteOldTrack = m_TrackAutodel->GetValue();
...@@ -117,7 +111,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) ...@@ -117,7 +111,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue(); m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue();
g_TwoSegmentTrackBuild = m_Track_DoubleSegm_Ctrl->GetValue(); g_TwoSegmentTrackBuild = m_Track_DoubleSegm_Ctrl->GetValue();
g_MagneticPadOption = m_MagneticPadOptCtrl->GetSelection(); g_MagneticPadOption = m_MagneticPadOptCtrl->GetSelection();
g_MagneticTrackOption = m_MagneticTrackOptCtrl->GetSelection(); g_MagneticTrackOption = m_MagneticTrackOptCtrl->GetSelection();
EndModal( 1 ); EndModal( 1 );
...@@ -126,45 +120,38 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) ...@@ -126,45 +120,38 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
#include "dialog_graphic_items_options.cpp" #include "dialog_graphic_items_options.cpp"
/*****************************************************************/
void WinEDA_PcbFrame::InstallPcbOptionsFrame( const wxPoint& pos, void WinEDA_PcbFrame::InstallPcbOptionsFrame( const wxPoint& pos,
wxDC* DC, int id ) wxDC* DC, int id )
/*****************************************************************/
{ {
switch( id ) switch( id )
{ {
case ID_PCB_DRAWINGS_WIDTHS_SETUP: case ID_PCB_DRAWINGS_WIDTHS_SETUP:
{ {
WinEDA_GraphicItemsOptionsDialog dlg( this ); WinEDA_GraphicItemsOptionsDialog dlg( this );
dlg.ShowModal(); dlg.ShowModal();
} }
break; break;
default: default:
wxMessageBox(wxT("InstallPcbOptionsFrame() id error")); wxMessageBox( wxT( "InstallPcbOptionsFrame() id error" ) );
break; break;
} }
} }
/*******************************************************************/
void WinEDA_ModuleEditFrame::InstallOptionsFrame( const wxPoint& pos ) void WinEDA_ModuleEditFrame::InstallOptionsFrame( const wxPoint& pos )
/*******************************************************************/
{ {
WinEDA_GraphicItemsOptionsDialog dlg( this ); WinEDA_GraphicItemsOptionsDialog dlg( this );
dlg.ShowModal(); dlg.ShowModal();
} }
/*****************************************************************/
void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
/*****************************************************************/
/* Must be called on a click on the left toolbar (options toolbar /* Must be called on a click on the left toolbar (options toolbar
* Update variables according to the tools states * Update variables according to the tools states
*/ */
void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
...@@ -177,16 +164,16 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -177,16 +164,16 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_GRID: case ID_TB_OPTIONS_SHOW_GRID:
m_Draw_Grid = m_OptionsToolBar->GetToolState( id ); m_Draw_Grid = m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_RATSNEST: case ID_TB_OPTIONS_SHOW_RATSNEST:
g_Show_Ratsnest = m_OptionsToolBar->GetToolState( id ); g_Show_Ratsnest = m_OptionsToolBar->GetToolState( id );
{ {
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc ); DrawPanel->PrepareGraphicContext( &dc );
Ratsnest_On_Off( &dc ); Ratsnest_On_Off( &dc );
RedrawActiveWindow( &dc, true); RedrawActiveWindow( &dc, true );
} }
break; break;
...@@ -201,7 +188,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -201,7 +188,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
if( id == ID_TB_OPTIONS_SELECT_UNIT_INCH ) if( id == ID_TB_OPTIONS_SELECT_UNIT_INCH )
g_UnitMetric = INCHES; g_UnitMetric = INCHES;
m_TrackAndViasSizesList_Changed = true; m_TrackAndViasSizesList_Changed = true;
UpdateStatusBar(); /* Reaffichage des coord curseur */ UpdateStatusBar();
ReCreateAuxiliaryToolbar(); ReCreateAuxiliaryToolbar();
DisplayUnitsMsg(); DisplayUnitsMsg();
break; break;
...@@ -209,7 +196,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -209,7 +196,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_POLAR_COORD: case ID_TB_OPTIONS_SHOW_POLAR_COORD:
Affiche_Message( wxEmptyString ); Affiche_Message( wxEmptyString );
DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id ); DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id );
UpdateStatusBar(); /* Reaffichage des coord curseur */ UpdateStatusBar();
break; break;
case ID_TB_OPTIONS_SELECT_CURSOR: case ID_TB_OPTIONS_SELECT_CURSOR:
...@@ -222,17 +209,17 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -222,17 +209,17 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_ZONES: case ID_TB_OPTIONS_SHOW_ZONES:
DisplayOpt.DisplayZonesMode = 0; DisplayOpt.DisplayZonesMode = 0;
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE: case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1; DisplayOpt.DisplayZonesMode = 1;
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY: case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2; DisplayOpt.DisplayZonesMode = 2;
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_PADS_SKETCH: case ID_TB_OPTIONS_SHOW_PADS_SKETCH:
...@@ -244,7 +231,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -244,7 +231,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
{ {
m_DisplayPadFill = DisplayOpt.DisplayPadFill = true; m_DisplayPadFill = DisplayOpt.DisplayPadFill = true;
} }
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH: case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
...@@ -256,29 +243,32 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -256,29 +243,32 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
{ {
m_DisplayViaFill = DisplayOpt.DisplayViaFill = true; m_DisplayViaFill = DisplayOpt.DisplayViaFill = true;
} }
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH: case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill =
!m_OptionsToolBar->GetToolState( id ); !m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE: case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
DisplayOpt.ContrastModeDisplay = DisplayOpt.ContrastModeDisplay =
m_OptionsToolBar->GetToolState( id ); m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE: case ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE:
g_DesignSettings.SetElementVisibility( MODULE_TEXT_NOV_VISIBLE, g_DesignSettings.SetElementVisibility( MODULE_TEXT_NOV_VISIBLE,
m_OptionsToolBar->GetToolState( id )); m_OptionsToolBar->GetToolState( id ) );
DrawPanel->Refresh( ); DrawPanel->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1: case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1:
#if !defined(KICAD_AUIMANAGER) #if !defined(KICAD_AUIMANAGER)
if( m_OptionsToolBar->GetToolState( id ) ) // show aux V toolbar (Microwave tool) if( m_OptionsToolBar->GetToolState( id ) ) // show aux V toolbar
// (Microwave tool)
ReCreateAuxVToolbar(); ReCreateAuxVToolbar();
else else
{ {
...@@ -291,17 +281,16 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -291,17 +281,16 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
OnSize( SizeEv ); OnSize( SizeEv );
} }
#else #else
m_auimgr.GetPane(wxT("m_AuxVToolBar")).Show( m_OptionsToolBar->GetToolState( id ) ); m_auimgr.GetPane( wxT( "m_AuxVToolBar" ) ).Show( m_OptionsToolBar->GetToolState( id ) );
m_auimgr.Update(); m_auimgr.Update();
#endif #endif
break; break;
default: default:
DisplayError( this, DisplayError( this,
wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error \n (event not handled!)" ) ); wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error \n (event not handled!)" ) );
break; break;
} }
SetToolbars(); SetToolbars();
} }
/*************************************************/ /************************************/
/* dialog_graphic_items_options.cpp - Gestion des Options et Reglages */ /* dialog_graphic_items_options.cpp */
/*************************************************/ /************************************/
/*
Affichage et modifications des parametres de travail de PcbNew
*/
#include "fctsys.h" #include "fctsys.h"
...@@ -24,79 +20,76 @@ ...@@ -24,79 +20,76 @@
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
/**************************************************************/
void WinEDA_GraphicItemsOptionsDialog::SetDisplayValue() void WinEDA_GraphicItemsOptionsDialog::SetDisplayValue()
/**************************************************************/
{ {
/* Drawings width */ /* Drawings width */
AddUnitSymbol(*m_GraphicSegmWidthTitle); AddUnitSymbol( *m_GraphicSegmWidthTitle );
PutValueInLocalUnits(*m_OptPcbSegmWidth, PutValueInLocalUnits( *m_OptPcbSegmWidth,
g_DesignSettings.m_DrawSegmentWidth, PCB_INTERNAL_UNIT ); g_DesignSettings.m_DrawSegmentWidth,
/* Edges width */ PCB_INTERNAL_UNIT );
AddUnitSymbol(*m_BoardEdgesWidthTitle); /* Edges width */
PutValueInLocalUnits(*m_OptPcbEdgesWidth, AddUnitSymbol( *m_BoardEdgesWidthTitle );
g_DesignSettings.m_EdgeSegmentWidth, PCB_INTERNAL_UNIT ); PutValueInLocalUnits( *m_OptPcbEdgesWidth,
g_DesignSettings.m_EdgeSegmentWidth,
/* Pcb Textes (Size & Width) */ PCB_INTERNAL_UNIT );
AddUnitSymbol(*m_CopperTextWidthTitle);
PutValueInLocalUnits(*m_OptPcbTextWidth, /* Pcb Textes (Size & Width) */
g_DesignSettings.m_PcbTextWidth, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_CopperTextWidthTitle );
PutValueInLocalUnits( *m_OptPcbTextWidth,
AddUnitSymbol(*m_TextSizeVTitle); g_DesignSettings.m_PcbTextWidth, PCB_INTERNAL_UNIT );
PutValueInLocalUnits(*m_OptPcbTextVSize,
g_DesignSettings.m_PcbTextSize.y, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_TextSizeVTitle );
PutValueInLocalUnits( *m_OptPcbTextVSize,
AddUnitSymbol(*m_TextSizeHTitle); g_DesignSettings.m_PcbTextSize.y, PCB_INTERNAL_UNIT );
PutValueInLocalUnits(*m_OptPcbTextHSize,
g_DesignSettings.m_PcbTextSize.x, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_TextSizeHTitle );
PutValueInLocalUnits( *m_OptPcbTextHSize,
g_DesignSettings.m_PcbTextSize.x, PCB_INTERNAL_UNIT );
/* Modules: Edges width */
AddUnitSymbol(*m_EdgeModWidthTitle);
PutValueInLocalUnits(*m_OptModuleEdgesWidth, /* Modules: Edges width */
ModuleSegmentWidth, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_EdgeModWidthTitle );
PutValueInLocalUnits( *m_OptModuleEdgesWidth,
/* Modules: Texts: Size & width */ ModuleSegmentWidth, PCB_INTERNAL_UNIT );
AddUnitSymbol(*m_TextModWidthTitle);
PutValueInLocalUnits(*m_OptModuleTextWidth, /* Modules: Texts: Size & width */
ModuleTextWidth, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_TextModWidthTitle );
PutValueInLocalUnits( *m_OptModuleTextWidth,
AddUnitSymbol(*m_TextModSizeVTitle); ModuleTextWidth, PCB_INTERNAL_UNIT );
PutValueInLocalUnits(*m_OptModuleTextVSize,
ModuleTextSize.y, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_TextModSizeVTitle );
PutValueInLocalUnits( *m_OptModuleTextVSize,
AddUnitSymbol(*m_TextModSizeHTitle); ModuleTextSize.y, PCB_INTERNAL_UNIT );
PutValueInLocalUnits(*m_OptModuleTextHSize,
ModuleTextSize.x, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_TextModSizeHTitle );
PutValueInLocalUnits( *m_OptModuleTextHSize,
ModuleTextSize.x, PCB_INTERNAL_UNIT );
} }
/*********************************************************************/ void WinEDA_GraphicItemsOptionsDialog::AcceptOptions( wxCommandEvent& event )
void WinEDA_GraphicItemsOptionsDialog::AcceptOptions(wxCommandEvent& event)
/*********************************************************************/
{ {
g_DesignSettings.m_DrawSegmentWidth = g_DesignSettings.m_DrawSegmentWidth =
ReturnValueFromTextCtrl( *m_OptPcbSegmWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbSegmWidth, PCB_INTERNAL_UNIT );
g_DesignSettings.m_EdgeSegmentWidth = g_DesignSettings.m_EdgeSegmentWidth =
ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth, PCB_INTERNAL_UNIT );
g_DesignSettings.m_PcbTextWidth = g_DesignSettings.m_PcbTextWidth =
ReturnValueFromTextCtrl( *m_OptPcbTextWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbTextWidth, PCB_INTERNAL_UNIT );
g_DesignSettings.m_PcbTextSize.y = g_DesignSettings.m_PcbTextSize.y =
ReturnValueFromTextCtrl( *m_OptPcbTextVSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbTextVSize, PCB_INTERNAL_UNIT );
g_DesignSettings.m_PcbTextSize.x = g_DesignSettings.m_PcbTextSize.x =
ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT );
ModuleSegmentWidth = ModuleSegmentWidth =
ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT );
ModuleTextWidth = ModuleTextWidth =
ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT );
ModuleTextSize.y = ModuleTextSize.y =
ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT );
ModuleTextSize.x = ModuleTextSize.x =
ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT );
EndModal(1); EndModal( 1 );
} }
...@@ -113,161 +106,300 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_GraphicItemsOptionsDialog, wxDialog ) ...@@ -113,161 +106,300 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_GraphicItemsOptionsDialog, wxDialog )
BEGIN_EVENT_TABLE( WinEDA_GraphicItemsOptionsDialog, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_GraphicItemsOptionsDialog, wxDialog )
////@begin WinEDA_GraphicItemsOptionsDialog event table entries ////@begin WinEDA_GraphicItemsOptionsDialog event table entries
EVT_BUTTON( wxID_OK, WinEDA_GraphicItemsOptionsDialog::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_GraphicItemsOptionsDialog::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_GraphicItemsOptionsDialog::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_GraphicItemsOptionsDialog::OnCancelClick )
////@end WinEDA_GraphicItemsOptionsDialog event table entries ////@end WinEDA_GraphicItemsOptionsDialog event table entries
END_EVENT_TABLE() END_EVENT_TABLE()
/*! /*!
* WinEDA_GraphicItemsOptionsDialog constructors * WinEDA_GraphicItemsOptionsDialog constructors
*/ */
WinEDA_GraphicItemsOptionsDialog::WinEDA_GraphicItemsOptionsDialog( ) WinEDA_GraphicItemsOptionsDialog::WinEDA_GraphicItemsOptionsDialog()
{ {
} }
WinEDA_GraphicItemsOptionsDialog::WinEDA_GraphicItemsOptionsDialog( WinEDA_BasePcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
WinEDA_GraphicItemsOptionsDialog::WinEDA_GraphicItemsOptionsDialog(
WinEDA_BasePcbFrame* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{ {
Create(parent, id, caption, pos, size, style); Create( parent, id, caption, pos, size, style );
} }
/*! /*!
* WinEDA_GraphicItemsOptionsDialog creator * WinEDA_GraphicItemsOptionsDialog creator
*/ */
bool WinEDA_GraphicItemsOptionsDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) bool WinEDA_GraphicItemsOptionsDialog::Create( wxWindow* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{ {
////@begin WinEDA_GraphicItemsOptionsDialog member initialisation ////@begin WinEDA_GraphicItemsOptionsDialog member initialisation
m_GraphicSegmWidthTitle = NULL; m_GraphicSegmWidthTitle = NULL;
m_OptPcbSegmWidth = NULL; m_OptPcbSegmWidth = NULL;
m_BoardEdgesWidthTitle = NULL; m_BoardEdgesWidthTitle = NULL;
m_OptPcbEdgesWidth = NULL; m_OptPcbEdgesWidth = NULL;
m_CopperTextWidthTitle = NULL; m_CopperTextWidthTitle = NULL;
m_OptPcbTextWidth = NULL; m_OptPcbTextWidth = NULL;
m_TextSizeVTitle = NULL; m_TextSizeVTitle = NULL;
m_OptPcbTextVSize = NULL; m_OptPcbTextVSize = NULL;
m_TextSizeHTitle = NULL; m_TextSizeHTitle = NULL;
m_OptPcbTextHSize = NULL; m_OptPcbTextHSize = NULL;
m_EdgeModWidthTitle = NULL; m_EdgeModWidthTitle = NULL;
m_OptModuleEdgesWidth = NULL; m_OptModuleEdgesWidth = NULL;
m_TextModWidthTitle = NULL; m_TextModWidthTitle = NULL;
m_OptModuleTextWidth = NULL; m_OptModuleTextWidth = NULL;
m_TextModSizeVTitle = NULL; m_TextModSizeVTitle = NULL;
m_OptModuleTextVSize = NULL; m_OptModuleTextVSize = NULL;
m_TextModSizeHTitle = NULL; m_TextModSizeHTitle = NULL;
m_OptModuleTextHSize = NULL; m_OptModuleTextHSize = NULL;
////@end WinEDA_GraphicItemsOptionsDialog member initialisation ////@end WinEDA_GraphicItemsOptionsDialog member initialisation
////@begin WinEDA_GraphicItemsOptionsDialog creation ////@begin WinEDA_GraphicItemsOptionsDialog creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS); SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style ); wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls(); CreateControls();
if (GetSizer()) if( GetSizer() )
{ {
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
} }
Centre(); Centre();
////@end WinEDA_GraphicItemsOptionsDialog creation ////@end WinEDA_GraphicItemsOptionsDialog creation
return true; return true;
} }
/*! /*!
* Control creation for WinEDA_GraphicItemsOptionsDialog * Control creation for WinEDA_GraphicItemsOptionsDialog
*/ */
void WinEDA_GraphicItemsOptionsDialog::CreateControls() void WinEDA_GraphicItemsOptionsDialog::CreateControls()
{ {
////@begin WinEDA_GraphicItemsOptionsDialog content construction ////@begin WinEDA_GraphicItemsOptionsDialog content construction
// Generated by DialogBlocks, 29/04/2009 15:15:02 (unregistered) // Generated by DialogBlocks, 29/04/2009 15:15:02 (unregistered)
WinEDA_GraphicItemsOptionsDialog* itemDialog1 = this; WinEDA_GraphicItemsOptionsDialog* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxHORIZONTAL );
itemDialog1->SetSizer(itemBoxSizer2);
itemDialog1->SetSizer( itemBoxSizer2 );
wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Graphics:"));
wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL); wxStaticBox* itemStaticBoxSizer3Static =
itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxGROW|wxALL, 5); new wxStaticBox(itemDialog1, wxID_ANY, _( "Graphics:" ) );
wxStaticBoxSizer* itemStaticBoxSizer3 =
m_GraphicSegmWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Graphic segm Width"), wxDefaultPosition, wxDefaultSize, 0 ); new wxStaticBoxSizer( itemStaticBoxSizer3Static, wxVERTICAL );
itemStaticBoxSizer3->Add(m_GraphicSegmWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); itemBoxSizer2->Add( itemStaticBoxSizer3, 0, wxGROW | wxALL, 5 );
m_OptPcbSegmWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_SEGW, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); m_GraphicSegmWidthTitle =
itemStaticBoxSizer3->Add(m_OptPcbSegmWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); new wxStaticText( itemDialog1, wxID_STATIC, _( "Graphic segm Width" ),
wxDefaultPosition, wxDefaultSize, 0 );
m_BoardEdgesWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Board Edges Width"), wxDefaultPosition, wxDefaultSize, 0 ); itemStaticBoxSizer3->Add( m_GraphicSegmWidthTitle,
itemStaticBoxSizer3->Add(m_BoardEdgesWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); 0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
m_OptPcbEdgesWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_EDGES, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); wxADJUST_MINSIZE,
itemStaticBoxSizer3->Add(m_OptPcbEdgesWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); 5 );
m_CopperTextWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Copper Text Width"), wxDefaultPosition, wxDefaultSize, 0 ); m_OptPcbSegmWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_SEGW,
itemStaticBoxSizer3->Add(m_CopperTextWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); _T( "" ), wxDefaultPosition,
wxDefaultSize, 0 );
m_OptPcbTextWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTW, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); itemStaticBoxSizer3->Add( m_OptPcbSegmWidth,
itemStaticBoxSizer3->Add(m_OptPcbTextWidth, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); 0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
m_TextSizeVTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Size V"), wxDefaultPosition, wxDefaultSize, 0 ); 5 );
itemStaticBoxSizer3->Add(m_TextSizeVTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_BoardEdgesWidthTitle =
m_OptPcbTextVSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTV, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); new wxStaticText( itemDialog1, wxID_STATIC, _( "Board Edges Width" ),
itemStaticBoxSizer3->Add(m_OptPcbTextVSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_BoardEdgesWidthTitle,
m_TextSizeHTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Size H"), wxDefaultPosition, wxDefaultSize, 0 ); 0,
itemStaticBoxSizer3->Add(m_TextSizeHTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
m_OptPcbTextHSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTH, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); 5 );
itemStaticBoxSizer3->Add(m_OptPcbTextHSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_OptPcbEdgesWidth =
itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); new wxTextCtrl( itemDialog1, ID_TEXTCTRL_EDGES, _T( "" ),
wxDefaultPosition, wxDefaultSize, 0 );
wxStaticBox* itemStaticBoxSizer15Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Modules:")); itemStaticBoxSizer3->Add( m_OptPcbEdgesWidth,
wxStaticBoxSizer* itemStaticBoxSizer15 = new wxStaticBoxSizer(itemStaticBoxSizer15Static, wxVERTICAL); 0,
itemBoxSizer2->Add(itemStaticBoxSizer15, 0, wxGROW|wxALL, 5); wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
m_EdgeModWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Edges Module Width"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer15->Add(m_EdgeModWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); m_CopperTextWidthTitle =
new wxStaticText( itemDialog1, wxID_STATIC, _( "Copper Text Width" ),
m_OptModuleEdgesWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_EDGEMOD_W, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer15->Add(m_OptModuleEdgesWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); itemStaticBoxSizer3->Add( m_CopperTextWidthTitle,
0,
m_TextModWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Module Width"), wxDefaultPosition, wxDefaultSize, 0 ); wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
itemStaticBoxSizer15->Add(m_TextModWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); wxADJUST_MINSIZE,
5 );
m_OptModuleTextWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TXTMOD_W, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer15->Add(m_OptModuleTextWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); m_OptPcbTextWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTW,
_T( "" ), wxDefaultPosition,
m_TextModSizeVTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Module Size V"), wxDefaultPosition, wxDefaultSize, 0 ); wxDefaultSize, 0 );
itemStaticBoxSizer15->Add(m_TextModSizeVTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); itemStaticBoxSizer3->Add( m_OptPcbTextWidth,
0,
m_OptModuleTextVSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TXTMOD_V, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM,
itemStaticBoxSizer15->Add(m_OptModuleTextVSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); 5 );
m_TextModSizeHTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Module Size H"), wxDefaultPosition, wxDefaultSize, 0 ); m_TextSizeVTitle = new wxStaticText( itemDialog1, wxID_STATIC,
itemStaticBoxSizer15->Add(m_TextModSizeHTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); _( "Text Size V" ), wxDefaultPosition,
wxDefaultSize, 0 );
m_OptModuleTextHSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TXTMOD_H, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); itemStaticBoxSizer3->Add( m_TextSizeVTitle,
itemStaticBoxSizer15->Add(m_OptModuleTextHSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); 0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxADJUST_MINSIZE,
5 );
wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_OptPcbTextVSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTV,
_T( "" ), wxDefaultPosition,
wxButton* itemButton26 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); wxDefaultSize, 0 );
itemBoxSizer25->Add(itemButton26, 0, wxGROW|wxALL, 5); itemStaticBoxSizer3->Add( m_OptPcbTextVSize,
0,
wxButton* itemButton27 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
itemBoxSizer25->Add(itemButton27, 0, wxGROW|wxALL, 5); 5 );
m_TextSizeHTitle = new wxStaticText( itemDialog1, wxID_STATIC,
_( "Text Size H" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_TextSizeHTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptPcbTextHSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTH,
_T( "" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_OptPcbTextHSize,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
itemBoxSizer2->Add( 5, 5, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxStaticBox* itemStaticBoxSizer15Static =
new wxStaticBox( itemDialog1, wxID_ANY, _( "Modules:" ) );
wxStaticBoxSizer* itemStaticBoxSizer15 =
new wxStaticBoxSizer( itemStaticBoxSizer15Static, wxVERTICAL );
itemBoxSizer2->Add( itemStaticBoxSizer15, 0, wxGROW | wxALL, 5 );
m_EdgeModWidthTitle =
new wxStaticText( itemDialog1, wxID_STATIC, _( "Edges Module Width" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer15->Add( m_EdgeModWidthTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptModuleEdgesWidth = new wxTextCtrl( itemDialog1,
ID_TEXTCTRL_EDGEMOD_W,
_T( "" ),
wxDefaultPosition,
wxDefaultSize,
0 );
itemStaticBoxSizer15->Add( m_OptModuleEdgesWidth,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
m_TextModWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC,
_( "Text Module Width" ),
wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer15->Add( m_TextModWidthTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptModuleTextWidth = new wxTextCtrl( itemDialog1,
ID_TEXTCTRL_TXTMOD_W,
_T( "" ),
wxDefaultPosition,
wxDefaultSize,
0 );
itemStaticBoxSizer15->Add( m_OptModuleTextWidth,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
m_TextModSizeVTitle = new wxStaticText( itemDialog1, wxID_STATIC,
_( "Text Module Size V" ),
wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer15->Add( m_TextModSizeVTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptModuleTextVSize = new wxTextCtrl( itemDialog1,
ID_TEXTCTRL_TXTMOD_V,
_T( "" ),
wxDefaultPosition,
wxDefaultSize,
0 );
itemStaticBoxSizer15->Add( m_OptModuleTextVSize,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
m_TextModSizeHTitle = new wxStaticText( itemDialog1, wxID_STATIC,
_( "Text Module Size H" ),
wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer15->Add( m_TextModSizeHTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptModuleTextHSize = new wxTextCtrl( itemDialog1,
ID_TEXTCTRL_TXTMOD_H,
_T( "" ),
wxDefaultPosition,
wxDefaultSize,
0 );
itemStaticBoxSizer15->Add( m_OptModuleTextHSize,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
itemBoxSizer2->Add( 5, 5, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxBoxSizer* itemBoxSizer25 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer2->Add( itemBoxSizer25, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxButton* itemButton26 = new wxButton( itemDialog1, wxID_OK, _( "&OK" ),
wxDefaultPosition,
wxDefaultSize, 0 );
itemBoxSizer25->Add( itemButton26, 0, wxGROW | wxALL, 5 );
wxButton* itemButton27 = new wxButton( itemDialog1, wxID_CANCEL,
_( "&Cancel" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemBoxSizer25->Add( itemButton27, 0, wxGROW | wxALL, 5 );
////@end WinEDA_GraphicItemsOptionsDialog content construction ////@end WinEDA_GraphicItemsOptionsDialog content construction
SetDisplayValue(); SetDisplayValue();
} }
/*! /*!
* Should we show tooltips? * Should we show tooltips?
*/ */
...@@ -277,19 +409,23 @@ bool WinEDA_GraphicItemsOptionsDialog::ShowToolTips() ...@@ -277,19 +409,23 @@ bool WinEDA_GraphicItemsOptionsDialog::ShowToolTips()
return true; return true;
} }
/*! /*!
* Get bitmap resources * Get bitmap resources
*/ */
wxBitmap WinEDA_GraphicItemsOptionsDialog::GetBitmapResource( const wxString& name ) wxBitmap WinEDA_GraphicItemsOptionsDialog::GetBitmapResource(
const wxString& name )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin WinEDA_GraphicItemsOptionsDialog bitmap retrieval ////@begin WinEDA_GraphicItemsOptionsDialog bitmap retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullBitmap; return wxNullBitmap;
////@end WinEDA_GraphicItemsOptionsDialog bitmap retrieval ////@end WinEDA_GraphicItemsOptionsDialog bitmap retrieval
} }
/*! /*!
* Get icon resources * Get icon resources
*/ */
...@@ -298,29 +434,34 @@ wxIcon WinEDA_GraphicItemsOptionsDialog::GetIconResource( const wxString& name ) ...@@ -298,29 +434,34 @@ wxIcon WinEDA_GraphicItemsOptionsDialog::GetIconResource( const wxString& name )
{ {
// Icon retrieval // Icon retrieval
////@begin WinEDA_GraphicItemsOptionsDialog icon retrieval ////@begin WinEDA_GraphicItemsOptionsDialog icon retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullIcon; return wxNullIcon;
////@end WinEDA_GraphicItemsOptionsDialog icon retrieval ////@end WinEDA_GraphicItemsOptionsDialog icon retrieval
} }
/*! /*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/ */
void WinEDA_GraphicItemsOptionsDialog::OnOkClick( wxCommandEvent& event ) void WinEDA_GraphicItemsOptionsDialog::OnOkClick( wxCommandEvent& event )
{ {
AcceptOptions(event); AcceptOptions( event );
} }
/*! /*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/ */
void WinEDA_GraphicItemsOptionsDialog::OnCancelClick( wxCommandEvent& event ) void WinEDA_GraphicItemsOptionsDialog::OnCancelClick( wxCommandEvent& event )
{ {
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_GraphicItemsOptionsDialog. ////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in
// WinEDA_GraphicItemsOptionsDialog.
// Before editing this code, remove the block markers. // Before editing this code, remove the block markers.
event.Skip(); event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_GraphicItemsOptionsDialog.
}
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in
// WinEDA_GraphicItemsOptionsDialog.
}
...@@ -15,7 +15,7 @@ static wxString Current_PadNetName; ...@@ -15,7 +15,7 @@ static wxString Current_PadNetName;
#define NBSHAPES 4 #define NBSHAPES 4
int CodeShape[NBSHAPES] = /* forme des pads */ int CodeShape[NBSHAPES] = /* Pad shapes. */
{ {
PAD_CIRCLE, PAD_OVAL, PAD_RECT, PAD_TRAPEZOID PAD_CIRCLE, PAD_OVAL, PAD_RECT, PAD_TRAPEZOID
}; };
...@@ -409,7 +409,7 @@ void DIALOG_PAD_PROPERTIES::SetPadLayersList( long layer_mask ) ...@@ -409,7 +409,7 @@ void DIALOG_PAD_PROPERTIES::SetPadLayersList( long layer_mask )
void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
/*************************************************************************/ /*************************************************************************/
/* Met a jour les differents parametres pour le composant en cours d'dition /* Updates the different parameters for the component being edited.
*/ */
{ {
long PadLayerMask; long PadLayerMask;
......
/******************************************************/ /****************************/
/* Edition of footprint edges */ /* Footprint edges editing. */
/******************************************************/ /****************************/
/**
/* fichier edgemod.cpp */ * Functions to edit graphic items used to draw footprint edges.
*
/* Functions to edit graphic items used to draw footprint edges. * @todo - Arc functions not compete but menus are ready to use.
* Function to Arcs are not made (TODO..) but menus are ready to use
*/ */
#include "fctsys.h" #include "fctsys.h"
...@@ -19,23 +18,20 @@ ...@@ -19,23 +18,20 @@
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
/* Routines Locales */
static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC ); static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Variables locales : */
int ArcValue = 900; int ArcValue = 900;
static wxPoint MoveVector; // Move vector for move edge static wxPoint MoveVector; // Move vector for move edge
static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command static wxPoint CursorInitialPosition; // Mouse cursor inital position for
// move command
/****************************************************************************/
void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
/****************************************************************************/
/* Function to initialise the move function params of a graphic item type DRAWSEGMENT /* Function to initialise the move function params of a graphic item type
* DRAWSEGMENT
*/ */
void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
{ {
if( Edge == NULL ) if( Edge == NULL )
return; return;
...@@ -50,13 +46,10 @@ void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -50,13 +46,10 @@ void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
} }
/*********************************************************************/
void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
/*********************************************************************/
/* /*
* Function to place a graphic item type EDGE_MODULE currently moved * Function to place a graphic item type EDGE_MODULE currently moved
*/ */
void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
{ {
if( Edge == NULL ) if( Edge == NULL )
return; return;
...@@ -77,10 +70,8 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -77,10 +70,8 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
} }
/************************************************************************/
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/
/* Move and redraw the current edited graphic item when mouse is moving */ /* Move and redraw the current edited graphic item when mouse is moving */
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem(); EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem();
...@@ -104,12 +95,9 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -104,12 +95,9 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
} }
/************************************************************************/
static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/
/* Redraw the current edited (moved) graphic item /* Redraw the current edited (moved) graphic item
*/ */
static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem(); EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem();
...@@ -126,7 +114,7 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -126,7 +114,7 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
Edge->m_End = screen->m_Curseur; Edge->m_End = screen->m_Curseur;
/* Mise a jour des coord relatives */ /* Update relative coordinate. */
Edge->m_End0 = Edge->m_End - Module->m_Pos; Edge->m_End0 = Edge->m_End - Module->m_Pos;
RotatePoint( &Edge->m_End0, -Module->m_Orient ); RotatePoint( &Edge->m_End0, -Module->m_Orient );
...@@ -136,9 +124,7 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -136,9 +124,7 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
} }
/***************************************************************************/
void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge ) void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge )
/***************************************************************************/
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
...@@ -146,7 +132,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge ) ...@@ -146,7 +132,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge )
if( Edge == NULL ) if( Edge == NULL )
{ {
Edge = (EDGE_MODULE*)(BOARD_ITEM*) Module->m_Drawings; Edge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings;
for( ; Edge != NULL; Edge = Edge->Next() ) for( ; Edge != NULL; Edge = Edge->Next() )
{ {
if( Edge->Type() != TYPE_EDGE_MODULE ) if( Edge->Type() != TYPE_EDGE_MODULE )
...@@ -164,31 +150,34 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge ) ...@@ -164,31 +150,34 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge )
} }
/***************************************************************************/
void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
/***************************************************************************/
/* Change the EDGE_MODULE Edge layer, (The new layer will be asked) /* Change the EDGE_MODULE Edge layer, (The new layer will be asked)
* if Edge == NULL change the layer of the entire footprint edges * if Edge == NULL change the layer of the entire footprint edges
* @param Edge = edge to edit, or NULL * @param Edge = edge to edit, or NULL
* @param DC = current Device Context * @param DC = current Device Context
*/ */
void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
int new_layer = SILKSCREEN_N_CMP; int new_layer = SILKSCREEN_N_CMP;
if( Edge != NULL ) if( Edge != NULL )
new_layer = Edge->GetLayer(); new_layer = Edge->GetLayer();
/* Ask for the new layer */ /* Ask for the new layer */
new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER ); new_layer = SelectLayer( new_layer,
FIRST_COPPER_LAYER,
LAST_NO_COPPER_LAYER );
if( new_layer < 0 ) if( new_layer < 0 )
return; return;
if ( new_layer >= FIRST_COPPER_LAYER && new_layer <= LAST_COPPER_LAYER ) if( new_layer >= FIRST_COPPER_LAYER && new_layer <= LAST_COPPER_LAYER )
/* an edge is put on a copper layer, and it is very dangerous. a confirmation is requested */
{ {
if ( ! IsOK(this, _("The graphic item will be on a copper layer.It is very dangerous. Are you sure") ) ) /* an edge is put on a copper layer, and it is very dangerous. a
*confirmation is requested */
if( !IsOK( this,
_(
"The graphic item will be on a copper layer. It is very dangerous. Are you sure?" ) ) )
return; return;
} }
...@@ -196,7 +185,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge ) ...@@ -196,7 +185,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
if( Edge == NULL ) if( Edge == NULL )
{ {
Edge = (EDGE_MODULE*)(BOARD_ITEM*) Module->m_Drawings; Edge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings;
for( ; Edge != NULL; Edge = Edge->Next() ) for( ; Edge != NULL; Edge = Edge->Next() )
{ {
if( Edge->Type() != TYPE_EDGE_MODULE ) if( Edge->Type() != TYPE_EDGE_MODULE )
...@@ -214,23 +203,21 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge ) ...@@ -214,23 +203,21 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
} }
/*************************************************************************/ /* Edition of the edge items width
void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC ) * Ask for a new width and init ModuleSegmentWidth.
/*************************************************************************/ * Change the width of EDGE_MODULE Edge if Edge != NULL
/* Edition of the edge items width
* Ask for a new width and init ModuleSegmentWidth.
* Change the width of EDGE_MODULE Edge if Edge != NULL
* @param Edge = edge to edit, or NULL * @param Edge = edge to edit, or NULL
* @param DC = current Device Context * @param DC = current Device Context
* @output ModuleSegmentWidth (global) = new width * @output ModuleSegmentWidth (global) = new width
*/ */
void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC )
{ {
wxString buffer; wxString buffer;
long ll; long ll;
buffer << ModuleSegmentWidth; buffer << ModuleSegmentWidth;
if( Get_Message( _( "New Width (1/10000\"):" ), _("Edge Width"), buffer, this ) ) if( Get_Message( _( "New Width (1/10000\"):" ), _( "Edge Width" ), buffer,
this ) )
return; return;
if( buffer.ToLong( &ll ) ) if( buffer.ToLong( &ll ) )
...@@ -252,47 +239,44 @@ void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -252,47 +239,44 @@ void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC )
} }
/****************************************************************************/
void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge )
/****************************************************************************/
/** Function Delete_Edge_Module /** Function Delete_Edge_Module
* delete EDGE_MODULE Edge * delete EDGE_MODULE Edge
* @param Edge = edge to delete * @param Edge = edge to delete
*/ */
void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge )
{ {
if( Edge == NULL ) if( Edge == NULL )
return; return;
if( Edge->Type() != TYPE_EDGE_MODULE ) if( Edge->Type() != TYPE_EDGE_MODULE )
{ {
DisplayError( this, wxT( "StructType error: TYPE_EDGE_MODULE expected" ) ); DisplayError( this,
wxT( "StructType error: TYPE_EDGE_MODULE expected" ) );
return; return;
} }
MODULE* Module = (MODULE*) Edge->GetParent(); MODULE* Module = (MODULE*) Edge->GetParent();
/* suppression d'un segment */ /* Delete segment. */
Edge ->DeleteStructure(); Edge->DeleteStructure();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
/******************************************************************/
static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/
/* abort function in moving edge. /* abort function in moving edge.
*/ */
static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
EDGE_MODULE* Edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem(); EDGE_MODULE* Edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
if( Edge && (Edge->Type() == TYPE_EDGE_MODULE) ) /* error si non */ if( Edge && ( Edge->Type() == TYPE_EDGE_MODULE ) )
{ {
if( Edge->m_Flags & IS_NEW ) /* effacement du nouveau contour */ if( Edge->m_Flags & IS_NEW ) /* Delete if new module. */
{ {
MODULE* Module = (MODULE*) Edge->GetParent(); MODULE* Module = (MODULE*) Edge->GetParent();
Edge->Draw( Panel, DC, GR_XOR, MoveVector ); Edge->Draw( Panel, DC, GR_XOR, MoveVector );
Edge ->DeleteStructure(); Edge->DeleteStructure();
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
} }
else else
...@@ -308,17 +292,16 @@ static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -308,17 +292,16 @@ static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
/*************************************************************************/
EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
wxDC* DC, int type_edge )
/*************************************************************************/
/* Create a new edge item (line, arc ..). /* Create a new edge item (line, arc ..).
* @param Edge = if NULL: create new edge else terminate edge and create a new edge * @param Edge = if NULL: create new edge else terminate edge and create a
* new edge
* @param DC = current Device Context * @param DC = current Device Context
* @param type_edge = S_SEGMENT,S_ARC .. * @param type_edge = S_SEGMENT,S_ARC ..
* @return the new created edge. * @return the new created edge.
*/ */
EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
wxDC* DC,
int type_edge )
{ {
MODULE* module = GetBoard()->m_Modules; MODULE* module = GetBoard()->m_Modules;
int angle = 0; int angle = 0;
...@@ -336,7 +319,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -336,7 +319,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
/* Add the new item to the Drawings list head*/ /* Add the new item to the Drawings list head*/
module->m_Drawings.PushFront( Edge ); module->m_Drawings.PushFront( Edge );
/* Mise a jour des caracteristiques du segment ou de l'arc */ /* Update characteristics of the segment or arc. */
Edge->m_Flags = IS_NEW; Edge->m_Flags = IS_NEW;
Edge->m_Angle = angle; Edge->m_Angle = angle;
Edge->m_Shape = type_edge; Edge->m_Shape = type_edge;
...@@ -369,8 +352,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -369,8 +352,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
DrawPanel->ManageCurseur = ShowEdgeModule; DrawPanel->ManageCurseur = ShowEdgeModule;
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module;
} }
/* TRANSLATE trace en cours : les coord du point d'arrivee ont ete mises
/* trace en cours : les coord du point d'arrivee ont ete mises
* a jour par la routine Montre_Position_New_Edge_Module * a jour par la routine Montre_Position_New_Edge_Module
*/ */
else else
...@@ -384,7 +366,8 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -384,7 +366,8 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
EDGE_MODULE* newedge = new EDGE_MODULE( module ); EDGE_MODULE* newedge = new EDGE_MODULE( module );
newedge->Copy( Edge ); newedge->Copy( Edge );
// insert _after_ Edge, which is the same as inserting _before_ Edge->Next() // insert _after_ Edge, which is the same as inserting _before_
// Edge->Next()
module->m_Drawings.Insert( newedge, Edge->Next() ); module->m_Drawings.Insert( newedge, Edge->Next() );
Edge->m_Flags = 0; Edge->m_Flags = 0;
...@@ -395,7 +378,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -395,7 +378,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge->m_Start = GetScreen()->m_Curseur; Edge->m_Start = GetScreen()->m_Curseur;
Edge->m_End = Edge->m_Start; Edge->m_End = Edge->m_Start;
/* Mise a jour des coord relatives */ /* Update relative coordinate. */
Edge->m_Start0 = Edge->m_Start - module->m_Pos; Edge->m_Start0 = Edge->m_Start - module->m_Pos;
RotatePoint( &Edge->m_Start0, -module->m_Orient ); RotatePoint( &Edge->m_Start0, -module->m_Orient );
...@@ -414,11 +397,9 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -414,11 +397,9 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
} }
/*************************************************************************/
void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
/*************************************************************************/
/* Terminate a move or create edge function /* Terminate a move or create edge function
*/ */
void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
...@@ -427,7 +408,7 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -427,7 +408,7 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
Edge->m_Flags = 0; Edge->m_Flags = 0;
/* If last segment length is 0: remove it */ /* If last segment length is 0: remove it */
if( Edge->m_Start == Edge->m_End ) if( Edge->m_Start == Edge->m_End )
Edge ->DeleteStructure(); Edge->DeleteStructure();
} }
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
......
/******************************************************/ /**************************************/
/* edit.cpp: fonctions generales de l'edition du PCB */ /* edit.cpp: edit PCB implementation. */
/******************************************************/ /**************************************/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -25,12 +25,8 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame, ...@@ -25,12 +25,8 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame,
EDA_BaseStruct* DrawStruct, wxDC* DC ); EDA_BaseStruct* DrawStruct, wxDC* DC );
/*********************************************************************/ /* Handles the selection of command events. */
void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
/*********************************************************************/
/* Traite les selections d'outils et les commandes appelees du menu POPUP
*/
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
...@@ -136,7 +132,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -136,7 +132,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
break; break;
default: // Finish (abort ) the command default: // Finish (abort) the command
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
...@@ -298,7 +294,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -298,7 +294,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_END_LINE: case ID_POPUP_PCB_END_LINE:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
// EndSegment(&dc); // EndSegment(&dc);
break; break;
case ID_POPUP_PCB_EDIT_TRACK: case ID_POPUP_PCB_EDIT_TRACK:
...@@ -555,7 +551,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -555,7 +551,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones. GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones.
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ ) for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
{ {
// Remove filled aresa in zone // Remove filled areas in zone
ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii ); ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
zone_container->m_FilledPolysList.clear();; zone_container->m_FilledPolysList.clear();;
} }
...@@ -969,10 +965,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -969,10 +965,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
} }
/****************************************************************/
static void Process_Move_Item( WinEDA_PcbFrame* frame, static void Process_Move_Item( WinEDA_PcbFrame* frame,
EDA_BaseStruct* DrawStruct, wxDC* DC ) EDA_BaseStruct* DrawStruct, wxDC* DC )
/****************************************************************/
{ {
if( DrawStruct == NULL ) if( DrawStruct == NULL )
return; return;
...@@ -996,9 +990,7 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame, ...@@ -996,9 +990,7 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame,
} }
/***************************************************************/
void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
/***************************************************************/
{ {
if( Item == NULL ) if( Item == NULL )
return; return;
...@@ -1071,7 +1063,7 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) ...@@ -1071,7 +1063,7 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
default: default:
{ {
wxString Line; wxString Line;
Line.Printf( wxT( "Remove: StructType %d Inattendu" ), Line.Printf( wxT( "Remove: item type %d unknown." ),
Item->Type() ); Item->Type() );
DisplayError( this, Line ); DisplayError( this, Line );
} }
...@@ -1080,9 +1072,7 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) ...@@ -1080,9 +1072,7 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
} }
/****************************************************************/
void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
/*****************************************************************/
{ {
int preslayer = GetScreen()->m_Active_Layer; int preslayer = GetScreen()->m_Active_Layer;
...@@ -1115,8 +1105,8 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) ...@@ -1115,8 +1105,8 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
// layers are also capable of being selected. // layers are also capable of being selected.
else else
{ {
if( (layer != COPPER_LAYER_N) && (layer != LAYER_CMP_N) if( ( layer != COPPER_LAYER_N ) && ( layer != LAYER_CMP_N )
&& (layer >= GetBoard()->m_BoardSettings->GetCopperLayerCount() - 1) ) && ( layer >= GetBoard()->m_BoardSettings->GetCopperLayerCount() - 1 ) )
{ {
// Uncomment following command (and line 17) to beep // Uncomment following command (and line 17) to beep
// the speaker. (Doing that would provide feedback to // the speaker. (Doing that would provide feedback to
...@@ -1132,7 +1122,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) ...@@ -1132,7 +1122,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
// See if we are drawing a segment; if so, add a via? // See if we are drawing a segment; if so, add a via?
if( m_ID_current_state == ID_TRACK_BUTT && current != NULL ) if( m_ID_current_state == ID_TRACK_BUTT && current != NULL )
{ {
if( current->Type() == TYPE_TRACK && (current->m_Flags & IS_NEW) ) if( current->Type() == TYPE_TRACK && ( current->m_Flags & IS_NEW ) )
{ {
// Want to set the routing layers so that it switches properly - // Want to set the routing layers so that it switches properly -
// see the implementation of Other_Layer_Route - the working // see the implementation of Other_Layer_Route - the working
......
...@@ -13,23 +13,23 @@ ...@@ -13,23 +13,23 @@
#include "protos.h" #include "protos.h"
/* Local functions */
static void Move_Texte_Pcb( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void Move_Texte_Pcb( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Abort_Edit_Pcb_Text( WinEDA_DrawPanel* Panel, wxDC* DC ); static void Abort_Edit_Pcb_Text( WinEDA_DrawPanel* Panel, wxDC* DC );
/* variables : */
static TEXTE_PCB s_TextCopy( (BOARD_ITEM*) NULL ); /* copy of the edited text
* (used to undo/redo/abort a complex edition command
*/
/*************************************************************/ static TEXTE_PCB s_TextCopy( (BOARD_ITEM*) NULL ); /* copy of the edited text
void Abort_Edit_Pcb_Text( WinEDA_DrawPanel* Panel, wxDC* DC ) * (used to undo/redo/abort
/*************************************************************/ * a complex edition command
*/
/* /*
* Routine de sortie du menu edit texte Pcb * Abort current text edit progress.
* Si un texte est selectionne, ses coord initiales sont regenerees *
* If a text is selected, its initial coord are regenerated
*/ */
void Abort_Edit_Pcb_Text( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
...@@ -55,13 +55,10 @@ void Abort_Edit_Pcb_Text( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -55,13 +55,10 @@ void Abort_Edit_Pcb_Text( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
/*********************************************************************/
void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
/*********************************************************************/
/* /*
* Place the current text being moving * Place the current text being moving
*/ */
void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
{ {
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
...@@ -81,7 +78,8 @@ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -81,7 +78,8 @@ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
} }
if( TextePcb->m_Flags == IS_MOVED ) // If moved only if( TextePcb->m_Flags == IS_MOVED ) // If moved only
SaveCopyInUndoList( TextePcb, UR_MOVED, TextePcb->m_Pos - s_TextCopy.m_Pos ); SaveCopyInUndoList( TextePcb, UR_MOVED,
TextePcb->m_Pos - s_TextCopy.m_Pos );
else else
{ {
// Restore initial params // Restore initial params
...@@ -96,12 +94,9 @@ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -96,12 +94,9 @@ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
} }
/***********************************************************************/ /* Initialize parameters to move a pcb text
void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC )
/***********************************************************************/
/* Initialise parameters to move a pcb text
*/ */
void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC )
{ {
if( TextePcb == NULL ) if( TextePcb == NULL )
return; return;
...@@ -120,31 +115,24 @@ void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -120,31 +115,24 @@ void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC )
} }
/*************************************************************************/ /* Move PCB text following the cursor. */
static void Move_Texte_Pcb( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void Move_Texte_Pcb( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*************************************************************************/
/* Routine deplacant le texte PCB suivant le curseur de la souris */
{ {
TEXTE_PCB* TextePcb = (TEXTE_PCB*) panel->GetScreen()->GetCurItem(); TEXTE_PCB* TextePcb = (TEXTE_PCB*) panel->GetScreen()->GetCurItem();
if( TextePcb == NULL ) if( TextePcb == NULL )
return; return;
/* effacement du texte : */
if( erase ) if( erase )
TextePcb->Draw( panel, DC, GR_XOR ); TextePcb->Draw( panel, DC, GR_XOR );
TextePcb->m_Pos = panel->GetScreen()->m_Curseur; TextePcb->m_Pos = panel->GetScreen()->m_Curseur;
/* Redessin du Texte */
TextePcb->Draw( panel, DC, GR_XOR ); TextePcb->Draw( panel, DC, GR_XOR );
} }
/**********************************************************************/
void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
/**********************************************************************/
{ {
if( TextePcb == NULL ) if( TextePcb == NULL )
return; return;
...@@ -159,18 +147,16 @@ void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -159,18 +147,16 @@ void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
} }
/*******************************************************/
TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC )
/*******************************************************/
{ {
TEXTE_PCB* TextePcb; TEXTE_PCB* TextePcb;
TextePcb = new TEXTE_PCB( GetBoard() ); TextePcb = new TEXTE_PCB( GetBoard() );
/* Chainage de la nouvelle structure en debut de liste */ /* Add text to the board item list. */
GetBoard()->Add( TextePcb ); GetBoard()->Add( TextePcb );
/* Mise a jour des caracteristiques */ /* Update text properties. */
TextePcb->m_Flags = IS_NEW; TextePcb->m_Flags = IS_NEW;
TextePcb->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ); TextePcb->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
TextePcb->m_Mirror = false; TextePcb->m_Mirror = false;
...@@ -194,9 +180,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) ...@@ -194,9 +180,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC )
} }
/***********************************************************************/
void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
/***********************************************************************/
{ {
int angle = 900; int angle = 900;
int drawmode = GR_XOR; int drawmode = GR_XOR;
...@@ -204,18 +188,18 @@ void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -204,18 +188,18 @@ void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
if( TextePcb == NULL ) if( TextePcb == NULL )
return; return;
/* effacement du texte : */ /* Erase previous text. */
TextePcb->Draw( DrawPanel, DC, GR_XOR ); TextePcb->Draw( DrawPanel, DC, GR_XOR );
TextePcb->m_Orient += angle; TextePcb->m_Orient += angle;
NORMALIZE_ANGLE( TextePcb->m_Orient ); NORMALIZE_ANGLE( TextePcb->m_Orient );
/* Redessin du Texte */ /* Redraw text in new position. */
TextePcb->Draw( DrawPanel, DC, drawmode ); TextePcb->Draw( DrawPanel, DC, drawmode );
TextePcb->DisplayInfo( this ); TextePcb->DisplayInfo( this );
if( TextePcb->m_Flags == 0 ) // i.e. not edited, or moved if( TextePcb->m_Flags == 0 ) // i.e. not edited, or moved
SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->m_Pos ); SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->m_Pos );
else // set flag edit, to show it was a complex command else // set flag edit, to show it was a complex command
TextePcb->m_Flags |= IN_EDIT; TextePcb->m_Flags |= IN_EDIT;
GetScreen()->SetModify(); GetScreen()->SetModify();
......
/******************************************************/ /***********************************/
/* Edition des contours du pcb: Routines */ /* Edit segments and edges of PCB. */
/* d'effacement et d'edition de segments et contours */ /***********************************/
/* du type PCB, draw, edgePCB */
/******************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -15,21 +13,18 @@ ...@@ -15,21 +13,18 @@
#include "protos.h" #include "protos.h"
/* Routines Locales */
static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC ); static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Variables locales : */
static wxPoint s_InitialPosition; // position originelle du curseur souris (fct deplacement)
static wxPoint s_LastPosition; // position courante du curseur souris
/****************************************************************************/ static wxPoint s_InitialPosition; // Initial cursor position.
void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) static wxPoint s_LastPosition; // Current cursor position.
/****************************************************************************/
/* Routine de preparation du deplacement d'un element graphique type DRAWSEGMENT
*/ /* Start move of a graphic element type DRAWSEGMENT */
void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
{ {
if( drawitem == NULL ) if( drawitem == NULL )
return; return;
...@@ -44,13 +39,10 @@ void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) ...@@ -44,13 +39,10 @@ void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
} }
/*********************************************************************/
void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
/*********************************************************************/
/* /*
* Routine de placement de l'element graphique type DRAWSEGMENT en cours de deplacement * Place graphic element of type DRAWSEGMENT.
*/ */
void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
{ {
if( drawitem == NULL ) if( drawitem == NULL )
return; return;
...@@ -64,14 +56,12 @@ void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) ...@@ -64,14 +56,12 @@ void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
drawitem->m_Flags = 0; drawitem->m_Flags = 0;
} }
/*
/************************************************************************/ * Redraw segment during cursor movement.
*/
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/
/* redessin du contour du Segment Edge lors des deplacements de la souris */
{ {
DRAWSEGMENT* Segment = (DRAWSEGMENT*) DRAWSEGMENT* Segment = (DRAWSEGMENT*) panel->GetScreen()->GetCurItem();
panel->GetScreen()->GetCurItem();
int t_fill = DisplayOpt.DisplayDrawItems; int t_fill = DisplayOpt.DisplayDrawItems;
if( Segment == NULL ) if( Segment == NULL )
...@@ -79,7 +69,6 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -79,7 +69,6 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
DisplayOpt.DisplayDrawItems = SKETCH; DisplayOpt.DisplayDrawItems = SKETCH;
/* efface ancienne position */
if( erase ) if( erase )
Segment->Draw( panel, DC, GR_XOR ); Segment->Draw( panel, DC, GR_XOR );
...@@ -94,9 +83,7 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -94,9 +83,7 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
} }
/**************************************************************************/
void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
/**************************************************************************/
{ {
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
int track_fill_copy = DisplayOpt.DisplayDrawItems; int track_fill_copy = DisplayOpt.DisplayDrawItems;
...@@ -104,9 +91,9 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -104,9 +91,9 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
if( Segment == NULL ) if( Segment == NULL )
return; return;
if( Segment->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment if( Segment->m_Flags & IS_NEW ) // Trace in progress.
{ {
/* effacement du segment en cours de trace */ /* Delete current segment. */
DisplayOpt.DisplayDrawItems = SKETCH; DisplayOpt.DisplayDrawItems = SKETCH;
Segment->Draw( DrawPanel, DC, GR_XOR ); Segment->Draw( DrawPanel, DC, GR_XOR );
PtStruct = Segment->Back(); PtStruct = Segment->Back();
...@@ -116,7 +103,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -116,7 +103,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
DisplayOpt.DisplayDrawItems = track_fill_copy; DisplayOpt.DisplayDrawItems = track_fill_copy;
SetCurItem( NULL ); SetCurItem( NULL );
} }
else if( Segment->m_Flags == 0) else if( Segment->m_Flags == 0 )
{ {
Segment->Draw( DrawPanel, DC, GR_XOR ); Segment->Draw( DrawPanel, DC, GR_XOR );
Segment->m_Flags = 0; Segment->m_Flags = 0;
...@@ -128,13 +115,11 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -128,13 +115,11 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
} }
/******************************************************************************/
void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer ) void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer )
/******************************************************************************/
{ {
if( aLayer <= LAST_COPPER_LAYER ) if( aLayer <= LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Copper layer global delete not allowed!" ), 20 ); DisplayError( this, _( "Copper layer global delete not allowed!" ) );
return; return;
} }
...@@ -160,14 +145,15 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer ) ...@@ -160,14 +145,15 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer )
{ {
item->UnLink(); item->UnLink();
picker.m_PickedItem = item; picker.m_PickedItem = item;
pickList.PushItem(picker); pickList.PushItem( picker );
} }
break; break;
default: default:
{ {
wxString msg; wxString msg;
msg.Printf( wxT("Delete_Drawings_All_Layer() error: unknown type %d"), item->Type()); msg.Printf( wxT("Delete_Drawings_All_Layer() error: unknown type %d"),
item->Type() );
wxMessageBox( msg ); wxMessageBox( msg );
break; break;
} }
...@@ -182,9 +168,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer ) ...@@ -182,9 +168,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer )
} }
/*************************************************************/
static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC ) static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/
{ {
DRAWSEGMENT* Segment = (DRAWSEGMENT*) Panel->GetScreen()->GetCurItem(); DRAWSEGMENT* Segment = (DRAWSEGMENT*) Panel->GetScreen()->GetCurItem();
...@@ -208,17 +192,14 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -208,17 +192,14 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
((WinEDA_PcbFrame*)Panel->m_Parent)->SetCurItem( NULL ); ( (WinEDA_PcbFrame*) Panel->m_Parent )->SetCurItem( NULL );
} }
/**********************************************************************/ /* Initialize the drawing of a segment of type other than trace.
*/
DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
int shape, wxDC* DC ) int shape, wxDC* DC )
/**********************************************************************/
/* Routine d'initialisation du trace d'un segment de type autre que piste
*/
{ {
int s_large; int s_large;
int angle = 0; int angle = 0;
...@@ -233,7 +214,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, ...@@ -233,7 +214,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
if( shape == S_ARC ) if( shape == S_ARC )
angle = 900; angle = 900;
if( Segment == NULL ) /* debut reel du trace */ if( Segment == NULL ) /* Create new trace. */
{ {
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) ); SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
Segment->m_Flags = IS_NEW; Segment->m_Flags = IS_NEW;
...@@ -245,8 +226,8 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, ...@@ -245,8 +226,8 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
DrawPanel->ManageCurseur = Montre_Position_NewSegment; DrawPanel->ManageCurseur = Montre_Position_NewSegment;
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; DrawPanel->ForceCloseManageCurseur = Exit_EditEdge;
} }
else /* trace en cours : les coord du point d'arrivee ont ete mises else /* TRANSLATE trace en cours : les coord du point d'arrivee ont
* a jour par la routine Montre_Position_NewSegment*/ * ete mises a jour par la routine Montre_Position_NewSegment*/
{ {
if( Segment->m_Start != Segment->m_End ) if( Segment->m_Start != Segment->m_End )
{ {
...@@ -284,16 +265,14 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, ...@@ -284,16 +265,14 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
} }
/***************************************************************/
void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
/***************************************************************/
{ {
if( Segment == NULL ) if( Segment == NULL )
return; return;
Segment->Draw( DrawPanel, DC, GR_OR ); Segment->Draw( DrawPanel, DC, GR_OR );
/* Effacement si Longueur nulle */ /* Delete if segment length is zero. */
if( Segment->m_Start == Segment->m_End) if( Segment->m_Start == Segment->m_End )
Segment ->DeleteStructure(); Segment ->DeleteStructure();
else else
...@@ -301,7 +280,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -301,7 +280,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
Segment->m_Flags = 0; Segment->m_Flags = 0;
GetBoard()->Add( Segment ); GetBoard()->Add( Segment );
GetScreen()->SetModify(); GetScreen()->SetModify();
SaveCopyInUndoList(Segment, UR_NEW ); SaveCopyInUndoList( Segment, UR_NEW );
} }
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
...@@ -310,11 +289,10 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -310,11 +289,10 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
} }
/************************************************************/ /* Redraw segment during cursor movement
*/
static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel,
wxDC* DC, bool erase ) wxDC* DC, bool erase )
/************************************************************/
/* redessin du contour du Segment Edge lors des deplacements de la souris */
{ {
DRAWSEGMENT* Segment = (DRAWSEGMENT*) DRAWSEGMENT* Segment = (DRAWSEGMENT*)
panel->GetScreen()->GetCurItem(); panel->GetScreen()->GetCurItem();
...@@ -325,16 +303,15 @@ static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, ...@@ -325,16 +303,15 @@ static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel,
DisplayOpt.DisplayDrawItems = SKETCH; DisplayOpt.DisplayDrawItems = SKETCH;
/* efface ancienne position */
if( erase ) if( erase )
Segment->Draw( panel, DC, GR_XOR ); Segment->Draw( panel, DC, GR_XOR );
if( Segments_45_Only && (Segment->m_Shape == S_SEGMENT ) ) if( Segments_45_Only && ( Segment->m_Shape == S_SEGMENT ) )
{ {
Calcule_Coord_Extremite_45( Segment->m_Start.x, Segment->m_Start.y, Calcule_Coord_Extremite_45( Segment->m_Start.x, Segment->m_Start.y,
&Segment->m_End.x, &Segment->m_End.y ); &Segment->m_End.x, &Segment->m_End.y );
} }
else /* ici l'angle d'inclinaison est quelconque */ else /* here the angle is arbitrary */
{ {
Segment->m_End = panel->GetScreen()->m_Curseur; Segment->m_End = panel->GetScreen()->m_Curseur;
} }
......
/************************************************/ /************************************************/
/* Module editor: Dialog box for editing module */ /* Module editor: Dialog box for editing module */
/* properties and carateristics */ /* properties and characteristics */
/************************************************/ /************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -14,12 +14,11 @@ ...@@ -14,12 +14,11 @@
#include "dialog_edit_module_for_BoardEditor.h" #include "dialog_edit_module_for_BoardEditor.h"
/*******************************************************************/
void WinEDA_PcbFrame::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
/*******************************************************************/
/* Fonction relai d'installation de la frame d'dition des proprietes /*
* du module*/ * Show module property dialog.
*/
void WinEDA_PcbFrame::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
{ {
if( Module == NULL ) if( Module == NULL )
return; return;
...@@ -54,13 +53,10 @@ void WinEDA_PcbFrame::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC ) ...@@ -54,13 +53,10 @@ void WinEDA_PcbFrame::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
} }
/*******************************************************************/
void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
/*******************************************************************/
/* /*
* Repositionne l'ancre sous le curseur souris * Position anchor under the cursor.
*/ */
void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
{ {
wxPoint moveVector; wxPoint moveVector;
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
...@@ -73,19 +69,19 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod ) ...@@ -73,19 +69,19 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
pt_mod->m_Pos = GetScreen()->m_Curseur; pt_mod->m_Pos = GetScreen()->m_Curseur;
/* Mise a jour des coord relatives des elements: /* Update the relative coordinates:
* les coordonnees relatives sont relatives a l'ancre, pour orient 0. * The coordinates are relative to the anchor point.
* il faut donc recalculer deltaX et deltaY en orientation 0 */ * Calculate deltaX and deltaY from the anchor. */
RotatePoint( &moveVector, -pt_mod->m_Orient ); RotatePoint( &moveVector, -pt_mod->m_Orient );
/* Mise a jour des coord relatives des pads */ /* Update the pad coordinates. */
pt_pad = (D_PAD*) pt_mod->m_Pads; pt_pad = (D_PAD*) pt_mod->m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{ {
pt_pad->m_Pos0 += moveVector; pt_pad->m_Pos0 += moveVector;
} }
/* Mise a jour des coord relatives contours .. */ /* Update the draw element coordinates. */
PtStruct = pt_mod->m_Drawings; PtStruct = pt_mod->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
...@@ -113,9 +109,7 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod ) ...@@ -113,9 +109,7 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
} }
/**********************************************************************/
void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item ) void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item )
/**********************************************************************/
{ {
if( Item == NULL ) if( Item == NULL )
return; return;
...@@ -154,8 +148,8 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item ) ...@@ -154,8 +148,8 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item )
default: default:
{ {
wxString Line; wxString Line;
Line.Printf( wxT( " Remove: StructType %d Inattendu" ), Line.Printf( wxT( " Remove: draw item type %d unknown." ),
Item->Type() ); Item->Type() );
DisplayError( this, Line ); DisplayError( this, Line );
} }
break; break;
......
/*******************************/ /*******************************/
/* Edition des pistes */ /* Edit tracks */
/* Routines de trace de pistes */
/*******************************/ /*******************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -15,22 +14,19 @@ ...@@ -15,22 +14,19 @@
#include "protos.h" #include "protos.h"
/***********************************************/ /* Displays or hides the ratsnest. */
void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC ) void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC )
/***********************************************/
/* Affiche ou efface le chevelu selon l'etat du bouton d'appel */
{ {
unsigned ii; unsigned ii;
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
{ {
if( g_Show_Ratsnest ) if( g_Show_Ratsnest )
Compile_Ratsnest( DC, TRUE ); Compile_Ratsnest( DC, TRUE );
return; return;
} }
DrawGeneralRatsnest( DC, 0 ); /* effacement eventuel du chevelu affiche */ DrawGeneralRatsnest( DC, 0 );
if( GetBoard()->GetRatsnestsCount() == 0 ) if( GetBoard()->GetRatsnestsCount() == 0 )
return; return;
...@@ -52,22 +48,19 @@ void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC ) ...@@ -52,22 +48,19 @@ void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC )
} }
/*************************************************************************/
void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
/*************************************************************************/
/* /*
* change de couche la piste pointee par la souris : * Exchange layer the track pointed to by the mouse:
* la piste doit etre sur une des couches de travail, * The track must be on one layer of work,
* elle est mise sur l'autre couche de travail, si cela est possible * It is put on another layer of work, if possible
* (ou si DRC = Off ). * (Or DRC = Off).
*/ */
void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
{ {
int ii; int ii;
TRACK* pt_track; TRACK* pt_track;
int l1, l2, nb_segm; int l1, l2, nb_segm;
if( (pt_segm == NULL ) || ( pt_segm->Type() == TYPE_ZONE ) ) if( ( pt_segm == NULL ) || ( pt_segm->Type() == TYPE_ZONE ) )
{ {
return; return;
} }
...@@ -77,13 +70,12 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) ...@@ -77,13 +70,12 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
pt_track = Marque_Une_Piste( GetBoard(), pt_segm, &nb_segm, NULL, true ); pt_track = Marque_Une_Piste( GetBoard(), pt_segm, &nb_segm, NULL, true );
Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_XOR ); Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_XOR );
/* effacement du flag BUSY et sauvegarde en membre .param de la couche /* Clear the BUSY flag and backup member. Param layer original. */
* initiale */
ii = nb_segm; pt_segm = pt_track; ii = nb_segm; pt_segm = pt_track;
for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Next() ) for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Next() )
{ {
pt_segm->SetState( BUSY, OFF ); pt_segm->SetState( BUSY, OFF );
pt_segm->m_Param = pt_segm->GetLayer(); /* pour sauvegarde */ pt_segm->m_Param = pt_segm->GetLayer(); /* For backup. */
} }
ii = 0; pt_segm = pt_track; ii = 0; pt_segm = pt_track;
...@@ -92,7 +84,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) ...@@ -92,7 +84,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
if( pt_segm->Type() == TYPE_VIA ) if( pt_segm->Type() == TYPE_VIA )
continue; continue;
/* inversion des couches */ /* Invert layers. */
if( pt_segm->GetLayer() == l1 ) if( pt_segm->GetLayer() == l1 )
pt_segm->SetLayer( l2 ); pt_segm->SetLayer( l2 );
else if( pt_segm->GetLayer() == l2 ) else if( pt_segm->GetLayer() == l2 )
...@@ -100,21 +92,23 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) ...@@ -100,21 +92,23 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
if( Drc_On && BAD_DRC==m_drc->Drc( pt_segm, GetBoard()->m_Track ) ) if( Drc_On && BAD_DRC==m_drc->Drc( pt_segm, GetBoard()->m_Track ) )
{ {
/* Annulation du changement */ /* Discard changes. */
ii = 0; pt_segm = pt_track; ii = 0;
pt_segm = pt_track;
for( ; ii < nb_segm; ii++, pt_segm = pt_segm->Next() ) for( ; ii < nb_segm; ii++, pt_segm = pt_segm->Next() )
{ {
pt_segm->SetLayer( pt_segm->m_Param ); pt_segm->SetLayer( pt_segm->m_Param );
} }
Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR ); Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR );
DisplayError( this, _( "Drc error, cancelled" ), 10 ); DisplayError( this, _( "Drc error, canceled" ), 10 );
return; return;
} }
} }
Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL ); Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL );
/* controle des extremites de segments: sont-ils sur un pad */ /* Control of segment end point, is it on a pad? */
ii = 0; pt_segm = pt_track; ii = 0; pt_segm = pt_track;
for( ; ii < nb_segm; pt_segm = pt_segm->Next(), ii++ ) for( ; ii < nb_segm; pt_segm = pt_segm->Next(), ii++ )
{ {
...@@ -128,19 +122,19 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) ...@@ -128,19 +122,19 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
} }
/****************************************************************/
bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
/****************************************************************/
{ {
unsigned itmp; unsigned itmp;
if( aTrack == NULL ) if( aTrack == NULL )
{ {
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ) if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer !=
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP; ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
else else
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; ((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM;
UpdateStatusBar(); UpdateStatusBar();
SetToolbars(); SetToolbars();
...@@ -148,12 +142,14 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -148,12 +142,14 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
} }
/* Avoid more than one via on the current location: */ /* Avoid more than one via on the current location: */
if( Locate_Via( GetBoard(), g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) ) if( Locate_Via( GetBoard(), g_CurrentTrackSegment->m_End,
g_CurrentTrackSegment->GetLayer() ) )
return false; return false;
for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() ) for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() )
{ {
if( segm->Type()==TYPE_VIA && g_CurrentTrackSegment->m_End==segm->m_Start ) if( segm->Type()==TYPE_VIA
&& g_CurrentTrackSegment->m_End==segm->m_Start )
return false; return false;
} }
...@@ -164,15 +160,17 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -164,15 +160,17 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
/* DRC error, the change layer is not made */ /* DRC error, the change layer is not made */
return false; return false;
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() ) // We must handle 2 segments // Handle 2 segments.
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() )
{ {
if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), GetBoard()->m_Track ) ) if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(),
GetBoard()->m_Track ) )
return false; return false;
} }
} }
/* Save current state before placing a via. /* Save current state before placing a via.
* If the via canot be placed this current state will be reused * If the via cannot be placed this current state will be reused
*/ */
itmp = g_CurrentTrackList.GetCount(); itmp = g_CurrentTrackList.GetCount();
Begin_Route( g_CurrentTrackSegment, DC ); Begin_Route( g_CurrentTrackSegment, DC );
...@@ -188,21 +186,25 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -188,21 +186,25 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
via->m_Start = via->m_End = g_CurrentTrackSegment->m_End; via->m_Start = via->m_End = g_CurrentTrackSegment->m_End;
int old_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; int old_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
//swap the layers. // swap the layers.
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ) if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer !=
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP; ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
else else
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; ((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM;
/* Adjust the via layer pair */ /* Adjust the via layer pair */
switch ( via->Shape() ) switch ( via->Shape() )
{ {
case VIA_BLIND_BURIED: case VIA_BLIND_BURIED:
via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); via->SetLayerPair( old_layer,
((PCB_SCREEN*)GetScreen())->m_Active_Layer );
via->SetDrillValue( GetBoard()->GetCurrentViaDrill() ); via->SetDrillValue( GetBoard()->GetCurrentViaDrill() );
break; break;
case VIA_MICROVIA: // from external to the near neghbour inner layer case VIA_MICROVIA: // from external to the near neighbor inner layer
if ( old_layer == COPPER_LAYER_N ) if ( old_layer == COPPER_LAYER_N )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_N_2; ((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_N_2;
else if ( old_layer == LAYER_CMP_N ) else if ( old_layer == LAYER_CMP_N )
...@@ -213,10 +215,11 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -213,10 +215,11 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
else if ( old_layer == GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2 ) else if ( old_layer == GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_CMP_N; ((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_CMP_N;
// else error // else error
via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); via->SetLayerPair( old_layer,
((PCB_SCREEN*)GetScreen())->m_Active_Layer );
{ {
NETINFO_ITEM* net = GetBoard()->FindNet( via->GetNet() ); NETINFO_ITEM* net = GetBoard()->FindNet( via->GetNet() );
via->m_Width = net->GetMicroViaSize(); via->m_Width = net->GetMicroViaSize();
} }
break; break;
...@@ -227,7 +230,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -227,7 +230,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
break; break;
} }
if( Drc_On && BAD_DRC==m_drc->Drc( via, GetBoard()->m_Track ) ) if( Drc_On && BAD_DRC==m_drc->Drc( via, GetBoard()->m_Track ) )
{ {
/* DRC fault: the Via cannot be placed here ... */ /* DRC fault: the Via cannot be placed here ... */
delete via; delete via;
...@@ -269,10 +272,11 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -269,10 +272,11 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
* and will be modified next * and will be modified next
*/ */
track->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); // set the layer to the new value // set the layer to the new value
track->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
/* the start point is the via position, /* the start point is the via position and the end point is the cursor
* and the end point is the cursor which also is on the via (will change when moving mouse) * which also is on the via (will change when moving mouse)
*/ */
track->m_Start = track->m_End = via->m_Start; track->m_Start = track->m_End = via->m_Start;
...@@ -295,19 +299,18 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -295,19 +299,18 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
} }
/*************************************************/ /* Displays:
void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC ) * The status of the net on top of the screen segment advanced by mouse.
/*************************************************/ * PCB status or bottom of screen if no segment peak.
/* Affiche:
* le status du net en haut d'ecran du segment pointe par la souris
* ou le status PCB en bas d'ecran si pas de segment pointe
*/ */
void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
{ {
TRACK* pt_segm; TRACK* pt_segm;
int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; int masquelayer =
g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer];
pt_segm = Locate_Pistes( GetBoard()->m_Track, masquelayer, CURSEUR_OFF_GRILLE ); pt_segm = Locate_Pistes( GetBoard()->m_Track, masquelayer,
CURSEUR_OFF_GRILLE );
if( pt_segm == NULL ) if( pt_segm == NULL )
GetBoard()->DisplayInfo( this ); GetBoard()->DisplayInfo( this );
else else
...@@ -315,15 +318,12 @@ void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC ) ...@@ -315,15 +318,12 @@ void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
} }
/**********************************************************************/ /* Draw ratsnest.
void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) *
/**********************************************************************/ * The net edge pad with mouse or module locates the mouse.
* Delete if the ratsnest if no module or pad is selected.
/* Affiche le ratsnest relatif
* au net du pad pointe par la souris
* ou au module localise par la souris
* Efface le chevelu affiche si aucun module ou pad n'est selectionne
*/ */
void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
{ {
D_PAD* pt_pad = NULL; D_PAD* pt_pad = NULL;
MODULE* Module = NULL; MODULE* Module = NULL;
...@@ -331,7 +331,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -331,7 +331,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
if( g_Show_Ratsnest ) if( g_Show_Ratsnest )
return; return;
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
Compile_Ratsnest( DC, TRUE ); Compile_Ratsnest( DC, TRUE );
if( item ) if( item )
...@@ -342,7 +342,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -342,7 +342,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
Module = (MODULE*) pt_pad->GetParent(); Module = (MODULE*) pt_pad->GetParent();
} }
if( pt_pad ) /* Affichage du chevelu du net correspondant */ if( pt_pad ) /* Displaying the ratsnest of the corresponding net. */
{ {
pt_pad->DisplayInfo( this ); pt_pad->DisplayInfo( this );
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
...@@ -350,13 +350,13 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -350,13 +350,13 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii]; RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii];
if( net->GetNet() == pt_pad->GetNet() ) if( net->GetNet() == pt_pad->GetNet() )
{ {
if( (net->m_Status & CH_VISIBLE) != 0 ) if( ( net->m_Status & CH_VISIBLE ) != 0 )
continue; continue;
net->m_Status |= CH_VISIBLE; net->m_Status |= CH_VISIBLE;
if( (net->m_Status & CH_ACTIF) == 0 ) if( ( net->m_Status & CH_ACTIF ) == 0 )
continue; continue;
net->Draw( DrawPanel, DC, GR_XOR, wxPoint(0,0) ); net->Draw( DrawPanel, DC, GR_XOR, wxPoint( 0, 0 ) );
} }
} }
} }
...@@ -364,7 +364,8 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -364,7 +364,8 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
{ {
if( item->Type() == TYPE_TEXTE_MODULE ) if( item->Type() == TYPE_TEXTE_MODULE )
{ {
if( item->GetParent() && (item->GetParent()->Type() == TYPE_MODULE) ) if( item->GetParent()
&& ( item->GetParent()->Type() == TYPE_MODULE ) )
Module = (MODULE*) item->GetParent(); Module = (MODULE*) item->GetParent();
} }
else if( item->Type() == TYPE_MODULE ) else if( item->Type() == TYPE_MODULE )
...@@ -378,10 +379,12 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -378,10 +379,12 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
pt_pad = Module->m_Pads; pt_pad = Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Next() )
{ {
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount();
ii++ )
{ {
RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii]; RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii];
if( (net->m_PadStart == pt_pad) || (net->m_PadEnd == pt_pad) ) if( ( net->m_PadStart == pt_pad )
|| ( net->m_PadEnd == pt_pad ) )
{ {
if( net->m_Status & CH_VISIBLE ) if( net->m_Status & CH_VISIBLE )
continue; continue;
...@@ -390,7 +393,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -390,7 +393,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
if( (net->m_Status & CH_ACTIF) == 0 ) if( (net->m_Status & CH_ACTIF) == 0 )
continue; continue;
net->Draw( DrawPanel, DC, GR_XOR, wxPoint(0,0) ); net->Draw( DrawPanel, DC, GR_XOR, wxPoint( 0, 0 ) );
} }
} }
} }
...@@ -400,8 +403,8 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -400,8 +403,8 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
} }
} }
/* Effacement complet des selections si aucun pad ou module n'a ete localise */ /* Erase if no pad or module has been selected. */
if( (pt_pad == NULL) && (Module == NULL) ) if( ( pt_pad == NULL ) && ( Module == NULL ) )
{ {
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
...@@ -411,12 +414,9 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -411,12 +414,9 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
} }
/*****************************************************/ /* High light the unconnected pads
void WinEDA_PcbFrame::Affiche_PadsNoConnect( wxDC* DC )
/*****************************************************/
/* Hight light the unconnected pads
*/ */
void WinEDA_PcbFrame::Affiche_PadsNoConnect( wxDC* DC )
{ {
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
{ {
......
/*******************************/ /****************/
/* Edition des pistes */ /* Edit traces. */
/* Routines de trace de pistes */ /****************/
/*******************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -16,7 +15,7 @@ ...@@ -16,7 +15,7 @@
#include "protos.h" #include "protos.h"
/* Routines Locales */
static void Exit_Editrack( WinEDA_DrawPanel* panel, wxDC* DC ); static void Exit_Editrack( WinEDA_DrawPanel* panel, wxDC* DC );
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC, bool erase ); wxDC* DC, bool erase );
...@@ -25,19 +24,16 @@ static void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList ); ...@@ -25,19 +24,16 @@ static void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList );
static void EnsureEndTrackOnPad( D_PAD* Pad ); static void EnsureEndTrackOnPad( D_PAD* Pad );
/* variables locales */
static int OldNetCodeSurbrillance; static int OldNetCodeSurbrillance;
static int OldEtatSurbrillance; static int OldEtatSurbrillance;
static PICKED_ITEMS_LIST s_ItemsListPicker; static PICKED_ITEMS_LIST s_ItemsListPicker;
/************************************************************/ /* Routine to cancel the route if a track is being drawn, or exit the
static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC ) * application EDITRACK.
/************************************************************/
/* routine d'annulation de la Commande Begin_Route si une piste est en cours
* de tracage, ou de sortie de l'application EDITRACK.
*/ */
static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) Panel->m_Parent; WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) Panel->m_Parent;
TRACK* track = (TRACK*) frame->GetCurItem(); TRACK* track = (TRACK*) frame->GetCurItem();
...@@ -55,7 +51,8 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -55,7 +51,8 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
// Undo pending changes (mainly a lock point cretion) and clear the undo picker list: // Undo pending changes (mainly a lock point cretion) and clear the
// undo picker list:
frame->PutDataInPreviousState( &s_ItemsListPicker, false, false ); frame->PutDataInPreviousState( &s_ItemsListPicker, false, false );
s_ItemsListPicker.ClearListAndDeleteItems(); s_ItemsListPicker.ClearListAndDeleteItems();
...@@ -69,27 +66,24 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -69,27 +66,24 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
/*************************************************************/
TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
/*************************************************************/
/* /*
* Routine d'initialisation d'un trace de piste et/ou de mise en place d'un * Begin drawing a new track and/or establish of a new track point.
* nouveau point piste
* *
* Si pas de piste en cours de trace: * If no current track record of:
* - Recherche de netname de la nouvelle piste ( pad de depart out netname * - Search netname of the new track (pad out departure netname
* de la piste si depart sur une ancienne piste * if the departure runway on an old track
* - Met en surbrillance tout le net * - Highlight all the net
* - Initilise les divers pointeurs de trace * - Initialize the various trace pointers.
* Si piste en cours: * If current track:
* - controle DRC * - Control DRC
* - si DRC OK : addition d'un nouveau point piste * - OK if DRC: adding a new track.
*/ */
TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
{ {
D_PAD* pt_pad = NULL; D_PAD* pt_pad = NULL;
TRACK* TrackOnStartPoint = NULL; TRACK* TrackOnStartPoint = NULL;
int masquelayer = g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer]; int masquelayer =
g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer];
BOARD_ITEM* LockPoint; BOARD_ITEM* LockPoint;
wxPoint pos = GetScreen()->m_Curseur; wxPoint pos = GetScreen()->m_Curseur;
...@@ -99,7 +93,9 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -99,7 +93,9 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
if( aTrack == NULL ) /* Starting a new track */ if( aTrack == NULL ) /* Starting a new track */
{ {
// Prepare the undo command info // Prepare the undo command info
s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but... s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be
// necessary,
// but...
/* erase old highlight */ /* erase old highlight */
OldNetCodeSurbrillance = g_HightLigth_NetCode; OldNetCodeSurbrillance = g_HightLigth_NetCode;
...@@ -130,14 +126,19 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -130,14 +126,19 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
{ {
TrackOnStartPoint = (TRACK*) LockPoint; TrackOnStartPoint = (TRACK*) LockPoint;
g_HightLigth_NetCode = TrackOnStartPoint->GetNet(); g_HightLigth_NetCode = TrackOnStartPoint->GetNet();
CreateLockPoint( pos, TrackOnStartPoint, NULL, &s_ItemsListPicker ); CreateLockPoint( pos,
TrackOnStartPoint,
NULL,
&s_ItemsListPicker );
} }
} }
else // no starting point, but a filled zone area can exist. This is also a good starting point. else // no starting point, but a filled zone area can exist. This is
// also a good starting point.
{ {
ZONE_CONTAINER* zone = GetBoard()->HitTestForAnyFilledArea( pos, ZONE_CONTAINER* zone =
GetScreen()-> GetBoard()->HitTestForAnyFilledArea( pos,
m_Active_Layer ); GetScreen()->
m_Active_Layer );
if( zone ) if( zone )
g_HightLigth_NetCode = zone->GetNet(); g_HightLigth_NetCode = zone->GetNet();
} }
...@@ -196,37 +197,44 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -196,37 +197,44 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
if( Drc_On ) if( Drc_On )
{ {
if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) if( BAD_DRC ==
m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
{ {
return g_CurrentTrackSegment; return g_CurrentTrackSegment;
} }
} }
} }
else /* Track in progress : segment coordinates are updated by ShowNewTrackWhenMovingCursor*/ else /* Track in progress : segment coordinates are updated by
* ShowNewTrackWhenMovingCursor*/
{ {
/* Tst for a D.R.C. error: */ /* Tst for a D.R.C. error: */
if( Drc_On ) if( Drc_On )
{ {
if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) if( BAD_DRC ==
m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
return NULL; return NULL;
// We must handle 2 segments // We must handle 2 segments
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() ) if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() )
{ {
if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), GetBoard()->m_Track ) ) if( BAD_DRC ==
m_drc->Drc( g_CurrentTrackSegment->Back(),
GetBoard()->m_Track ) )
return NULL; return NULL;
} }
} }
/* Current track is Ok: current segment is kept, and a new one is created /* Current track is Ok: current segment is kept, and a new one is
* unless the current segment is null, or 2 last are null if a 2 segments track build * created unless the current segment is null, or 2 last are null
* if a 2 segments track build.
*/ */
bool CanCreateNewSegment = true; bool CanCreateNewSegment = true;
if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() ) if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() )
CanCreateNewSegment = false; CanCreateNewSegment = false;
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull()
&& g_CurrentTrackSegment->Back() && g_CurrentTrackSegment->Back()->IsNull() ) && g_CurrentTrackSegment->Back()
&& g_CurrentTrackSegment->Back()->IsNull() )
CanCreateNewSegment = false; CanCreateNewSegment = false;
if( CanCreateNewSegment ) if( CanCreateNewSegment )
...@@ -251,7 +259,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -251,7 +259,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
oneBeforeLatest->end = Locate_Pad_Connecte( GetBoard(), oneBeforeLatest, END ); oneBeforeLatest->end = Locate_Pad_Connecte(
GetBoard(), oneBeforeLatest, END );
if( oneBeforeLatest->end ) if( oneBeforeLatest->end )
{ {
oneBeforeLatest->SetState( END_ONPAD, ON ); oneBeforeLatest->SetState( END_ONPAD, ON );
...@@ -281,31 +290,28 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -281,31 +290,28 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
} }
/**************************************************************************/ /* Correct a bend is 90 and changes by 2 elbows at 45
bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC ) * This only works on horizontal or vertical segments.
/***************************************************************************/
/* rectifie un virage a 90 et le modifie par 2 coudes a 45
* n'opere que sur des segments horizontaux ou verticaux.
* *
* entree : pointeur sur le segment qui vient d'etre trace * Input: pointer to the segment that we have drawn
* On suppose que le segment precedent est celui qui a ete * Assume that the preceding segment is one that has been
* precedement trace * previously drawn
* retourne: * Returns:
* 1 si ok * 1 if ok
* 0 si impossible * 0 if not
*/ */
bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
{ {
int pas_45; int pas_45;
int dx0, dy0, dx1, dy1; int dx0, dy0, dx1, dy1;
if( g_CurrentTrackList.GetCount() < 2 ) if( g_CurrentTrackList.GetCount() < 2 )
return false; /* il faut au moins 2 segments */ return false; /* There must be 2 segments. */
TRACK* curTrack = g_CurrentTrackSegment; TRACK* curTrack = g_CurrentTrackSegment;
TRACK* prevTrack = curTrack->Back(); TRACK* prevTrack = curTrack->Back();
// Test s'il y a 2 segments consecutifs a raccorder // Test whether there has 2 consecutive segments to be connected.
if( curTrack->Type() != TYPE_TRACK || prevTrack->Type() != TYPE_TRACK ) if( curTrack->Type() != TYPE_TRACK || prevTrack->Type() != TYPE_TRACK )
{ {
return false; return false;
...@@ -318,21 +324,21 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC ) ...@@ -318,21 +324,21 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
while( pas_45 < curTrack->m_Width ) while( pas_45 < curTrack->m_Width )
pas_45 *= 2; pas_45 *= 2;
// OK : tst si les segments sont a 90 degre et vertic ou horiz // Test if the segments are horizontal or vertical.
dx0 = prevTrack->m_End.x - prevTrack->m_Start.x; dx0 = prevTrack->m_End.x - prevTrack->m_Start.x;
dy0 = prevTrack->m_End.y - prevTrack->m_Start.y; dy0 = prevTrack->m_End.y - prevTrack->m_Start.y;
dx1 = curTrack->m_End.x - curTrack->m_Start.x; dx1 = curTrack->m_End.x - curTrack->m_Start.x;
dy1 = curTrack->m_End.y - curTrack->m_Start.y; dy1 = curTrack->m_End.y - curTrack->m_Start.y;
// les segments doivent etre de longueur suffisante: // Segments must be of sufficient length.
if( MAX( abs( dx0 ), abs( dy0 ) ) < (pas_45 * 2) ) if( MAX( abs( dx0 ), abs( dy0 ) ) < ( pas_45 * 2 ) )
return false; return false;
if( MAX( abs( dx1 ), abs( dy1 ) ) < (pas_45 * 2) ) if( MAX( abs( dx1 ), abs( dy1 ) ) < ( pas_45 * 2 ) )
return false; return false;
/* creation du nouveau segment, raccordant des 2 segm: */ /* Create a new segment and connect it with the previous 2 segments. */
TRACK* newTrack = curTrack->Copy(); TRACK* newTrack = curTrack->Copy();
newTrack->m_Start = prevTrack->m_End; newTrack->m_Start = prevTrack->m_End;
...@@ -340,16 +346,16 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC ) ...@@ -340,16 +346,16 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
if( dx0 == 0 ) // Segment precedent Vertical if( dx0 == 0 ) // Segment precedent Vertical
{ {
if( dy1 != 0 ) // les 2 segments ne sont pas a 90 ; if( dy1 != 0 ) // 2 segments are not 90 degrees.
{ {
delete newTrack; delete newTrack;
return false; return false;
} }
/* Calcul des coordonnees du point de raccord : /* Calculate coordinates the connection point.
* le nouveau segment raccorde le 1er segment Vertical * The new segment connects the 1st segment Vertical and the 2nd
* au 2eme segment Horizontal */ * horizontal segment.
*/
if( dy0 > 0 ) if( dy0 > 0 )
newTrack->m_Start.y -= pas_45; newTrack->m_Start.y -= pas_45;
else else
...@@ -360,7 +366,7 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC ) ...@@ -360,7 +366,7 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
else else
newTrack->m_End.x -= pas_45; newTrack->m_End.x -= pas_45;
if( Drc_On && BAD_DRC==m_drc->Drc( curTrack, GetBoard()->m_Track ) ) if( Drc_On && BAD_DRC == m_drc->Drc( curTrack, GetBoard()->m_Track ) )
{ {
delete newTrack; delete newTrack;
return false; return false;
...@@ -373,20 +379,18 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC ) ...@@ -373,20 +379,18 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
return true; return true;
} }
if( dy0 == 0 ) // Segment precedent Horizontal : dy0 = 0 if( dy0 == 0 ) // Segment precedent horizontal
{ {
if( dx1 != 0 ) // les 2 segments ne sont pas a 90 ; if( dx1 != 0 ) // 2 segments are not 90 degrees
{ {
delete newTrack; delete newTrack;
return false; return false;
} }
// Segments a 90 /* Calculate the coordinates of the point of connection:
* A new segment has been established, connecting segment 1
/* Modif des coordonnees du point de raccord : * (horizontal) and segment 2 (vertical)
* un nouveau segment a ete cree, raccordant le 1er segment Horizontal */
* au 2eme segment Vertical */
if( dx0 > 0 ) if( dx0 > 0 )
newTrack->m_Start.x -= pas_45; newTrack->m_Start.x -= pas_45;
else else
...@@ -414,20 +418,19 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC ) ...@@ -414,20 +418,19 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
} }
/**************************************************************/
void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
/*************************************************************/
/* /*
* Routine de fin de trace d'une piste (succession de segments) * End trace route in progress.
*/ */
void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
{ {
int masquelayer = g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer]; int masquelayer =
g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer];
if( aTrack == NULL ) if( aTrack == NULL )
return; return;
if( Drc_On && BAD_DRC==m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) if( Drc_On && BAD_DRC==
m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
return; return;
/* Sauvegarde des coord du point terminal de la piste */ /* Sauvegarde des coord du point terminal de la piste */
...@@ -438,9 +441,9 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -438,9 +441,9 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
if( Begin_Route( aTrack, DC ) == NULL ) if( Begin_Route( aTrack, DC ) == NULL )
return; return;
ShowNewTrackWhenMovingCursor( DrawPanel, DC, true ); /* mise a jour trace reel */ ShowNewTrackWhenMovingCursor( DrawPanel, DC, true );
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false ); /* efface trace piste*/ ShowNewTrackWhenMovingCursor( DrawPanel, DC, false );
trace_ratsnest_pad( DC ); /* efface trace chevelu*/ trace_ratsnest_pad( DC );
/* cleanup /* cleanup
* if( g_CurrentTrackSegment->Next() != NULL ) * if( g_CurrentTrackSegment->Next() != NULL )
...@@ -453,27 +456,27 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -453,27 +456,27 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
/* La piste est ici non chainee a la liste des segments de piste. /* The track here is non chained to the list of track segments.
* Il faut la replacer dans la zone de net, * It must be seen in the area of net
* le plus pres possible du segment d'attache ( ou de fin ), car * As close as possible to the segment base (or end), because
* ceci contribue a la reduction du temps de calcul */ * This helps to reduce the computing time */
/* Accrochage de la fin de la piste */ /* Attaching the end of the track. */
BOARD_ITEM* LockPoint = LocateLockPoint( GetBoard(), pos, masquelayer ); BOARD_ITEM* LockPoint = LocateLockPoint( GetBoard(), pos, masquelayer );
if( LockPoint ) /* La fin de la piste est sur un PAD */ if( LockPoint ) /* End of trace is on a pad. */
{ {
if( LockPoint->Type() == TYPE_PAD ) if( LockPoint->Type() == TYPE_PAD )
{ {
EnsureEndTrackOnPad( (D_PAD*) LockPoint ); EnsureEndTrackOnPad( (D_PAD*) LockPoint );
} }
else /* la fin de la piste est sur une autre piste: il faudra else /* End of is on a different track, it will
* peut-etre creer un point d'ancrage */ * possibly create an anchor. */
{ {
TRACK* adr_buf = (TRACK*) LockPoint; TRACK* adr_buf = (TRACK*) LockPoint;
g_HightLigth_NetCode = adr_buf->GetNet(); g_HightLigth_NetCode = adr_buf->GetNet();
/* creation eventuelle d'un point d'accrochage */ /* Possible establishment of a hanging point. */
LockPoint = CreateLockPoint( g_CurrentTrackSegment->m_End, LockPoint = CreateLockPoint( g_CurrentTrackSegment->m_End,
adr_buf, adr_buf,
g_CurrentTrackSegment, g_CurrentTrackSegment,
...@@ -484,16 +487,19 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -484,16 +487,19 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
// Delete Null segments: // Delete Null segments:
DeleteNullTrackSegments( GetBoard(), g_CurrentTrackList ); DeleteNullTrackSegments( GetBoard(), g_CurrentTrackList );
// Insert new segments if they exist. This can be NULL on a double click on the start point // Insert new segments if they exist. This can be NULL on a double click
// on the start point
if( g_FirstTrackSegment != NULL ) if( g_FirstTrackSegment != NULL )
{ {
int netcode = g_FirstTrackSegment->GetNet(); int netcode = g_FirstTrackSegment->GetNet();
TRACK* firstTrack = g_FirstTrackSegment; TRACK* firstTrack = g_FirstTrackSegment;
int newCount = g_CurrentTrackList.GetCount(); int newCount = g_CurrentTrackList.GetCount();
// Put entire new current segment list in BOARD, ans prepare undo command // Put entire new current segment list in BOARD, ans prepare undo
// command
TRACK* track; TRACK* track;
TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( GetBoard() ); TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint(
GetBoard() );
while( ( track = g_CurrentTrackList.PopFront() ) != NULL ) while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
{ {
ITEM_PICKER picker( track, UR_NEW ); ITEM_PICKER picker( track, UR_NEW );
...@@ -506,7 +512,7 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -506,7 +512,7 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
Trace_Une_Piste( DrawPanel, DC, firstTrack, newCount, GR_OR ); Trace_Une_Piste( DrawPanel, DC, firstTrack, newCount, GR_OR );
int i = 0; int i = 0;
for( track = firstTrack; track && i<newCount; ++i, track = track->Next() ) for( track = firstTrack; track && i<newCount; ++i, track = track->Next() )
{ {
track->m_Flags = 0; track->m_Flags = 0;
track->SetState( BUSY, OFF ); track->SetState( BUSY, OFF );
...@@ -518,9 +524,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -518,9 +524,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
EraseRedundantTrack( DC, firstTrack, newCount, &s_ItemsListPicker ); EraseRedundantTrack( DC, firstTrack, newCount, &s_ItemsListPicker );
} }
SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED ); SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more
// owner of picked items
/* compute the new rastnest : */ /* compute the new rastnest */
test_1_net_connexion( DC, netcode ); test_1_net_connexion( DC, netcode );
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -554,7 +561,7 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ) ...@@ -554,7 +561,7 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
TRACK* found = NULL; TRACK* found = NULL;
for( TRACK* track = listStart; track; track = track->Next() ) for( TRACK* track = listStart; track; track = track->Next() )
{ {
if( track->Type() == TYPE_TRACK ) // skip vias if( track->Type() == TYPE_TRACK ) // skip vias
{ {
...@@ -568,7 +575,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ) ...@@ -568,7 +575,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
continue; continue;
/* TRACK::HitTest */ /* TRACK::HitTest */
int dist = (width + track->m_Width) / 2 + aTrack->GetClearance( track ); int dist = (width + track->m_Width) / 2 + aTrack->GetClearance(
track );
wxPoint pos = ref - track->m_Start; wxPoint pos = ref - track->m_Start;
wxPoint vec = track->m_End - track->m_Start; wxPoint vec = track->m_End - track->m_Start;
...@@ -580,7 +588,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ) ...@@ -580,7 +588,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
/* prefer intrusions from the side, not the end */ /* prefer intrusions from the side, not the end */
double tmp = (double) pos.x * vec.x + (double) pos.y * vec.y; double tmp = (double) pos.x * vec.x + (double) pos.y * vec.y;
if( tmp >= 0 && tmp <= (double) vec.x * vec.x + (double) vec.y * vec.y ) if( tmp >= 0 && tmp <= (double) vec.x * vec.x + (double) vec.y *
vec.y )
break; break;
} }
} }
...@@ -607,7 +616,7 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ) ...@@ -607,7 +616,7 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
*/ */
static void PushTrack( WinEDA_DrawPanel* panel ) static void PushTrack( WinEDA_DrawPanel* panel )
{ {
BOARD* pcb = ( (WinEDA_BasePcbFrame*)(panel->m_Parent) )->GetBoard(); BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->GetBoard();
wxPoint cursor = ActiveScreen->m_Curseur; wxPoint cursor = ActiveScreen->m_Curseur;
wxPoint cv, vec, n; wxPoint cv, vec, n;
TRACK* track = g_CurrentTrackSegment; TRACK* track = g_CurrentTrackSegment;
...@@ -634,7 +643,10 @@ static void PushTrack( WinEDA_DrawPanel* panel ) ...@@ -634,7 +643,10 @@ static void PushTrack( WinEDA_DrawPanel* panel )
if( !det ) if( !det )
return; return;
dist = (track->m_Width + 1) / 2 + (other->m_Width + 1) / 2 + track->GetClearance( other ) + 2; dist =
(track->m_Width +
1) / 2 + (other->m_Width + 1) / 2 + track->GetClearance(
other ) + 2;
/* /*
* DRC wants >, so +1. * DRC wants >, so +1.
...@@ -661,12 +673,11 @@ static void PushTrack( WinEDA_DrawPanel* panel ) ...@@ -661,12 +673,11 @@ static void PushTrack( WinEDA_DrawPanel* panel )
} }
/****************************************************************************/
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/****************************************************************************/
/* Redraw the current track beiing created when the mouse cursor is moved /* Redraw the current track beiing created when the mouse cursor is moved
*/ */
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase )
{ {
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
...@@ -685,17 +696,22 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ...@@ -685,17 +696,22 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
/* Erase old track */ /* Erase old track */
if( erase ) if( erase )
{ {
Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR ); Trace_Une_Piste( panel,
DC,
g_FirstTrackSegment,
g_CurrentTrackList.GetCount(),
GR_XOR );
frame->trace_ratsnest_pad( DC ); frame->trace_ratsnest_pad( DC );
if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) // Show the via area if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
{ {
int color = g_DesignSettings.m_LayerColor[g_CurrentTrackSegment->GetLayer()]; int color =
g_DesignSettings.m_LayerColor[g_CurrentTrackSegment->GetLayer()];
GRCircle( &panel->m_ClipBox, DC, g_CurrentTrackSegment->m_End.x, GRCircle( &panel->m_ClipBox, DC, g_CurrentTrackSegment->m_End.x,
g_CurrentTrackSegment->m_End.y, g_CurrentTrackSegment->m_End.y,
(netclass->GetViaDiameter() / 2) + netclass->GetClearance(), ( netclass->GetViaDiameter() / 2 ) + netclass->GetClearance(),
color ); color );
} }
} }
...@@ -716,7 +732,8 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ...@@ -716,7 +732,8 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
previous_track->SetLayer( screen->m_Active_Layer ); previous_track->SetLayer( screen->m_Active_Layer );
if( !g_DesignSettings.m_UseConnectedTrackWidth ) if( !g_DesignSettings.m_UseConnectedTrackWidth )
previous_track->m_Width = frame->GetBoard()->GetCurrentTrackWidth(); previous_track->m_Width =
frame->GetBoard()->GetCurrentTrackWidth();
} }
} }
...@@ -729,13 +746,14 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ...@@ -729,13 +746,14 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
if( Drc_On ) if( Drc_On )
PushTrack( panel ); PushTrack( panel );
ComputeBreakPoint( g_CurrentTrackSegment, g_CurrentTrackList.GetCount(), ComputeBreakPoint( g_CurrentTrackSegment,
g_CurrentTrackList.GetCount(),
g_CurrentTrackSegment->m_End ); g_CurrentTrackSegment->m_End );
} }
else else
{ {
/* Calcul de l'extremite de la piste pour orientations permises: /* Calculate of the end of the path for the permitted directions:
* horiz,vertical ou 45 degre * horizontal, vertical or 45 degrees.
*/ */
Calcule_Coord_Extremite_45( g_CurrentTrackSegment->m_Start.x, Calcule_Coord_Extremite_45( g_CurrentTrackSegment->m_Start.x,
g_CurrentTrackSegment->m_Start.y, g_CurrentTrackSegment->m_Start.y,
...@@ -743,28 +761,34 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ...@@ -743,28 +761,34 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
&g_CurrentTrackSegment->m_End.y ); &g_CurrentTrackSegment->m_End.y );
} }
} }
else /* ici l'angle d'inclinaison est quelconque */ else /* Here the angle is arbitrary */
{ {
g_CurrentTrackSegment->m_End = screen->m_Curseur; g_CurrentTrackSegment->m_End = screen->m_Curseur;
} }
/* Redraw the new track */ /* Redraw the new track */
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR ); Trace_Une_Piste( panel,
DC,
g_FirstTrackSegment,
g_CurrentTrackList.GetCount(),
GR_XOR );
if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) // Show the via area if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
{ {
int color = g_DesignSettings.m_LayerColor[g_CurrentTrackSegment->GetLayer()]; int color =
g_DesignSettings.m_LayerColor[g_CurrentTrackSegment->GetLayer()];
GRCircle( &panel->m_ClipBox, DC, g_CurrentTrackSegment->m_End.x, GRCircle( &panel->m_ClipBox, DC, g_CurrentTrackSegment->m_End.x,
g_CurrentTrackSegment->m_End.y, g_CurrentTrackSegment->m_End.y,
(netclass->GetViaDiameter() / 2) + netclass->GetClearance(), ( netclass->GetViaDiameter() / 2 ) + netclass->GetClearance(),
color ); color );
} }
/* Display info about currrent segment and the full new track: /* Display info about currrent segment and the full new track:
* Choose the interesting segment: because we are using a 2 segments step, * Choose the interesting segment: because we are using a 2 segments step,
* the last segment can be null, and the previous segment can be the interesting segment. * the last segment can be null, and the previous segment can be the
* interesting segment.
*/ */
TRACK* isegm = g_CurrentTrackSegment; TRACK* isegm = g_CurrentTrackSegment;
if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() ) if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() )
...@@ -794,21 +818,17 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ...@@ -794,21 +818,17 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
} }
/*****************************************************************/ /* Determine the coordinate to advanced the the current segment
void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy ) * in 0, 90, or 45 degrees, depending on position of origin and
/*****************************************************************/ * cursor position.
/* determine les parametres .fx et .fy du segment pointe par pt_segm
* pour avoir un segment oriente a 0, 90 ou 45 degres, selon position
* du oint d'origine et de la souris
*/ */
void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
{ {
int deltax, deltay, angle; int deltax, deltay, angle;
deltax = ActiveScreen->m_Curseur.x - ox; deltax = ActiveScreen->m_Curseur.x - ox;
deltay = ActiveScreen->m_Curseur.y - oy; deltay = ActiveScreen->m_Curseur.y - oy;
/* calcul de l'angle preferentiel : 0, 45 , 90 degre */
deltax = abs( deltax ); deltax = abs( deltax );
deltay = abs( deltay ); deltay = abs( deltay );
angle = 45; angle = 45;
...@@ -841,10 +861,10 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy ) ...@@ -841,10 +861,10 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
deltax = MIN( deltax, deltay ); deltax = MIN( deltax, deltay );
deltay = deltax; deltay = deltax;
/* recalcul des signes de deltax et deltay */ /* Recalculate the signs fo deltax and deltaY. */
if( (ActiveScreen->m_Curseur.x - ox) < 0 ) if( ( ActiveScreen->m_Curseur.x - ox ) < 0 )
deltax = -deltax; deltax = -deltax;
if( (ActiveScreen->m_Curseur.y - oy) < 0 ) if( ( ActiveScreen->m_Curseur.y - oy ) < 0 )
deltay = -deltay; deltay = -deltay;
*fx = ox + deltax; *fx = ox + deltax;
...@@ -859,13 +879,10 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy ) ...@@ -859,13 +879,10 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
} }
/********************************************************/
void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
/********************************************************/
/** /**
* Compute new track angle based on previous track. * Compute new track angle based on previous track.
*/ */
void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
{ {
int iDx = 0; int iDx = 0;
int iDy = 0; int iDy = 0;
...@@ -911,11 +928,11 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) ...@@ -911,11 +928,11 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
switch( iAngle ) switch( iAngle )
{ {
case - 1: case -1:
break; break;
case 0: case 0:
if( (end.x - track->m_Start.x) < 0 ) if( ( end.x - track->m_Start.x ) < 0 )
track->m_End.x = end.x + iDy; track->m_End.x = end.x + iDy;
else else
track->m_End.x = end.x - iDy; track->m_End.x = end.x - iDy;
...@@ -926,10 +943,10 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) ...@@ -926,10 +943,10 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
iDx = MIN( iDx, iDy ); iDx = MIN( iDx, iDy );
iDy = iDx; iDy = iDx;
/* recalcul des signes de deltax et deltay */ /* Recalculate the signs fo deltax and deltaY. */
if( (end.x - track->m_Start.x) < 0 ) if( ( end.x - track->m_Start.x ) < 0 )
iDx = -iDx; iDx = -iDx;
if( (end.y - track->m_Start.y) < 0 ) if( ( end.y - track->m_Start.y ) < 0 )
iDy = -iDy; iDy = -iDy;
track->m_End.x = track->m_Start.x + iDx; track->m_End.x = track->m_Start.x + iDx;
...@@ -937,7 +954,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) ...@@ -937,7 +954,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
break; break;
case 90: case 90:
if( (end.y - track->m_Start.y) < 0 ) if( ( end.y - track->m_Start.y ) < 0 )
track->m_End.y = end.y + iDx; track->m_End.y = end.y + iDx;
else else
track->m_End.y = end.y - iDx; track->m_End.y = end.y - iDx;
...@@ -957,13 +974,10 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) ...@@ -957,13 +974,10 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
} }
/****************************************************************************/
void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
/****************************************************************************/
/* Delete track segments which have len = 0; after creating a new track /* Delete track segments which have len = 0; after creating a new track
* return a pointer on the first segment (start of track list) * return a pointer on the first segment (start of track list)
*/ */
void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
{ {
if( aTrackList.GetCount() == 0 ) if( aTrackList.GetCount() == 0 )
return; return;
...@@ -1031,14 +1045,11 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList ) ...@@ -1031,14 +1045,11 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
} }
/************************************/
void EnsureEndTrackOnPad( D_PAD* Pad )
/************************************/
/* Ensure the end point of g_CurrentTrackSegment is on the pas "Pad" /* Ensure the end point of g_CurrentTrackSegment is on the pas "Pad"
* if no, create a new track segment if necessary * if no, create a new track segment if necessary
* and move current (or new) end segment on pad * and move current (or new) end segment on pad
*/ */
void EnsureEndTrackOnPad( D_PAD* Pad )
{ {
if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok ! if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok !
{ {
......
/*************************************************************/ /********************/
/* Edition des Modules: Routines de modification des textes */ /* Edi module text. */
/* sur les MODULES */ /********************/
/*************************************************************/
/* Fichier EDTXTMOD.CPP */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -16,30 +13,31 @@ ...@@ -16,30 +13,31 @@
#include "protos.h" #include "protos.h"
/* Routines Locales */ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel,
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); wxDC* DC,
bool erase );
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC ); static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC );
/* local variables */
wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp
static wxPoint TextInitialPosition; // Mouse cursor inital position for undo/abort move command
static int TextInitialOrientation; // module text inital orientation for undo/abort move+rot command+rot
wxPoint MoveVector; // Move vector for move edge, exported
// to dialog_edit mod_text.cpp
static wxPoint TextInitialPosition; // Mouse cursor initial position for
// undo/abort move command
static int TextInitialOrientation; // module text initial orientation for
// undo/abort move+rot command+rot
/******************************************************************************/
TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
/******************************************************************************/
/* Add a new graphical text to the active module (footprint) /* Add a new graphical text to the active module (footprint)
* Note there always are 2 texts: reference and value. * Note there always are 2 texts: reference and value.
* New texts have the member TEXTE_MODULE.m_Type set to TEXT_is_DIVERS * New texts have the member TEXTE_MODULE.m_Type set to TEXT_is_DIVERS
*/ */
TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
{ {
TEXTE_MODULE* Text; TEXTE_MODULE* Text;
Text = new TEXTE_MODULE( Module ); Text = new TEXTE_MODULE( Module );
/* Chainage de la nouvelle structure en tete de liste drawings */ /* Add the new text object to the beginning of the draw item list. */
if( Module ) if( Module )
Module->m_Drawings.PushFront( Text ); Module->m_Drawings.PushFront( Text );
...@@ -48,7 +46,8 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) ...@@ -48,7 +46,8 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
Text->m_Text = wxT( "text" ); Text->m_Text = wxT( "text" );
ModuleTextWidth = Clamp_Text_PenSize( ModuleTextWidth, ModuleTextWidth = Clamp_Text_PenSize( ModuleTextWidth,
MIN(ModuleTextSize.x, ModuleTextSize.y), true ); MIN( ModuleTextSize.x,
ModuleTextSize.y ), true );
Text->m_Size = ModuleTextSize; Text->m_Size = ModuleTextSize;
Text->m_Width = ModuleTextWidth; Text->m_Width = ModuleTextWidth;
Text->m_Pos = GetScreen()->m_Curseur; Text->m_Pos = GetScreen()->m_Curseur;
...@@ -67,20 +66,20 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) ...@@ -67,20 +66,20 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
} }
/**************************************************************************/ /* Rotate text 90 degrees.
*/
void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
/**************************************************************************/
/* Rotation de 90 du texte d'un module */
{ {
if( Text == NULL ) if( Text == NULL )
return; return;
MODULE* module = (MODULE*) Text->GetParent(); MODULE* module = (MODULE*) Text->GetParent();
if( module && module->m_Flags == 0 && Text->m_Flags == 0 ) // simple rot command if( module && module->m_Flags == 0 && Text->m_Flags == 0 ) // prepare undo
{ // prepare undo command // command
{
if( this->m_Ident == PCB_FRAME ) if( this->m_Ident == PCB_FRAME )
SaveCopyInUndoList( module,UR_CHANGED ); SaveCopyInUndoList( module, UR_CHANGED );
} }
// we expect MoveVector to be (0,0) if there is no move in progress // we expect MoveVector to be (0,0) if there is no move in progress
...@@ -90,9 +89,7 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -90,9 +89,7 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
while( Text->m_Orient >= 1800 ) while( Text->m_Orient >= 1800 )
Text->m_Orient -= 1800; Text->m_Orient -= 1800;
/* Redessin du Texte */
Text->Draw( DrawPanel, DC, GR_XOR, MoveVector ); Text->Draw( DrawPanel, DC, GR_XOR, MoveVector );
Text->DisplayInfo( this ); Text->DisplayInfo( this );
if( module ) if( module )
...@@ -101,13 +98,10 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -101,13 +98,10 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
} }
/**************************************************************************/
void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
/**************************************************************************/
/* /*
* Supprime 1 texte sur module (si ce n'est pas la rfrence ou la valeur) * Deletes text in module (if not the reference or value)
*/ */
void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
{ {
MODULE* Module; MODULE* Module;
...@@ -119,8 +113,6 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text ) ...@@ -119,8 +113,6 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
if( Text->m_Type == TEXT_is_DIVERS ) if( Text->m_Type == TEXT_is_DIVERS )
{ {
DrawPanel->PostDirtyRect( Text->GetBoundingBox() ); DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
/* liberation de la memoire : */
Text->DeleteStructure(); Text->DeleteStructure();
GetScreen()->SetModify(); GetScreen()->SetModify();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
...@@ -128,13 +120,12 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text ) ...@@ -128,13 +120,12 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
} }
/*************************************************************/
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/
/* /*
* Routine de sortie du menu edit texte module * Abort text move in progress.
* Si un texte est selectionne, ses coord initiales sont regenerees *
* If a text is selected, its initial coordinates are regenerated.
*/ */
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
BASE_SCREEN* screen = Panel->GetScreen(); BASE_SCREEN* screen = Panel->GetScreen();
TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem(); TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem();
...@@ -152,7 +143,7 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -152,7 +143,7 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
// If the text was moved (the move does not change internal data) // If the text was moved (the move does not change internal data)
// it could be rotated while moving. So set old value for orientation // it could be rotated while moving. So set old value for orientation
if ( (Text->m_Flags & IS_MOVED) ) if( (Text->m_Flags & IS_MOVED) )
Text->m_Orient = TextInitialOrientation; Text->m_Orient = TextInitialOrientation;
/* Redraw the text */ /* Redraw the text */
...@@ -168,12 +159,9 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -168,12 +159,9 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
/****************************************************************************/ /* Start a text move.
void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
/****************************************************************************/
/* Routine d'initialisation du deplacement d'un texte sur module
*/ */
void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{ {
MODULE* Module; MODULE* Module;
...@@ -187,7 +175,7 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -187,7 +175,7 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
TextInitialPosition = Text->m_Pos; TextInitialPosition = Text->m_Pos;
TextInitialOrientation = Text->m_Orient; TextInitialOrientation = Text->m_Orient;
Text->DisplayInfo( this ); Text->DisplayInfo( this );
...@@ -200,40 +188,37 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -200,40 +188,37 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
} }
/*************************************************************************/ /* Place the text a the cursor position when the left mouse button is clicked.
void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
/*************************************************************************/
/* Routine complementaire a StartMoveTexteModule().
* Place le texte en cours de deplacement
*/ */
void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{ {
if( Text != NULL ) if( Text != NULL )
{ {
DrawPanel->PostDirtyRect( Text->GetBoundingBox() ); DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
/* mise a jour des coordonnes relatives a l'ancre */ /* Update the coordinates for anchor. */
MODULE* Module = (MODULE*) Text->GetParent(); MODULE* Module = (MODULE*) Text->GetParent();
if( Module ) if( Module )
{ {
// Prepare undo command (a rotation can be made while moving) // Prepare undo command (a rotation can be made while moving)
EXCHG(Text->m_Orient, TextInitialOrientation); EXCHG( Text->m_Orient, TextInitialOrientation );
if( m_Ident == PCB_FRAME ) if( m_Ident == PCB_FRAME )
SaveCopyInUndoList(Module, UR_CHANGED); SaveCopyInUndoList( Module, UR_CHANGED );
else else
SaveCopyInUndoList(Module, UR_MODEDIT); SaveCopyInUndoList( Module, UR_MODEDIT );
EXCHG(Text->m_Orient, TextInitialOrientation); EXCHG( Text->m_Orient, TextInitialOrientation );
Text->m_Pos = GetScreen()->m_Curseur; // Set the new position for text // Set the new position for text.
Text->m_Pos = GetScreen()->m_Curseur;
wxPoint textRelPos = Text->m_Pos - Module->m_Pos; wxPoint textRelPos = Text->m_Pos - Module->m_Pos;
RotatePoint( &textRelPos, -Module->m_Orient ); RotatePoint( &textRelPos, -Module->m_Orient );
Text->m_Pos0 = textRelPos; Text->m_Pos0 = textRelPos;
Text->m_Flags = 0; Text->m_Flags = 0;
Module->m_Flags = 0; Module->m_Flags = 0;
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
GetScreen()->SetModify(); GetScreen()->SetModify();
/* Redessin du Texte */ /* Redraw text. */
DrawPanel->PostDirtyRect( Text->GetBoundingBox() ); DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
} }
else else
...@@ -248,9 +233,8 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -248,9 +233,8 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
} }
/********************************************************************************/ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC,
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) bool erase )
/********************************************************************************/
{ {
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem(); TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem();
...@@ -258,7 +242,7 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ...@@ -258,7 +242,7 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
if( Text == NULL ) if( Text == NULL )
return; return;
/* Undraw the text : */ /* Undraw the text */
if( erase ) if( erase )
Text->Draw( panel, DC, GR_XOR, MoveVector ); Text->Draw( panel, DC, GR_XOR, MoveVector );
......
/***************************************************/ /************************************************/
/* export_gencad.cpp - export en formay GenCAD 1.4 */ /* export_gencad.cpp - export GenCAD 1.4 format */
/***************************************************/ /************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -28,26 +28,25 @@ static void FootprintWriteShape( FILE* File, MODULE* module ); ...@@ -28,26 +28,25 @@ static void FootprintWriteShape( FILE* File, MODULE* module );
// layer name for Gencad export // layer name for Gencad export
static const wxString GenCAD_Layer_Name[32] = static const wxString GenCAD_Layer_Name[32] =
{ {
wxT( "BOTTOM" ), wxT( "INNER1" ), wxT( "INNER2" ), wxT( "BOTTOM" ), wxT( "INNER1" ), wxT( "INNER2" ),
wxT( wxT( "INNER3" ), wxT( "INNER4" ), wxT( "INNER5" ),
"INNER3" ), wxT( "INNER6" ), wxT( "INNER7" ), wxT( "INNER8" ),
wxT( "INNER4" ), wxT( "INNER5" ), wxT( "INNER6" ), wxT( wxT( "INNER9" ), wxT( "INNER10" ), wxT( "INNER11" ),
"INNER7" ), wxT( "INNER12" ), wxT( "INNER13" ), wxT( "INNER14" ),
wxT( "INNER8" ), wxT( "INNER9" ), wxT( "INNER10" ), wxT( wxT( "TOP" ), wxT( "adhecu" ), wxT( "adhecmp" ),
"INNER11" ), wxT( "SOLDERPASTE_BOTTOM" ), wxT( "SOLDERPASTE_TOP" ),
wxT( "INNER12" ), wxT( "INNER13" ), wxT( "INNER14" ), wxT( "TOP" ), wxT( "SILKSCREEN_BOTTOM" ), wxT( "SILKSCREEN_TOP" ),
wxT( "adhecu" ), wxT( "adhecmp" ), wxT( "SOLDERPASTE_BOTTOM" ),wxT( wxT( "SOLDERMASK_BOTTOM" ), wxT( "SOLDERMASK_TOP" ), wxT( "drawings" ),
"SOLDERPASTE_TOP" ), wxT( "comments" ), wxT( "eco1" ), wxT( "eco2" ),
wxT( "SILKSCREEN_BOTTOM" ), wxT( "SILKSCREEN_TOP" ), wxT( "SOLDERMASK_BOTTOM" ), wxT( wxT( "edges" ), wxT( "--" ), wxT( "--" ),
"SOLDERMASK_TOP" ), wxT( "--" )
wxT( "drawings" ), wxT( "comments" ), wxT( "eco1" ), wxT( "eco2" ),
wxT( "edges" ), wxT( "--" ), wxT( "--" ), wxT( "--" )
}; };
int offsetX, offsetY; int offsetX, offsetY;
D_PAD* PadList; D_PAD* PadList;
/* 2 helper functions to calculate coordinates of modules in gencad values ( GenCAD Y axis from bottom to top) /* 2 helper functions to calculate coordinates of modules in gencad values (
* GenCAD Y axis from bottom to top)
*/ */
static int mapXto( int x ) static int mapXto( int x )
{ {
...@@ -61,13 +60,10 @@ static int mapYto( int y ) ...@@ -61,13 +60,10 @@ static int mapYto( int y )
} }
/***********************************************************/
void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
/***********************************************************/
/* /*
* Creates an Export file (format GenCAD 1.4) from the current borad. * Creates an Export file (format GenCAD 1.4) from the current board.
*/ */
void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
{ {
wxFileName fn = GetScreen()->m_FileName; wxFileName fn = GetScreen()->m_FileName;
wxString msg, ext, wildcard; wxString msg, ext, wildcard;
...@@ -100,8 +96,8 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) ...@@ -100,8 +96,8 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
DrawPanel->PrepareGraphicContext( &dc ); DrawPanel->PrepareGraphicContext( &dc );
Compile_Ratsnest( &dc, TRUE ); Compile_Ratsnest( &dc, TRUE );
/* Temporary modification of footprints that are flipped (i.e. on bottom layer) /* Temporary modification of footprints that are flipped (i.e. on bottom
* to convert them to non flipped footprints. * layer) to convert them to non flipped footprints.
* This is necessary to easily export shapes to GenCAD, * This is necessary to easily export shapes to GenCAD,
* that are given as normal orientation (non flipped, rotation = 0)) * that are given as normal orientation (non flipped, rotation = 0))
* these changes will be undone later * these changes will be undone later
...@@ -128,7 +124,9 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) ...@@ -128,7 +124,9 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
/* Create the shapes list /* Create the shapes list
* (shapes of pads and footprints */ * (shapes of pads and footprints */
CreatePadsShapesSection( file, GetBoard() ); /* Must be called CreatePadsShapesSection( file, GetBoard() ); /* Must be called
* before CreatePadsStacksSection and * before
* CreatePadsStacksSection
* and
* CreateShapesSection() * CreateShapesSection()
*/ */
CreatePadsStacksSection( file, GetBoard() ); CreatePadsStacksSection( file, GetBoard() );
...@@ -140,7 +138,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) ...@@ -140,7 +138,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
/* Create the list of Nets: */ /* Create the list of Nets: */
CreateSignalsSection( file, GetBoard() ); CreateSignalsSection( file, GetBoard() );
// Cretaes the Routes section (i.e. the list of board tracks) // Creates the Routes section (i.e. the list of board tracks)
CreateRoutesSection( file, GetBoard() ); CreateRoutesSection( file, GetBoard() );
fclose( file ); fclose( file );
...@@ -157,9 +155,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) ...@@ -157,9 +155,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
} }
/**************************************************************************/
static int Pad_list_Sort_by_Shapes( const void* refptr, const void* objptr ) static int Pad_list_Sort_by_Shapes( const void* refptr, const void* objptr )
/**************************************************************************/
{ {
const D_PAD* padref = *(D_PAD**) refptr; const D_PAD* padref = *(D_PAD**) refptr;
const D_PAD* padcmp = *(D_PAD**) objptr; const D_PAD* padcmp = *(D_PAD**) objptr;
...@@ -168,17 +164,14 @@ static int Pad_list_Sort_by_Shapes( const void* refptr, const void* objptr ) ...@@ -168,17 +164,14 @@ static int Pad_list_Sort_by_Shapes( const void* refptr, const void* objptr )
} }
/*****************************************************/
void CreatePadsShapesSection( FILE* file, BOARD* pcb )
/*****************************************************/
/* Creates the pads shapes list ( 1 shape per pad ) /* Creates the pads shapes list ( 1 shape per pad )
* Uses .GetSubRatsnest member of class D_PAD, to handle the shape id (value 1 ..n) * Uses .GetSubRatsnest member of class D_PAD, to handle the shape id (value 1
* for pads shapes PAD1 to PADn * ..n) for pads shapes PAD1 to PADn
* *
* The PADS section is used to describe the shape of all the pads used on the printed circuit * The PADS section is used to describe the shape of all the pads used on the
* board. The PADS section must be included, even if only a default pad is described and used for * printed circuit board. The PADS section must be included, even if only a
* all pads. The keywords used in the PADS section are: * default pad is described and used for all pads.
* The keywords used in the PADS section are:
* $PADS * $PADS
* PAD <pad_name> <pad_type> <drill_size> * PAD <pad_name> <pad_type> <drill_size>
* LINE <line_ref> * LINE <line_ref>
...@@ -187,11 +180,14 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) ...@@ -187,11 +180,14 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
* RECTANGLE <rectangle_ref> * RECTANGLE <rectangle_ref>
* ATTRIBUTE <attrib_ref> * ATTRIBUTE <attrib_ref>
* $ENDPADS * $ENDPADS
* $PADS and $ENDPADS mark the PADS section of the GenCAD file. Each pad description * $PADS and $ENDPADS mark the PADS section of the GenCAD file. Each pad
* must start with a PAD keyword. * description must start with a PAD keyword.
* The layer in which a pad lies is defined in the SHAPE section of the GenCAD specification. * The layer in which a pad lies is defined in the SHAPE section of the GenCAD
* The pad is always placed on a shape at the pad origin, or in a pad stack at the pad stack origin. * specification.
* The pad is always placed on a shape at the pad origin, or in a pad stack at
* the pad stack origin.
*/ */
void CreatePadsShapesSection( FILE* file, BOARD* pcb )
{ {
std::vector<D_PAD*> pads; std::vector<D_PAD*> pads;
...@@ -202,20 +198,22 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) ...@@ -202,20 +198,22 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
if( pcb->GetPadsCount() > 0 ) if( pcb->GetPadsCount() > 0 )
{ {
pads.insert( pads.end(), pads.insert( pads.end(),
pcb->m_NetInfo->m_PadsFullList.begin(), pcb->m_NetInfo->m_PadsFullList.end() ); pcb->m_NetInfo->m_PadsFullList.begin(),
qsort( &pads[0], pcb->GetPadsCount(), sizeof( D_PAD* ), Pad_list_Sort_by_Shapes ); pcb->m_NetInfo->m_PadsFullList.end() );
qsort( &pads[0], pcb->GetPadsCount(), sizeof( D_PAD* ),
Pad_list_Sort_by_Shapes );
} }
D_PAD* old_pad = NULL; D_PAD* old_pad = NULL;
int pad_name_number = 0; int pad_name_number = 0;
for( unsigned i = 0; i<pads.size(); ++i ) for( unsigned i = 0; i<pads.size(); ++i )
{ {
D_PAD* pad = pads[i]; D_PAD* pad = pads[i];
pad->SetSubRatsnest( pad_name_number ); pad->SetSubRatsnest( pad_name_number );
if( old_pad && 0==D_PAD::Compare( old_pad, pad ) ) if( old_pad && 0==D_PAD::Compare( old_pad, pad ) )
continue; // already created continue; // already created
old_pad = pad; old_pad = pad;
...@@ -241,8 +239,8 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) ...@@ -241,8 +239,8 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
pad_type = "RECTANGULAR"; pad_type = "RECTANGULAR";
fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x );
fprintf( file, "RECTANGLE %d %d %d %d\n", fprintf( file, "RECTANGLE %d %d %d %d\n",
pad->m_Offset.x - dx, -(pad->m_Offset.y - dy), pad->m_Offset.x - dx, -(pad->m_Offset.y - dy),
pad->m_Offset.x + dx, -(pad->m_Offset.y + dy) ); pad->m_Offset.x + dx, -(pad->m_Offset.y + dy) );
break; break;
case PAD_OVAL: /* Create outline by 2 lines and 2 arcs */ case PAD_OVAL: /* Create outline by 2 lines and 2 arcs */
...@@ -302,11 +300,8 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) ...@@ -302,11 +300,8 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
} }
/*****************************************************/ /*The PADSTACKS section is optional, and is used to describe how a group of
void CreatePadsStacksSection( FILE* file, BOARD* pcb ) * pads are
/*****************************************************/
/*The PADSTACKS section is optional, and is used to describe how a group of pads are
* arranged. The keywords used in the PADSTACKS section are: * arranged. The keywords used in the PADSTACKS section are:
* $PADSTACKS * $PADSTACKS
* PADSTACK <pad_name> <drill_size> * PADSTACK <pad_name> <drill_size>
...@@ -315,24 +310,23 @@ void CreatePadsStacksSection( FILE* file, BOARD* pcb ) ...@@ -315,24 +310,23 @@ void CreatePadsStacksSection( FILE* file, BOARD* pcb )
* $ENDPADSTACKS * $ENDPADSTACKS
* $PADSTACKS and $ENDPADSTACKS mark the PADSTACKS section of the GenCAD file. * $PADSTACKS and $ENDPADSTACKS mark the PADSTACKS section of the GenCAD file.
*/ */
void CreatePadsStacksSection( FILE* file, BOARD* pcb )
{ {
fputs( "$PADSTACKS\n", file ); fputs( "$PADSTACKS\n", file );
fputs( "$ENDPADSTACKS\n\n", file ); fputs( "$ENDPADSTACKS\n\n", file );
} }
/**************************************************/
void CreateShapesSection( FILE* file, BOARD* pcb )
/**************************************************/
/* Creates the footprint shape list. /* Creates the footprint shape list.
* We must use one shape for identical footprint (i.e. come from the same footprint in lib) * We must use one shape for identical footprint (i.e. come from the same
* footprint in lib)
* But because pads shapes and positions can be easily modified on board, * But because pads shapes and positions can be easily modified on board,
* a shape is created by footprint found. * a shape is created by footprint found.
* (todo : compare footprints shapes and creates only one shape for all footprints found having the same shape) * (todo : compare footprints shapes and creates only one shape for all
* footprints found having the same shape)
* The shape is always given in orientation 0, position 0 not flipped * The shape is always given in orientation 0, position 0 not flipped
* *
* Syntaxe: * Syntax:
* $SHAPES * $SHAPES
* SHAPE <shape_name> * SHAPE <shape_name>
* INSERT <string> here <string> = "TH" * INSERT <string> here <string> = "TH"
...@@ -343,6 +337,7 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) ...@@ -343,6 +337,7 @@ void CreateShapesSection( FILE* file, BOARD* pcb )
* .. * ..
* $ENDSHAPES * $ENDSHAPES
*/ */
void CreateShapesSection( FILE* file, BOARD* pcb )
{ {
MODULE* module; MODULE* module;
D_PAD* pad; D_PAD* pad;
...@@ -359,14 +354,14 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) ...@@ -359,14 +354,14 @@ void CreateShapesSection( FILE* file, BOARD* pcb )
for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) for( pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{ {
layer = "ALL"; layer = "ALL";
if( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER ) if( ( pad->m_Masque_Layer & ALL_CU_LAYERS ) == CUIVRE_LAYER )
{ {
if( module->GetLayer() == CMP_N ) if( module->GetLayer() == CMP_N )
layer = "BOTTOM"; layer = "BOTTOM";
else else
layer = "TOP"; layer = "TOP";
} }
else if( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CMP_LAYER ) else if( ( pad->m_Masque_Layer & ALL_CU_LAYERS ) == CMP_LAYER )
{ {
if( module->GetLayer() == CMP_N ) if( module->GetLayer() == CMP_N )
layer = "TOP"; layer = "TOP";
...@@ -394,16 +389,13 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) ...@@ -394,16 +389,13 @@ void CreateShapesSection( FILE* file, BOARD* pcb )
} }
/******************************************************/
void CreateComponentsSection( FILE* file, BOARD* pcb )
/******************************************************/
/* Creates the section $COMPONENTS (Footprints placement) /* Creates the section $COMPONENTS (Footprints placement)
* When a footprint is on bottom side of the board:: * When a footprint is on bottom side of the board::
* shapes are given with option "FLIP" and "MIRRORX". * shapes are given with option "FLIP" and "MIRRORX".
* - But shapes remain given like component not mirrored and not flipped * - But shapes remain given like component not mirrored and not flipped
* - orientaion is given like if where not mirrored and not flipped. * - orientation is given like if where not mirrored and not flipped.
*/ */
void CreateComponentsSection( FILE* file, BOARD* pcb )
{ {
MODULE* module = pcb->m_Modules; MODULE* module = pcb->m_Modules;
TEXTE_MODULE* PtTexte; TEXTE_MODULE* PtTexte;
...@@ -419,7 +411,9 @@ void CreateComponentsSection( FILE* file, BOARD* pcb ) ...@@ -419,7 +411,9 @@ void CreateComponentsSection( FILE* file, BOARD* pcb )
if( module->flag ) if( module->flag )
{ {
mirror = "MIRRORX"; // Mirrored relative to X axis mirror = "MIRRORX"; // Mirrored relative to X axis
flip = "FLIP"; // Normal shape description ( gencad viewer must show it flipped and mirrored) flip = "FLIP"; // Normal shape description ( gencad
// viewer must show it flipped and
// mirrored)
NEGATE_AND_NORMALIZE_ANGLE_POS( orient ); NEGATE_AND_NORMALIZE_ANGLE_POS( orient );
} }
else else
...@@ -428,9 +422,12 @@ void CreateComponentsSection( FILE* file, BOARD* pcb ) ...@@ -428,9 +422,12 @@ void CreateComponentsSection( FILE* file, BOARD* pcb )
flip = "0"; flip = "0";
} }
fprintf( file, "COMPONENT %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) ); fprintf( file, "COMPONENT %s\n",
fprintf( file, "DEVICE %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) ); CONV_TO_UTF8( module->m_Reference->m_Text ) );
fprintf( file, "PLACE %d %d\n", mapXto( module->m_Pos.x ), mapYto( module->m_Pos.y ) ); fprintf( file, "DEVICE %s\n",
CONV_TO_UTF8( module->m_Reference->m_Text ) );
fprintf( file, "PLACE %d %d\n", mapXto( module->m_Pos.x ),
mapYto( module->m_Pos.y ) );
fprintf( file, "LAYER %s\n", (module->flag) ? "BOTTOM" : "TOP" ); fprintf( file, "LAYER %s\n", (module->flag) ? "BOTTOM" : "TOP" );
fprintf( file, "ROTATION %d", orient / 10 ); fprintf( file, "ROTATION %d", orient / 10 );
...@@ -464,26 +461,24 @@ void CreateComponentsSection( FILE* file, BOARD* pcb ) ...@@ -464,26 +461,24 @@ void CreateComponentsSection( FILE* file, BOARD* pcb )
} }
//put a comment: //put a comment:
fprintf( file, "SHEET Part %s %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ), fprintf( file, "SHEET Part %s %s\n",
CONV_TO_UTF8( module->m_Value->m_Text ) ); CONV_TO_UTF8( module->m_Reference->m_Text ),
CONV_TO_UTF8( module->m_Value->m_Text ) );
} }
fputs( "$ENDCOMPONENTS\n\n", file ); fputs( "$ENDCOMPONENTS\n\n", file );
} }
/***************************************************/
void CreateSignalsSection( FILE* file, BOARD* pcb )
/***************************************************/
/* Creates the list of Nets: /* Creates the list of Nets:
* $SIGNALS * $SIGNALS
* SIGNAL <equipot name> * SIGNAL <net name>
* NODE <component name> <pin name> * NODE <component name> <pin name>
* ... * ...
* NODE <component name> <pin name> * NODE <component name> <pin name>
* $ENDSIGNALS * $ENDSIGNALS
*/ */
void CreateSignalsSection( FILE* file, BOARD* pcb )
{ {
wxString msg; wxString msg;
NETINFO_ITEM* net; NETINFO_ITEM* net;
...@@ -496,13 +491,14 @@ void CreateSignalsSection( FILE* file, BOARD* pcb ) ...@@ -496,13 +491,14 @@ void CreateSignalsSection( FILE* file, BOARD* pcb )
for( unsigned ii = 0; ii < pcb->m_NetInfo->GetCount(); ii++ ) for( unsigned ii = 0; ii < pcb->m_NetInfo->GetCount(); ii++ )
{ {
net = pcb->m_NetInfo->GetNetItem( ii ); net = pcb->m_NetInfo->GetNetItem( ii );
if( net->GetNetname() == wxEmptyString ) // dummy equipot (non connexion) if( net->GetNetname() == wxEmptyString ) // dummy netlist (no
// connection)
{ {
wxString msg; msg << wxT( "NoConnection" ) << NbNoConn++; wxString msg; msg << wxT( "NoConnection" ) << NbNoConn++;
net->SetNetname( msg );; net->SetNetname( msg );;
} }
if( net->GetNet() <= 0 ) // dummy equipot (non connexion) if( net->GetNet() <= 0 ) // dummy netlist (no connection)
continue; continue;
msg = wxT( "SIGNAL " ) + net->GetNetname(); msg = wxT( "SIGNAL " ) + net->GetNetname();
...@@ -520,8 +516,8 @@ void CreateSignalsSection( FILE* file, BOARD* pcb ) ...@@ -520,8 +516,8 @@ void CreateSignalsSection( FILE* file, BOARD* pcb )
pad->ReturnStringPadName( padname ); pad->ReturnStringPadName( padname );
msg.Printf( wxT( "NODE %s %.4s" ), msg.Printf( wxT( "NODE %s %.4s" ),
GetChars( module->m_Reference->m_Text ), GetChars( module->m_Reference->m_Text ),
GetChars( padname ) ); GetChars( padname ) );
fputs( CONV_TO_UTF8( msg ), file ); fputs( CONV_TO_UTF8( msg ), file );
fputs( "\n", file ); fputs( "\n", file );
...@@ -533,12 +529,9 @@ void CreateSignalsSection( FILE* file, BOARD* pcb ) ...@@ -533,12 +529,9 @@ void CreateSignalsSection( FILE* file, BOARD* pcb )
} }
/*************************************************************/
bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
/*************************************************************/
/* Creates the section $HEADER ... $ENDHEADER /* Creates the section $HEADER ... $ENDHEADER
*/ */
bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
{ {
wxString msg; wxString msg;
PCB_SCREEN* screen = (PCB_SCREEN*) ( frame->GetScreen() ); PCB_SCREEN* screen = (PCB_SCREEN*) ( frame->GetScreen() );
...@@ -550,12 +543,14 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame ) ...@@ -550,12 +543,14 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
msg = wxT( "DRAWING " ) + screen->m_FileName; msg = wxT( "DRAWING " ) + screen->m_FileName;
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
msg = wxT( "REVISION " ) + screen->m_Revision + wxT( " " ) + screen->m_Date; msg = wxT( "REVISION " ) + screen->m_Revision + wxT( " " ) +
screen->m_Date;
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
msg.Printf( wxT( "UNITS USER %d" ), PCB_INTERNAL_UNIT ); msg.Printf( wxT( "UNITS USER %d" ), PCB_INTERNAL_UNIT );
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
msg.Printf( wxT( "ORIGIN %d %d" ), mapXto( frame->m_Auxiliary_Axis_Position.x ), msg.Printf( wxT( "ORIGIN %d %d" ),
mapYto( frame->m_Auxiliary_Axis_Position.y ) ); mapXto( frame->m_Auxiliary_Axis_Position.x ),
mapYto( frame->m_Auxiliary_Axis_Position.y ) );
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
fputs( "INTERTRACK 0\n", file ); fputs( "INTERTRACK 0\n", file );
fputs( "$ENDHEADER\n\n", file ); fputs( "$ENDHEADER\n\n", file );
...@@ -564,14 +559,11 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame ) ...@@ -564,14 +559,11 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
} }
/**************************************************************************/
static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr )
/**************************************************************************/
/* /*
* Sort function used to sort tracks segments: * Sort function used to sort tracks segments:
* items are sorted by netcode, then by width then by layer * items are sorted by netcode, then by width then by layer
*/ */
static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr )
{ {
const TRACK* ref, * cmp; const TRACK* ref, * cmp;
int diff; int diff;
...@@ -580,7 +572,7 @@ static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr ) ...@@ -580,7 +572,7 @@ static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr )
cmp = *( (TRACK**) objptr ); cmp = *( (TRACK**) objptr );
if( ( diff = ref->GetNet() - cmp->GetNet() ) ) if( ( diff = ref->GetNet() - cmp->GetNet() ) )
return diff; return diff;
if( (diff = ref->m_Width - cmp->m_Width) ) if( ( diff = ref->m_Width - cmp->m_Width ) )
return diff; return diff;
if( ( diff = ref->GetLayer() - cmp->GetLayer() ) ) if( ( diff = ref->GetLayer() - cmp->GetLayer() ) )
return diff; return diff;
...@@ -589,10 +581,6 @@ static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr ) ...@@ -589,10 +581,6 @@ static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr )
} }
/*************************************************/
void CreateRoutesSection( FILE* file, BOARD* pcb )
/*************************************************/
/* Creates the section ROUTES /* Creates the section ROUTES
* that handles tracks, vias * that handles tracks, vias
* TODO: add zones * TODO: add zones
...@@ -602,6 +590,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) ...@@ -602,6 +590,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
* $ENROUTE * $ENROUTE
* Track segments must be sorted by nets * Track segments must be sorted by nets
*/ */
void CreateRoutesSection( FILE* file, BOARD* pcb )
{ {
TRACK* track, ** tracklist; TRACK* track, ** tracklist;
int vianum = 1; int vianum = 1;
...@@ -665,12 +654,13 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) ...@@ -665,12 +654,13 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
{ {
old_layer = track->GetLayer(); old_layer = track->GetLayer();
fprintf( file, "LAYER %s\n", fprintf( file, "LAYER %s\n",
CONV_TO_UTF8( GenCAD_Layer_Name[track->GetLayer() & 0x1F] ) ); CONV_TO_UTF8( GenCAD_Layer_Name[track->GetLayer() &
0x1F] ) );
} }
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
mapXto( track->m_Start.x ), mapYto( track->m_Start.y ), mapXto( track->m_Start.x ), mapYto( track->m_Start.y ),
mapXto( track->m_End.x ), mapYto( track->m_End.y ) ); mapXto( track->m_End.x ), mapYto( track->m_End.y ) );
} }
if( track->Type() == TYPE_VIA ) if( track->Type() == TYPE_VIA )
{ {
...@@ -687,14 +677,11 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) ...@@ -687,14 +677,11 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
} }
/***************************************************/
void CreateDevicesSection( FILE* file, BOARD* pcb )
/***************************************************/
/* Creates the section $DEVICES /* Creates the section $DEVICES
* This is a list of footprints properties * This is a list of footprints properties
* ( Shapes are in section $SHAPE ) * ( Shapes are in section $SHAPE )
*/ */
void CreateDevicesSection( FILE* file, BOARD* pcb )
{ {
MODULE* module; MODULE* module;
D_PAD* pad; D_PAD* pad;
...@@ -703,7 +690,8 @@ void CreateDevicesSection( FILE* file, BOARD* pcb ) ...@@ -703,7 +690,8 @@ void CreateDevicesSection( FILE* file, BOARD* pcb )
for( module = pcb->m_Modules; module != NULL; module = module->Next() ) for( module = pcb->m_Modules; module != NULL; module = module->Next() )
{ {
fprintf( file, "DEVICE %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) ); fprintf( file, "DEVICE %s\n",
CONV_TO_UTF8( module->m_Reference->m_Text ) );
fprintf( file, "PART %s\n", CONV_TO_UTF8( module->m_LibRef ) ); fprintf( file, "PART %s\n", CONV_TO_UTF8( module->m_LibRef ) );
fprintf( file, "TYPE %s\n", "UNKNOWN" ); fprintf( file, "TYPE %s\n", "UNKNOWN" );
for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) for( pad = module->m_Pads; pad != NULL; pad = pad->Next() )
...@@ -715,43 +703,45 @@ void CreateDevicesSection( FILE* file, BOARD* pcb ) ...@@ -715,43 +703,45 @@ void CreateDevicesSection( FILE* file, BOARD* pcb )
fprintf( file, " %.4s\n", pad->m_Padname ); fprintf( file, " %.4s\n", pad->m_Padname );
} }
fprintf( file, "ATTRIBUTE %s\n", CONV_TO_UTF8( module->m_Value->m_Text ) ); fprintf( file, "ATTRIBUTE %s\n",
CONV_TO_UTF8( module->m_Value->m_Text ) );
} }
fputs( "$ENDDEVICES\n\n", file ); fputs( "$ENDDEVICES\n\n", file );
} }
/*************************************************/
void CreateBoardSection( FILE* file, BOARD* pcb )
/*************************************************/
/* Creates the section $BOARD. /* Creates the section $BOARD.
* We output here only the board boudary box * We output here only the board boundary box
*/ */
void CreateBoardSection( FILE* file, BOARD* pcb )
{ {
fputs( "$BOARD\n", file ); fputs( "$BOARD\n", file );
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.m_Pos.y ), mapXto( pcb->m_BoundaryBox.m_Pos.x ),
mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.m_Pos.y ) ); mapYto( pcb->m_BoundaryBox.m_Pos.y ),
mapXto( pcb->m_BoundaryBox.GetRight() ),
mapYto( pcb->m_BoundaryBox.m_Pos.y ) );
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.m_Pos.y ), mapXto( pcb->m_BoundaryBox.GetRight() ),
mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.GetBottom() ) ); mapYto( pcb->m_BoundaryBox.m_Pos.y ),
mapXto( pcb->m_BoundaryBox.GetRight() ),
mapYto( pcb->m_BoundaryBox.GetBottom() ) );
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.GetBottom() ), mapXto( pcb->m_BoundaryBox.GetRight() ),
mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.GetBottom() ) ); mapYto( pcb->m_BoundaryBox.GetBottom() ),
mapXto( pcb->m_BoundaryBox.m_Pos.x ),
mapYto( pcb->m_BoundaryBox.GetBottom() ) );
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.GetBottom() ), mapXto( pcb->m_BoundaryBox.m_Pos.x ),
mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.m_Pos.y ) ); mapYto( pcb->m_BoundaryBox.GetBottom() ),
mapXto( pcb->m_BoundaryBox.m_Pos.x ),
mapYto( pcb->m_BoundaryBox.m_Pos.y ) );
fputs( "$ENDBOARD\n\n", file ); fputs( "$ENDBOARD\n\n", file );
} }
/****************************************************/
void CreateTracksInfoData( FILE* file, BOARD* pcb )
/****************************************************/
/* Creates the section "$TRACKS" /* Creates the section "$TRACKS"
* This sections give the list of widths (tools) used in tracks and vias * This sections give the list of widths (tools) used in tracks and vias
* format: * format:
...@@ -762,20 +752,21 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb ) ...@@ -762,20 +752,21 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb )
* Each tool name is build like this: "TRACK" + track width. * Each tool name is build like this: "TRACK" + track width.
* For instance for a width = 120 : name = "TRACK120". * For instance for a width = 120 : name = "TRACK120".
*/ */
void CreateTracksInfoData( FILE* file, BOARD* pcb )
{ {
TRACK* track; TRACK* track;
int last_width = -1; int last_width = -1;
/* recherche des epaisseurs utilisees pour les traces: */ /* Find thickness used for traces. */
std::vector <int> trackinfo; std::vector <int> trackinfo;
unsigned ii; unsigned ii;
for( track = pcb->m_Track; track != NULL; track = track->Next() ) for( track = pcb->m_Track; track != NULL; track = track->Next() )
{ {
if( last_width != track->m_Width ) // recherche d'une epaisseur deja utilisee if( last_width != track->m_Width ) // Find a thickness already used.
{ {
for( ii = 0; ii < trackinfo.size(); ii++ ) for( ii = 0; ii < trackinfo.size(); ii++ )
{ {
if( trackinfo[ii] == track->m_Width ) if( trackinfo[ii] == track->m_Width )
break; break;
...@@ -790,9 +781,9 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb ) ...@@ -790,9 +781,9 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb )
for( track = pcb->m_Zone; track != NULL; track = track->Next() ) for( track = pcb->m_Zone; track != NULL; track = track->Next() )
{ {
if( last_width != track->m_Width ) // recherche d'une epaisseur deja utilisee if( last_width != track->m_Width ) // Find a thickness already used.
{ {
for( ii = 0; ii < trackinfo.size(); ii++ ) for( ii = 0; ii < trackinfo.size(); ii++ )
{ {
if( trackinfo[ii] == track->m_Width ) if( trackinfo[ii] == track->m_Width )
break; break;
...@@ -807,7 +798,7 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb ) ...@@ -807,7 +798,7 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb )
// Write data // Write data
fputs( "$TRACKS\n", file ); fputs( "$TRACKS\n", file );
for( ii = 0; ii < trackinfo.size(); ii++ ) for( ii = 0; ii < trackinfo.size(); ii++ )
{ {
fprintf( file, "TRACK TRACK%d %d\n", trackinfo[ii], trackinfo[ii] ); fprintf( file, "TRACK TRACK%d %d\n", trackinfo[ii], trackinfo[ii] );
} }
...@@ -816,10 +807,6 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb ) ...@@ -816,10 +807,6 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb )
} }
/***************************************************/
void FootprintWriteShape( FILE* file, MODULE* module )
/***************************************************/
/* Creates the shape of a footprint (section SHAPE) /* Creates the shape of a footprint (section SHAPE)
* The shape is always given "normal" (Orient 0, not mirrored) * The shape is always given "normal" (Orient 0, not mirrored)
* Syntax: * Syntax:
...@@ -830,17 +817,19 @@ void FootprintWriteShape( FILE* file, MODULE* module ) ...@@ -830,17 +817,19 @@ void FootprintWriteShape( FILE* file, MODULE* module )
* ARC startX startY endX endY centreX centreY * ARC startX startY endX endY centreX centreY
* PAD_CIRCLE centreX scentreY radius * PAD_CIRCLE centreX scentreY radius
*/ */
void FootprintWriteShape( FILE* file, MODULE* module )
{ {
EDGE_MODULE* PtEdge; EDGE_MODULE* PtEdge;
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
int Yaxis_sign = -1; // Controle changement signe axe Y (selon module normal/miroir et conventions d'axe) int Yaxis_sign = -1; // Control Y axis change sign (as normal
// module / mirror axis and conventions)
/* creates header: */ /* creates header: */
fprintf( file, "SHAPE %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) ); fprintf( file, "SHAPE %s\n", CONV_TO_UTF8( module->m_Reference->m_Text ) );
fprintf( file, "INSERT %s\n", (module->m_Attributs & MOD_CMS) ? "SMD" : "TH" ); fprintf( file, "INSERT %s\n",
(module->m_Attributs & MOD_CMS) ? "SMD" : "TH" );
/* creates Attributs */ /* creates Attributes */
if( module->m_Attributs != MOD_DEFAULT ) if( module->m_Attributs != MOD_DEFAULT )
{ {
fprintf( file, "ATTRIBUTE" ); fprintf( file, "ATTRIBUTE" );
...@@ -851,7 +840,6 @@ void FootprintWriteShape( FILE* file, MODULE* module ) ...@@ -851,7 +840,6 @@ void FootprintWriteShape( FILE* file, MODULE* module )
fprintf( file, "\n" ); fprintf( file, "\n" );
} }
/* creates Drawing */ /* creates Drawing */
PtStruct = module->m_Drawings; PtStruct = module->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
...@@ -883,7 +871,7 @@ void FootprintWriteShape( FILE* file, MODULE* module ) ...@@ -883,7 +871,7 @@ void FootprintWriteShape( FILE* file, MODULE* module )
break; break;
} }
case S_ARC: /* print ARC x,y start x,y end x,y centre */ case S_ARC: /* print ARC x,y start x,y end x,y center */
{ {
int arcendx, arcendy; int arcendx, arcendy;
arcendx = PtEdge->m_Start0.x; arcendx = PtEdge->m_Start0.x;
...@@ -897,7 +885,7 @@ void FootprintWriteShape( FILE* file, MODULE* module ) ...@@ -897,7 +885,7 @@ void FootprintWriteShape( FILE* file, MODULE* module )
} }
default: default:
DisplayError( NULL, wxT( "Type Edge Module inconnu" ) ); DisplayError( NULL, wxT( "Type Edge Module invalid." ) );
break; break;
} /* end switch PtEdge->m_Shape */ } /* end switch PtEdge->m_Shape */
......
/***************************************************/ /********************************************/
/* PCBNEW - Gestion des Recherches (fonction Find) */ /* PCBNEW - Find dialog box implementation. */
/***************************************************/ /********************************************/
/* Fichier find.cpp */
/*
* Affichage et modifications des parametres de travail de PcbNew
* Parametres = dimensions des via, pistes, isolements, options...
*/
#include "fctsys.h" #include "fctsys.h"
...@@ -25,14 +18,12 @@ ...@@ -25,14 +18,12 @@
#include "find.h" #include "find.h"
/*Local Variables */
static wxString s_OldStringFound; static wxString s_OldStringFound;
static int s_ItemCount, s_MarkerCount; static int s_ItemCount, s_MarkerCount;
/*********************************************************************/
void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC ) void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC )
/*********************************************************************/
{ {
WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos ); WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos );
...@@ -41,15 +32,13 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC ) ...@@ -41,15 +32,13 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC )
} }
/*******************************************************/
void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
/********************************************************/
{ {
PCB_SCREEN* screen = (PCB_SCREEN*)(m_Parent->GetScreen()); PCB_SCREEN* screen = (PCB_SCREEN*) ( m_Parent->GetScreen() );
wxPoint locate_pos; wxPoint locate_pos;
wxString msg; wxString msg;
bool FindMarker = FALSE; bool FindMarker = FALSE;
BOARD_ITEM* foundItem = 0; BOARD_ITEM* foundItem = 0;
switch( event.GetId() ) switch( event.GetId() )
{ {
...@@ -59,7 +48,8 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) ...@@ -59,7 +48,8 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
case ID_FIND_MARKER: case ID_FIND_MARKER:
s_MarkerCount = 0; s_MarkerCount = 0;
// fall thru
// fall thru
case ID_FIND_NEXT_MARKER: case ID_FIND_NEXT_MARKER:
FindMarker = TRUE; FindMarker = TRUE;
...@@ -68,7 +58,8 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) ...@@ -68,7 +58,8 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
s_OldStringFound = m_NewText->GetValue(); s_OldStringFound = m_NewText->GetValue();
m_Parent->DrawPanel->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y ); m_Parent->DrawPanel->GetViewStart( &screen->m_StartVisu.x,
&screen->m_StartVisu.y );
if( FindMarker ) if( FindMarker )
{ {
...@@ -82,9 +73,12 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) ...@@ -82,9 +73,12 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
else else
{ {
int StartCount = 0; int StartCount = 0;
for( MODULE* module = m_Parent->GetBoard()->m_Modules; module; module = module->Next() ) for( MODULE* module = m_Parent->GetBoard()->m_Modules;
module;
module = module->Next() )
{ {
if( WildCompareString( s_OldStringFound, module->GetReference().GetData(), FALSE ) ) if( WildCompareString( s_OldStringFound,
module->GetReference().GetData(), FALSE ) )
{ {
StartCount++; StartCount++;
if( StartCount > s_ItemCount ) if( StartCount > s_ItemCount )
...@@ -95,7 +89,8 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) ...@@ -95,7 +89,8 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
break; break;
} }
} }
if( WildCompareString( s_OldStringFound, module->m_Value->m_Text.GetData(), FALSE ) ) if( WildCompareString( s_OldStringFound,
module->m_Value->m_Text.GetData(), FALSE ) )
{ {
StartCount++; StartCount++;
if( StartCount > s_ItemCount ) if( StartCount > s_ItemCount )
...@@ -153,17 +148,13 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFindFrame, wxDialog ) ...@@ -153,17 +148,13 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFindFrame, wxDialog )
////@begin WinEDA_PcbFindFrame event table entries ////@begin WinEDA_PcbFindFrame event table entries
EVT_BUTTON( ID_FIND_ITEM, WinEDA_PcbFindFrame::OnFindItemClick ) EVT_BUTTON( ID_FIND_ITEM, WinEDA_PcbFindFrame::OnFindItemClick )
EVT_BUTTON( ID_FIND_NEXT_ITEM, WinEDA_PcbFindFrame::OnFindNextItemClick ) EVT_BUTTON( ID_FIND_NEXT_ITEM, WinEDA_PcbFindFrame::OnFindNextItemClick )
EVT_BUTTON( ID_FIND_MARKER, WinEDA_PcbFindFrame::OnFindMarkerClick ) EVT_BUTTON( ID_FIND_MARKER, WinEDA_PcbFindFrame::OnFindMarkerClick )
EVT_BUTTON( ID_FIND_NEXT_MARKER, WinEDA_PcbFindFrame::OnFindNextMarkerClick ) EVT_BUTTON( ID_FIND_NEXT_MARKER, WinEDA_PcbFindFrame::OnFindNextMarkerClick )
////@end WinEDA_PcbFindFrame event table entries ////@end WinEDA_PcbFindFrame event table entries
END_EVENT_TABLE() END_EVENT_TABLE()
/*! /*!
* WinEDA_PcbFindFrame constructors * WinEDA_PcbFindFrame constructors
*/ */
...@@ -174,15 +165,15 @@ WinEDA_PcbFindFrame::WinEDA_PcbFindFrame() ...@@ -174,15 +165,15 @@ WinEDA_PcbFindFrame::WinEDA_PcbFindFrame()
WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( WinEDA_BasePcbFrame* parent, WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( WinEDA_BasePcbFrame* parent,
wxDC* DC, wxDC* DC,
const wxPoint& pos, const wxPoint& pos,
wxWindowID id, wxWindowID id,
const wxString& caption, const wxString& caption,
const wxSize& size, const wxSize& size,
long style ) long style )
{ {
m_Parent = parent; m_Parent = parent;
m_DC = DC; m_DC = DC;
Create( parent, id, caption, pos, size, style ); Create( parent, id, caption, pos, size, style );
...@@ -194,27 +185,29 @@ WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( WinEDA_BasePcbFrame* parent, ...@@ -194,27 +185,29 @@ WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( WinEDA_BasePcbFrame* parent,
* WinEDA_PcbFindFrame creator * WinEDA_PcbFindFrame creator
*/ */
bool WinEDA_PcbFindFrame::Create( wxWindow* parent, bool WinEDA_PcbFindFrame::Create( wxWindow* parent,
wxWindowID id, wxWindowID id,
const wxString& caption, const wxString& caption,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style ) long style )
{ {
////@begin WinEDA_PcbFindFrame member initialisation ////@begin WinEDA_PcbFindFrame member initialisation
m_NewText = NULL; m_NewText = NULL;
////@end WinEDA_PcbFindFrame member initialisation ////@end WinEDA_PcbFindFrame member initialisation
////@begin WinEDA_PcbFindFrame creation ////@begin WinEDA_PcbFindFrame creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS); SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style ); wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls(); CreateControls();
if (GetSizer()) if( GetSizer() )
{ {
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
} }
Centre(); Centre();
////@end WinEDA_PcbFindFrame creation ////@end WinEDA_PcbFindFrame creation
return true; return true;
} }
...@@ -231,36 +224,74 @@ void WinEDA_PcbFindFrame::CreateControls() ...@@ -231,36 +224,74 @@ void WinEDA_PcbFindFrame::CreateControls()
WinEDA_PcbFindFrame* itemDialog1 = this; WinEDA_PcbFindFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
itemDialog1->SetSizer(itemBoxSizer2);
itemDialog1->SetSizer( itemBoxSizer2 );
wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("Item to find:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(itemStaticText3, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1,
wxID_STATIC,
m_NewText = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); _( "Item to find:" ),
itemBoxSizer2->Add(m_NewText, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); wxDefaultPosition,
wxDefaultSize,
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL); 0 );
itemBoxSizer2->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); itemBoxSizer2->Add( itemStaticText3,
0,
wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL); wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
itemBoxSizer5->Add(itemBoxSizer6, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); 5 );
wxButton* itemButton7 = new wxButton( itemDialog1, ID_FIND_ITEM, _("Find Item"), wxDefaultPosition, wxDefaultSize, 0 ); m_NewText = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add( m_NewText, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer( wxHORIZONTAL );
itemBoxSizer2->Add( itemBoxSizer5,
0,
wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT |
wxBOTTOM,
5 );
wxBoxSizer* itemBoxSizer6 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer5->Add( itemBoxSizer6,
0,
wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
5 );
wxButton* itemButton7 =
new wxButton( itemDialog1, ID_FIND_ITEM, _( "Find Item" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemButton7->SetDefault(); itemButton7->SetDefault();
itemBoxSizer6->Add(itemButton7, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer6->Add( itemButton7, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxButton* itemButton8 = new wxButton( itemDialog1, ID_FIND_NEXT_ITEM, _("Find Next Item"), wxDefaultPosition, wxDefaultSize, 0 ); wxButton* itemButton8 =
itemBoxSizer6->Add(itemButton8, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); new wxButton( itemDialog1, ID_FIND_NEXT_ITEM, _( "Find Next Item" ),
wxDefaultPosition, wxDefaultSize,
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL); 0 );
itemBoxSizer5->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); itemBoxSizer6->Add( itemButton8,
0,
wxButton* itemButton10 = new wxButton( itemDialog1, ID_FIND_MARKER, _("Find Marker"), wxDefaultPosition, wxDefaultSize, 0 ); wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
itemBoxSizer9->Add(itemButton10, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); 5 );
wxButton* itemButton11 = new wxButton( itemDialog1, ID_FIND_NEXT_MARKER, _("Find Next Marker"), wxDefaultPosition, wxDefaultSize, 0 ); wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer9->Add(itemButton11, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); itemBoxSizer5->Add( itemBoxSizer9,
0,
wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
5 );
wxButton* itemButton10 =
new wxButton( itemDialog1, ID_FIND_MARKER, _( "Find Marker" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( itemButton10, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxButton* itemButton11 = new wxButton( itemDialog1,
ID_FIND_NEXT_MARKER,
_( "Find Next Marker" ),
wxDefaultPosition,
wxDefaultSize,
0 );
itemBoxSizer9->Add( itemButton11,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
////@end WinEDA_PcbFindFrame content construction ////@end WinEDA_PcbFindFrame content construction
} }
...@@ -284,8 +315,9 @@ wxBitmap WinEDA_PcbFindFrame::GetBitmapResource( const wxString& name ) ...@@ -284,8 +315,9 @@ wxBitmap WinEDA_PcbFindFrame::GetBitmapResource( const wxString& name )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin WinEDA_PcbFindFrame bitmap retrieval ////@begin WinEDA_PcbFindFrame bitmap retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullBitmap; return wxNullBitmap;
////@end WinEDA_PcbFindFrame bitmap retrieval ////@end WinEDA_PcbFindFrame bitmap retrieval
} }
...@@ -298,8 +330,9 @@ wxIcon WinEDA_PcbFindFrame::GetIconResource( const wxString& name ) ...@@ -298,8 +330,9 @@ wxIcon WinEDA_PcbFindFrame::GetIconResource( const wxString& name )
{ {
// Icon retrieval // Icon retrieval
////@begin WinEDA_PcbFindFrame icon retrieval ////@begin WinEDA_PcbFindFrame icon retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullIcon; return wxNullIcon;
////@end WinEDA_PcbFindFrame icon retrieval ////@end WinEDA_PcbFindFrame icon retrieval
} }
......
/*************************************************************************/ /************************************************************************/
/* Functions to create drill data used to create aFiles and report aFiles */ /* Functions to create drill data used to create files and report files */
/*************************************************************************/ /************************************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -21,17 +21,13 @@ using namespace std; ...@@ -21,17 +21,13 @@ using namespace std;
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "gendrill.h" #include "gendrill.h"
/**********************************************************************************/
void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
Ki_PageDescr* aSheet, Ki_PageDescr* aSheet,
std::vector<HOLE_INFO> aHoleListBuffer, std::vector<HOLE_INFO> aHoleListBuffer,
std::vector<DRILL_TOOL> aToolListBuffer, std::vector<DRILL_TOOL> aToolListBuffer,
bool aUnit_Drill_is_Inch, int format, bool aUnit_Drill_is_Inch, int format,
const wxPoint& auxoffset ) const wxPoint& auxoffset )
/**********************************************************************************/
/* Genere le plan de percage (Drill map)
*/
{ {
int x, y; int x, y;
int plotX, plotY, TextWidth; int plotX, plotY, TextWidth;
...@@ -47,15 +43,15 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -47,15 +43,15 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
SetLocaleTo_C_standard(); // Use the standard notation for float numbers SetLocaleTo_C_standard(); // Use the standard notation for float numbers
/* calcul des dimensions et centre du PCB */ /* Calculate dimensions and center of PCB */
aPcb->ComputeBoundaryBox(); aPcb->ComputeBoundaryBox();
dX = aPcb->m_BoundaryBox.GetWidth(); dX = aPcb->m_BoundaryBox.GetWidth();
dY = aPcb->m_BoundaryBox.GetHeight(); dY = aPcb->m_BoundaryBox.GetHeight();
BoardCentre = aPcb->m_BoundaryBox.Centre(); BoardCentre = aPcb->m_BoundaryBox.Centre();
// Calcul de l'echelle du dessin du PCB, // Calculate the scale for the format type, scale 1 in HPGL, drawing on
// Echelle 1 en HPGL, dessin sur feuille A4 en PS, + texte description des symboles // an A4 sheet in PS, + text description of symbols
switch( format ) switch( format )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
...@@ -65,7 +61,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -65,7 +61,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
plotter->set_viewport( offset, scale, 0 ); plotter->set_viewport( offset, scale, 0 );
break; break;
case PLOT_FORMAT_HPGL: /* Calcul des echelles de conversion format HPGL */ case PLOT_FORMAT_HPGL: /* Scale for HPGL format. */
{ {
offset.x = 0; offset.x = 0;
offset.y = 0; offset.y = 0;
...@@ -94,7 +90,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -94,7 +90,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
offset.x = BoardCentre.x - (SheetSize.x / 2) / scale; offset.x = BoardCentre.x - (SheetSize.x / 2) / scale;
offset.y = BoardCentre.y - (SheetSize.y / 2) / scale; offset.y = BoardCentre.y - (SheetSize.y / 2) / scale;
offset.y += SheetSize.y / 8; /* decalage pour legende */ offset.y += SheetSize.y / 8; /* offset to legend */
PS_PLOTTER* ps_plotter = new PS_PLOTTER; PS_PLOTTER* ps_plotter = new PS_PLOTTER;
plotter = ps_plotter; plotter = ps_plotter;
ps_plotter->set_paper_size( SheetPS ); ps_plotter->set_paper_size( SheetPS );
...@@ -132,7 +128,8 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -132,7 +128,8 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, EDGE_LAYER, FILLED ); PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, EDGE_LAYER,
FILLED );
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
...@@ -163,22 +160,23 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -163,22 +160,23 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
// Plot board outlines and drill map // Plot board outlines and drill map
Gen_Drill_PcbMap( aPcb, plotter, aHoleListBuffer, aToolListBuffer ); Gen_Drill_PcbMap( aPcb, plotter, aHoleListBuffer, aToolListBuffer );
/* Impression de la liste des symboles utilises */ /* Print a list of symbols used. */
CharSize = 800; /* text size in 1/10000 mils */ CharSize = 800; /* text size in 1/10000 mils */
double CharScale = 1.0 / scale; /* real scale will be CharScale * scale_x, double CharScale = 1.0 / scale; /* real scale will be CharScale
* because the global plot scale is scale_x */ * scale_x, because the global
TextWidth = (int) ( (CharSize * CharScale) / 10 ); // Set text width (thickness) * plot scale is scale_x */
TextWidth = (int) ( (CharSize * CharScale) / 10 ); // Set text width (thickness)
intervalle = (int) ( CharSize * CharScale ) + TextWidth; intervalle = (int) ( CharSize * CharScale ) + TextWidth;
/* Trace des informations */ /* Trace information. */
plotX = aPcb->m_BoundaryBox.GetX() + 200 * CharScale; plotX = aPcb->m_BoundaryBox.GetX() + 200 * CharScale;
plotY = aPcb->m_BoundaryBox.GetBottom() + intervalle; plotY = aPcb->m_BoundaryBox.GetBottom() + intervalle;
/* Plot title "Info" */ /* Plot title "Info" */
wxString Text = wxT( "Drill Map:" ); wxString Text = wxT( "Drill Map:" );
plotter->text( wxPoint( plotX, plotY ), BLACK, plotter->text( wxPoint( plotX, plotY ), BLACK, Text, 0,
Text, wxSize( (int) ( CharSize * CharScale ),
0, wxSize( (int) ( CharSize * CharScale ), (int) ( CharSize * CharScale ) ), (int) ( CharSize * CharScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
TextWidth, false, false ); TextWidth, false, false );
...@@ -195,7 +193,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -195,7 +193,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
y = plotY + CharSize * CharScale; y = plotY + CharSize * CharScale;
plotter->marker( wxPoint( x, y ), plot_diam, ii ); plotter->marker( wxPoint( x, y ), plot_diam, ii );
/* Trace de la legende associee */ /* Trace the legends. */
// List the diameter of each drill in the selected Drill Unit, // List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit. // and then its diameter in the other Drill Unit.
...@@ -246,17 +244,14 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -246,17 +244,14 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
} }
/****************************************************************************************/
void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* plotter,
std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer )
/****************************************************************************************/
/** Creates the drill map aFile in HPGL or POSTSCRIPT format /** Creates the drill map aFile in HPGL or POSTSCRIPT format
* @param aPcb BOARD * @param aPcb BOARD
* @param aHoleListBuffer = std::vector<HOLE_INFO> list of holes descriptors * @param aHoleListBuffer = std::vector<HOLE_INFO> list of holes descriptors
* @param aToolListBuffer = std::vector<DRILL_TOOL> drill list buffer * @param aToolListBuffer = std::vector<DRILL_TOOL> drill list buffer
*/ */
void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* plotter,
std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer )
{ {
wxPoint pos; wxPoint pos;
...@@ -291,17 +286,14 @@ void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* plotter, ...@@ -291,17 +286,14 @@ void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* plotter,
} }
/**************************************************************************************************/
void GenDrillReportFile( FILE* aFile, BOARD* aPcb, const wxString& aBoardFilename,
bool aUnit_Drill_is_Inch,
std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer
)
/*************************************************************************************************/
/* /*
* Create a list of drill values and drill count * Create a list of drill values and drill count
*/ */
void GenDrillReportFile( FILE* aFile, BOARD* aPcb,
const wxString& aBoardFilename,
bool aUnit_Drill_is_Inch,
std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer )
{ {
unsigned TotalHoleCount; unsigned TotalHoleCount;
char line[1024]; char line[1024];
...@@ -313,7 +305,8 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, const wxString& aBoardFilenam ...@@ -313,7 +305,8 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, const wxString& aBoardFilenam
fprintf( aFile, "Drill report for %s\n", CONV_TO_UTF8( aBoardFilename ) ); fprintf( aFile, "Drill report for %s\n", CONV_TO_UTF8( aBoardFilename ) );
fprintf( aFile, "Created on %s\n", DateAndTime( line ) ); fprintf( aFile, "Created on %s\n", DateAndTime( line ) );
// List which Drill Unit option had been selected for the associated drill aFile. // List which Drill Unit option had been selected for the associated
// drill aFile.
if( aUnit_Drill_is_Inch ) if( aUnit_Drill_is_Inch )
fputs( "Selected Drill Unit: Imperial (\")\n\n", aFile ); fputs( "Selected Drill Unit: Imperial (\")\n\n", aFile );
else else
...@@ -402,11 +395,13 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, const wxString& aBoardFilenam ...@@ -402,11 +395,13 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, const wxString& aBoardFilenam
layer2 = layer1 + 1; layer2 = layer1 + 1;
else else
{ {
if( layer2 >= LAYER_CMP_N ) // no more layer pair to consider if( layer2 >= LAYER_CMP_N ) // no more layer pair to consider
break; break;
layer1++; layer2++; // use next layer pair layer1++; layer2++; // use next layer pair
if( layer2 == g_DesignSettings.GetCopperLayerCount() - 1 ) // The last layer is reached
layer2 = LAYER_CMP_N; // the last layer is always the component layer if( layer2 == g_DesignSettings.GetCopperLayerCount() - 1 )
layer2 = LAYER_CMP_N; // the last layer is always the
// component layer
} }
gen_through_holes = false; gen_through_holes = false;
} }
......
/*************************************/ /*****************************/
/* fichier gen_modules_placefile.cpp */ /* gen_modules_placefile.cpp */
/*************************************/ /*****************************/
/* /*
* 1 - create ascii files for automatic placement of smd components * 1 - create ascii files for automatic placement of smd components
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "trigo.h" #include "trigo.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
class LIST_MOD /* Permet de lister les elements utiles des modules */ class LIST_MOD /* Can list the elements of useful modules. */
{ {
public: public:
MODULE* m_Module; MODULE* m_Module;
...@@ -25,13 +25,12 @@ public: ...@@ -25,13 +25,12 @@ public:
}; };
/* variables locale : */ static wxPoint File_Place_Offset; /* Offset coordinates for generated file. */
static wxPoint File_Place_Offset; /* Offset des coord de placement pour le fichier gnr */
/* Routines Locales */
static void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ); static void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile );
/* Routine de tri utilisee par GenereModulesPosition() */
/* Sort function use by GenereModulesPosition() */
static int ListeModCmp( const void* o1, const void* o2 ) static int ListeModCmp( const void* o1, const void* o2 )
{ {
LIST_MOD* ref = (LIST_MOD*) o1; LIST_MOD* ref = (LIST_MOD*) o1;
...@@ -64,13 +63,9 @@ static bool HasNonSMDPins( MODULE* aModule ) ...@@ -64,13 +63,9 @@ static bool HasNonSMDPins( MODULE* aModule )
#endif #endif
/**************************************************************/ /* Generate the module positions, used component placement.
void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
/**************************************************************/
/* Routine de generation du fichier de positionnement des modules,
* utilis pour les machines de placement de composants
*/ */
void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
{ {
bool doBoardBack = false; bool doBoardBack = false;
MODULE* module; MODULE* module;
...@@ -87,25 +82,26 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) ...@@ -87,25 +82,26 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
FILE* fpBack = 0; FILE* fpBack = 0;
bool switchedLocale = false; bool switchedLocale = false;
/* Calcul des echelles de conversion */ /* Calculate conversion scales. */
double conv_unit = 0.0001; /* unites = INCHES */ double conv_unit = 0.0001; /* unites = INCHES */
// if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */ // if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */
File_Place_Offset = m_Auxiliary_Axis_Position; File_Place_Offset = m_Auxiliary_Axis_Position;
/* Calcul du nombre de modules utiles ( Attribut CMS, non VIRTUAL ) ) */ /* Calculating the number of useful modules (CMS attribute, not VIRTUAL) */
int moduleCount = 0; int moduleCount = 0;
for( module = GetBoard()->m_Modules; module; module = module->Next() ) for( module = GetBoard()->m_Modules; module; module = module->Next() )
{ {
if( module->m_Attributs & MOD_VIRTUAL ) if( module->m_Attributs & MOD_VIRTUAL )
{ {
D(printf("skipping module %s because it's virtual\n", CONV_TO_UTF8(module->GetReference()) );) D( printf( "skipping module %s because it's virtual\n",
CONV_TO_UTF8( module->GetReference() ) );)
continue; continue;
} }
if( (module->m_Attributs & MOD_CMS) == 0 ) if( ( module->m_Attributs & MOD_CMS ) == 0 )
{ {
#if 1 && defined(DEBUG) // enable this code to fix a bunch of mis-labeled modules: #if 1 && defined(DEBUG) // enable this code to fix a bunch of mis-labeled modules:
if( !HasNonSMDPins( module ) ) if( !HasNonSMDPins( module ) )
...@@ -115,7 +111,8 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) ...@@ -115,7 +111,8 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
} }
else else
{ {
printf( "skipping %s because its attribute is not CMS and it has non SMD pins\n", CONV_TO_UTF8(module->GetReference()) ); printf( "skipping %s because its attribute is not CMS and it has non SMD pins\n",
CONV_TO_UTF8(module->GetReference()) );
continue; continue;
} }
#else #else
...@@ -131,7 +128,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) ...@@ -131,7 +128,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
if( moduleCount == 0 ) if( moduleCount == 0 )
{ {
DisplayError( this, _( "No Modules for Automated Placement" ), 20 ); DisplayError( this, _( "No modules for automated placement." ) );
return; return;
} }
...@@ -165,11 +162,12 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) ...@@ -165,11 +162,12 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
} }
} }
// 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 like 1.3)
SetLocaleTo_C_standard( ); SetLocaleTo_C_standard( );
switchedLocale = true; switchedLocale = true;
/* Affichage du bilan : */ /* Display results */
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
Affiche_1_Parametre( this, 0, _( "Component side place file:" ), Affiche_1_Parametre( this, 0, _( "Component side place file:" ),
fnFront.GetFullPath(), BLUE ); fnFront.GetFullPath(), BLUE );
...@@ -181,7 +179,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) ...@@ -181,7 +179,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
msg.Empty(); msg << moduleCount; msg.Empty(); msg << moduleCount;
Affiche_1_Parametre( this, 65, _( "Module count" ), msg, RED ); Affiche_1_Parametre( this, 65, _( "Module count" ), msg, RED );
/* Etablissement de la liste des modules par ordre alphabetique */ /* Sort the list of modules by alphabetical order */
Liste = (LIST_MOD*) MyZMalloc( moduleCount * sizeof(LIST_MOD) ); Liste = (LIST_MOD*) MyZMalloc( moduleCount * sizeof(LIST_MOD) );
module = GetBoard()->m_Modules; module = GetBoard()->m_Modules;
...@@ -201,9 +199,9 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) ...@@ -201,9 +199,9 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
qsort( Liste, moduleCount, sizeof(LIST_MOD), ListeModCmp ); qsort( Liste, moduleCount, sizeof(LIST_MOD), ListeModCmp );
/* Generation entete du fichier 'commentaires) */ /* Generation header file comments. */
sprintf( line, "### Module positions - created on %s ###\n", sprintf( line, "### Module positions - created on %s ###\n",
DateAndTime( Buff ) ); DateAndTime( Buff ) );
fputs( line, fpFront ); fputs( line, fpFront );
if( doBoardBack ) if( doBoardBack )
fputs( line, fpBack ); fputs( line, fpBack );
...@@ -234,13 +232,13 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) ...@@ -234,13 +232,13 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
if( doBoardBack ) if( doBoardBack )
fputs( line, fpBack ); fputs( line, fpBack );
/* Generation lignes utiles du fichier */
for( int ii = 0; ii < moduleCount; ii++ ) for( int ii = 0; ii < moduleCount; ii++ )
{ {
wxPoint module_pos; wxPoint module_pos;
wxString ref = Liste[ii].m_Reference; wxString ref = Liste[ii].m_Reference;
wxString val = Liste[ii].m_Value; wxString val = Liste[ii].m_Value;
sprintf( line, "%-8.8s %-16.16s ", CONV_TO_UTF8( ref ), CONV_TO_UTF8( val ) ); sprintf( line, "%-8.8s %-16.16s ", CONV_TO_UTF8( ref ),
CONV_TO_UTF8( val ) );
module_pos = Liste[ii].m_Module->m_Pos; module_pos = Liste[ii].m_Module->m_Pos;
module_pos.x -= File_Place_Offset.x; module_pos.x -= File_Place_Offset.x;
...@@ -270,7 +268,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) ...@@ -270,7 +268,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
} }
} }
/* Generation fin du fichier */ /* Generate EOF. */
fputs( "## End\n", fpFront ); fputs( "## End\n", fpFront );
if( doBoardBack ) if( doBoardBack )
...@@ -291,7 +289,7 @@ exit: // the only safe way out of here, no returns please. ...@@ -291,7 +289,7 @@ exit: // the only safe way out of here, no returns please.
MyFree( Liste ); MyFree( Liste );
if( switchedLocale ) if( switchedLocale )
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default( ); // revert to the current locale
if( fpFront ) if( fpFront )
fclose( fpFront ); fclose( fpFront );
...@@ -301,12 +299,9 @@ exit: // the only safe way out of here, no returns please. ...@@ -301,12 +299,9 @@ exit: // the only safe way out of here, no returns please.
} }
/**************************************************************/
void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
/**************************************************************/
/* Print a module report. /* Print a module report.
*/ */
void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
{ {
double conv_unit; double conv_unit;
MODULE* Module; MODULE* Module;
...@@ -317,14 +312,12 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) ...@@ -317,14 +312,12 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
FILE* rptfile; FILE* rptfile;
wxPoint module_pos; wxPoint module_pos;
/* Calcul des echelles de conversion */
conv_unit = 0.0001; /* unites = INCHES */ conv_unit = 0.0001; /* unites = INCHES */
// if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */ // if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */
File_Place_Offset = wxPoint( 0, 0 ); File_Place_Offset = wxPoint( 0, 0 );
/* Init nom fichier */
fn = GetScreen()->m_FileName; fn = GetScreen()->m_FileName;
fn.SetExt( wxT( "rpt" ) ); fn.SetExt( wxT( "rpt" ) );
...@@ -336,10 +329,11 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) ...@@ -336,10 +329,11 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
return; return;
} }
// 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 like 1.3)
SetLocaleTo_C_standard( ); SetLocaleTo_C_standard( );
/* Generation entete du fichier 'commentaires) */ /* Generate header file comments.) */
sprintf( line, "## Module report - date %s\n", DateAndTime( Buff ) ); sprintf( line, "## Module report - date %s\n", DateAndTime( Buff ) );
fputs( line, rptfile ); fputs( line, rptfile );
...@@ -348,7 +342,6 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) ...@@ -348,7 +342,6 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
fputs( line, rptfile ); fputs( line, rptfile );
fputs( "## Unit = inches, Angle = deg.\n", rptfile ); fputs( "## Unit = inches, Angle = deg.\n", rptfile );
/* Generation lignes utiles du fichier */
fputs( "##\n", rptfile ); fputs( "##\n", rptfile );
fputs( "\n$BeginDESCRIPTION\n", rptfile ); fputs( "\n$BeginDESCRIPTION\n", rptfile );
...@@ -370,12 +363,15 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) ...@@ -370,12 +363,15 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
Module = (MODULE*) GetBoard()->m_Modules; Module = (MODULE*) GetBoard()->m_Modules;
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
{ {
sprintf( line, "$MODULE \"%s\"\n", CONV_TO_UTF8( Module->m_Reference->m_Text ) ); sprintf( line, "$MODULE \"%s\"\n",
CONV_TO_UTF8( Module->m_Reference->m_Text ) );
fputs( line, rptfile ); fputs( line, rptfile );
sprintf( line, "reference \"%s\"\n", CONV_TO_UTF8( Module->m_Reference->m_Text ) ); sprintf( line, "reference \"%s\"\n",
CONV_TO_UTF8( Module->m_Reference->m_Text ) );
fputs( line, rptfile ); fputs( line, rptfile );
sprintf( line, "value \"%s\"\n", CONV_TO_UTF8( Module->m_Value->m_Text ) ); sprintf( line, "value \"%s\"\n",
CONV_TO_UTF8( Module->m_Value->m_Text ) );
fputs( line, rptfile ); fputs( line, rptfile );
sprintf( line, "footprint \"%s\"\n", CONV_TO_UTF8( Module->m_LibRef ) ); sprintf( line, "footprint \"%s\"\n", CONV_TO_UTF8( Module->m_LibRef ) );
fputs( line, rptfile ); fputs( line, rptfile );
...@@ -429,7 +425,8 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) ...@@ -429,7 +425,8 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
pad->m_Offset.y * conv_unit ); pad->m_Offset.y * conv_unit );
fputs( line, rptfile ); fputs( line, rptfile );
sprintf( line, "orientation %.2f\n", double(pad->m_Orient - Module->m_Orient) / 10 ); sprintf( line, "orientation %.2f\n",
double(pad->m_Orient - Module->m_Orient) / 10 );
fputs( line, rptfile ); fputs( line, rptfile );
const char* shape_name[6] = const char* shape_name[6] =
{ "??? ", "Circ", "Rect", "Oval", "trap", "spec" }; { "??? ", "Circ", "Rect", "Oval", "trap", "spec" };
...@@ -448,7 +445,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) ...@@ -448,7 +445,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
} }
fprintf( rptfile, "$EndMODULE %s\n\n", fprintf( rptfile, "$EndMODULE %s\n\n",
CONV_TO_UTF8(Module->m_Reference->m_Text ) ); CONV_TO_UTF8(Module->m_Reference->m_Text ) );
} }
/* Write board Edges */ /* Write board Edges */
...@@ -462,36 +459,30 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) ...@@ -462,36 +459,30 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
WriteDrawSegmentPcb( (DRAWSEGMENT*) PtStruct, rptfile ); WriteDrawSegmentPcb( (DRAWSEGMENT*) PtStruct, rptfile );
} }
/* Generation fin du fichier */ /* Generate EOF. */
fputs( "$EndDESCRIPTION\n", rptfile ); fputs( "$EndDESCRIPTION\n", rptfile );
fclose( rptfile ); fclose( rptfile );
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default( ); // revert to the current locale
} }
/*******************************************************************/ /* Output to rpt file a segment type from the PCB drawing.
void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ) * The contours are of different types:
/*******************************************************************/ * Segment
* Circle
/* Sortie sur rptfile d'un segment type drawing PCB: * Arc
* Les contours sont de differents type:
* segment
* cercle
* arc
*/ */
void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile )
{ {
double conv_unit, ux0, uy0, dx, dy; double conv_unit, ux0, uy0, dx, dy;
double rayon, width; double rayon, width;
char line[1024]; char line[1024];
/* Calcul des echelles de conversion */ conv_unit = 0.0001; /* units = INCHES */
conv_unit = 0.0001; /* unites = INCHES */
/* coord de depart */
ux0 = PtDrawSegment->m_Start.x * conv_unit; ux0 = PtDrawSegment->m_Start.x * conv_unit;
uy0 = PtDrawSegment->m_Start.y * conv_unit; uy0 = PtDrawSegment->m_Start.y * conv_unit;
/* coord d'arrivee */
dx = PtDrawSegment->m_End.x * conv_unit; dx = PtDrawSegment->m_End.x * conv_unit;
dy = PtDrawSegment->m_End.y * conv_unit; dy = PtDrawSegment->m_End.y * conv_unit;
...@@ -520,7 +511,8 @@ void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ) ...@@ -520,7 +511,8 @@ void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile )
fprintf( rptfile, "$ARC \n" ); fprintf( rptfile, "$ARC \n" );
fprintf( rptfile, "centre %.6lf %.6lf\n", ux0, uy0 ); fprintf( rptfile, "centre %.6lf %.6lf\n", ux0, uy0 );
fprintf( rptfile, "start %.6lf %.6lf\n", endx * conv_unit, endy * conv_unit ); fprintf( rptfile, "start %.6lf %.6lf\n",
endx * conv_unit, endy * conv_unit );
fprintf( rptfile, "end %.6lf %.6lf\n", dx, dy ); fprintf( rptfile, "end %.6lf %.6lf\n", dx, dy );
fprintf( rptfile, "width %.6lf\n", width ); fprintf( rptfile, "width %.6lf\n", width );
fprintf( rptfile, "$EndARC \n" ); fprintf( rptfile, "$EndARC \n" );
......
/***************************************************************/ /*************************************************************/
/* Functionbs to create EXCELLON drill files and report files */ /* Functions to create EXCELLON drill files and report files */
/***************************************************************/ /*************************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -31,29 +31,32 @@ const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl" ) ); ...@@ -31,29 +31,32 @@ const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl" ) );
* Number format: * Number format:
* - Floating point format * - Floating point format
* - integer format * - integer format
* - integer format: "Trailling Zero" ( TZ ) or "Leading Zero" * - integer format: "Trailing Zero" ( TZ ) or "Leading Zero"
* Units * Units
* - Decimal * - Decimal
* - Metric * - Metric
* *
* The drill maps can be created in HPGL or PS format * The drill maps can be created in HPGL or PS format
* *
* dialog_gendrill.cpp is the file (included in this file) which handles the Dialog box for drill file generation * dialog_gendrill.cpp is the file (included in this file) which handles
* the Dialog box for drill file generation
*/ */
/* Local Function */
static void Gen_Line_EXCELLON( char* line, float x, float y ); static void Gen_Line_EXCELLON( char* line, float x, float y );
static void Write_End_Of_File_Drill( FILE* aFile ); static void Write_End_Of_File_Drill( FILE* aFile );
/* Local Variables : */ static float s_ConversionUnits; /* Conversion unite for
static float s_ConversionUnits; /* coeff de conversion des unites drill / pcb */ * drill / pcb */
static int s_Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */ static int s_Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */
static int s_Zeros_Format = DECIMAL_FORMAT; static int s_Zeros_Format = DECIMAL_FORMAT;
static DrillPrecision s_Precision( 2, 4 ); static DrillPrecision s_Precision( 2, 4 );
static bool DrillOriginIsAuxAxis; // Axis selection (main / auxiliary) for Drill Origin coordinates static bool DrillOriginIsAuxAxis; /* Axis selection (main /
static wxPoint File_Drill_Offset; /* Offset des coord de percage pour le fichier g�n�r� */ * auxiliary) for drill
* origin coordinates */
static wxPoint File_Drill_Offset; /* Offset coordinate for
* drilling file. */
static bool Minimal = false; static bool Minimal = false;
static bool Mirror = true; static bool Mirror = true;
...@@ -72,12 +75,9 @@ static std::vector<HOLE_INFO> s_HoleListBuffer; ...@@ -72,12 +75,9 @@ static std::vector<HOLE_INFO> s_HoleListBuffer;
#include "dialog_gendrill.cpp" // Dialog box for drill file generation #include "dialog_gendrill.cpp" // Dialog box for drill file generation
/************************************************/ /* some param values initialization before display dialog window
void WinEDA_DrillFrame::InitDisplayParams( void )
/************************************************/
/* some param values initialisation before display dialog window
*/ */
void WinEDA_DrillFrame::InitDisplayParams( void )
{ {
wxString msg; wxString msg;
...@@ -103,11 +103,13 @@ void WinEDA_DrillFrame::InitDisplayParams( void ) ...@@ -103,11 +103,13 @@ void WinEDA_DrillFrame::InitDisplayParams( void )
msg << g_pcb_plot_options.HPGL_Pen_Speed; msg << g_pcb_plot_options.HPGL_Pen_Speed;
m_PenSpeed->SetValue( msg ); m_PenSpeed->SetValue( msg );
// See if we have some buried vias or/and microvias, and display microvias drill value if so // See if we have some buried vias or/and microvias, and display
// microvias drill value if so
m_ThroughViasCount = 0; m_ThroughViasCount = 0;
m_MicroViasCount = 0; m_MicroViasCount = 0;
m_BlindOrBuriedViasCount = 0; m_BlindOrBuriedViasCount = 0;
for( TRACK* track = m_Parent->GetBoard()->m_Track; track != NULL; track = track->Next() ) for( TRACK* track = m_Parent->GetBoard()->m_Track; track != NULL;
track = track->Next() )
{ {
if( track->Type() != TYPE_VIA ) if( track->Type() != TYPE_VIA )
continue; continue;
...@@ -122,9 +124,10 @@ void WinEDA_DrillFrame::InitDisplayParams( void ) ...@@ -122,9 +124,10 @@ void WinEDA_DrillFrame::InitDisplayParams( void )
m_MicroViasDrillSizer->Enable( m_MicroViasCount ); m_MicroViasDrillSizer->Enable( m_MicroViasCount );
m_MicroViaDrillValue->Enable( m_MicroViasCount ); m_MicroViaDrillValue->Enable( m_MicroViasCount );
// Pads holes cound: // Pads holes round:
m_PadsHoleCount = 0; m_PadsHoleCount = 0;
for( MODULE* module = m_Parent->GetBoard()->m_Modules; module != NULL; module = module->Next() ) for( MODULE* module = m_Parent->GetBoard()->m_Modules;
module != NULL; module = module->Next() )
{ {
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() ) for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{ {
...@@ -157,9 +160,7 @@ void WinEDA_DrillFrame::InitDisplayParams( void ) ...@@ -157,9 +160,7 @@ void WinEDA_DrillFrame::InitDisplayParams( void )
} }
/**************************************/
void WinEDA_DrillFrame::SetParams( void ) void WinEDA_DrillFrame::SetParams( void )
/**************************************/
{ {
wxString msg; wxString msg;
long ltmp; long ltmp;
...@@ -183,7 +184,7 @@ void WinEDA_DrillFrame::SetParams( void ) ...@@ -183,7 +184,7 @@ void WinEDA_DrillFrame::SetParams( void )
File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position; File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position;
/* get precision from radio box strings (this just makes it easier to /* get precision from radio box strings (this just makes it easier to
* change options later)*/ * change options later)*/
wxString ps = m_Choice_Precision->GetStringSelection(); wxString ps = m_Choice_Precision->GetStringSelection();
wxString l = ps.substr( 0, 1 ); wxString l = ps.substr( 0, 1 );
wxString r = ps.substr( 2, 1 ); wxString r = ps.substr( 2, 1 );
...@@ -201,12 +202,9 @@ void WinEDA_DrillFrame::SetParams( void ) ...@@ -201,12 +202,9 @@ void WinEDA_DrillFrame::SetParams( void )
} }
/*****************************************************************/
void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
/*****************************************************************/
/* This function displays and deletes the dialog frame for drill tools /* This function displays and deletes the dialog frame for drill tools
*/ */
void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
{ {
wxConfig* Config = wxGetApp().m_EDA_Config; wxConfig* Config = wxGetApp().m_EDA_Config;
...@@ -227,10 +225,8 @@ void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event ) ...@@ -227,10 +225,8 @@ void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
} }
/******************************************/
void WinEDA_DrillFrame::UpdateConfig()
/******************************************/
/* Save drill options: */ /* Save drill options: */
void WinEDA_DrillFrame::UpdateConfig()
{ {
SetParams(); SetParams();
...@@ -249,23 +245,25 @@ void WinEDA_DrillFrame::UpdateConfig() ...@@ -249,23 +245,25 @@ void WinEDA_DrillFrame::UpdateConfig()
} }
/*************************************************************/
void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
/*************************************************************/
/** /**
* Function GenDrillFiles * Function GenDrillFiles
* Calls the functions to create EXCELLON drill files and/od drill map files * Calls the functions to create EXCELLON drill files and/or drill map files
* When all holes are through, one excellon file is created * When all holes are through, one excellon file is created
* when there are some partial holes (some blind or buried vias: * when there are some partial holes (some blind or buried vias:
* One excellon file is created, for all through holes. * One excellon file is created, for all through holes.
* And one file per layer pair, which have one or more holes, excluding through holes, already in the first file. * And one file per layer pair, which have one or more holes, excluding
* through holes, already in the first file.
*/ */
void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
wxString layer_extend; // added to the Board FileName to create FullFileName (= Board FileName + layer pair names) wxString layer_extend; /* added to the Board FileName to
* create FullFileName (= Board
* FileName + layer pair names) */
wxString msg; wxString msg;
bool ExistsBuriedVias = false; // If true, drill files are created layer pair by layer pair for buried vias bool ExistsBuriedVias = false; /* If true, drill files are created
* layer pair by layer pair for
* buried vias */
int layer1 = COPPER_LAYER_N; int layer1 = COPPER_LAYER_N;
int layer2 = LAYER_CMP_N; int layer2 = LAYER_CMP_N;
bool gen_through_holes = true; bool gen_through_holes = true;
...@@ -275,9 +273,9 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event ) ...@@ -275,9 +273,9 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
m_Parent->MsgPanel->EraseMsgBox(); m_Parent->MsgPanel->EraseMsgBox();
/* Set conversion scale depending on drill file units */ /* Set conversion scale depending on drill file units */
s_ConversionUnits = 0.0001f; /* unites = INCHES */ s_ConversionUnits = 0.0001f; /* units = INCHES */
if( !s_Unit_Drill_is_Inch ) if( !s_Unit_Drill_is_Inch )
s_ConversionUnits = 0.000254f; /* unites = mm */ s_ConversionUnits = 0.000254f; /* units = mm */
if( m_MicroViasCount || m_BlindOrBuriedViasCount ) if( m_MicroViasCount || m_BlindOrBuriedViasCount )
ExistsBuriedVias = true; ExistsBuriedVias = true;
...@@ -325,7 +323,8 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event ) ...@@ -325,7 +323,8 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
return; return;
} }
Create_Drill_File_EXCELLON( excellon_dest, s_HoleListBuffer, s_ToolListBuffer ); Create_Drill_File_EXCELLON( excellon_dest, s_HoleListBuffer,
s_ToolListBuffer );
switch( m_Choice_Drill_Map->GetSelection() ) switch( m_Choice_Drill_Map->GetSelection() )
{ {
...@@ -366,7 +365,8 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event ) ...@@ -366,7 +365,8 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
layer2++; // use next layer pair layer2++; // use next layer pair
if( layer2 == g_DesignSettings.GetCopperLayerCount() - 1 ) if( layer2 == g_DesignSettings.GetCopperLayerCount() - 1 )
layer2 = LAYER_CMP_N; // the last layer is always the component layer layer2 = LAYER_CMP_N; // the last layer is always the
// component layer
} }
gen_through_holes = false; gen_through_holes = false;
...@@ -381,9 +381,7 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event ) ...@@ -381,9 +381,7 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
} }
/********************************************************************/
void WinEDA_DrillFrame::UpdatePrecisionOptions( wxCommandEvent& event ) void WinEDA_DrillFrame::UpdatePrecisionOptions( wxCommandEvent& event )
/********************************************************************/
{ {
if( m_Choice_Unit->GetSelection()==1 ) if( m_Choice_Unit->GetSelection()==1 )
{ {
...@@ -404,18 +402,15 @@ void WinEDA_DrillFrame::UpdatePrecisionOptions( wxCommandEvent& event ) ...@@ -404,18 +402,15 @@ void WinEDA_DrillFrame::UpdatePrecisionOptions( wxCommandEvent& event )
} }
/**********************************************************************************/
int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* excellon_dest,
std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer )
/**********************************************************************************/
/** /**
* Create the drill file in EXCELLON format * Create the drill file in EXCELLON format
* @return hole count * @return hole count
* @param aHoleListBuffer = hole descriptor list * @param aHoleListBuffer = hole descriptor list
* @param aToolListBuffer = Drill tools list * @param aToolListBuffer = Drill tools list
*/ */
int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* excellon_dest,
std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer )
{ {
int diam, holes_count; int diam, holes_count;
int x0, y0, xf, yf, xc, yc; int x0, y0, xf, yf, xc, yc;
...@@ -434,10 +429,12 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce ...@@ -434,10 +429,12 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
{ {
if( s_Unit_Drill_is_Inch ) /* does it need T01, T02 or is T1,T2 ok?*/ if( s_Unit_Drill_is_Inch ) /* does it need T01, T02 or is T1,T2 ok?*/
fprintf( excellon_dest, "T%dC%.3f\n", ii + 1, fprintf( excellon_dest, "T%dC%.3f\n", ii + 1,
float (aToolListBuffer[ii].m_Diameter) * s_ConversionUnits ); float (aToolListBuffer[ii].m_Diameter)
* s_ConversionUnits );
else else
fprintf( excellon_dest, "T%dC%.3f\n", ii + 1, fprintf( excellon_dest, "T%dC%.3f\n", ii + 1,
float (aToolListBuffer[ii].m_Diameter) * s_ConversionUnits * 10.0 ); float (aToolListBuffer[ii].m_Diameter)
* s_ConversionUnits * 10.0 );
} }
fputs( "%\n", excellon_dest ); fputs( "%\n", excellon_dest );
...@@ -451,7 +448,8 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce ...@@ -451,7 +448,8 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
else if( !Minimal ) else if( !Minimal )
fputs( "M71\n", excellon_dest ); /* M71 = metric mode */ fputs( "M71\n", excellon_dest ); /* M71 = metric mode */
/* Read the hole file and generate lines for normal holes (oblong holes will be created later) */ /* Read the hole file and generate lines for normal holes (oblong
* holes will be created later) */
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ ) for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
{ {
if( aHoleListBuffer[ii].m_Hole_Shape ) if( aHoleListBuffer[ii].m_Hole_Shape )
...@@ -483,8 +481,10 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce ...@@ -483,8 +481,10 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
holes_count++; holes_count++;
} }
/* Read the hole file and generate lines for normal holes (oblong holes will be created later) */ /* Read the hole file and generate lines for normal holes (oblong holes
tool_reference = -2; // set to a value not used for aHoleListBuffer[ii].m_Tool_Reference * will be created later) */
tool_reference = -2; // set to a value not used for
// aHoleListBuffer[ii].m_Tool_Reference
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ ) for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
{ {
if( aHoleListBuffer[ii].m_Hole_Shape == 0 ) if( aHoleListBuffer[ii].m_Hole_Shape == 0 )
...@@ -495,7 +495,8 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce ...@@ -495,7 +495,8 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
fprintf( excellon_dest, "T%d\n", tool_reference ); fprintf( excellon_dest, "T%d\n", tool_reference );
} }
diam = MIN( aHoleListBuffer[ii].m_Hole_SizeX, aHoleListBuffer[ii].m_Hole_SizeY ); diam = MIN( aHoleListBuffer[ii].m_Hole_SizeX,
aHoleListBuffer[ii].m_Hole_SizeY );
if( diam == 0 ) if( diam == 0 )
continue; continue;
...@@ -506,12 +507,14 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce ...@@ -506,12 +507,14 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
/* Compute the start and end coordinates for the shape */ /* Compute the start and end coordinates for the shape */
if( aHoleListBuffer[ii].m_Hole_SizeX < aHoleListBuffer[ii].m_Hole_SizeY ) if( aHoleListBuffer[ii].m_Hole_SizeX < aHoleListBuffer[ii].m_Hole_SizeY )
{ {
int delta = (aHoleListBuffer[ii].m_Hole_SizeY - aHoleListBuffer[ii].m_Hole_SizeX) / 2; int delta = ( aHoleListBuffer[ii].m_Hole_SizeY
- aHoleListBuffer[ii].m_Hole_SizeX ) / 2;
y0 -= delta; yf += delta; y0 -= delta; yf += delta;
} }
else else
{ {
int delta = (aHoleListBuffer[ii].m_Hole_SizeX - aHoleListBuffer[ii].m_Hole_SizeY ) / 2; int delta = ( aHoleListBuffer[ii].m_Hole_SizeX
- aHoleListBuffer[ii].m_Hole_SizeY ) / 2;
x0 -= delta; xf += delta; x0 -= delta; xf += delta;
} }
RotatePoint( &x0, &y0, xc, yc, aHoleListBuffer[ii].m_Hole_Orient ); RotatePoint( &x0, &y0, xc, yc, aHoleListBuffer[ii].m_Hole_Orient );
...@@ -523,12 +526,15 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce ...@@ -523,12 +526,15 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
y0 *= -1; yf *= -1; y0 *= -1; yf *= -1;
} }
xt = float (x0) * s_ConversionUnits; yt = float (y0) * s_ConversionUnits; xt = float (x0) * s_ConversionUnits;
yt = float (y0) * s_ConversionUnits;
if( s_Unit_Drill_is_Inch ) if( s_Unit_Drill_is_Inch )
Gen_Line_EXCELLON( line, xt, yt ); Gen_Line_EXCELLON( line, xt, yt );
else else
Gen_Line_EXCELLON( line, xt * 10, yt * 10 ); Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
/* remove the '\n' from end of line, because we must add the "G85" command to the line: */ /* remove the '\n' from end of line, because we must add the "G85"
* command to the line: */
for( int kk = 0; line[kk] != 0; kk++ ) for( int kk = 0; line[kk] != 0; kk++ )
if( line[kk] == '\n' || line[kk] =='\r' ) if( line[kk] == '\n' || line[kk] =='\r' )
line[kk] = 0; line[kk] = 0;
...@@ -537,7 +543,9 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce ...@@ -537,7 +543,9 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
fputs( "G85", excellon_dest ); // add the "G85" command fputs( "G85", excellon_dest ); // add the "G85" command
xt = float (xf) * s_ConversionUnits; yt = float (yf) * s_ConversionUnits; xt = float (xf) * s_ConversionUnits;
yt = float (yf) * s_ConversionUnits;
if( s_Unit_Drill_is_Inch ) if( s_Unit_Drill_is_Inch )
Gen_Line_EXCELLON( line, xt, yt ); Gen_Line_EXCELLON( line, xt, yt );
else else
...@@ -555,14 +563,11 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce ...@@ -555,14 +563,11 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
} }
/***********************************************************************/
void Gen_Line_EXCELLON( char* line, float x, float y )
/***********************************************************************/
/* Created a line like: /* Created a line like:
* X48000Y19500 * X48000Y19500
* According to the selected format * According to the selected format
*/ */
void Gen_Line_EXCELLON( char* line, float x, float y )
{ {
wxString xs, ys; wxString xs, ys;
int xpad = s_Precision.m_lhs + s_Precision.m_rhs; int xpad = s_Precision.m_lhs + s_Precision.m_rhs;
...@@ -589,9 +594,10 @@ void Gen_Line_EXCELLON( char* line, float x, float y ) ...@@ -589,9 +594,10 @@ void Gen_Line_EXCELLON( char* line, float x, float y )
case SUPPRESS_TRAILING: case SUPPRESS_TRAILING:
{ {
for( int i = 0; i< s_Precision.m_rhs; i++ ) for( int i = 0; i < s_Precision.m_rhs; i++ )
{ {
x *= 10; y *= 10; x *= 10;
y *= 10;
} }
if( x<0 ) if( x<0 )
...@@ -632,10 +638,6 @@ void Gen_Line_EXCELLON( char* line, float x, float y ) ...@@ -632,10 +638,6 @@ void Gen_Line_EXCELLON( char* line, float x, float y )
} }
/************************************************************/
void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
/************************************************************/
/* Print the DRILL file header. The full header is: /* Print the DRILL file header. The full header is:
* M48 * M48
* ;DRILL file {PCBNEW (2007-11-29-b)} date 17/1/2008-21:02:35 * ;DRILL file {PCBNEW (2007-11-29-b)} date 17/1/2008-21:02:35
...@@ -648,6 +650,7 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile ) ...@@ -648,6 +650,7 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
* ICI,OFF * ICI,OFF
* ATC,ON * ATC,ON
*/ */
void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
{ {
char Line[256]; char Line[256];
...@@ -660,7 +663,8 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile ) ...@@ -660,7 +663,8 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
// The next 2 lines in EXCELLON files are comments: // The next 2 lines in EXCELLON files are comments:
wxString msg = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion(); wxString msg = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
fprintf( aFile, ";DRILL file {%s} date %s\n", CONV_TO_UTF8( msg ), Line ); fprintf( aFile, ";DRILL file {%s} date %s\n", CONV_TO_UTF8( msg ),
Line );
msg = wxT( ";FORMAT={" ); msg = wxT( ";FORMAT={" );
// Print precision: // Print precision:
...@@ -675,7 +679,8 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile ) ...@@ -675,7 +679,8 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
* this is same as m_Choice_Zeros_Format strings, but NOT translated * this is same as m_Choice_Zeros_Format strings, but NOT translated
* because some EXCELLON parsers do not like non ascii values * because some EXCELLON parsers do not like non ascii values
* so we use ONLY english (ascii) strings. * so we use ONLY english (ascii) strings.
* if new options are added in m_Choice_Zeros_Format, they must also be added here * if new options are added in m_Choice_Zeros_Format, they must also
* be added here
*/ */
msg << wxT( " / " ); msg << wxT( " / " );
const wxString zero_fmt[5] = const wxString zero_fmt[5] =
...@@ -684,6 +689,7 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile ) ...@@ -684,6 +689,7 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
wxT( "suppress trailing zeros" ), wxT( "keep zeros" ), wxT( "suppress trailing zeros" ), wxT( "keep zeros" ),
wxT( "???" ) wxT( "???" )
}; };
if( ii < 0 || ii > 4 ) if( ii < 0 || ii > 4 )
ii = 4; ii = 4;
msg << zero_fmt[ii]; msg << zero_fmt[ii];
...@@ -716,23 +722,19 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile ) ...@@ -716,23 +722,19 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
} }
/****************************************/
void Write_End_Of_File_Drill( FILE* aFile ) void Write_End_Of_File_Drill( FILE* aFile )
/****************************************/
{ {
//add if minimal here //add if minimal here
fputs( "T0\nM30\n", aFile ); fclose( aFile ); fputs( "T0\nM30\n", aFile ); fclose( aFile );
} }
/**********************************************************************************/ /* Generate the drill plan (Drill map) format HPGL or POSTSCRIPT
*/
void WinEDA_DrillFrame::GenDrillMap( const wxString aFileName, void WinEDA_DrillFrame::GenDrillMap( const wxString aFileName,
std::vector<HOLE_INFO>& aHoleListBuffer, std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& buffer, int format ) std::vector<DRILL_TOOL>& buffer,
/**********************************************************************************/ int format )
/* Genere le plan de percage (Drill map) format HPGL ou POSTSCRIPT
*/
{ {
wxFileName fn; wxFileName fn;
wxString ext, wildcard; wxString ext, wildcard;
...@@ -799,13 +801,10 @@ void WinEDA_DrillFrame::GenDrillMap( const wxString aFileName, ...@@ -799,13 +801,10 @@ void WinEDA_DrillFrame::GenDrillMap( const wxString aFileName,
} }
/**************************************************************************************************/
void WinEDA_DrillFrame::GenDrillReport( const wxString aFileName )
/**************************************************************************************************/
/* /*
* Create a list of drill values and drill count * Create a list of drill values and drill count
*/ */
void WinEDA_DrillFrame::GenDrillReport( const wxString aFileName )
{ {
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
......
/*************************/ /*************/
/* Edition des Pastilles */ /* Edit pads */
/*************************/ /*************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -49,32 +49,31 @@ private: ...@@ -49,32 +49,31 @@ private:
wxCheckBox* m_Pad_Orient_Change; wxCheckBox* m_Pad_Orient_Change;
public: public:
WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* parent, D_PAD* Pad );
// Constructor and destructor
WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame * parent, D_PAD * Pad );
~WinEDA_PadGlobalEditFrame() { } ~WinEDA_PadGlobalEditFrame() { }
private: private:
void PadPropertiesAccept( wxCommandEvent& event ); void PadPropertiesAccept( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
BEGIN_EVENT_TABLE( WinEDA_PadGlobalEditFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_PadGlobalEditFrame, wxDialog )
EVT_BUTTON( ID_CHANGE_CURRENT_MODULE, WinEDA_PadGlobalEditFrame::PadPropertiesAccept ) EVT_BUTTON( ID_CHANGE_CURRENT_MODULE,
EVT_BUTTON( ID_CHANGE_ID_MODULES, WinEDA_PadGlobalEditFrame::PadPropertiesAccept ) WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( ID_CHANGE_GET_PAD_SETTINGS, WinEDA_PadGlobalEditFrame::PadPropertiesAccept ) EVT_BUTTON( ID_CHANGE_ID_MODULES,
EVT_BUTTON( wxID_CANCEL, WinEDA_PadGlobalEditFrame::OnCancelClick ) WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( ID_CHANGE_GET_PAD_SETTINGS,
WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( wxID_CANCEL, WinEDA_PadGlobalEditFrame::OnCancelClick )
END_EVENT_TABLE() END_EVENT_TABLE()
WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame(
/********************************************************************************/ WinEDA_BasePcbFrame* parent,
WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* parent, D_PAD* Pad ) :
D_PAD* Pad ) : wxDialog( parent, -1, _( "Edit Pads Global" ), wxDefaultPosition,
wxDialog( parent, -1, _( "Edit Pads Global" ), wxDefaultPosition, wxSize( 310, 235 ), wxSize( 310, 235 ), DIALOG_STYLE )
DIALOG_STYLE )
/********************************************************************************/
{ {
wxPoint pos; wxPoint pos;
wxButton* Button; wxButton* Button;
...@@ -84,7 +83,7 @@ WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* paren ...@@ -84,7 +83,7 @@ WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* paren
CurrentPad = Pad; CurrentPad = Pad;
/* Creation des boutons de commande */ /* Create command buttons. */
pos.x = 150; pos.x = 150;
pos.y = 10; pos.y = 10;
Button = new wxButton( this, ID_CHANGE_GET_PAD_SETTINGS, Button = new wxButton( this, ID_CHANGE_GET_PAD_SETTINGS,
...@@ -101,69 +100,65 @@ WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* paren ...@@ -101,69 +100,65 @@ WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* paren
pos.y += Button->GetDefaultSize().y + 10; pos.y += Button->GetDefaultSize().y + 10;
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), pos ); Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), pos );
// Selection des filtres de selection des pads : // Pad filter selection.
pos.x = 5; pos.x = 5;
pos.y = 5; pos.y = 5;
new wxStaticBox( this, -1, _( "Pad Filter :" ), pos, wxSize( 130, 75 ) ); new wxStaticBox( this, -1, _( "Pad Filter :" ), pos, wxSize( 130, 75 ) );
pos.x += 5; pos.x += 5;
pos.y += 18; pos.y += 18;
m_Pad_Shape_Filter = new wxCheckBox( this, -1, _( "Shape Filter" ), pos ); m_Pad_Shape_Filter = new wxCheckBox( this, -1, _( "Shape Filter" ), pos );
m_Pad_Shape_Filter->SetValue( Pad_Shape_Filter ); m_Pad_Shape_Filter->SetValue( Pad_Shape_Filter );
pos.y += 18; pos.y += 18;
m_Pad_Layer_Filter = new wxCheckBox( this, -1, _( "Layer Filter" ), pos ); m_Pad_Layer_Filter = new wxCheckBox( this, -1, _( "Layer Filter" ), pos );
m_Pad_Layer_Filter->SetValue( Pad_Layer_Filter ); m_Pad_Layer_Filter->SetValue( Pad_Layer_Filter );
pos.y += 18; pos.y += 18;
m_Pad_Orient_Filter = new wxCheckBox( this, -1, _( "Orient Filter" ), pos ); m_Pad_Orient_Filter = new wxCheckBox( this, -1, _( "Orient Filter" ), pos );
m_Pad_Orient_Filter->SetValue( Pad_Orient_Filter ); m_Pad_Orient_Filter->SetValue( Pad_Orient_Filter );
// Items a editer // Items a editer
pos.x -= 5; pos.x -= 5;
pos.y += 25; pos.y += 25;
new wxStaticBox( this, -1, _( "Change Items :" ), pos, wxSize( 130, 95 ) ); new wxStaticBox( this, -1, _( "Change Items :" ), pos, wxSize( 130, 95 ) );
pos.x += 5; pos.x += 5;
pos.y += 18; pos.y += 18;
m_Pad_Size_Change = new wxCheckBox( this, -1, _( "Change Size" ), pos ); m_Pad_Size_Change = new wxCheckBox( this, -1, _( "Change Size" ), pos );
m_Pad_Size_Change->SetValue( Pad_Size_Change ); m_Pad_Size_Change->SetValue( Pad_Size_Change );
pos.y += 18; pos.y += 18;
m_Pad_Shape_Change = new wxCheckBox( this, -1, _( "Change Shape" ), pos ); m_Pad_Shape_Change = new wxCheckBox( this, -1, _( "Change Shape" ), pos );
m_Pad_Shape_Change->SetValue( Pad_Shape_Change ); m_Pad_Shape_Change->SetValue( Pad_Shape_Change );
pos.y += 18; pos.y += 18;
m_Pad_Drill_Change = new wxCheckBox( this, -1, _( "Change Drill" ), pos ); m_Pad_Drill_Change = new wxCheckBox( this, -1, _( "Change Drill" ), pos );
m_Pad_Drill_Change->SetValue( Pad_Drill_Change ); m_Pad_Drill_Change->SetValue( Pad_Drill_Change );
pos.y += 18; pos.y += 18;
m_Pad_Orient_Change = new wxCheckBox( this, -1, _( "Change Orientation" ), pos ); m_Pad_Orient_Change = new wxCheckBox( this, -1, _( "Change Orientation" ),
pos );
m_Pad_Orient_Change->SetValue( Pad_Orient_Change ); m_Pad_Orient_Change->SetValue( Pad_Orient_Change );
} }
/**********************************************************************/ void WinEDA_PadGlobalEditFrame::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
void WinEDA_PadGlobalEditFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/*************************************************************************/ /* Update the parameters for the component being edited.
void WinEDA_PadGlobalEditFrame::PadPropertiesAccept( wxCommandEvent& event )
/*************************************************************************/
/* Met a jour les differents parametres pour le composant en cours d'dition
*/ */
void WinEDA_PadGlobalEditFrame::PadPropertiesAccept( wxCommandEvent& event )
{ {
int returncode = 0; int returncode = 0;
...@@ -176,7 +171,7 @@ void WinEDA_PadGlobalEditFrame::PadPropertiesAccept( wxCommandEvent& event ) ...@@ -176,7 +171,7 @@ void WinEDA_PadGlobalEditFrame::PadPropertiesAccept( wxCommandEvent& event )
case ID_CHANGE_ID_MODULES: case ID_CHANGE_ID_MODULES:
returncode = 1; returncode = 1;
// Fall through // Fall through
case ID_CHANGE_CURRENT_MODULE: case ID_CHANGE_CURRENT_MODULE:
Pad_Shape_Filter = m_Pad_Shape_Filter->GetValue(); Pad_Shape_Filter = m_Pad_Shape_Filter->GetValue();
...@@ -192,16 +187,14 @@ void WinEDA_PadGlobalEditFrame::PadPropertiesAccept( wxCommandEvent& event ) ...@@ -192,16 +187,14 @@ void WinEDA_PadGlobalEditFrame::PadPropertiesAccept( wxCommandEvent& event )
} }
/***************************************************************************/
void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
/***************************************************************************/
/** Function Global_Import_Pad_Settings /** Function Global_Import_Pad_Settings
* Function to change pad caracteristics for the given footprint * Function to change pad caracteristics for the given footprint
* or alls footprints which look like the given footprint * or alls footprints which look like the given footprint
* @param aPad pad to use as pattern. The given footprint is the parent of this pad * @param aPad pad to use as pattern. The given footprint is the parent of
* this pad
* @param aDraw: if true: redraws the footprint * @param aDraw: if true: redraws the footprint
*/ */
void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
{ {
MODULE* Module_Ref, * Module; MODULE* Module_Ref, * Module;
int diag; int diag;
...@@ -214,7 +207,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -214,7 +207,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( Module == NULL ) if( Module == NULL )
{ {
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) ); DisplayError( this,
wxT( "Global_Import_Pad_Settings() Error: NULL module" ) );
return; return;
} }
...@@ -222,7 +216,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -222,7 +216,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
Module->DisplayInfo( this ); Module->DisplayInfo( this );
WinEDA_PadGlobalEditFrame* frame = new WinEDA_PadGlobalEditFrame( this, aPad ); WinEDA_PadGlobalEditFrame* frame = new WinEDA_PadGlobalEditFrame( this,
aPad );
diag = frame->ShowModal(); diag = frame->ShowModal();
frame->Destroy(); frame->Destroy();
...@@ -232,10 +227,10 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -232,10 +227,10 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( diag == 1 ) if( diag == 1 )
Edit_Same_Modules = TRUE; Edit_Same_Modules = TRUE;
/* Recherche et copie du nom librairie de reference: */ /* Search and copy the name of library reference. */
Module_Ref = Module; Module_Ref = Module;
/* Mise a jour des modules ou du module */ /* Update the modules or module. */
Module = (MODULE*) m_Pcb->m_Modules; Module = (MODULE*) m_Pcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
...@@ -249,18 +244,18 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -249,18 +244,18 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
Module->DisplayInfo( this ); Module->DisplayInfo( this );
/* Effacement du module */ /* Erase module */
if ( aDraw ) if( aDraw )
{ {
Module->m_Flags |= DO_NOT_DRAW; Module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
Module->m_Flags &= ~DO_NOT_DRAW; Module->m_Flags &= ~DO_NOT_DRAW;
} }
D_PAD* pt_pad = (D_PAD*) Module->m_Pads; D_PAD* pt_pad = (D_PAD*) Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{ {
/* Filtrage des modifications interdites */ /* Filters changes prohibited. */
if( Pad_Shape_Filter ) if( Pad_Shape_Filter )
{ {
if( pt_pad->m_PadShape != g_Pad_Master.m_PadShape ) if( pt_pad->m_PadShape != g_Pad_Master.m_PadShape )
...@@ -269,7 +264,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -269,7 +264,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( Pad_Orient_Filter ) if( Pad_Orient_Filter )
{ {
if( (pt_pad->m_Orient - Module->m_Orient) != g_Pad_Master.m_Orient ) if( (pt_pad->m_Orient - Module->m_Orient) !=
g_Pad_Master.m_Orient )
continue; continue;
} }
...@@ -278,10 +274,11 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -278,10 +274,11 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( pt_pad->m_Masque_Layer != g_Pad_Master.m_Masque_Layer ) if( pt_pad->m_Masque_Layer != g_Pad_Master.m_Masque_Layer )
continue; continue;
else else
m_Pcb->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK); m_Pcb->m_Status_Pcb &=
~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK);
} }
/* Modif des caracteristiques: */ /* Change characteristics.: */
if( Pad_Shape_Change ) if( Pad_Shape_Change )
{ {
pt_pad->m_Attribut = g_Pad_Master.m_Attribut; pt_pad->m_Attribut = g_Pad_Master.m_Attribut;
...@@ -292,14 +289,14 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -292,14 +289,14 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( Pad_Size_Change ) if( Pad_Size_Change )
{ {
pt_pad->m_Size = g_Pad_Master.m_Size; pt_pad->m_Size = g_Pad_Master.m_Size;
pt_pad->m_DeltaSize = g_Pad_Master.m_DeltaSize; pt_pad->m_DeltaSize = g_Pad_Master.m_DeltaSize;
pt_pad->m_Offset = g_Pad_Master.m_Offset; pt_pad->m_Offset = g_Pad_Master.m_Offset;
} }
if( Pad_Drill_Change ) if( Pad_Drill_Change )
{ {
pt_pad->m_Drill = g_Pad_Master.m_Drill; pt_pad->m_Drill = g_Pad_Master.m_Drill;
pt_pad->m_DrillShape = g_Pad_Master.m_DrillShape; pt_pad->m_DrillShape = g_Pad_Master.m_DrillShape;
} }
...@@ -308,7 +305,6 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -308,7 +305,6 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
pt_pad->m_Orient = g_Pad_Master.m_Orient + Module->m_Orient; pt_pad->m_Orient = g_Pad_Master.m_Orient + Module->m_Orient;
} }
/* Traitement des cas particuliers : */
if( g_Pad_Master.m_PadShape != PAD_TRAPEZOID ) if( g_Pad_Master.m_PadShape != PAD_TRAPEZOID )
{ {
pt_pad->m_DeltaSize.x = 0; pt_pad->m_DeltaSize.x = 0;
...@@ -334,7 +330,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -334,7 +330,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
} }
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
if ( aDraw ) if( aDraw )
DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
} }
......
/****************************************************/
/* EDITEUR de PCB: AUTOROUTAGE: routines "graphiques" */ /* PCB EDITOR: autorouting and "graphics" routines. */
/******************************************************/ /****************************************************/
/* Fichier BOARD.CC */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -14,60 +12,88 @@ ...@@ -14,60 +12,88 @@
#include "trigo.h" #include "trigo.h"
#include "cell.h" #include "cell.h"
/* Exported functions */ int ToMatrixCoordinate( int aPhysicalCoordinate );
int ToMatrixCoordinate ( int aPhysicalCoordinate); void TraceLignePcb( int x0,
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color ); int y0,
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int layer, int x1,
int color, int op_logique ); int y1,
int layer,
int color );
/* Local functions */ void TraceArc( int ux0,
static void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int uy0,
int color, int op_logique ); int ux1,
int uy1,
static void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, int ArcAngle,
int color, int op_logique ); int lg,
static void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int layer,
int color, int op_logique ); int color,
int op_logique );
/* Macro d'appel de mise a jour de cellules */
#define OP_CELL( layer, dy, dx ) { if( layer < 0 ) \
{ \ static void DrawSegmentQcq( int ux0,
WriteCell( dy, dx, BOTTOM, color ); \ int uy0,
if( Nb_Sides ) \ int ux1,
WriteCell( dy, dx, TOP, color );\ int uy1,
} \ int lg,
else { \ int layer,
if( layer == Route_Layer_BOTTOM ) \ int color,
WriteCell( dy, dx, BOTTOM, color );\ int op_logique );
if( Nb_Sides ) \
if( layer == Route_Layer_TOP ) \ static void TraceFilledCercle( BOARD* Pcb,
WriteCell( dy, dx, TOP, color );\ int cx,
} } int cy,
int rayon,
int ToMatrixCoordinate ( int aPhysicalCoordinate) int masque_layer,
int color,
int op_logique );
static void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logique );
/* Macro call to update cell. */
#define OP_CELL( layer, dy, dx ) \
{ \
if( layer < 0 ) \
{ \
WriteCell( dy, dx, BOTTOM, color ); \
if( Nb_Sides ) \
WriteCell( dy, dx, TOP, color ); \
} \
else \
{ \
if( layer == Route_Layer_BOTTOM ) \
WriteCell( dy, dx, BOTTOM, color ); \
if( Nb_Sides ) \
if( layer == Route_Layer_TOP ) \
WriteCell( dy, dx, TOP, color ); \
} \
}
/** Function ToMatrixCoordinate /** Function ToMatrixCoordinate
* compute the coordinate in the routing matrix from the real (board) value * compute the coordinate in the routing matrix from the real (board) value
* @param aPhysicalCoordinate = value to convert * @param aPhysicalCoordinate = value to convert
* @return the coordinate relative to the matrix * @return the coordinate relative to the matrix
*/ */
int ToMatrixCoordinate( int aPhysicalCoordinate )
{ {
return aPhysicalCoordinate / g_GridRoutingSize; return aPhysicalCoordinate / g_GridRoutingSize;
} }
/******************************************************************************/
void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logique ) /* Initialize a color value, the cells included in the board edge of the
/******************************************************************************/ * pad surface by pt_pad, with the margin reserved for isolation and the
* half width of the runway
/* Initialise a la valeur color, les cellules du Board comprises dans la * Parameters:
* surface du pad pointe par pt_pad, avec la marge reservee pour l'isolement * Pt_pad: pointer to the description of the pad
* et la demi largeur de la piste * color: mask write in cells
* Parametres: * margin: add a value to the radius or half the score pad
* pt_pad : pointeur sur la description du pad * op_logique: type of writing in the cell (WRITE, OR)
* color : masque a ecrire dans les cellules
* marge : valeur a ajouter au rayon ou demi cote du pad
* op_logique: type d'ecriture dans la cellule ( WRITE, OR )
*/ */
void Place_1_Pad_Board( BOARD* Pcb,
D_PAD* pt_pad,
int color,
int marge,
int op_logique )
{ {
int dx, dy; int dx, dy;
wxPoint shape_pos = pt_pad->ReturnShapePos();; wxPoint shape_pos = pt_pad->ReturnShapePos();;
...@@ -90,10 +116,12 @@ void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_ ...@@ -90,10 +116,12 @@ void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_
dy += abs( pt_pad->m_DeltaSize.x ) / 2; dy += abs( pt_pad->m_DeltaSize.x ) / 2;
} }
if( (pt_pad->m_Orient % 900) == 0 ) if( ( pt_pad->m_Orient % 900 ) == 0 ) /* The pad is a rectangle
{ /* Le pad est un rectangle horizontal ou vertical */ * horizontally or vertically. */
if( (pt_pad->m_Orient == 900 ) || (pt_pad->m_Orient == 2700) ) {
{ /* orient tournee de 90 deg */ /* Orientation turned 90 deg. */
if( ( pt_pad->m_Orient == 900 ) || ( pt_pad->m_Orient == 2700 ) )
{
EXCHG( dx, dy ); EXCHG( dx, dy );
} }
...@@ -111,19 +139,21 @@ void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_ ...@@ -111,19 +139,21 @@ void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_
} }
/************************************************************************/ /* Initialize a color value, the cells included in the board rea of the
void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, * circle center cx, cy.
int color, int op_logique ) * Parameters:
/************************************************************************/ * radius: a value add to the radius or half the score pad
* masque_layer: layer occupied
/* Initialise a la valeur color, les cellules du Board comprises dans la * color: mask write in cells
* surface du cercle de centre cx,cy. * op_logique: type of writing in the cell (WRITE, OR)
* Parametres:
* rayon : valeur a ajouter au rayon ou demi cote du pad
* masque_layer = couches occupees
* color : masque a ecrire dans les cellules
* op_logique: type d'ecriture dans la cellule ( WRITE, OR )
*/ */
void TraceFilledCercle( BOARD* Pcb,
int cx,
int cy,
int rayon,
int masque_layer,
int color,
int op_logique )
{ {
int row, col; int row, col;
int ux0, uy0, ux1, uy1; int ux0, uy0, ux1, uy1;
...@@ -131,21 +161,21 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, ...@@ -131,21 +161,21 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
int trace = 0; int trace = 0;
float fdistmin, fdistx, fdisty; float fdistmin, fdistx, fdisty;
void (*WriteCell)( int, int, int, BoardCell ); void (* WriteCell)( int, int, int, BoardCell );
int tstwrite = 0; int tstwrite = 0;
int distmin; int distmin;
/* Determination des couches occupees : */ /* Determine occupied layer. */
/* routage sur 1 seule couche: /* Single routing layer on bitmap and BOTTOM
* sur bitmap BOTTOM et Route_Layer_B = Route_Layer_A*/ * Route_Layer_B = Route_Layer_A */
if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] )
trace = 1; /* Trace sur BOTTOM */ trace = 1; /* Trace on BOTTOM */
if( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) if( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] )
if( Nb_Sides ) if( Nb_Sides )
trace |= 2;/* Trace sur TOP */ trace |= 2; /* Trace on TOP */
if( trace == 0 ) if( trace == 0 )
return; return;
...@@ -154,34 +184,44 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, ...@@ -154,34 +184,44 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
{ {
default: default:
case WRITE_CELL: case WRITE_CELL:
WriteCell = SetCell; break; WriteCell = SetCell;
break;
case WRITE_OR_CELL: case WRITE_OR_CELL:
WriteCell = OrCell; break; WriteCell = OrCell;
break;
case WRITE_XOR_CELL: case WRITE_XOR_CELL:
WriteCell = XorCell; break; WriteCell = XorCell;
break;
case WRITE_AND_CELL: case WRITE_AND_CELL:
WriteCell = AndCell; break; WriteCell = AndCell;
break;
case WRITE_ADD_CELL: case WRITE_ADD_CELL:
WriteCell = AddCell; break; WriteCell = AddCell;
break;
} }
cx -= Pcb->m_BoundaryBox.m_Pos.x; cy -= Pcb->m_BoundaryBox.m_Pos.y; cx -= Pcb->m_BoundaryBox.m_Pos.x;
cy -= Pcb->m_BoundaryBox.m_Pos.y;
distmin = rayon; distmin = rayon;
/* Calcul du rectangle d'encadrement du cercle*/ /* Calculate the bounding rectangle of the circle. */
ux0 = cx - rayon; uy0 = cy - rayon; ux0 = cx - rayon;
ux1 = cx + rayon; uy1 = cy + rayon; uy0 = cy - rayon;
ux1 = cx + rayon;
uy1 = cy + rayon;
/* Calcul des coord limites des cellules appartenant au rectangle */ /* Calculate limit coordinates of cells belonging to the rectangle. */
row_max = uy1 / g_GridRoutingSize; row_max = uy1 / g_GridRoutingSize;
col_max = ux1 / g_GridRoutingSize; col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; // if (uy0 > row_min*g_GridRoutingSize ) row_min++; row_min = uy0 / g_GridRoutingSize; // if (uy0 > row_min*g_GridRoutingSize
col_min = ux0 / g_GridRoutingSize; // if (ux0 > col_min*g_GridRoutingSize ) col_min++; // ) row_min++;
col_min = ux0 / g_GridRoutingSize; // if (ux0 > col_min*g_GridRoutingSize
// ) col_min++;
if( row_min < 0 ) if( row_min < 0 )
row_min = 0; row_min = 0;
...@@ -192,7 +232,7 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, ...@@ -192,7 +232,7 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
if( col_max >= (Ncols - 1) ) if( col_max >= (Ncols - 1) )
col_max = Ncols - 1; col_max = Ncols - 1;
/* On s'assure que l'on place toujours au moins une cellule */ /* Calculate coordinate limits of cell belonging to the rectangle. */
if( row_min > row_max ) if( row_min > row_max )
row_max = row_min; row_max = row_min;
if( col_min > col_max ) if( col_min > col_max )
...@@ -202,14 +242,14 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, ...@@ -202,14 +242,14 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
for( row = row_min; row <= row_max; row++ ) for( row = row_min; row <= row_max; row++ )
{ {
fdisty = (float) ( cy - (row * g_GridRoutingSize) ); fdisty = (float) ( cy - ( row * g_GridRoutingSize ) );
fdisty *= fdisty; fdisty *= fdisty;
for( col = col_min; col <= col_max; col++ ) for( col = col_min; col <= col_max; col++ )
{ {
fdistx = (float) ( cx - (col * g_GridRoutingSize) ); fdistx = (float) ( cx - ( col * g_GridRoutingSize ) );
fdistx *= fdistx; fdistx *= fdistx;
if( fdistmin <= (fdistx + fdisty) ) if( fdistmin <= ( fdistx + fdisty ) )
continue; continue;
if( trace & 1 ) if( trace & 1 )
...@@ -223,22 +263,23 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, ...@@ -223,22 +263,23 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
if( tstwrite ) if( tstwrite )
return; return;
/* Si aucune cellule n'a ete ecrite, on touche les 4 voisins diagonaux /* If no cell has been written, it affects the 4 neighboring diagonal
* (cas defavorable: pad hors grille, au centre des 4 voisins diagonaux) */ * (Adverse event: pad off grid in the center of the 4 neighboring
* diagonal) */
distmin = g_GridRoutingSize / 2 + 1; distmin = g_GridRoutingSize / 2 + 1;
fdistmin = ( (float) distmin * distmin ) * 2; /* = dist centre au point diagonal*/ fdistmin = ( (float) distmin * distmin ) * 2; /* Distance to center point
* diagonally */
for( row = row_min; row <= row_max; row++ ) for( row = row_min; row <= row_max; row++ )
{ {
fdisty = (float) ( cy - (row * g_GridRoutingSize) ); fdisty = (float) ( cy - ( row * g_GridRoutingSize ) );
fdisty *= fdisty; fdisty *= fdisty;
for( col = col_min; col <= col_max; col++ ) for( col = col_min; col <= col_max; col++ )
{ {
fdistx = (float) ( cx - (col * g_GridRoutingSize) ); fdistx = (float) ( cx - ( col * g_GridRoutingSize ) );
fdistx *= fdistx; fdistx *= fdistx;
if( fdistmin <= (fdistx + fdisty) ) if( fdistmin <= ( fdistx + fdisty ) )
continue; continue;
if( trace & 1 ) if( trace & 1 )
...@@ -250,44 +291,46 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, ...@@ -250,44 +291,46 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
} }
/******************************************************************************/ /* Draws a segment of track on the BOARD.
void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_logique )
/******************************************************************************/
/* trace un Segment de piste sur le BOARD de routage
*/ */
void TraceSegmentPcb( BOARD* Pcb,
TRACK* pt_segm,
int color,
int marge,
int op_logique )
{ {
int demi_pas, demi_largeur; int demi_pas, demi_largeur;
int ux0, uy0, ux1, uy1; int ux0, uy0, ux1, uy1;
demi_pas = g_GridRoutingSize / 2; demi_pas = g_GridRoutingSize / 2;
demi_largeur = (pt_segm->m_Width / 2) + marge; demi_largeur = ( pt_segm->m_Width / 2 ) + marge;
/* Calcul du rectangle d'encadrement du segment ( si H,V ou Via) */ /* Calculate the bounding rectangle of the segment (if H, V or Via) */
ux0 = pt_segm->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x; ux0 = pt_segm->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x;
uy0 = pt_segm->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y; uy0 = pt_segm->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y;
ux1 = pt_segm->m_End.x - Pcb->m_BoundaryBox.m_Pos.x; ux1 = pt_segm->m_End.x - Pcb->m_BoundaryBox.m_Pos.x;
uy1 = pt_segm->m_End.y - Pcb->m_BoundaryBox.m_Pos.y; uy1 = pt_segm->m_End.y - Pcb->m_BoundaryBox.m_Pos.y;
/* Test si VIA (cercle plein a tracer) */ /* Test if VIA (filled circle was drawn) */
if( pt_segm->Type() == TYPE_VIA ) if( pt_segm->Type() == TYPE_VIA )
{ {
int mask_layer = 0; int mask_layer = 0;
if ( pt_segm->IsOnLayer(Route_Layer_BOTTOM) ) if( pt_segm->IsOnLayer( Route_Layer_BOTTOM ) )
mask_layer = 1 << Route_Layer_BOTTOM; mask_layer = 1 << Route_Layer_BOTTOM;
if ( pt_segm->IsOnLayer(Route_Layer_TOP) ) if( pt_segm->IsOnLayer( Route_Layer_TOP ) )
{ {
if ( mask_layer == 0 ) if( mask_layer == 0 )
mask_layer = 1 << Route_Layer_TOP; mask_layer = 1 << Route_Layer_TOP;
else mask_layer = -1; else
mask_layer = -1;
} }
if( color == VIA_IMPOSSIBLE ) if( color == VIA_IMPOSSIBLE )
mask_layer = -1; mask_layer = -1;
if ( mask_layer ) if( mask_layer )
TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur, TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y,
mask_layer, color, op_logique ); demi_largeur, mask_layer, color, op_logique );
return; return;
} }
...@@ -295,44 +338,52 @@ void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_l ...@@ -295,44 +338,52 @@ void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_l
if( color == VIA_IMPOSSIBLE ) if( color == VIA_IMPOSSIBLE )
layer = -1; layer = -1;
/* Le segment est ici un segment de droite ou un cercle ou un arc: */ /* The segment is here a straight line or a circle or an arc.: */
if( pt_segm->m_Shape == S_CIRCLE ) if( pt_segm->m_Shape == S_CIRCLE )
{ {
TraceCercle( ux0, uy0, ux1, uy1, demi_largeur, layer, color, op_logique ); TraceCercle( ux0, uy0, ux1, uy1, demi_largeur, layer, color,
op_logique );
return; return;
} }
if( pt_segm->m_Shape == S_ARC ) if( pt_segm->m_Shape == S_ARC )
{ {
TraceArc( ux0, uy0, ux1, uy1, pt_segm->m_Param, demi_largeur, layer, color, op_logique ); TraceArc( ux0, uy0, ux1, uy1, pt_segm->m_Param, demi_largeur, layer,
color, op_logique );
return; return;
} }
/* Le segment est ici un segment de droite */ /* The segment is here a line segment. */
if( (ux0 != ux1) && (uy0 != uy1) ) // segment incline if( ( ux0 != ux1 ) && ( uy0 != uy1 ) ) // Segment tilts.
{ {
DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color, op_logique ); DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color,
op_logique );
return; return;
} }
// Ici le segment est HORIZONTAL ou VERTICAL // The segment is horizontal or vertical.
// DrawHVSegment(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); //F4EXB 051018-01 // DrawHVSegment(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique);
DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color, op_logique ); //F4EXB 051018-01 // F4EXB 051018-01
return; //F4EXB 051018-01 DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color,
op_logique ); // F4EXB 051018-01
return; // F4EXB 051018-01
} }
/******************************************************************************************/ /* Draws a line, if layer = -1 on all layers
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op_logique )
/******************************************************************************************/
/* trace une ligne; si layer = -1 sur toutes les couches
*/ */
void TraceLignePcb( int x0,
int y0,
int x1,
int y1,
int layer,
int color,
int op_logique )
{ {
int dx, dy, lim; int dx, dy, lim;
int cumul, inc, il, delta; int cumul, inc, il, delta;
void (*WriteCell)( int, int, int, BoardCell ); void (* WriteCell)( int, int, int, BoardCell );
switch( op_logique ) switch( op_logique )
{ {
...@@ -353,15 +404,15 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -353,15 +404,15 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
WriteCell = AddCell; break; WriteCell = AddCell; break;
} }
if( x0 == x1 ) // ligne verticale if( x0 == x1 ) // Vertical.
{ {
if( y1 < y0 ) if( y1 < y0 )
EXCHG( y0, y1 ); EXCHG( y0, y1 );
dy = y0 / g_GridRoutingSize; dy = y0 / g_GridRoutingSize;
lim = y1 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize;
dx = x0 / g_GridRoutingSize; dx = x0 / g_GridRoutingSize;
/* Clipping aux limites du board */ /* Clipping limits of board. */
if( (dx < 0) || (dx >= Ncols) ) if( ( dx < 0 ) || ( dx >= Ncols ) )
return; return;
if( dy < 0 ) if( dy < 0 )
dy = 0; dy = 0;
...@@ -375,15 +426,15 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -375,15 +426,15 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
return; return;
} }
if( y0 == y1 ) // ligne horizontale if( y0 == y1 ) // Horizontal
{ {
if( x1 < x0 ) if( x1 < x0 )
EXCHG( x0, x1 ); EXCHG( x0, x1 );
dx = x0 / g_GridRoutingSize; dx = x0 / g_GridRoutingSize;
lim = x1 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize;
dy = y0 / g_GridRoutingSize; dy = y0 / g_GridRoutingSize;
/* Clipping aux limites du board */ /* Clipping limits of board. */
if( (dy < 0) || (dy >= Nrows) ) if( ( dy < 0 ) || ( dy >= Nrows ) )
return; return;
if( dx < 0 ) if( dx < 0 )
dx = 0; dx = 0;
...@@ -397,8 +448,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -397,8 +448,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
return; return;
} }
/* Ici l'angle est quelconque: on utilise l'algorithme de LUCAS */ /* Here is some perspective: using the algorithm LUCAS. */
if( abs( x1 - x0 ) >= abs( y1 - y0 ) ) /* segment peu incline */ if( abs( x1 - x0 ) >= abs( y1 - y0 ) ) /* segment slightly inclined/ */
{ {
if( x1 < x0 ) if( x1 < x0 )
{ {
...@@ -410,18 +461,24 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -410,18 +461,24 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
dy = y0 / g_GridRoutingSize; dy = y0 / g_GridRoutingSize;
inc = 1; if( y1 < y0 ) inc = 1; if( y1 < y0 )
inc = -1; inc = -1;
il = lim - dx; cumul = il / 2; delta = abs( y1 - y0 ) / g_GridRoutingSize; il = lim - dx; cumul = il / 2;
delta = abs( y1 - y0 ) / g_GridRoutingSize;
for( ; dx <= lim; ) for( ; dx <= lim; )
{ {
if( (dx >= 0) && (dy >= 0) if( ( dx >= 0 ) && ( dy >= 0 )
&& (dx < Ncols) && (dy < Nrows) ) && ( dx < Ncols ) && ( dy < Nrows ) )
{ {
OP_CELL( layer, dy, dx ); OP_CELL( layer, dy, dx );
} }
dx++; cumul += delta;
dx++;
cumul += delta;
if( cumul > il ) if( cumul > il )
{ {
cumul -= il; dy += inc; cumul -= il;
dy += inc;
} }
} }
} }
...@@ -429,58 +486,63 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -429,58 +486,63 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
{ {
if( y1 < y0 ) if( y1 < y0 )
{ {
EXCHG( x1, x0 ); EXCHG( y1, y0 ); EXCHG( x1, x0 );
EXCHG( y1, y0 );
} }
dy = y0 / g_GridRoutingSize; dy = y0 / g_GridRoutingSize;
lim = y1 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize;
dx = x0 / g_GridRoutingSize; dx = x0 / g_GridRoutingSize;
inc = 1; if( x1 < x0 ) inc = 1;
if( x1 < x0 )
inc = -1; inc = -1;
il = lim - dy; cumul = il / 2; delta = abs( x1 - x0 ) / g_GridRoutingSize;
il = lim - dy; cumul = il / 2;
delta = abs( x1 - x0 ) / g_GridRoutingSize;
for( ; dy <= lim; ) for( ; dy <= lim; )
{ {
if( (dx >= 0) && (dy >= 0) if( ( dx >= 0 ) && ( dy >= 0 )
&& (dx < Ncols) && (dy < Nrows) ) && ( dx < Ncols ) && ( dy < Nrows ) )
{ {
OP_CELL( layer, dy, dx ); OP_CELL( layer, dy, dx );
} }
dy++; cumul += delta;
dy++;
cumul += delta;
if( cumul > il ) if( cumul > il )
{ {
cumul -= il; dx += inc; cumul -= il;
dx += inc;
} }
} }
} }
} }
/*****************************************************************/ /* Overloaded functions.
void TraceFilledRectangle( BOARD* Pcb,
int ux0, int uy0, int ux1, int uy1,
int masque_layer, int color, int op_logique )
/*****************************************************************/
/* Fonction Surchargee.
* *
* Met a la valeur color l'ensemble des cellules du board inscrites dans * Uses the color value of all cells included in the board coordinate of
* le rectangle de coord ux0,uy0 ( angle haut a gauche ) * the rectangle ux0, uy0 (top left corner)
* a ux1,uy1 ( angle bas a droite ) * A UX1, UY1 (bottom right corner)
* Le rectangle est horizontal ( ou vertical ) * The rectangle is horizontal (or vertical)
* Coordonnees PCB. * Contact PCBs.
*/ */
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int masque_layer, int color, int op_logique )
{ {
int row, col; int row, col;
int row_min, row_max, col_min, col_max; int row_min, row_max, col_min, col_max;
int trace = 0; int trace = 0;
void (*WriteCell)( int, int, int, BoardCell ); void (* WriteCell)( int, int, int, BoardCell );
if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] )
trace = 1; /* Trace sur BOTTOM */ trace = 1; /* Trace on BOTTOM */
if( (masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides ) if( ( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides )
trace |= 2; /* Trace sur TOP */ trace |= 2; /* Trace on TOP */
if( trace == 0 ) if( trace == 0 )
return; return;
...@@ -489,39 +551,48 @@ void TraceFilledRectangle( BOARD* Pcb, ...@@ -489,39 +551,48 @@ void TraceFilledRectangle( BOARD* Pcb,
{ {
default: default:
case WRITE_CELL: case WRITE_CELL:
WriteCell = SetCell; break; WriteCell = SetCell;
break;
case WRITE_OR_CELL: case WRITE_OR_CELL:
WriteCell = OrCell; break; WriteCell = OrCell;
break;
case WRITE_XOR_CELL: case WRITE_XOR_CELL:
WriteCell = XorCell; break; WriteCell = XorCell;
break;
case WRITE_AND_CELL: case WRITE_AND_CELL:
WriteCell = AndCell; break; WriteCell = AndCell;
break;
case WRITE_ADD_CELL: case WRITE_ADD_CELL:
WriteCell = AddCell; break; WriteCell = AddCell;
break;
} }
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
/* Calcul des coord limites des cellules appartenant au rectangle */ /* Calculating limits coord cells belonging to the rectangle. */
row_max = uy1 / g_GridRoutingSize; row_max = uy1 / g_GridRoutingSize;
col_max = ux1 / g_GridRoutingSize; col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize ) row_min = uy0 / g_GridRoutingSize;
if( uy0 > row_min * g_GridRoutingSize )
row_min++; row_min++;
col_min = ux0 / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize ) col_min = ux0 / g_GridRoutingSize;
if( ux0 > col_min * g_GridRoutingSize )
col_min++; col_min++;
if( row_min < 0 ) if( row_min < 0 )
row_min = 0; row_min = 0;
if( row_max >= (Nrows - 1) ) if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1; row_max = Nrows - 1;
if( col_min < 0 ) if( col_min < 0 )
col_min = 0; col_min = 0;
if( col_max >= (Ncols - 1) ) if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1; col_max = Ncols - 1;
for( row = row_min; row <= row_max; row++ ) for( row = row_min; row <= row_max; row++ )
...@@ -537,35 +608,33 @@ void TraceFilledRectangle( BOARD* Pcb, ...@@ -537,35 +608,33 @@ void TraceFilledRectangle( BOARD* Pcb,
} }
/***********************************************************************************/ /* Overloaded functions.
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int angle,
int masque_layer, int color, int op_logique )
/***********************************************************************************/
/* Fonction Surchargee.
* *
* Met a la valeur color l'ensemble des cellules du board inscrites dans * Uses the color value of all cells included in the board coordinate of the
* le rectangle de coord ux0,uy0 ( angle haut a droite ) * rectangle ux0, uy0 (top right corner)
* a ux1,uy1 ( angle bas a gauche ) * a UX1, UY1 (lower left corner)
* Le rectangle est tourne de la valeur angle (en 0,1 degres) * the rectangle is the value of turning angle (in degrees 0.1)
* Coordonnees PCB. * contact PCBs.
*/ */
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int angle, int masque_layer, int color,
int op_logique )
{ {
int row, col; int row, col;
int cx, cy; /* Centre du rectangle */ int cx, cy; /* Center of rectangle */
int rayon; /* rayon du cercle exinscrit */ int rayon; /* Radius of the circle */
int row_min, row_max, col_min, col_max; int row_min, row_max, col_min, col_max;
int rotrow, rotcol; int rotrow, rotcol;
int trace = 0; int trace = 0;
void (*WriteCell)( int, int, int, BoardCell ); void (* WriteCell)( int, int, int, BoardCell );
if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] )
trace = 1; /* Trace sur BOTTOM */ trace = 1; /* Trace on BOTTOM */
if( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) if( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] )
if( Nb_Sides ) if( Nb_Sides )
trace |= 2;/* Trace sur TOP */ trace |= 2; /* Trace on TOP */
if( trace == 0 ) if( trace == 0 )
return; return;
...@@ -574,50 +643,61 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int a ...@@ -574,50 +643,61 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int a
{ {
default: default:
case WRITE_CELL: case WRITE_CELL:
WriteCell = SetCell; break; WriteCell = SetCell;
break;
case WRITE_OR_CELL: case WRITE_OR_CELL:
WriteCell = OrCell; break; WriteCell = OrCell;
break;
case WRITE_XOR_CELL: case WRITE_XOR_CELL:
WriteCell = XorCell; break; WriteCell = XorCell;
break;
case WRITE_AND_CELL: case WRITE_AND_CELL:
WriteCell = AndCell; break; WriteCell = AndCell;
break;
case WRITE_ADD_CELL: case WRITE_ADD_CELL:
WriteCell = AddCell; break; WriteCell = AddCell;
break;
} }
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
cx = (ux0 + ux1) / 2; cy = (uy0 + uy1) / 2; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
rayon = (int) sqrt( (double) (cx - ux0) * (cx - ux0)
+ (double) (cy - uy0) * (cy - uy0) ); cx = (ux0 + ux1) / 2;
cy = (uy0 + uy1) / 2;
/* Calcul des coord limites des cellules appartenant au rectangle */ rayon = (int) sqrt( (double) ( cx - ux0 ) * ( cx - ux0 )
row_max = (cy + rayon) / g_GridRoutingSize; + (double) ( cy - uy0 ) * ( cy - uy0 ) );
col_max = (cx + rayon) / g_GridRoutingSize;
row_min = (cy - rayon) / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize ) /* Calculating coordinate limits belonging to the rectangle. */
row_max = ( cy + rayon ) / g_GridRoutingSize;
col_max = ( cx + rayon ) / g_GridRoutingSize;
row_min = ( cy - rayon ) / g_GridRoutingSize;
if( uy0 > row_min * g_GridRoutingSize )
row_min++; row_min++;
col_min = (cx - rayon) / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize ) col_min = ( cx - rayon ) / g_GridRoutingSize;
if( ux0 > col_min * g_GridRoutingSize )
col_min++; col_min++;
if( row_min < 0 ) if( row_min < 0 )
row_min = 0; row_min = 0;
if( row_max >= (Nrows - 1) ) if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1; row_max = Nrows - 1;
if( col_min < 0 ) if( col_min < 0 )
col_min = 0; col_min = 0;
if( col_max >= (Ncols - 1) ) if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1; col_max = Ncols - 1;
for( row = row_min; row <= row_max; row++ ) for( row = row_min; row <= row_max; row++ )
{ {
for( col = col_min; col <= col_max; col++ ) for( col = col_min; col <= col_max; col++ )
{ {
rotrow = row * g_GridRoutingSize; rotcol = col * g_GridRoutingSize; rotrow = row * g_GridRoutingSize;
rotcol = col * g_GridRoutingSize;
RotatePoint( &rotcol, &rotrow, cx, cy, -angle ); RotatePoint( &rotcol, &rotrow, cx, cy, -angle );
if( rotrow <= uy0 ) if( rotrow <= uy0 )
continue; continue;
...@@ -636,22 +716,20 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int a ...@@ -636,22 +716,20 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int a
} }
/*****************************************************************/ /* Fills all cells BOARD contained in the segment
* half-width lg, org ux, ux end y0, y1 is set to color.
* coordinates in PCB units (0.1 million) relating to the origin
* pt_pcb-> m_PcbBox.m_Xmin, Y's board.
*/
void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logique ) int color, int op_logique )
/*****************************************************************/
/* Remplit toutes les cellules du BOARD contenues dans le segment
* de demi-largeur lg, org ux,y0 fin ux,y1 a la valeur color .
* coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->m_PcbBox.m_Xmin,Y du board.
*/
{ {
int row, col; int row, col;
int inc; int inc;
int row_max, col_max, row_min, col_min; int row_max, col_max, row_min, col_min;
int demi_pas; int demi_pas;
void (*WriteCell)( int, int, int, BoardCell ); void (* WriteCell)( int, int, int, BoardCell );
int angle; int angle;
int cx, cy, dx, dy; int cx, cy, dx, dy;
...@@ -659,101 +737,111 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, ...@@ -659,101 +737,111 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
{ {
default: default:
case WRITE_CELL: case WRITE_CELL:
WriteCell = SetCell; break; WriteCell = SetCell;
break;
case WRITE_OR_CELL: case WRITE_OR_CELL:
WriteCell = OrCell; break; WriteCell = OrCell;
break;
case WRITE_XOR_CELL: case WRITE_XOR_CELL:
WriteCell = XorCell; break; WriteCell = XorCell;
break;
case WRITE_AND_CELL: case WRITE_AND_CELL:
WriteCell = AndCell; break; WriteCell = AndCell;
break;
case WRITE_ADD_CELL: case WRITE_ADD_CELL:
WriteCell = AddCell; break; WriteCell = AddCell;
break;
} }
/* on rend la coordonnee ux1 tj > ux0 , pour simplifier les calculs */ /* Make coordinate ux1 tj > ux0 to simplify calculations */
if( ux1 < ux0 ) if( ux1 < ux0 )
{ {
EXCHG( ux1, ux0 ); EXCHG( uy1, uy0 ); EXCHG( ux1, ux0 );
EXCHG( uy1, uy0 );
} }
/* calcul de l'increment selon axe Y */ /* Calculating the incrementing the Y axis */
inc = 1; if( uy1 < uy0 ) inc = 1;
if( uy1 < uy0 )
inc = -1; inc = -1;
/* Calcul de l'encadrement : */
demi_pas = g_GridRoutingSize / 2; demi_pas = g_GridRoutingSize / 2;
col_min = (ux0 - lg) / g_GridRoutingSize; col_min = ( ux0 - lg ) / g_GridRoutingSize;
if( col_min < 0 ) if( col_min < 0 )
col_min = 0; col_min = 0;
col_max = (ux1 + lg + demi_pas) / g_GridRoutingSize; col_max = ( ux1 + lg + demi_pas ) / g_GridRoutingSize;
if( col_max > (Ncols - 1) ) if( col_max > ( Ncols - 1 ) )
col_max = Ncols - 1; col_max = Ncols - 1;
if( inc > 0 ) if( inc > 0 )
{ {
row_min = (uy0 - lg) / g_GridRoutingSize; row_min = ( uy0 - lg ) / g_GridRoutingSize;
row_max = (uy1 + lg + demi_pas) / g_GridRoutingSize; row_max = ( uy1 + lg + demi_pas ) / g_GridRoutingSize;
} }
else else
{ {
row_min = (uy1 - lg) / g_GridRoutingSize; row_min = ( uy1 - lg ) / g_GridRoutingSize;
row_max = (uy0 + lg + demi_pas) / g_GridRoutingSize; row_max = ( uy0 + lg + demi_pas ) / g_GridRoutingSize;
} }
if( row_min < 0 ) if( row_min < 0 )
row_min = 0; row_min = 0;
if( row_min > (Nrows - 1) ) if( row_min > ( Nrows - 1 ) )
row_min = Nrows - 1; row_min = Nrows - 1;
if( row_max < 0 ) if( row_max < 0 )
row_max = 0; row_max = 0;
if( row_max > (Nrows - 1) ) if( row_max > ( Nrows - 1 ) )
row_max = Nrows - 1; row_max = Nrows - 1;
dx = ux1 - ux0;
dy = uy1 - uy0;
dx = ux1 - ux0; dy = uy1 - uy0;
if( dx ) if( dx )
angle = (int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI); angle = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
else else
{ {
angle = 900; if( dy < 0 ) angle = 900;
if( dy < 0 )
angle = -900; angle = -900;
} }
RotatePoint( &dx, &dy, angle ); /* dx = longueur, dy = 0 */ RotatePoint( &dx, &dy, angle ); /* dx = length, dy = 0 */
for( col = col_min; col <= col_max; col++ ) for( col = col_min; col <= col_max; col++ )
{ {
int cxr; int cxr;
cxr = (col * g_GridRoutingSize) - ux0; cxr = ( col * g_GridRoutingSize ) - ux0;
for( row = row_min; row <= row_max; row++ ) for( row = row_min; row <= row_max; row++ )
{ {
cy = (row * g_GridRoutingSize) - uy0; cy = (row * g_GridRoutingSize) - uy0;
cx = cxr; cx = cxr;
RotatePoint( &cx, &cy, angle ); RotatePoint( &cx, &cy, angle );
if( abs( cy ) > lg ) if( abs( cy ) > lg )
continue; /* Le point est trop loin sur l'axe Y */ continue; /* The point is too far on the Y axis. */
/* ici le point a tester est proche du segment: la position /* This point a test is close to the segment: the position
* selon l'axe X doit etre testee */ * along the X axis must be tested.
if( (cx >= 0) && (cx <= dx) ) */
if( ( cx >= 0 ) && ( cx <= dx ) )
{ {
OP_CELL( layer, row, col ); OP_CELL( layer, row, col );
continue; continue;
} }
/* examen des extremites qui sont arrondies */ /* Examination of extremities are rounded. */
if( (cx < 0) && (cx >= -lg) ) if( ( cx < 0 ) && ( cx >= -lg ) )
{ {
if( ( (cx * cx) + (cy * cy) ) <= (lg * lg) ) if( ( ( cx * cx ) + ( cy * cy ) ) <= ( lg * lg ) )
OP_CELL( layer, row, col ); OP_CELL( layer, row, col );
continue; continue;
} }
if( (cx > dx) && ( cx <= (dx + lg) ) ) if( ( cx > dx ) && ( cx <= ( dx + lg ) ) )
{ {
if( ( ( (cx - dx) * (cx - dx) ) + (cy * cy) ) <= (lg * lg) ) if( ( ( ( cx - dx ) * ( cx - dx ) ) + ( cy * cy ) )
<= ( lg * lg ) )
OP_CELL( layer, row, col ); OP_CELL( layer, row, col );
continue; continue;
} }
...@@ -761,28 +849,28 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, ...@@ -761,28 +849,28 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
} }
} }
/*****************************************************************/
void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logique )
/*****************************************************************/
/* Remplit toutes les cellules du BOARD contenues dans le cercle /* Fills all cells BOARD contained in the circle
* de demi-largeur lg, centre ux,y0 passant par ux,y1 a la valeur color . * half-width lg center ux, ux through y0, y1 is set to color.
* coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->m_PcbBox.m_Xmin,Y du board. * coord in PCB units (0.1 million) relating to the origin
* pt_pcb-> m_PcbBox.m_Xmin, Y's board.
*/ */
void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logique )
{ {
int rayon, nb_segm; int rayon, nb_segm;
int x0, y0, // Point de depart du segment en cours de trace int x0, y0, // Starting point of the current segment trace.
x1, y1; // point d'arrivee x1, y1; // End point.
int ii; int ii;
int angle; int angle;
rayon = (int) hypot( (double) (ux1 - ux0), (double) (uy1 - uy0) ); rayon = (int) hypot( (double) (ux1 - ux0), (double) (uy1 - uy0) );
x0 = x1 = rayon; y0 = y1 = 0; x0 = x1 = rayon;
y0 = y1 = 0;
if( lg < 1 ) if( lg < 1 )
lg = 1; lg = 1;
nb_segm = (2 * rayon) / lg; nb_segm = ( 2 * rayon ) / lg;
if( nb_segm < 5 ) if( nb_segm < 5 )
nb_segm = 5; nb_segm = 5;
if( nb_segm > 100 ) if( nb_segm > 100 )
...@@ -790,42 +878,42 @@ void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, ...@@ -790,42 +878,42 @@ void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
for( ii = 1; ii < nb_segm; ii++ ) for( ii = 1; ii < nb_segm; ii++ )
{ {
angle = (3600 * ii) / nb_segm; angle = (3600 * ii) / nb_segm;
x1 = (int) (rayon * fcosinus[angle]); x1 = (int) ( rayon * fcosinus[angle] );
y1 = (int) (rayon * fsinus[angle]); y1 = (int) ( rayon * fsinus[angle] );
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logique ); DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg,
x0 = x1; y0 = y1; layer, color, op_logique );
x0 = x1;
y0 = y1;
} }
DrawSegmentQcq( x1 + ux0, y1 + uy0, ux0 + rayon, uy0, lg, layer, color, op_logique ); DrawSegmentQcq( x1 + ux0, y1 + uy0, ux0 + rayon, uy0, lg, layer,
color, op_logique );
} }
/****************************************************************************/ /* Fills all cells BOARD contained in the arc of "L" angle
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int layer, * half-width lg ux center, starting in ux y0, y1 is set to color.
int color, int op_logique ) * coord in PCB units (0.1 million) relating to the origin
/****************************************************************************/ * Pt_pcb->m_PcbBox.m_Xmin, Y's board.
/* Remplit toutes les cellules du BOARD contenues dans l'arc de "longueur" angle
* de demi-largeur lg, centre ux,y0 commencant en ux,y1 a la valeur color .
* coord en unites PCB (0.1 mil) relatives a l'origine
* pt_pcb->m_PcbBox.m_Xmin,Y du board.
*/ */
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg,
int layer, int color, int op_logique )
{ {
int rayon, nb_segm; int rayon, nb_segm;
int x0, y0, // Point de depart du segment en cours de trace int x0, y0, // Starting point of the current segment trace
x1, y1; // point d'arrivee x1, y1; // End point
int ii; int ii;
int angle, StAngle; int angle, StAngle;
rayon = (int) hypot( (double) (ux1 - ux0), (double) (uy1 - uy0) ); rayon = (int) hypot( (double) (ux1 - ux0), (double) (uy1 - uy0) );
x0 = ux1 - ux0; x0 = ux1 - ux0;
y0 = uy1 - uy0; y0 = uy1 - uy0;
StAngle = ArcTangente( uy1 - uy0, ux1 - ux0 ); StAngle = ArcTangente( uy1 - uy0, ux1 - ux0 );
if( lg < 1 ) if( lg < 1 )
lg = 1; lg = 1;
nb_segm = (2 * rayon) / lg; nb_segm = ( 2 * rayon ) / lg;
nb_segm = ( nb_segm * abs( ArcAngle ) ) / 3600; nb_segm = ( nb_segm * abs( ArcAngle ) ) / 3600;
if( nb_segm < 5 ) if( nb_segm < 5 )
nb_segm = 5; nb_segm = 5;
...@@ -834,7 +922,7 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int lay ...@@ -834,7 +922,7 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int lay
for( ii = 1; ii <= nb_segm; ii++ ) for( ii = 1; ii <= nb_segm; ii++ )
{ {
angle = (ArcAngle * ii) / nb_segm; angle = ( ArcAngle * ii ) / nb_segm;
angle += StAngle; angle += StAngle;
while( angle >= 3600 ) while( angle >= 3600 )
...@@ -843,11 +931,14 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int lay ...@@ -843,11 +931,14 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int lay
while( angle < 0 ) while( angle < 0 )
angle += 3600; angle += 3600;
x1 = (int) (rayon * fcosinus[angle]); x1 = (int) ( rayon * fcosinus[angle] );
y1 = (int) (rayon * fsinus[angle]); y1 = (int) ( rayon * fsinus[angle] );
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logique ); DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer,
x0 = x1; y0 = y1; color, op_logique );
x0 = x1;
y0 = y1;
} }
// DrawSegmentQcq(x1+ux0,y1+uy0, ux0+rayon, uy0,lg,layer, color, op_logique); // DrawSegmentQcq(x1+ux0,y1+uy0, ux0+rayon, uy0,lg,layer, color,
// op_logique);
} }
/****************************************************/
/********************************************************************/ /* Routines for reading and saving of structures in */
/* Routines de lecture et sauvegarde des structures en format ASCii */ /* ASCII file common to Pcbnew and CVPCB. */
/* Fichier common a PCBNEW et CVPCB */ /****************************************************/
/********************************************************************/
/* ioascii.cpp */
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -26,82 +23,79 @@ ...@@ -26,82 +23,79 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
/* ASCII format of structures:
*
* Structure PAD:
*
* $PAD
* Sh "name" form DIMVA dimH dV dH East: general form dV, dH = delta size
* Dr. diam dV dH: drill: diameter drilling offsets
* At Type S / N layers: standard, cms, conn, hole, meca.,
* Stack / Normal, 32-bit hexadecimal: occupation layers
* Nm net_code netname
* Po posrefX posrefy: reFX position, Y (0 = east position / anchor)
* $EndPAD
*
* Module Structure
*
* $MODULE namelib
* Po ax ay east layer masquelayer m_TimeCode
* ax ay ord = anchor (position module)
* east = east to 0.1 degree
* layer = layer number
* masquelayer = silkscreen layer for
* m_TimeCode internal use (groups)
* Li <namelib>
*
* Cd <text> description of the component (Component Doc)
* Kw <text> List of key words
*
* Sc schematic timestamp, reference schematic
*
* Op rot90 rot180 placement Options Auto (court rot 90, 180)
* rot90 is about 2x4-bit:
* lsb = cost rot 90, rot court msb = -90;
*
* Tn px py DIMVA dimh East thickness mirror visible "text"
* n = type (0 = ref, val = 1,> 1 = qcq
* Texts POS x, y / anchor and orient module 0
* DIMVA dimh East
* mirror thickness (Normal / Mirror)
* Visible V / I
* DS ox oy fx fy w
* Edge: coord segment ox, oy has fx, fy, on
* was the anchor and orient 0
* thickness w
* DC ox oy fx fy w descr circle (center, 1 point, thickness)
* $PAD
* $EndPAD section pads if available
* $Endmodule
*/
/* Format des structures de sauvegarde type ASCII :
Structure PAD:
$PAD
Sh "name" forme dimv dimH dV dH orient :forme generale dV, dH = delta dimensions
Dr diam, dV dH :drill : diametre offsets de percage
At type S/N layers : type standard,cms,conn,hole,meca.,
Stack/Normal,
Hexadecimal 32 bits: occupation des couches
Nm net_code netname
Po posrefX posrefy : position refX,Y (= position orient 0 / ancre)
$EndPAD
****** Structure module ***********
$MODULE namelib
Po ax ay orient layer masquelayer m_TimeCode
ax ay = coord ancre (position module)
orient = orient en 0.1 degre
layer = numero de couche
masquelayer = couche pour serigraphie
m_TimeCode a usage interne (groupements)
Li <namelib>
Cd <text> Description du composant (Composant Doc)
Kw <text> Liste des mots cle
Sc schematimestamp de reference schematique
Op rot90 rot180 Options de placement auto (cout rot 90, 180 )
rot90 est sur 2x4 bits:
lsb = cout rot 90, msb = cout rot -90;
Tn px py dimv dimh orient epaisseur miroir visible "texte"
n = type (0 = ref, 1 = val, > 1 =qcq
Textes POS x,y / ancre et orient module 0
dimv dimh orient
epaisseur miroir (Normal/miroir)
visible V/I
DS ox oy fx fy w
edge: segment coord ox,oy a fx,fy, relatives
a l'ancre et orient 0
epaisseur w
DC ox oy fx fy w descr cercle (centre, 1 point, epaisseur)
$PAD
$EndPAD section pads s'il y en a
$EndMODULE
*/
/* Local Variables */
int NbDraw, NbTrack, NbZone, NbMod, NbNets;
int NbDraw, NbTrack, NbZone, NbMod, NbNets;
/**********************************************************************/
int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
TRACK* insertBeforeMe, int StructType, int* LineNum, int NumSegm )
/**********************************************************************/
/** Read a list of segments (Tracks, zones) /** Read a list of segments (Tracks, zones)
* @return items count or - count if no end block ($End...) found. * @return items count or - count if no end block ($End...) found.
*/ */
int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
TRACK* insertBeforeMe,
int StructType,
int* LineNum,
int NumSegm )
{ {
int shape, width, drill, layer, type, flags, net_code; int shape, width, drill, layer, type, flags, net_code;
int ii = 0; int ii = 0;
char line1[256]; char line1[256];
char line2[256]; char line2[256];
TRACK* newTrack; TRACK* newTrack;
while( GetLine( File, line1, LineNum ) ) while( GetLine( File, line1, LineNum ) )
{ {
int makeType; int makeType;
unsigned long timeStamp; unsigned long timeStamp;
if( line1[0] == '$' ) if( line1[0] == '$' )
{ {
...@@ -111,7 +105,8 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, ...@@ -111,7 +105,8 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
// Read the 2nd line to determine the exact type, one of: // Read the 2nd line to determine the exact type, one of:
// TYPE_TRACK, TYPE_VIA, or TYPE_ZONE. The type field in 2nd line // TYPE_TRACK, TYPE_VIA, or TYPE_ZONE. The type field in 2nd line
// differentiates between TYPE_TRACK and TYPE_VIA. With virtual // differentiates between TYPE_TRACK and TYPE_VIA. With virtual
// functions in use, it is critical to instantiate the TYPE_VIA exactly. // functions in use, it is critical to instantiate the TYPE_VIA
// exactly.
if( GetLine( File, line2, LineNum ) == NULL ) if( GetLine( File, line2, LineNum ) == NULL )
break; break;
...@@ -142,7 +137,8 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, ...@@ -142,7 +137,8 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
case TYPE_ZONE: // this is now deprecated, but exits in old boards case TYPE_ZONE: // this is now deprecated, but exits in old boards
newTrack = new SEGZONE( GetBoard() ); newTrack = new SEGZONE( GetBoard() );
GetBoard()->m_Zone.Insert( (SEGZONE*)newTrack, (SEGZONE*)insertBeforeMe ); GetBoard()->m_Zone.Insert( (SEGZONE*) newTrack,
(SEGZONE*) insertBeforeMe );
break; break;
} }
...@@ -159,14 +155,15 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, ...@@ -159,14 +155,15 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
if( arg_count < 7 || drill <= 0 ) if( arg_count < 7 || drill <= 0 )
newTrack->SetDrillDefault(); newTrack->SetDrillDefault();
else else
newTrack->SetDrillValue(drill); newTrack->SetDrillValue( drill );
newTrack->SetLayer( layer ); newTrack->SetLayer( layer );
if ( makeType == TYPE_VIA ) if( makeType == TYPE_VIA ) // Ensure layers are OK when possible:
{ // Ensure layers are OK when possible: {
if( newTrack->Shape() == VIA_THROUGH ) if( newTrack->Shape() == VIA_THROUGH )
((SEGVIA*)newTrack)->SetLayerPair( LAYER_CMP_N, COPPER_LAYER_N ); ( (SEGVIA*) newTrack )->SetLayerPair( LAYER_CMP_N,
COPPER_LAYER_N );
} }
newTrack->SetNet( net_code ); newTrack->SetNet( net_code );
...@@ -178,11 +175,9 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, ...@@ -178,11 +175,9 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
} }
/**********************************************************************************/
int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum ) int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
/**********************************************************************************/
{ {
char Line[1024], * data; char Line[1024], * data;
while( GetLine( File, Line, LineNum ) != NULL ) while( GetLine( File, Line, LineNum ) != NULL )
{ {
...@@ -240,13 +235,14 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum ) ...@@ -240,13 +235,14 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
layer_count++; layer_count++;
Masque_Layer >>= 1; Masque_Layer >>= 1;
} }
GetBoard()->m_BoardSettings->SetCopperLayerCount( layer_count ); GetBoard()->m_BoardSettings->SetCopperLayerCount( layer_count );
continue; continue;
} }
if( stricmp( data, "LayerThickness" ) == 0 ) if( stricmp( data, "LayerThickness" ) == 0 )
{ {
data = strtok( NULL, " =\n\r" ); data = strtok( NULL, " =\n\r" );
GetBoard()->m_BoardSettings->m_LayerThickness = atoi( data );; GetBoard()->m_BoardSettings->m_LayerThickness = atoi( data );;
continue; continue;
} }
...@@ -272,13 +268,15 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum ) ...@@ -272,13 +268,15 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
data = strtok( NULL, " =\n\r" ); data = strtok( NULL, " =\n\r" );
GetBoard()->m_BoundaryBox.SetY( atoi( data ) ); GetBoard()->m_BoundaryBox.SetY( atoi( data ) );
data = strtok( NULL, " =\n\r" ); data = strtok( NULL, " =\n\r" );
GetBoard()->m_BoundaryBox.SetWidth( atoi( data ) - GetBoard()->m_BoundaryBox.GetX() ); GetBoard()->m_BoundaryBox.SetWidth(
atoi( data ) - GetBoard()->m_BoundaryBox.GetX() );
data = strtok( NULL, " =\n\r" ); data = strtok( NULL, " =\n\r" );
GetBoard()->m_BoundaryBox.SetHeight( atoi( data ) - GetBoard()->m_BoundaryBox.GetY() ); GetBoard()->m_BoundaryBox.SetHeight(
atoi( data ) - GetBoard()->m_BoundaryBox.GetY() );
continue; continue;
} }
/* Lecture du nombre de segments type DRAW , TRACT, ZONE */ /* Reading the number of segments of type DRAW, TRACK, ZONE */
if( stricmp( data, "Ndraw" ) == 0 ) if( stricmp( data, "Ndraw" ) == 0 )
{ {
data = strtok( NULL, " =\n\r" ); data = strtok( NULL, " =\n\r" );
...@@ -319,14 +317,12 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum ) ...@@ -319,14 +317,12 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
} }
/*************************************************************/
int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
/*************************************************************/
{ {
char Line[1024]; char Line[1024];
char* data; char* data;
NETCLASS * netclass_default = GetBoard()->m_NetClasses.GetDefault(); NETCLASS* netclass_default = GetBoard()->m_NetClasses.GetDefault();
while( GetLine( File, Line, LineNum ) != NULL ) while( GetLine( File, Line, LineNum ) != NULL )
{ {
...@@ -335,15 +331,21 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -335,15 +331,21 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "$EndSETUP" ) == 0 ) if( stricmp( Line, "$EndSETUP" ) == 0 )
{ {
// Until such time as the *.brd file does not have the global parameters: // Until such time as the *.brd file does not have the
// "TrackWidth", "TrackMinWidth", "ViaSize", "ViaDrill", "ViaMinSize", and "TrackClearence", // global parameters:
// put those same global values into the default NETCLASS until later board load // "TrackWidth", "TrackMinWidth", "ViaSize", "ViaDrill",
// code should override them. *.brd files which have been saved with knowledge of // "ViaMinSize", and "TrackClearence", put those same global
// NETCLASSes will override these defaults, old boards will not. // values into the default NETCLASS until later board load
// code should override them. *.brd files which have been
// saved with knowledge of NETCLASSes will override these
// defaults, old boards will not.
//
// @todo: I expect that at some point we can remove said global // @todo: I expect that at some point we can remove said global
// parameters from the *.brd file since the ones in the default // parameters from the *.brd file since the ones in the
// netclass serve the same purpose. If needed at all, the global defaults should go into // default netclass serve the same purpose. If needed
// a preferences file instead so they are there to start new board projects. // at all, the global defaults should go into a preferences
// file instead so they are there to start new board
// projects.
GetBoard()->m_NetClasses.GetDefault()->SetParams(); GetBoard()->m_NetClasses.GetDefault()->SetParams();
return 0; return 0;
...@@ -369,15 +371,15 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -369,15 +371,15 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
continue; continue;
} }
const int LAYERKEYZ = sizeof("Layer[")-1; const int LAYERKEYZ = sizeof("Layer[") - 1;
if( strncmp( Line, "Layer[", LAYERKEYZ ) == 0 ) if( strncmp( Line, "Layer[", LAYERKEYZ ) == 0 )
{ {
// parse: // parse:
// Layer[n] <a_Layer_name_with_no_spaces> <LAYER_T> // Layer[n] <a_Layer_name_with_no_spaces> <LAYER_T>
char* cp = Line + LAYERKEYZ; char* cp = Line + LAYERKEYZ;
int layer = atoi(cp); int layer = atoi( cp );
if( data ) if( data )
{ {
...@@ -460,7 +462,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -460,7 +462,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "ViaSizeList" ) == 0 ) if( stricmp( Line, "ViaSizeList" ) == 0 )
{ {
int tmp = atoi( data ); int tmp = atoi( data );
VIA_DIMENSION via_dim; VIA_DIMENSION via_dim;
via_dim.m_Diameter = tmp; via_dim.m_Diameter = tmp;
data = strtok( NULL, " \n\r" ); data = strtok( NULL, " \n\r" );
...@@ -576,22 +578,31 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -576,22 +578,31 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
/* Ensure tracks and vias sizes lists are ok: /* Ensure tracks and vias sizes lists are ok:
* Sort lists by by increasing value and remove duplicates * Sort lists by by increasing value and remove duplicates
* (the first value is not tested, because it is the netclass value * (the first value is not tested, because it is the netclass value
*/ */
sort( GetBoard()->m_ViasDimensionsList.begin()+1, GetBoard()->m_ViasDimensionsList.end() ); sort( GetBoard()->m_ViasDimensionsList.begin() + 1,
sort( GetBoard()->m_TrackWidthList.begin()+1, GetBoard()->m_TrackWidthList.end() ); GetBoard()->m_ViasDimensionsList.end() );
for( unsigned ii = 1; ii < GetBoard()->m_ViasDimensionsList.size()-1; ii++ ) sort( GetBoard()->m_TrackWidthList.begin() + 1,
GetBoard()->m_TrackWidthList.end() );
for( unsigned ii = 1;
ii < GetBoard()->m_ViasDimensionsList.size() - 1;
ii++ )
{ {
if( GetBoard()->m_ViasDimensionsList[ii] == GetBoard()->m_ViasDimensionsList[ii+1] ) if( GetBoard()->m_ViasDimensionsList[ii]
== GetBoard()->m_ViasDimensionsList[ii + 1] )
{ {
GetBoard()->m_ViasDimensionsList.erase(GetBoard()->m_ViasDimensionsList.begin()+ii); GetBoard()->m_ViasDimensionsList.erase(
GetBoard()->m_ViasDimensionsList.begin() + ii );
ii--; ii--;
} }
} }
for( unsigned ii = 1; ii < GetBoard()->m_TrackWidthList.size()-1; ii++ )
for( unsigned ii = 1; ii < GetBoard()->m_TrackWidthList.size() - 1; ii++ )
{ {
if( GetBoard()->m_TrackWidthList[ii] == GetBoard()->m_TrackWidthList[ii+1] ) if( GetBoard()->m_TrackWidthList[ii]
== GetBoard()->m_TrackWidthList[ii + 1] )
{ {
GetBoard()->m_TrackWidthList.erase(GetBoard()->m_TrackWidthList.begin()+ii); GetBoard()->m_TrackWidthList.erase(
GetBoard()->m_TrackWidthList.begin() + ii );
ii--; ii--;
} }
} }
...@@ -601,12 +612,10 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -601,12 +612,10 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
#ifdef PCBNEW #ifdef PCBNEW
/******************************************************************************/
static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard ) static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
/******************************************************************************/
{ {
NETCLASS * netclass_default = aFrame->GetBoard()->m_NetClasses.GetDefault(); NETCLASS* netclass_default = aFrame->GetBoard()->m_NetClasses.GetDefault();
char text[1024]; char text[1024];
fprintf( aFile, "$SETUP\n" ); fprintf( aFile, "$SETUP\n" );
sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT ); sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
...@@ -616,78 +625,105 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard ) ...@@ -616,78 +625,105 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() ); fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() );
unsigned layerMask = g_TabAllCopperLayerMask[aBoard->GetCopperLayerCount()-1]; unsigned layerMask =
g_TabAllCopperLayerMask[aBoard->GetCopperLayerCount() - 1];
for( int layer=0; layerMask; ++layer, layerMask>>=1 ) for( int layer = 0; layerMask; ++layer, layerMask >>= 1 )
{ {
if( layerMask & 1 ) if( layerMask & 1 )
{ {
fprintf( aFile, "Layer[%d] %s %s\n", layer, fprintf( aFile, "Layer[%d] %s %s\n", layer,
CONV_TO_UTF8( aBoard->GetLayerName(layer) ), CONV_TO_UTF8( aBoard->GetLayerName( layer ) ),
LAYER::ShowType( aBoard->GetLayerType( layer ) ) ); LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
} }
} }
// Save current default track width, for compatibility with older pcbnew version; // Save current default track width, for compatibility with older
// pcbnew version;
fprintf( aFile, "TrackWidth %d\n", aBoard->GetCurrentTrackWidth() ); fprintf( aFile, "TrackWidth %d\n", aBoard->GetCurrentTrackWidth() );
// Save custom tracks width list (the first is not saved here: this is the netclass value
// Save custom tracks width list (the first is not saved here: this is the
// netclass value
for( unsigned ii = 1; ii < aBoard->m_TrackWidthList.size(); ii++ ) for( unsigned ii = 1; ii < aBoard->m_TrackWidthList.size(); ii++ )
fprintf( aFile, "TrackWidthList %d\n", aBoard->m_TrackWidthList[ii] ); fprintf( aFile, "TrackWidthList %d\n", aBoard->m_TrackWidthList[ii] );
fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() ); fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() );
fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance ); fprintf( aFile,
fprintf( aFile, "TrackMinWidth %d\n" , g_DesignSettings.m_TrackMinWidth ); "ZoneClearence %d\n",
g_Zone_Default_Setting.m_ZoneClearance );
fprintf( aFile, "TrackMinWidth %d\n", g_DesignSettings.m_TrackMinWidth );
fprintf( aFile, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth ); fprintf( aFile, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth );
fprintf( aFile, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth ); fprintf( aFile, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth );
// Save current default via size, for compatibility with older pcbnew version;
// Save current default via size, for compatibility with older pcbnew
// version;
fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() ); fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() );
fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() ); fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() );
fprintf( aFile, "ViaMinSize %d\n", g_DesignSettings.m_ViasMinSize ); fprintf( aFile, "ViaMinSize %d\n", g_DesignSettings.m_ViasMinSize );
fprintf( aFile, "ViaMinDrill %d\n", g_DesignSettings.m_ViasMinDrill ); fprintf( aFile, "ViaMinDrill %d\n", g_DesignSettings.m_ViasMinDrill );
// Save custom vias diameters list (the first is not saved here: this is the netclass value // Save custom vias diameters list (the first is not saved here: this is
// the netclass value
for( unsigned ii = 1; ii < aBoard->m_ViasDimensionsList.size(); ii++ ) for( unsigned ii = 1; ii < aBoard->m_ViasDimensionsList.size(); ii++ )
fprintf( aFile, "ViaSizeList %d %d\n", fprintf( aFile, "ViaSizeList %d %d\n",
aBoard->m_ViasDimensionsList[ii].m_Diameter, aBoard->m_ViasDimensionsList[ii].m_Diameter,
aBoard->m_ViasDimensionsList[ii].m_Drill ); aBoard->m_ViasDimensionsList[ii].m_Drill );
// for old versions compatibility: // for old versions compatibility:
fprintf( aFile, "MicroViaSize %d\n", netclass_default->GetuViaDiameter() ); fprintf( aFile, "MicroViaSize %d\n", netclass_default->GetuViaDiameter() );
fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill()); fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill() );
fprintf( aFile, "MicroViasAllowed %d\n", g_DesignSettings.m_MicroViasAllowed); fprintf( aFile,
fprintf( aFile, "MicroViaMinSize %d\n" , g_DesignSettings.m_MicroViasMinSize ); "MicroViasAllowed %d\n",
fprintf( aFile, "MicroViaMinDrill %d\n", g_DesignSettings.m_MicroViasMinDrill ); g_DesignSettings.m_MicroViasAllowed );
fprintf( aFile,
"MicroViaMinSize %d\n",
g_DesignSettings.m_MicroViasMinSize );
fprintf( aFile,
"MicroViaMinDrill %d\n",
g_DesignSettings.m_MicroViasMinDrill );
fprintf( aFile, "TextPcbWidth %d\n", g_DesignSettings.m_PcbTextWidth ); fprintf( aFile, "TextPcbWidth %d\n", g_DesignSettings.m_PcbTextWidth );
fprintf( aFile, "TextPcbSize %d %d\n", fprintf( aFile,
g_DesignSettings.m_PcbTextSize.x, g_DesignSettings.m_PcbTextSize.y ); "TextPcbSize %d %d\n",
g_DesignSettings.m_PcbTextSize.x,
g_DesignSettings.m_PcbTextSize.y );
fprintf( aFile, "EdgeModWidth %d\n", ModuleSegmentWidth ); fprintf( aFile, "EdgeModWidth %d\n", ModuleSegmentWidth );
fprintf( aFile, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y ); fprintf( aFile, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y );
fprintf( aFile, "TextModWidth %d\n", ModuleTextWidth ); fprintf( aFile, "TextModWidth %d\n", ModuleTextWidth );
fprintf( aFile, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); fprintf( aFile,
"PadSize %d %d\n",
g_Pad_Master.m_Size.x,
g_Pad_Master.m_Size.y );
fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x );
fprintf( aFile, "Pad2MaskClearance %d\n", g_DesignSettings.m_SolderMaskMargin ); fprintf( aFile,
if( g_DesignSettings.m_SolderPasteMargin != 0) "Pad2MaskClearance %d\n",
fprintf( aFile, "Pad2PasteClearance %d\n", g_DesignSettings.m_SolderPasteMargin ); g_DesignSettings.m_SolderMaskMargin );
if( g_DesignSettings.m_SolderPasteMargin != 0 )
fprintf( aFile,
"Pad2PasteClearance %d\n",
g_DesignSettings.m_SolderPasteMargin );
if( g_DesignSettings.m_SolderPasteMarginRatio != 0 ) if( g_DesignSettings.m_SolderPasteMarginRatio != 0 )
fprintf( aFile, "Pad2PasteClearanceRatio %g\n", g_DesignSettings.m_SolderPasteMarginRatio ); fprintf( aFile,
"Pad2PasteClearanceRatio %g\n",
g_DesignSettings.m_SolderPasteMarginRatio );
fprintf( aFile, "AuxiliaryAxisOrg %d %d\n", fprintf( aFile,
aFrame->m_Auxiliary_Axis_Position.x, aFrame->m_Auxiliary_Axis_Position.y ); "AuxiliaryAxisOrg %d %d\n",
aFrame->m_Auxiliary_Axis_Position.x,
aFrame->m_Auxiliary_Axis_Position.y );
fprintf( aFile, "$EndSETUP\n\n" ); fprintf( aFile, "$EndSETUP\n\n" );
return 1; return 1;
} }
#endif #endif
/******************************************************/
bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
/******************************************************/
{ {
EDA_BaseStruct* PtStruct = GetBoard()->m_Modules; EDA_BaseStruct* PtStruct = GetBoard()->m_Modules;
int NbModules, NbDrawItem, NbLayers; int NbModules, NbDrawItem, NbLayers;
...@@ -697,8 +733,11 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) ...@@ -697,8 +733,11 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "$GENERAL\n" ); fprintf( File, "$GENERAL\n" );
fprintf( File, "LayerCount %d\n", NbLayers ); fprintf( File, "LayerCount %d\n", NbLayers );
// Write old format for Layer count (for compatibility with old versions of pcbnew // Write old format for Layer count (for compatibility with old versions of
fprintf( File, "Ly %8X\n", g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS ); // For compatibility with old version of pcbnew // pcbnew
fprintf( File,
"Ly %8X\n",
g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS );
fprintf( File, "EnabledLayers %08X\n", GetBoard()->GetEnabledLayers() ); fprintf( File, "EnabledLayers %08X\n", GetBoard()->GetEnabledLayers() );
fprintf( File, "VisibleLayers %08X\n", GetBoard()->GetVisibleLayers() ); fprintf( File, "VisibleLayers %08X\n", GetBoard()->GetVisibleLayers() );
fprintf( File, "VisibleElements %08X\n", GetBoard()->GetVisibleElements() ); fprintf( File, "VisibleElements %08X\n", GetBoard()->GetVisibleElements() );
...@@ -708,9 +747,10 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) ...@@ -708,9 +747,10 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
/* Write Bounding box info */ /* Write Bounding box info */
GetBoard()->ComputeBoundaryBox(); GetBoard()->ComputeBoundaryBox();
fprintf( File, "Di %d %d %d %d\n", fprintf( File, "Di %d %d %d %d\n",
GetBoard()->m_BoundaryBox.GetX(), GetBoard()->m_BoundaryBox.GetY(), GetBoard()->m_BoundaryBox.GetX(),
GetBoard()->m_BoundaryBox.GetRight(), GetBoard()->m_BoundaryBox.GetY(),
GetBoard()->m_BoundaryBox.GetBottom() ); GetBoard()->m_BoundaryBox.GetRight(),
GetBoard()->m_BoundaryBox.GetBottom() );
/* Write segment count for footprints, drawings, track and zones */ /* Write segment count for footprints, drawings, track and zones */
/* Calculate the footprint count */ /* Calculate the footprint count */
...@@ -724,7 +764,8 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) ...@@ -724,7 +764,8 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "Ndraw %d\n", NbDrawItem ); fprintf( File, "Ndraw %d\n", NbDrawItem );
fprintf( File, "Ntrack %d\n", GetBoard()->GetNumSegmTrack() ); fprintf( File, "Ntrack %d\n", GetBoard()->GetNumSegmTrack() );
fprintf( File, "Nzone %d\n", GetBoard()->GetNumSegmZone() ); fprintf( File, "Nzone %d\n", GetBoard()->GetNumSegmZone() );
fprintf( File, "LayerThickness %d\n", GetBoard()->m_BoardSettings->m_LayerThickness ); fprintf( File, "LayerThickness %d\n",
GetBoard()->m_BoardSettings->m_LayerThickness );
fprintf( File, "Nmodule %d\n", NbModules ); fprintf( File, "Nmodule %d\n", NbModules );
fprintf( File, "Nnets %d\n", GetBoard()->m_NetInfo->GetCount() ); fprintf( File, "Nnets %d\n", GetBoard()->m_NetInfo->GetCount() );
...@@ -734,14 +775,12 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) ...@@ -734,14 +775,12 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
} }
/******************************************************/
bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
/******************************************************/
/** Function WriteSheetDescr /** Function WriteSheetDescr
* Save the page information (size, texts, date ..) * Save the page information (size, texts, date ..)
* @param screen BASE_SCREEN to save * @param screen BASE_SCREEN to save
* @param File = an openen FILE to write info * @param File = an open FILE to write info
*/ */
bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
{ {
Ki_PageDescr* sheet = screen->m_CurrentSheetDesc; Ki_PageDescr* sheet = screen->m_CurrentSheetDesc;
...@@ -762,9 +801,7 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File ) ...@@ -762,9 +801,7 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
} }
/***************************************************************************/
static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum ) static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
/***************************************************************************/
{ {
char Line[1024], buf[1024], * text; char Line[1024], buf[1024], * text;
...@@ -861,25 +898,24 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum ) ...@@ -861,25 +898,24 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
} }
/********************************************************************/
int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
/********************************************************************/
/** ReadPcbFile /** ReadPcbFile
* Read a board file <file>.brd * Read a board file <file>.brd
* @param Append if 0: a previoulsy loaded board is deleted before loading the file. * @param Append if 0: a previously loaded board is deleted before loading
* else all items of the board file are added to the existing board * the file else all items of the board file are added to the
* existing board
*/ */
int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
{ {
char Line[1024]; char Line[1024];
int LineNum = 0; int LineNum = 0;
wxBusyCursor dummy; wxBusyCursor dummy;
// Switch the locale to standard C (needed to read floating point numbers like 1.3) // Switch the locale to standard C (needed to read floating point numbers
// like 1.3)
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
BOARD* board = GetBoard(); BOARD* board = GetBoard();
NbDraw = NbTrack = NbZone = NbMod = NbNets = -1; NbDraw = NbTrack = NbZone = NbMod = NbNets = -1;
...@@ -887,8 +923,9 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) ...@@ -887,8 +923,9 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
board->m_NetClasses.Clear(); board->m_NetClasses.Clear();
// Put a dollar sign in front, and test for a specific length of characters // Put a dollar sign in front, and test for a specific length of characters
// The -1 is to omit the trailing \0 which is included in sizeof() on a string. // The -1 is to omit the trailing \0 which is included in sizeof() on a
#define TESTLINE(x) (strncmp(Line, "$" x, sizeof("$" x)-1) == 0) // string.
#define TESTLINE( x ) (strncmp( Line, "$" x, sizeof("$" x) - 1 ) == 0)
while( GetLine( File, Line, &LineNum ) != NULL ) while( GetLine( File, Line, &LineNum ) != NULL )
{ {
...@@ -935,7 +972,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) ...@@ -935,7 +972,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
#ifdef PCBNEW #ifdef PCBNEW
TRACK* insertBeforeMe = Append ? NULL : board->m_Track.GetFirst(); TRACK* insertBeforeMe = Append ? NULL : board->m_Track.GetFirst();
ReadListeSegmentDescr( File, insertBeforeMe, TYPE_TRACK, ReadListeSegmentDescr( File, insertBeforeMe, TYPE_TRACK,
&LineNum, NbTrack ); &LineNum, NbTrack );
#endif #endif
continue; continue;
} }
...@@ -963,11 +1000,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) ...@@ -963,11 +1000,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
if( TESTLINE( "CZONE_OUTLINE" ) ) if( TESTLINE( "CZONE_OUTLINE" ) )
{ {
ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(board); ZONE_CONTAINER* zone_descr = new ZONE_CONTAINER( board );
zone_descr->ReadDescr( File, &LineNum ); zone_descr->ReadDescr( File, &LineNum );
if ( zone_descr->GetNumCorners( ) > 2 ) // should always occur if( zone_descr->GetNumCorners() > 2 ) // should always occur
board->Add(zone_descr); board->Add( zone_descr );
else delete zone_descr; else
delete zone_descr;
continue; continue;
} }
...@@ -993,7 +1031,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) ...@@ -993,7 +1031,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
SEGZONE* insertBeforeMe = Append ? NULL : board->m_Zone.GetFirst(); SEGZONE* insertBeforeMe = Append ? NULL : board->m_Zone.GetFirst();
ReadListeSegmentDescr( File, insertBeforeMe, TYPE_ZONE, ReadListeSegmentDescr( File, insertBeforeMe, TYPE_ZONE,
&LineNum, NbZone ); &LineNum, NbZone );
#endif #endif
continue; continue;
} }
...@@ -1029,13 +1067,14 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) ...@@ -1029,13 +1067,14 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
break; break;
} }
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
// Build the net info list // Build the net info list
GetBoard()->m_NetInfo->BuildListOfNets(); GetBoard()->m_NetInfo->BuildListOfNets();
board->SynchronizeNetsAndNetClasses( ); board->SynchronizeNetsAndNetClasses();
m_TrackAndViasSizesList_Changed = true; m_TrackAndViasSizesList_Changed = true;
Affiche_Message( wxEmptyString ); Affiche_Message( wxEmptyString );
...@@ -1046,35 +1085,37 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) ...@@ -1046,35 +1085,37 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
#ifdef PCBNEW #ifdef PCBNEW
/***************************************************/
int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
/****************************************************/
/* Routine de sauvegarde du PCB courant sous format ASCII /* Save the current PCB in ASCII format
* retourne * Returns
* 1 si OK * 1 if OK
* 0 si sauvegarde non faite * 0 if error occurs saving file.
*/ */
int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
{ {
bool rc; bool rc;
char line[256]; char line[256];
GetBoard()->m_Status_Pcb &= ~CONNEXION_OK; GetBoard()->m_Status_Pcb &= ~CONNEXION_OK;
wxBeginBusyCursor(); wxBeginBusyCursor();
// 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();
/* Ecriture de l'entete PCB : */ /* Writing file header. */
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB, fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
DateAndTime( line ) ); DateAndTime( line ) );
fprintf( aFile, "# Created by Pcbnew%s\n\n", CONV_TO_UTF8( GetBuildVersion() ) ); fprintf( aFile, "# Created by Pcbnew%s\n\n",
CONV_TO_UTF8( GetBuildVersion() ) );
GetBoard()->SynchronizeNetsAndNetClasses(); GetBoard()->SynchronizeNetsAndNetClasses();
// Select default Netclass before writing file. // Select default Netclass before writing file.
// Useful to save default values in headers // Useful to save default values in headers
GetBoard()->SetCurrentNetClass( GetBoard()->m_NetClasses.GetDefault()->GetName( )); GetBoard()->SetCurrentNetClass(
GetBoard()->m_NetClasses.GetDefault()->GetName() );
m_TrackAndViasSizesList_Changed = true; m_TrackAndViasSizesList_Changed = true;
AuxiliaryToolBar_Update_UI(); AuxiliaryToolBar_Update_UI();
...@@ -1084,7 +1125,7 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile ) ...@@ -1084,7 +1125,7 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
rc = GetBoard()->Save( aFile ); rc = GetBoard()->Save( aFile );
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
wxEndBusyCursor(); wxEndBusyCursor();
if( !rc ) if( !rc )
...@@ -1095,4 +1136,5 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile ) ...@@ -1095,4 +1136,5 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
return rc; return rc;
} }
#endif #endif
/***************************************/ /****************************************/
/* Gestion de la LIBRAIRIE des MODULES */ /* Manage module (footprint) libraries. */
/***************************************/ /****************************************/
/* Fichier LIBRAIRI.CPP */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -16,41 +14,38 @@ ...@@ -16,41 +14,38 @@
#include "protos.h" #include "protos.h"
/* /*
* Format de l'entete de la Librairie: * Module library header format:
* chaine ENTETE-LIBRAIRIE date-heure * Array LIBRARY HEADER-datetime
* $INDEX * $INDEX
* liste des noms modules ( 1 nom par ligne) * List of modules names (1 name per line)
* $EndINDEX * $EndIndex
* liste des descriptions des Modules * List of descriptions of Modules
* $EndLIBRARY * $EndLIBRARY
*/ */
#define BACKUP_EXT wxT( "bak" )
#define BACKUP_EXT wxT( "bak" )
#define FILETMP_EXT wxT( "$$$" ) #define FILETMP_EXT wxT( "$$$" )
#define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" ) #define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" )
const wxString ModExportFileExtension( wxT( "emp" ) ); const wxString ModExportFileExtension( wxT( "emp" ) );
static const wxString ModExportFileWildcard( _( "Kicad foot print export files (*.emp)|*.emp" ) ); static const wxString ModExportFileWildcard(
_( "Kicad foot print export files (*.emp)|*.emp" ) );
/* Fonctions locales */
static bool CreateDocLibrary( const wxString& LibName ); static bool CreateDocLibrary( const wxString& LibName );
/*********************************************************/
MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
/*********************************************************/
/** /**
* Function Import_Module * Function Import_Module
* Read a file containing only one footprint. * Read a file containing only one footprint.
* Used to import (after exporting) a footprint * Used to import (after exporting) a footprint
* Exported files have the standart ext .emp * Exported files have the standard ext .emp
* This is the same format as .mod files but restricted to only one footprint * This is the same format as .mod files but restricted to only one footprint
* The import function can also read gpcb footprint file, in Newlib format * The import function can also read gpcb footprint file, in Newlib format
* (One footprint per file, Newlib files have no special ext.) * (One footprint per file, Newlib files have no special ext.)
* @param DC = Current Device Context (can be NULL) * @param DC = Current Device Context (can be NULL)
*/ */
MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
{ {
int NbLine = 0; int NbLine = 0;
char Line[1024]; char Line[1024];
...@@ -64,7 +59,6 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) ...@@ -64,7 +59,6 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
if( Config ) if( Config )
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading ); Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading );
/* Lecture Fichier module */
wxFileDialog dlg( this, _( "Import Footprint Module" ), wxFileDialog dlg( this, _( "Import Footprint Module" ),
LastOpenedPathForLoading, wxEmptyString, LastOpenedPathForLoading, wxEmptyString,
ModExportFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); ModExportFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
...@@ -88,8 +82,9 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) ...@@ -88,8 +82,9 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading ); Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading );
} }
// 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();
/* Read header and test file type */ /* Read header and test file type */
GetLine( file, Line, &NbLine ); GetLine( file, Line, &NbLine );
...@@ -127,7 +122,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) ...@@ -127,7 +122,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
module->ReadDescr( file, &NbLine ); module->ReadDescr( file, &NbLine );
fclose( file ); fclose( file );
} }
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
/* Insert footprint in list*/ /* Insert footprint in list*/
GetBoard()->Add( module ); GetBoard()->Add( module );
...@@ -142,21 +137,20 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) ...@@ -142,21 +137,20 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
} }
/************************************************************************/
void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
/************************************************************************/
/** /**
* Function Export_Module * Function Export_Module
* Create a file containing only one footprint. * Create a file containing only one footprint.
* Used to export a footprint * Used to export a footprint
* Exported files have the standart ext .emp * Exported files have the standard ext .emp
* This is the same format as .mod files but restricted to only one footprint * This is the same format as .mod files but restricted to only one footprint
* So Create a new lib (which will contains one module) and export a footprint is basically the same thing * So Create a new lib (which will contains one module) and export a footprint
* is basically the same thing
* @param DC = Current Device Context (can be NULL) * @param DC = Current Device Context (can be NULL)
* @param createlib : true = use default lib path to create lib * @param createlib : true = use default lib path to create lib
* false = use current path or last used path to export footprint * false = use current path or last used path to export
* footprint
*/ */
void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
{ {
wxFileName fn; wxFileName fn;
char Line[1025]; char Line[1025];
...@@ -177,8 +171,8 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) ...@@ -177,8 +171,8 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path ); Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path );
fn.SetPath( path ); fn.SetPath( path );
title = createlib ? _( "Create New Library" ) : _( "Export Module" ); title = createlib ? _( "Create New Library" ) : _( "Export Module" );
wildcard = createlib ? ModuleFileWildcard : ModExportFileWildcard; wildcard = createlib ? ModuleFileWildcard : ModExportFileWildcard;
wxFileDialog dlg( this, msg, fn.GetPath(), fn.GetFullName(), wildcard, wxFileDialog dlg( this, msg, fn.GetPath(), fn.GetFullName(), wildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
...@@ -188,7 +182,6 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) ...@@ -188,7 +182,6 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
fn = dlg.GetPath(); fn = dlg.GetPath();
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* Generation du fichier Empreinte */
if( ( file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL ) if( ( file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL )
{ {
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) ); msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
...@@ -201,7 +194,8 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) ...@@ -201,7 +194,8 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() ); Config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() );
} }
// Switch the locale to standard C (needed to read floating point numbers like 1.3) // Switch the locale to standard C (needed to read floating point numbers
// like 1.3)
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
fprintf( file, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( Line ) ); fprintf( file, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( Line ) );
...@@ -214,17 +208,16 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) ...@@ -214,17 +208,16 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
fputs( "$EndLIBRARY\n", file ); fputs( "$EndLIBRARY\n", file );
fclose( file ); fclose( file );
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
msg.Printf( _( "Module exported in file <%s>" ), GetChars( fn.GetFullPath() ) ); msg.Printf( _( "Module exported in file <%s>" ),
GetChars( fn.GetFullPath() ) );
DisplayInfoMessage( this, msg ); DisplayInfoMessage( this, msg );
} }
/**********************************************************/ void WinEDA_ModuleEditFrame::Delete_Module_In_Library(
void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const const wxString& aLibname )
wxString& aLibname )
/**********************************************************/
{ {
wxFileName newFileName; wxFileName newFileName;
wxFileName oldFileName; wxFileName oldFileName;
...@@ -233,8 +226,10 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -233,8 +226,10 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
FILE* dest, * lib_module; FILE* dest, * lib_module;
wxString CmpName, msg; wxString CmpName, msg;
/* Demande du nom du composant a supprimer */ CmpName = Select_1_Module_From_List( this,
CmpName = Select_1_Module_From_List( this, aLibname, wxEmptyString, wxEmptyString ); aLibname,
wxEmptyString,
wxEmptyString );
if( CmpName == wxEmptyString ) if( CmpName == wxEmptyString )
return; return;
...@@ -247,7 +242,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -247,7 +242,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
oldFileName = aLibname; oldFileName = aLibname;
if( ( lib_module = wxFopen( oldFileName.GetFullPath(), if( ( lib_module = wxFopen( oldFileName.GetFullPath(),
wxT( "rt" ) ) ) == NULL ) wxT( "rt" ) ) ) == NULL )
{ {
wxString msg; wxString msg;
msg = _( "Library " ) + oldFileName.GetFullPath() + _( " not found" ); msg = _( "Library " ) + oldFileName.GetFullPath() + _( " not found" );
...@@ -256,7 +251,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -256,7 +251,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
} }
/* lecture entete */ /* Read header. */
GetLine( lib_module, Line, &LineNum ); GetLine( lib_module, Line, &LineNum );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
...@@ -266,7 +261,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -266,7 +261,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
return; return;
} }
/* lecture des nom des composants */ /* Read module names. */
while( GetLine( lib_module, Line, &LineNum ) ) while( GetLine( lib_module, Line, &LineNum ) )
{ {
if( strnicmp( Line, "$INDEX", 6 ) == 0 ) if( strnicmp( Line, "$INDEX", 6 ) == 0 )
...@@ -275,7 +270,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -275,7 +270,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
{ {
StrPurge( Line ); StrPurge( Line );
msg = CONV_FROM_UTF8( Line ); msg = CONV_FROM_UTF8( Line );
if( CmpName.CmpNoCase( msg ) == 0 ) /* composant trouve */ if( CmpName.CmpNoCase( msg ) == 0 ) /* New module? */
{ {
NoFound = 0; break; NoFound = 0; break;
} }
...@@ -295,7 +290,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -295,7 +290,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
return; return;
} }
/* Creation de la nouvelle librairie */ /* Create new library. */
newFileName = oldFileName; newFileName = oldFileName;
newFileName.SetExt( FILETMP_EXT ); newFileName.SetExt( FILETMP_EXT );
...@@ -310,7 +305,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -310,7 +305,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxBeginBusyCursor(); wxBeginBusyCursor();
/* Creation de l'entete avec nouvelle date */ /* Create header with new date. */
fprintf( dest, ENTETE_LIBRAIRIE ); fprintf( dest, ENTETE_LIBRAIRIE );
fprintf( dest, " %s\n$INDEX\n", DateAndTime( Line ) ); fprintf( dest, " %s\n$INDEX\n", DateAndTime( Line ) );
...@@ -339,7 +334,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -339,7 +334,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
fprintf( dest, "$EndINDEX\n" ); fprintf( dest, "$EndINDEX\n" );
/* Copie des modules */ /* Copy modules. */
while( GetLine( lib_module, Line, &LineNum ) ) while( GetLine( lib_module, Line, &LineNum ) )
{ {
StrPurge( Line ); StrPurge( Line );
...@@ -349,7 +344,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -349,7 +344,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
msg = CONV_FROM_UTF8( Name ); msg = CONV_FROM_UTF8( Name );
if( msg.CmpNoCase( CmpName ) == 0 ) if( msg.CmpNoCase( CmpName ) == 0 )
{ {
/* suppression ancien module */ /* Delete old module. */
while( GetLine( lib_module, Line, &LineNum ) ) while( GetLine( lib_module, Line, &LineNum ) )
{ {
if( strnicmp( Line, "$EndMODULE", 9 ) == 0 ) if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
...@@ -367,7 +362,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -367,7 +362,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxEndBusyCursor(); wxEndBusyCursor();
/* Le fichier ancienne librairie est renommee en .bak */ /* The old library file is renamed .bak */
wxFileName backupFileName = oldFileName; wxFileName backupFileName = oldFileName;
backupFileName.SetExt( BACKUP_EXT ); backupFileName.SetExt( BACKUP_EXT );
...@@ -375,13 +370,13 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -375,13 +370,13 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxRemoveFile( backupFileName.GetFullPath() ); wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( oldFileName.GetFullPath(), if( !wxRenameFile( oldFileName.GetFullPath(),
backupFileName.GetFullPath() ) ) backupFileName.GetFullPath() ) )
{ {
DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) ); DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) );
return; return;
} }
/* Le fichier temporaire est renommee comme l'ancienne Lib */ /* The temporary file is renamed as the previous library. */
if( !wxRenameFile( newFileName.GetFullPath(), oldFileName.GetFullPath() ) ) if( !wxRenameFile( newFileName.GetFullPath(), oldFileName.GetFullPath() ) )
{ {
DisplayError( this, wxT( "Librairi.cpp: rename err 2" ) ); DisplayError( this, wxT( "Librairi.cpp: rename err 2" ) );
...@@ -389,24 +384,20 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -389,24 +384,20 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
} }
msg.Printf( _( "Component %s deleted in library %s" ), GetChars( CmpName ), msg.Printf( _( "Component %s deleted in library %s" ), GetChars( CmpName ),
GetChars( oldFileName.GetFullPath() ) ); GetChars( oldFileName.GetFullPath() ) );
Affiche_Message( msg ); Affiche_Message( msg );
CreateDocLibrary( oldFileName.GetFullPath() ); CreateDocLibrary( oldFileName.GetFullPath() );
} }
/***********************************************************************/
void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
bool NewModulesOnly )
/***********************************************************************/
/* /*
* Sauve en Librairie: * Save library:
* tous les nouveaux modules ( c.a.d. les modules * All new modules (ie modules not already exist (if NewModulesOnly == true)
* n'existant pas deja (si NewModulesOnly == true) * all modules (if NewModulesOnly == FALSE)
* tous les modules (si NewModulesOnly == FALSE)
*/ */
void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
bool NewModulesOnly )
{ {
int ii, NbModules = 0; int ii, NbModules = 0;
float Pas; float Pas;
...@@ -432,14 +423,15 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, ...@@ -432,14 +423,15 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
fileName = dlg.GetPath(); fileName = dlg.GetPath();
} }
wxFileName fn(fileName); wxFileName fn( fileName );
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
bool file_exists = wxFileExists( fileName ); bool file_exists = wxFileExists( fileName );
if( !NewModulesOnly && file_exists ) if( !NewModulesOnly && file_exists )
{ {
wxString msg; wxString msg;
msg.Printf( _( "File %s exists, OK to replace ?" ), GetChars( fileName ) ); msg.Printf( _( "File %s exists, OK to replace ?" ),
GetChars( fileName ) );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
} }
...@@ -464,7 +456,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, ...@@ -464,7 +456,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
fclose( lib_module ); fclose( lib_module );
} }
/* Calcul du nombre de modules */ /* Calculate the number of modules. */
Module = (MODULE*) GetBoard()->m_Modules; Module = (MODULE*) GetBoard()->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() ) for( ; Module != NULL; Module = (MODULE*) Module->Next() )
NbModules++; NbModules++;
...@@ -476,10 +468,11 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, ...@@ -476,10 +468,11 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() ) for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() )
{ {
if( Save_Module_In_Library( fileName, Module, if( Save_Module_In_Library( fileName, Module,
NewModulesOnly ? FALSE : true, FALSE, false ) == 0 ) NewModulesOnly ? FALSE : true,
FALSE, false ) == 0 )
break; break;
DisplayActivity( (int) ( ii * Pas ), wxEmptyString ); DisplayActivity( (int) ( ii * Pas ), wxEmptyString );
/* Tst demande d'arret de sauvegarde ( key ESCAPE actionnee ) */ /* Check for request to stop backup (ESCAPE key actuated) */
if( DrawPanel->m_AbortRequest ) if( DrawPanel->m_AbortRequest )
break; break;
} }
...@@ -488,21 +481,22 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, ...@@ -488,21 +481,22 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
} }
/*****************************************************************/
int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
MODULE* aModule, bool aOverwrite,
bool aDisplayDialog, bool aCreateDocFile )
/*****************************************************************/
/** Function Save_Module_In_Library /** Function Save_Module_In_Library
* Save in an existing library a given footprint * Save in an existing library a given footprint
* @param aLibName = name of the library to use * @param aLibName = name of the library to use
* @param aModule = the given footprint * @param aModule = the given footprint
* @param aOverwrite = true to overwrite an existing footprint, false to abort an existing footprint is found * @param aOverwrite = true to overwrite an existing footprint, false to abort
* @param aDisplayDialog = true to display a dialog to enter or confirm the footprint name * an existing footprint is found
* @param aDisplayDialog = true to display a dialog to enter or confirm the
* footprint name
* @param aCreateDocFile = true to creates the associated doc file * @param aCreateDocFile = true to creates the associated doc file
* @return : 1 if OK, 0 if abort * @return : 1 if OK, 0 if abort
*/ */
int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
MODULE* aModule,
bool aOverwrite,
bool aDisplayDialog,
bool aCreateDocFile )
{ {
wxFileName oldFileName; wxFileName oldFileName;
wxFileName newFileName; wxFileName newFileName;
...@@ -523,7 +517,6 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -523,7 +517,6 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
return 0; return 0;
} }
/* Ask for the footprint name in lib */ /* Ask for the footprint name in lib */
Name_Cmp = aModule->m_LibRef; Name_Cmp = aModule->m_LibRef;
...@@ -544,17 +537,18 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -544,17 +537,18 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
return 0; return 0;
} }
/* lRead library file : library header */ /* Read library file : library header */
GetLine( lib_module, Line, &LineNum ); GetLine( lib_module, Line, &LineNum );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{ {
fclose( lib_module ); fclose( lib_module );
msg.Printf( _( "File %s is not a eeschema library" ), GetChars( aLibName ) ); msg.Printf( _( "File %s is not a eeschema library" ),
GetChars( aLibName ) );
DisplayError( this, msg ); DisplayError( this, msg );
return 0; return 0;
} }
/* Reaf footprints in lib: - search for an existing footprint */ /* Read footprints in lib: - search for an existing footprint */
newmodule = 1; end = 0; newmodule = 1; end = 0;
while( !end && GetLine( lib_module, Line, &LineNum ) ) while( !end && GetLine( lib_module, Line, &LineNum ) )
{ {
...@@ -572,7 +566,8 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -572,7 +566,8 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
StrPurge( Line ); StrPurge( Line );
msg = CONV_FROM_UTF8( Line ); msg = CONV_FROM_UTF8( Line );
if( Name_Cmp.CmpNoCase( msg ) == 0 ) /* an existing footprint is found */ if( Name_Cmp.CmpNoCase( msg ) == 0 ) /* an existing footprint is
* found */
{ {
added = FALSE; added = FALSE;
newmodule = 0; newmodule = 0;
...@@ -582,7 +577,8 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -582,7 +577,8 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
msg << LineNum; msg << LineNum;
Affiche_Message( msg ); Affiche_Message( msg );
} }
if( !aOverwrite ) /* lDo not save the given footprint: an old one exists */ if( !aOverwrite ) /* Do not save the given footprint: an old
* one exists */
{ {
fclose( lib_module ); return 1; fclose( lib_module ); return 1;
} }
...@@ -614,8 +610,9 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -614,8 +610,9 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
wxBeginBusyCursor(); wxBeginBusyCursor();
// 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();
/* Create the library header with a new date */ /* Create the library header with a new date */
fprintf( dest, ENTETE_LIBRAIRIE ); fprintf( dest, ENTETE_LIBRAIRIE );
...@@ -657,7 +654,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -657,7 +654,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
msg = CONV_FROM_UTF8( Name ); msg = CONV_FROM_UTF8( Name );
if( msg.CmpNoCase( Name_Cmp ) == 0 ) if( msg.CmpNoCase( Name_Cmp ) == 0 )
{ {
/* skip old footprint descr (delete from the lib)*/ /* skip old footprint descr (delete from the lib) */
while( GetLine( lib_module, Line, &LineNum ) ) while( GetLine( lib_module, Line, &LineNum ) )
{ {
if( strnicmp( Line, "$EndMODULE", 9 ) == 0 ) if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
...@@ -677,7 +674,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -677,7 +674,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
aModule->m_TimeStamp = tmp; aModule->m_TimeStamp = tmp;
fclose( dest ); fclose( lib_module ); fclose( dest ); fclose( lib_module );
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
wxEndBusyCursor(); wxEndBusyCursor();
...@@ -699,7 +696,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -699,7 +696,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
} }
/* creates the new .dcm doc file corresponding to the new library */ /* creates the new .dcm doc file corresponding to the new library */
if ( aCreateDocFile ) if( aCreateDocFile )
CreateDocLibrary( aLibName ); CreateDocLibrary( aLibName );
if( aDisplayDialog ) if( aDisplayDialog )
...@@ -714,25 +711,23 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -714,25 +711,23 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
} }
/************************************************************************************/
MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_name )
/************************************************************************************/
/* Create a new module or footprint : A new module contains 2 texts : /* Create a new module or footprint : A new module contains 2 texts :
* First = REFERENCE * First = REFERENCE
* Second = VALUE: "VAL**" * Second = VALUE: "VAL**"
* the new module is added on begining of the linked list of modules * the new module is added on beginning of the linked list of modules
*/ */
MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC,
const wxString& module_name )
{ {
MODULE* Module; MODULE* Module;
wxString Line; wxString Line;
wxPoint newpos; wxPoint newpos;
/* Ask fo the new module reference */ /* Ask for the new module reference */
if( module_name.IsEmpty() ) if( module_name.IsEmpty() )
{ {
if( Get_Message( _( "Module Reference:" ), _( "Module Creation" ), Line, this ) != 0 ) if( Get_Message( _( "Module Reference:" ),
_( "Module Creation" ), Line, this ) != 0 )
{ {
DisplayInfoMessage( this, _( "No reference, aborted" ) ); DisplayInfoMessage( this, _( "No reference, aborted" ) );
return NULL; return NULL;
...@@ -743,7 +738,8 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n ...@@ -743,7 +738,8 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
Line.Trim( true ); Line.Trim( true );
Line.Trim( FALSE ); Line.Trim( FALSE );
// Creates the new module and add it to the head of the linked list of modules // Creates the new module and add it to the head of the linked list of
// modules
Module = new MODULE( GetBoard() ); Module = new MODULE( GetBoard() );
GetBoard()->Add( Module ); GetBoard()->Add( Module );
...@@ -773,9 +769,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n ...@@ -773,9 +769,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
} }
/*******************************************************/
void WinEDA_ModuleEditFrame::Select_Active_Library() void WinEDA_ModuleEditFrame::Select_Active_Library()
/*******************************************************/
{ {
if( g_LibName_List.GetCount() == 0 ) if( g_LibName_List.GetCount() == 0 )
return; return;
...@@ -797,9 +791,7 @@ void WinEDA_ModuleEditFrame::Select_Active_Library() ...@@ -797,9 +791,7 @@ void WinEDA_ModuleEditFrame::Select_Active_Library()
} }
/**********************************************************************/
int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName ) int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
/**********************************************************************/
{ {
FILE* lib_module; FILE* lib_module;
wxString msg; wxString msg;
...@@ -819,7 +811,7 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName ) ...@@ -819,7 +811,7 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
return -1; return -1;
} }
/* Ecriture de l'entete de la nouvelle librairie */ /* Write the header of the new library. */
if( fprintf( lib_module, ENTETE_LIBRAIRIE ) == 0 ) if( fprintf( lib_module, ENTETE_LIBRAIRIE ) == 0 )
{ {
msg = _( "Create error " ) + LibName; msg = _( "Create error " ) + LibName;
...@@ -836,16 +828,13 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName ) ...@@ -836,16 +828,13 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
} }
/******************************************************/ /* Synch. Dcm combines a library Libname
static bool CreateDocLibrary( const wxString& LibName ) * (Full file name)
/*****************************************************/
/* Creation du fichier .dcm associe a la librairie LibName
* (full file name)
*/ */
static bool CreateDocLibrary( const wxString& LibName )
{ {
char Line[1024]; char Line[1024];
char cbuf[256]; char cbuf[256];
wxString Name, Doc, KeyWord; wxString Name, Doc, KeyWord;
wxFileName fn; wxFileName fn;
FILE* LibMod, * LibDoc; FILE* LibMod, * LibDoc;
...@@ -857,7 +846,7 @@ static bool CreateDocLibrary( const wxString& LibName ) ...@@ -857,7 +846,7 @@ static bool CreateDocLibrary( const wxString& LibName )
if( LibMod == NULL ) if( LibMod == NULL )
return FALSE; return FALSE;
/* lecture entete librairie*/ /* Read library header. */
GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ); GetLine( LibMod, Line, NULL, sizeof(Line) - 1 );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{ {
...@@ -874,7 +863,7 @@ static bool CreateDocLibrary( const wxString& LibName ) ...@@ -874,7 +863,7 @@ static bool CreateDocLibrary( const wxString& LibName )
fprintf( LibDoc, ENTETE_LIBDOC ); fprintf( LibDoc, ENTETE_LIBDOC );
fprintf( LibDoc, " %s\n", DateAndTime( cbuf ) ); fprintf( LibDoc, " %s\n", DateAndTime( cbuf ) );
/* Lecture de la librairie */ /* Read library. */
Name = Doc = KeyWord = wxEmptyString; Name = Doc = KeyWord = wxEmptyString;
while( GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ) ) while( GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ) )
{ {
...@@ -907,7 +896,9 @@ static bool CreateDocLibrary( const wxString& LibName ) ...@@ -907,7 +896,9 @@ static bool CreateDocLibrary( const wxString& LibName )
Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) ); Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
} }
if( (Name != wxEmptyString) && ( (Doc != wxEmptyString) || (KeyWord != wxEmptyString) ) ) /* Generation de la doc du composant */ /* Generate the module the documentation. */
if( ( Name != wxEmptyString )
&& ( ( Doc != wxEmptyString ) || ( KeyWord != wxEmptyString ) ) )
{ {
fprintf( LibDoc, "#\n$MODULE %s\n", CONV_TO_UTF8( Name ) ); fprintf( LibDoc, "#\n$MODULE %s\n", CONV_TO_UTF8( Name ) );
fprintf( LibDoc, "Li %s\n", CONV_TO_UTF8( Name ) ); fprintf( LibDoc, "Li %s\n", CONV_TO_UTF8( Name ) );
...@@ -920,7 +911,7 @@ static bool CreateDocLibrary( const wxString& LibName ) ...@@ -920,7 +911,7 @@ static bool CreateDocLibrary( const wxString& LibName )
fprintf( LibDoc, "$EndMODULE\n" ); fprintf( LibDoc, "$EndMODULE\n" );
} }
Name = Doc = KeyWord = wxEmptyString; Name = Doc = KeyWord = wxEmptyString;
} /* Fin lecture desc 1 module */ } /* End read 1 module */
if( strnicmp( Line, "$INDEX", 6 ) == 0 ) if( strnicmp( Line, "$INDEX", 6 ) == 0 )
{ {
...@@ -930,12 +921,10 @@ static bool CreateDocLibrary( const wxString& LibName ) ...@@ -930,12 +921,10 @@ static bool CreateDocLibrary( const wxString& LibName )
break; break;
} }
/* Fin Lecture INDEX */ /* End read INDEX */
} }
} }
/* Fin lecture 1 Librairie */
fclose( LibMod ); fclose( LibMod );
fprintf( LibDoc, "#\n$EndLIBDOC\n" ); fprintf( LibDoc, "#\n$EndLIBDOC\n" );
fclose( LibDoc ); fclose( LibDoc );
......
...@@ -23,8 +23,7 @@ public: ...@@ -23,8 +23,7 @@ public:
ModList* Next; ModList* Next;
wxString m_Name, m_Doc, m_KeyWord; wxString m_Name, m_Doc, m_KeyWord;
public: public: ModList()
ModList()
{ {
Next = NULL; Next = NULL;
} }
...@@ -35,26 +34,23 @@ public: ...@@ -35,26 +34,23 @@ public:
} }
}; };
/* Fonctions locales */
static void DisplayCmpDoc( wxString& Name ); static void DisplayCmpDoc( wxString& Name );
static void ReadDocLib( const wxString& ModLibName ); static void ReadDocLib( const wxString& ModLibName );
/*****/
/* variables locales */
static ModList* MList; static ModList* MList;
/********************************************************************/
void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module ) void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
/********************************************************************/
{ {
MODULE* NewModule; MODULE* NewModule;
WinEDA_BasePcbFrame* parent = (WinEDA_BasePcbFrame*) GetParent(); WinEDA_BasePcbFrame* parent = (WinEDA_BasePcbFrame*) GetParent();
if( Module == NULL ) if( Module == NULL )
{ {
if( parent->GetBoard() == NULL || parent->GetBoard()->m_Modules == NULL ) if( parent->GetBoard() == NULL
|| parent->GetBoard()->m_Modules == NULL )
return; return;
Module = Select_1_Module_From_BOARD( parent->GetBoard() ); Module = Select_1_Module_From_BOARD( parent->GetBoard() );
...@@ -90,25 +86,23 @@ void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module ) ...@@ -90,25 +86,23 @@ void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
} }
/****************************************************************************/
MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
wxDC* DC ) wxDC* DC )
/****************************************************************************/
/* Permet de charger un module directement a partir de la librairie */
{ {
MODULE* module; MODULE* module;
wxPoint curspos = GetScreen()->m_Curseur; wxPoint curspos = GetScreen()->m_Curseur;
wxString ModuleName, keys; wxString ModuleName, keys;
static wxArrayString HistoryList; static wxArrayString HistoryList;
static wxString lastCommponentName; static wxString lastCommponentName;
bool AllowWildSeach = TRUE; bool AllowWildSeach = TRUE;
/* Ask for a component name or key words */ /* Ask for a component name or key words */
WinEDA_SelectCmp dlg( this, GetComponentDialogPosition(), HistoryList, WinEDA_SelectCmp dlg( this, GetComponentDialogPosition(), HistoryList,
_( "Place Module" ), false ); _( "Place Module" ), false );
dlg.SetComponentName( lastCommponentName ); dlg.SetComponentName( lastCommponentName );
if ( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return NULL; return NULL;
ModuleName = dlg.GetComponentName(); ModuleName = dlg.GetComponentName();
...@@ -134,21 +128,21 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, ...@@ -134,21 +128,21 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
} }
} }
else if( ( ModuleName.Contains( wxT( "?" ) ) ) else if( ( ModuleName.Contains( wxT( "?" ) ) )
|| ( ModuleName.Contains( wxT( "*" ) ) ) ) // Selection wild card || ( ModuleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
{ {
AllowWildSeach = FALSE; AllowWildSeach = FALSE;
ModuleName = Select_1_Module_From_List( this, library, ModuleName, ModuleName = Select_1_Module_From_List( this, library, ModuleName,
wxEmptyString ); wxEmptyString );
if( ModuleName.IsEmpty() ) if( ModuleName.IsEmpty() )
{ {
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
return NULL; /* annulation de commande */ return NULL; /* Cancel command. */
} }
} }
module = Get_Librairie_Module( library, ModuleName, FALSE ); module = Get_Librairie_Module( library, ModuleName, FALSE );
if( ( module == NULL ) && AllowWildSeach ) /* Sarch with wildcard */ if( ( module == NULL ) && AllowWildSeach ) /* Search with wildcard */
{ {
AllowWildSeach = FALSE; AllowWildSeach = FALSE;
wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' ); wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' );
...@@ -158,7 +152,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, ...@@ -158,7 +152,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
if( ModuleName.IsEmpty() ) if( ModuleName.IsEmpty() )
{ {
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
return NULL; /* annulation de commande */ return NULL; /* Cancel command. */
} }
else else
module = Get_Librairie_Module( library, ModuleName, TRUE ); module = Get_Librairie_Module( library, ModuleName, TRUE );
...@@ -177,15 +171,17 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, ...@@ -177,15 +171,17 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
module->m_TimeStamp = GetTimeStamp(); module->m_TimeStamp = GetTimeStamp();
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
module->SetPosition( curspos ); module->SetPosition( curspos );
/* TODO: call RecalculateAllTracksNetcode() only if some pads pads have /* TODO: call RecalculateAllTracksNetcode() only if some pads pads have
* a netname. * a netname.
* If all pads are not connected (usually the case in module libraries, * If all pads are not connected (usually the case in module libraries,
* rebuild only the pad and list of nets ( faster) * rebuild only the pad and list of nets ( faster)
*/ */
// GetBoard()->m_Pcb->m_NetInfo->BuildListOfNets(); // GetBoard()->m_Pcb->m_NetInfo->BuildListOfNets();
RecalculateAllTracksNetcode( ); RecalculateAllTracksNetcode();
if ( DC ) if( DC )
module->Draw( DrawPanel, DC, GR_OR ); module->Draw( DrawPanel, DC, GR_OR );
} }
...@@ -196,16 +192,18 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, ...@@ -196,16 +192,18 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
/** function Get_Librairie_Module /** function Get_Librairie_Module
* *
* Read active libraries or one library to find and load a given module * Read active libraries or one library to find and load a given module
* If found the lodule is linked to the tail of linked list of modules * If found the module is linked to the tail of linked list of modules
* @param aLibrary: the full filename of the library to read. If empty, all active libraries are read * @param aLibrary: the full filename of the library to read. If empty,
* all active libraries are read
* @param aModuleName = module name to load * @param aModuleName = module name to load
* @param aDisplayMessageError = true to display an error message if any. * @param aDisplayMessageError = true to display an error message if any.
* @return a MODULE * pointer to the new module, or NULL * @return a MODULE * pointer to the new module, or NULL
* *
*/ */
MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullFilename, MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module(
const wxString& aModuleName, const wxString& aLibraryFullFilename,
bool aDisplayMessageError ) const wxString& aModuleName,
bool aDisplayMessageError )
{ {
int LineNum, Found = 0; int LineNum, Found = 0;
wxFileName fn; wxFileName fn;
...@@ -219,7 +217,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -219,7 +217,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{ {
if ( one_lib ) if( one_lib )
fn = aLibraryFullFilename; fn = aLibraryFullFilename;
else else
fn = wxFileName( wxEmptyString, g_LibName_List[ii], fn = wxFileName( wxEmptyString, g_LibName_List[ii],
...@@ -229,7 +227,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -229,7 +227,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
if( !tmp ) if( !tmp )
{ {
if ( aDisplayMessageError ) if( aDisplayMessageError )
{ {
msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ), msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ),
GetChars( fn.GetFullName() ) ); GetChars( fn.GetFullName() ) );
...@@ -253,7 +251,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -253,7 +251,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
msg.Printf( _( "Scan Lib: %s" ), GetChars( tmp ) ); msg.Printf( _( "Scan Lib: %s" ), GetChars( tmp ) );
Affiche_Message( msg ); Affiche_Message( msg );
/* lecture entete chaine definie par ENTETE_LIBRAIRIE */ /* Reading header ENTETE_LIBRAIRIE */
LineNum = 0; LineNum = 0;
GetLine( file, Line, &LineNum ); GetLine( file, Line, &LineNum );
StrPurge( Line ); StrPurge( Line );
...@@ -267,7 +265,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -267,7 +265,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
return NULL; return NULL;
} }
/* Lecture de la liste des composants de la librairie */ /* Reading the list of modules in the library. */
Found = 0; Found = 0;
while( !Found && GetLine( file, Line, &LineNum ) ) while( !Found && GetLine( file, Line, &LineNum ) )
{ {
...@@ -284,13 +282,13 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -284,13 +282,13 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
if( msg.CmpNoCase( aModuleName ) == 0 ) if( msg.CmpNoCase( aModuleName ) == 0 )
{ {
Found = 1; Found = 1;
break; /* Trouve! */ break; /* Found! */
} }
} }
} }
} }
/* Lecture de la librairie */ /* Read library. */
while( Found && GetLine( file, Line, &LineNum ) ) while( Found && GetLine( file, Line, &LineNum ) )
{ {
if( Line[0] != '$' ) if( Line[0] != '$' )
...@@ -299,18 +297,18 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -299,18 +297,18 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
continue; continue;
if( strnicmp( Line, "$MODULE", 7 ) != 0 ) if( strnicmp( Line, "$MODULE", 7 ) != 0 )
continue; continue;
/* Lecture du nom du composant */ /* Read module name. */
Name = CONV_FROM_UTF8( Line + 8 ); Name = CONV_FROM_UTF8( Line + 8 );
if( Name.CmpNoCase( aModuleName ) == 0 ) /* composant localise */ if( Name.CmpNoCase( aModuleName ) == 0 )
{ {
NewModule = new MODULE( GetBoard() ); NewModule = new MODULE( GetBoard() );
// Switch the locale to standard C (needed to print // Switch the locale to standard C (needed to print
// floating point numbers like 1.3) // floating point numbers like 1.3)
SetLocaleTo_C_standard( ); SetLocaleTo_C_standard();
NewModule->ReadDescr( file, &LineNum ); NewModule->ReadDescr( file, &LineNum );
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
GetBoard()->Add( NewModule, ADD_APPEND ); GetBoard()->Add( NewModule, ADD_APPEND );
fclose( file ); fclose( file );
Affiche_Message( wxEmptyString ); Affiche_Message( wxEmptyString );
...@@ -319,9 +317,8 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -319,9 +317,8 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
} }
fclose( file ); fclose( file );
if ( one_lib ) if( one_lib )
break; break;
} }
if( aDisplayMessageError ) if( aDisplayMessageError )
...@@ -334,28 +331,28 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -334,28 +331,28 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
} }
/***************************************************************/
wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
WinEDA_DrawFrame* active_window,
const wxString& aLibraryFullFilename,
const wxString& aMask, const wxString& aKeyWord )
/***************************************************************/
/** Function Select_1_Module_From_List /** Function Select_1_Module_From_List
* Display a list of modules found in active libraries or a given library * Display a list of modules found in active libraries or a given library
* @param aLibraryFullFilename = library to list (if aLibraryFullFilename == void, list all modules) * @param aLibraryFullFilename = library to list (if aLibraryFullFilename ==
* @param aMask = Display filter (wildcart)( Mask = wxEmptyString if not used ) * void, list all modules)
* @param aKeyWord = keyword list, to display a filtered list of module having one (or more) of these keyworks in their keywork list * @param aMask = Display filter (wildcard)( Mask = wxEmptyString if not used
* ( aKeyWord = wxEmptyString if not used ) * )
* @param aKeyWord = keyword list, to display a filtered list of module having
* one (or more) of these keyworks in their keywork list
* ( aKeyWord = wxEmptyString if not used )
* *
* @return wxEmptyString if abort or fails, or the selected module name if Ok * @return wxEmptyString if abort or fails, or the selected module name if Ok
*/ */
wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
WinEDA_DrawFrame* active_window,
const wxString& aLibraryFullFilename,
const wxString& aMask, const wxString& aKeyWord )
{ {
int LineNum; int LineNum;
unsigned ii, NbModules; unsigned ii, NbModules;
char Line[1024]; char Line[1024];
wxFileName fn; wxFileName fn;
static wxString OldName;/* Memorise le nom du dernier composant charge */ static wxString OldName; /* Save the name of the last module loaded. */
wxString CmpName, tmp; wxString CmpName, tmp;
FILE* file; FILE* file;
wxString msg; wxString msg;
...@@ -363,15 +360,15 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -363,15 +360,15 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
WinEDAListBox* ListBox = new WinEDAListBox( active_window, wxEmptyString, WinEDAListBox* ListBox = new WinEDAListBox( active_window, wxEmptyString,
NULL, OldName, DisplayCmpDoc, NULL, OldName, DisplayCmpDoc,
wxColour( 200, 200, 255 ), wxColour( 200, 200, 255 ),
GetComponentDialogPosition()); GetComponentDialogPosition() );
wxBeginBusyCursor(); wxBeginBusyCursor();
/* Recherche des composants en librairies */ /* Find modules in libraries. */
NbModules = 0; NbModules = 0;
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{ {
/* Calcul du nom complet de la librairie */ /* Calculate the full file name of the library. */
if( aLibraryFullFilename.IsEmpty() ) if( aLibraryFullFilename.IsEmpty() )
{ {
fn = wxFileName( wxEmptyString, g_LibName_List[ii], fn = wxFileName( wxEmptyString, g_LibName_List[ii],
...@@ -393,8 +390,8 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -393,8 +390,8 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
ReadDocLib( tmp ); ReadDocLib( tmp );
if( !aKeyWord.IsEmpty() ) /* Inutile de lire la librairie si selection if( !aKeyWord.IsEmpty() ) /* Don't read the library if selection
* par mots cles, deja lus */ * by keywords, already read. */
{ {
if( !aLibraryFullFilename.IsEmpty() ) if( !aLibraryFullFilename.IsEmpty() )
break; break;
...@@ -411,10 +408,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -411,10 +408,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
} }
// Statusbar library loaded message // Statusbar library loaded message
msg = _( "Library " ) + fn.GetFullPath() + _(" loaded"); msg = _( "Library " ) + fn.GetFullPath() + _( " loaded" );
Affiche_Message( msg ); Affiche_Message( msg );
/* lecture entete */ /* Read header. */
LineNum = 0; LineNum = 0;
GetLine( file, Line, &LineNum, sizeof(Line) - 1 ); GetLine( file, Line, &LineNum, sizeof(Line) - 1 );
...@@ -428,7 +425,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -428,7 +425,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
continue; continue;
} }
/* Lecture de la librairie */ /* Read library. */
while( GetLine( file, Line, &LineNum, sizeof(Line) - 1 ) ) while( GetLine( file, Line, &LineNum, sizeof(Line) - 1 ) )
{ {
if( Line[0] != '$' ) if( Line[0] != '$' )
...@@ -454,10 +451,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -454,10 +451,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
NbModules++; NbModules++;
} }
} }
} /* Fin Lecture INDEX */ } /* End read INDEX */
} }
/* Fin lecture 1 Librairie */ /* End read library. */
fclose( file ); fclose( file );
file = NULL; file = NULL;
...@@ -465,7 +462,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -465,7 +462,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
break; break;
} }
/* creation de la liste des modules si recherche par mots-cles */ /* Create list of modules if search by keyword. */
if( !aKeyWord.IsEmpty() ) if( !aKeyWord.IsEmpty() )
{ {
ModList* ItemMod = MList; ModList* ItemMod = MList;
...@@ -494,7 +491,6 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -494,7 +491,6 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
ListBox->Destroy(); ListBox->Destroy();
/* liberation mem de la liste des textes doc module */
while( MList != NULL ) while( MList != NULL )
{ {
ModList* NewMod = MList->Next; ModList* NewMod = MList->Next;
...@@ -509,13 +505,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( ...@@ -509,13 +505,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
} }
/******************************************/ /* Find and display the doc Component Name
static void DisplayCmpDoc( wxString& Name ) * The list of doc is pointed to by mlist.
/*******************************************/
/* Routine de recherche et d'affichage de la doc du composant Name
* La liste des doc est pointee par MList
*/ */
static void DisplayCmpDoc( wxString& Name )
{ {
ModList* Mod = MList; ModList* Mod = MList;
...@@ -525,10 +518,9 @@ static void DisplayCmpDoc( wxString& Name ) ...@@ -525,10 +518,9 @@ static void DisplayCmpDoc( wxString& Name )
return; return;
} }
/* Recherche de la description */
while( Mod ) while( Mod )
{ {
if( !Mod->m_Name.IsEmpty() && (Mod->m_Name.CmpNoCase( Name ) == 0) ) if( !Mod->m_Name.IsEmpty() && ( Mod->m_Name.CmpNoCase( Name ) == 0 ) )
break; break;
Mod = Mod->Next; Mod = Mod->Next;
} }
...@@ -544,14 +536,11 @@ static void DisplayCmpDoc( wxString& Name ) ...@@ -544,14 +536,11 @@ static void DisplayCmpDoc( wxString& Name )
} }
/***************************************************/ /* Read the doc file and combine with a library ModLibName.
static void ReadDocLib( const wxString& ModLibName ) * Load in memory the list of docs string pointed to by mlist
/***************************************************/ * ModLibName = full file name of the library modules
/* Routine de lecture du fichier Doc associe a la librairie ModLibName.
* Cree en memoire la chaine liste des docs pointee par MList
* ModLibName = full file Name de la librairie Modules
*/ */
static void ReadDocLib( const wxString& ModLibName )
{ {
ModList* NewMod; ModList* NewMod;
char Line[1024]; char Line[1024];
...@@ -567,13 +556,12 @@ static void ReadDocLib( const wxString& ModLibName ) ...@@ -567,13 +556,12 @@ static void ReadDocLib( const wxString& ModLibName )
if( strnicmp( Line, ENTETE_LIBDOC, L_ENTETE_LIB ) != 0 ) if( strnicmp( Line, ENTETE_LIBDOC, L_ENTETE_LIB ) != 0 )
return; return;
/* Lecture de la librairie */
while( GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ) ) while( GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ) )
{ {
if( Line[0] != '$' ) if( Line[0] != '$' )
continue; continue;
if( Line[1] == 'E' ) if( Line[1] == 'E' )
break;; break; ;
if( Line[1] == 'M' ) /* Debut decription 1 module */ if( Line[1] == 'M' ) /* Debut decription 1 module */
{ {
NewMod = new ModList(); NewMod = new ModList();
...@@ -599,33 +587,28 @@ static void ReadDocLib( const wxString& ModLibName ) ...@@ -599,33 +587,28 @@ static void ReadDocLib( const wxString& ModLibName )
break; break;
} }
} }
} /* lecture 1 descr module */ } /* End read 1 module. */
} }
/* Fin lecture librairie */
fclose( LibDoc ); fclose( LibDoc );
} }
/********************************************************************/ /* Display the list of modules currently PCB
MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) * Returns a pointer if module selected
/********************************************************************/ * Returns NULL otherwise
/* Affiche la liste des modules du PCB en cours
* Retourne un pointeur si module selectionne
* retourne NULL sinon
*/ */
MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb )
{ {
int ii; int ii;
MODULE* Module; MODULE* Module;
static wxString OldName;/* Memorise le nom du dernier composant charge */ static wxString OldName; /* Save name of last module selectec. */
wxString CmpName, msg; wxString CmpName, msg;
WinEDAListBox* ListBox = new WinEDAListBox( this, wxEmptyString, WinEDAListBox* ListBox = new WinEDAListBox( this, wxEmptyString,
NULL, wxEmptyString, NULL, NULL, wxEmptyString, NULL,
wxColour( 200, 200, 255 ) ); wxColour( 200, 200, 255 ) );
/* Recherche des composants en BOARD */
ii = 0; ii = 0;
Module = Pcb->m_Modules; Module = Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() ) for( ; Module != NULL; Module = (MODULE*) Module->Next() )
...@@ -652,7 +635,6 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) ...@@ -652,7 +635,6 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb )
OldName = CmpName; OldName = CmpName;
// Recherche du pointeur sur le module
Module = Pcb->m_Modules; Module = Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() ) for( ; Module != NULL; Module = (MODULE*) Module->Next() )
{ {
......
/*****************************/ /*******************/
/* Localisation des elements */ /* Locate element. */
/*****************************/ /*******************/
#include "fctsys.h" #include "fctsys.h"
...@@ -28,20 +28,17 @@ wxPoint inline RefPos( int typeloc ) ...@@ -28,20 +28,17 @@ wxPoint inline RefPos( int typeloc )
} }
/*******************************************************************/ /* Locates a via point pX, pY
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer ) * If layer < 0 will be located via whatever layer
/*******************************************************************/ * If layer = 0 .. 15 Via will be located according to its type:
* - Traverse: all layers
/* Localise une via au point pX,pY * - = Blind between layers useful
* Si layer < 0 la via sera localisee quelle que soit la couche * - Blind idem
* Si layer = 0 .. 15 la via sera localisee selon son type: * Entry: coord point of reference, layer
* - traversante : toutes couches * Output: NULL if not via
* - aveugle = entre couches utiles * (* TRACK) address via
* - borgnes idem
* Entree : coord du point de reference, couche
* Sortie: NULL si pas de via
* (TRACK*) adresse de la via
*/ */
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer )
{ {
TRACK* track; TRACK* track;
...@@ -63,9 +60,7 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer ) ...@@ -63,9 +60,7 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer )
} }
/*******************************************************************/
TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer ) TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer )
/*******************************************************************/
{ {
TRACK* track; TRACK* track;
...@@ -87,18 +82,15 @@ TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer ) ...@@ -87,18 +82,15 @@ TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer )
} }
/********************************************************************/ /* Location of the pellet CONNECTED developed a test track
D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr ) * input: ptr_piste: pointer to the segment of track
/********************************************************************/ * Extr = flag = START -> beginning of the test segment
* END -> end of the segment to be tested
/* localisation de la pastille connectee au point de piste a tester * Returns:
* entree : ptr_piste: pointeur sur le segment de piste * A pointer to the description of the pad if found.
* extr = flag = START -> debut du segment a tester * NULL pointer if pad NOT FOUND
* = END -> fin du segment a tester
* retourne:
* un pointeur sur la description de la pastille si localisation
* pointeur NULL si pastille non trouvee
*/ */
D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr )
{ {
D_PAD* ptr_pad = NULL; D_PAD* ptr_pad = NULL;
wxPoint ref_pos; wxPoint ref_pos;
...@@ -125,25 +117,18 @@ D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr ) ...@@ -125,25 +117,18 @@ D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr )
} }
/*************************************************
* D_PAD * Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer)
* D_PAD* Locate_Any_Pad( BOARD* Pcb, int ref_pos, bool OnlyCurrentLayer)
*************************************************/
/* /*
* localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou * Locate pad pointed to by the coordinates ref_pos.x,, ref_pos.y or
* par la souris, recherche faite sur toutes les empreintes. * the mouse, search done on all tracks.
* entree : * Input:
* - coord souris * - mouse coord or ref_pos
* ou ref_pos * Returns:
* retourne: * Pointer to the pad if found.
* pointeur sur la description de la pastille si localisation * NULL pointer if pad NOT FOUND
* pointeur NULL si pastille non trouvee * Num_empr = number of fingerprint pad
* num_empr = numero d'empreinte du pad
* *
* la priorit� est donn�e a la couche active * Priority is the active layer
*/ */
D_PAD* Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer ) D_PAD* Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer )
{ {
wxPoint ref_pos = RefPos( typeloc ); wxPoint ref_pos = RefPos( typeloc );
...@@ -151,9 +136,11 @@ D_PAD* Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer ) ...@@ -151,9 +136,11 @@ D_PAD* Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer )
} }
D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, bool OnlyCurrentLayer ) D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos,
bool OnlyCurrentLayer )
{ {
int layer_mask = g_TabOneLayerMask[ ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer]; int layer_mask =
g_TabOneLayerMask[ ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer];
for( MODULE* module=Pcb->m_Modules; module; module = module->Next() ) for( MODULE* module=Pcb->m_Modules; module; module = module->Next() )
{ {
...@@ -175,21 +162,15 @@ D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, bool OnlyCurrentLayer ...@@ -175,21 +162,15 @@ D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, bool OnlyCurrentLayer
} }
/******************************************************************************/ /* Locate pad pointed to by the coordinate ref_pos.x,, ref_pos.y or
/* D_PAD* Locate_Pads(MODULE * module, int masque_layer,int typeloc) */ * the mouse on the current footprint.
/* D_PAD* Locate_Pads(MODULE * module, const wxPoint & ref_pos,int masque_layer) */ * Input:
/******************************************************************************/ * - General parameters of the footprint update by characters()
* - = Masque_layer layer(s) (bit_masque) which must be the pad
/* localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou * Returns:
* par la souris, concernant l'empreinte en cours. * A pointer to the pad if found
* entree : * NULL pointer if pad NOT FOUND
* - parametres generaux de l'empreinte mise a jour par caract()
* - masque_layer = couche(s) (bit_masque)sur laquelle doit etre la pastille
* retourne:
* un pointeur sur la description de la pastille si localisation
* pointeur NULL si pastille non trouvee
*/ */
D_PAD* Locate_Pads( MODULE* module, int masque_layer, int typeloc ) D_PAD* Locate_Pads( MODULE* module, int masque_layer, int typeloc )
{ {
wxPoint ref_pos = RefPos( typeloc ); wxPoint ref_pos = RefPos( typeloc );
...@@ -201,8 +182,8 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) ...@@ -201,8 +182,8 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
{ {
for( D_PAD* pt_pad = module->m_Pads; pt_pad; pt_pad = pt_pad->Next() ) for( D_PAD* pt_pad = module->m_Pads; pt_pad; pt_pad = pt_pad->Next() )
{ {
/* ... et sur la bonne couche */ /* ... and on the correct layer. */
if( (pt_pad->m_Masque_Layer & masque_layer) == 0 ) if( ( pt_pad->m_Masque_Layer & masque_layer ) == 0 )
continue; continue;
if( pt_pad->HitTest( ref_pos ) ) if( pt_pad->HitTest( ref_pos ) )
...@@ -216,11 +197,12 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) ...@@ -216,11 +197,12 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
/** /**
* Function Locate_Prefered_Module * Function Locate_Prefered_Module
* locates a footprint by its bounding rectangle. If several footprints * locates a footprint by its bounding rectangle. If several footprints
* are possible, then the priority is: the closest on the active layer, then closest. * are possible, then the priority is: the closest on the active layer, then
* closest.
* The current mouse or cursor coordinates are grabbed from the active window * The current mouse or cursor coordinates are grabbed from the active window
* to performe hit-testing. * to perform hit-testing.
* distance is calculated via manhattan distance from the center of the bounding rectangle * distance is calculated via manhattan distance from the center of the
* to the cursor postition. * bounding rectangle to the cursor position.
* *
* @param Pcb The BOARD to search within. * @param Pcb The BOARD to search within.
* @param typeloc Flag bits, tuning the search, see pcbnew.h * @param typeloc Flag bits, tuning the search, see pcbnew.h
...@@ -229,13 +211,13 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) ...@@ -229,13 +211,13 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
{ {
MODULE* pt_module; MODULE* pt_module;
int lx, ly; /* dimensions du rectangle d'encadrement du module */ int lx, ly;
MODULE* module = NULL; /* module localise sur la couche active */ MODULE* module = NULL;
MODULE* Altmodule = NULL; /* module localise sur les couches non actives */ MODULE* Altmodule = NULL;
int min_dim = 0x7FFFFFFF; /* dim mini du module localise sur la couche active */ int min_dim = 0x7FFFFFFF;
int alt_min_dim = 0x7FFFFFFF; /* dim mini du module localise sur les couches non actives */ int alt_min_dim = 0x7FFFFFFF;
int layer; /* pour calcul de couches prioritaires */ int layer;
wxPoint ref_pos; /* coord du point de reference pour la localisation */ wxPoint ref_pos;
ref_pos = RefPos( typeloc ); ref_pos = RefPos( typeloc );
...@@ -246,14 +228,16 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) ...@@ -246,14 +228,16 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
if( !pt_module->HitTest( ref_pos ) ) if( !pt_module->HitTest( ref_pos ) )
continue; continue;
// if caller wants to ignore locked modules, and this one is locked, skip it. // if caller wants to ignore locked modules, and this one is locked,
// skip it.
if( (typeloc & IGNORE_LOCKED) && pt_module->IsLocked() ) if( (typeloc & IGNORE_LOCKED) && pt_module->IsLocked() )
continue; continue;
/* calcul de priorite: la priorite est donnee a la couche /* Calculate priority: the priority is given to the layer of the
* d'appartenance du module et a la couche cuivre si le module * module and the copper layer if the module layer is indelible,
* est sur couche serigr,adhesive cuivre, a la couche cmp si le module * adhesive copper, a layer if cmp module layer is indelible,
* est sur couche serigr,adhesive composant */ * adhesive component.
*/
layer = pt_module->GetLayer(); layer = pt_module->GetLayer();
if( layer==ADHESIVE_N_CU || layer==SILKSCREEN_N_CU ) if( layer==ADHESIVE_N_CU || layer==SILKSCREEN_N_CU )
...@@ -262,34 +246,37 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) ...@@ -262,34 +246,37 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP ) else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP )
layer = CMP_N; layer = CMP_N;
/* Localisation: test des dimensions minimales, choix du meilleur candidat */ /* Test of minimum size to choosing the best candidate. */
/* calcul des dimensions du cadre :*/ int offx = pt_module->m_BoundaryBox.m_Size.x / 2 +
int offx = pt_module->m_BoundaryBox.m_Size.x/2 + pt_module->m_BoundaryBox.m_Pos.x +
pt_module->m_BoundaryBox.m_Pos.x + pt_module->m_Pos.x;
pt_module->m_Pos.x; int offy = pt_module->m_BoundaryBox.m_Size.y / 2
int offy = pt_module->m_BoundaryBox.m_Size.y/2 + pt_module->m_BoundaryBox.m_Pos.y
+ pt_module->m_BoundaryBox.m_Pos.y + pt_module->m_Pos.y;
+ pt_module->m_Pos.y;
//off x & offy point to the middle of the box. //off x & offy point to the middle of the box.
int dist = abs(ref_pos.x - offx) + abs(ref_pos.y - offy); int dist = abs( ref_pos.x - offx ) + abs( ref_pos.y - offy );
lx = pt_module->m_BoundaryBox.GetWidth(); lx = pt_module->m_BoundaryBox.GetWidth();
ly = pt_module->m_BoundaryBox.GetHeight(); ly = pt_module->m_BoundaryBox.GetHeight();
//int dist = MIN(lx, ly); // to pick the smallest module (kinda screwy with same-sized modules -- this is bad!) //int dist = MIN(lx, ly); // to pick the smallest module (kinda
// screwy with same-sized modules -- this is bad!)
if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer ){ if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer )
if( dist <= min_dim ){ {
/* meilleure empreinte localisee sur couche active */ if( dist <= min_dim )
{
/* better footprint shown on the active layer */
module = pt_module; module = pt_module;
min_dim = dist; min_dim = dist;
} }
} }
else if( !(typeloc & MATCH_LAYER) else if( !( typeloc & MATCH_LAYER )
&& ( !(typeloc & VISIBLE_ONLY) || IsModuleLayerVisible( layer ) ) ) && ( !( typeloc & VISIBLE_ONLY )
|| IsModuleLayerVisible( layer ) ) )
{ {
if( dist <= alt_min_dim ) if( dist <= alt_min_dim )
{ {
/* meilleure empreinte localisee sur autres couches */ /* better footprint shown on other layers */
Altmodule = pt_module; Altmodule = pt_module;
alt_min_dim = dist; alt_min_dim = dist;
} }
...@@ -309,15 +296,14 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) ...@@ -309,15 +296,14 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
return NULL; return NULL;
} }
/******************************************************************/
inline bool IsPointsAreNear(wxPoint & p1, wxPoint & p2, int max_dist)
/******************************************************************/
/* /*
return true if the dist between p1 and p2 < max_dist * return true if the dist between p1 and p2 < max_dist
Currently in test (currently rasnest algos work only if p1 == p2) * Currently in test (currently rasnest algos work only if p1 == p2)
*/ */
inline bool IsPointsAreNear(wxPoint & p1, wxPoint & p2, int max_dist)
{ {
#if 0 // Do not change it: does not work #if 0 // Do not change it: does not work
{ {
int dist; int dist;
dist = abs(p1.x - p2.x) + abs (p1.y - p2.y); dist = abs(p1.x - p2.x) + abs (p1.y - p2.y);
...@@ -331,13 +317,11 @@ int dist; ...@@ -331,13 +317,11 @@ int dist;
return false; return false;
} }
/**************************************************************/
TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
TRACK* pt_lim, int extr )
/**************************************************************/
/** Search for the track (or via) segment which is connected to the track segment PtRefSegm /** Search for the track (or via) segment which is connected to the track
* if extr == START, the starting track segment PtRefSegm is used to locate a connected segment * segment PtRefSegm
* if extr == START, the starting track segment PtRefSegm is used to locate
* a connected segment
* if extr == END, the ending track segment PtRefSegm is used * if extr == END, the ending track segment PtRefSegm is used
* The test connection consider only end track segments * The test connection consider only end track segments
* *
...@@ -345,7 +329,8 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base, ...@@ -345,7 +329,8 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
* if pt_lim == NULL, the search is made from pt_base to the end of list * if pt_lim == NULL, the search is made from pt_base to the end of list
* *
* In order to have a fast computation time: * In order to have a fast computation time:
* a first search is made considering only the +/- 50 next door neightbour of PtRefSegm. * a first search is made considering only the +/- 50 next door neighbor
* of PtRefSegm.
* if no track is found : the entire list is tested * if no track is found : the entire list is tested
* *
* @param PtRefSegm = reference segment * @param PtRefSegm = reference segment
...@@ -353,6 +338,8 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base, ...@@ -353,6 +338,8 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
* @param pt_lim = upper limit for search (can be NULL) * @param pt_lim = upper limit for search (can be NULL)
* @param extr = START or END = end of ref track segment to use in tests * @param extr = START or END = end of ref track segment to use in tests
*/ */
TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
TRACK* pt_lim, int extr )
{ {
const int NEIGHTBOUR_COUNT_MAX = 50; const int NEIGHTBOUR_COUNT_MAX = 50;
...@@ -369,7 +356,6 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base, ...@@ -369,7 +356,6 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
Reflayer = PtRefSegm->ReturnMaskLayer(); Reflayer = PtRefSegm->ReturnMaskLayer();
/* 1ere passe */
PtSegmB = PtSegmN = PtRefSegm; PtSegmB = PtSegmN = PtRefSegm;
for( ii = 0; ii < NEIGHTBOUR_COUNT_MAX; ii++ ) for( ii = 0; ii < NEIGHTBOUR_COUNT_MAX; ii++ )
...@@ -384,17 +370,18 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base, ...@@ -384,17 +370,18 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
if( PtSegmN == PtRefSegm ) if( PtSegmN == PtRefSegm )
goto suite; goto suite;
/* max_dist is the max distance between 2 track ends which ensure a copper continuty */ /* max_dist is the max distance between 2 track ends which
* ensure a copper continuity */
max_dist = (PtSegmN->m_Width + PtRefSegm->m_Width)/2; max_dist = (PtSegmN->m_Width + PtRefSegm->m_Width)/2;
if( IsPointsAreNear(pos_ref, PtSegmN->m_Start, max_dist) ) if( IsPointsAreNear(pos_ref, PtSegmN->m_Start, max_dist) )
{ /* Test des couches */ {
if( Reflayer & PtSegmN->ReturnMaskLayer() ) if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN; return PtSegmN;
} }
if( IsPointsAreNear(pos_ref, PtSegmN->m_End, max_dist) ) if( IsPointsAreNear(pos_ref, PtSegmN->m_End, max_dist) )
{ /* Test des couches */ {
if( Reflayer & PtSegmN->ReturnMaskLayer() ) if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN; return PtSegmN;
} }
...@@ -415,13 +402,13 @@ suite: ...@@ -415,13 +402,13 @@ suite:
max_dist = (PtSegmB->m_Width + PtRefSegm->m_Width)/2; max_dist = (PtSegmB->m_Width + PtRefSegm->m_Width)/2;
if( IsPointsAreNear(pos_ref, PtSegmB->m_Start, max_dist) ) if( IsPointsAreNear(pos_ref, PtSegmB->m_Start, max_dist) )
{ /* Test des couches */ {
if( Reflayer & PtSegmB->ReturnMaskLayer() ) if( Reflayer & PtSegmB->ReturnMaskLayer() )
return PtSegmB; return PtSegmB;
} }
if( IsPointsAreNear(pos_ref, PtSegmB->m_End, max_dist) ) if( IsPointsAreNear(pos_ref, PtSegmB->m_End, max_dist) )
{ /* Test des couches */ {
if( Reflayer & PtSegmB->ReturnMaskLayer() ) if( Reflayer & PtSegmB->ReturnMaskLayer() )
return PtSegmB; return PtSegmB;
} }
...@@ -435,7 +422,7 @@ suite1: ...@@ -435,7 +422,7 @@ suite1:
} }
} }
/* Recherche generale */ /* General search. */
for( PtSegmN = pt_base; PtSegmN != NULL; PtSegmN = PtSegmN->Next() ) for( PtSegmN = pt_base; PtSegmN != NULL; PtSegmN = PtSegmN->Next() )
{ {
if( PtSegmN->GetState( DELETED | BUSY ) ) if( PtSegmN->GetState( DELETED | BUSY ) )
...@@ -451,17 +438,16 @@ suite1: ...@@ -451,17 +438,16 @@ suite1:
continue; continue;
} }
max_dist = ( PtSegmN->m_Width + PtRefSegm->m_Width ) / 2;
max_dist = (PtSegmN->m_Width + PtRefSegm->m_Width)/2; if( IsPointsAreNear( pos_ref, PtSegmN->m_Start, max_dist ) )
{
if( IsPointsAreNear(pos_ref,PtSegmN->m_Start, max_dist) )
{ /* Test des couches */
if( Reflayer & PtSegmN->ReturnMaskLayer() ) if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN; return PtSegmN;
} }
if( IsPointsAreNear(pos_ref, PtSegmN->m_End, max_dist) ) if( IsPointsAreNear( pos_ref, PtSegmN->m_End, max_dist ) )
{ /* Test des couches */ {
if( Reflayer & PtSegmN->ReturnMaskLayer() ) if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN; return PtSegmN;
} }
...@@ -473,20 +459,13 @@ suite1: ...@@ -473,20 +459,13 @@ suite1:
} }
/****************************************************************************/
/* TRACK *Locate_Pistes(TRACK * start_adresse, int MasqueLayer,int typeloc) */
/* TRACK *Locate_Pistes(TRACK * start_adresse, int ref_pos.x, int ref_pos.y,*/
/* int MasqueLayer) */
/****************************************************************************/
/* /*
* 1 - routine de localisation du segment de piste pointe par la souris. * 1 - Locate segment of track leading from the mouse.
* 2 - routine de localisation du segment de piste pointe par le point * 2 - Locate segment of track point by point
* ref_pos.x , ref_pos.y.r * ref_pos.x, ref_pos.y.r
* *
* La recherche commence a l'adresse start_adresse * The search begins to address start_adresse
*/ */
TRACK* Locate_Pistes( TRACK* start_adresse, int MasqueLayer, int typeloc ) TRACK* Locate_Pistes( TRACK* start_adresse, int MasqueLayer, int typeloc )
{ {
wxPoint ref_pos = RefPos( typeloc ); wxPoint ref_pos = RefPos( typeloc );
...@@ -495,7 +474,8 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int MasqueLayer, int typeloc ) ...@@ -495,7 +474,8 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int MasqueLayer, int typeloc )
} }
TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLayer ) TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos,
int MasqueLayer )
{ {
for( TRACK* track = start_adresse; track; track = track->Next() ) for( TRACK* track = start_adresse; track; track = track->Next() )
{ {
...@@ -503,14 +483,16 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa ...@@ -503,14 +483,16 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa
if( track->GetState( BUSY | DELETED ) ) if( track->GetState( BUSY | DELETED ) )
{ {
// D(printf("track %p is BUSY | DELETED. BUSY=%d DELETED=%d\n", track, track->GetState(BUSY), track->GetState(DELETED) );) // D( printf( "track %p is BUSY | DELETED. BUSY=%d DELETED=%d\n",
// track, track->GetState( BUSY ),
// track->GetState( DELETED ) );)
continue; continue;
} }
if( g_DesignSettings.IsLayerVisible( layer ) == false ) if( g_DesignSettings.IsLayerVisible( layer ) == false )
continue; continue;
if( track->Type() == TYPE_VIA ) /* VIA rencontree */ if( track->Type() == TYPE_VIA ) /* VIA encountered. */
{ {
if( track->HitTest( ref_pos ) ) if( track->HitTest( ref_pos ) )
return track; return track;
...@@ -518,7 +500,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa ...@@ -518,7 +500,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa
else else
{ {
if( (g_TabOneLayerMask[layer] & MasqueLayer) == 0 ) if( (g_TabOneLayerMask[layer] & MasqueLayer) == 0 )
continue; /* Segments sur couches differentes */ continue; /* Segments on different layers. */
if( track->HitTest( ref_pos ) ) if( track->HitTest( ref_pos ) )
return track; return track;
...@@ -528,22 +510,14 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa ...@@ -528,22 +510,14 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa
return NULL; return NULL;
} }
/****************************************************************/
/* TRACK * Locate_Zone(TRACK * start_adresse, int layer, */
/* int typeloc) */
/* TRACK * Locate_Zone(TRACK * start_adresse, */
/* const wxPoint & ref_pos, */
/* int layer) */
/****************************************************************/
/* /*
* 1 - routine de localisation du segment de zone pointe par la souris. * 1 - Locate zone area by the mouse.
* 2 - routine de localisation du segment de zone pointe par le point * 2 - Locate zone area by point
* ref_pos.x , ref_pos.y.r * def_pos.x, ref_pos.y.r
* *
* Si layer == -1 , le tst de la couche n'est pas fait * If layer == -1, tst layer is not
* *
* 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 )
{ {
...@@ -568,21 +542,18 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer ) ...@@ -568,21 +542,18 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer )
} }
/* Find the pad center px, py,
/*******************************************************************************/ * The layer INDICATED BY masque_layer (bitwise)
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_layer ) * (Runway end)
/*******************************************************************************/ * The list of pads must already exist.
/* Routine cherchant le pad de centre px,py,
* sur la couche indiquee par masque_layer (bit a bit)
* ( extremite de piste )
* La liste des pads doit deja exister.
* *
* retourne : * Returns:
* NULL si pas de pad localise. * NULL if no pad located.
* pointeur sur la structure descr_pad correspondante si pad trouve * Pointer to the structure corresponding descr_pad if pad found
* (bonne position ET bonne couche). * (Good position and good layer).
*/ */
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos,
int masque_layer )
{ {
for( unsigned i=0; i<Pcb->GetPadsCount(); ++i ) for( unsigned i=0; i<Pcb->GetPadsCount(); ++i )
{ {
...@@ -591,7 +562,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_ ...@@ -591,7 +562,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_
if( pad->m_Pos != ref_pos ) if( pad->m_Pos != ref_pos )
continue; continue;
/* Pad peut-etre trouve ici : il doit etre sur la bonne couche */ /* Pad found, it must be on the correct layer */
if( pad->m_Masque_Layer & masque_layer ) if( pad->m_Masque_Layer & masque_layer )
return pad; return pad;
} }
...@@ -600,18 +571,15 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_ ...@@ -600,18 +571,15 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_
} }
/***********************************************************************************/ /* Locate segment with one end that coincides with the point x, y
* Data on layers by masklayer
* Research is done to address start_adr has end_adr
* If end_adr = NULL, end search list
* The segments of track marks with the flag are not DELETED or taken
* into account
*/
TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
const wxPoint& ref_pos, int MaskLayer ) const wxPoint& ref_pos, int MaskLayer )
/***********************************************************************************/
/* Localiste le segment dont une extremite coincide avec le point x,y
* sur les couches donnees par masklayer
* la recherche se fait de l'adresse start_adr a end_adr
* si end_adr = NULL, recherche jusqu'a la fin de la liste
* Les segments de piste marques avec le flag DELETED ne sont pas
* pris en compte
*/
{ {
TRACK* PtSegm; TRACK* PtSegm;
...@@ -624,14 +592,12 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, ...@@ -624,14 +592,12 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
{ {
if( ref_pos == PtSegm->m_Start ) if( ref_pos == PtSegm->m_Start )
{ {
/* Test des couches */
if( MaskLayer & PtSegm->ReturnMaskLayer() ) if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm; return PtSegm;
} }
if( ref_pos == PtSegm->m_End ) if( ref_pos == PtSegm->m_End )
{ {
/* Test des couches */
if( MaskLayer & PtSegm->ReturnMaskLayer() ) if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm; return PtSegm;
} }
...@@ -644,17 +610,13 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, ...@@ -644,17 +610,13 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
} }
/*******************************************************************/ /* Locates via through the point x, y, on layer data by masklayer.
* Search is done to address start_adr has end_adr.
* If end_adr = NULL, end search list
* Vias whose parameter has the State or DELETED bit BUSY = 1 are ignored
*/
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
const wxPoint& pos, int MaskLayer ) const wxPoint& pos, int MaskLayer )
/*******************************************************************/
/* Localise la via de centre le point x,y , sur les couches donnees
* par masklayer
* la recherche se fait de l'adresse start_adr a end_adr.
* si end_adr = NULL, recherche jusqu'a la fin de la liste
* les vias dont le parametre State a le bit DELETED ou BUSY = 1 sont ignorees
*/
{ {
TRACK* PtSegm; TRACK* PtSegm;
...@@ -666,7 +628,6 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, ...@@ -666,7 +628,6 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
{ {
if( PtSegm->GetState( BUSY | DELETED ) == 0 ) if( PtSegm->GetState( BUSY | DELETED ) == 0 )
{ {
/* Test des couches */
if( MaskLayer & PtSegm->ReturnMaskLayer() ) if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm; return PtSegm;
} }
...@@ -678,4 +639,3 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, ...@@ -678,4 +639,3 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
return NULL; return NULL;
} }
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