Compiler warning, object name, bug, and string fixes.

* Fixed EESchema options dialog focus bug so escape key now works in GTK.
* Rename schematic objects for improved readability.
* Fixed GCC compiler warnings in plot code.
* Added paragraph in UIpolicies.txt about setting dialog box sizes.
* Lots of message box string clean up.
This commit is contained in:
stambaughw
2009-12-02 21:44:03 +00:00
parent 04c7eb2916
commit 1aaa7a9bf2
60 changed files with 1677 additions and 1879 deletions
+222 -169
View File
@@ -17,9 +17,8 @@
#include "netlist.h"
/* Local Functions*/
static int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
DrawSheetPath* sheet );
SCH_SHEET_PATH* sheet );
static void BreakReference( std::vector <OBJ_CMP_TO_LIST>& aComponentsList );
static void ReAnnotateComponents( std::vector <OBJ_CMP_TO_LIST>& aComponentsList );
static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsList );
@@ -30,19 +29,17 @@ static int ExistUnit( int aObjet, int aUnit,
static int ReplaceDuplicatedTimeStamps();
/******************************************************/
void WinEDA_SchematicFrame::UpdateSheetNumberAndDate()
/******************************************************/
/* Set a sheet number, the sheet count for sheets in the whole schematic
* and update the date in all screens
*/
void WinEDA_SchematicFrame::UpdateSheetNumberAndDate()
{
wxString date = GenDate();
EDA_ScreenList s_list;
// Set the date
for( SCH_SCREEN* screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
for( SCH_SCREEN* screen = s_list.GetFirst(); screen != NULL;
screen = s_list.GetNext() )
screen->m_Date = date;
// Set sheet counts
@@ -61,12 +58,13 @@ void WinEDA_SchematicFrame::UpdateSheetNumberAndDate()
void ReAnnotatePowerSymbolsOnly( void )
{
/* Build the whole sheet list in hierarchy (sheet, not screen) */
EDA_SheetList SheetList;
SCH_SHEET_LIST SheetList;
DrawSheetPath* sheet;
int CmpNumber = 1;
SCH_SHEET_PATH* sheet;
int CmpNumber = 1;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst(); sheet != NULL;
sheet = SheetList.GetNext() )
{
EDA_BaseStruct* DrawList = sheet->LastDrawList();
for( ; DrawList != NULL; DrawList = DrawList->Next() )
@@ -105,7 +103,8 @@ void ReAnnotatePowerSymbolsOnly( void )
* if same X pos, by Y pos
* if same Y pos, by time stamp
*/
static bool AnnotateBy_X_Position( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST& item2 )
static bool AnnotateBy_X_Position( const OBJ_CMP_TO_LIST& item1,
const OBJ_CMP_TO_LIST& item2 )
{
int ii = item1.CompareRef( item2 );
@@ -130,7 +129,8 @@ static bool AnnotateBy_X_Position( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_T
* if same Y pos, by X pos
* if same X pos, by time stamp
*/
static bool AnnotateBy_Y_Position( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST& item2 )
static bool AnnotateBy_Y_Position( const OBJ_CMP_TO_LIST& item1,
const OBJ_CMP_TO_LIST& item2 )
{
int ii = item1.CompareRef( item2 );
@@ -148,15 +148,16 @@ static bool AnnotateBy_Y_Position( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_T
/*****************************************************************************
* qsort function to annotate items by value
* Components are sorted
* by reference
* if same reference: by value
* if same value: by unit number
* if same unit number, by sheet
* if same sheet, by time stamp
*****************************************************************************/
static bool AnnotateByValue( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST& item2 )
* qsort function to annotate items by value
* Components are sorted
* by reference
* if same reference: by value
* if same value: by unit number
* if same unit number, by sheet
* if same sheet, by time stamp
*****************************************************************************/
static bool AnnotateByValue( const OBJ_CMP_TO_LIST& item1,
const OBJ_CMP_TO_LIST& item2 )
{
int ii = item1.CompareRef( item2 );
@@ -178,10 +179,11 @@ static bool AnnotateByValue( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST
/*****************************************************************************
* qsort function to annotate items by value
* Components are sorted by time stamp
*****************************************************************************/
static bool SortByTimeStamp( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST& item2 )
* qsort function to annotate items by value
* Components are sorted by time stamp
*****************************************************************************/
static bool SortByTimeStamp( const OBJ_CMP_TO_LIST& item1,
const OBJ_CMP_TO_LIST& item2 )
{
int ii = item1.m_SheetPath.Cmp( item2.m_SheetPath );
@@ -192,15 +194,14 @@ static bool SortByTimeStamp( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST
}
/**************************************************************************************/
void WinEDA_SchematicFrame::DeleteAnnotation( bool aCurrentSheetOnly, bool aRedraw )
/**************************************************************************************/
/** Function DeleteAnnotation
* Remove current component annotations
* @param aCurrentSheetOnly : if false: remove all annotations, else remove annotation relative to the current sheet only
* @param aCurrentSheetOnly : if false: remove all annotations, else remove
* annotation relative to the current sheet only
* @param aRedraw : true to refresh display
*/
void WinEDA_SchematicFrame::DeleteAnnotation( bool aCurrentSheetOnly,
bool aRedraw )
{
SCH_ITEM* strct;
SCH_SCREEN* screen;
@@ -242,22 +243,26 @@ void WinEDA_SchematicFrame::DeleteAnnotation( bool aCurrentSheetOnly, bool aRedr
}
/*****************************************************************************
* AnnotateComponents:
*
* Compute the annotation of the components for the whole project, or the
* current sheet only. All the components or the new ones only will be
* annotated.
* @param parent = Schematic frame
* @param annotateSchematic : true = entire schematic annotation, false = current scheet only
* @param sortOption : 0 = annotate by sorting X position,
* 1 = annotate by sorting Y position,
* 2 = annotate by sorting value
* @param resetAnnotation : true = remove previous annotation false = anotate new components only
* @param repairsTimestamps : true = test for duplicate times stamps and replace duplicated
* Note: this option could change previous annotation, because time stamps are used to handle annotation
* mainly in complex hierarchies.
*****************************************************************************/
/**
* AnnotateComponents:
*
* Compute the annotation of the components for the whole project, or the
* current sheet only. All the components or the new ones only will be
* annotated.
* @param parent = Schematic frame
* @param annotateSchematic : true = entire schematic annotation,
* false = current sheet only
* @param sortOption : 0 = annotate by sorting X position,
* 1 = annotate by sorting Y position,
* 2 = annotate by sorting value
* @param resetAnnotation : true = remove previous annotation
* false = annotate new components only
* @param repairsTimestamps : true = test for duplicate times stamps and
* replace duplicated
* Note: this option could change previous annotation, because time
* stamps are used to handle annotation mainly in complex
* hierarchies.
*/
void AnnotateComponents( WinEDA_SchematicFrame* parent,
bool annotateSchematic,
int sortOption,
@@ -268,15 +273,17 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent,
wxBusyCursor dummy;
// Test and replace duplicte time stamps
// duplicate can happen with old schematics, or schematic conversions or manual editions of files ...
// Test and replace duplicate time stamps
// duplicate can happen with old schematics, or schematic conversions or
// manual editions of files ...
if( repairsTimestamps )
{
int ireplacecount = ReplaceDuplicatedTimeStamps();
if( ireplacecount )
{
wxString msg;
msg.Printf( _( "%d Duplicate Time stamps replaced" ), ireplacecount );
msg.Printf( _( "%d duplicate time stamps replaced." ),
ireplacecount );
DisplayInfoMessage( NULL, msg, 2 );
}
}
@@ -287,7 +294,7 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent,
parent->DeleteAnnotation( !annotateSchematic, false );
/* Build the sheet list */
EDA_SheetList SheetList;
SCH_SHEET_LIST SheetList;
/* Update the sheet number, sheet count and date */
parent->UpdateSheetNumberAndDate();
@@ -295,7 +302,7 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent,
/* Build component list */
if( annotateSchematic )
{
DrawSheetPath* sheet;
SCH_SHEET_PATH* sheet;
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
@@ -312,11 +319,13 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent,
switch( sortOption )
{
case 0:
sort( ComponentsList.begin(), ComponentsList.end(), AnnotateBy_X_Position );
sort( ComponentsList.begin(), ComponentsList.end(),
AnnotateBy_X_Position );
break;
case 1:
sort( ComponentsList.begin(), ComponentsList.end(), AnnotateBy_Y_Position );
sort( ComponentsList.begin(), ComponentsList.end(),
AnnotateBy_Y_Position );
break;
case 2:
@@ -334,16 +343,14 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent,
}
/*******************************************************************************************************/
int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
DrawSheetPath* aSheet )
/********************************************************************************************************/
/** function AddComponentsInSheetToList()
* Add a OBJ_CMP_TO_LIST object in aComponentsList for each component found in sheet
* Add a OBJ_CMP_TO_LIST object in aComponentsList for each component found
* in sheet
* @param aComponentsList = a std::vector list to fill
* @param the DrawSheetPath sheet to analyse
* @param the SCH_SHEET_PATH sheet to analyze
*/
int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
SCH_SHEET_PATH* aSheet )
{
int NbrCmp = 0;
EDA_BaseStruct* DrawList = aSheet->LastDrawList();
@@ -372,7 +379,8 @@ int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
if( DrawLibItem->GetRef( aSheet ).IsEmpty() )
DrawLibItem->SetRef( aSheet, wxT( "DefRef?" ) );
strncpy( new_object.m_Reference, CONV_TO_UTF8( DrawLibItem->GetRef( aSheet ) ), 32 );
strncpy( new_object.m_Reference,
CONV_TO_UTF8( DrawLibItem->GetRef( aSheet ) ), 32 );
new_object.m_NumRef = -1;
@@ -390,10 +398,10 @@ int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
}
/*****************************************************************************
* Update the reference component for the schematic project (or the current
* sheet)
*****************************************************************************/
/*
* Update the reference component for the schematic project (or the current
* sheet)
*/
static void ReAnnotateComponents( std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
{
/* update the reference numbers */
@@ -407,7 +415,8 @@ static void ReAnnotateComponents( std::vector <OBJ_CMP_TO_LIST>& aComponentsList
else
sprintf( Text + strlen( Text ), "%d", aComponentsList[ii].m_NumRef );
component->SetRef( &(aComponentsList[ii].m_SheetPath), CONV_FROM_UTF8( Text ) );
component->SetRef( &(aComponentsList[ii].m_SheetPath),
CONV_FROM_UTF8( Text ) );
component->m_Multi = aComponentsList[ii].m_Unit;
component->SetUnitSelection( &(aComponentsList[ii].m_SheetPath),
aComponentsList[ii].m_Unit );
@@ -415,15 +424,15 @@ static void ReAnnotateComponents( std::vector <OBJ_CMP_TO_LIST>& aComponentsList
}
/*****************************************************************************
* Split component reference designators into a name (prefix) and number.
* Example: IC1 becomes IC and 1 in the .m_NumRef member.
* For multi part per package components not already annotated, set .m_Unit
* to a max value (0x7FFFFFFF).
*
* @param aComponentsList = list of component
* @param NbOfCmp = item count in the list
*****************************************************************************/
/**
* Split component reference designators into a name (prefix) and number.
* Example: IC1 becomes IC and 1 in the .m_NumRef member.
* For multi part per package components not already annotated, set .m_Unit
* to a max value (0x7FFFFFFF).
*
* @param aComponentsList = list of component
* @param NbOfCmp = item count in the list
*/
void BreakReference( std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
{
char* Text;
@@ -466,16 +475,16 @@ void BreakReference( std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
}
/*****************************************************************************
* Compute the reference number for components without reference number
* Compute .m_NumRef member
*****************************************************************************/
/*
* Compute the reference number for components without reference number
* Compute .m_NumRef member
*/
static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
{
int LastReferenceNumber, NumberOfUnits, Unit;
/* Components with an invisible reference (power...) always are re-annotated.
* So set theirs .m_IsNew member to true
/* Components with an invisible reference (power...) always are
* re-annotated. So set their .m_IsNew member to true
*/
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
{
@@ -486,9 +495,10 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi
}
}
/* calculate index of the first component with the same reference prefix than the current component.
* all of component having the same reference prefix will receive a reference number with consecutives values:
* IC .. will be set to IC4, IC4, IC5 ...
/* calculate index of the first component with the same reference prefix
* than the current component. All components having the same reference
* prefix will receive a reference number with consecutive values:
* IC .. will be set to IC4, IC4, IC5 ...
*/
unsigned first = 0;
/* calculate the last used number for this reference prefix: */
@@ -498,8 +508,10 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi
if( aComponentsList[ii].m_Flag )
continue;
if( aComponentsList[first].CompareRef( aComponentsList[ii] ) != 0 ) /* New reference found: we need a new ref number for this reference */
if( aComponentsList[first].CompareRef( aComponentsList[ii] ) != 0 )
{
/* New reference found: we need a new ref number for this
* reference */
first = ii;
LastReferenceNumber = GetLastReferenceNumber( ii, aComponentsList );
}
@@ -533,7 +545,8 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi
}
/* search for others units of this component.
* we search for others parts that have the same value and the same reference prefix (ref without ref number)
* we search for others parts that have the same value and the same
* reference prefix (ref without ref number)
*/
for( Unit = 1; Unit <= NumberOfUnits; Unit++ )
{
@@ -541,23 +554,27 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi
continue;
int found = ExistUnit( ii, Unit, aComponentsList );
if( found >= 0 )
continue; /* this unit exists for this reference (unit already annotated) */
continue; /* this unit exists for this reference (unit
* already annotated) */
/* Search a component to annotate ( same prefix, same value, not annotated) */
/* Search a component to annotate ( same prefix, same value,
* not annotated) */
for( unsigned jj = ii + 1; jj < aComponentsList.size(); jj++ )
{
if( aComponentsList[jj].m_Flag ) // already tested
continue;
if( aComponentsList[ii].CompareRef( aComponentsList[jj] ) != 0 ) // references are different
if( aComponentsList[ii].CompareRef( aComponentsList[jj] ) != 0 )
continue;
if( aComponentsList[jj].CompareValue( aComponentsList[ii] ) != 0 )
continue; // values are different
continue;
if( !aComponentsList[jj].m_IsNew )
continue;
/* Component without reference number found, annotate it if possible */
if( !aComponentsList[jj].IsPartsLocked() || (aComponentsList[jj].m_Unit == Unit) )
/* Component without reference number found, annotate it
* if possible */
if( !aComponentsList[jj].IsPartsLocked()
|| ( aComponentsList[jj].m_Unit == Unit ) )
{
aComponentsList[jj].m_NumRef = aComponentsList[ii].m_NumRef;
aComponentsList[jj].m_Unit = Unit;
@@ -571,21 +588,23 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi
}
/*****************************************************************************
* Search the last used (greatest) reference number in the component list
* for the prefix reference given by Objet
* The component list must be sorted.
*
* @param aObjet = reference item ( aComponentsList[aObjet].m_TextRef is the search pattern)
* @param aComponentsList = list of items
*****************************************************************************/
int GetLastReferenceNumber( int aObjet, std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
/**
* Search the last used (greatest) reference number in the component list
* for the prefix reference given by Objet
* The component list must be sorted.
*
* @param aObjet = reference item ( aComponentsList[aObjet].m_TextRef is
* the search pattern)
* @param aComponentsList = list of items
*/
int GetLastReferenceNumber( int aObjet,
std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
{
int LastNumber = 0;
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
{
/* Nouveau Identificateur */
/* New identifier. */
if( aComponentsList[aObjet].CompareRef( aComponentsList[ii] ) != 0 )
continue;
if( LastNumber < aComponentsList[ii].m_NumRef )
@@ -596,15 +615,16 @@ int GetLastReferenceNumber( int aObjet, std::vector <OBJ_CMP_TO_LIST>& aComponen
}
/*****************************************************************************
* Search in the sorted list of components, for a given componen,t an other component
* with the same reference and a given part unit.
* Mainly used to manage multiple parts per package components
* @param aObjet = index in aComponentsList for the given OBJ_CMP_TO_LIST item to test
* @param Unit = the given unit number to search
* @param aComponentsList = list of items to examine
* @return index in aComponentsList if found or -1 if not found
*****************************************************************************/
/**
* Search in the sorted list of components, for a given component an other
* component with the same reference and a given part unit. Mainly used to
* manage multiple parts per package components.
* @param aObjet = index in aComponentsList for the given OBJ_CMP_TO_LIST
* item to test
* @param Unit = the given unit number to search
* @param aComponentsList = list of items to examine
* @return index in aComponentsList if found or -1 if not found
*/
static int ExistUnit( int aObjet, int Unit,
std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
{
@@ -613,16 +633,21 @@ static int ExistUnit( int aObjet, int Unit,
NumRef = aComponentsList[aObjet].m_NumRef;
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
{
if( aObjet == (int) ii ) // Do not compare with itself !
if( aObjet == (int) ii )
// Do not compare with itself !
continue;
if( aComponentsList[ii].m_IsNew ) // Not already with an updated reference
if( aComponentsList[ii].m_IsNew )
// Not already with an updated reference
continue;
if( aComponentsList[ii].m_NumRef != NumRef ) // Not the same reference number (like 35 in R35)
if( aComponentsList[ii].m_NumRef != NumRef )
// Not the same reference number (like 35 in R35)
continue;
if( aComponentsList[aObjet].CompareRef( aComponentsList[ii] ) != 0 ) // Not the same reference prefix
if( aComponentsList[aObjet].CompareRef( aComponentsList[ii] ) != 0 )
// Not the same reference prefix
continue;
if( aComponentsList[ii].m_Unit == Unit ) // A part with the same reference and the given unit is found
if( aComponentsList[ii].m_Unit == Unit )
{
// A part with the same reference and the given unit is found
return ii;
}
}
@@ -631,10 +656,6 @@ static int ExistUnit( int aObjet, int Unit,
}
/***************************************************************************************/
int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly )
/***************************************************************************************/
/**
* Function CheckAnnotate
* Check errors relatives to annotation:
@@ -643,26 +664,30 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
* for multiple parts per package components :
* part number > number of parts
* different values between parts
* @return errors count
* @param aMessageList = a wxArrayString to store messages. If NULL, they are displayed in a wxMessageBox
* @param aMessageList = a wxArrayString to store messages. If NULL, they
* are displayed in a wxMessageBox
* @param aOneSheetOnly : true = search is made only in the current sheet
* false = search in whole hierarchy (usual search).
* false = search in whole hierarchy (usual search).
* @return errors count
*/
int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList,
bool aOneSheetOnly )
{
int error;
wxString Buff;
wxString msg, cmpref;
int error;
wxString Buff;
wxString msg, cmpref;
/* build the screen list */
EDA_SheetList SheetList;
SCH_SHEET_LIST SheetList;
std::vector <OBJ_CMP_TO_LIST> ComponentsList;
/* Build the list of components */
if( !aOneSheetOnly )
{
DrawSheetPath* sheet;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
SCH_SHEET_PATH* sheet;
for( sheet = SheetList.GetFirst(); sheet != NULL;
sheet = SheetList.GetNext() )
AddComponentsInSheetToList( ComponentsList, sheet );
}
else
@@ -693,23 +718,28 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
msg.Printf( _( "item not annotated: %s%s" ),
cmpref.GetData(), Buff.GetData() );
if( (ComponentsList[ii].m_Unit > 0) && (ComponentsList[ii].m_Unit < 0x7FFFFFFF) )
if( ( ComponentsList[ii].m_Unit > 0 )
&& ( ComponentsList[ii].m_Unit < 0x7FFFFFFF ) )
{
Buff.Printf( _( "( unit %d)" ), ComponentsList[ii].m_Unit );
msg << Buff;
}
if( aMessageList )
{
aMessageList->Add( msg + wxT( "\n" ) );
}
else
{
DisplayError( NULL, msg );
}
error++;
break;
}
// Annotate error
if( MAX( ComponentsList[ii].m_Entry->GetPartCount(), 1 ) < ComponentsList[ii].m_Unit )
if( MAX( ComponentsList[ii].m_Entry->GetPartCount(), 1 )
< ComponentsList[ii].m_Unit )
{
if( ComponentsList[ii].m_NumRef >= 0 )
Buff << ComponentsList[ii].m_NumRef;
@@ -721,7 +751,8 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
Buff.GetData() );
Buff.Printf( _( " unit %d and no more than %d parts" ),
ComponentsList[ii].m_Unit, ComponentsList[ii].m_Entry->GetPartCount() );
ComponentsList[ii].m_Unit,
ComponentsList[ii].m_Entry->GetPartCount() );
msg << Buff;
if( aMessageList )
{
@@ -743,7 +774,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
msg.Empty();
Buff.Empty();
if( (ComponentsList[ii].CompareRef( ComponentsList[ii + 1] ) != 0)
if( ( ComponentsList[ii].CompareRef( ComponentsList[ii + 1] ) != 0 )
|| ( ComponentsList[ii].m_NumRef != ComponentsList[ii + 1].m_NumRef ) )
continue;
@@ -760,7 +791,8 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
msg.Printf( _( "Multiple item %s%s" ),
cmpref.GetData(), Buff.GetData() );
if( (ComponentsList[ii].m_Unit > 0) && (ComponentsList[ii].m_Unit < 0x7FFFFFFF) )
if( ( ComponentsList[ii].m_Unit > 0 )
&& ( ComponentsList[ii].m_Unit < 0x7FFFFFFF ) )
{
Buff.Printf( _( " (unit %d)" ), ComponentsList[ii].m_Unit );
msg << Buff;
@@ -776,8 +808,9 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
}
/* Test error if units are different but number of parts per package
* too hight (ex U3 ( 1 part) and we find U3B this is an error) */
if( ComponentsList[ii].m_Entry->GetPartCount() != ComponentsList[ii + 1].m_Entry->GetPartCount() )
* too high (ex U3 ( 1 part) and we find U3B this is an error) */
if( ComponentsList[ii].m_Entry->GetPartCount()
!= ComponentsList[ii + 1].m_Entry->GetPartCount() )
{
if( ComponentsList[ii].m_NumRef >= 0 )
Buff << ComponentsList[ii].m_NumRef;
@@ -788,7 +821,8 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
msg.Printf( _( "Multiple item %s%s" ),
cmpref.GetData(), Buff.GetData() );
if( (ComponentsList[ii].m_Unit > 0) && (ComponentsList[ii].m_Unit < 0x7FFFFFFF) )
if( ( ComponentsList[ii].m_Unit > 0 )
&& ( ComponentsList[ii].m_Unit < 0x7FFFFFFF ) )
{
Buff.Printf( _( " (unit %d)" ), ComponentsList[ii].m_Unit );
msg << Buff;
@@ -799,11 +833,14 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
aMessageList->Add( msg + wxT( "\n" ));
}
else
{
DisplayError( NULL, msg );
}
error++;
}
/* Error if values are different between units, for the same reference */
/* Error if values are different between units, for the same
* reference */
int next = ii + 1;
if( ComponentsList[ii].CompareValue( ComponentsList[next] ) != 0 )
{
@@ -812,40 +849,47 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
nextcmpref = CONV_FROM_UTF8( ComponentsList[next].m_Reference );
#if defined(KICAD_GOST)
msg.Printf( _( "Diff values for %s%d.%c (%s) and %s%d.%c (%s)" ),
cmpref.GetData(),
ComponentsList[ii].m_NumRef,
ComponentsList[ii].m_Unit + '1' - 1,
ComponentsList[ii].m_Value->GetData(), nextcmpref.GetData(),
ComponentsList[next].m_NumRef,
ComponentsList[next].m_Unit + '1' - 1,
ComponentsList[next].m_Value->GetData() );
cmpref.GetData(),
ComponentsList[ii].m_NumRef,
ComponentsList[ii].m_Unit + '1' - 1,
ComponentsList[ii].m_Value->GetData(),
nextcmpref.GetData(),
ComponentsList[next].m_NumRef,
ComponentsList[next].m_Unit + '1' - 1,
ComponentsList[next].m_Value->GetData() );
#else
msg.Printf( _( "Diff values for %s%d%c (%s) and %s%d%c (%s)" ),
cmpref.GetData(),
ComponentsList[ii].m_NumRef,
ComponentsList[ii].m_Unit + 'A' - 1,
ComponentsList[ii].m_Value->GetData(), nextcmpref.GetData(),
ComponentsList[next].m_NumRef,
ComponentsList[next].m_Unit + 'A' - 1,
ComponentsList[next].m_Value->GetData() );
cmpref.GetData(),
ComponentsList[ii].m_NumRef,
ComponentsList[ii].m_Unit + 'A' - 1,
ComponentsList[ii].m_Value->GetData(),
nextcmpref.GetData(),
ComponentsList[next].m_NumRef,
ComponentsList[next].m_Unit + 'A' - 1,
ComponentsList[next].m_Value->GetData() );
#endif
if( aMessageList )
{
aMessageList->Add( msg + wxT( "\n" ));
}
}
else
{
DisplayError( NULL, msg );
}
error++;
}
}
// count the duplicated time stamps
sort( ComponentsList.begin(), ComponentsList.end(), SortByTimeStamp );
for( int ii = 0; (ii < imax) && (error < 4); ii++ )
for( int ii = 0; ( ii < imax ) && ( error < 4 ); ii++ )
{
if( (ComponentsList[ii].m_TimeStamp != ComponentsList[ii + 1].m_TimeStamp)
|| ( ComponentsList[ii].m_SheetPath != ComponentsList[ii + 1].m_SheetPath ) )
if( (ComponentsList[ii].m_TimeStamp
!= ComponentsList[ii + 1].m_TimeStamp)
|| ( ComponentsList[ii].m_SheetPath
!= ComponentsList[ii + 1].m_SheetPath ) )
continue;
/* Same time stamp found. */
@@ -862,10 +906,13 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
nextcmpref.GetData(), ComponentsList[ii + 1].m_NumRef );
if( aMessageList )
{
aMessageList->Add( msg + wxT( "\n" ));
}
aMessageList->Add( msg + wxT( "\n" ));
}
else
{
DisplayError( NULL, msg );
}
error++;
}
@@ -896,7 +943,8 @@ static bool SortItemByTimeStamp( const SCH_ITEM* item1, const SCH_ITEM* item2 )
/** Function ReplaceDuplicatedTimeStamps
* Search for duplicate time stamps in the whole hierarchy, and replace duplicae by new time stamps
* Search for duplicate time stamps in the whole hierarchy, and replace
* duplicate by new time stamps
*/
int ReplaceDuplicatedTimeStamps()
{
@@ -904,19 +952,22 @@ int ReplaceDuplicatedTimeStamps()
EDA_ScreenList ScreenList;
/* Build the list of items with time stamps (components and sheets)
* note: if all items have a different time stamp, this ensure also different paths in complex hierarchy
* this is the reason we have differant time stamps for components AND sheets
* note: if all items have a different time stamp, this ensure also
* different paths in complex hierarchy
* this is the reason we have different time stamps for components AND
* sheets
*/
std::vector <SCH_ITEM*> itemlist;
SCH_SCREEN* screen;
SCH_ITEM* item;
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
for( screen = ScreenList.GetFirst(); screen != NULL;
screen = ScreenList.GetNext() )
{
item = screen->EEDrawList;
while( item )
{
if( (item->Type() == DRAW_SHEET_STRUCT_TYPE)
|| (item->Type() == TYPE_SCH_COMPONENT) )
if( ( item->Type() == DRAW_SHEET_STRUCT_TYPE )
|| ( item->Type() == TYPE_SCH_COMPONENT ) )
itemlist.push_back( item );
item = item->Next();
@@ -924,7 +975,6 @@ int ReplaceDuplicatedTimeStamps()
}
// Test and replace duplicated time stamps
int imax = itemlist.size() - 1;
int errcount = 0;
sort( itemlist.begin(), itemlist.end(), SortItemByTimeStamp );
@@ -936,12 +986,15 @@ int ReplaceDuplicatedTimeStamps()
{
errcount++;
// for a component, update its Time stamp and its paths (m_PathsAndReferences field)
// for a component, update its Time stamp and its paths
// (m_PathsAndReferences field)
if( item->Type() == TYPE_SCH_COMPONENT )
( (SCH_COMPONENT*) item )->SetTimeStamp( GetTimeStamp() );
// for a sheet, update only its time stamp (annotation of its components will be lost)
// TODO: see how to change sheet paths for its cmp list (can be possible in most cases)
// for a sheet, update only its time stamp (annotation of its
// components will be lost)
// @todo: see how to change sheet paths for its cmp list (can
// be possible in most cases)
else
item->m_TimeStamp = GetTimeStamp();
}