Solved an annotation problem, some code cleanning and translation

This commit is contained in:
CHARRAS 2007-12-03 06:54:19 +00:00
parent 0803392344
commit 4002c6f418
13 changed files with 190 additions and 274 deletions

View File

@ -4,6 +4,12 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2007-Dec-02 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema:
Solved an annotation problem: in multiple parts per package components,
when sorted by position, parts were not grouped by package.
2007-Dec-2 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================

View File

@ -2,17 +2,19 @@
/* annotate.cpp: component annotation */
/**************************************/
/* Local Variable */
static bool AnnotProject = true;
static bool SortByPosition = true;
#include "annotate_dialog.cpp"
#include "netlist.h"
#include "protos.h"
/* fonctions exportees */
int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumSheet );
int AnnotTriComposant( const void* o1, const void* o2 );
void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp );
/* fonctions locales */
/* Local Functions*/
static int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumSheet );
static int AnnotTriComposant( const void* o1, const void* o2 );
static void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp );
static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp );
static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp );
static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseListeCmp,
@ -20,19 +22,15 @@ static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseLis
static int ExistUnit( CmpListStruct* Objet, int Unit,
CmpListStruct* BaseListeCmp, int NbOfCmp );
/* Variable locales */
static bool AnnotProject = TRUE;
static bool SortByPosition = TRUE;
/**************************************/
void ReAnnotatePowerSymbolsOnly()
void ReAnnotatePowerSymbolsOnly( void )
/**************************************/
/* Used to reannotate the power symbols, before testing erc or computing netlist
* when a true component reannotation is not necessary
*
* In order to avoid conflicts the ref number start with a 0:
* In order to avoid conflicts the ref number starts with a 0:
* PWR with id 12 is named PWR12 in global annotation and PWR012 by the Power annotation
*/
{
@ -66,9 +64,13 @@ void ReAnnotatePowerSymbolsOnly()
}
/******************************************************************/
/***********************************************************************/
void InstallAnnotateFrame( WinEDA_SchematicFrame* parent, wxPoint& pos )
/******************************************************************/
/***********************************************************************/
/** Function InstallAnnotateFrame
* Install the annotate dialog frame
*/
{
WinEDA_AnnotateFrame* frame = new WinEDA_AnnotateFrame( parent );
@ -81,7 +83,7 @@ void InstallAnnotateFrame( WinEDA_SchematicFrame* parent, wxPoint& pos )
void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
/******************************************************************/
/*
/** Function WinEDA_AnnotateFrame::AnnotateComponents
* Compute the annotation of the components for the whole projeect, or the current sheet only.
* All the components or the new ones only will be annotated.
*/
@ -92,8 +94,8 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
wxBusyCursor dummy;
AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? TRUE : FALSE;
SortByPosition = (m_AnnotSortCmpCtrl->GetSelection() == 0) ? TRUE : FALSE;
AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? true : FALSE;
SortByPosition = (m_AnnotSortCmpCtrl->GetSelection() == 0) ? true : FALSE;
/* If it is an annotation for all the components, reset previous annotation: */
if( m_AnnotNewCmpCtrl->GetSelection() == 0 )
@ -113,7 +115,7 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
/* First pass: Component counting */
screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen;
if( AnnotProject == TRUE )
if( AnnotProject == true )
{
NbOfCmp = 0;
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
@ -132,7 +134,7 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
/* Second pass : Int data tables */
screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen;
if( AnnotProject == TRUE )
if( AnnotProject == true )
{
ii = 0;
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
@ -147,22 +149,22 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
if( ii != NbOfCmp )
DisplayError( this, wxT( "Internal error in AnnotateComponents()" ) );
/* Separation des Numeros de la reference: IC1 -> IC, et 1 dans .m_NumRef */
/* Break full components reference in name (prefix) and number: example: IC1 become IC, and 1 */
BreakReference( BaseListeCmp, NbOfCmp );
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct),
( int( * ) ( const void*, const void* ) )AnnotTriComposant );
/* Recalcul des numeros de reference */
/* Recalculate reference numbers */
ComputeReferenceNumber( BaseListeCmp, NbOfCmp );
ReAnnotateComponents( BaseListeCmp, NbOfCmp );
MyFree( BaseListeCmp ); BaseListeCmp = NULL;
/* Final control */
CheckAnnotate( m_Parent, AnnotProject ? FALSE : TRUE );
CheckAnnotate( m_Parent, AnnotProject ? FALSE : true );
m_Parent->DrawPanel->Refresh( TRUE ); /* Refresh screen */
m_Parent->DrawPanel->Refresh( true ); /* Refresh screen */
EndModal( 1 );
}
@ -181,10 +183,10 @@ void WinEDA_AnnotateFrame::DeleteAnnotation( wxCommandEvent& event )
if( !IsOK( this, _( "Previous Annotation will be deleted. Continue ?" ) ) )
{
m_Abort = TRUE; return;
m_Abort = true; return;
}
AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? TRUE : FALSE;
AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? true : FALSE;
m_Abort = FALSE;
/* Build the screen list */
@ -197,7 +199,7 @@ void WinEDA_AnnotateFrame::DeleteAnnotation( wxCommandEvent& event )
ScreenSch->SetModify();
if( AnnotProject == TRUE )
if( AnnotProject == true )
screen = ScreenList.GetFirst();
else
screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen;
@ -218,7 +220,7 @@ void WinEDA_AnnotateFrame::DeleteAnnotation( wxCommandEvent& event )
break;
}
m_Parent->DrawPanel->Refresh( TRUE );
m_Parent->DrawPanel->Refresh( true );
EndModal( 0 );
}
@ -321,18 +323,16 @@ int AnnotTriComposant( const void* o1, const void* o2 )
int ii = strnicmp( Objet1->m_TextRef, Objet2->m_TextRef, 32 );
if( SortByPosition == TRUE )
if( SortByPosition == true )
{
if( ii == 0 )
ii = Objet1->m_Sheet - Objet2->m_Sheet;
if( ii == 0 )
ii = Objet1->m_Unit - Objet2->m_Unit;
if( ii == 0 )
ii = Objet1->m_Pos.x - Objet2->m_Pos.x;
if( ii == 0 )
ii = Objet1->m_Pos.y - Objet2->m_Pos.y;
}
else
else // Sort by value
{
if( ii == 0 )
ii = strnicmp( Objet1->m_TextValue, Objet2->m_TextValue, 32 );
@ -340,6 +340,10 @@ int AnnotTriComposant( const void* o1, const void* o2 )
ii = Objet1->m_Unit - Objet2->m_Unit;
if( ii == 0 )
ii = Objet1->m_Sheet - Objet2->m_Sheet;
if( ii == 0 )
ii = Objet1->m_Pos.x - Objet2->m_Pos.x;
if( ii == 0 )
ii = Objet1->m_Pos.y - Objet2->m_Pos.y;
}
if( ii == 0 )
@ -384,19 +388,16 @@ static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp )
void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
/**************************************************************/
/* Modifie dans BaseListeCmp la reference des composants en supprimant la
* partie nombre de la partie texte.
* Place le nombre dans .m_NumRef
* Pour les composants multiples non encore annotes, met .m_Unit a sa valeur max
* Utilise:
* BaseListeCmp
* NbOfCmp
/** BreakReference
* Break full components reference in name (prefix) and number: example: IC1 become IC, and 1 in .m_NumRef
* For multi part per package components not already annotated, set .m_Unit to a max value (0x7FFFFFFF)
* @param BaseListeCmp = list of component
* @param NbOfCmp = item count in the list
*/
{
int ii, ll;
char* Text;
/* Separation des Numeros de la reference: IC1 -> IC, et 1 dans .m_NumRef */
for( ii = 0; ii < NbOfCmp; ii++ )
{
BaseListeCmp[ii].m_NumRef = -1;
@ -404,7 +405,7 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
ll = strlen( Text ) - 1;
if( Text[ll] == '?' )
{
BaseListeCmp[ii].m_IsNew = TRUE;
BaseListeCmp[ii].m_IsNew = true;
if( !BaseListeCmp[ii].m_PartsLocked )
BaseListeCmp[ii].m_Unit = 0x7FFFFFFF;
Text[ll] = 0;
@ -413,7 +414,7 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
if( isdigit( Text[ll] ) == 0 )
{
BaseListeCmp[ii].m_IsNew = TRUE;
BaseListeCmp[ii].m_IsNew = true;
if( !BaseListeCmp[ii].m_PartsLocked )
BaseListeCmp[ii].m_Unit = 0x7FFFFFFF;
continue;
@ -453,7 +454,7 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
Text = BaseListeCmp[ii].m_TextRef;
if( *Text == '#' )
{
BaseListeCmp[ii].m_IsNew = TRUE;
BaseListeCmp[ii].m_IsNew = true;
BaseListeCmp[ii].m_NumRef = 0;
}
}
@ -472,7 +473,7 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
LastReferenceNumber = GetLastReferenceNumber( BaseListeCmp + ii, BaseListeCmp, NbOfCmp );
}
/* Annotation of mono-part components ( 1 part per package ) (trivial case)*/
/* Annotation of one part per package components (trivial case)*/
if( BaseListeCmp[ii].m_NbParts <= 1 )
{
if( BaseListeCmp[ii].m_IsNew )
@ -514,13 +515,12 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
continue;
Text = BaseListeCmp[jj].m_TextRef;
if( strnicmp( RefText, Text, 32 ) != 0 )
break; // references are different
continue; // references are different
Text = BaseListeCmp[jj].m_TextValue;
if( strnicmp( ValText, Text, 32 ) != 0 )
break; // values are different
continue; // values are different
if( !BaseListeCmp[jj].m_IsNew )
{
//BaseListeCmp[jj].m_Flag = 1;
continue;
}
/* Component without reference number found, annotate it if possible */
@ -542,9 +542,13 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseListeCmp, int NbOfCmp )
/*************************************************************************************************/
/* Recherche le plus grand numero de reference dans les composants
* de meme prefixe de reference que celui pointe par Objet
* la liste des composants est supposee triee
/** Function GetLastReferenceNumber
* Search the last (bigger) reference number in the component list
* for the prefix reference given by Objet
* The component list must be sorted
* @param Objet = reference item ( Objet->m_TextRef is the search pattern)
* @param BaseListeCmp = list of items
* @param NbOfCmp = items count in list of items
*/
{
CmpListStruct* LastObjet = BaseListeCmp + NbOfCmp;
@ -608,9 +612,10 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
/******************************************************************/
/* Retourne le nombre de composants non annotés ou de meme référence (doublés)
* Si OneSheetOnly : recherche sur le schema courant
* sinon: recherche sur toute la hierarchie
/** Function CheckAnnotate
* @return composent count ( which are not annotated or have the same reference (duplicates))
* @param OneSheetOnly : true = search is made only in the current sheet
* false = search in whole hierarchy (usual search).
*/
{
int NbSheet, ii, NumSheet = 1, error, NbOfCmp;
@ -619,7 +624,7 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
wxString Buff;
wxString msg, cmpref;
/* build tje screen list */
/* build the screen list */
EDA_ScreenList ScreenList( NULL );
NbSheet = ScreenList.GetCount();
@ -628,7 +633,7 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
ScreenSch->SetModify();
ScreenList.UpdateSheetNumberAndDate();
/* 1ere passe : Comptage du nombre de composants */
/* first pass : count composents */
screen = (SCH_SCREEN*) frame->m_CurrentScreen;
if( !OneSheetOnly )
{
@ -647,10 +652,11 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
return 0;
}
/* Second pass : create the list of components */
ii = sizeof(CmpListStruct) * NbOfCmp;
ListeCmp = (CmpListStruct*) MyZMalloc( ii );
/* 2eme passe : Remplissage du tableau des caracteristiques */
if( OneSheetOnly == 0 )
{
ii = 0;
@ -668,10 +674,10 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
qsort( ListeCmp, NbOfCmp, sizeof(CmpListStruct), AnnotTriComposant );
/* Separation des Numeros de la reference: IC1 -> IC, et 1 dans .m_NumRef */
/* Break full components reference in name (prefix) and number: example: IC1 become IC, and 1 */
BreakReference( ListeCmp, NbOfCmp );
/* comptage des elements non annotes */
/* count not yet annotated items */
error = 0;
for( ii = 0; ii < NbOfCmp - 1; ii++ )
{
@ -729,9 +735,10 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
if( (stricmp( ListeCmp[ii].m_TextRef, ListeCmp[ii + 1].m_TextRef ) != 0)
|| ( ListeCmp[ii].m_NumRef != ListeCmp[ii + 1].m_NumRef ) )
continue;
/* Meme reference trouvée */
/* Il y a erreur si meme unite */
/* Same reference found */
/* If same unit, error ! */
if( ListeCmp[ii].m_Unit == ListeCmp[ii + 1].m_Unit )
{
if( ListeCmp[ii].m_NumRef >= 0 )
@ -753,8 +760,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
continue;
}
/* Il y a erreur si unites differentes mais nombre de parts differentes
* par boitier (ex U3 ( 1 part) et U3B sont incompatibles) */
/* Test error if units are different but number of parts per package to hight
* (ex U3 ( 1 part) and we find U3B the is an error) */
if( ListeCmp[ii].m_NbParts != ListeCmp[ii + 1].m_NbParts )
{
if( ListeCmp[ii].m_NumRef >= 0 )
@ -775,7 +782,7 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
error++;
}
/* Il y a erreur si unites differentes ET valeurs différentes */
/* Error if values are différent between units, for the same reference */
if( stricmp( ListeCmp[ii].m_TextValue, ListeCmp[ii + 1].m_TextValue ) != 0 )
{
wxString nextcmpref, cmpvalue, nextcmpvalue;

View File

@ -155,6 +155,8 @@ void WinEDA_AnnotateFrame::CreateControls()
itemBoxSizer7->Add(itemButton10, 0, wxGROW|wxALL, 5);
////@end WinEDA_AnnotateFrame content construction
m_AnnotSortCmpCtrl->SetSelection(SortByPosition ? 0 : 1);
}
/*!

View File

@ -148,7 +148,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_PCB_GLOBAL_DELETE:
Erase_Current_Layer( &dc, TRUE );
Erase_Current_Layer( TRUE );
break;
case wxID_CUT:

View File

@ -32,7 +32,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
{
case ID_MENU_LOAD_FILE:
case ID_LOAD_FILE:
if( Clear_Pcb( &dc, TRUE ) )
if( Clear_Pcb( TRUE ) )
{
LoadOneGerberFile( wxEmptyString, &dc, 0 );
}
@ -56,7 +56,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
case ID_MENU_NEW_BOARD:
case ID_NEW_BOARD:
Clear_Pcb( &dc, TRUE );
Clear_Pcb( TRUE );
Zoom_Automatique( FALSE );
GetScreen()->SetRefreshReq();
break;
@ -71,7 +71,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
case ID_LOAD_FILE_8:
case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10:
if( Clear_Pcb( &dc, TRUE ) )
if( Clear_Pcb( TRUE ) )
{
LoadOneGerberFile(
GetLastProject( id - ID_LOAD_FILE_1 ).GetData(),

View File

@ -15,7 +15,7 @@
/********************************************************/
bool WinEDA_GerberFrame::Clear_Pcb( wxDC* DC, bool query )
bool WinEDA_GerberFrame::Clear_Pcb( bool query )
/********************************************************/
/* Realise les init des pointeurs et variables
@ -82,7 +82,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( wxDC* DC, bool query )
/*********************************************************/
void WinEDA_GerberFrame::Erase_Zones( wxDC* DC, bool query )
void WinEDA_GerberFrame::Erase_Zones( bool query )
/*********************************************************/
{
if( query && !IsOK( this, _( "Delete zones ?" ) ) )
@ -98,10 +98,9 @@ void WinEDA_GerberFrame::Erase_Zones( wxDC* DC, bool query )
}
/*****************************************************/
void WinEDA_GerberFrame::Erase_Segments_Pcb( wxDC* DC,
bool all_layers, bool query )
/*****************************************************/
/************************************************************************/
void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query )
/************************************************************************/
{
BOARD_ITEM* PtStruct;
BOARD_ITEM* PtNext;
@ -135,10 +134,9 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( wxDC* DC,
}
/****************************************************************/
void WinEDA_GerberFrame::Erase_Pistes( wxDC* DC, int masque_type,
bool query )
/****************************************************************/
/******************************************************************/
void WinEDA_GerberFrame::Erase_Pistes( int masque_type, bool query )
/******************************************************************/
/* Efface les segments de piste, selon les autorisations affichees
* masque_type = masque des options de selection:
@ -166,7 +164,7 @@ void WinEDA_GerberFrame::Erase_Pistes( wxDC* DC, int masque_type,
/*****************************************************************/
void WinEDA_GerberFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query )
/*****************************************************************/
{
BOARD_ITEM* PtStruct;
@ -187,9 +185,9 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
}
/*******************************************************************/
void WinEDA_GerberFrame::Erase_Current_Layer( wxDC* DC, bool query )
/*******************************************************************/
/*********************************************************/
void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
/*********************************************************/
{
int layer = GetScreen()->m_Active_Layer;
wxString msg;

View File

@ -393,15 +393,15 @@ public:
// Read/write fonctions:
EDA_BaseStruct* ReadDrawSegmentDescr( FILE* File, int* LineNum );
int ReadListeSegmentDescr( wxDC* DC, FILE* File,
int ReadListeSegmentDescr( FILE* File,
TRACK* PtSegm, int StructType,
int* LineNum, int NumSegm );
int ReadSetup( FILE* File, int* LineNum );
int ReadGeneralDescrPcb( wxDC* DC, FILE* File, int* LineNum );
int ReadGeneralDescrPcb( FILE* File, int* LineNum );
// PCB handling
bool Clear_Pcb( wxDC* DC, bool query );
bool Clear_Pcb( bool query );
/**
* Function PcbGeneralLocateAndDisplay
@ -681,12 +681,12 @@ public:
// loading modules: see WinEDA_BasePcbFrame
// Borad handling
void Erase_Zones( wxDC* DC, bool query );
void Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query );
// Board handling
void Erase_Zones( bool query );
void Erase_Segments_Pcb( bool is_edges, bool query );
void Erase_Pistes( wxDC* DC, int masque_type, bool query );
void Erase_Modules( wxDC* DC, bool query );
void Erase_Textes_Pcb( wxDC* DC, bool query );
void Erase_Modules( bool query );
void Erase_Textes_Pcb( bool query );
void Erase_Marqueurs();
void UnDeleteItem( wxDC* DC );
void RemoveStruct( BOARD_ITEM* Item, wxDC* DC );
@ -902,12 +902,12 @@ public:
void Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
// PCB handling
bool Clear_Pcb( wxDC* DC, bool query );
void Erase_Current_Layer( wxDC* DC, bool query );
void Erase_Zones( wxDC* DC, bool query );
void Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query );
void Erase_Pistes( wxDC* DC, int masque_type, bool query );
void Erase_Textes_Pcb( wxDC* DC, bool query );
bool Clear_Pcb( bool query );
void Erase_Current_Layer( bool query );
void Erase_Zones( bool query );
void Erase_Segments_Pcb( bool is_edges, bool query );
void Erase_Pistes( int masque_type, bool query );
void Erase_Textes_Pcb( bool query );
void UnDeleteItem( wxDC* DC );
void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number );

View File

@ -34,7 +34,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
{
case ID_MENU_LOAD_FILE:
case ID_LOAD_FILE:
Clear_Pcb( &dc, TRUE );
Clear_Pcb(TRUE );
LoadOnePcbFile( wxEmptyString, &dc, FALSE );
ReCreateAuxiliaryToolbar();
break;
@ -64,7 +64,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
if( !IsOK( this, msg ) )
break;
}
Clear_Pcb( &dc, TRUE );
Clear_Pcb( TRUE );
LoadOnePcbFile( filename, &dc, FALSE );
GetScreen()->m_FileName = oldfilename;
SetTitle( GetScreen()->m_FileName );
@ -79,7 +79,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
case ID_MENU_NEW_BOARD:
case ID_NEW_BOARD:
Clear_Pcb( &dc, TRUE );
Clear_Pcb( TRUE );
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData() );
SetTitle( GetScreen()->m_FileName );
@ -95,7 +95,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
case ID_LOAD_FILE_8:
case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10:
Clear_Pcb( &dc, TRUE );
Clear_Pcb(TRUE );
wxSetWorkingDirectory( wxPathOnly( GetLastProject( id - ID_LOAD_FILE_1 ) ) );
LoadOnePcbFile( GetLastProject( id - ID_LOAD_FILE_1 ).GetData(),
&dc, FALSE );

View File

@ -41,38 +41,38 @@ void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event )
if( m_DelAlls->GetValue() )
{
m_Parent->Clear_Pcb( &dc, TRUE );
m_Parent->Clear_Pcb( TRUE );
redraw = TRUE;
}
else
{
if( m_DelZones->GetValue() )
{
m_Parent->Erase_Zones( &dc, TRUE );
m_Parent->Erase_Zones( TRUE );
redraw = TRUE;
}
if( m_DelTexts->GetValue() )
{
m_Parent->Erase_Textes_Pcb( &dc, TRUE );
m_Parent->Erase_Textes_Pcb( TRUE );
redraw = TRUE;
}
if( m_DelEdges->GetValue() )
{
m_Parent->Erase_Segments_Pcb( &dc, TRUE, TRUE );
m_Parent->Erase_Segments_Pcb( TRUE, TRUE );
redraw = TRUE;
}
if( m_DelDrawings->GetValue() )
{
m_Parent->Erase_Segments_Pcb( &dc, FALSE, TRUE );
m_Parent->Erase_Segments_Pcb( FALSE, TRUE );
redraw = TRUE;
}
if( m_DelModules->GetValue() )
{
m_Parent->Erase_Modules( &dc, TRUE );
m_Parent->Erase_Modules( TRUE );
redraw = TRUE;
}
@ -108,7 +108,7 @@ void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event )
/*********************************************************/
bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query )
bool WinEDA_BasePcbFrame::Clear_Pcb( bool query )
/*********************************************************/
/* Realise les init des pointeurs et variables
@ -146,7 +146,7 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query )
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
DelLimitesZone( DC, FALSE );
DelLimitesZone( NULL, FALSE );
for( ; g_UnDeleteStackPtr != 0; )
{
@ -207,7 +207,7 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query )
/************************************************************/
void WinEDA_PcbFrame::Erase_Zones( wxDC* DC, bool query )
void WinEDA_PcbFrame::Erase_Zones( bool query )
/************************************************************/
{
if( query && !IsOK( this, _( "Delete Zones ?" ) ) )
@ -220,14 +220,14 @@ void WinEDA_PcbFrame::Erase_Zones( wxDC* DC, bool query )
m_Pcb->m_NbSegmZone = 0;
}
DelLimitesZone( DC, FALSE );
DelLimitesZone( NULL, FALSE );
GetScreen()->SetModify();
}
/*****************************************************************************/
void WinEDA_PcbFrame::Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query )
void WinEDA_PcbFrame::Erase_Segments_Pcb( bool is_edges, bool query )
/*****************************************************************************/
{
BOARD_ITEM* PtStruct;
@ -304,7 +304,7 @@ void WinEDA_PcbFrame::Erase_Pistes( wxDC* DC, int masque_type, bool query )
/**************************************************************/
void WinEDA_PcbFrame::Erase_Modules( wxDC* DC, bool query )
void WinEDA_PcbFrame::Erase_Modules( bool query )
/**************************************************************/
{
if( query && !IsOK( this, _( "Delete Modules?" ) ) )
@ -325,7 +325,7 @@ void WinEDA_PcbFrame::Erase_Modules( wxDC* DC, bool query )
/************************************************************/
void WinEDA_PcbFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
void WinEDA_PcbFrame::Erase_Textes_Pcb( bool query )
/************************************************************/
{
BOARD_ITEM* PtStruct, * PtNext;

View File

@ -74,46 +74,26 @@
extern Ki_PageDescr* SheetList[];
/* Variables locales, utilisees pour la lecture des fichiers PCB */
/* Local Variables */
int NbDraw, NbTrack, NbZone, NbMod, NbNets;
/**********************************************************************/
int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
TRACK* PtSegm, int StructType, int* LineNum, int NumSegm )
/**********************************************************************/
/* Lecture de la description d'une liste de segments (Tracks, zones)
* Retourne:
* si ok nombre d'items lus.
* si pas de fin de block ($..) - nombre.
/** Read a list of segments (Tracks, zones)
* @return items count or - count if no end block ($End...) found.
*/
{
int shape, width, layer, type, flags, net_code;
int ii = 0, PerCent, Pas;
int ii = 0;
char line1[256];
char line2[256];
TRACK* NewTrack;
PerCent = 0;
Pas = NumSegm / 99;
#ifdef PCBNEW
switch( StructType )
{
case TYPETRACK:
case TYPEVIA:
DisplayActivity( PerCent, wxT( "Tracks:" ) );
break;
case TYPEZONE:
DisplayActivity( PerCent, wxT( "Zones:" ) );
break;
}
#endif
while( GetLine( File, line1, LineNum ) )
{
int makeType;
@ -121,7 +101,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
if( line1[0] == '$' )
{
return ii; /* fin de liste OK */
return ii; /* end of segmentlist: OK */
}
// Read the 2nd line to determine the exact type, one of:
@ -179,29 +159,6 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
PtSegm->SetLayer( layer );
PtSegm->SetNet( net_code );
PtSegm->SetState( flags, ON );
#ifdef PCBNEW
PtSegm->Draw( DrawPanel, DC, GR_OR );
#endif
ii++;
if( ( Pas && (ii % Pas ) == 0) )
{
PerCent++;
#ifdef PCBNEW
switch( makeType )
{
case TYPETRACK:
case TYPEVIA:
DisplayActivity( PerCent, _( "Tracks:" ) );
break;
case TYPEZONE:
DisplayActivity( PerCent, _( "Zones:" ) );
break;
}
#endif
}
}
DisplayError( this, _( "Error: Unexpected end of file !" ) );
@ -210,7 +167,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
/**********************************************************************************/
int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( wxDC* DC, FILE* File, int* LineNum )
int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
/**********************************************************************************/
{
char Line[1024], * data;
@ -266,29 +223,6 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( wxDC* DC, FILE* File, int* LineNum
m_Pcb->m_BoundaryBox.SetWidth( atoi( data ) - m_Pcb->m_BoundaryBox.GetX() );
data = strtok( NULL, " =\n\r" );
m_Pcb->m_BoundaryBox.SetHeight( atoi( data ) - m_Pcb->m_BoundaryBox.GetY() );
/* calcul du zoom optimal */
pcbsize = m_Pcb->m_BoundaryBox.GetSize();
screensize = DrawPanel->GetClientSize();
ii = pcbsize.x / screensize.x;
jj = pcbsize.y / screensize.y;
bestzoom = MAX( ii, jj );
screen->m_Curseur = m_Pcb->m_BoundaryBox.Centre();
screen->SetZoom( bestzoom );
// la position des trac<61> a chang<6E> mise a jour dans le DC courant
wxPoint org;
DrawPanel->GetViewStart( &org.x, &org.y );
DrawPanel->GetScrollPixelsPerUnit( &ii, &jj );
org.x *= ii; org.y *= jj;
#ifdef WX_ZOOM
DC->SetUserScale( 1.0 / (double) screen->GetZoom(), 1.0 / screen->GetZoom() );
org.x *= screen->GetZoom(); org.y *= screen->GetZoom();
DC->SetDeviceOrigin( -org.x, -org.y );
#endif
DrawPanel->SetBoundaryBox();
Recadre_Trace( TRUE );
continue;
}
@ -527,21 +461,6 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x;
continue;
}
if( stricmp( Line, "PadDeltaSize" ) == 0 )
{
g_Pad_Master.m_DeltaSize.x = atoi( data );
data = strtok( NULL, " =\n\r" );
g_Pad_Master.m_DeltaSize.y = atoi( data );
continue;
}
if( stricmp( Line, "PadShapeOffset" ) == 0 )
{
g_Pad_Master.m_Offset.x = atoi( data );
data = strtok( NULL, " =\n\r" );
g_Pad_Master.m_Offset.y = atoi( data );
continue;
}
#endif
}
@ -613,9 +532,6 @@ static int WriteSetup( FILE* File, WinEDA_BasePcbFrame* frame )
fprintf( File, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y );
fprintf( File, "PadDrill %d\n", g_Pad_Master.m_Drill.x );
// fprintf(File, "PadDeltaSize %d %d\n", Pad_DeltaSize.x, Pad_DeltaSize.y);
// fprintf(File, "PadDrillOffset %d %d\n", Pad_OffsetSize.x, Pad_OffsetSize.y);
fprintf( File, "AuxiliaryAxisOrg %d %d\n",
frame->m_Auxiliary_Axis_Position.x, frame->m_Auxiliary_Axis_Position.y );
@ -633,11 +549,7 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
EDA_BaseStruct* PtStruct = m_Pcb->m_Modules;
int NbModules, NbDrawItem, NbLayers;
/* Calcul du nombre des modules */
for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Pnext )
NbModules++;
/* generation du masque des couches autorisees */
/* Write copper layer count */
NbLayers = m_Pcb->m_BoardSettings->m_CopperLayerCount;
fprintf( File, "$GENERAL\n" );
fprintf( File, "LayerCount %d\n", NbLayers );
@ -647,14 +559,18 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "Links %d\n", m_Pcb->m_NbLinks );
fprintf( File, "NoConn %d\n", m_Pcb->m_NbNoconnect );
/* Generation des coord du rectangle d'encadrement */
/* Write Bounding box info */
m_Pcb->ComputeBoundaryBox();
fprintf( File, "Di %d %d %d %d\n",
m_Pcb->m_BoundaryBox.GetX(), m_Pcb->m_BoundaryBox.GetY(),
m_Pcb->m_BoundaryBox.GetRight(),
m_Pcb->m_BoundaryBox.GetBottom() );
/* Generation du nombre de segments type DRAW , TRACT ZONE */
/* Write segment count for footprints, drawings, track and zones */
/* Calculate the footprint count */
for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Pnext )
NbModules++;
PtStruct = m_Pcb->m_Drawings; NbDrawItem = 0;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
NbDrawItem++;
@ -674,8 +590,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
*/
{
/* Sauvegarde des dimensions de la feuille de dessin, des textes du cartouche.. */
Ki_PageDescr* sheet = screen->m_CurrentSheet;
fprintf( File, "$SHEETDESCR\n" );
@ -701,7 +621,6 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
{
char Line[1024], buf[1024], * text;
/* Recheche suite et fin de descr */
while( GetLine( File, Line, LineNum ) != NULL )
{
if( strnicmp( Line, "$End", 4 ) == 0 )
@ -799,9 +718,10 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
/********************************************************************/
/* Lit un fichier PCB .brd
* Si Append == 0: l'ancien pcb en memoire est supprime
* Sinon il y a ajout des elements
/** ReadPcbFile
* Read a board file <file>.brd
* @param Append if 0: a previoulsy loaded boar is delete before loadin the file.
* else all items of the board file are added to the existing board
*/
{
char Line[1024];
@ -852,7 +772,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
if( strnicmp( Line, "$GENERAL", 8 ) == 0 )
{
ReadGeneralDescrPcb( DC, File, &LineNum );
ReadGeneralDescrPcb( File, &LineNum );
continue;
}
@ -898,10 +818,6 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
{
float Pas;
Pas = 100.0; if( NbMod > 1 )
Pas /= NbMod;
Module = new MODULE( m_Pcb );
if( Module == NULL )
continue;
@ -919,10 +835,6 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
}
LastModule = Module;
nbmod++;
#ifdef PCBNEW
DisplayActivity( (int) ( Pas * nbmod), wxT( "Modules:" ) );
#endif
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
continue;
}
@ -942,9 +854,6 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
LastStructPcb->Pnext = StructPcb;
}
LastStructPcb = StructPcb;
#ifdef PCBNEW
( (TEXTE_PCB*) StructPcb )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
#endif
continue;
}
@ -963,9 +872,6 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
LastStructPcb->Pnext = DrawSegm;
}
LastStructPcb = DrawSegm;
#ifdef PCBNEW
Trace_DrawSegmentPcb( DrawPanel, DC, DrawSegm, GR_OR );
#endif
continue;
}
@ -985,9 +891,6 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
LastStructPcb->Pnext = Cotation;
}
LastStructPcb = Cotation;
#ifdef PCBNEW
Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
#endif
continue;
}
@ -1007,9 +910,6 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
LastStructPcb->Pnext = Mire;
}
LastStructPcb = Mire;
#ifdef PCBNEW
Mire->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
#endif
continue;
}
@ -1028,7 +928,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
}
#ifdef PCBNEW
int ii = ReadListeSegmentDescr( DC, File, StartTrack, TYPETRACK,
int ii = ReadListeSegmentDescr( File, StartTrack, TYPETRACK,
&LineNum, NbTrack );
m_Pcb->m_NbSegmTrack += ii;
#endif
@ -1049,7 +949,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
}
#ifdef PCBNEW
int ii = ReadListeSegmentDescr( DC, File, StartZone, TYPEZONE,
int ii = ReadListeSegmentDescr( File, StartZone, TYPEZONE,
&LineNum, NbZone );
m_Pcb->m_NbSegmZone += ii;
#endif
@ -1061,6 +961,9 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
Affiche_Message( wxEmptyString );
BestZoom();
DrawPanel->ReDraw(DC, true);
#ifdef PCBNEW
Compile_Ratsnest( DC, TRUE );
#endif

View File

@ -61,7 +61,7 @@ void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE* Module )
SetCurItem( NULL );
Clear_Pcb( NULL, TRUE );
Clear_Pcb( TRUE );
m_Pcb->m_Status_Pcb = 0;
NewModule = new MODULE( m_Pcb );

View File

@ -209,7 +209,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_MODEDIT_NEW_MODULE:
Clear_Pcb( &dc, TRUE );
Clear_Pcb( TRUE );
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
GetScreen()->m_Curseur = wxPoint( 0, 0 );
@ -314,7 +314,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_LIBEDIT_IMPORT_PART:
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
Clear_Pcb( &dc, TRUE );
Clear_Pcb( TRUE );
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Import_Module( &dc );
if( m_Pcb->m_Modules )
@ -342,7 +342,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
{
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
Clear_Pcb( &dc, TRUE );
Clear_Pcb( TRUE );
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Load_Module_From_Library( m_CurrentLib, &dc );
if( m_Pcb->m_Modules )

View File

@ -643,7 +643,7 @@ void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw )
{
next = segment->Next();
if( Redraw )
if( Redraw && DC )
Trace_DrawSegmentPcb( DrawPanel, DC, segment, GR_XOR );
delete segment;