2007-09-20 21:06:49 +00:00
|
|
|
/**************************************/
|
|
|
|
/* annotate.cpp: component annotation */
|
|
|
|
/**************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
#include <algorithm> // to use sort vector
|
|
|
|
#include <vector>
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "wxstruct.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
#include "program.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "protos.h"
|
2008-12-10 16:49:53 +00:00
|
|
|
#include "netlist.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2008-12-10 16:49:53 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
static int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH* sheet );
|
2008-12-10 16:49:53 +00:00
|
|
|
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 );
|
|
|
|
int GetLastReferenceNumber( int aObjet,
|
|
|
|
std::vector <OBJ_CMP_TO_LIST>& aComponentsList );
|
|
|
|
static int ExistUnit( int aObjet, int aUnit,
|
|
|
|
std::vector <OBJ_CMP_TO_LIST>& aComponentsList );
|
2009-04-25 10:12:30 +00:00
|
|
|
static int ReplaceDuplicatedTimeStamps();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
/* Set a sheet number, the sheet count for sheets in the whole schematic
|
|
|
|
* and update the date in all screens
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void WinEDA_SchematicFrame::UpdateSheetNumberAndDate()
|
2008-02-28 19:27:25 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
wxString date = GenDate();
|
|
|
|
SCH_SCREENS s_list;
|
2008-02-28 19:27:25 +00:00
|
|
|
|
2008-04-30 17:04:22 +00:00
|
|
|
// Set the date
|
2009-12-02 21:44:03 +00:00
|
|
|
for( SCH_SCREEN* screen = s_list.GetFirst(); screen != NULL;
|
|
|
|
screen = s_list.GetNext() )
|
2008-04-30 17:04:22 +00:00
|
|
|
screen->m_Date = date;
|
2008-02-28 19:27:25 +00:00
|
|
|
|
2008-04-30 17:04:22 +00:00
|
|
|
// Set sheet counts
|
|
|
|
SetSheetNumberAndCount();
|
2008-02-28 19:27:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* Used to annotate the power symbols, before testing erc or computing
|
|
|
|
* netlist when a component reannotation is not necessary
|
2007-12-03 06:54:19 +00:00
|
|
|
*
|
2008-02-26 01:07:38 +00:00
|
|
|
* In order to avoid conflicts the reference number starts with a 0. A
|
|
|
|
* PWR with id 12 is named PWR12 in global annotation and PWR012 by the
|
|
|
|
* Power annotation.
|
|
|
|
****************************************************************************/
|
|
|
|
void ReAnnotatePowerSymbolsOnly( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-01-06 20:09:32 +00:00
|
|
|
/* Build the whole sheet list in hierarchy (sheet, not screen) */
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_LIST SheetList;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH* sheet;
|
|
|
|
int CmpNumber = 1;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL;
|
|
|
|
sheet = SheetList.GetNext() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
EDA_BaseStruct* DrawList = sheet->LastDrawList();
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; DrawList != NULL; DrawList = DrawList->Next() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
if( DrawList->Type() != TYPE_SCH_COMPONENT )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2009-09-18 14:56:05 +00:00
|
|
|
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList;
|
|
|
|
LIB_COMPONENT* Entry =
|
|
|
|
CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
if( ( Entry == NULL ) || !Entry->IsPower() )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
//DrawLibItem->ClearAnnotation(sheet); this clears all annotation :(
|
2008-02-26 01:07:38 +00:00
|
|
|
wxString refstr = DrawLibItem->m_PrefixString;
|
|
|
|
|
|
|
|
//str will be "C?" or so after the ClearAnnotation call.
|
|
|
|
while( refstr.Last() == '?' )
|
|
|
|
refstr.RemoveLast();
|
|
|
|
|
|
|
|
if( !refstr.StartsWith( wxT( "#" ) ) )
|
|
|
|
refstr = wxT( "#" ) + refstr;
|
|
|
|
refstr << wxT( "0" ) << CmpNumber;
|
|
|
|
DrawLibItem->SetRef( sheet, refstr );
|
2007-09-20 21:06:49 +00:00
|
|
|
CmpNumber++;
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
/* sort function to annotate items by their position.
|
2008-04-21 06:34:56 +00:00
|
|
|
* Components are sorted
|
|
|
|
* by reference
|
|
|
|
* if same reference: by sheet
|
|
|
|
* if same sheet, by X pos
|
2008-12-10 16:49:53 +00:00
|
|
|
* if same X pos, by Y pos
|
|
|
|
* if same Y pos, by time stamp
|
2008-04-21 06:34:56 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static bool AnnotateBy_X_Position( const OBJ_CMP_TO_LIST& item1,
|
|
|
|
const OBJ_CMP_TO_LIST& item2 )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
int ii = item1.CompareRef( item2 );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_SheetPath.Cmp( item2.m_SheetPath );
|
2008-02-26 01:07:38 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_RootCmp->m_Pos.x - item2.m_RootCmp->m_Pos.x;
|
2008-02-26 01:07:38 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_RootCmp->m_Pos.y - item2.m_RootCmp->m_Pos.y;
|
2008-02-26 01:07:38 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_TimeStamp - item2.m_TimeStamp;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
return ii < 0;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
/* sort function to annotate items by their position.
|
2008-04-21 14:03:20 +00:00
|
|
|
* Components are sorted
|
|
|
|
* by reference
|
|
|
|
* if same reference: by sheet
|
|
|
|
* if same sheet, by Y pos
|
2008-12-10 16:49:53 +00:00
|
|
|
* if same Y pos, by X pos
|
|
|
|
* if same X pos, by time stamp
|
2008-04-21 14:03:20 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static bool AnnotateBy_Y_Position( const OBJ_CMP_TO_LIST& item1,
|
|
|
|
const OBJ_CMP_TO_LIST& item2 )
|
2008-04-21 14:03:20 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
int ii = item1.CompareRef( item2 );
|
2008-04-21 14:03:20 +00:00
|
|
|
|
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_SheetPath.Cmp( item2.m_SheetPath );
|
2008-04-21 14:03:20 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_RootCmp->m_Pos.y - item2.m_RootCmp->m_Pos.y;
|
2008-04-21 14:03:20 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_RootCmp->m_Pos.x - item2.m_RootCmp->m_Pos.x;
|
2008-04-21 14:03:20 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_TimeStamp - item2.m_TimeStamp;
|
2008-04-21 14:03:20 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
return ii < 0;
|
2008-04-21 14:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
/*****************************************************************************
|
2009-12-02 21:44:03 +00:00
|
|
|
* 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 )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
int ii = item1.CompareRef( item2 );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.CompareValue( item2 );
|
2008-02-26 01:07:38 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_Unit - item2.m_Unit;
|
2008-02-26 01:07:38 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_SheetPath.Cmp( item2.m_SheetPath );
|
2008-02-26 01:07:38 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_RootCmp->m_Pos.x - item2.m_RootCmp->m_Pos.x;
|
2008-02-26 01:07:38 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_RootCmp->m_Pos.y - item2.m_RootCmp->m_Pos.y;
|
2008-02-26 01:07:38 +00:00
|
|
|
if( ii == 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
ii = item1.m_TimeStamp - item2.m_TimeStamp;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
return ii < 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-25 10:12:30 +00:00
|
|
|
/*****************************************************************************
|
2009-12-02 21:44:03 +00:00
|
|
|
* 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 )
|
2009-04-25 10:12:30 +00:00
|
|
|
{
|
|
|
|
int ii = item1.m_SheetPath.Cmp( item2.m_SheetPath );
|
|
|
|
|
|
|
|
if( ii == 0 )
|
|
|
|
ii = item1.m_TimeStamp - item2.m_TimeStamp;
|
|
|
|
|
|
|
|
return ii < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
/** Function DeleteAnnotation
|
|
|
|
* Remove current component annotations
|
2009-12-02 21:44:03 +00:00
|
|
|
* @param aCurrentSheetOnly : if false: remove all annotations, else remove
|
|
|
|
* annotation relative to the current sheet only
|
2008-04-21 06:34:56 +00:00
|
|
|
* @param aRedraw : true to refresh display
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void WinEDA_SchematicFrame::DeleteAnnotation( bool aCurrentSheetOnly,
|
|
|
|
bool aRedraw )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
SCH_ITEM* strct;
|
|
|
|
SCH_SCREEN* screen;
|
|
|
|
SCH_SCREENS ScreenList;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
screen = ScreenList.GetFirst();
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
if( aCurrentSheetOnly )
|
|
|
|
screen = GetScreen();
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
if( screen == NULL )
|
|
|
|
return;
|
|
|
|
while( screen )
|
|
|
|
{
|
|
|
|
strct = screen->EEDrawList;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; strct; strct = strct->Next() )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
|
|
|
if( strct->Type() == TYPE_SCH_COMPONENT )
|
|
|
|
{
|
|
|
|
if( aCurrentSheetOnly )
|
|
|
|
( (SCH_COMPONENT*) strct )->ClearAnnotation( m_CurrentSheet );
|
|
|
|
else
|
|
|
|
( (SCH_COMPONENT*) strct )->ClearAnnotation( NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2008-04-21 06:34:56 +00:00
|
|
|
if( aCurrentSheetOnly )
|
|
|
|
break;
|
|
|
|
screen = ScreenList.GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//update the References
|
|
|
|
m_CurrentSheet->UpdateAllScreenReferences();
|
|
|
|
|
|
|
|
if( aRedraw )
|
|
|
|
DrawPanel->Refresh( true );
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-02-26 01:07:38 +00:00
|
|
|
void AnnotateComponents( WinEDA_SchematicFrame* parent,
|
2008-02-28 19:27:25 +00:00
|
|
|
bool annotateSchematic,
|
2008-04-21 14:03:20 +00:00
|
|
|
int sortOption,
|
2009-04-25 10:12:30 +00:00
|
|
|
bool resetAnnotation,
|
|
|
|
bool repairsTimestamps )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
std::vector <OBJ_CMP_TO_LIST> ComponentsList;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
wxBusyCursor dummy;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// Test and replace duplicate time stamps
|
|
|
|
// duplicate can happen with old schematics, or schematic conversions or
|
|
|
|
// manual editions of files ...
|
2009-04-25 10:12:30 +00:00
|
|
|
if( repairsTimestamps )
|
|
|
|
{
|
|
|
|
int ireplacecount = ReplaceDuplicatedTimeStamps();
|
2009-07-05 12:09:41 +00:00
|
|
|
if( ireplacecount )
|
2009-04-25 10:12:30 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2009-12-02 21:44:03 +00:00
|
|
|
msg.Printf( _( "%d duplicate time stamps replaced." ),
|
|
|
|
ireplacecount );
|
2009-07-05 12:09:41 +00:00
|
|
|
DisplayInfoMessage( NULL, msg, 2 );
|
2009-04-25 10:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
/* If it is an annotation for all the components, reset previous
|
2008-04-21 06:34:56 +00:00
|
|
|
* annotation: */
|
2008-02-26 01:07:38 +00:00
|
|
|
if( resetAnnotation )
|
2008-04-21 06:34:56 +00:00
|
|
|
parent->DeleteAnnotation( !annotateSchematic, false );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/* Build the sheet list */
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_LIST SheetList;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
/* Update the sheet number, sheet count and date */
|
|
|
|
parent->UpdateSheetNumberAndDate();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
/* Build component list */
|
2008-02-26 01:07:38 +00:00
|
|
|
if( annotateSchematic )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH* sheet;
|
2008-02-26 01:07:38 +00:00
|
|
|
for( sheet = SheetList.GetFirst();
|
2008-02-28 19:27:25 +00:00
|
|
|
sheet != NULL;
|
|
|
|
sheet = SheetList.GetNext() )
|
2008-12-10 16:49:53 +00:00
|
|
|
AddComponentsInSheetToList( ComponentsList, sheet );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
else
|
2008-12-10 16:49:53 +00:00
|
|
|
AddComponentsInSheetToList( ComponentsList, parent->GetSheet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
/* Break full components reference in name (prefix) and number:
|
2008-04-21 06:34:56 +00:00
|
|
|
* example: IC1 become IC, and 1 */
|
2008-12-10 16:49:53 +00:00
|
|
|
BreakReference( ComponentsList );
|
2008-04-25 10:32:16 +00:00
|
|
|
|
2008-04-21 14:03:20 +00:00
|
|
|
switch( sortOption )
|
|
|
|
{
|
|
|
|
case 0:
|
2009-12-02 21:44:03 +00:00
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(),
|
|
|
|
AnnotateBy_X_Position );
|
2008-04-21 14:03:20 +00:00
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-04-21 14:03:20 +00:00
|
|
|
case 1:
|
2009-12-02 21:44:03 +00:00
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(),
|
|
|
|
AnnotateBy_Y_Position );
|
2008-04-21 14:03:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2008-12-10 16:49:53 +00:00
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(), AnnotateByValue );
|
2008-04-21 14:03:20 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/* Recalculate reference numbers */
|
2008-12-10 16:49:53 +00:00
|
|
|
ComputeReferenceNumber( ComponentsList );
|
|
|
|
ReAnnotateComponents( ComponentsList );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
/* Final control (just in case ... )*/
|
2009-07-05 12:09:41 +00:00
|
|
|
parent->CheckAnnotate( NULL, !annotateSchematic );
|
2010-06-30 11:15:34 +00:00
|
|
|
parent->OnModify( );
|
2008-02-26 01:07:38 +00:00
|
|
|
parent->DrawPanel->Refresh( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-12 21:30:07 +00:00
|
|
|
/** function AddComponentsInSheetToList()
|
2009-12-02 21:44:03 +00:00
|
|
|
* Add a OBJ_CMP_TO_LIST object in aComponentsList for each component found
|
|
|
|
* in sheet
|
2008-12-12 21:30:07 +00:00
|
|
|
* @param aComponentsList = a std::vector list to fill
|
2009-12-02 21:44:03 +00:00
|
|
|
* @param the SCH_SHEET_PATH sheet to analyze
|
2009-04-25 10:12:30 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
|
|
|
|
SCH_SHEET_PATH* aSheet )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
int NbrCmp = 0;
|
|
|
|
EDA_BaseStruct* DrawList = aSheet->LastDrawList();
|
|
|
|
SCH_COMPONENT* DrawLibItem;
|
|
|
|
LIB_COMPONENT* Entry;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
for( ; DrawList != NULL; DrawList = DrawList->Next() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
if( DrawList->Type() == TYPE_SCH_COMPONENT )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
DrawLibItem = (SCH_COMPONENT*) DrawList;
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry =
|
|
|
|
CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
|
2007-09-20 21:06:49 +00:00
|
|
|
if( Entry == NULL )
|
2008-02-26 01:07:38 +00:00
|
|
|
continue;
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
OBJ_CMP_TO_LIST new_object;
|
2009-04-25 10:12:30 +00:00
|
|
|
new_object.m_RootCmp = DrawLibItem;
|
|
|
|
new_object.m_Entry = Entry;
|
|
|
|
new_object.m_Unit = DrawLibItem->GetUnitSelection( aSheet );
|
|
|
|
new_object.m_SheetPath = *aSheet;
|
|
|
|
new_object.m_IsNew = false;
|
|
|
|
new_object.m_Flag = 0;
|
2008-12-10 16:49:53 +00:00
|
|
|
new_object.m_TimeStamp = DrawLibItem->m_TimeStamp;
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
if( DrawLibItem->GetRef( aSheet ).IsEmpty() )
|
|
|
|
DrawLibItem->SetRef( aSheet, wxT( "DefRef?" ) );
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
new_object.SetRef( DrawLibItem->GetRef( aSheet ) );
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
new_object.m_NumRef = -1;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
if( DrawLibItem->GetField( VALUE )->m_Text.IsEmpty() )
|
|
|
|
DrawLibItem->GetField( VALUE )->m_Text = wxT( "~" );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
new_object.m_Value = &DrawLibItem->GetField( VALUE )->m_Text;
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList.push_back( new_object );
|
2007-09-20 21:06:49 +00:00
|
|
|
NbrCmp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NbrCmp;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/*
|
|
|
|
* Update the reference component for the schematic project (or the current
|
|
|
|
* sheet)
|
|
|
|
*/
|
2008-12-10 16:49:53 +00:00
|
|
|
static void ReAnnotateComponents( std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
/* update the reference numbers */
|
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-07-30 21:41:55 +00:00
|
|
|
#if 0
|
2008-12-10 16:49:53 +00:00
|
|
|
char* Text = aComponentsList[ii].m_Reference;
|
|
|
|
SCH_COMPONENT* component = aComponentsList[ii].m_RootCmp;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
if( aComponentsList[ii].m_NumRef < 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
strcat( Text, "?" );
|
|
|
|
else
|
2008-12-10 16:49:53 +00:00
|
|
|
sprintf( Text + strlen( Text ), "%d", aComponentsList[ii].m_NumRef );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
component->SetRef( &(aComponentsList[ii].m_SheetPath),
|
|
|
|
CONV_FROM_UTF8( Text ) );
|
2010-07-30 21:41:55 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
wxString ref = aComponentsList[ii].GetRef();
|
|
|
|
SCH_COMPONENT* component = aComponentsList[ii].m_RootCmp;
|
|
|
|
|
|
|
|
if( aComponentsList[ii].m_NumRef < 0 )
|
|
|
|
ref += wxChar( '?' );
|
|
|
|
else
|
|
|
|
ref << aComponentsList[ii].m_NumRef;
|
|
|
|
|
|
|
|
aComponentsList[ii].SetRef( ref );
|
|
|
|
|
|
|
|
component->SetRef( &aComponentsList[ii].m_SheetPath, ref );
|
|
|
|
#endif
|
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
component->m_Multi = aComponentsList[ii].m_Unit;
|
2010-07-30 21:41:55 +00:00
|
|
|
component->SetUnitSelection( &aComponentsList[ii].m_SheetPath,
|
2009-04-25 10:12:30 +00:00
|
|
|
aComponentsList[ii].m_Unit );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2008-12-10 16:49:53 +00:00
|
|
|
void BreakReference( std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-07-30 21:41:55 +00:00
|
|
|
std::string refText; // construct once outside loop
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList[ii].m_NumRef = -1;
|
2010-07-30 21:41:55 +00:00
|
|
|
|
|
|
|
refText = aComponentsList[ii].GetRefStr();
|
|
|
|
|
|
|
|
int ll = refText.length() - 1;
|
|
|
|
|
|
|
|
if( refText[ll] == '?' )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList[ii].m_IsNew = true;
|
2010-07-30 21:41:55 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
if( !aComponentsList[ii].IsPartsLocked() )
|
|
|
|
aComponentsList[ii].m_Unit = 0x7FFFFFFF;
|
2010-07-30 21:41:55 +00:00
|
|
|
|
|
|
|
refText.erase(ll); // delete last char
|
|
|
|
|
|
|
|
aComponentsList[ii].SetRefStr( refText );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
else if( isdigit( refText[ll] ) == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList[ii].m_IsNew = true;
|
|
|
|
if( !aComponentsList[ii].IsPartsLocked() )
|
|
|
|
aComponentsList[ii].m_Unit = 0x7FFFFFFF;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
else
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-07-30 21:41:55 +00:00
|
|
|
while( ll >= 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-07-30 21:41:55 +00:00
|
|
|
if( (refText[ll] <= ' ' ) || isdigit( refText[ll] ) )
|
|
|
|
ll--;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( isdigit( refText[ll + 1] ) )
|
|
|
|
{
|
|
|
|
// nul terminated C string into cp
|
|
|
|
const char* cp = refText.c_str() + ll + 1;
|
|
|
|
|
|
|
|
aComponentsList[ii].m_NumRef = atoi( cp );
|
|
|
|
}
|
|
|
|
|
|
|
|
refText.erase( ll+1 ); // delete from ll+1 to end
|
|
|
|
break;
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2010-07-30 21:41:55 +00:00
|
|
|
|
|
|
|
aComponentsList[ii].SetRefStr( refText );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/*
|
|
|
|
* Compute the reference number for components without reference number
|
|
|
|
* Compute .m_NumRef member
|
|
|
|
*/
|
2008-12-10 16:49:53 +00:00
|
|
|
static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
int LastReferenceNumber, NumberOfUnits, Unit;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Components with an invisible reference (power...) always are
|
|
|
|
* re-annotated. So set their .m_IsNew member to true
|
2008-12-10 16:49:53 +00:00
|
|
|
*/
|
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-07-30 21:41:55 +00:00
|
|
|
if( aComponentsList[ii].GetRefStr()[0] == '#' )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList[ii].m_IsNew = true;
|
|
|
|
aComponentsList[ii].m_NumRef = 0;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* 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 ...
|
2008-12-10 16:49:53 +00:00
|
|
|
*/
|
|
|
|
unsigned first = 0;
|
|
|
|
/* calculate the last used number for this reference prefix: */
|
|
|
|
LastReferenceNumber = GetLastReferenceNumber( first, aComponentsList );
|
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
if( aComponentsList[ii].m_Flag )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( aComponentsList[first].CompareRef( aComponentsList[ii] ) != 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
/* New reference found: we need a new ref number for this
|
|
|
|
* reference */
|
2008-12-10 16:49:53 +00:00
|
|
|
first = ii;
|
|
|
|
LastReferenceNumber = GetLastReferenceNumber( ii, aComponentsList );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/* Annotation of one part per package components (trivial case)*/
|
2009-10-05 17:52:41 +00:00
|
|
|
if( aComponentsList[ii].m_Entry->GetPartCount() <= 1 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
if( aComponentsList[ii].m_IsNew )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
LastReferenceNumber++;
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList[ii].m_NumRef = LastReferenceNumber;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList[ii].m_Unit = 1;
|
|
|
|
aComponentsList[ii].m_Flag = 1;
|
|
|
|
aComponentsList[ii].m_IsNew = false;
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
/* Annotation of multi-part components ( n parts per package )
|
2008-04-21 06:34:56 +00:00
|
|
|
* (complex case) */
|
2009-10-05 17:52:41 +00:00
|
|
|
NumberOfUnits = aComponentsList[ii].m_Entry->GetPartCount();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
if( aComponentsList[ii].m_IsNew )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-02-26 01:07:38 +00:00
|
|
|
LastReferenceNumber++;
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList[ii].m_NumRef = LastReferenceNumber;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
if( !aComponentsList[ii].IsPartsLocked() )
|
|
|
|
aComponentsList[ii].m_Unit = 1;
|
|
|
|
aComponentsList[ii].m_Flag = 1;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
/* search for others units of this component.
|
2009-12-02 21:44:03 +00:00
|
|
|
* we search for others parts that have the same value and the same
|
|
|
|
* reference prefix (ref without ref number)
|
2008-12-10 16:49:53 +00:00
|
|
|
*/
|
2007-09-20 21:06:49 +00:00
|
|
|
for( Unit = 1; Unit <= NumberOfUnits; Unit++ )
|
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
if( aComponentsList[ii].m_Unit == Unit )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2008-12-10 16:49:53 +00:00
|
|
|
int found = ExistUnit( ii, Unit, aComponentsList );
|
|
|
|
if( found >= 0 )
|
2009-12-02 21:44:03 +00:00
|
|
|
continue; /* this unit exists for this reference (unit
|
|
|
|
* already annotated) */
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Search a component to annotate ( same prefix, same value,
|
|
|
|
* not annotated) */
|
2008-12-10 16:49:53 +00:00
|
|
|
for( unsigned jj = ii + 1; jj < aComponentsList.size(); jj++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
if( aComponentsList[jj].m_Flag ) // already tested
|
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( aComponentsList[ii].CompareRef( aComponentsList[jj] ) != 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2008-12-10 16:49:53 +00:00
|
|
|
if( aComponentsList[jj].CompareValue( aComponentsList[ii] ) != 0 )
|
2009-12-02 21:44:03 +00:00
|
|
|
continue;
|
2008-12-10 16:49:53 +00:00
|
|
|
if( !aComponentsList[jj].m_IsNew )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2008-02-28 19:27:25 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Component without reference number found, annotate it
|
|
|
|
* if possible */
|
|
|
|
if( !aComponentsList[jj].IsPartsLocked()
|
|
|
|
|| ( aComponentsList[jj].m_Unit == Unit ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
aComponentsList[jj].m_NumRef = aComponentsList[ii].m_NumRef;
|
|
|
|
aComponentsList[jj].m_Unit = Unit;
|
|
|
|
aComponentsList[jj].m_Flag = 1;
|
|
|
|
aComponentsList[jj].m_IsNew = false;
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/**
|
|
|
|
* 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 )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
int LastNumber = 0;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
/* New identifier. */
|
2008-12-10 16:49:53 +00:00
|
|
|
if( aComponentsList[aObjet].CompareRef( aComponentsList[ii] ) != 0 )
|
|
|
|
continue;
|
|
|
|
if( LastNumber < aComponentsList[ii].m_NumRef )
|
|
|
|
LastNumber = aComponentsList[ii].m_NumRef;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return LastNumber;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2008-12-10 16:49:53 +00:00
|
|
|
static int ExistUnit( int aObjet, int Unit,
|
|
|
|
std::vector <OBJ_CMP_TO_LIST>& aComponentsList )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
int NumRef;
|
|
|
|
|
|
|
|
NumRef = aComponentsList[aObjet].m_NumRef;
|
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
if( aObjet == (int) ii )
|
|
|
|
// Do not compare with itself !
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2009-12-02 21:44:03 +00:00
|
|
|
if( aComponentsList[ii].m_IsNew )
|
|
|
|
// Not already with an updated reference
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2009-12-02 21:44:03 +00:00
|
|
|
if( aComponentsList[ii].m_NumRef != NumRef )
|
|
|
|
// Not the same reference number (like 35 in R35)
|
2008-04-16 08:40:31 +00:00
|
|
|
continue;
|
2009-12-02 21:44:03 +00:00
|
|
|
if( aComponentsList[aObjet].CompareRef( aComponentsList[ii] ) != 0 )
|
|
|
|
// Not the same reference prefix
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2009-12-02 21:44:03 +00:00
|
|
|
if( aComponentsList[ii].m_Unit == Unit )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
// A part with the same reference and the given unit is found
|
2007-09-20 21:06:49 +00:00
|
|
|
return ii;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
/**
|
|
|
|
* Function CheckAnnotate
|
2008-12-12 21:30:07 +00:00
|
|
|
* Check errors relatives to annotation:
|
|
|
|
* components not annotated
|
|
|
|
* components having the same reference (duplicates)
|
|
|
|
* for multiple parts per package components :
|
|
|
|
* part number > number of parts
|
|
|
|
* different values between parts
|
2009-12-02 21:44:03 +00:00
|
|
|
* @param aMessageList = a wxArrayString to store messages. If NULL, they
|
|
|
|
* are displayed in a wxMessageBox
|
2009-07-05 12:09:41 +00:00
|
|
|
* @param aOneSheetOnly : true = search is made only in the current sheet
|
2009-12-02 21:44:03 +00:00
|
|
|
* false = search in whole hierarchy (usual search).
|
|
|
|
* @return errors count
|
2008-12-10 16:49:53 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList,
|
|
|
|
bool aOneSheetOnly )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
int error;
|
|
|
|
wxString Buff;
|
|
|
|
wxString msg, cmpref;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/* build the screen list */
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_LIST SheetList;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
std::vector <OBJ_CMP_TO_LIST> ComponentsList;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
/* Build the list of components */
|
2009-07-05 12:09:41 +00:00
|
|
|
if( !aOneSheetOnly )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH* sheet;
|
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL;
|
|
|
|
sheet = SheetList.GetNext() )
|
2008-12-10 16:49:53 +00:00
|
|
|
AddComponentsInSheetToList( ComponentsList, sheet );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
else
|
2009-07-05 12:09:41 +00:00
|
|
|
AddComponentsInSheetToList( ComponentsList, GetSheet() );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(), AnnotateByValue );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
/* Break full components reference in name (prefix) and number: example:
|
2008-04-21 06:34:56 +00:00
|
|
|
* IC1 become IC, and 1 */
|
2008-12-10 16:49:53 +00:00
|
|
|
BreakReference( ComponentsList );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/* count not yet annotated items */
|
2007-09-20 21:06:49 +00:00
|
|
|
error = 0;
|
2008-12-10 16:49:53 +00:00
|
|
|
int imax = ComponentsList.size() - 1;
|
|
|
|
for( int ii = 0; ii < imax; ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
msg.Empty();
|
2007-09-21 04:40:12 +00:00
|
|
|
Buff.Empty();
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
if( ComponentsList[ii].m_IsNew )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
if( ComponentsList[ii].m_NumRef >= 0 )
|
|
|
|
Buff << ComponentsList[ii].m_NumRef;
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
|
|
|
Buff = wxT( "?" );
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
cmpref = ComponentsList[ii].GetRef();
|
2008-02-26 01:07:38 +00:00
|
|
|
msg.Printf( _( "item not annotated: %s%s" ),
|
2010-07-30 21:41:55 +00:00
|
|
|
GetChars( cmpref ), GetChars( Buff ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( ComponentsList[ii].m_Unit > 0 )
|
|
|
|
&& ( ComponentsList[ii].m_Unit < 0x7FFFFFFF ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
Buff.Printf( _( "( unit %d)" ), ComponentsList[ii].m_Unit );
|
2007-09-20 21:06:49 +00:00
|
|
|
msg << Buff;
|
|
|
|
}
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aMessageList )
|
|
|
|
{
|
2009-07-08 15:42:45 +00:00
|
|
|
aMessageList->Add( msg + wxT( "\n" ) );
|
2009-07-05 12:09:41 +00:00
|
|
|
}
|
|
|
|
else
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-07-05 12:09:41 +00:00
|
|
|
DisplayError( NULL, msg );
|
2009-12-02 21:44:03 +00:00
|
|
|
}
|
2007-12-03 06:54:19 +00:00
|
|
|
error++;
|
2007-09-21 04:40:12 +00:00
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
// Annotate error
|
2009-12-02 21:44:03 +00:00
|
|
|
if( MAX( ComponentsList[ii].m_Entry->GetPartCount(), 1 )
|
|
|
|
< ComponentsList[ii].m_Unit )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
if( ComponentsList[ii].m_NumRef >= 0 )
|
|
|
|
Buff << ComponentsList[ii].m_NumRef;
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
|
|
|
Buff = wxT( "?" );
|
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
cmpref = ComponentsList[ii].GetRef();
|
|
|
|
|
|
|
|
msg.Printf( _( "Error item %s%s" ), GetChars( cmpref ),
|
|
|
|
GetChars( Buff ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
Buff.Printf( _( " unit %d and no more than %d parts" ),
|
2009-12-02 21:44:03 +00:00
|
|
|
ComponentsList[ii].m_Unit,
|
|
|
|
ComponentsList[ii].m_Entry->GetPartCount() );
|
2007-09-20 21:06:49 +00:00
|
|
|
msg << Buff;
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aMessageList )
|
|
|
|
{
|
2009-07-08 15:42:45 +00:00
|
|
|
aMessageList->Add( msg + wxT( "\n" ));
|
2009-07-05 12:09:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayError( NULL, msg );
|
2007-12-03 06:54:19 +00:00
|
|
|
error++;
|
2007-09-21 04:40:12 +00:00
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( error )
|
|
|
|
return error;
|
|
|
|
|
2007-09-21 04:40:12 +00:00
|
|
|
// count the duplicated elements (if all are annotated)
|
2008-12-10 16:49:53 +00:00
|
|
|
for( int ii = 0; (ii < imax) && (error < 4); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
msg.Empty();
|
2007-09-21 04:40:12 +00:00
|
|
|
Buff.Empty();
|
2007-12-03 06:54:19 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( ComponentsList[ii].CompareRef( ComponentsList[ii + 1] ) != 0 )
|
2008-12-10 16:49:53 +00:00
|
|
|
|| ( ComponentsList[ii].m_NumRef != ComponentsList[ii + 1].m_NumRef ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
/* Same reference found. If same unit, error !
|
|
|
|
*/
|
|
|
|
if( ComponentsList[ii].m_Unit == ComponentsList[ii + 1].m_Unit )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
if( ComponentsList[ii].m_NumRef >= 0 )
|
|
|
|
Buff << ComponentsList[ii].m_NumRef;
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
|
|
|
Buff = wxT( "?" );
|
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
cmpref = ComponentsList[ii].GetRef();
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
msg.Printf( _( "Multiple item %s%s" ),
|
2010-07-30 21:41:55 +00:00
|
|
|
GetChars( cmpref ), GetChars( Buff ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( ComponentsList[ii].m_Unit > 0 )
|
|
|
|
&& ( ComponentsList[ii].m_Unit < 0x7FFFFFFF ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
Buff.Printf( _( " (unit %d)" ), ComponentsList[ii].m_Unit );
|
2007-09-20 21:06:49 +00:00
|
|
|
msg << Buff;
|
|
|
|
}
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aMessageList )
|
|
|
|
{
|
2009-07-08 15:42:45 +00:00
|
|
|
aMessageList->Add( msg + wxT( "\n" ));
|
2009-07-05 12:09:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayError( NULL, msg );
|
2007-12-03 06:54:19 +00:00
|
|
|
error++;
|
2007-09-21 04:40:12 +00:00
|
|
|
continue;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
/* Test error if units are different but number of parts per package
|
2009-12-02 21:44:03 +00:00
|
|
|
* 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() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
if( ComponentsList[ii].m_NumRef >= 0 )
|
|
|
|
Buff << ComponentsList[ii].m_NumRef;
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
|
|
|
Buff = wxT( "?" );
|
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
cmpref = ComponentsList[ii].GetRef();
|
2008-02-26 01:07:38 +00:00
|
|
|
msg.Printf( _( "Multiple item %s%s" ),
|
2010-07-30 21:41:55 +00:00
|
|
|
GetChars( cmpref ), GetChars( Buff ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( ComponentsList[ii].m_Unit > 0 )
|
|
|
|
&& ( ComponentsList[ii].m_Unit < 0x7FFFFFFF ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-12-10 16:49:53 +00:00
|
|
|
Buff.Printf( _( " (unit %d)" ), ComponentsList[ii].m_Unit );
|
2007-09-20 21:06:49 +00:00
|
|
|
msg << Buff;
|
|
|
|
}
|
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aMessageList )
|
|
|
|
{
|
2009-07-08 15:42:45 +00:00
|
|
|
aMessageList->Add( msg + wxT( "\n" ));
|
2009-07-05 12:09:41 +00:00
|
|
|
}
|
|
|
|
else
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-07-05 12:09:41 +00:00
|
|
|
DisplayError( NULL, msg );
|
2009-12-02 21:44:03 +00:00
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
error++;
|
|
|
|
}
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Error if values are different between units, for the same
|
|
|
|
* reference */
|
2009-04-25 10:12:30 +00:00
|
|
|
int next = ii + 1;
|
2008-12-10 16:49:53 +00:00
|
|
|
if( ComponentsList[ii].CompareValue( ComponentsList[next] ) != 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-07-30 21:41:55 +00:00
|
|
|
wxString nextcmpref = ComponentsList[next].GetRef();
|
|
|
|
|
|
|
|
cmpref = ComponentsList[ii].GetRef();
|
|
|
|
|
2009-04-25 10:12:30 +00:00
|
|
|
#if defined(KICAD_GOST)
|
2008-11-05 11:41:15 +00:00
|
|
|
msg.Printf( _( "Diff values for %s%d.%c (%s) and %s%d.%c (%s)" ),
|
2009-12-02 21:44:03 +00:00
|
|
|
cmpref.GetData(),
|
|
|
|
ComponentsList[ii].m_NumRef,
|
|
|
|
ComponentsList[ii].m_Unit + '1' - 1,
|
2010-07-30 21:41:55 +00:00
|
|
|
GetChars( *ComponentsList[ii].m_Value ),
|
|
|
|
GetChars( nextcmpref ),
|
2009-12-02 21:44:03 +00:00
|
|
|
ComponentsList[next].m_NumRef,
|
|
|
|
ComponentsList[next].m_Unit + '1' - 1,
|
|
|
|
ComponentsList[next].m_Value->GetData() );
|
2008-11-05 11:41:15 +00:00
|
|
|
#else
|
2007-09-20 21:06:49 +00:00
|
|
|
msg.Printf( _( "Diff values for %s%d%c (%s) and %s%d%c (%s)" ),
|
2009-12-02 21:44:03 +00:00
|
|
|
cmpref.GetData(),
|
|
|
|
ComponentsList[ii].m_NumRef,
|
|
|
|
ComponentsList[ii].m_Unit + 'A' - 1,
|
2010-07-30 21:41:55 +00:00
|
|
|
GetChars( *ComponentsList[ii].m_Value ),
|
|
|
|
GetChars( nextcmpref ),
|
2009-12-02 21:44:03 +00:00
|
|
|
ComponentsList[next].m_NumRef,
|
|
|
|
ComponentsList[next].m_Unit + 'A' - 1,
|
2010-07-30 21:41:55 +00:00
|
|
|
GetChars( *ComponentsList[next].m_Value ) );
|
2008-11-05 11:41:15 +00:00
|
|
|
#endif
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aMessageList )
|
|
|
|
{
|
2009-07-08 15:42:45 +00:00
|
|
|
aMessageList->Add( msg + wxT( "\n" ));
|
2009-12-02 21:44:03 +00:00
|
|
|
}
|
2009-07-05 12:09:41 +00:00
|
|
|
else
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-07-05 12:09:41 +00:00
|
|
|
DisplayError( NULL, msg );
|
2009-12-02 21:44:03 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
error++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-25 10:12:30 +00:00
|
|
|
// count the duplicated time stamps
|
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(), SortByTimeStamp );
|
2009-12-02 21:44:03 +00:00
|
|
|
for( int ii = 0; ( ii < imax ) && ( error < 4 ); ii++ )
|
2009-04-25 10:12:30 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
if( (ComponentsList[ii].m_TimeStamp
|
|
|
|
!= ComponentsList[ii + 1].m_TimeStamp)
|
|
|
|
|| ( ComponentsList[ii].m_SheetPath
|
|
|
|
!= ComponentsList[ii + 1].m_SheetPath ) )
|
2009-04-25 10:12:30 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Same time stamp found. */
|
|
|
|
wxString nextcmpref;
|
|
|
|
wxString full_path;
|
2010-07-30 21:41:55 +00:00
|
|
|
|
2009-04-25 10:12:30 +00:00
|
|
|
full_path.Printf( wxT( "%s%8.8X" ),
|
2010-07-30 21:41:55 +00:00
|
|
|
GetChars( ComponentsList[ii].m_SheetPath.Path() ),
|
2009-04-25 10:12:30 +00:00
|
|
|
ComponentsList[ii].m_TimeStamp );
|
2010-07-30 21:41:55 +00:00
|
|
|
|
|
|
|
cmpref = ComponentsList[ii].GetRef();
|
|
|
|
nextcmpref = ComponentsList[ii + 1].GetRef();
|
|
|
|
|
2009-04-25 10:12:30 +00:00
|
|
|
msg.Printf( _( "duplicate time stamp (%s) for %s%d and %s%d" ),
|
2010-07-30 21:41:55 +00:00
|
|
|
GetChars( full_path ),
|
|
|
|
GetChars( cmpref ), ComponentsList[ii].m_NumRef,
|
|
|
|
GetChars( nextcmpref ), ComponentsList[ii + 1].m_NumRef );
|
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
if( aMessageList )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
aMessageList->Add( msg + wxT( "\n" ));
|
|
|
|
}
|
2009-07-05 12:09:41 +00:00
|
|
|
else
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-07-05 12:09:41 +00:00
|
|
|
DisplayError( NULL, msg );
|
2009-12-02 21:44:03 +00:00
|
|
|
}
|
|
|
|
|
2009-04-25 10:12:30 +00:00
|
|
|
error++;
|
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
return error;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2009-04-25 10:12:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************
|
|
|
|
* function to sort sch_items by time stamp
|
|
|
|
************************************************/
|
|
|
|
static bool SortItemByTimeStamp( const SCH_ITEM* item1, const SCH_ITEM* item2 )
|
|
|
|
{
|
|
|
|
int ii = item1->m_TimeStamp - item2->m_TimeStamp;
|
|
|
|
|
|
|
|
/* if same time stamp, compare type, in order to have
|
2009-07-05 12:09:41 +00:00
|
|
|
* first : component
|
|
|
|
* after : sheet
|
|
|
|
* because this is the first item that have its time stamp changed
|
|
|
|
* and changing the time stamp of a sheet can loose annotation
|
|
|
|
*/
|
|
|
|
|
|
|
|
if( ii == 0 && ( item1->Type() != item2->Type() ) )
|
|
|
|
if( item1->Type() == DRAW_SHEET_STRUCT_TYPE )
|
2009-04-25 10:12:30 +00:00
|
|
|
ii = -1;
|
|
|
|
|
|
|
|
return ii < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Function ReplaceDuplicatedTimeStamps
|
2009-12-02 21:44:03 +00:00
|
|
|
* Search for duplicate time stamps in the whole hierarchy, and replace
|
|
|
|
* duplicate by new time stamps
|
2009-04-25 10:12:30 +00:00
|
|
|
*/
|
|
|
|
int ReplaceDuplicatedTimeStamps()
|
|
|
|
{
|
|
|
|
/* Build the whole screen list */
|
2010-10-26 20:25:48 +00:00
|
|
|
SCH_SCREENS ScreenList;
|
2009-04-25 10:12:30 +00:00
|
|
|
|
|
|
|
/* Build the list of items with time stamps (components and sheets)
|
2009-12-02 21:44:03 +00:00
|
|
|
* 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
|
2009-04-25 10:12:30 +00:00
|
|
|
*/
|
|
|
|
std::vector <SCH_ITEM*> itemlist;
|
|
|
|
SCH_SCREEN* screen;
|
|
|
|
SCH_ITEM* item;
|
2009-12-02 21:44:03 +00:00
|
|
|
for( screen = ScreenList.GetFirst(); screen != NULL;
|
|
|
|
screen = ScreenList.GetNext() )
|
2009-04-25 10:12:30 +00:00
|
|
|
{
|
|
|
|
item = screen->EEDrawList;
|
|
|
|
while( item )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( item->Type() == DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
|| ( item->Type() == TYPE_SCH_COMPONENT ) )
|
2009-04-25 10:12:30 +00:00
|
|
|
itemlist.push_back( item );
|
|
|
|
|
|
|
|
item = item->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test and replace duplicated time stamps
|
|
|
|
int imax = itemlist.size() - 1;
|
|
|
|
int errcount = 0;
|
|
|
|
sort( itemlist.begin(), itemlist.end(), SortItemByTimeStamp );
|
|
|
|
for( int ii = 0; ii < imax; ii++ )
|
|
|
|
{
|
|
|
|
item = itemlist[ii];
|
|
|
|
SCH_ITEM* nextitem = itemlist[ii + 1];
|
|
|
|
if( item->m_TimeStamp == nextitem->m_TimeStamp )
|
|
|
|
{
|
|
|
|
errcount++;
|
2009-07-05 12:09:41 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// for a component, update its Time stamp and its paths
|
|
|
|
// (m_PathsAndReferences field)
|
2009-07-05 12:09:41 +00:00
|
|
|
if( item->Type() == TYPE_SCH_COMPONENT )
|
|
|
|
( (SCH_COMPONENT*) item )->SetTimeStamp( GetTimeStamp() );
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// 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)
|
2009-04-25 10:12:30 +00:00
|
|
|
else
|
|
|
|
item->m_TimeStamp = GetTimeStamp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return errcount;
|
|
|
|
}
|