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 )
/* Draw keep out area of a module. */
/***********************************/
/* ???
/* TRANSLATE
* les cellules ( du plan des Distances ) du rectangle x0,y0 a x1,y1 sont
* incrementees de la valeur Penalite
* celles qui sont externes au rectangle, mais internes au rectangle
......
......@@ -344,7 +344,7 @@ int Build_Work( BOARD* Pcb )
for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); 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 )
continue;
if( pt_rats->m_Status & CH_UNROUTABLE )
......
/*********************************************/
/* Edition des pistes: Routines d'effacement */
/* Effacement de segment, piste, net et zone */
/*********************************************/
/******************************************/
/* Edit Track: Erase Routines */
/* Delete segments, tracks, and net areas */
/******************************************/
#include "fctsys.h"
#include "common.h"
......@@ -14,16 +13,12 @@
#include "protos.h"
/***************************************************************/
TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
/***************************************************************/
/* 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.
/* Removes 1 segment of track.
* 2 cases:
* If There is evidence of new track: delete new segment.
* Otherwise, delete segment under the cursor.
*/
TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
{
int current_net_code;
......@@ -36,7 +31,8 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
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 )
{
......@@ -44,7 +40,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
D( g_CurrentTrackList.VerifyListIntegrity(); )
// effacement de la piste en cours
// Delete the current trace
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE );
// delete the most recently entered
......@@ -52,8 +48,9 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
if( g_TwoSegmentTrackBuild )
{
// if in 2 track mode, and the next most recent is a segment not a via,
// and the one previous to that is a via, then delete up to the via.
// if in 2 track mode, and the next most recent is a segment
// not a via, and the one previous to that is a via, then
// delete up to the via.
if( g_CurrentTrackList.GetCount() >= 2
&& g_CurrentTrackSegment->Type() != TYPE_VIA
&& g_CurrentTrackSegment->Back()->Type() == TYPE_VIA )
......@@ -62,22 +59,26 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
}
}
while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() == TYPE_VIA )
while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() ==
TYPE_VIA )
{
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();
}
// Rectification couche active qui a pu changer si une via
// a ete effacee
// Correct active layer which could change if a via
// has been erased
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer;
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();
}
......@@ -107,9 +108,10 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
current_net_code = aTrack->GetNet();
DLIST<TRACK>* container = (DLIST<TRACK>*) aTrack->GetList();
DLIST<TRACK>* container = (DLIST<TRACK>*)aTrack->GetList();
wxASSERT( container );
container->Remove( aTrack );
// redraw the area where the track was
DrawPanel->PostDirtyRect( aTrack->GetBoundingBox() );
......@@ -122,9 +124,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
}
/**********************************************************/
void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* aTrack )
/**********************************************************/
{
if( aTrack != NULL )
{
......@@ -136,18 +136,16 @@ void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* aTrack )
}
/********************************************************/
void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
/********************************************************/
{
if( aTrack == NULL )
return;
if( !IsOK( this, _( "Delete NET ?" ) ) )
if( !IsOK( this, _( "Delete NET?" ) ) )
return;
PICKED_ITEMS_LIST itemsList;
ITEM_PICKER picker(NULL,UR_DELETED);
ITEM_PICKER picker( NULL, UR_DELETED );
int net_code_delete = aTrack->GetNet();
/* Search the first item for the given net code */
......@@ -155,7 +153,7 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
/* Remove all segments having the given net code */
int ii = 0;
TRACK * next_track;
TRACK* next_track;
for( TRACK* segm = trackList; segm; segm = next_track, ++ii )
{
next_track = segm->Next();
......@@ -163,64 +161,63 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
break;
GetBoard()->m_Track.Remove( segm );
// redraw the area where the track was
DrawPanel->PostDirtyRect( segm->GetBoundingBox() );
picker.m_PickedItem = segm;
picker.m_PickedItemType = segm->Type();
itemsList.PushItem(picker);
itemsList.PushItem( picker );
}
SaveCopyInUndoList( itemsList, UR_DELETED );
GetScreen()->SetModify();
test_1_net_connexion( DC, net_code_delete );
GetBoard()->DisplayInfo( this );
}
/********************************************************************/
void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
/********************************************************************/
/* 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
/* Remove 1 track:
* The leading segment is removed and all adjacent segments
* until a pad or a junction point of more than 2 segments is found
*/
void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
{
int segments_to_delete_count;
if( pt_segm == NULL )
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 )
return;
int net_code = pt_segm->GetNet();
PICKED_ITEMS_LIST itemsList;
ITEM_PICKER picker(NULL,UR_DELETED);
ITEM_PICKER picker( NULL, UR_DELETED );
int ii = 0;
TRACK* tracksegment = trackList;
TRACK * next_track;
TRACK* next_track;
for( ; ii < segments_to_delete_count; ii++, tracksegment = next_track )
{
next_track = tracksegment->Next();
tracksegment->SetState( BUSY, OFF );
D(printf("%s: track %p status=\"%s\"\n", __func__, tracksegment,
CONV_TO_UTF8( TRACK::ShowState( tracksegment->GetState(-1)) )
);)
D( printf( "%s: track %p status=\"%s\"\n", __func__, tracksegment,
CONV_TO_UTF8( TRACK::ShowState( tracksegment->GetState( -1 ) ) )
); )
GetBoard()->m_Track.Remove( tracksegment );
// redraw the area where the track was
DrawPanel->PostDirtyRect( tracksegment->GetBoundingBox() );
picker.m_PickedItem = tracksegment;
picker.m_PickedItemType = tracksegment->Type();
itemsList.PushItem(picker);
itemsList.PushItem( picker );
}
SaveCopyInUndoList( itemsList, UR_DELETED );
if ( net_code > 0 )
if( net_code > 0 )
test_1_net_connexion( DC, net_code );
}
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_svg_print.cpp
// Author: jean-pierre Charras
// Modified by:
......@@ -56,16 +55,15 @@ private:
void OnSetColorModeSelected( wxCommandEvent& event );
void SetPenWidth();
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
* et affiche la fenetre de dialogue de gestion de l'impression des feuilles
/* Prepare the data structures of print management
* And displays the dialog window management of printing sheets
*/
void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
{
DIALOG_SVG_PRINT frame( this );
......@@ -84,9 +82,7 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent ) :
}
/*************************************************************/
void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
/*************************************************************/
{
SetFocus(); // Make ESC key working
......@@ -99,7 +95,8 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
AddUnitSymbol( *m_TextPenWidth, g_UnitMetric );
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 );
......@@ -108,15 +105,22 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
int 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 )
m_BoxSelectLayer[layer]->SetValue( true );
if( layer < 16 )
m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer], 0, wxGROW | wxALL, 1 );
m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer],
0,
wxGROW | wxALL,
1 );
else
m_TechnicalBoxSizer->Add( m_BoxSelectLayer[layer], 0, wxGROW | wxALL, 1 );
m_TechnicalBoxSizer->Add( m_BoxSelectLayer[layer],
0,
wxGROW | wxALL,
1 );
}
if( m_Config )
......@@ -141,11 +145,10 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
}
/***********************************/
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 )
{
......@@ -158,13 +161,12 @@ void DIALOG_SVG_PRINT::SetPenWidth()
}
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 )
/***************************************************************************/
{
wxFileName fn;
wxString msg;
......@@ -176,9 +178,9 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref )
if( aPrintAll )
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;
fn = m_FileNameCtrl->GetValue();
......@@ -188,16 +190,15 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref )
}
if( aPrintAll )
fn.SetName( fn.GetName() + wxT("-brd") );
fn.SetName( fn.GetName() + wxT( "-brd" ) );
else
{
fn.SetName( fn.GetName() + wxT("-") +
m_BoxSelectLayer[layer]->GetLabel( ) );
fn.SetName( fn.GetName() + wxT( "-" ) +
m_BoxSelectLayer[layer]->GetLabel() );
m_PrintMaskLayer = 1 << layer;
if ( m_PrintBoardEdgesCtrl->IsChecked() )
if( m_PrintBoardEdgesCtrl->IsChecked() )
m_PrintMaskLayer |= EDGE_LAYER;
}
fn.SetExt( wxT( "svg" ) );
......@@ -209,20 +210,18 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref )
msg += wxT( "\n" );
m_MessagesBox->AppendText( msg );
if ( aPrintAll )
if( aPrintAll )
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;
wxPoint tmp_startvisu;
......@@ -231,7 +230,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre
float dpi;
bool success = true;
/* modification des cadrages et reglages locaux */
/* Change frames and local settings */
tmp_startvisu = screen->m_StartVisu;
tmpzoom = screen->GetZoom();
old_org = screen->m_DrawOrg;
......@@ -250,16 +249,20 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre
EDA_Rect tmp = panel->m_ClipBox;
GRResetPenAndBrush( &dc );
s_PrintPenMinWidth = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
s_PrintPenMinWidth = ReturnValueFromTextCtrl( *m_DialogPenWidth,
m_Parent->m_InternalUnits );
SetPenMinWidth( s_PrintPenMinWidth );
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : true );
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;
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 );
SetLocaleTo_Default(); // revert to the current locale
screen->m_IsPrinting = false;
......@@ -276,35 +279,27 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre
}
/********************************************************************/
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 );
}
/********************************************************************/
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 );
}
/******************************************************************/
void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event )
/******************************************************************/
{
Close();
}
/***********************************************************/
void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
/***********************************************************/
{
SetPenWidth();
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
......@@ -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
*/
void DIALOG_SVG_PRINT::OnSetColorModeSelected( wxCommandEvent& event )
{
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
}
/************************************************
* Module editor: Dialog box for editing module
* properties for the Board Editor
************************************************/
/******************************************************************************
* Module editor: Dialog box for editing module properties in the pcb editor. *
******************************************************************************/
#include "fctsys.h"
#include "common.h"
......@@ -17,11 +16,11 @@
#include "dialog_edit_module_for_BoardEditor.h"
/**************************************************************************************/
DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR( WinEDA_PcbFrame* aParent,
MODULE* aModule, wxDC* aDC ) :
DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR(
WinEDA_PcbFrame* aParent,
MODULE* aModule,
wxDC* aDC ) :
DIALOG_MODULE_BOARD_EDITOR_BASE( aParent )
/**************************************************************************************/
{
m_Parent = aParent;
m_DC = aDC;
......@@ -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()
/***************************************************************************/
/* 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 );
PutValueInLocalUnits( *m_ModPositionY, m_CurrentModule->GetPosition().y, PCB_INTERNAL_UNIT );
PutValueInLocalUnits( *m_ModPositionY,
m_CurrentModule->GetPosition().y, PCB_INTERNAL_UNIT );
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;
switch( m_CurrentModule->m_Orient )
......@@ -76,16 +74,16 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
break;
case 900:
case - 2700:
case -2700:
m_OrientCtrl->SetSelection( 1 );
break;
case - 900:
case -900:
case 2700:
m_OrientCtrl->SetSelection( 2 );
break;
case - 1800:
case -1800:
case 1800:
m_OrientCtrl->SetSelection( 3 );
break;
......@@ -112,33 +110,35 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
PutValueInLocalUnits( *m_SolderMaskMarginCtrl,
m_CurrentModule->m_LocalSolderMaskMargin,
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,
m_CurrentModule->m_LocalSolderPasteMargin,
internalUnit );
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 )
msg.Printf( wxT( "-%.1f" ), m_CurrentModule->m_LocalSolderPasteMarginRatio * 100.0 );
msg.Printf( wxT( "-%.1f" ),
m_CurrentModule->m_LocalSolderPasteMarginRatio * 100.0 );
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 );
}
/**********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
/**********************************************************************/
{
EndModal( -1 );
}
/************************************************************************/
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_Parent->GetScreen()->SetModify();
......@@ -148,9 +148,7 @@ void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event )
}
/**********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event )
/**********************************************************************/
{
m_Parent->InstallExchangeModuleFrame( m_CurrentModule );
......@@ -160,9 +158,7 @@ void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event )
}
/*************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event )
/*************************************************************************/
{
switch( m_OrientCtrl->GetSelection() )
{
......@@ -194,9 +190,7 @@ void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event )
}
/*******************************************************/
void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
/*******************************************************/
{
SetFocus();
......@@ -226,13 +220,12 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
#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,
_(
"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,
_(
"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
/* Controls on right side of the dialog */
......@@ -258,8 +251,10 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
m_AutoPlaceCtrl->SetSelection(
(m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 );
#if wxCHECK_VERSION( 2, 8, 0 )
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 0,
_( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1,
_( "Disable hotkey move commands and Auto Placement" ) );
#endif
m_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 );
......@@ -268,22 +263,26 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
// Initialize 3D parameters
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 );
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 );
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 );
}
/* 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 )
{
......@@ -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
* @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() )
return;
......@@ -317,15 +317,15 @@ void DIALOG_MODULE_BOARD_EDITOR::TransfertDisplayTo3DValues( int aIndexSelection
}
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event )
/***********************************************************/
{
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
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;
if( m_LastSelected3DShapeIndex >= (int) m_Shapes3D_list.size() )
......@@ -338,17 +338,13 @@ void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event )
}
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::Add3DShape( wxCommandEvent& event )
/***********************************************************/
{
Browse3DLib( event );
}
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event )
/***********************************************************/
{
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
......@@ -366,14 +362,13 @@ void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event )
{
m_LastSelected3DShapeIndex = 0;
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 )
/*********************************************************************/
{
wxString fullfilename, shortfilename;
wxString fullpath;
......@@ -385,10 +380,10 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
fullfilename = EDA_FileSelector( _( "3D Shape:" ),
fullpath, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_Shapes3DExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
fullpath,
wxEmptyString,
g_Shapes3DExtBuffer,
mask,
this,
wxFD_OPEN,
TRUE
......@@ -404,9 +399,11 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* 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 );
new3DShape->m_Shape3DName = shortfilename;
m_Shapes3D_list.push_back( new3DShape );
......@@ -421,15 +418,14 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
}
/******************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
/******************************************************************************/
{
bool change_layer = FALSE;
wxPoint modpos;
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 );
if( m_DC )
......@@ -440,15 +436,20 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
// Initialize masks clearances
m_CurrentModule->m_LocalClearance =
ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, m_Parent->m_InternalUnits );
ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl,
m_Parent->m_InternalUnits );
m_CurrentModule->m_LocalSolderMaskMargin =
ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->m_InternalUnits );
ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl,
m_Parent->m_InternalUnits );
m_CurrentModule->m_LocalSolderPasteMargin =
ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->m_InternalUnits );
ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl,
m_Parent->m_InternalUnits );
double dtmp;
msg = m_SolderPasteMarginRatioCtrl->GetValue();
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 )
dtmp = -50;
m_CurrentModule->m_LocalSolderPasteMarginRatio = dtmp / 100;
......@@ -463,7 +464,8 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
msg = m_OrientValue->GetValue();
msg.ToLong( &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
{
......@@ -554,9 +556,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
}
/***********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event )
/***********************************************************************/
{
wxPoint tmp = m_Parent->GetScreen()->m_Curseur;
......@@ -568,9 +568,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event )
}
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event )
/***********************************************************/
{
wxPoint tmp = m_Parent->GetScreen()->m_Curseur;
......
......@@ -257,10 +257,10 @@ void DIALOG_MODULE_MODULE_EDITOR::Browse3DLib( wxCommandEvent& event )
fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
fullfilename = EDA_FileSelector( _( "3D Shape:" ),
fullpath, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_Shapes3DExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
fullpath,
wxEmptyString,
g_Shapes3DExtBuffer,
mask,
this,
wxFD_OPEN,
TRUE
......
......@@ -2,10 +2,11 @@
// Name: dialog_general_options.cpp
// Author: jean-pierre Charras
/////////////////////////////////////////////////////////////////////////////
/* functions relatives to the dialogs opened from the main menu :
Preferences/general
Preferences/display
*/
* Preferences/general
* Preferences/display
*/
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
......@@ -18,20 +19,17 @@
#include "pcbnew_id.h"
/***********************************************************************************/
Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent, wxDC* DC ) :
Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent,
wxDC* DC ) :
DialogGeneralOptionsBoardEditor_base( parent )
/***********************************************************************************/
{
m_Parent = parent;
m_DC = DC;
init();
}
/********************************************************************/
void Dialog_GeneralOptions::init()
/********************************************************************/
{
SetFocus();
......@@ -43,17 +41,18 @@ void Dialog_GeneralOptions::init()
wxString timevalue;
timevalue << g_TimeOut / 60;
m_SaveTime->SetValue( timevalue );
/*
int layer_count[] = {1,2,4,6,8,10,12,14,16};
m_LayerNumber->SetSelection(1);
for ( unsigned ii = 0; ii < sizeof(layer_count); ii++ )
{
if ( g_DesignSettings.m_CopperLayerCount != layer_count[ii] )
continue;
m_LayerNumber->SetSelection(ii);
break;
}
*/
* int layer_count[] = {1,2,4,6,8,10,12,14,16};
* m_LayerNumber->SetSelection(1);
* for ( unsigned ii = 0; ii < sizeof(layer_count); ii++ )
* {
* if ( g_DesignSettings.m_CopperLayerCount != layer_count[ii] )
* continue;
* m_LayerNumber->SetSelection(ii);
* break;
* }
*/
m_MaxShowLinks->SetValue( g_MaxLinksShowed );
m_DrcOn->SetValue( Drc_On );
......@@ -76,39 +75,34 @@ void Dialog_GeneralOptions::init()
}
/*****************************************************************/
void Dialog_GeneralOptions::OnCancelClick( wxCommandEvent& event )
/*****************************************************************/
{
event.Skip();
}
/**************************************************************************/
void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
/**************************************************************************/
{
int ii;
DisplayOpt.DisplayPolarCood =
(m_PolarDisplay->GetSelection() == 0) ? FALSE : true;
( m_PolarDisplay->GetSelection() == 0 ) ? FALSE : true;
ii = g_UnitMetric;
g_UnitMetric = (m_UnitsSelection->GetSelection() == 0) ? 0 : 1;
g_UnitMetric = ( m_UnitsSelection->GetSelection() == 0 ) ? 0 : 1;
if( ii != g_UnitMetric )
m_Parent->ReCreateAuxiliaryToolbar();
m_Parent->m_CursorShape = m_CursorShape->GetSelection();
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();
Drc_On = m_DrcOn->GetValue();
if( g_Show_Ratsnest != m_ShowGlobalRatsnest->GetValue() )
{
g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue();
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_AutoDeleteOldTrack = m_TrackAutodel->GetValue();
......@@ -126,14 +120,12 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
#include "dialog_graphic_items_options.cpp"
/*****************************************************************/
void WinEDA_PcbFrame::InstallPcbOptionsFrame( const wxPoint& pos,
wxDC* DC, int id )
/*****************************************************************/
{
switch( id )
{
case ID_PCB_DRAWINGS_WIDTHS_SETUP:
{
WinEDA_GraphicItemsOptionsDialog dlg( this );
......@@ -142,29 +134,24 @@ void WinEDA_PcbFrame::InstallPcbOptionsFrame( const wxPoint& pos,
break;
default:
wxMessageBox(wxT("InstallPcbOptionsFrame() id error"));
wxMessageBox( wxT( "InstallPcbOptionsFrame() id error" ) );
break;
}
}
/*******************************************************************/
void WinEDA_ModuleEditFrame::InstallOptionsFrame( const wxPoint& pos )
/*******************************************************************/
{
WinEDA_GraphicItemsOptionsDialog dlg( this );
dlg.ShowModal();
}
/*****************************************************************/
void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
/*****************************************************************/
/* Must be called on a click on the left toolbar (options toolbar
* Update variables according to the tools states
*/
void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
......@@ -177,7 +164,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_GRID:
m_Draw_Grid = m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_RATSNEST:
......@@ -186,7 +173,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc );
Ratsnest_On_Off( &dc );
RedrawActiveWindow( &dc, true);
RedrawActiveWindow( &dc, true );
}
break;
......@@ -201,7 +188,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
if( id == ID_TB_OPTIONS_SELECT_UNIT_INCH )
g_UnitMetric = INCHES;
m_TrackAndViasSizesList_Changed = true;
UpdateStatusBar(); /* Reaffichage des coord curseur */
UpdateStatusBar();
ReCreateAuxiliaryToolbar();
DisplayUnitsMsg();
break;
......@@ -209,7 +196,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_POLAR_COORD:
Affiche_Message( wxEmptyString );
DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id );
UpdateStatusBar(); /* Reaffichage des coord curseur */
UpdateStatusBar();
break;
case ID_TB_OPTIONS_SELECT_CURSOR:
......@@ -222,17 +209,17 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_ZONES:
DisplayOpt.DisplayZonesMode = 0;
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1;
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2;
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_PADS_SKETCH:
......@@ -244,7 +231,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
{
m_DisplayPadFill = DisplayOpt.DisplayPadFill = true;
}
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
......@@ -256,29 +243,32 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
{
m_DisplayViaFill = DisplayOpt.DisplayViaFill = true;
}
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill =
!m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
DisplayOpt.ContrastModeDisplay =
m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE:
g_DesignSettings.SetElementVisibility( MODULE_TEXT_NOV_VISIBLE,
m_OptionsToolBar->GetToolState( id ));
DrawPanel->Refresh( );
m_OptionsToolBar->GetToolState( id ) );
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1:
#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();
else
{
......@@ -291,7 +281,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
OnSize( SizeEv );
}
#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();
#endif
break;
......@@ -303,5 +293,4 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
}
SetToolbars();
}
/*************************************************/
/* dialog_graphic_items_options.cpp - Gestion des Options et Reglages */
/*************************************************/
/*
Affichage et modifications des parametres de travail de PcbNew
*/
/************************************/
/* dialog_graphic_items_options.cpp */
/************************************/
#include "fctsys.h"
......@@ -24,57 +20,54 @@
#include <wx/spinctrl.h>
/**************************************************************/
void WinEDA_GraphicItemsOptionsDialog::SetDisplayValue()
/**************************************************************/
{
/* Drawings width */
AddUnitSymbol(*m_GraphicSegmWidthTitle);
PutValueInLocalUnits(*m_OptPcbSegmWidth,
g_DesignSettings.m_DrawSegmentWidth, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_GraphicSegmWidthTitle );
PutValueInLocalUnits( *m_OptPcbSegmWidth,
g_DesignSettings.m_DrawSegmentWidth,
PCB_INTERNAL_UNIT );
/* Edges width */
AddUnitSymbol(*m_BoardEdgesWidthTitle);
PutValueInLocalUnits(*m_OptPcbEdgesWidth,
g_DesignSettings.m_EdgeSegmentWidth, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_BoardEdgesWidthTitle );
PutValueInLocalUnits( *m_OptPcbEdgesWidth,
g_DesignSettings.m_EdgeSegmentWidth,
PCB_INTERNAL_UNIT );
/* Pcb Textes (Size & Width) */
AddUnitSymbol(*m_CopperTextWidthTitle);
PutValueInLocalUnits(*m_OptPcbTextWidth,
AddUnitSymbol( *m_CopperTextWidthTitle );
PutValueInLocalUnits( *m_OptPcbTextWidth,
g_DesignSettings.m_PcbTextWidth, PCB_INTERNAL_UNIT );
AddUnitSymbol(*m_TextSizeVTitle);
PutValueInLocalUnits(*m_OptPcbTextVSize,
AddUnitSymbol( *m_TextSizeVTitle );
PutValueInLocalUnits( *m_OptPcbTextVSize,
g_DesignSettings.m_PcbTextSize.y, PCB_INTERNAL_UNIT );
AddUnitSymbol(*m_TextSizeHTitle);
PutValueInLocalUnits(*m_OptPcbTextHSize,
AddUnitSymbol( *m_TextSizeHTitle );
PutValueInLocalUnits( *m_OptPcbTextHSize,
g_DesignSettings.m_PcbTextSize.x, PCB_INTERNAL_UNIT );
/* Modules: Edges width */
AddUnitSymbol(*m_EdgeModWidthTitle);
PutValueInLocalUnits(*m_OptModuleEdgesWidth,
AddUnitSymbol( *m_EdgeModWidthTitle );
PutValueInLocalUnits( *m_OptModuleEdgesWidth,
ModuleSegmentWidth, PCB_INTERNAL_UNIT );
/* Modules: Texts: Size & width */
AddUnitSymbol(*m_TextModWidthTitle);
PutValueInLocalUnits(*m_OptModuleTextWidth,
AddUnitSymbol( *m_TextModWidthTitle );
PutValueInLocalUnits( *m_OptModuleTextWidth,
ModuleTextWidth, PCB_INTERNAL_UNIT );
AddUnitSymbol(*m_TextModSizeVTitle);
PutValueInLocalUnits(*m_OptModuleTextVSize,
AddUnitSymbol( *m_TextModSizeVTitle );
PutValueInLocalUnits( *m_OptModuleTextVSize,
ModuleTextSize.y, PCB_INTERNAL_UNIT );
AddUnitSymbol(*m_TextModSizeHTitle);
PutValueInLocalUnits(*m_OptModuleTextHSize,
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 =
ReturnValueFromTextCtrl( *m_OptPcbSegmWidth, PCB_INTERNAL_UNIT );
......@@ -96,7 +89,7 @@ void WinEDA_GraphicItemsOptionsDialog::AcceptOptions(wxCommandEvent& event)
ModuleTextSize.x =
ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT );
EndModal(1);
EndModal( 1 );
}
......@@ -113,32 +106,44 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_GraphicItemsOptionsDialog, wxDialog )
BEGIN_EVENT_TABLE( WinEDA_GraphicItemsOptionsDialog, wxDialog )
////@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_EVENT_TABLE()
/*!
* 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
*/
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
m_GraphicSegmWidthTitle = NULL;
......@@ -159,22 +164,25 @@ bool WinEDA_GraphicItemsOptionsDialog::Create( wxWindow* parent, wxWindowID id,
m_OptModuleTextVSize = NULL;
m_TextModSizeHTitle = NULL;
m_OptModuleTextHSize = NULL;
////@end WinEDA_GraphicItemsOptionsDialog member initialisation
////@begin WinEDA_GraphicItemsOptionsDialog creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
if( GetSizer() )
{
GetSizer()->SetSizeHints(this);
GetSizer()->SetSizeHints( this );
}
Centre();
////@end WinEDA_GraphicItemsOptionsDialog creation
return true;
}
/*!
* Control creation for WinEDA_GraphicItemsOptionsDialog
*/
......@@ -186,88 +194,212 @@ void WinEDA_GraphicItemsOptionsDialog::CreateControls()
WinEDA_GraphicItemsOptionsDialog* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Graphics:"));
wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL);
itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxGROW|wxALL, 5);
m_GraphicSegmWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Graphic segm Width"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add(m_GraphicSegmWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_OptPcbSegmWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_SEGW, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add(m_OptPcbSegmWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_BoardEdgesWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Board Edges Width"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add(m_BoardEdgesWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_OptPcbEdgesWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_EDGES, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add(m_OptPcbEdgesWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_CopperTextWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Copper Text Width"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add(m_CopperTextWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_OptPcbTextWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTW, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add(m_OptPcbTextWidth, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_TextSizeVTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Size V"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add(m_TextSizeVTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_OptPcbTextVSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTV, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add(m_OptPcbTextVSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 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);
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxHORIZONTAL );
itemDialog1->SetSizer( itemBoxSizer2 );
wxStaticBox* itemStaticBoxSizer3Static =
new wxStaticBox(itemDialog1, wxID_ANY, _( "Graphics:" ) );
wxStaticBoxSizer* itemStaticBoxSizer3 =
new wxStaticBoxSizer( itemStaticBoxSizer3Static, wxVERTICAL );
itemBoxSizer2->Add( itemStaticBoxSizer3, 0, wxGROW | wxALL, 5 );
m_GraphicSegmWidthTitle =
new wxStaticText( itemDialog1, wxID_STATIC, _( "Graphic segm Width" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_GraphicSegmWidthTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptPcbSegmWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_SEGW,
_T( "" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_OptPcbSegmWidth,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
m_BoardEdgesWidthTitle =
new wxStaticText( itemDialog1, wxID_STATIC, _( "Board Edges Width" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_BoardEdgesWidthTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptPcbEdgesWidth =
new wxTextCtrl( itemDialog1, ID_TEXTCTRL_EDGES, _T( "" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_OptPcbEdgesWidth,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
m_CopperTextWidthTitle =
new wxStaticText( itemDialog1, wxID_STATIC, _( "Copper Text Width" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_CopperTextWidthTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptPcbTextWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTW,
_T( "" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_OptPcbTextWidth,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
m_TextSizeVTitle = new wxStaticText( itemDialog1, wxID_STATIC,
_( "Text Size V" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_TextSizeVTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
wxADJUST_MINSIZE,
5 );
m_OptPcbTextVSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTV,
_T( "" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemStaticBoxSizer3->Add( m_OptPcbTextVSize,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
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
SetDisplayValue();
}
/*!
* Should we show tooltips?
*/
......@@ -277,19 +409,23 @@ bool WinEDA_GraphicItemsOptionsDialog::ShowToolTips()
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap WinEDA_GraphicItemsOptionsDialog::GetBitmapResource( const wxString& name )
wxBitmap WinEDA_GraphicItemsOptionsDialog::GetBitmapResource(
const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_GraphicItemsOptionsDialog bitmap retrieval
wxUnusedVar(name);
wxUnusedVar( name );
return wxNullBitmap;
////@end WinEDA_GraphicItemsOptionsDialog bitmap retrieval
}
/*!
* Get icon resources
*/
......@@ -298,29 +434,34 @@ wxIcon WinEDA_GraphicItemsOptionsDialog::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WinEDA_GraphicItemsOptionsDialog icon retrieval
wxUnusedVar(name);
wxUnusedVar( name );
return wxNullIcon;
////@end WinEDA_GraphicItemsOptionsDialog icon retrieval
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void WinEDA_GraphicItemsOptionsDialog::OnOkClick( wxCommandEvent& event )
{
AcceptOptions(event);
AcceptOptions( event );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
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.
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;
#define NBSHAPES 4
int CodeShape[NBSHAPES] = /* forme des pads */
int CodeShape[NBSHAPES] = /* Pad shapes. */
{
PAD_CIRCLE, PAD_OVAL, PAD_RECT, PAD_TRAPEZOID
};
......@@ -409,7 +409,7 @@ void DIALOG_PAD_PROPERTIES::SetPadLayersList( long layer_mask )
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;
......
/******************************************************/
/* Edition of footprint edges */
/******************************************************/
/* fichier edgemod.cpp */
/* Functions to edit graphic items used to draw footprint edges.
* Function to Arcs are not made (TODO..) but menus are ready to use
/****************************/
/* Footprint edges editing. */
/****************************/
/**
* Functions to edit graphic items used to draw footprint edges.
*
* @todo - Arc functions not compete but menus are ready to use.
*/
#include "fctsys.h"
......@@ -19,23 +18,20 @@
#include "wxPcbStruct.h"
/* Routines Locales */
static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Variables locales : */
int ArcValue = 900;
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 )
return;
......@@ -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
*/
void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
{
if( Edge == NULL )
return;
......@@ -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 */
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
BASE_SCREEN* screen = panel->GetScreen();
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem();
......@@ -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
*/
static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
BASE_SCREEN* screen = panel->GetScreen();
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem();
......@@ -126,7 +114,7 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
Edge->m_End = screen->m_Curseur;
/* Mise a jour des coord relatives */
/* Update relative coordinate. */
Edge->m_End0 = Edge->m_End - Module->m_Pos;
RotatePoint( &Edge->m_End0, -Module->m_Orient );
......@@ -136,9 +124,7 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
}
/***************************************************************************/
void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge )
/***************************************************************************/
{
MODULE* Module = GetBoard()->m_Modules;
......@@ -146,7 +132,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge )
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() )
{
if( Edge->Type() != TYPE_EDGE_MODULE )
......@@ -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)
* if Edge == NULL change the layer of the entire footprint edges
* @param Edge = edge to edit, or NULL
* @param DC = current Device Context
*/
*/
void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
{
MODULE* Module = GetBoard()->m_Modules;
int new_layer = SILKSCREEN_N_CMP;
if( Edge != NULL )
new_layer = Edge->GetLayer();
/* 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 )
return;
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( new_layer >= FIRST_COPPER_LAYER && new_layer <= LAST_COPPER_LAYER )
{
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;
}
......@@ -196,7 +185,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
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() )
{
if( Edge->Type() != TYPE_EDGE_MODULE )
......@@ -214,10 +203,6 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
}
/*************************************************************************/
void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC )
/*************************************************************************/
/* Edition of the edge items width
* Ask for a new width and init ModuleSegmentWidth.
* Change the width of EDGE_MODULE Edge if Edge != NULL
......@@ -225,12 +210,14 @@ void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC )
* @param DC = current Device Context
* @output ModuleSegmentWidth (global) = new width
*/
void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC )
{
wxString buffer;
long ll;
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;
if( buffer.ToLong( &ll ) )
......@@ -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
* delete EDGE_MODULE Edge
* @param Edge = edge to delete
*/
void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge )
{
if( Edge == NULL )
return;
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;
}
MODULE* Module = (MODULE*) Edge->GetParent();
/* suppression d'un segment */
Edge ->DeleteStructure();
/* Delete segment. */
Edge->DeleteStructure();
Module->m_LastEdit_Time = time( NULL );
Module->Set_Rectangle_Encadrement();
GetScreen()->SetModify();
}
/******************************************************************/
static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/
/* abort function in moving edge.
*/
*/
static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
{
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();
Edge->Draw( Panel, DC, GR_XOR, MoveVector );
Edge ->DeleteStructure();
Edge->DeleteStructure();
Module->Set_Rectangle_Encadrement();
}
else
......@@ -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 ..).
* @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 type_edge = S_SEGMENT,S_ARC ..
* @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;
int angle = 0;
......@@ -336,7 +319,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
/* Add the new item to the Drawings list head*/
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_Angle = angle;
Edge->m_Shape = type_edge;
......@@ -369,8 +352,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
DrawPanel->ManageCurseur = ShowEdgeModule;
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module;
}
/* trace en cours : les coord du point d'arrivee ont ete mises
/* TRANSLATE trace en cours : les coord du point d'arrivee ont ete mises
* a jour par la routine Montre_Position_New_Edge_Module
*/
else
......@@ -384,7 +366,8 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
EDGE_MODULE* newedge = new EDGE_MODULE( module );
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() );
Edge->m_Flags = 0;
......@@ -395,7 +378,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge->m_Start = GetScreen()->m_Curseur;
Edge->m_End = Edge->m_Start;
/* Mise a jour des coord relatives */
/* Update relative coordinate. */
Edge->m_Start0 = Edge->m_Start - module->m_Pos;
RotatePoint( &Edge->m_Start0, -module->m_Orient );
......@@ -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
*/
*/
void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
{
MODULE* Module = GetBoard()->m_Modules;
......@@ -427,7 +408,7 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
Edge->m_Flags = 0;
/* If last segment length is 0: remove it */
if( Edge->m_Start == Edge->m_End )
Edge ->DeleteStructure();
Edge->DeleteStructure();
}
Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL );
......
/******************************************************/
/* edit.cpp: fonctions generales de l'edition du PCB */
/******************************************************/
/**************************************/
/* edit.cpp: edit PCB implementation. */
/**************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -25,12 +25,8 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame,
EDA_BaseStruct* DrawStruct, wxDC* DC );
/*********************************************************************/
/* Handles the selection of command events. */
void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
/*********************************************************************/
/* Traite les selections d'outils et les commandes appelees du menu POPUP
*/
{
int id = event.GetId();
wxPoint pos;
......@@ -136,7 +132,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
break;
default: // Finish (abort ) the command
default: // Finish (abort) the command
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
......@@ -555,7 +551,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones.
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->m_FilledPolysList.clear();;
}
......@@ -969,10 +965,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
}
/****************************************************************/
static void Process_Move_Item( WinEDA_PcbFrame* frame,
EDA_BaseStruct* DrawStruct, wxDC* DC )
/****************************************************************/
{
if( DrawStruct == NULL )
return;
......@@ -996,9 +990,7 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame,
}
/***************************************************************/
void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
/***************************************************************/
{
if( Item == NULL )
return;
......@@ -1071,7 +1063,7 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
default:
{
wxString Line;
Line.Printf( wxT( "Remove: StructType %d Inattendu" ),
Line.Printf( wxT( "Remove: item type %d unknown." ),
Item->Type() );
DisplayError( this, Line );
}
......@@ -1080,9 +1072,7 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
}
/****************************************************************/
void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
/*****************************************************************/
{
int preslayer = GetScreen()->m_Active_Layer;
......@@ -1115,8 +1105,8 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
// layers are also capable of being selected.
else
{
if( (layer != COPPER_LAYER_N) && (layer != LAYER_CMP_N)
&& (layer >= GetBoard()->m_BoardSettings->GetCopperLayerCount() - 1) )
if( ( layer != COPPER_LAYER_N ) && ( layer != LAYER_CMP_N )
&& ( layer >= GetBoard()->m_BoardSettings->GetCopperLayerCount() - 1 ) )
{
// Uncomment following command (and line 17) to beep
// the speaker. (Doing that would provide feedback to
......@@ -1132,7 +1122,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
// See if we are drawing a segment; if so, add a via?
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 -
// see the implementation of Other_Layer_Route - the working
......
......@@ -13,23 +13,23 @@
#include "protos.h"
/* Local functions */
static void Move_Texte_Pcb( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
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
* (used to undo/redo/abort
* a complex edition command
*/
/*************************************************************/
void Abort_Edit_Pcb_Text( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/
/*
* Routine de sortie du menu edit texte Pcb
* Si un texte est selectionne, ses coord initiales sont regenerees
* Abort current text edit progress.
*
* If a text is selected, its initial coord are regenerated
*/
void Abort_Edit_Pcb_Text( WinEDA_DrawPanel* Panel, wxDC* DC )
{
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
......@@ -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
*/
void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
{
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
......@@ -81,7 +78,8 @@ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
}
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
{
// Restore initial params
......@@ -96,12 +94,9 @@ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
}
/***********************************************************************/
void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC )
/***********************************************************************/
/* Initialise parameters to move a pcb text
/* Initialize parameters to move a pcb text
*/
void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC )
{
if( TextePcb == NULL )
return;
......@@ -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 )
/*************************************************************************/
/* Routine deplacant le texte PCB suivant le curseur de la souris */
{
TEXTE_PCB* TextePcb = (TEXTE_PCB*) panel->GetScreen()->GetCurItem();
if( TextePcb == NULL )
return;
/* effacement du texte : */
if( erase )
TextePcb->Draw( panel, DC, GR_XOR );
TextePcb->m_Pos = panel->GetScreen()->m_Curseur;
/* Redessin du Texte */
TextePcb->Draw( panel, DC, GR_XOR );
}
/**********************************************************************/
void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
/**********************************************************************/
{
if( TextePcb == NULL )
return;
......@@ -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* TextePcb;
TextePcb = new TEXTE_PCB( GetBoard() );
/* Chainage de la nouvelle structure en debut de liste */
/* Add text to the board item list. */
GetBoard()->Add( TextePcb );
/* Mise a jour des caracteristiques */
/* Update text properties. */
TextePcb->m_Flags = IS_NEW;
TextePcb->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
TextePcb->m_Mirror = false;
......@@ -194,9 +180,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC )
}
/***********************************************************************/
void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
/***********************************************************************/
{
int angle = 900;
int drawmode = GR_XOR;
......@@ -204,13 +188,13 @@ void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
if( TextePcb == NULL )
return;
/* effacement du texte : */
/* Erase previous text. */
TextePcb->Draw( DrawPanel, DC, GR_XOR );
TextePcb->m_Orient += angle;
NORMALIZE_ANGLE( TextePcb->m_Orient );
/* Redessin du Texte */
/* Redraw text in new position. */
TextePcb->Draw( DrawPanel, DC, drawmode );
TextePcb->DisplayInfo( this );
if( TextePcb->m_Flags == 0 ) // i.e. not edited, or moved
......
/******************************************************/
/* Edition des contours du pcb: Routines */
/* d'effacement et d'edition de segments et contours */
/* du type PCB, draw, edgePCB */
/******************************************************/
/***********************************/
/* Edit segments and edges of PCB. */
/***********************************/
#include "fctsys.h"
#include "common.h"
......@@ -15,21 +13,18 @@
#include "protos.h"
/* Routines Locales */
static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Montre_Position_NewSegment( 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
/****************************************************************************/
void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
/****************************************************************************/
static wxPoint s_InitialPosition; // Initial cursor position.
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 )
return;
......@@ -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 )
return;
......@@ -64,14 +56,12 @@ void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
drawitem->m_Flags = 0;
}
/************************************************************************/
/*
* Redraw segment during cursor movement.
*/
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*)
panel->GetScreen()->GetCurItem();
DRAWSEGMENT* Segment = (DRAWSEGMENT*) panel->GetScreen()->GetCurItem();
int t_fill = DisplayOpt.DisplayDrawItems;
if( Segment == NULL )
......@@ -79,7 +69,6 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
DisplayOpt.DisplayDrawItems = SKETCH;
/* efface ancienne position */
if( erase )
Segment->Draw( panel, DC, GR_XOR );
......@@ -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 )
/**************************************************************************/
{
EDA_BaseStruct* PtStruct;
int track_fill_copy = DisplayOpt.DisplayDrawItems;
......@@ -104,9 +91,9 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
if( Segment == NULL )
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;
Segment->Draw( DrawPanel, DC, GR_XOR );
PtStruct = Segment->Back();
......@@ -116,7 +103,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
DisplayOpt.DisplayDrawItems = track_fill_copy;
SetCurItem( NULL );
}
else if( Segment->m_Flags == 0)
else if( Segment->m_Flags == 0 )
{
Segment->Draw( DrawPanel, DC, GR_XOR );
Segment->m_Flags = 0;
......@@ -128,13 +115,11 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
}
/******************************************************************************/
void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer )
/******************************************************************************/
{
if( aLayer <= LAST_COPPER_LAYER )
{
DisplayError( this, _( "Copper layer global delete not allowed!" ), 20 );
DisplayError( this, _( "Copper layer global delete not allowed!" ) );
return;
}
......@@ -160,14 +145,15 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer )
{
item->UnLink();
picker.m_PickedItem = item;
pickList.PushItem(picker);
pickList.PushItem( picker );
}
break;
default:
{
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 );
break;
}
......@@ -182,9 +168,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer )
}
/*************************************************************/
static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/
{
DRAWSEGMENT* Segment = (DRAWSEGMENT*) Panel->GetScreen()->GetCurItem();
......@@ -208,17 +192,14 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
}
Panel->ManageCurseur = 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,
int shape, wxDC* DC )
/**********************************************************************/
/* Routine d'initialisation du trace d'un segment de type autre que piste
*/
{
int s_large;
int angle = 0;
......@@ -233,7 +214,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
if( shape == S_ARC )
angle = 900;
if( Segment == NULL ) /* debut reel du trace */
if( Segment == NULL ) /* Create new trace. */
{
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
Segment->m_Flags = IS_NEW;
......@@ -245,8 +226,8 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
DrawPanel->ManageCurseur = Montre_Position_NewSegment;
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge;
}
else /* trace en cours : les coord du point d'arrivee ont ete mises
* a jour par la routine Montre_Position_NewSegment*/
else /* TRANSLATE trace en cours : les coord du point d'arrivee ont
* ete mises a jour par la routine Montre_Position_NewSegment*/
{
if( Segment->m_Start != Segment->m_End )
{
......@@ -284,16 +265,14 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
}
/***************************************************************/
void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
/***************************************************************/
{
if( Segment == NULL )
return;
Segment->Draw( DrawPanel, DC, GR_OR );
/* Effacement si Longueur nulle */
if( Segment->m_Start == Segment->m_End)
/* Delete if segment length is zero. */
if( Segment->m_Start == Segment->m_End )
Segment ->DeleteStructure();
else
......@@ -301,7 +280,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
Segment->m_Flags = 0;
GetBoard()->Add( Segment );
GetScreen()->SetModify();
SaveCopyInUndoList(Segment, UR_NEW );
SaveCopyInUndoList( Segment, UR_NEW );
}
DrawPanel->ManageCurseur = NULL;
......@@ -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,
wxDC* DC, bool erase )
/************************************************************/
/* redessin du contour du Segment Edge lors des deplacements de la souris */
{
DRAWSEGMENT* Segment = (DRAWSEGMENT*)
panel->GetScreen()->GetCurItem();
......@@ -325,16 +303,15 @@ static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel,
DisplayOpt.DisplayDrawItems = SKETCH;
/* efface ancienne position */
if( erase )
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,
&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;
}
......
/************************************************/
/* Module editor: Dialog box for editing module */
/* properties and carateristics */
/* properties and characteristics */
/************************************************/
#include "fctsys.h"
......@@ -14,12 +14,11 @@
#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 )
return;
......@@ -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;
EDA_BaseStruct* PtStruct;
......@@ -73,19 +69,19 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
pt_mod->m_Pos = GetScreen()->m_Curseur;
/* Mise a jour des coord relatives des elements:
* les coordonnees relatives sont relatives a l'ancre, pour orient 0.
* il faut donc recalculer deltaX et deltaY en orientation 0 */
/* Update the relative coordinates:
* The coordinates are relative to the anchor point.
* Calculate deltaX and deltaY from the anchor. */
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;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{
pt_pad->m_Pos0 += moveVector;
}
/* Mise a jour des coord relatives contours .. */
/* Update the draw element coordinates. */
PtStruct = pt_mod->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
......@@ -113,9 +109,7 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
}
/**********************************************************************/
void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item )
/**********************************************************************/
{
if( Item == NULL )
return;
......@@ -154,7 +148,7 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item )
default:
{
wxString Line;
Line.Printf( wxT( " Remove: StructType %d Inattendu" ),
Line.Printf( wxT( " Remove: draw item type %d unknown." ),
Item->Type() );
DisplayError( this, Line );
}
......
/*******************************/
/* Edition des pistes */
/* Routines de trace de pistes */
/* Edit tracks */
/*******************************/
#include "fctsys.h"
......@@ -15,22 +14,19 @@
#include "protos.h"
/***********************************************/
/* Displays or hides the ratsnest. */
void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC )
/***********************************************/
/* Affiche ou efface le chevelu selon l'etat du bouton d'appel */
{
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 )
Compile_Ratsnest( DC, TRUE );
return;
}
DrawGeneralRatsnest( DC, 0 ); /* effacement eventuel du chevelu affiche */
DrawGeneralRatsnest( DC, 0 );
if( GetBoard()->GetRatsnestsCount() == 0 )
return;
......@@ -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 :
* la piste doit etre sur une des couches de travail,
* elle est mise sur l'autre couche de travail, si cela est possible
* (ou si DRC = Off ).
* Exchange layer the track pointed to by the mouse:
* The track must be on one layer of work,
* It is put on another layer of work, if possible
* (Or DRC = Off).
*/
void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
{
int ii;
TRACK* pt_track;
int l1, l2, nb_segm;
if( (pt_segm == NULL ) || ( pt_segm->Type() == TYPE_ZONE ) )
if( ( pt_segm == NULL ) || ( pt_segm->Type() == TYPE_ZONE ) )
{
return;
}
......@@ -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 );
Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_XOR );
/* effacement du flag BUSY et sauvegarde en membre .param de la couche
* initiale */
/* Clear the BUSY flag and backup member. Param layer original. */
ii = nb_segm; pt_segm = pt_track;
for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Next() )
{
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;
......@@ -92,7 +84,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
if( pt_segm->Type() == TYPE_VIA )
continue;
/* inversion des couches */
/* Invert layers. */
if( pt_segm->GetLayer() == l1 )
pt_segm->SetLayer( l2 );
else if( pt_segm->GetLayer() == l2 )
......@@ -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 ) )
{
/* Annulation du changement */
ii = 0; pt_segm = pt_track;
/* Discard changes. */
ii = 0;
pt_segm = pt_track;
for( ; ii < nb_segm; ii++, pt_segm = pt_segm->Next() )
{
pt_segm->SetLayer( pt_segm->m_Param );
}
Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR );
DisplayError( this, _( "Drc error, cancelled" ), 10 );
DisplayError( this, _( "Drc error, canceled" ), 10 );
return;
}
}
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;
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 )
}
/****************************************************************/
bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
/****************************************************************/
{
unsigned itmp;
if( aTrack == NULL )
{
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer !=
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
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();
SetToolbars();
......@@ -148,12 +142,14 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
}
/* 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;
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;
}
......@@ -164,15 +160,17 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
/* DRC error, the change layer is not made */
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;
}
}
/* 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();
Begin_Route( g_CurrentTrackSegment, 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;
int old_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
//swap the layers.
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
// swap the layers.
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer !=
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
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 */
switch ( via->Shape() )
{
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() );
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 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_N_2;
else if ( old_layer == LAYER_CMP_N )
......@@ -213,7 +215,8 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
else if ( old_layer == GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_CMP_N;
// 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() );
via->m_Width = net->GetMicroViaSize();
......@@ -269,10 +272,11 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
* 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,
* and the end point is the cursor which also is on the via (will change when moving mouse)
/* the start point is the via position and the end point is the cursor
* which also is on the via (will change when moving mouse)
*/
track->m_Start = track->m_End = via->m_Start;
......@@ -295,19 +299,18 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
}
/*************************************************/
void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
/*************************************************/
/* 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
/* Displays:
* The status of the net on top of the screen segment advanced by mouse.
* PCB status or bottom of screen if no segment peak.
*/
void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
{
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 )
GetBoard()->DisplayInfo( this );
else
......@@ -315,15 +318,12 @@ void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
}
/**********************************************************************/
void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
/**********************************************************************/
/* 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
/* Draw ratsnest.
*
* The net edge pad with mouse or module locates the mouse.
* Delete if the ratsnest if no module or pad is selected.
*/
void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
{
D_PAD* pt_pad = NULL;
MODULE* Module = NULL;
......@@ -331,7 +331,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
if( g_Show_Ratsnest )
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 );
if( item )
......@@ -342,7 +342,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
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 );
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
......@@ -350,13 +350,13 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii];
if( net->GetNet() == pt_pad->GetNet() )
{
if( (net->m_Status & CH_VISIBLE) != 0 )
if( ( net->m_Status & CH_VISIBLE ) != 0 )
continue;
net->m_Status |= CH_VISIBLE;
if( (net->m_Status & CH_ACTIF) == 0 )
if( ( net->m_Status & CH_ACTIF ) == 0 )
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 )
{
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();
}
else if( item->Type() == TYPE_MODULE )
......@@ -378,10 +379,12 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
pt_pad = Module->m_Pads;
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];
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 )
continue;
......@@ -390,7 +393,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
if( (net->m_Status & CH_ACTIF) == 0 )
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 )
}
}
/* Effacement complet des selections si aucun pad ou module n'a ete localise */
if( (pt_pad == NULL) && (Module == NULL) )
/* Erase if no pad or module has been selected. */
if( ( pt_pad == NULL ) && ( Module == NULL ) )
{
DrawGeneralRatsnest( DC );
......@@ -411,12 +414,9 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
}
/*****************************************************/
void WinEDA_PcbFrame::Affiche_PadsNoConnect( wxDC* DC )
/*****************************************************/
/* Hight light the unconnected pads
/* High light the unconnected pads
*/
void WinEDA_PcbFrame::Affiche_PadsNoConnect( wxDC* DC )
{
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
{
......
/*******************************/
/* Edition des pistes */
/* Routines de trace de pistes */
/*******************************/
/****************/
/* Edit traces. */
/****************/
#include "fctsys.h"
#include "common.h"
......@@ -16,7 +15,7 @@
#include "protos.h"
/* Routines Locales */
static void Exit_Editrack( WinEDA_DrawPanel* panel, wxDC* DC );
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC, bool erase );
......@@ -25,19 +24,16 @@ static void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList );
static void EnsureEndTrackOnPad( D_PAD* Pad );
/* variables locales */
static int OldNetCodeSurbrillance;
static int OldEtatSurbrillance;
static PICKED_ITEMS_LIST s_ItemsListPicker;
/************************************************************/
static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
/************************************************************/
/* routine d'annulation de la Commande Begin_Route si une piste est en cours
* de tracage, ou de sortie de l'application EDITRACK.
/* Routine to cancel the route if a track is being drawn, or exit the
* application EDITRACK.
*/
static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
{
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) Panel->m_Parent;
TRACK* track = (TRACK*) frame->GetCurItem();
......@@ -55,7 +51,8 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
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 );
s_ItemsListPicker.ClearListAndDeleteItems();
......@@ -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
* nouveau point piste
* Begin drawing a new track and/or establish of a new track point.
*
* Si pas de piste en cours de trace:
* - Recherche de netname de la nouvelle piste ( pad de depart out netname
* de la piste si depart sur une ancienne piste
* - Met en surbrillance tout le net
* - Initilise les divers pointeurs de trace
* Si piste en cours:
* - controle DRC
* - si DRC OK : addition d'un nouveau point piste
* If no current track record of:
* - Search netname of the new track (pad out departure netname
* if the departure runway on an old track
* - Highlight all the net
* - Initialize the various trace pointers.
* If current track:
* - Control DRC
* - OK if DRC: adding a new track.
*/
TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
{
D_PAD* pt_pad = 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;
wxPoint pos = GetScreen()->m_Curseur;
......@@ -99,7 +93,9 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
if( aTrack == NULL ) /* Starting a new track */
{
// Prepare the undo command info
s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but...
s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be
// necessary,
// but...
/* erase old highlight */
OldNetCodeSurbrillance = g_HightLigth_NetCode;
......@@ -130,12 +126,17 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
{
TrackOnStartPoint = (TRACK*) LockPoint;
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 =
GetBoard()->HitTestForAnyFilledArea( pos,
GetScreen()->
m_Active_Layer );
if( zone )
......@@ -196,37 +197,44 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
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;
}
}
}
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: */
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;
// We must 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 NULL;
}
}
/* Current track is Ok: current segment is kept, and a new one is created
* unless the current segment is null, or 2 last are null if a 2 segments track build
/* Current track is Ok: current segment is kept, and a new one is
* created unless the current segment is null, or 2 last are null
* if a 2 segments track build.
*/
bool CanCreateNewSegment = true;
if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() )
CanCreateNewSegment = false;
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull()
&& g_CurrentTrackSegment->Back() && g_CurrentTrackSegment->Back()->IsNull() )
&& g_CurrentTrackSegment->Back()
&& g_CurrentTrackSegment->Back()->IsNull() )
CanCreateNewSegment = false;
if( CanCreateNewSegment )
......@@ -251,7 +259,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
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 )
{
oneBeforeLatest->SetState( END_ONPAD, ON );
......@@ -281,31 +290,28 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
}
/**************************************************************************/
bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
/***************************************************************************/
/* rectifie un virage a 90 et le modifie par 2 coudes a 45
* n'opere que sur des segments horizontaux ou verticaux.
/* Correct a bend is 90 and changes by 2 elbows at 45
* This only works on horizontal or vertical segments.
*
* entree : pointeur sur le segment qui vient d'etre trace
* On suppose que le segment precedent est celui qui a ete
* precedement trace
* retourne:
* 1 si ok
* 0 si impossible
* Input: pointer to the segment that we have drawn
* Assume that the preceding segment is one that has been
* previously drawn
* Returns:
* 1 if ok
* 0 if not
*/
bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
{
int pas_45;
int dx0, dy0, dx1, dy1;
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* 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 )
{
return false;
......@@ -318,21 +324,21 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
while( pas_45 < curTrack->m_Width )
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;
dy0 = prevTrack->m_End.y - prevTrack->m_Start.y;
dx1 = curTrack->m_End.x - curTrack->m_Start.x;
dy1 = curTrack->m_End.y - curTrack->m_Start.y;
// les segments doivent etre de longueur suffisante:
if( MAX( abs( dx0 ), abs( dy0 ) ) < (pas_45 * 2) )
// Segments must be of sufficient length.
if( MAX( abs( dx0 ), abs( dy0 ) ) < ( pas_45 * 2 ) )
return false;
if( MAX( abs( dx1 ), abs( dy1 ) ) < (pas_45 * 2) )
if( MAX( abs( dx1 ), abs( dy1 ) ) < ( pas_45 * 2 ) )
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();
newTrack->m_Start = prevTrack->m_End;
......@@ -340,16 +346,16 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
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;
return false;
}
/* Calcul des coordonnees du point de raccord :
* le nouveau segment raccorde le 1er segment Vertical
* au 2eme segment Horizontal */
/* Calculate coordinates the connection point.
* The new segment connects the 1st segment Vertical and the 2nd
* horizontal segment.
*/
if( dy0 > 0 )
newTrack->m_Start.y -= pas_45;
else
......@@ -360,7 +366,7 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
else
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;
return false;
......@@ -373,20 +379,18 @@ bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
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;
return false;
}
// Segments a 90
/* Modif des coordonnees du point de raccord :
* un nouveau segment a ete cree, raccordant le 1er segment Horizontal
* au 2eme segment Vertical */
/* Calculate the coordinates of the point of connection:
* A new segment has been established, connecting segment 1
* (horizontal) and segment 2 (vertical)
*/
if( dx0 > 0 )
newTrack->m_Start.x -= pas_45;
else
......@@ -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 )
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;
/* Sauvegarde des coord du point terminal de la piste */
......@@ -438,9 +441,9 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
if( Begin_Route( aTrack, DC ) == NULL )
return;
ShowNewTrackWhenMovingCursor( DrawPanel, DC, true ); /* mise a jour trace reel */
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false ); /* efface trace piste*/
trace_ratsnest_pad( DC ); /* efface trace chevelu*/
ShowNewTrackWhenMovingCursor( DrawPanel, DC, true );
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false );
trace_ratsnest_pad( DC );
/* cleanup
* if( g_CurrentTrackSegment->Next() != NULL )
......@@ -453,27 +456,27 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
D( g_CurrentTrackList.VerifyListIntegrity(); );
/* La piste est ici non chainee a la liste des segments de piste.
* Il faut la replacer dans la zone de net,
* le plus pres possible du segment d'attache ( ou de fin ), car
* ceci contribue a la reduction du temps de calcul */
/* The track here is non chained to the list of track segments.
* It must be seen in the area of net
* As close as possible to the segment base (or end), because
* 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 );
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 )
{
EnsureEndTrackOnPad( (D_PAD*) LockPoint );
}
else /* la fin de la piste est sur une autre piste: il faudra
* peut-etre creer un point d'ancrage */
else /* End of is on a different track, it will
* possibly create an anchor. */
{
TRACK* adr_buf = (TRACK*) LockPoint;
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,
adr_buf,
g_CurrentTrackSegment,
......@@ -484,16 +487,19 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
// Delete Null segments:
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 )
{
int netcode = g_FirstTrackSegment->GetNet();
TRACK* firstTrack = g_FirstTrackSegment;
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* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( GetBoard() );
TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint(
GetBoard() );
while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
{
ITEM_PICKER picker( track, UR_NEW );
......@@ -518,9 +524,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
EraseRedundantTrack( DC, firstTrack, newCount, &s_ItemsListPicker );
}
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 );
GetScreen()->SetModify();
......@@ -568,7 +575,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
continue;
/* 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 vec = track->m_End - track->m_Start;
......@@ -580,7 +588,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
/* prefer intrusions from the side, not the end */
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;
}
}
......@@ -607,7 +616,7 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
*/
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 cv, vec, n;
TRACK* track = g_CurrentTrackSegment;
......@@ -634,7 +643,10 @@ static void PushTrack( WinEDA_DrawPanel* panel )
if( !det )
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.
......@@ -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
*/
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase )
{
D( g_CurrentTrackList.VerifyListIntegrity(); );
......@@ -685,17 +696,22 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
/* Erase old track */
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 );
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,
g_CurrentTrackSegment->m_End.y,
(netclass->GetViaDiameter() / 2) + netclass->GetClearance(),
( netclass->GetViaDiameter() / 2 ) + netclass->GetClearance(),
color );
}
}
......@@ -716,7 +732,8 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
previous_track->SetLayer( screen->m_Active_Layer );
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
if( Drc_On )
PushTrack( panel );
ComputeBreakPoint( g_CurrentTrackSegment, g_CurrentTrackList.GetCount(),
ComputeBreakPoint( g_CurrentTrackSegment,
g_CurrentTrackList.GetCount(),
g_CurrentTrackSegment->m_End );
}
else
{
/* Calcul de l'extremite de la piste pour orientations permises:
* horiz,vertical ou 45 degre
/* Calculate of the end of the path for the permitted directions:
* horizontal, vertical or 45 degrees.
*/
Calcule_Coord_Extremite_45( g_CurrentTrackSegment->m_Start.x,
g_CurrentTrackSegment->m_Start.y,
......@@ -743,28 +761,34 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
&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;
}
/* Redraw the new track */
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,
g_CurrentTrackSegment->m_End.y,
(netclass->GetViaDiameter() / 2) + netclass->GetClearance(),
( netclass->GetViaDiameter() / 2 ) + netclass->GetClearance(),
color );
}
/* Display info about currrent segment and the full new track:
* 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;
if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() )
......@@ -794,21 +818,17 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
}
/*****************************************************************/
void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
/*****************************************************************/
/* 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
/* Determine the coordinate to advanced the the current segment
* in 0, 90, or 45 degrees, depending on position of origin and
* cursor position.
*/
void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
{
int deltax, deltay, angle;
deltax = ActiveScreen->m_Curseur.x - ox;
deltay = ActiveScreen->m_Curseur.y - oy;
/* calcul de l'angle preferentiel : 0, 45 , 90 degre */
deltax = abs( deltax );
deltay = abs( deltay );
angle = 45;
......@@ -841,10 +861,10 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
deltax = MIN( deltax, deltay );
deltay = deltax;
/* recalcul des signes de deltax et deltay */
if( (ActiveScreen->m_Curseur.x - ox) < 0 )
/* Recalculate the signs fo deltax and deltaY. */
if( ( ActiveScreen->m_Curseur.x - ox ) < 0 )
deltax = -deltax;
if( (ActiveScreen->m_Curseur.y - oy) < 0 )
if( ( ActiveScreen->m_Curseur.y - oy ) < 0 )
deltay = -deltay;
*fx = ox + deltax;
......@@ -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.
*/
void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
{
int iDx = 0;
int iDy = 0;
......@@ -911,11 +928,11 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
switch( iAngle )
{
case - 1:
case -1:
break;
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;
else
track->m_End.x = end.x - iDy;
......@@ -926,10 +943,10 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
iDx = MIN( iDx, iDy );
iDy = iDx;
/* recalcul des signes de deltax et deltay */
if( (end.x - track->m_Start.x) < 0 )
/* Recalculate the signs fo deltax and deltaY. */
if( ( end.x - track->m_Start.x ) < 0 )
iDx = -iDx;
if( (end.y - track->m_Start.y) < 0 )
if( ( end.y - track->m_Start.y ) < 0 )
iDy = -iDy;
track->m_End.x = track->m_Start.x + iDx;
......@@ -937,7 +954,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
break;
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;
else
track->m_End.y = end.y - iDx;
......@@ -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
* return a pointer on the first segment (start of track list)
*/
void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
{
if( aTrackList.GetCount() == 0 )
return;
......@@ -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"
* if no, create a new track segment if necessary
* and move current (or new) end segment on pad
*/
void EnsureEndTrackOnPad( D_PAD* Pad )
{
if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok !
{
......
/*************************************************************/
/* Edition des Modules: Routines de modification des textes */
/* sur les MODULES */
/*************************************************************/
/* Fichier EDTXTMOD.CPP */
/********************/
/* Edi module text. */
/********************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -16,30 +13,31 @@
#include "protos.h"
/* Routines Locales */
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
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)
* Note there always are 2 texts: reference and value.
* 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;
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 )
Module->m_Drawings.PushFront( Text );
......@@ -48,7 +46,8 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
Text->m_Text = wxT( "text" );
ModuleTextWidth = Clamp_Text_PenSize( ModuleTextWidth,
MIN(ModuleTextSize.x, ModuleTextSize.y), true );
MIN( ModuleTextSize.x,
ModuleTextSize.y ), true );
Text->m_Size = ModuleTextSize;
Text->m_Width = ModuleTextWidth;
Text->m_Pos = GetScreen()->m_Curseur;
......@@ -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 )
/**************************************************************************/
/* Rotation de 90 du texte d'un module */
{
if( Text == NULL )
return;
MODULE* module = (MODULE*) Text->GetParent();
if( module && module->m_Flags == 0 && Text->m_Flags == 0 ) // simple rot command
{ // prepare undo command
if( module && module->m_Flags == 0 && Text->m_Flags == 0 ) // prepare undo
// command
{
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
......@@ -90,9 +89,7 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
while( Text->m_Orient >= 1800 )
Text->m_Orient -= 1800;
/* Redessin du Texte */
Text->Draw( DrawPanel, DC, GR_XOR, MoveVector );
Text->DisplayInfo( this );
if( module )
......@@ -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;
......@@ -119,8 +113,6 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
if( Text->m_Type == TEXT_is_DIVERS )
{
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
/* liberation de la memoire : */
Text->DeleteStructure();
GetScreen()->SetModify();
Module->m_LastEdit_Time = time( NULL );
......@@ -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
* Si un texte est selectionne, ses coord initiales sont regenerees
* Abort text move in progress.
*
* If a text is selected, its initial coordinates are regenerated.
*/
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
{
BASE_SCREEN* screen = Panel->GetScreen();
TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem();
......@@ -152,7 +143,7 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
// If the text was moved (the move does not change internal data)
// 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;
/* Redraw the text */
......@@ -168,12 +159,9 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
}
/****************************************************************************/
void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
/****************************************************************************/
/* Routine d'initialisation du deplacement d'un texte sur module
/* Start a text move.
*/
void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{
MODULE* Module;
......@@ -200,31 +188,28 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
}
/*************************************************************************/
void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
/*************************************************************************/
/* Routine complementaire a StartMoveTexteModule().
* Place le texte en cours de deplacement
/* Place the text a the cursor position when the left mouse button is clicked.
*/
void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{
if( Text != NULL )
{
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
/* mise a jour des coordonnes relatives a l'ancre */
/* Update the coordinates for anchor. */
MODULE* Module = (MODULE*) Text->GetParent();
if( Module )
{
// 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 )
SaveCopyInUndoList(Module, UR_CHANGED);
SaveCopyInUndoList( Module, UR_CHANGED );
else
SaveCopyInUndoList(Module, UR_MODEDIT);
EXCHG(Text->m_Orient, TextInitialOrientation);
SaveCopyInUndoList( Module, UR_MODEDIT );
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;
RotatePoint( &textRelPos, -Module->m_Orient );
Text->m_Pos0 = textRelPos;
......@@ -233,7 +218,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
Module->m_LastEdit_Time = time( NULL );
GetScreen()->SetModify();
/* Redessin du Texte */
/* Redraw text. */
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
}
else
......@@ -248,9 +233,8 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
}
/********************************************************************************/
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/********************************************************************************/
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase )
{
BASE_SCREEN* screen = panel->GetScreen();
TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem();
......@@ -258,7 +242,7 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
if( Text == NULL )
return;
/* Undraw the text : */
/* Undraw the text */
if( erase )
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 "common.h"
......@@ -29,25 +29,24 @@ static void FootprintWriteShape( FILE* File, MODULE* module );
static const wxString GenCAD_Layer_Name[32] =
{
wxT( "BOTTOM" ), wxT( "INNER1" ), wxT( "INNER2" ),
wxT(
"INNER3" ),
wxT( "INNER4" ), wxT( "INNER5" ), wxT( "INNER6" ), wxT(
"INNER7" ),
wxT( "INNER8" ), wxT( "INNER9" ), wxT( "INNER10" ), wxT(
"INNER11" ),
wxT( "INNER12" ), wxT( "INNER13" ), wxT( "INNER14" ), wxT( "TOP" ),
wxT( "adhecu" ), wxT( "adhecmp" ), wxT( "SOLDERPASTE_BOTTOM" ),wxT(
"SOLDERPASTE_TOP" ),
wxT( "SILKSCREEN_BOTTOM" ), wxT( "SILKSCREEN_TOP" ), wxT( "SOLDERMASK_BOTTOM" ), wxT(
"SOLDERMASK_TOP" ),
wxT( "drawings" ), wxT( "comments" ), wxT( "eco1" ), wxT( "eco2" ),
wxT( "edges" ), wxT( "--" ), wxT( "--" ), wxT( "--" )
wxT( "INNER3" ), wxT( "INNER4" ), wxT( "INNER5" ),
wxT( "INNER6" ), wxT( "INNER7" ), wxT( "INNER8" ),
wxT( "INNER9" ), wxT( "INNER10" ), wxT( "INNER11" ),
wxT( "INNER12" ), wxT( "INNER13" ), wxT( "INNER14" ),
wxT( "TOP" ), wxT( "adhecu" ), wxT( "adhecmp" ),
wxT( "SOLDERPASTE_BOTTOM" ), wxT( "SOLDERPASTE_TOP" ),
wxT( "SILKSCREEN_BOTTOM" ), wxT( "SILKSCREEN_TOP" ),
wxT( "SOLDERMASK_BOTTOM" ), wxT( "SOLDERMASK_TOP" ), wxT( "drawings" ),
wxT( "comments" ), wxT( "eco1" ), wxT( "eco2" ),
wxT( "edges" ), wxT( "--" ), wxT( "--" ),
wxT( "--" )
};
int offsetX, offsetY;
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 )
{
......@@ -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;
wxString msg, ext, wildcard;
......@@ -100,8 +96,8 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
DrawPanel->PrepareGraphicContext( &dc );
Compile_Ratsnest( &dc, TRUE );
/* Temporary modification of footprints that are flipped (i.e. on bottom layer)
* to convert them to non flipped footprints.
/* Temporary modification of footprints that are flipped (i.e. on bottom
* layer) to convert them to non flipped footprints.
* This is necessary to easily export shapes to GenCAD,
* that are given as normal orientation (non flipped, rotation = 0))
* these changes will be undone later
......@@ -128,7 +124,9 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
/* Create the shapes list
* (shapes of pads and footprints */
CreatePadsShapesSection( file, GetBoard() ); /* Must be called
* before CreatePadsStacksSection and
* before
* CreatePadsStacksSection
* and
* CreateShapesSection()
*/
CreatePadsStacksSection( file, GetBoard() );
......@@ -140,7 +138,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
/* Create the list of Nets: */
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() );
fclose( file );
......@@ -157,9 +155,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
}
/**************************************************************************/
static int Pad_list_Sort_by_Shapes( const void* refptr, const void* objptr )
/**************************************************************************/
{
const D_PAD* padref = *(D_PAD**) refptr;
const D_PAD* padcmp = *(D_PAD**) 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 )
* Uses .GetSubRatsnest member of class D_PAD, to handle the shape id (value 1 ..n)
* for pads shapes PAD1 to PADn
* Uses .GetSubRatsnest member of class D_PAD, to handle the shape id (value 1
* ..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
* board. The PADS section must be included, even if only a default pad is described and used for
* all pads. The keywords used in the PADS section are:
* The PADS section is used to describe the shape of all the pads used on the
* printed circuit board. The PADS section must be included, even if only a
* default pad is described and used for all pads.
* The keywords used in the PADS section are:
* $PADS
* PAD <pad_name> <pad_type> <drill_size>
* LINE <line_ref>
......@@ -187,11 +180,14 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
* RECTANGLE <rectangle_ref>
* ATTRIBUTE <attrib_ref>
* $ENDPADS
* $PADS and $ENDPADS mark the PADS section of the GenCAD file. Each pad 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 pad is always placed on a shape at the pad origin, or in a pad stack at the pad stack origin.
* $PADS and $ENDPADS mark the PADS section of the GenCAD file. Each pad
* 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 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;
......@@ -202,8 +198,10 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
if( pcb->GetPadsCount() > 0 )
{
pads.insert( pads.end(),
pcb->m_NetInfo->m_PadsFullList.begin(), pcb->m_NetInfo->m_PadsFullList.end() );
qsort( &pads[0], pcb->GetPadsCount(), sizeof( D_PAD* ), Pad_list_Sort_by_Shapes );
pcb->m_NetInfo->m_PadsFullList.begin(),
pcb->m_NetInfo->m_PadsFullList.end() );
qsort( &pads[0], pcb->GetPadsCount(), sizeof( D_PAD* ),
Pad_list_Sort_by_Shapes );
}
D_PAD* old_pad = NULL;
......@@ -302,11 +300,8 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
}
/*****************************************************/
void CreatePadsStacksSection( FILE* file, BOARD* pcb )
/*****************************************************/
/*The PADSTACKS section is optional, and is used to describe how a group of 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:
* $PADSTACKS
* PADSTACK <pad_name> <drill_size>
......@@ -315,24 +310,23 @@ void CreatePadsStacksSection( FILE* file, BOARD* pcb )
* $ENDPADSTACKS
* $PADSTACKS and $ENDPADSTACKS mark the PADSTACKS section of the GenCAD file.
*/
void CreatePadsStacksSection( FILE* file, BOARD* pcb )
{
fputs( "$PADSTACKS\n", file );
fputs( "$ENDPADSTACKS\n\n", file );
}
/**************************************************/
void CreateShapesSection( FILE* file, BOARD* pcb )
/**************************************************/
/* 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,
* 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
*
* Syntaxe:
* Syntax:
* $SHAPES
* SHAPE <shape_name>
* INSERT <string> here <string> = "TH"
......@@ -343,6 +337,7 @@ void CreateShapesSection( FILE* file, BOARD* pcb )
* ..
* $ENDSHAPES
*/
void CreateShapesSection( FILE* file, BOARD* pcb )
{
MODULE* module;
D_PAD* pad;
......@@ -359,14 +354,14 @@ void CreateShapesSection( FILE* file, BOARD* pcb )
for( pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
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 )
layer = "BOTTOM";
else
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 )
layer = "TOP";
......@@ -394,16 +389,13 @@ void CreateShapesSection( FILE* file, BOARD* pcb )
}
/******************************************************/
void CreateComponentsSection( FILE* file, BOARD* pcb )
/******************************************************/
/* Creates the section $COMPONENTS (Footprints placement)
* When a footprint is on bottom side of the board::
* shapes are given with option "FLIP" and "MIRRORX".
* - 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;
TEXTE_MODULE* PtTexte;
......@@ -419,7 +411,9 @@ void CreateComponentsSection( FILE* file, BOARD* pcb )
if( module->flag )
{
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 );
}
else
......@@ -428,9 +422,12 @@ void CreateComponentsSection( FILE* file, BOARD* pcb )
flip = "0";
}
fprintf( file, "COMPONENT %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, "PLACE %d %d\n", mapXto( module->m_Pos.x ), mapYto( module->m_Pos.y ) );
fprintf( file, "COMPONENT %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, "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, "ROTATION %d", orient / 10 );
......@@ -464,7 +461,8 @@ void CreateComponentsSection( FILE* file, BOARD* pcb )
}
//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_Reference->m_Text ),
CONV_TO_UTF8( module->m_Value->m_Text ) );
}
......@@ -472,18 +470,15 @@ void CreateComponentsSection( FILE* file, BOARD* pcb )
}
/***************************************************/
void CreateSignalsSection( FILE* file, BOARD* pcb )
/***************************************************/
/* Creates the list of Nets:
* $SIGNALS
* SIGNAL <equipot name>
* SIGNAL <net name>
* NODE <component name> <pin name>
* ...
* NODE <component name> <pin name>
* $ENDSIGNALS
*/
void CreateSignalsSection( FILE* file, BOARD* pcb )
{
wxString msg;
NETINFO_ITEM* net;
......@@ -496,13 +491,14 @@ void CreateSignalsSection( FILE* file, BOARD* pcb )
for( unsigned ii = 0; ii < pcb->m_NetInfo->GetCount(); 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++;
net->SetNetname( msg );;
}
if( net->GetNet() <= 0 ) // dummy equipot (non connexion)
if( net->GetNet() <= 0 ) // dummy netlist (no connection)
continue;
msg = wxT( "SIGNAL " ) + net->GetNetname();
......@@ -533,12 +529,9 @@ void CreateSignalsSection( FILE* file, BOARD* pcb )
}
/*************************************************************/
bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
/*************************************************************/
/* Creates the section $HEADER ... $ENDHEADER
*/
bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
{
wxString msg;
PCB_SCREEN* screen = (PCB_SCREEN*) ( frame->GetScreen() );
......@@ -550,11 +543,13 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
msg = wxT( "DRAWING " ) + screen->m_FileName;
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 );
msg.Printf( wxT( "UNITS USER %d" ), PCB_INTERNAL_UNIT );
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" ),
mapXto( frame->m_Auxiliary_Axis_Position.x ),
mapYto( frame->m_Auxiliary_Axis_Position.y ) );
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
fputs( "INTERTRACK 0\n", file );
......@@ -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:
* 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;
int diff;
......@@ -580,7 +572,7 @@ static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr )
cmp = *( (TRACK**) objptr );
if( ( diff = ref->GetNet() - cmp->GetNet() ) )
return diff;
if( (diff = ref->m_Width - cmp->m_Width) )
if( ( diff = ref->m_Width - cmp->m_Width ) )
return diff;
if( ( diff = ref->GetLayer() - cmp->GetLayer() ) )
return diff;
......@@ -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
* that handles tracks, vias
* TODO: add zones
......@@ -602,6 +590,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
* $ENROUTE
* Track segments must be sorted by nets
*/
void CreateRoutesSection( FILE* file, BOARD* pcb )
{
TRACK* track, ** tracklist;
int vianum = 1;
......@@ -665,7 +654,8 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
{
old_layer = track->GetLayer();
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",
......@@ -687,14 +677,11 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
}
/***************************************************/
void CreateDevicesSection( FILE* file, BOARD* pcb )
/***************************************************/
/* Creates the section $DEVICES
* This is a list of footprints properties
* ( Shapes are in section $SHAPE )
*/
void CreateDevicesSection( FILE* file, BOARD* pcb )
{
MODULE* module;
D_PAD* pad;
......@@ -703,7 +690,8 @@ void CreateDevicesSection( FILE* file, BOARD* pcb )
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, "TYPE %s\n", "UNKNOWN" );
for( pad = module->m_Pads; pad != NULL; pad = pad->Next() )
......@@ -715,43 +703,45 @@ void CreateDevicesSection( FILE* file, BOARD* pcb )
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 );
}
/*************************************************/
void CreateBoardSection( FILE* file, BOARD* pcb )
/*************************************************/
/* 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 );
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.GetRight() ), mapYto( pcb->m_BoundaryBox.m_Pos.y ) );
mapXto( pcb->m_BoundaryBox.m_Pos.x ),
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",
mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.m_Pos.y ),
mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.GetBottom() ) );
mapXto( pcb->m_BoundaryBox.GetRight() ),
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",
mapXto( pcb->m_BoundaryBox.GetRight() ), mapYto( pcb->m_BoundaryBox.GetBottom() ),
mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.GetBottom() ) );
mapXto( pcb->m_BoundaryBox.GetRight() ),
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",
mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.GetBottom() ),
mapXto( pcb->m_BoundaryBox.m_Pos.x ), mapYto( pcb->m_BoundaryBox.m_Pos.y ) );
mapXto( pcb->m_BoundaryBox.m_Pos.x ),
mapYto( pcb->m_BoundaryBox.GetBottom() ),
mapXto( pcb->m_BoundaryBox.m_Pos.x ),
mapYto( pcb->m_BoundaryBox.m_Pos.y ) );
fputs( "$ENDBOARD\n\n", file );
}
/****************************************************/
void CreateTracksInfoData( FILE* file, BOARD* pcb )
/****************************************************/
/* Creates the section "$TRACKS"
* This sections give the list of widths (tools) used in tracks and vias
* format:
......@@ -762,18 +752,19 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb )
* Each tool name is build like this: "TRACK" + track width.
* For instance for a width = 120 : name = "TRACK120".
*/
void CreateTracksInfoData( FILE* file, BOARD* pcb )
{
TRACK* track;
int last_width = -1;
/* recherche des epaisseurs utilisees pour les traces: */
/* Find thickness used for traces. */
std::vector <int> trackinfo;
unsigned ii;
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++ )
{
......@@ -790,7 +781,7 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb )
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++ )
{
......@@ -816,10 +807,6 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb )
}
/***************************************************/
void FootprintWriteShape( FILE* file, MODULE* module )
/***************************************************/
/* Creates the shape of a footprint (section SHAPE)
* The shape is always given "normal" (Orient 0, not mirrored)
* Syntax:
......@@ -830,17 +817,19 @@ void FootprintWriteShape( FILE* file, MODULE* module )
* ARC startX startY endX endY centreX centreY
* PAD_CIRCLE centreX scentreY radius
*/
void FootprintWriteShape( FILE* file, MODULE* module )
{
EDGE_MODULE* PtEdge;
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: */
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 )
{
fprintf( file, "ATTRIBUTE" );
......@@ -851,7 +840,6 @@ void FootprintWriteShape( FILE* file, MODULE* module )
fprintf( file, "\n" );
}
/* creates Drawing */
PtStruct = module->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
......@@ -883,7 +871,7 @@ void FootprintWriteShape( FILE* file, MODULE* module )
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;
arcendx = PtEdge->m_Start0.x;
......@@ -897,7 +885,7 @@ void FootprintWriteShape( FILE* file, MODULE* module )
}
default:
DisplayError( NULL, wxT( "Type Edge Module inconnu" ) );
DisplayError( NULL, wxT( "Type Edge Module invalid." ) );
break;
} /* end switch PtEdge->m_Shape */
......
/***************************************************/
/* PCBNEW - Gestion des Recherches (fonction Find) */
/***************************************************/
/* Fichier find.cpp */
/*
* Affichage et modifications des parametres de travail de PcbNew
* Parametres = dimensions des via, pistes, isolements, options...
*/
/********************************************/
/* PCBNEW - Find dialog box implementation. */
/********************************************/
#include "fctsys.h"
......@@ -25,14 +18,12 @@
#include "find.h"
/*Local Variables */
static wxString s_OldStringFound;
static int s_ItemCount, s_MarkerCount;
/*********************************************************************/
void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC )
/*********************************************************************/
{
WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos );
......@@ -41,11 +32,9 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC )
}
/*******************************************************/
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;
wxString msg;
bool FindMarker = FALSE;
......@@ -59,6 +48,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
case ID_FIND_MARKER:
s_MarkerCount = 0;
// fall thru
case ID_FIND_NEXT_MARKER:
......@@ -68,7 +58,8 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
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 )
{
......@@ -82,9 +73,12 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
else
{
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++;
if( StartCount > s_ItemCount )
......@@ -95,7 +89,8 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
break;
}
}
if( WildCompareString( s_OldStringFound, module->m_Value->m_Text.GetData(), FALSE ) )
if( WildCompareString( s_OldStringFound,
module->m_Value->m_Text.GetData(), FALSE ) )
{
StartCount++;
if( StartCount > s_ItemCount )
......@@ -153,17 +148,13 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFindFrame, wxDialog )
////@begin WinEDA_PcbFindFrame event table entries
EVT_BUTTON( ID_FIND_ITEM, WinEDA_PcbFindFrame::OnFindItemClick )
EVT_BUTTON( ID_FIND_NEXT_ITEM, WinEDA_PcbFindFrame::OnFindNextItemClick )
EVT_BUTTON( ID_FIND_MARKER, WinEDA_PcbFindFrame::OnFindMarkerClick )
EVT_BUTTON( ID_FIND_NEXT_MARKER, WinEDA_PcbFindFrame::OnFindNextMarkerClick )
////@end WinEDA_PcbFindFrame event table entries
END_EVENT_TABLE()
/*!
* WinEDA_PcbFindFrame constructors
*/
......@@ -203,18 +194,20 @@ bool WinEDA_PcbFindFrame::Create( wxWindow* parent,
{
////@begin WinEDA_PcbFindFrame member initialisation
m_NewText = NULL;
////@end WinEDA_PcbFindFrame member initialisation
////@begin WinEDA_PcbFindFrame creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
if( GetSizer() )
{
GetSizer()->SetSizeHints(this);
GetSizer()->SetSizeHints( this );
}
Centre();
////@end WinEDA_PcbFindFrame creation
return true;
}
......@@ -231,36 +224,74 @@ void WinEDA_PcbFindFrame::CreateControls()
WinEDA_PcbFindFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
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);
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 );
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
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 );
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();
itemBoxSizer6->Add(itemButton7, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
wxButton* itemButton8 = new wxButton( itemDialog1, ID_FIND_NEXT_ITEM, _("Find Next Item"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer6->Add(itemButton8, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
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);
itemBoxSizer6->Add( itemButton7, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxButton* itemButton8 =
new wxButton( itemDialog1, ID_FIND_NEXT_ITEM, _( "Find Next Item" ),
wxDefaultPosition, wxDefaultSize,
0 );
itemBoxSizer6->Add( itemButton8,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
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
}
......@@ -284,8 +315,9 @@ wxBitmap WinEDA_PcbFindFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_PcbFindFrame bitmap retrieval
wxUnusedVar(name);
wxUnusedVar( name );
return wxNullBitmap;
////@end WinEDA_PcbFindFrame bitmap retrieval
}
......@@ -298,8 +330,9 @@ wxIcon WinEDA_PcbFindFrame::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WinEDA_PcbFindFrame icon retrieval
wxUnusedVar(name);
wxUnusedVar( name );
return wxNullIcon;
////@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"
......@@ -21,17 +21,13 @@ using namespace std;
#include "class_board_design_settings.h"
#include "gendrill.h"
/**********************************************************************************/
void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
Ki_PageDescr* aSheet,
std::vector<HOLE_INFO> aHoleListBuffer,
std::vector<DRILL_TOOL> aToolListBuffer,
bool aUnit_Drill_is_Inch, int format,
const wxPoint& auxoffset )
/**********************************************************************************/
/* Genere le plan de percage (Drill map)
*/
{
int x, y;
int plotX, plotY, TextWidth;
......@@ -47,15 +43,15 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
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();
dX = aPcb->m_BoundaryBox.GetWidth();
dY = aPcb->m_BoundaryBox.GetHeight();
BoardCentre = aPcb->m_BoundaryBox.Centre();
// Calcul de l'echelle du dessin du PCB,
// Echelle 1 en HPGL, dessin sur feuille A4 en PS, + texte description des symboles
// Calculate the scale for the format type, scale 1 in HPGL, drawing on
// an A4 sheet in PS, + text description of symbols
switch( format )
{
case PLOT_FORMAT_GERBER:
......@@ -65,7 +61,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
plotter->set_viewport( offset, scale, 0 );
break;
case PLOT_FORMAT_HPGL: /* Calcul des echelles de conversion format HPGL */
case PLOT_FORMAT_HPGL: /* Scale for HPGL format. */
{
offset.x = 0;
offset.y = 0;
......@@ -94,7 +90,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
offset.x = BoardCentre.x - (SheetSize.x / 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;
plotter = ps_plotter;
ps_plotter->set_paper_size( SheetPS );
......@@ -132,7 +128,8 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
switch( PtStruct->Type() )
{
case TYPE_DRAWSEGMENT:
PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, EDGE_LAYER, FILLED );
PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, EDGE_LAYER,
FILLED );
break;
case TYPE_TEXTE:
......@@ -163,22 +160,23 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
// Plot board outlines and drill map
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 */
double CharScale = 1.0 / scale; /* real scale will be CharScale * scale_x,
* because the global plot scale is scale_x */
double CharScale = 1.0 / scale; /* real scale will be CharScale
* scale_x, because the global
* plot scale is scale_x */
TextWidth = (int) ( (CharSize * CharScale) / 10 ); // Set text width (thickness)
intervalle = (int) ( CharSize * CharScale ) + TextWidth;
/* Trace des informations */
/* Trace information. */
plotX = aPcb->m_BoundaryBox.GetX() + 200 * CharScale;
plotY = aPcb->m_BoundaryBox.GetBottom() + intervalle;
/* Plot title "Info" */
wxString Text = wxT( "Drill Map:" );
plotter->text( wxPoint( plotX, plotY ), BLACK,
Text,
0, wxSize( (int) ( CharSize * CharScale ), (int) ( CharSize * CharScale ) ),
plotter->text( wxPoint( plotX, plotY ), BLACK, Text, 0,
wxSize( (int) ( CharSize * CharScale ),
(int) ( CharSize * CharScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
TextWidth, false, false );
......@@ -195,7 +193,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
y = plotY + CharSize * CharScale;
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,
// and then its diameter in the other Drill Unit.
......@@ -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
* @param aPcb BOARD
* @param aHoleListBuffer = std::vector<HOLE_INFO> list of holes descriptors
* @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;
......@@ -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
*/
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;
char line[1024];
......@@ -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, "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 )
fputs( "Selected Drill Unit: Imperial (\")\n\n", aFile );
else
......@@ -405,8 +398,10 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, const wxString& aBoardFilenam
if( layer2 >= LAYER_CMP_N ) // no more layer pair to consider
break;
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;
}
......
/*************************************/
/* fichier gen_modules_placefile.cpp */
/*************************************/
/*****************************/
/* gen_modules_placefile.cpp */
/*****************************/
/*
* 1 - create ascii files for automatic placement of smd components
......@@ -16,7 +16,7 @@
#include "trigo.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:
MODULE* m_Module;
......@@ -25,13 +25,12 @@ public:
};
/* variables locale : */
static wxPoint File_Place_Offset; /* Offset des coord de placement pour le fichier gnr */
static wxPoint File_Place_Offset; /* Offset coordinates for generated file. */
/* Routines Locales */
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 )
{
LIST_MOD* ref = (LIST_MOD*) o1;
......@@ -64,13 +63,9 @@ static bool HasNonSMDPins( MODULE* aModule )
#endif
/**************************************************************/
void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
/**************************************************************/
/* Routine de generation du fichier de positionnement des modules,
* utilis pour les machines de placement de composants
/* Generate the module positions, used component placement.
*/
void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
{
bool doBoardBack = false;
MODULE* module;
......@@ -87,25 +82,26 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
FILE* fpBack = 0;
bool switchedLocale = false;
/* Calcul des echelles de conversion */
/* Calculate conversion scales. */
double conv_unit = 0.0001; /* unites = INCHES */
// if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */
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;
for( module = GetBoard()->m_Modules; module; module = module->Next() )
{
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;
}
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( !HasNonSMDPins( module ) )
......@@ -115,7 +111,8 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
}
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;
}
#else
......@@ -131,7 +128,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
if( moduleCount == 0 )
{
DisplayError( this, _( "No Modules for Automated Placement" ), 20 );
DisplayError( this, _( "No modules for automated placement." ) );
return;
}
......@@ -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( );
switchedLocale = true;
/* Affichage du bilan : */
/* Display results */
MsgPanel->EraseMsgBox();
Affiche_1_Parametre( this, 0, _( "Component side place file:" ),
fnFront.GetFullPath(), BLUE );
......@@ -181,7 +179,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
msg.Empty(); msg << moduleCount;
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) );
module = GetBoard()->m_Modules;
......@@ -201,7 +199,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
qsort( Liste, moduleCount, sizeof(LIST_MOD), ListeModCmp );
/* Generation entete du fichier 'commentaires) */
/* Generation header file comments. */
sprintf( line, "### Module positions - created on %s ###\n",
DateAndTime( Buff ) );
fputs( line, fpFront );
......@@ -234,13 +232,13 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
if( doBoardBack )
fputs( line, fpBack );
/* Generation lignes utiles du fichier */
for( int ii = 0; ii < moduleCount; ii++ )
{
wxPoint module_pos;
wxString ref = Liste[ii].m_Reference;
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.x -= File_Place_Offset.x;
......@@ -270,7 +268,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
}
}
/* Generation fin du fichier */
/* Generate EOF. */
fputs( "## End\n", fpFront );
if( doBoardBack )
......@@ -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.
*/
void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
{
double conv_unit;
MODULE* Module;
......@@ -317,14 +312,12 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
FILE* rptfile;
wxPoint module_pos;
/* Calcul des echelles de conversion */
conv_unit = 0.0001; /* unites = INCHES */
// if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */
File_Place_Offset = wxPoint( 0, 0 );
/* Init nom fichier */
fn = GetScreen()->m_FileName;
fn.SetExt( wxT( "rpt" ) );
......@@ -336,10 +329,11 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
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( );
/* Generation entete du fichier 'commentaires) */
/* Generate header file comments.) */
sprintf( line, "## Module report - date %s\n", DateAndTime( Buff ) );
fputs( line, rptfile );
......@@ -348,7 +342,6 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
fputs( line, rptfile );
fputs( "## Unit = inches, Angle = deg.\n", rptfile );
/* Generation lignes utiles du fichier */
fputs( "##\n", rptfile );
fputs( "\n$BeginDESCRIPTION\n", rptfile );
......@@ -370,12 +363,15 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
Module = (MODULE*) GetBoard()->m_Modules;
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 );
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 );
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 );
sprintf( line, "footprint \"%s\"\n", CONV_TO_UTF8( Module->m_LibRef ) );
fputs( line, rptfile );
......@@ -429,7 +425,8 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
pad->m_Offset.y * conv_unit );
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 );
const char* shape_name[6] =
{ "??? ", "Circ", "Rect", "Oval", "trap", "spec" };
......@@ -462,36 +459,30 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
WriteDrawSegmentPcb( (DRAWSEGMENT*) PtStruct, rptfile );
}
/* Generation fin du fichier */
/* Generate EOF. */
fputs( "$EndDESCRIPTION\n", rptfile );
fclose( rptfile );
SetLocaleTo_Default( ); // revert to the current locale
}
/*******************************************************************/
void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile )
/*******************************************************************/
/* Sortie sur rptfile d'un segment type drawing PCB:
* Les contours sont de differents type:
* segment
* cercle
* arc
/* Output to rpt file a segment type from the PCB drawing.
* The contours are of different types:
* Segment
* Circle
* Arc
*/
void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile )
{
double conv_unit, ux0, uy0, dx, dy;
double rayon, width;
char line[1024];
/* Calcul des echelles de conversion */
conv_unit = 0.0001; /* unites = INCHES */
conv_unit = 0.0001; /* units = INCHES */
/* coord de depart */
ux0 = PtDrawSegment->m_Start.x * conv_unit;
uy0 = PtDrawSegment->m_Start.y * conv_unit;
/* coord d'arrivee */
dx = PtDrawSegment->m_End.x * conv_unit;
dy = PtDrawSegment->m_End.y * conv_unit;
......@@ -520,7 +511,8 @@ void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile )
fprintf( rptfile, "$ARC \n" );
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, "width %.6lf\n", width );
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 "appl_wxstruct.h"
......@@ -31,29 +31,32 @@ const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl" ) );
* Number format:
* - Floating point format
* - integer format
* - integer format: "Trailling Zero" ( TZ ) or "Leading Zero"
* - integer format: "Trailing Zero" ( TZ ) or "Leading Zero"
* Units
* - Decimal
* - Metric
*
* 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 Write_End_Of_File_Drill( FILE* aFile );
/* Local Variables : */
static float s_ConversionUnits; /* coeff de conversion des unites drill / pcb */
static float s_ConversionUnits; /* Conversion unite for
* drill / pcb */
static int s_Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */
static int s_Zeros_Format = DECIMAL_FORMAT;
static DrillPrecision s_Precision( 2, 4 );
static bool DrillOriginIsAuxAxis; // Axis selection (main / auxiliary) for Drill Origin coordinates
static wxPoint File_Drill_Offset; /* Offset des coord de percage pour le fichier g�n�r� */
static bool DrillOriginIsAuxAxis; /* Axis selection (main /
* auxiliary) for drill
* origin coordinates */
static wxPoint File_Drill_Offset; /* Offset coordinate for
* drilling file. */
static bool Minimal = false;
static bool Mirror = true;
......@@ -72,12 +75,9 @@ static std::vector<HOLE_INFO> s_HoleListBuffer;
#include "dialog_gendrill.cpp" // Dialog box for drill file generation
/************************************************/
void WinEDA_DrillFrame::InitDisplayParams( void )
/************************************************/
/* some param values initialisation before display dialog window
/* some param values initialization before display dialog window
*/
void WinEDA_DrillFrame::InitDisplayParams( void )
{
wxString msg;
......@@ -103,11 +103,13 @@ void WinEDA_DrillFrame::InitDisplayParams( void )
msg << g_pcb_plot_options.HPGL_Pen_Speed;
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_MicroViasCount = 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 )
continue;
......@@ -122,9 +124,10 @@ void WinEDA_DrillFrame::InitDisplayParams( void )
m_MicroViasDrillSizer->Enable( m_MicroViasCount );
m_MicroViaDrillValue->Enable( m_MicroViasCount );
// Pads holes cound:
// Pads holes round:
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() )
{
......@@ -157,9 +160,7 @@ void WinEDA_DrillFrame::InitDisplayParams( void )
}
/**************************************/
void WinEDA_DrillFrame::SetParams( void )
/**************************************/
{
wxString msg;
long ltmp;
......@@ -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
*/
void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
{
wxConfig* Config = wxGetApp().m_EDA_Config;
......@@ -227,10 +225,8 @@ void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
}
/******************************************/
void WinEDA_DrillFrame::UpdateConfig()
/******************************************/
/* Save drill options: */
void WinEDA_DrillFrame::UpdateConfig()
{
SetParams();
......@@ -249,23 +245,25 @@ void WinEDA_DrillFrame::UpdateConfig()
}
/*************************************************************/
void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
/*************************************************************/
/**
* 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 there are some partial holes (some blind or buried vias:
* 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;
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;
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 layer2 = LAYER_CMP_N;
bool gen_through_holes = true;
......@@ -275,9 +273,9 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
m_Parent->MsgPanel->EraseMsgBox();
/* 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 )
s_ConversionUnits = 0.000254f; /* unites = mm */
s_ConversionUnits = 0.000254f; /* units = mm */
if( m_MicroViasCount || m_BlindOrBuriedViasCount )
ExistsBuriedVias = true;
......@@ -325,7 +323,8 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
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() )
{
......@@ -366,7 +365,8 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
layer2++; // use next layer pair
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;
......@@ -381,9 +381,7 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
}
/********************************************************************/
void WinEDA_DrillFrame::UpdatePrecisionOptions( wxCommandEvent& event )
/********************************************************************/
{
if( m_Choice_Unit->GetSelection()==1 )
{
......@@ -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
* @return hole count
* @param aHoleListBuffer = hole descriptor 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 x0, y0, xf, yf, xc, yc;
......@@ -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?*/
fprintf( excellon_dest, "T%dC%.3f\n", ii + 1,
float (aToolListBuffer[ii].m_Diameter) * s_ConversionUnits );
float (aToolListBuffer[ii].m_Diameter)
* s_ConversionUnits );
else
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 );
......@@ -451,7 +448,8 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
else if( !Minimal )
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++ )
{
if( aHoleListBuffer[ii].m_Hole_Shape )
......@@ -483,8 +481,10 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
holes_count++;
}
/* Read the hole file and generate lines for normal holes (oblong holes will be created later) */
tool_reference = -2; // set to a value not used for aHoleListBuffer[ii].m_Tool_Reference
/* Read the hole file and generate lines for normal holes (oblong holes
* 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++ )
{
if( aHoleListBuffer[ii].m_Hole_Shape == 0 )
......@@ -495,7 +495,8 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
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 )
continue;
......@@ -506,12 +507,14 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
/* Compute the start and end coordinates for the shape */
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;
}
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;
}
RotatePoint( &x0, &y0, xc, yc, aHoleListBuffer[ii].m_Hole_Orient );
......@@ -523,12 +526,15 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
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 )
Gen_Line_EXCELLON( line, xt, yt );
else
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++ )
if( line[kk] == '\n' || line[kk] =='\r' )
line[kk] = 0;
......@@ -537,7 +543,9 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( FILE* exce
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 )
Gen_Line_EXCELLON( line, xt, yt );
else
......@@ -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:
* X48000Y19500
* According to the selected format
*/
void Gen_Line_EXCELLON( char* line, float x, float y )
{
wxString xs, ys;
int xpad = s_Precision.m_lhs + s_Precision.m_rhs;
......@@ -589,9 +594,10 @@ void Gen_Line_EXCELLON( char* line, float x, float y )
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 )
......@@ -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:
* M48
* ;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 )
* ICI,OFF
* ATC,ON
*/
void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
{
char Line[256];
......@@ -660,7 +663,8 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
// The next 2 lines in EXCELLON files are comments:
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={" );
// Print precision:
......@@ -675,7 +679,8 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
* this is same as m_Choice_Zeros_Format strings, but NOT translated
* because some EXCELLON parsers do not like non ascii values
* 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( " / " );
const wxString zero_fmt[5] =
......@@ -684,6 +689,7 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
wxT( "suppress trailing zeros" ), wxT( "keep zeros" ),
wxT( "???" )
};
if( ii < 0 || ii > 4 )
ii = 4;
msg << zero_fmt[ii];
......@@ -716,23 +722,19 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile )
}
/****************************************/
void Write_End_Of_File_Drill( FILE* aFile )
/****************************************/
{
//add if minimal here
fputs( "T0\nM30\n", aFile ); fclose( aFile );
}
/**********************************************************************************/
/* Generate the drill plan (Drill map) format HPGL or POSTSCRIPT
*/
void WinEDA_DrillFrame::GenDrillMap( const wxString aFileName,
std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& buffer, int format )
/**********************************************************************************/
/* Genere le plan de percage (Drill map) format HPGL ou POSTSCRIPT
*/
std::vector<DRILL_TOOL>& buffer,
int format )
{
wxFileName fn;
wxString ext, wildcard;
......@@ -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
*/
void WinEDA_DrillFrame::GenDrillReport( const wxString aFileName )
{
wxFileName fn;
wxString msg;
......
/*************************/
/* Edition des Pastilles */
/*************************/
/*************/
/* Edit pads */
/*************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -49,9 +49,7 @@ private:
wxCheckBox* m_Pad_Orient_Change;
public:
// Constructor and destructor
WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame * parent, D_PAD * Pad );
WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* parent, D_PAD* Pad );
~WinEDA_PadGlobalEditFrame() { }
private:
......@@ -62,19 +60,20 @@ private:
};
BEGIN_EVENT_TABLE( WinEDA_PadGlobalEditFrame, wxDialog )
EVT_BUTTON( ID_CHANGE_CURRENT_MODULE, WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( ID_CHANGE_ID_MODULES, WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( ID_CHANGE_GET_PAD_SETTINGS, WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( wxID_CANCEL, WinEDA_PadGlobalEditFrame::OnCancelClick )
EVT_BUTTON( ID_CHANGE_CURRENT_MODULE,
WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( ID_CHANGE_ID_MODULES,
WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( ID_CHANGE_GET_PAD_SETTINGS,
WinEDA_PadGlobalEditFrame::PadPropertiesAccept )
EVT_BUTTON( wxID_CANCEL, WinEDA_PadGlobalEditFrame::OnCancelClick )
END_EVENT_TABLE()
/********************************************************************************/
WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* parent,
WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame(
WinEDA_BasePcbFrame* parent,
D_PAD* Pad ) :
wxDialog( parent, -1, _( "Edit Pads Global" ), wxDefaultPosition, wxSize( 310, 235 ),
DIALOG_STYLE )
/********************************************************************************/
wxDialog( parent, -1, _( "Edit Pads Global" ), wxDefaultPosition,
wxSize( 310, 235 ), DIALOG_STYLE )
{
wxPoint pos;
wxButton* Button;
......@@ -84,7 +83,7 @@ WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* paren
CurrentPad = Pad;
/* Creation des boutons de commande */
/* Create command buttons. */
pos.x = 150;
pos.y = 10;
Button = new wxButton( this, ID_CHANGE_GET_PAD_SETTINGS,
......@@ -101,7 +100,7 @@ WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* paren
pos.y += Button->GetDefaultSize().y + 10;
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), pos );
// Selection des filtres de selection des pads :
// Pad filter selection.
pos.x = 5;
pos.y = 5;
new wxStaticBox( this, -1, _( "Pad Filter :" ), pos, wxSize( 130, 75 ) );
......@@ -144,26 +143,22 @@ WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame( WinEDA_BasePcbFrame* paren
m_Pad_Drill_Change->SetValue( Pad_Drill_Change );
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 );
}
/**********************************************************************/
void WinEDA_PadGlobalEditFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
void WinEDA_PadGlobalEditFrame::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
{
EndModal( -1 );
}
/*************************************************************************/
void WinEDA_PadGlobalEditFrame::PadPropertiesAccept( wxCommandEvent& event )
/*************************************************************************/
/* Met a jour les differents parametres pour le composant en cours d'dition
/* Update the parameters for the component being edited.
*/
void WinEDA_PadGlobalEditFrame::PadPropertiesAccept( wxCommandEvent& event )
{
int returncode = 0;
......@@ -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 to change pad caracteristics for 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
*/
void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
{
MODULE* Module_Ref, * Module;
int diag;
......@@ -214,7 +207,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( Module == NULL )
{
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) );
DisplayError( this,
wxT( "Global_Import_Pad_Settings() Error: NULL module" ) );
return;
}
......@@ -222,7 +216,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
Module->DisplayInfo( this );
WinEDA_PadGlobalEditFrame* frame = new WinEDA_PadGlobalEditFrame( this, aPad );
WinEDA_PadGlobalEditFrame* frame = new WinEDA_PadGlobalEditFrame( this,
aPad );
diag = frame->ShowModal();
frame->Destroy();
......@@ -232,10 +227,10 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( diag == 1 )
Edit_Same_Modules = TRUE;
/* Recherche et copie du nom librairie de reference: */
/* Search and copy the name of library reference. */
Module_Ref = Module;
/* Mise a jour des modules ou du module */
/* Update the modules or module. */
Module = (MODULE*) m_Pcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
......@@ -249,8 +244,8 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
Module->DisplayInfo( this );
/* Effacement du module */
if ( aDraw )
/* Erase module */
if( aDraw )
{
Module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
......@@ -260,7 +255,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
D_PAD* pt_pad = (D_PAD*) Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{
/* Filtrage des modifications interdites */
/* Filters changes prohibited. */
if( Pad_Shape_Filter )
{
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 )
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;
}
......@@ -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 )
continue;
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 )
{
pt_pad->m_Attribut = g_Pad_Master.m_Attribut;
......@@ -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;
}
/* Traitement des cas particuliers : */
if( g_Pad_Master.m_PadShape != PAD_TRAPEZOID )
{
pt_pad->m_DeltaSize.x = 0;
......@@ -334,7 +330,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
}
Module->Set_Rectangle_Encadrement();
if ( aDraw )
if( aDraw )
DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
}
......
/* EDITEUR de PCB: AUTOROUTAGE: routines "graphiques" */
/******************************************************/
/* Fichier BOARD.CC */
/****************************************************/
/* PCB EDITOR: autorouting and "graphics" routines. */
/****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -14,60 +12,88 @@
#include "trigo.h"
#include "cell.h"
/* Exported functions */
int ToMatrixCoordinate ( int aPhysicalCoordinate);
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color );
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int layer,
int color, int op_logique );
/* Local functions */
static void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logique );
static void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
int color, int op_logique );
int ToMatrixCoordinate( int aPhysicalCoordinate );
void TraceLignePcb( int x0,
int y0,
int x1,
int y1,
int layer,
int color );
void TraceArc( int ux0,
int uy0,
int ux1,
int uy1,
int ArcAngle,
int lg,
int layer,
int color,
int op_logique );
static void DrawSegmentQcq( int ux0,
int uy0,
int ux1,
int uy1,
int lg,
int layer,
int color,
int op_logique );
static void TraceFilledCercle( BOARD* Pcb,
int cx,
int cy,
int rayon,
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 d'appel de mise a jour de cellules */
#define OP_CELL( layer, dy, dx ) { if( layer < 0 ) \
/* 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 );\
WriteCell( dy, dx, TOP, color ); \
} \
else { \
else \
{ \
if( layer == Route_Layer_BOTTOM ) \
WriteCell( dy, dx, BOTTOM, color );\
WriteCell( dy, dx, BOTTOM, color ); \
if( Nb_Sides ) \
if( layer == Route_Layer_TOP ) \
WriteCell( dy, dx, TOP, color );\
} }
WriteCell( dy, dx, TOP, color ); \
} \
}
int ToMatrixCoordinate ( int aPhysicalCoordinate)
/** Function ToMatrixCoordinate
* compute the coordinate in the routing matrix from the real (board) value
* @param aPhysicalCoordinate = value to convert
* @return the coordinate relative to the matrix
*/
int ToMatrixCoordinate( int aPhysicalCoordinate )
{
return aPhysicalCoordinate / g_GridRoutingSize;
}
/******************************************************************************/
void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logique )
/******************************************************************************/
/* Initialise a la valeur color, les cellules du Board comprises dans la
* surface du pad pointe par pt_pad, avec la marge reservee pour l'isolement
* et la demi largeur de la piste
* Parametres:
* pt_pad : pointeur sur la description du pad
* 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 )
/* 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
* Parameters:
* Pt_pad: pointer to the description of the pad
* color: mask write in cells
* margin: add a value to the radius or half the score pad
* op_logique: type of writing in the cell (WRITE, OR)
*/
void Place_1_Pad_Board( BOARD* Pcb,
D_PAD* pt_pad,
int color,
int marge,
int op_logique )
{
int dx, dy;
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_
dy += abs( pt_pad->m_DeltaSize.x ) / 2;
}
if( (pt_pad->m_Orient % 900) == 0 )
{ /* Le pad est un rectangle horizontal ou vertical */
if( (pt_pad->m_Orient == 900 ) || (pt_pad->m_Orient == 2700) )
{ /* orient tournee de 90 deg */
if( ( pt_pad->m_Orient % 900 ) == 0 ) /* The pad is a rectangle
* horizontally or vertically. */
{
/* Orientation turned 90 deg. */
if( ( pt_pad->m_Orient == 900 ) || ( pt_pad->m_Orient == 2700 ) )
{
EXCHG( dx, dy );
}
......@@ -111,19 +139,21 @@ void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_
}
/************************************************************************/
void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
int color, int op_logique )
/************************************************************************/
/* Initialise a la valeur color, les cellules du Board comprises dans la
* surface du cercle de centre cx,cy.
* 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 )
/* Initialize a color value, the cells included in the board rea of the
* circle center cx, cy.
* Parameters:
* radius: a value add to the radius or half the score pad
* masque_layer: layer occupied
* color: mask write in cells
* op_logique: type of writing in the cell (WRITE, OR)
*/
void TraceFilledCercle( BOARD* Pcb,
int cx,
int cy,
int rayon,
int masque_layer,
int color,
int op_logique )
{
int row, col;
int ux0, uy0, ux1, uy1;
......@@ -131,21 +161,21 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
int trace = 0;
float fdistmin, fdistx, fdisty;
void (*WriteCell)( int, int, int, BoardCell );
void (* WriteCell)( int, int, int, BoardCell );
int tstwrite = 0;
int distmin;
/* Determination des couches occupees : */
/* Determine occupied layer. */
/* routage sur 1 seule couche:
* sur bitmap BOTTOM et Route_Layer_B = Route_Layer_A*/
/* Single routing layer on bitmap and BOTTOM
* Route_Layer_B = Route_Layer_A */
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( Nb_Sides )
trace |= 2;/* Trace sur TOP */
trace |= 2; /* Trace on TOP */
if( trace == 0 )
return;
......@@ -154,34 +184,44 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
{
default:
case WRITE_CELL:
WriteCell = SetCell; break;
WriteCell = SetCell;
break;
case WRITE_OR_CELL:
WriteCell = OrCell; break;
WriteCell = OrCell;
break;
case WRITE_XOR_CELL:
WriteCell = XorCell; break;
WriteCell = XorCell;
break;
case WRITE_AND_CELL:
WriteCell = AndCell; break;
WriteCell = AndCell;
break;
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;
/* Calcul du rectangle d'encadrement du cercle*/
ux0 = cx - rayon; uy0 = cy - rayon;
ux1 = cx + rayon; uy1 = cy + rayon;
/* Calculate the bounding rectangle of the circle. */
ux0 = cx - 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;
col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; // if (uy0 > row_min*g_GridRoutingSize ) row_min++;
col_min = ux0 / g_GridRoutingSize; // if (ux0 > col_min*g_GridRoutingSize ) col_min++;
row_min = uy0 / g_GridRoutingSize; // if (uy0 > row_min*g_GridRoutingSize
// ) row_min++;
col_min = ux0 / g_GridRoutingSize; // if (ux0 > col_min*g_GridRoutingSize
// ) col_min++;
if( row_min < 0 )
row_min = 0;
......@@ -192,7 +232,7 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
if( 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 )
row_max = row_min;
if( col_min > col_max )
......@@ -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++ )
{
fdisty = (float) ( cy - (row * g_GridRoutingSize) );
fdisty = (float) ( cy - ( row * g_GridRoutingSize ) );
fdisty *= fdisty;
for( col = col_min; col <= col_max; col++ )
{
fdistx = (float) ( cx - (col * g_GridRoutingSize) );
fdistx = (float) ( cx - ( col * g_GridRoutingSize ) );
fdistx *= fdistx;
if( fdistmin <= (fdistx + fdisty) )
if( fdistmin <= ( fdistx + fdisty ) )
continue;
if( trace & 1 )
......@@ -223,22 +263,23 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
if( tstwrite )
return;
/* Si aucune cellule n'a ete ecrite, on touche les 4 voisins diagonaux
* (cas defavorable: pad hors grille, au centre des 4 voisins diagonaux) */
/* If no cell has been written, it affects the 4 neighboring diagonal
* (Adverse event: pad off grid in the center of the 4 neighboring
* diagonal) */
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++ )
{
fdisty = (float) ( cy - (row * g_GridRoutingSize) );
fdisty = (float) ( cy - ( row * g_GridRoutingSize ) );
fdisty *= fdisty;
for( col = col_min; col <= col_max; col++ )
{
fdistx = (float) ( cx - (col * g_GridRoutingSize) );
fdistx = (float) ( cx - ( col * g_GridRoutingSize ) );
fdistx *= fdistx;
if( fdistmin <= (fdistx + fdisty) )
if( fdistmin <= ( fdistx + fdisty ) )
continue;
if( trace & 1 )
......@@ -250,44 +291,46 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
}
/******************************************************************************/
void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_logique )
/******************************************************************************/
/* trace un Segment de piste sur le BOARD de routage
/* Draws a segment of track on the BOARD.
*/
void TraceSegmentPcb( BOARD* Pcb,
TRACK* pt_segm,
int color,
int marge,
int op_logique )
{
int demi_pas, demi_largeur;
int ux0, uy0, ux1, uy1;
demi_pas = g_GridRoutingSize / 2;
demi_largeur = (pt_segm->m_Width / 2) + marge;
/* Calcul du rectangle d'encadrement du segment ( si H,V ou Via) */
demi_largeur = ( pt_segm->m_Width / 2 ) + marge;
/* Calculate the bounding rectangle of the segment (if H, V or Via) */
ux0 = pt_segm->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x;
uy0 = pt_segm->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y;
ux1 = pt_segm->m_End.x - Pcb->m_BoundaryBox.m_Pos.x;
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 )
{
int mask_layer = 0;
if ( pt_segm->IsOnLayer(Route_Layer_BOTTOM) )
if( pt_segm->IsOnLayer( 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;
else mask_layer = -1;
else
mask_layer = -1;
}
if( color == VIA_IMPOSSIBLE )
mask_layer = -1;
if ( mask_layer )
TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur,
mask_layer, color, op_logique );
if( mask_layer )
TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y,
demi_largeur, mask_layer, color, op_logique );
return;
}
......@@ -295,44 +338,52 @@ void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_l
if( color == VIA_IMPOSSIBLE )
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 )
{
TraceCercle( ux0, uy0, ux1, uy1, demi_largeur, layer, color, op_logique );
TraceCercle( ux0, uy0, ux1, uy1, demi_largeur, layer, color,
op_logique );
return;
}
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;
}
/* Le segment est ici un segment de droite */
if( (ux0 != ux1) && (uy0 != uy1) ) // segment incline
/* The segment is here a line segment. */
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;
}
// Ici le segment est HORIZONTAL ou VERTICAL
// DrawHVSegment(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); //F4EXB 051018-01
DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color, op_logique ); //F4EXB 051018-01
return; //F4EXB 051018-01
// The segment is horizontal or vertical.
// DrawHVSegment(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique);
// F4EXB 051018-01
DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color,
op_logique ); // F4EXB 051018-01
return; // F4EXB 051018-01
}
/******************************************************************************************/
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
/* 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 )
{
int dx, dy, lim;
int cumul, inc, il, delta;
void (*WriteCell)( int, int, int, BoardCell );
void (* WriteCell)( int, int, int, BoardCell );
switch( op_logique )
{
......@@ -353,15 +404,15 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
WriteCell = AddCell; break;
}
if( x0 == x1 ) // ligne verticale
if( x0 == x1 ) // Vertical.
{
if( y1 < y0 )
EXCHG( y0, y1 );
dy = y0 / g_GridRoutingSize;
lim = y1 / g_GridRoutingSize;
dx = x0 / g_GridRoutingSize;
/* Clipping aux limites du board */
if( (dx < 0) || (dx >= Ncols) )
/* Clipping limits of board. */
if( ( dx < 0 ) || ( dx >= Ncols ) )
return;
if( dy < 0 )
dy = 0;
......@@ -375,15 +426,15 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
return;
}
if( y0 == y1 ) // ligne horizontale
if( y0 == y1 ) // Horizontal
{
if( x1 < x0 )
EXCHG( x0, x1 );
dx = x0 / g_GridRoutingSize;
lim = x1 / g_GridRoutingSize;
dy = y0 / g_GridRoutingSize;
/* Clipping aux limites du board */
if( (dy < 0) || (dy >= Nrows) )
/* Clipping limits of board. */
if( ( dy < 0 ) || ( dy >= Nrows ) )
return;
if( dx < 0 )
dx = 0;
......@@ -397,8 +448,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
return;
}
/* Ici l'angle est quelconque: on utilise l'algorithme de LUCAS */
if( abs( x1 - x0 ) >= abs( y1 - y0 ) ) /* segment peu incline */
/* Here is some perspective: using the algorithm LUCAS. */
if( abs( x1 - x0 ) >= abs( y1 - y0 ) ) /* segment slightly inclined/ */
{
if( x1 < x0 )
{
......@@ -410,18 +461,24 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
dy = y0 / g_GridRoutingSize;
inc = 1; if( y1 < y0 )
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; )
{
if( (dx >= 0) && (dy >= 0)
&& (dx < Ncols) && (dy < Nrows) )
if( ( dx >= 0 ) && ( dy >= 0 )
&& ( dx < Ncols ) && ( dy < Nrows ) )
{
OP_CELL( layer, dy, dx );
}
dx++; cumul += delta;
dx++;
cumul += delta;
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
{
if( y1 < y0 )
{
EXCHG( x1, x0 ); EXCHG( y1, y0 );
EXCHG( x1, x0 );
EXCHG( y1, y0 );
}
dy = y0 / g_GridRoutingSize;
lim = y1 / g_GridRoutingSize;
dx = x0 / g_GridRoutingSize;
inc = 1; if( x1 < x0 )
inc = 1;
if( x1 < x0 )
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; )
{
if( (dx >= 0) && (dy >= 0)
&& (dx < Ncols) && (dy < Nrows) )
if( ( dx >= 0 ) && ( dy >= 0 )
&& ( dx < Ncols ) && ( dy < Nrows ) )
{
OP_CELL( layer, dy, dx );
}
dy++; cumul += delta;
dy++;
cumul += delta;
if( cumul > il )
{
cumul -= il; dx += inc;
cumul -= il;
dx += inc;
}
}
}
}
/*****************************************************************/
void TraceFilledRectangle( BOARD* Pcb,
int ux0, int uy0, int ux1, int uy1,
int masque_layer, int color, int op_logique )
/*****************************************************************/
/* Fonction Surchargee.
/* Overloaded functions.
*
* Met a la valeur color l'ensemble des cellules du board inscrites dans
* le rectangle de coord ux0,uy0 ( angle haut a gauche )
* a ux1,uy1 ( angle bas a droite )
* Le rectangle est horizontal ( ou vertical )
* Coordonnees PCB.
* Uses the color value of all cells included in the board coordinate of
* the rectangle ux0, uy0 (top left corner)
* A UX1, UY1 (bottom right corner)
* The rectangle is horizontal (or vertical)
* 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_min, row_max, col_min, col_max;
int trace = 0;
void (*WriteCell)( int, int, int, BoardCell );
void (* WriteCell)( int, int, int, BoardCell );
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 )
trace |= 2; /* Trace sur TOP */
if( ( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides )
trace |= 2; /* Trace on TOP */
if( trace == 0 )
return;
......@@ -489,39 +551,48 @@ void TraceFilledRectangle( BOARD* Pcb,
{
default:
case WRITE_CELL:
WriteCell = SetCell; break;
WriteCell = SetCell;
break;
case WRITE_OR_CELL:
WriteCell = OrCell; break;
WriteCell = OrCell;
break;
case WRITE_XOR_CELL:
WriteCell = XorCell; break;
WriteCell = XorCell;
break;
case WRITE_AND_CELL:
WriteCell = AndCell; break;
WriteCell = AndCell;
break;
case WRITE_ADD_CELL:
WriteCell = AddCell; break;
WriteCell = AddCell;
break;
}
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
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;
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++;
col_min = ux0 / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize )
col_min = ux0 / g_GridRoutingSize;
if( ux0 > col_min * g_GridRoutingSize )
col_min++;
if( row_min < 0 )
row_min = 0;
if( row_max >= (Nrows - 1) )
if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= (Ncols - 1) )
if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1;
for( row = row_min; row <= row_max; row++ )
......@@ -537,35 +608,33 @@ void TraceFilledRectangle( BOARD* Pcb,
}
/***********************************************************************************/
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int angle,
int masque_layer, int color, int op_logique )
/***********************************************************************************/
/* Fonction Surchargee.
/* Overloaded functions.
*
* Met a la valeur color l'ensemble des cellules du board inscrites dans
* le rectangle de coord ux0,uy0 ( angle haut a droite )
* a ux1,uy1 ( angle bas a gauche )
* Le rectangle est tourne de la valeur angle (en 0,1 degres)
* Coordonnees PCB.
* Uses the color value of all cells included in the board coordinate of the
* rectangle ux0, uy0 (top right corner)
* a UX1, UY1 (lower left corner)
* the rectangle is the value of turning angle (in degrees 0.1)
* 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 cx, cy; /* Centre du rectangle */
int rayon; /* rayon du cercle exinscrit */
int cx, cy; /* Center of rectangle */
int rayon; /* Radius of the circle */
int row_min, row_max, col_min, col_max;
int rotrow, rotcol;
int trace = 0;
void (*WriteCell)( int, int, int, BoardCell );
void (* WriteCell)( int, int, int, BoardCell );
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( Nb_Sides )
trace |= 2;/* Trace sur TOP */
trace |= 2; /* Trace on TOP */
if( trace == 0 )
return;
......@@ -574,50 +643,61 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int a
{
default:
case WRITE_CELL:
WriteCell = SetCell; break;
WriteCell = SetCell;
break;
case WRITE_OR_CELL:
WriteCell = OrCell; break;
WriteCell = OrCell;
break;
case WRITE_XOR_CELL:
WriteCell = XorCell; break;
WriteCell = XorCell;
break;
case WRITE_AND_CELL:
WriteCell = AndCell; break;
WriteCell = AndCell;
break;
case WRITE_ADD_CELL:
WriteCell = AddCell; break;
WriteCell = AddCell;
break;
}
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
cx = (ux0 + ux1) / 2; cy = (uy0 + uy1) / 2;
rayon = (int) sqrt( (double) (cx - ux0) * (cx - ux0)
+ (double) (cy - uy0) * (cy - uy0) );
cx = (ux0 + ux1) / 2;
cy = (uy0 + uy1) / 2;
rayon = (int) sqrt( (double) ( cx - ux0 ) * ( cx - ux0 )
+ (double) ( cy - uy0 ) * ( cy - uy0 ) );
/* Calcul des coord limites des cellules appartenant au 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 )
/* 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++;
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++;
if( row_min < 0 )
row_min = 0;
if( row_max >= (Nrows - 1) )
if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= (Ncols - 1) )
if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1;
for( row = row_min; row <= row_max; row++ )
{
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 );
if( rotrow <= uy0 )
continue;
......@@ -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,
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 inc;
int row_max, col_max, row_min, col_min;
int demi_pas;
void (*WriteCell)( int, int, int, BoardCell );
void (* WriteCell)( int, int, int, BoardCell );
int angle;
int cx, cy, dx, dy;
......@@ -659,101 +737,111 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
{
default:
case WRITE_CELL:
WriteCell = SetCell; break;
WriteCell = SetCell;
break;
case WRITE_OR_CELL:
WriteCell = OrCell; break;
WriteCell = OrCell;
break;
case WRITE_XOR_CELL:
WriteCell = XorCell; break;
WriteCell = XorCell;
break;
case WRITE_AND_CELL:
WriteCell = AndCell; break;
WriteCell = AndCell;
break;
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 )
{
EXCHG( ux1, ux0 ); EXCHG( uy1, uy0 );
EXCHG( ux1, ux0 );
EXCHG( uy1, uy0 );
}
/* calcul de l'increment selon axe Y */
inc = 1; if( uy1 < uy0 )
/* Calculating the incrementing the Y axis */
inc = 1;
if( uy1 < uy0 )
inc = -1;
/* Calcul de l'encadrement : */
demi_pas = g_GridRoutingSize / 2;
col_min = (ux0 - lg) / g_GridRoutingSize;
col_min = ( ux0 - lg ) / g_GridRoutingSize;
if( col_min < 0 )
col_min = 0;
col_max = (ux1 + lg + demi_pas) / g_GridRoutingSize;
if( col_max > (Ncols - 1) )
col_max = ( ux1 + lg + demi_pas ) / g_GridRoutingSize;
if( col_max > ( Ncols - 1 ) )
col_max = Ncols - 1;
if( inc > 0 )
{
row_min = (uy0 - lg) / g_GridRoutingSize;
row_max = (uy1 + lg + demi_pas) / g_GridRoutingSize;
row_min = ( uy0 - lg ) / g_GridRoutingSize;
row_max = ( uy1 + lg + demi_pas ) / g_GridRoutingSize;
}
else
{
row_min = (uy1 - lg) / g_GridRoutingSize;
row_max = (uy0 + lg + demi_pas) / g_GridRoutingSize;
row_min = ( uy1 - lg ) / g_GridRoutingSize;
row_max = ( uy0 + lg + demi_pas ) / g_GridRoutingSize;
}
if( row_min < 0 )
row_min = 0;
if( row_min > (Nrows - 1) )
if( row_min > ( Nrows - 1 ) )
row_min = Nrows - 1;
if( row_max < 0 )
row_max = 0;
if( row_max > (Nrows - 1) )
if( row_max > ( Nrows - 1 ) )
row_max = Nrows - 1;
dx = ux1 - ux0;
dy = uy1 - uy0;
dx = ux1 - ux0; dy = uy1 - uy0;
if( dx )
angle = (int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);
angle = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
else
{
angle = 900; if( dy < 0 )
angle = 900;
if( dy < 0 )
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++ )
{
int cxr;
cxr = (col * g_GridRoutingSize) - ux0;
cxr = ( col * g_GridRoutingSize ) - ux0;
for( row = row_min; row <= row_max; row++ )
{
cy = (row * g_GridRoutingSize) - uy0;
cx = cxr;
RotatePoint( &cx, &cy, angle );
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
* selon l'axe X doit etre testee */
if( (cx >= 0) && (cx <= dx) )
/* This point a test is close to the segment: the position
* along the X axis must be tested.
*/
if( ( cx >= 0 ) && ( cx <= dx ) )
{
OP_CELL( layer, row, col );
continue;
}
/* examen des extremites qui sont arrondies */
if( (cx < 0) && (cx >= -lg) )
/* Examination of extremities are rounded. */
if( ( cx < 0 ) && ( cx >= -lg ) )
{
if( ( (cx * cx) + (cy * cy) ) <= (lg * lg) )
if( ( ( cx * cx ) + ( cy * cy ) ) <= ( lg * lg ) )
OP_CELL( layer, row, col );
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 );
continue;
}
......@@ -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
* de demi-largeur lg, centre ux,y0 passant par 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.
/* Fills all cells BOARD contained in the circle
* half-width lg center ux, ux through y0, y1 is set to color.
* 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 x0, y0, // Point de depart du segment en cours de trace
x1, y1; // point d'arrivee
int x0, y0, // Starting point of the current segment trace.
x1, y1; // End point.
int ii;
int angle;
rayon = (int) hypot( (double) (ux1 - ux0), (double) (uy1 - uy0) );
x0 = x1 = rayon; y0 = y1 = 0;
x0 = x1 = rayon;
y0 = y1 = 0;
if( lg < 1 )
lg = 1;
nb_segm = (2 * rayon) / lg;
nb_segm = ( 2 * rayon ) / lg;
if( nb_segm < 5 )
nb_segm = 5;
if( nb_segm > 100 )
......@@ -790,30 +878,30 @@ void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
for( ii = 1; ii < nb_segm; ii++ )
{
angle = (3600 * ii) / nb_segm;
x1 = (int) (rayon * fcosinus[angle]);
y1 = (int) (rayon * fsinus[angle]);
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logique );
x0 = x1; y0 = y1;
x1 = (int) ( rayon * fcosinus[angle] );
y1 = (int) ( rayon * fsinus[angle] );
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg,
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 );
}
/****************************************************************************/
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int layer,
int color, int op_logique )
/****************************************************************************/
/* 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.
/* Fills all cells BOARD contained in the arc of "L" angle
* half-width lg ux center, starting in ux y0, y1 is set to color.
* coord in PCB units (0.1 million) relating to the origin
* Pt_pcb->m_PcbBox.m_Xmin, Y's 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 x0, y0, // Point de depart du segment en cours de trace
x1, y1; // point d'arrivee
int x0, y0, // Starting point of the current segment trace
x1, y1; // End point
int ii;
int angle, StAngle;
......@@ -825,7 +913,7 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int lay
StAngle = ArcTangente( uy1 - uy0, ux1 - ux0 );
if( lg < 1 )
lg = 1;
nb_segm = (2 * rayon) / lg;
nb_segm = ( 2 * rayon ) / lg;
nb_segm = ( nb_segm * abs( ArcAngle ) ) / 3600;
if( 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
for( ii = 1; ii <= nb_segm; ii++ )
{
angle = (ArcAngle * ii) / nb_segm;
angle = ( ArcAngle * ii ) / nb_segm;
angle += StAngle;
while( angle >= 3600 )
......@@ -843,11 +931,14 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int lay
while( angle < 0 )
angle += 3600;
x1 = (int) (rayon * fcosinus[angle]);
y1 = (int) (rayon * fsinus[angle]);
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logique );
x0 = x1; y0 = y1;
x1 = (int) ( rayon * fcosinus[angle] );
y1 = (int) ( rayon * fsinus[angle] );
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, 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);
}
/********************************************************************/
/* Routines de lecture et sauvegarde des structures en format ASCii */
/* Fichier common a PCBNEW et CVPCB */
/********************************************************************/
/* ioascii.cpp */
/****************************************************/
/* Routines for reading and saving of structures in */
/* ASCII file common to Pcbnew and CVPCB. */
/****************************************************/
#include "fctsys.h"
#include "common.h"
......@@ -26,70 +23,67 @@
#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)
* @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 ii = 0;
......@@ -111,7 +105,8 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
// Read the 2nd line to determine the exact type, one of:
// TYPE_TRACK, TYPE_VIA, or TYPE_ZONE. The type field in 2nd line
// 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 )
break;
......@@ -142,7 +137,8 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
case TYPE_ZONE: // this is now deprecated, but exits in old boards
newTrack = new SEGZONE( GetBoard() );
GetBoard()->m_Zone.Insert( (SEGZONE*)newTrack, (SEGZONE*)insertBeforeMe );
GetBoard()->m_Zone.Insert( (SEGZONE*) newTrack,
(SEGZONE*) insertBeforeMe );
break;
}
......@@ -159,14 +155,15 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
if( arg_count < 7 || drill <= 0 )
newTrack->SetDrillDefault();
else
newTrack->SetDrillValue(drill);
newTrack->SetDrillValue( drill );
newTrack->SetLayer( layer );
if ( makeType == TYPE_VIA )
{ // Ensure layers are OK when possible:
if( makeType == TYPE_VIA ) // Ensure layers are OK when possible:
{
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 );
......@@ -178,9 +175,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
}
/**********************************************************************************/
int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
/**********************************************************************************/
{
char Line[1024], * data;
......@@ -240,6 +235,7 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
layer_count++;
Masque_Layer >>= 1;
}
GetBoard()->m_BoardSettings->SetCopperLayerCount( layer_count );
continue;
......@@ -272,13 +268,15 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
data = strtok( NULL, " =\n\r" );
GetBoard()->m_BoundaryBox.SetY( atoi( data ) );
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" );
GetBoard()->m_BoundaryBox.SetHeight( atoi( data ) - GetBoard()->m_BoundaryBox.GetY() );
GetBoard()->m_BoundaryBox.SetHeight(
atoi( data ) - GetBoard()->m_BoundaryBox.GetY() );
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 )
{
data = strtok( NULL, " =\n\r" );
......@@ -319,14 +317,12 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
}
/*************************************************************/
int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
/*************************************************************/
{
char Line[1024];
char* data;
NETCLASS * netclass_default = GetBoard()->m_NetClasses.GetDefault();
NETCLASS* netclass_default = GetBoard()->m_NetClasses.GetDefault();
while( GetLine( File, Line, LineNum ) != NULL )
{
......@@ -335,15 +331,21 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "$EndSETUP" ) == 0 )
{
// Until such time as the *.brd file does not have the global parameters:
// "TrackWidth", "TrackMinWidth", "ViaSize", "ViaDrill", "ViaMinSize", and "TrackClearence",
// put those same global 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.
// Until such time as the *.brd file does not have the
// global parameters:
// "TrackWidth", "TrackMinWidth", "ViaSize", "ViaDrill",
// "ViaMinSize", and "TrackClearence", put those same global
// 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
// parameters from the *.brd file since the ones in the default
// netclass serve the same purpose. If needed at all, the global defaults should go into
// a preferences file instead so they are there to start new board projects.
// parameters from the *.brd file since the ones in the
// default netclass serve the same purpose. If needed
// 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();
return 0;
......@@ -369,7 +371,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
continue;
}
const int LAYERKEYZ = sizeof("Layer[")-1;
const int LAYERKEYZ = sizeof("Layer[") - 1;
if( strncmp( Line, "Layer[", LAYERKEYZ ) == 0 )
{
......@@ -377,7 +379,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
// Layer[n] <a_Layer_name_with_no_spaces> <LAYER_T>
char* cp = Line + LAYERKEYZ;
int layer = atoi(cp);
int layer = atoi( cp );
if( data )
{
......@@ -577,21 +579,30 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
* Sort lists by by increasing value and remove duplicates
* (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_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] )
{
GetBoard()->m_ViasDimensionsList.erase(GetBoard()->m_ViasDimensionsList.begin()+ii);
sort( GetBoard()->m_ViasDimensionsList.begin() + 1,
GetBoard()->m_ViasDimensionsList.end() );
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] )
{
GetBoard()->m_ViasDimensionsList.erase(
GetBoard()->m_ViasDimensionsList.begin() + 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--;
}
}
......@@ -601,11 +612,9 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
#ifdef PCBNEW
/******************************************************************************/
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];
fprintf( aFile, "$SETUP\n" );
......@@ -616,38 +625,47 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
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 )
{
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 ) ) );
}
}
// 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() );
// 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++ )
fprintf( aFile, "TrackWidthList %d\n", aBoard->m_TrackWidthList[ii] );
fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() );
fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance );
fprintf( aFile, "TrackMinWidth %d\n" , g_DesignSettings.m_TrackMinWidth );
fprintf( aFile,
"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, "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, "ViaDrill %d\n", netclass_default->GetViaDrill() );
fprintf( aFile, "ViaMinSize %d\n", g_DesignSettings.m_ViasMinSize );
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++ )
fprintf( aFile, "ViaSizeList %d %d\n",
aBoard->m_ViasDimensionsList[ii].m_Diameter,
......@@ -655,39 +673,57 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
// for old versions compatibility:
fprintf( aFile, "MicroViaSize %d\n", netclass_default->GetuViaDiameter() );
fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill());
fprintf( aFile, "MicroViasAllowed %d\n", g_DesignSettings.m_MicroViasAllowed);
fprintf( aFile, "MicroViaMinSize %d\n" , g_DesignSettings.m_MicroViasMinSize );
fprintf( aFile, "MicroViaMinDrill %d\n", g_DesignSettings.m_MicroViasMinDrill );
fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill() );
fprintf( aFile,
"MicroViasAllowed %d\n",
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, "TextPcbSize %d %d\n",
g_DesignSettings.m_PcbTextSize.x, g_DesignSettings.m_PcbTextSize.y );
fprintf( aFile,
"TextPcbSize %d %d\n",
g_DesignSettings.m_PcbTextSize.x,
g_DesignSettings.m_PcbTextSize.y );
fprintf( aFile, "EdgeModWidth %d\n", ModuleSegmentWidth );
fprintf( aFile, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y );
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, "Pad2MaskClearance %d\n", g_DesignSettings.m_SolderMaskMargin );
if( g_DesignSettings.m_SolderPasteMargin != 0)
fprintf( aFile, "Pad2PasteClearance %d\n", g_DesignSettings.m_SolderPasteMargin );
fprintf( aFile,
"Pad2MaskClearance %d\n",
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 )
fprintf( aFile, "Pad2PasteClearanceRatio %g\n", g_DesignSettings.m_SolderPasteMarginRatio );
fprintf( aFile,
"Pad2PasteClearanceRatio %g\n",
g_DesignSettings.m_SolderPasteMarginRatio );
fprintf( aFile, "AuxiliaryAxisOrg %d %d\n",
aFrame->m_Auxiliary_Axis_Position.x, aFrame->m_Auxiliary_Axis_Position.y );
fprintf( aFile,
"AuxiliaryAxisOrg %d %d\n",
aFrame->m_Auxiliary_Axis_Position.x,
aFrame->m_Auxiliary_Axis_Position.y );
fprintf( aFile, "$EndSETUP\n\n" );
return 1;
}
#endif
/******************************************************/
bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
/******************************************************/
{
EDA_BaseStruct* PtStruct = GetBoard()->m_Modules;
int NbModules, NbDrawItem, NbLayers;
......@@ -697,8 +733,11 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "$GENERAL\n" );
fprintf( File, "LayerCount %d\n", NbLayers );
// Write old format for Layer count (for compatibility with old versions of pcbnew
fprintf( File, "Ly %8X\n", g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS ); // For compatibility with old version of pcbnew
// Write old format for Layer count (for compatibility with old versions of
// pcbnew
fprintf( File,
"Ly %8X\n",
g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS );
fprintf( File, "EnabledLayers %08X\n", GetBoard()->GetEnabledLayers() );
fprintf( File, "VisibleLayers %08X\n", GetBoard()->GetVisibleLayers() );
fprintf( File, "VisibleElements %08X\n", GetBoard()->GetVisibleElements() );
......@@ -708,7 +747,8 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
/* Write Bounding box info */
GetBoard()->ComputeBoundaryBox();
fprintf( File, "Di %d %d %d %d\n",
GetBoard()->m_BoundaryBox.GetX(), GetBoard()->m_BoundaryBox.GetY(),
GetBoard()->m_BoundaryBox.GetX(),
GetBoard()->m_BoundaryBox.GetY(),
GetBoard()->m_BoundaryBox.GetRight(),
GetBoard()->m_BoundaryBox.GetBottom() );
......@@ -724,7 +764,8 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "Ndraw %d\n", NbDrawItem );
fprintf( File, "Ntrack %d\n", GetBoard()->GetNumSegmTrack() );
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, "Nnets %d\n", GetBoard()->m_NetInfo->GetCount() );
......@@ -734,14 +775,12 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
}
/******************************************************/
bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
/******************************************************/
/** Function WriteSheetDescr
* Save the page information (size, texts, date ..)
* @param screen BASE_SCREEN to save
* @param File = an openen FILE to write info
*/
* Save the page information (size, texts, date ..)
* @param screen BASE_SCREEN to save
* @param File = an open FILE to write info
*/
bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
{
Ki_PageDescr* sheet = screen->m_CurrentSheetDesc;
......@@ -762,9 +801,7 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
}
/***************************************************************************/
static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
/***************************************************************************/
{
char Line[1024], buf[1024], * text;
......@@ -861,22 +898,21 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
}
/********************************************************************/
int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
/********************************************************************/
/** ReadPcbFile
* Read a board file <file>.brd
* @param Append if 0: a previoulsy loaded board is deleted before loading the file.
* else all items of the board file are added to the existing board
* @param Append if 0: a previously loaded board is deleted before loading
* 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];
int LineNum = 0;
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();
BOARD* board = GetBoard();
......@@ -887,8 +923,9 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
board->m_NetClasses.Clear();
// 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.
#define TESTLINE(x) (strncmp(Line, "$" x, sizeof("$" x)-1) == 0)
// The -1 is to omit the trailing \0 which is included in sizeof() on a
// string.
#define TESTLINE( x ) (strncmp( Line, "$" x, sizeof("$" x) - 1 ) == 0)
while( GetLine( File, Line, &LineNum ) != NULL )
{
......@@ -963,11 +1000,12 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
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 );
if ( zone_descr->GetNumCorners( ) > 2 ) // should always occur
board->Add(zone_descr);
else delete zone_descr;
if( zone_descr->GetNumCorners() > 2 ) // should always occur
board->Add( zone_descr );
else
delete zone_descr;
continue;
}
......@@ -1029,13 +1067,14 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
break;
}
SetLocaleTo_Default( ); // revert to the current locale
SetLocaleTo_Default(); // revert to the current locale
GetBoard()->m_Status_Pcb = 0;
// Build the net info list
GetBoard()->m_NetInfo->BuildListOfNets();
board->SynchronizeNetsAndNetClasses( );
board->SynchronizeNetsAndNetClasses();
m_TrackAndViasSizesList_Changed = true;
Affiche_Message( wxEmptyString );
......@@ -1046,15 +1085,13 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
#ifdef PCBNEW
/***************************************************/
int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
/****************************************************/
/* Routine de sauvegarde du PCB courant sous format ASCII
* retourne
* 1 si OK
* 0 si sauvegarde non faite
/* Save the current PCB in ASCII format
* Returns
* 1 if OK
* 0 if error occurs saving file.
*/
int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
{
bool rc;
char line[256];
......@@ -1063,18 +1100,22 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
wxBeginBusyCursor();
// 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)
SetLocaleTo_C_standard();
/* Ecriture de l'entete PCB : */
/* Writing file header. */
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
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();
// Select default Netclass before writing file.
// 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;
AuxiliaryToolBar_Update_UI();
......@@ -1084,7 +1125,7 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
rc = GetBoard()->Save( aFile );
SetLocaleTo_Default( ); // revert to the current locale
SetLocaleTo_Default(); // revert to the current locale
wxEndBusyCursor();
if( !rc )
......@@ -1095,4 +1136,5 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
return rc;
}
#endif
/***************************************/
/* Gestion de la LIBRAIRIE des MODULES */
/***************************************/
/* Fichier LIBRAIRI.CPP */
/****************************************/
/* Manage module (footprint) libraries. */
/****************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -16,41 +14,38 @@
#include "protos.h"
/*
* Format de l'entete de la Librairie:
* chaine ENTETE-LIBRAIRIE date-heure
* Module library header format:
* Array LIBRARY HEADER-datetime
* $INDEX
* liste des noms modules ( 1 nom par ligne)
* $EndINDEX
* liste des descriptions des Modules
* List of modules names (1 name per line)
* $EndIndex
* List of descriptions of Modules
* $EndLIBRARY
*/
#define BACKUP_EXT wxT( "bak" )
#define FILETMP_EXT wxT( "$$$" )
#define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" )
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 );
/*********************************************************/
MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
/*********************************************************/
/**
* Function Import_Module
* Read a file containing only one 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
* The import function can also read gpcb footprint file, in Newlib format
* (One footprint per file, Newlib files have no special ext.)
* @param DC = Current Device Context (can be NULL)
*/
MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
{
int NbLine = 0;
char Line[1024];
......@@ -64,7 +59,6 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
if( Config )
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading );
/* Lecture Fichier module */
wxFileDialog dlg( this, _( "Import Footprint Module" ),
LastOpenedPathForLoading, wxEmptyString,
ModExportFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
......@@ -88,8 +82,9 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading );
}
// 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)
SetLocaleTo_C_standard();
/* Read header and test file type */
GetLine( file, Line, &NbLine );
......@@ -127,7 +122,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
module->ReadDescr( file, &NbLine );
fclose( file );
}
SetLocaleTo_Default( ); // revert to the current locale
SetLocaleTo_Default(); // revert to the current locale
/* Insert footprint in list*/
GetBoard()->Add( module );
......@@ -142,21 +137,20 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
}
/************************************************************************/
void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
/************************************************************************/
/**
* Function Export_Module
* Create a file containing only one 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
* 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 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;
char Line[1025];
......@@ -188,7 +182,6 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
fn = dlg.GetPath();
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* Generation du fichier Empreinte */
if( ( file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL )
{
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
......@@ -201,7 +194,8 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
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();
fprintf( file, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( Line ) );
......@@ -214,17 +208,16 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
fputs( "$EndLIBRARY\n", 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 );
}
/**********************************************************/
void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxString& aLibname )
/**********************************************************/
void WinEDA_ModuleEditFrame::Delete_Module_In_Library(
const wxString& aLibname )
{
wxFileName newFileName;
wxFileName oldFileName;
......@@ -233,8 +226,10 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
FILE* dest, * lib_module;
wxString CmpName, msg;
/* Demande du nom du composant a supprimer */
CmpName = Select_1_Module_From_List( this, aLibname, wxEmptyString, wxEmptyString );
CmpName = Select_1_Module_From_List( this,
aLibname,
wxEmptyString,
wxEmptyString );
if( CmpName == wxEmptyString )
return;
......@@ -256,7 +251,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
}
/* lecture entete */
/* Read header. */
GetLine( lib_module, Line, &LineNum );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
......@@ -266,7 +261,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
return;
}
/* lecture des nom des composants */
/* Read module names. */
while( GetLine( lib_module, Line, &LineNum ) )
{
if( strnicmp( Line, "$INDEX", 6 ) == 0 )
......@@ -275,7 +270,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
{
StrPurge( Line );
msg = CONV_FROM_UTF8( Line );
if( CmpName.CmpNoCase( msg ) == 0 ) /* composant trouve */
if( CmpName.CmpNoCase( msg ) == 0 ) /* New module? */
{
NoFound = 0; break;
}
......@@ -295,7 +290,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
return;
}
/* Creation de la nouvelle librairie */
/* Create new library. */
newFileName = oldFileName;
newFileName.SetExt( FILETMP_EXT );
......@@ -310,7 +305,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxBeginBusyCursor();
/* Creation de l'entete avec nouvelle date */
/* Create header with new date. */
fprintf( dest, ENTETE_LIBRAIRIE );
fprintf( dest, " %s\n$INDEX\n", DateAndTime( Line ) );
......@@ -339,7 +334,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
fprintf( dest, "$EndINDEX\n" );
/* Copie des modules */
/* Copy modules. */
while( GetLine( lib_module, Line, &LineNum ) )
{
StrPurge( Line );
......@@ -349,7 +344,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
msg = CONV_FROM_UTF8( Name );
if( msg.CmpNoCase( CmpName ) == 0 )
{
/* suppression ancien module */
/* Delete old module. */
while( GetLine( lib_module, Line, &LineNum ) )
{
if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
......@@ -367,7 +362,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxEndBusyCursor();
/* Le fichier ancienne librairie est renommee en .bak */
/* The old library file is renamed .bak */
wxFileName backupFileName = oldFileName;
backupFileName.SetExt( BACKUP_EXT );
......@@ -381,7 +376,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
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() ) )
{
DisplayError( this, wxT( "Librairi.cpp: rename err 2" ) );
......@@ -396,17 +391,13 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
}
/***********************************************************************/
void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
bool NewModulesOnly )
/***********************************************************************/
/*
* Sauve en Librairie:
* tous les nouveaux modules ( c.a.d. les modules
* n'existant pas deja (si NewModulesOnly == true)
* tous les modules (si NewModulesOnly == FALSE)
* Save library:
* All new modules (ie modules not already exist (if NewModulesOnly == true)
* all modules (if NewModulesOnly == FALSE)
*/
void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
bool NewModulesOnly )
{
int ii, NbModules = 0;
float Pas;
......@@ -432,14 +423,15 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
fileName = dlg.GetPath();
}
wxFileName fn(fileName);
wxFileName fn( fileName );
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
bool file_exists = wxFileExists( fileName );
if( !NewModulesOnly && file_exists )
{
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 ) )
return;
}
......@@ -464,7 +456,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
fclose( lib_module );
}
/* Calcul du nombre de modules */
/* Calculate the number of modules. */
Module = (MODULE*) GetBoard()->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() )
NbModules++;
......@@ -476,10 +468,11 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() )
{
if( Save_Module_In_Library( fileName, Module,
NewModulesOnly ? FALSE : true, FALSE, false ) == 0 )
NewModulesOnly ? FALSE : true,
FALSE, false ) == 0 )
break;
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 )
break;
}
......@@ -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
* Save in an existing library a given footprint
* @param aLibName = name of the library to use
* @param aModule = the given footprint
* @param aOverwrite = true to overwrite an existing footprint, false to abort an existing footprint is found
* @param aDisplayDialog = true to display a dialog to enter or confirm the footprint name
* @param aOverwrite = true to overwrite an existing footprint, false to abort
* 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
* @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 newFileName;
......@@ -523,7 +517,6 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
return 0;
}
/* Ask for the footprint name in lib */
Name_Cmp = aModule->m_LibRef;
......@@ -544,17 +537,18 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
return 0;
}
/* lRead library file : library header */
/* Read library file : library header */
GetLine( lib_module, Line, &LineNum );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{
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 );
return 0;
}
/* Reaf footprints in lib: - search for an existing footprint */
/* Read footprints in lib: - search for an existing footprint */
newmodule = 1; end = 0;
while( !end && GetLine( lib_module, Line, &LineNum ) )
{
......@@ -572,7 +566,8 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
StrPurge( 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;
newmodule = 0;
......@@ -582,7 +577,8 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
msg << LineNum;
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;
}
......@@ -614,8 +610,9 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
wxBeginBusyCursor();
// 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)
SetLocaleTo_C_standard();
/* Create the library header with a new date */
fprintf( dest, ENTETE_LIBRAIRIE );
......@@ -657,7 +654,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
msg = CONV_FROM_UTF8( Name );
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 ) )
{
if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
......@@ -677,7 +674,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
aModule->m_TimeStamp = tmp;
fclose( dest ); fclose( lib_module );
SetLocaleTo_Default( ); // revert to the current locale
SetLocaleTo_Default(); // revert to the current locale
wxEndBusyCursor();
......@@ -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 */
if ( aCreateDocFile )
if( aCreateDocFile )
CreateDocLibrary( aLibName );
if( aDisplayDialog )
......@@ -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 :
* First = REFERENCE
* 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;
wxString Line;
wxPoint newpos;
/* Ask fo the new module reference */
/* Ask for the new module reference */
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" ) );
return NULL;
......@@ -743,7 +738,8 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
Line.Trim( true );
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() );
GetBoard()->Add( Module );
......@@ -773,9 +769,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
}
/*******************************************************/
void WinEDA_ModuleEditFrame::Select_Active_Library()
/*******************************************************/
{
if( g_LibName_List.GetCount() == 0 )
return;
......@@ -797,9 +791,7 @@ void WinEDA_ModuleEditFrame::Select_Active_Library()
}
/**********************************************************************/
int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
/**********************************************************************/
{
FILE* lib_module;
wxString msg;
......@@ -819,7 +811,7 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
return -1;
}
/* Ecriture de l'entete de la nouvelle librairie */
/* Write the header of the new library. */
if( fprintf( lib_module, ENTETE_LIBRAIRIE ) == 0 )
{
msg = _( "Create error " ) + LibName;
......@@ -836,13 +828,10 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
}
/******************************************************/
static bool CreateDocLibrary( const wxString& LibName )
/*****************************************************/
/* Creation du fichier .dcm associe a la librairie LibName
* (full file name)
/* Synch. Dcm combines a library Libname
* (Full file name)
*/
static bool CreateDocLibrary( const wxString& LibName )
{
char Line[1024];
char cbuf[256];
......@@ -857,7 +846,7 @@ static bool CreateDocLibrary( const wxString& LibName )
if( LibMod == NULL )
return FALSE;
/* lecture entete librairie*/
/* Read library header. */
GetLine( LibMod, Line, NULL, sizeof(Line) - 1 );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{
......@@ -874,7 +863,7 @@ static bool CreateDocLibrary( const wxString& LibName )
fprintf( LibDoc, ENTETE_LIBDOC );
fprintf( LibDoc, " %s\n", DateAndTime( cbuf ) );
/* Lecture de la librairie */
/* Read library. */
Name = Doc = KeyWord = wxEmptyString;
while( GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ) )
{
......@@ -907,7 +896,9 @@ static bool CreateDocLibrary( const wxString& LibName )
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, "Li %s\n", CONV_TO_UTF8( Name ) );
......@@ -920,7 +911,7 @@ static bool CreateDocLibrary( const wxString& LibName )
fprintf( LibDoc, "$EndMODULE\n" );
}
Name = Doc = KeyWord = wxEmptyString;
} /* Fin lecture desc 1 module */
} /* End read 1 module */
if( strnicmp( Line, "$INDEX", 6 ) == 0 )
{
......@@ -930,12 +921,10 @@ static bool CreateDocLibrary( const wxString& LibName )
break;
}
/* Fin Lecture INDEX */
/* End read INDEX */
}
}
/* Fin lecture 1 Librairie */
fclose( LibMod );
fprintf( LibDoc, "#\n$EndLIBDOC\n" );
fclose( LibDoc );
......
......@@ -23,8 +23,7 @@ public:
ModList* Next;
wxString m_Name, m_Doc, m_KeyWord;
public:
ModList()
public: ModList()
{
Next = NULL;
}
......@@ -35,26 +34,23 @@ public:
}
};
/* Fonctions locales */
static void DisplayCmpDoc( wxString& Name );
static void ReadDocLib( const wxString& ModLibName );
/*****/
/* variables locales */
static ModList* MList;
/********************************************************************/
void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
/********************************************************************/
{
MODULE* NewModule;
WinEDA_BasePcbFrame* parent = (WinEDA_BasePcbFrame*) GetParent();
if( Module == NULL )
{
if( parent->GetBoard() == NULL || parent->GetBoard()->m_Modules == NULL )
if( parent->GetBoard() == NULL
|| parent->GetBoard()->m_Modules == NULL )
return;
Module = Select_1_Module_From_BOARD( parent->GetBoard() );
......@@ -90,11 +86,8 @@ void WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
}
/****************************************************************************/
MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
wxDC* DC )
/****************************************************************************/
/* Permet de charger un module directement a partir de la librairie */
{
MODULE* module;
wxPoint curspos = GetScreen()->m_Curseur;
......@@ -106,9 +99,10 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
/* Ask for a component name or key words */
WinEDA_SelectCmp dlg( this, GetComponentDialogPosition(), HistoryList,
_( "Place Module" ), false );
dlg.SetComponentName( lastCommponentName );
if ( dlg.ShowModal() == wxID_CANCEL )
if( dlg.ShowModal() == wxID_CANCEL )
return NULL;
ModuleName = dlg.GetComponentName();
......@@ -142,13 +136,13 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
if( ModuleName.IsEmpty() )
{
DrawPanel->MouseToCursorSchema();
return NULL; /* annulation de commande */
return NULL; /* Cancel command. */
}
}
module = Get_Librairie_Module( library, ModuleName, FALSE );
if( ( module == NULL ) && AllowWildSeach ) /* Sarch with wildcard */
if( ( module == NULL ) && AllowWildSeach ) /* Search with wildcard */
{
AllowWildSeach = FALSE;
wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' );
......@@ -158,7 +152,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
if( ModuleName.IsEmpty() )
{
DrawPanel->MouseToCursorSchema();
return NULL; /* annulation de commande */
return NULL; /* Cancel command. */
}
else
module = Get_Librairie_Module( library, ModuleName, TRUE );
......@@ -177,15 +171,17 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
module->m_TimeStamp = GetTimeStamp();
GetBoard()->m_Status_Pcb = 0;
module->SetPosition( curspos );
/* TODO: call RecalculateAllTracksNetcode() only if some pads pads have
* a netname.
* If all pads are not connected (usually the case in module libraries,
* rebuild only the pad and list of nets ( faster)
*/
// GetBoard()->m_Pcb->m_NetInfo->BuildListOfNets();
RecalculateAllTracksNetcode( );
RecalculateAllTracksNetcode();
if ( DC )
if( DC )
module->Draw( DrawPanel, DC, GR_OR );
}
......@@ -196,14 +192,16 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
/** function Get_Librairie_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
* @param aLibrary: the full filename of the library to read. If empty, all active libraries are read
* 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 aModuleName = module name to load
* @param aDisplayMessageError = true to display an error message if any.
* @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& aLibraryFullFilename,
const wxString& aModuleName,
bool aDisplayMessageError )
{
......@@ -219,7 +217,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{
if ( one_lib )
if( one_lib )
fn = aLibraryFullFilename;
else
fn = wxFileName( wxEmptyString, g_LibName_List[ii],
......@@ -229,7 +227,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
if( !tmp )
{
if ( aDisplayMessageError )
if( aDisplayMessageError )
{
msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ),
GetChars( fn.GetFullName() ) );
......@@ -253,7 +251,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
msg.Printf( _( "Scan Lib: %s" ), GetChars( tmp ) );
Affiche_Message( msg );
/* lecture entete chaine definie par ENTETE_LIBRAIRIE */
/* Reading header ENTETE_LIBRAIRIE */
LineNum = 0;
GetLine( file, Line, &LineNum );
StrPurge( Line );
......@@ -267,7 +265,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
return NULL;
}
/* Lecture de la liste des composants de la librairie */
/* Reading the list of modules in the library. */
Found = 0;
while( !Found && GetLine( file, Line, &LineNum ) )
{
......@@ -284,13 +282,13 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
if( msg.CmpNoCase( aModuleName ) == 0 )
{
Found = 1;
break; /* Trouve! */
break; /* Found! */
}
}
}
}
/* Lecture de la librairie */
/* Read library. */
while( Found && GetLine( file, Line, &LineNum ) )
{
if( Line[0] != '$' )
......@@ -299,18 +297,18 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
continue;
if( strnicmp( Line, "$MODULE", 7 ) != 0 )
continue;
/* Lecture du nom du composant */
/* Read module name. */
Name = CONV_FROM_UTF8( Line + 8 );
if( Name.CmpNoCase( aModuleName ) == 0 ) /* composant localise */
if( Name.CmpNoCase( aModuleName ) == 0 )
{
NewModule = new MODULE( GetBoard() );
// Switch the locale to standard C (needed to print
// floating point numbers like 1.3)
SetLocaleTo_C_standard( );
SetLocaleTo_C_standard();
NewModule->ReadDescr( file, &LineNum );
SetLocaleTo_Default( ); // revert to the current locale
SetLocaleTo_Default(); // revert to the current locale
GetBoard()->Add( NewModule, ADD_APPEND );
fclose( file );
Affiche_Message( wxEmptyString );
......@@ -319,9 +317,8 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
}
fclose( file );
if ( one_lib )
if( one_lib )
break;
}
if( aDisplayMessageError )
......@@ -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
* 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 aMask = Display filter (wildcart)( Mask = 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
* @param aLibraryFullFilename = library to list (if aLibraryFullFilename ==
* void, list all modules)
* @param aMask = Display filter (wildcard)( Mask = 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
*/
wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
WinEDA_DrawFrame* active_window,
const wxString& aLibraryFullFilename,
const wxString& aMask, const wxString& aKeyWord )
{
int LineNum;
unsigned ii, NbModules;
char Line[1024];
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;
FILE* file;
wxString msg;
......@@ -363,15 +360,15 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
WinEDAListBox* ListBox = new WinEDAListBox( active_window, wxEmptyString,
NULL, OldName, DisplayCmpDoc,
wxColour( 200, 200, 255 ),
GetComponentDialogPosition());
GetComponentDialogPosition() );
wxBeginBusyCursor();
/* Recherche des composants en librairies */
/* Find modules in libraries. */
NbModules = 0;
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() )
{
fn = wxFileName( wxEmptyString, g_LibName_List[ii],
......@@ -393,8 +390,8 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
ReadDocLib( tmp );
if( !aKeyWord.IsEmpty() ) /* Inutile de lire la librairie si selection
* par mots cles, deja lus */
if( !aKeyWord.IsEmpty() ) /* Don't read the library if selection
* by keywords, already read. */
{
if( !aLibraryFullFilename.IsEmpty() )
break;
......@@ -411,10 +408,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
}
// Statusbar library loaded message
msg = _( "Library " ) + fn.GetFullPath() + _(" loaded");
msg = _( "Library " ) + fn.GetFullPath() + _( " loaded" );
Affiche_Message( msg );
/* lecture entete */
/* Read header. */
LineNum = 0;
GetLine( file, Line, &LineNum, sizeof(Line) - 1 );
......@@ -428,7 +425,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
continue;
}
/* Lecture de la librairie */
/* Read library. */
while( GetLine( file, Line, &LineNum, sizeof(Line) - 1 ) )
{
if( Line[0] != '$' )
......@@ -454,10 +451,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
NbModules++;
}
}
} /* Fin Lecture INDEX */
} /* End read INDEX */
}
/* Fin lecture 1 Librairie */
/* End read library. */
fclose( file );
file = NULL;
......@@ -465,7 +462,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
break;
}
/* creation de la liste des modules si recherche par mots-cles */
/* Create list of modules if search by keyword. */
if( !aKeyWord.IsEmpty() )
{
ModList* ItemMod = MList;
......@@ -494,7 +491,6 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
ListBox->Destroy();
/* liberation mem de la liste des textes doc module */
while( MList != NULL )
{
ModList* NewMod = MList->Next;
......@@ -509,13 +505,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
}
/******************************************/
static void DisplayCmpDoc( wxString& Name )
/*******************************************/
/* Routine de recherche et d'affichage de la doc du composant Name
* La liste des doc est pointee par MList
/* Find and display the doc Component Name
* The list of doc is pointed to by mlist.
*/
static void DisplayCmpDoc( wxString& Name )
{
ModList* Mod = MList;
......@@ -525,10 +518,9 @@ static void DisplayCmpDoc( wxString& Name )
return;
}
/* Recherche de la description */
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;
Mod = Mod->Next;
}
......@@ -544,14 +536,11 @@ static void DisplayCmpDoc( wxString& Name )
}
/***************************************************/
static void ReadDocLib( const wxString& ModLibName )
/***************************************************/
/* 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
/* Read the doc file and combine with a library ModLibName.
* Load in memory the list of docs string pointed to by mlist
* ModLibName = full file name of the library modules
*/
static void ReadDocLib( const wxString& ModLibName )
{
ModList* NewMod;
char Line[1024];
......@@ -567,13 +556,12 @@ static void ReadDocLib( const wxString& ModLibName )
if( strnicmp( Line, ENTETE_LIBDOC, L_ENTETE_LIB ) != 0 )
return;
/* Lecture de la librairie */
while( GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ) )
{
if( Line[0] != '$' )
continue;
if( Line[1] == 'E' )
break;;
break; ;
if( Line[1] == 'M' ) /* Debut decription 1 module */
{
NewMod = new ModList();
......@@ -599,33 +587,28 @@ static void ReadDocLib( const wxString& ModLibName )
break;
}
}
} /* lecture 1 descr module */
} /* End read 1 module. */
}
/* Fin lecture librairie */
fclose( LibDoc );
}
/********************************************************************/
MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb )
/********************************************************************/
/* Affiche la liste des modules du PCB en cours
* Retourne un pointeur si module selectionne
* retourne NULL sinon
/* Display the list of modules currently PCB
* Returns a pointer if module selected
* Returns NULL otherwise
*/
MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb )
{
int ii;
MODULE* Module;
static wxString OldName;/* Memorise le nom du dernier composant charge */
static wxString OldName; /* Save name of last module selectec. */
wxString CmpName, msg;
WinEDAListBox* ListBox = new WinEDAListBox( this, wxEmptyString,
NULL, wxEmptyString, NULL,
wxColour( 200, 200, 255 ) );
/* Recherche des composants en BOARD */
ii = 0;
Module = Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() )
......@@ -652,7 +635,6 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb )
OldName = CmpName;
// Recherche du pointeur sur le module
Module = Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() )
{
......
/*****************************/
/* Localisation des elements */
/*****************************/
/*******************/
/* Locate element. */
/*******************/
#include "fctsys.h"
......@@ -28,20 +28,17 @@ wxPoint inline RefPos( int typeloc )
}
/*******************************************************************/
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer )
/*******************************************************************/
/* Localise une via au point pX,pY
* Si layer < 0 la via sera localisee quelle que soit la couche
* Si layer = 0 .. 15 la via sera localisee selon son type:
* - traversante : toutes couches
* - aveugle = entre couches utiles
* - borgnes idem
* Entree : coord du point de reference, couche
* Sortie: NULL si pas de via
* (TRACK*) adresse de la via
/* Locates a via point pX, pY
* If layer < 0 will be located via whatever layer
* If layer = 0 .. 15 Via will be located according to its type:
* - Traverse: all layers
* - = Blind between layers useful
* - Blind idem
* Entry: coord point of reference, layer
* Output: NULL if not via
* (* TRACK) address via
*/
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer )
{
TRACK* track;
......@@ -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* track;
......@@ -87,18 +82,15 @@ TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer )
}
/********************************************************************/
D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr )
/********************************************************************/
/* localisation de la pastille connectee au point de piste a tester
* entree : ptr_piste: pointeur sur le segment de piste
* extr = flag = START -> debut du segment a tester
* = END -> fin du segment a tester
* retourne:
* un pointeur sur la description de la pastille si localisation
* pointeur NULL si pastille non trouvee
/* Location of the pellet CONNECTED developed a test track
* 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
* Returns:
* A pointer to the description of the pad if found.
* NULL pointer if pad NOT FOUND
*/
D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr )
{
D_PAD* ptr_pad = NULL;
wxPoint ref_pos;
......@@ -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
* par la souris, recherche faite sur toutes les empreintes.
* entree :
* - coord souris
* ou ref_pos
* retourne:
* pointeur sur la description de la pastille si localisation
* pointeur NULL si pastille non trouvee
* num_empr = numero d'empreinte du pad
* Locate pad pointed to by the coordinates ref_pos.x,, ref_pos.y or
* the mouse, search done on all tracks.
* Input:
* - mouse coord or ref_pos
* Returns:
* Pointer to the pad if found.
* NULL pointer if pad NOT FOUND
* Num_empr = number of fingerprint 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 )
{
wxPoint ref_pos = RefPos( typeloc );
......@@ -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() )
{
......@@ -175,21 +162,15 @@ D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, bool OnlyCurrentLayer
}
/******************************************************************************/
/* D_PAD* Locate_Pads(MODULE * module, int masque_layer,int typeloc) */
/* D_PAD* Locate_Pads(MODULE * module, const wxPoint & ref_pos,int masque_layer) */
/******************************************************************************/
/* localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou
* par la souris, concernant l'empreinte en cours.
* entree :
* - 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
/* Locate pad pointed to by the coordinate ref_pos.x,, ref_pos.y or
* the mouse on the current footprint.
* Input:
* - General parameters of the footprint update by characters()
* - = Masque_layer layer(s) (bit_masque) which must be the pad
* Returns:
* A pointer to the pad if found
* NULL pointer if pad NOT FOUND
*/
D_PAD* Locate_Pads( MODULE* module, int masque_layer, int typeloc )
{
wxPoint ref_pos = RefPos( typeloc );
......@@ -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() )
{
/* ... et sur la bonne couche */
if( (pt_pad->m_Masque_Layer & masque_layer) == 0 )
/* ... and on the correct layer. */
if( ( pt_pad->m_Masque_Layer & masque_layer ) == 0 )
continue;
if( pt_pad->HitTest( ref_pos ) )
......@@ -216,11 +197,12 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
/**
* Function Locate_Prefered_Module
* 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
* to performe hit-testing.
* distance is calculated via manhattan distance from the center of the bounding rectangle
* to the cursor postition.
* to perform hit-testing.
* distance is calculated via manhattan distance from the center of the
* bounding rectangle to the cursor position.
*
* @param Pcb The BOARD to search within.
* @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 )
MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
{
MODULE* pt_module;
int lx, ly; /* dimensions du rectangle d'encadrement du module */
MODULE* module = NULL; /* module localise sur la couche active */
MODULE* Altmodule = NULL; /* module localise sur les couches non actives */
int min_dim = 0x7FFFFFFF; /* dim mini du module localise sur la couche active */
int alt_min_dim = 0x7FFFFFFF; /* dim mini du module localise sur les couches non actives */
int layer; /* pour calcul de couches prioritaires */
wxPoint ref_pos; /* coord du point de reference pour la localisation */
int lx, ly;
MODULE* module = NULL;
MODULE* Altmodule = NULL;
int min_dim = 0x7FFFFFFF;
int alt_min_dim = 0x7FFFFFFF;
int layer;
wxPoint ref_pos;
ref_pos = RefPos( typeloc );
......@@ -246,14 +228,16 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
if( !pt_module->HitTest( ref_pos ) )
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() )
continue;
/* calcul de priorite: la priorite est donnee a la couche
* d'appartenance du module et a la couche cuivre si le module
* est sur couche serigr,adhesive cuivre, a la couche cmp si le module
* est sur couche serigr,adhesive composant */
/* Calculate priority: the priority is given to the layer of the
* module and the copper layer if the module layer is indelible,
* adhesive copper, a layer if cmp module layer is indelible,
* adhesive component.
*/
layer = pt_module->GetLayer();
if( layer==ADHESIVE_N_CU || layer==SILKSCREEN_N_CU )
......@@ -262,34 +246,37 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP )
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_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_Pos.y;
//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();
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( dist <= min_dim ){
/* meilleure empreinte localisee sur couche active */
if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer )
{
if( dist <= min_dim )
{
/* better footprint shown on the active layer */
module = pt_module;
min_dim = dist;
}
}
else if( !(typeloc & MATCH_LAYER)
&& ( !(typeloc & VISIBLE_ONLY) || IsModuleLayerVisible( layer ) ) )
else if( !( typeloc & MATCH_LAYER )
&& ( !( typeloc & VISIBLE_ONLY )
|| IsModuleLayerVisible( layer ) ) )
{
if( dist <= alt_min_dim )
{
/* meilleure empreinte localisee sur autres couches */
/* better footprint shown on other layers */
Altmodule = pt_module;
alt_min_dim = dist;
}
......@@ -309,13 +296,12 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
return NULL;
}
/******************************************************************/
inline bool IsPointsAreNear(wxPoint & p1, wxPoint & p2, int max_dist)
/******************************************************************/
/*
return true if the dist between p1 and p2 < max_dist
Currently in test (currently rasnest algos work only if p1 == p2)
* return true if the dist between p1 and p2 < max_dist
* 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
{
......@@ -331,13 +317,11 @@ int dist;
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
* if extr == START, the starting track segment PtRefSegm is used to locate a connected segment
/** Search for the track (or via) segment which is connected to the track
* 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
* The test connection consider only end track segments
*
......@@ -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
*
* 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
*
* @param PtRefSegm = reference segment
......@@ -353,6 +338,8 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
* @param pt_lim = upper limit for search (can be NULL)
* @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;
......@@ -369,7 +356,6 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
Reflayer = PtRefSegm->ReturnMaskLayer();
/* 1ere passe */
PtSegmB = PtSegmN = PtRefSegm;
for( ii = 0; ii < NEIGHTBOUR_COUNT_MAX; ii++ )
......@@ -384,17 +370,18 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
if( PtSegmN == PtRefSegm )
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;
if( IsPointsAreNear(pos_ref, PtSegmN->m_Start, max_dist) )
{ /* Test des couches */
{
if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN;
}
if( IsPointsAreNear(pos_ref, PtSegmN->m_End, max_dist) )
{ /* Test des couches */
{
if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN;
}
......@@ -415,13 +402,13 @@ suite:
max_dist = (PtSegmB->m_Width + PtRefSegm->m_Width)/2;
if( IsPointsAreNear(pos_ref, PtSegmB->m_Start, max_dist) )
{ /* Test des couches */
{
if( Reflayer & PtSegmB->ReturnMaskLayer() )
return PtSegmB;
}
if( IsPointsAreNear(pos_ref, PtSegmB->m_End, max_dist) )
{ /* Test des couches */
{
if( Reflayer & PtSegmB->ReturnMaskLayer() )
return PtSegmB;
}
......@@ -435,7 +422,7 @@ suite1:
}
}
/* Recherche generale */
/* General search. */
for( PtSegmN = pt_base; PtSegmN != NULL; PtSegmN = PtSegmN->Next() )
{
if( PtSegmN->GetState( DELETED | BUSY ) )
......@@ -451,17 +438,16 @@ suite1:
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) )
{ /* Test des couches */
if( IsPointsAreNear( pos_ref, PtSegmN->m_Start, max_dist ) )
{
if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN;
}
if( IsPointsAreNear(pos_ref, PtSegmN->m_End, max_dist) )
{ /* Test des couches */
if( IsPointsAreNear( pos_ref, PtSegmN->m_End, max_dist ) )
{
if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN;
}
......@@ -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.
* 2 - routine de localisation du segment de piste pointe par le point
* ref_pos.x , ref_pos.y.r
* 1 - Locate segment of track leading from the mouse.
* 2 - Locate segment of track point by point
* 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 )
{
wxPoint ref_pos = RefPos( 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() )
{
......@@ -503,14 +483,16 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa
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;
}
if( g_DesignSettings.IsLayerVisible( layer ) == false )
continue;
if( track->Type() == TYPE_VIA ) /* VIA rencontree */
if( track->Type() == TYPE_VIA ) /* VIA encountered. */
{
if( track->HitTest( ref_pos ) )
return track;
......@@ -518,7 +500,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa
else
{
if( (g_TabOneLayerMask[layer] & MasqueLayer) == 0 )
continue; /* Segments sur couches differentes */
continue; /* Segments on different layers. */
if( track->HitTest( ref_pos ) )
return track;
......@@ -528,22 +510,14 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa
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.
* 2 - routine de localisation du segment de zone pointe par le point
* ref_pos.x , ref_pos.y.r
* 1 - Locate zone area by the mouse.
* 2 - Locate zone area by point
* 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 )
{
......@@ -568,21 +542,18 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer )
}
/*******************************************************************************/
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_layer )
/*******************************************************************************/
/* 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.
/* Find the pad center px, py,
* The layer INDICATED BY masque_layer (bitwise)
* (Runway end)
* The list of pads must already exist.
*
* retourne :
* NULL si pas de pad localise.
* pointeur sur la structure descr_pad correspondante si pad trouve
* (bonne position ET bonne couche).
* Returns:
* NULL if no pad located.
* Pointer to the structure corresponding descr_pad if pad found
* (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 )
{
......@@ -591,7 +562,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_
if( pad->m_Pos != ref_pos )
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 )
return pad;
}
......@@ -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,
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;
......@@ -624,14 +592,12 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
{
if( ref_pos == PtSegm->m_Start )
{
/* Test des couches */
if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm;
}
if( ref_pos == PtSegm->m_End )
{
/* Test des couches */
if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm;
}
......@@ -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,
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;
......@@ -666,7 +628,6 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
{
if( PtSegm->GetState( BUSY | DELETED ) == 0 )
{
/* Test des couches */
if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm;
}
......@@ -678,4 +639,3 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
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