|
|
|
@ -2,24 +2,27 @@ |
|
|
|
/* annotate.cpp: component annotation */ |
|
|
|
/**************************************/ |
|
|
|
|
|
|
|
#include <algorithm> // to use sort vector
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "netlist.h"
|
|
|
|
#include "protos.h"
|
|
|
|
#include "netlist.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Local Functions*/ |
|
|
|
static int ListeComposants( CmpListStruct* BaseListeCmp, |
|
|
|
DrawSheetPath* sheet ); |
|
|
|
static void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ); |
|
|
|
static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp ); |
|
|
|
static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ); |
|
|
|
int GetLastReferenceNumber( CmpListStruct* Objet, |
|
|
|
CmpListStruct* BaseListeCmp, |
|
|
|
int NbOfCmp ); |
|
|
|
static int ExistUnit( CmpListStruct* Objet, int Unit, |
|
|
|
CmpListStruct* BaseListeCmp, int NbOfCmp ); |
|
|
|
static int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList, |
|
|
|
DrawSheetPath* 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 ); |
|
|
|
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 ); |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/ |
|
|
|
@ -34,7 +37,7 @@ void WinEDA_SchematicFrame::UpdateSheetNumberAndDate() |
|
|
|
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
|
|
|
|
@ -55,13 +58,10 @@ void ReAnnotatePowerSymbolsOnly( void ) |
|
|
|
/* Build the screen list (screen, not sheet) */ |
|
|
|
EDA_SheetList SheetList( NULL ); |
|
|
|
|
|
|
|
|
|
|
|
DrawSheetPath* 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() ) |
|
|
|
@ -70,10 +70,8 @@ void ReAnnotatePowerSymbolsOnly( void ) |
|
|
|
continue; |
|
|
|
SCH_COMPONENT* DrawLibItem = |
|
|
|
(SCH_COMPONENT*) DrawList; |
|
|
|
EDA_LibComponentStruct* Entry = |
|
|
|
FindLibPart( |
|
|
|
DrawLibItem->m_ChipName.GetData(), wxEmptyString, |
|
|
|
FIND_ROOT ); |
|
|
|
EDA_LibComponentStruct* Entry = FindLibPart( |
|
|
|
DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); |
|
|
|
if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) ) |
|
|
|
continue; |
|
|
|
|
|
|
|
@ -94,59 +92,53 @@ void ReAnnotatePowerSymbolsOnly( void ) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* qsort function to annotate items by their position.
|
|
|
|
/* sort function to annotate items by their position.
|
|
|
|
* Components are sorted |
|
|
|
* by reference |
|
|
|
* if same reference: by sheet |
|
|
|
* if same sheet, by X pos |
|
|
|
* if same X pos, by Y pos |
|
|
|
* if same Y pos, by time stamp |
|
|
|
* if same X pos, by Y pos |
|
|
|
* if same Y pos, by time stamp |
|
|
|
*/ |
|
|
|
int AnnotateBy_X_Position( const void* o1, const void* o2 ) |
|
|
|
static bool AnnotateBy_X_Position( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST& item2 ) |
|
|
|
{ |
|
|
|
CmpListStruct* item1 = (CmpListStruct*) o1; |
|
|
|
CmpListStruct* item2 = (CmpListStruct*) o2; |
|
|
|
|
|
|
|
int ii = strnicmp( item1->m_TextRef, item2->m_TextRef, 32 ); |
|
|
|
int ii = item1.CompareRef( item2 ); |
|
|
|
|
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_SheetList.Cmp( item2->m_SheetList ); |
|
|
|
ii = item1.m_SheetPath.Cmp( item2.m_SheetPath ); |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_Pos.x - item2->m_Pos.x; |
|
|
|
ii = item1.m_RootCmp->m_Pos.x - item2.m_RootCmp->m_Pos.x; |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_Pos.y - item2->m_Pos.y; |
|
|
|
ii = item1.m_RootCmp->m_Pos.y - item2.m_RootCmp->m_Pos.y; |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_TimeStamp - item2->m_TimeStamp; |
|
|
|
ii = item1.m_TimeStamp - item2.m_TimeStamp; |
|
|
|
|
|
|
|
return ii; |
|
|
|
return ii < 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* qsort function to annotate items by their position.
|
|
|
|
/* sort function to annotate items by their position.
|
|
|
|
* Components are sorted |
|
|
|
* by reference |
|
|
|
* if same reference: by sheet |
|
|
|
* if same sheet, by Y pos |
|
|
|
* if same Y pos, by X pos |
|
|
|
* if same X pos, by time stamp |
|
|
|
* if same Y pos, by X pos |
|
|
|
* if same X pos, by time stamp |
|
|
|
*/ |
|
|
|
int AnnotateBy_Y_Position( const void* o1, const void* o2 ) |
|
|
|
static bool AnnotateBy_Y_Position( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST& item2 ) |
|
|
|
{ |
|
|
|
CmpListStruct* item1 = (CmpListStruct*) o1; |
|
|
|
CmpListStruct* item2 = (CmpListStruct*) o2; |
|
|
|
|
|
|
|
int ii = strnicmp( item1->m_TextRef, item2->m_TextRef, 32 ); |
|
|
|
int ii = item1.CompareRef( item2 ); |
|
|
|
|
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_SheetList.Cmp( item2->m_SheetList ); |
|
|
|
ii = item1.m_SheetPath.Cmp( item2.m_SheetPath ); |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_Pos.y - item2->m_Pos.y; |
|
|
|
ii = item1.m_RootCmp->m_Pos.y - item2.m_RootCmp->m_Pos.y; |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_Pos.x - item2->m_Pos.x; |
|
|
|
ii = item1.m_RootCmp->m_Pos.x - item2.m_RootCmp->m_Pos.x; |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_TimeStamp - item2->m_TimeStamp; |
|
|
|
ii = item1.m_TimeStamp - item2.m_TimeStamp; |
|
|
|
|
|
|
|
return ii; |
|
|
|
return ii < 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -159,27 +151,24 @@ int AnnotateBy_Y_Position( const void* o1, const void* o2 ) |
|
|
|
* if same unit number, by sheet |
|
|
|
* if same sheet, by time stamp |
|
|
|
*****************************************************************************/ |
|
|
|
int AnnotateByValue( const void* o1, const void* o2 ) |
|
|
|
static bool AnnotateByValue( const OBJ_CMP_TO_LIST& item1, const OBJ_CMP_TO_LIST& item2 ) |
|
|
|
{ |
|
|
|
CmpListStruct* item1 = (CmpListStruct*) o1; |
|
|
|
CmpListStruct* item2 = (CmpListStruct*) o2; |
|
|
|
|
|
|
|
int ii = strnicmp( item1->m_TextRef, item2->m_TextRef, 32 ); |
|
|
|
int ii = item1.CompareRef( item2 ); |
|
|
|
|
|
|
|
if( ii == 0 ) |
|
|
|
ii = strnicmp( item1->m_TextValue, item2->m_TextValue, 32 ); |
|
|
|
ii = item1.CompareValue( item2 ); |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_Unit - item2->m_Unit; |
|
|
|
ii = item1.m_Unit - item2.m_Unit; |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_SheetList.Cmp( item2->m_SheetList ); |
|
|
|
ii = item1.m_SheetPath.Cmp( item2.m_SheetPath ); |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_Pos.x - item2->m_Pos.x; |
|
|
|
ii = item1.m_RootCmp->m_Pos.x - item2.m_RootCmp->m_Pos.x; |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_Pos.y - item2->m_Pos.y; |
|
|
|
ii = item1.m_RootCmp->m_Pos.y - item2.m_RootCmp->m_Pos.y; |
|
|
|
if( ii == 0 ) |
|
|
|
ii = item1->m_TimeStamp - item2->m_TimeStamp; |
|
|
|
ii = item1.m_TimeStamp - item2.m_TimeStamp; |
|
|
|
|
|
|
|
return ii; |
|
|
|
return ii < 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -193,9 +182,9 @@ void WinEDA_SchematicFrame::DeleteAnnotation( bool aCurrentSheetOnly, bool aRedr |
|
|
|
* @param aRedraw : true to refresh display |
|
|
|
*/ |
|
|
|
{ |
|
|
|
EDA_BaseStruct* strct; |
|
|
|
SCH_SCREEN* screen; |
|
|
|
EDA_ScreenList ScreenList; |
|
|
|
SCH_ITEM* strct; |
|
|
|
SCH_SCREEN* screen; |
|
|
|
EDA_ScreenList ScreenList; |
|
|
|
|
|
|
|
screen = ScreenList.GetFirst(); |
|
|
|
|
|
|
|
@ -251,11 +240,9 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent, |
|
|
|
int sortOption, |
|
|
|
bool resetAnnotation ) |
|
|
|
{ |
|
|
|
int ii, NbOfCmp; |
|
|
|
DrawSheetPath* sheet; |
|
|
|
CmpListStruct* BaseListeCmp; |
|
|
|
std::vector <OBJ_CMP_TO_LIST> ComponentsList; |
|
|
|
|
|
|
|
wxBusyCursor dummy; |
|
|
|
wxBusyCursor dummy; |
|
|
|
|
|
|
|
/* If it is an annotation for all the components, reset previous
|
|
|
|
* annotation: */ |
|
|
|
@ -268,87 +255,59 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent, |
|
|
|
/* Update the sheet number, sheet count and date */ |
|
|
|
parent->UpdateSheetNumberAndDate(); |
|
|
|
|
|
|
|
/* First pass: Component counting */ |
|
|
|
ii = 0; |
|
|
|
sheet = parent->GetSheet(); |
|
|
|
if( annotateSchematic ) |
|
|
|
{ |
|
|
|
NbOfCmp = 0; |
|
|
|
for( sheet = SheetList.GetFirst(); |
|
|
|
sheet != NULL; |
|
|
|
sheet = SheetList.GetNext() ) |
|
|
|
NbOfCmp += ListeComposants( NULL, sheet ); |
|
|
|
} |
|
|
|
else |
|
|
|
NbOfCmp = ListeComposants( NULL, sheet ); |
|
|
|
|
|
|
|
if( NbOfCmp == 0 ) |
|
|
|
return; |
|
|
|
|
|
|
|
BaseListeCmp = (CmpListStruct*) MyZMalloc( NbOfCmp * sizeof(CmpListStruct) ); |
|
|
|
|
|
|
|
/* Second pass : Init data tables */ |
|
|
|
/* Build component list */ |
|
|
|
if( annotateSchematic ) |
|
|
|
{ |
|
|
|
ii = 0; |
|
|
|
DrawSheetPath* sheet; |
|
|
|
for( sheet = SheetList.GetFirst(); |
|
|
|
sheet != NULL; |
|
|
|
sheet = SheetList.GetNext() ) |
|
|
|
ii += ListeComposants( BaseListeCmp + ii, sheet ); |
|
|
|
AddComponentsInSheetToList( ComponentsList, sheet ); |
|
|
|
} |
|
|
|
else |
|
|
|
ii = ListeComposants( BaseListeCmp, sheet ); |
|
|
|
AddComponentsInSheetToList( ComponentsList, parent->GetSheet() ); |
|
|
|
|
|
|
|
if( ii != NbOfCmp ) |
|
|
|
DisplayError( parent, wxT( "Internal error in AnnotateComponents()" ) ); |
|
|
|
|
|
|
|
/* Break full components reference in name (prefix) and number:
|
|
|
|
* example: IC1 become IC, and 1 */ |
|
|
|
BreakReference( BaseListeCmp, NbOfCmp ); |
|
|
|
BreakReference( ComponentsList ); |
|
|
|
|
|
|
|
switch( sortOption ) |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct), |
|
|
|
( int( * ) ( const void*, const void* ) )AnnotateBy_X_Position ); |
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(), AnnotateBy_X_Position ); |
|
|
|
break; |
|
|
|
|
|
|
|
case 1: |
|
|
|
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct), |
|
|
|
( int( * ) ( const void*, const void* ) )AnnotateBy_Y_Position ); |
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(), AnnotateBy_Y_Position ); |
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct), |
|
|
|
( int( * ) ( const void*, const void* ) )AnnotateByValue ); |
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(), AnnotateByValue ); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
/* Recalculate reference numbers */ |
|
|
|
ComputeReferenceNumber( BaseListeCmp, NbOfCmp ); |
|
|
|
ReAnnotateComponents( BaseListeCmp, NbOfCmp ); |
|
|
|
|
|
|
|
MyFree( BaseListeCmp ); |
|
|
|
BaseListeCmp = NULL; |
|
|
|
ComputeReferenceNumber( ComponentsList ); |
|
|
|
ReAnnotateComponents( ComponentsList ); |
|
|
|
|
|
|
|
/* Final control */ |
|
|
|
/* Final control (just in case ... )*/ |
|
|
|
CheckAnnotate( parent, !annotateSchematic ); |
|
|
|
parent->DrawPanel->Refresh( true ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* if BaseListeCmp == NULL : count components |
|
|
|
* else update data table BaseListeCmp |
|
|
|
* Add a OBJ_CMP_TO_LIST object in aComponentsList for each component foun in sheet |
|
|
|
*****************************************************************************/ |
|
|
|
int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetPath* sheet ) |
|
|
|
int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList, DrawSheetPath* aSheet ) |
|
|
|
{ |
|
|
|
int NbrCmp = 0; |
|
|
|
EDA_BaseStruct* DrawList = sheet->LastDrawList(); |
|
|
|
EDA_BaseStruct* DrawList = aSheet->LastDrawList(); |
|
|
|
SCH_COMPONENT* DrawLibItem; |
|
|
|
EDA_LibComponentStruct* Entry; |
|
|
|
|
|
|
|
for( ; DrawList; DrawList = DrawList->Next() ) |
|
|
|
for( ; DrawList != NULL; DrawList = DrawList->Next() ) |
|
|
|
{ |
|
|
|
if( DrawList->Type() == TYPE_SCH_COMPONENT ) |
|
|
|
{ |
|
|
|
@ -359,34 +318,28 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetPath* sheet ) |
|
|
|
if( Entry == NULL ) |
|
|
|
continue; |
|
|
|
|
|
|
|
if( BaseListeCmp == NULL ) /* Items counting only */ |
|
|
|
{ |
|
|
|
NbrCmp++; |
|
|
|
continue; |
|
|
|
} |
|
|
|
OBJ_CMP_TO_LIST new_object; |
|
|
|
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; |
|
|
|
new_object.m_TimeStamp = DrawLibItem->m_TimeStamp; |
|
|
|
|
|
|
|
BaseListeCmp[NbrCmp].m_Cmp = DrawLibItem; |
|
|
|
BaseListeCmp[NbrCmp].m_NbParts = Entry->m_UnitCount; |
|
|
|
BaseListeCmp[NbrCmp].m_Unit = DrawLibItem->GetUnitSelection( sheet ); // DrawLibItem->m_Multi;
|
|
|
|
BaseListeCmp[NbrCmp].m_PartsLocked = Entry->m_UnitSelectionLocked; |
|
|
|
BaseListeCmp[NbrCmp].m_SheetList = *sheet; |
|
|
|
BaseListeCmp[NbrCmp].m_IsNew = FALSE; |
|
|
|
BaseListeCmp[NbrCmp].m_Pos = DrawLibItem->m_Pos; |
|
|
|
BaseListeCmp[NbrCmp].m_TimeStamp = DrawLibItem->m_TimeStamp; |
|
|
|
if( DrawLibItem->GetRef( aSheet ).IsEmpty() ) |
|
|
|
DrawLibItem->SetRef( aSheet, wxT( "DefRef?" ) ); |
|
|
|
|
|
|
|
if( DrawLibItem->GetRef( sheet ).IsEmpty() ) |
|
|
|
DrawLibItem->SetRef( sheet, wxT( "DefRef?" ) ); |
|
|
|
strncpy( new_object.m_Reference, CONV_TO_UTF8( DrawLibItem->GetRef( aSheet ) ), 32 ); |
|
|
|
|
|
|
|
strncpy( BaseListeCmp[NbrCmp].m_TextRef, |
|
|
|
CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ), 32 ); |
|
|
|
new_object.m_NumRef = -1; |
|
|
|
|
|
|
|
BaseListeCmp[NbrCmp].m_NumRef = -1; |
|
|
|
if( DrawLibItem->GetField( VALUE )->m_Text.IsEmpty() ) |
|
|
|
DrawLibItem->GetField( VALUE )->m_Text = wxT( "~" ); |
|
|
|
|
|
|
|
if( DrawLibItem->GetField(VALUE)->m_Text.IsEmpty() ) |
|
|
|
DrawLibItem->GetField(VALUE)->m_Text = wxT( "~" ); |
|
|
|
new_object.m_Value = &DrawLibItem->GetField( VALUE )->m_Text; |
|
|
|
|
|
|
|
strncpy( BaseListeCmp[NbrCmp].m_TextValue, |
|
|
|
CONV_TO_UTF8( DrawLibItem->GetField(VALUE)->m_Text ), 32 ); |
|
|
|
aComponentsList.push_back( new_object ); |
|
|
|
NbrCmp++; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -399,27 +352,23 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetPath* sheet ) |
|
|
|
* Update the reference component for the schematic project (or the current |
|
|
|
* sheet) |
|
|
|
*****************************************************************************/ |
|
|
|
static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp ) |
|
|
|
static void ReAnnotateComponents( std::vector <OBJ_CMP_TO_LIST>& aComponentsList ) |
|
|
|
{ |
|
|
|
int ii; |
|
|
|
char* Text; |
|
|
|
SCH_COMPONENT* DrawLibItem; |
|
|
|
|
|
|
|
/* Reattribution des numeros */ |
|
|
|
for( ii = 0; ii < NbOfCmp; ii++ ) |
|
|
|
/* update the reference numbers */ |
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ ) |
|
|
|
{ |
|
|
|
Text = BaseListeCmp[ii].m_TextRef; |
|
|
|
DrawLibItem = BaseListeCmp[ii].m_Cmp; |
|
|
|
char* Text = aComponentsList[ii].m_Reference; |
|
|
|
SCH_COMPONENT* component = aComponentsList[ii].m_RootCmp; |
|
|
|
|
|
|
|
if( BaseListeCmp[ii].m_NumRef < 0 ) |
|
|
|
if( aComponentsList[ii].m_NumRef < 0 ) |
|
|
|
strcat( Text, "?" ); |
|
|
|
else |
|
|
|
sprintf( Text + strlen( Text ), "%d", BaseListeCmp[ii].m_NumRef ); |
|
|
|
sprintf( Text + strlen( Text ), "%d", aComponentsList[ii].m_NumRef ); |
|
|
|
|
|
|
|
DrawLibItem->SetRef( &(BaseListeCmp[ii].m_SheetList), |
|
|
|
CONV_FROM_UTF8( Text ) ); |
|
|
|
DrawLibItem->m_Multi = BaseListeCmp[ii].m_Unit; |
|
|
|
DrawLibItem->SetUnitSelection( &(BaseListeCmp[ii].m_SheetList), DrawLibItem->m_Multi ); |
|
|
|
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 ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -430,33 +379,32 @@ static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp ) |
|
|
|
* For multi part per package components not already annotated, set .m_Unit |
|
|
|
* to a max value (0x7FFFFFFF). |
|
|
|
* |
|
|
|
* @param BaseListeCmp = list of component |
|
|
|
* @param aComponentsList = list of component |
|
|
|
* @param NbOfCmp = item count in the list |
|
|
|
*****************************************************************************/ |
|
|
|
void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ) |
|
|
|
void BreakReference( std::vector <OBJ_CMP_TO_LIST>& aComponentsList ) |
|
|
|
{ |
|
|
|
int ii, ll; |
|
|
|
char* Text; |
|
|
|
|
|
|
|
for( ii = 0; ii < NbOfCmp; ii++ ) |
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ ) |
|
|
|
{ |
|
|
|
BaseListeCmp[ii].m_NumRef = -1; |
|
|
|
Text = BaseListeCmp[ii].m_TextRef; |
|
|
|
ll = strlen( Text ) - 1; |
|
|
|
aComponentsList[ii].m_NumRef = -1; |
|
|
|
Text = aComponentsList[ii].m_Reference; |
|
|
|
int ll = strlen( Text ) - 1; |
|
|
|
if( Text[ll] == '?' ) |
|
|
|
{ |
|
|
|
BaseListeCmp[ii].m_IsNew = true; |
|
|
|
if( !BaseListeCmp[ii].m_PartsLocked ) |
|
|
|
BaseListeCmp[ii].m_Unit = 0x7FFFFFFF; |
|
|
|
aComponentsList[ii].m_IsNew = true; |
|
|
|
if( !aComponentsList[ii].IsPartsLocked() ) |
|
|
|
aComponentsList[ii].m_Unit = 0x7FFFFFFF; |
|
|
|
Text[ll] = 0; |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if( isdigit( Text[ll] ) == 0 ) |
|
|
|
{ |
|
|
|
BaseListeCmp[ii].m_IsNew = true; |
|
|
|
if( !BaseListeCmp[ii].m_PartsLocked ) |
|
|
|
BaseListeCmp[ii].m_Unit = 0x7FFFFFFF; |
|
|
|
aComponentsList[ii].m_IsNew = true; |
|
|
|
if( !aComponentsList[ii].IsPartsLocked() ) |
|
|
|
aComponentsList[ii].m_Unit = 0x7FFFFFFF; |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
@ -467,7 +415,7 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ) |
|
|
|
else |
|
|
|
{ |
|
|
|
if( isdigit( Text[ll + 1] ) ) |
|
|
|
BaseListeCmp[ii].m_NumRef = atoi( &Text[ll + 1] ); |
|
|
|
aComponentsList[ii].m_NumRef = atoi( &Text[ll + 1] ); |
|
|
|
Text[ll + 1] = 0; |
|
|
|
break; |
|
|
|
} |
|
|
|
@ -480,103 +428,99 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ) |
|
|
|
* Compute the reference number for components without reference number |
|
|
|
* Compute .m_NumRef member |
|
|
|
*****************************************************************************/ |
|
|
|
static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ) |
|
|
|
static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsList ) |
|
|
|
{ |
|
|
|
int ii, jj, LastReferenceNumber, NumberOfUnits, Unit; |
|
|
|
const char* Text, * RefText, * ValText; |
|
|
|
CmpListStruct* ObjRef, * ObjToTest; |
|
|
|
int LastReferenceNumber, NumberOfUnits, Unit; |
|
|
|
|
|
|
|
/* Components with an invisible reference (power...) always are
|
|
|
|
* re-annotated */ |
|
|
|
for( ii = 0; ii < NbOfCmp; ii++ ) |
|
|
|
/* Components with an invisible reference (power...) always are re-annotated.
|
|
|
|
* So set theirs .m_IsNew member to true |
|
|
|
*/ |
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ ) |
|
|
|
{ |
|
|
|
Text = BaseListeCmp[ii].m_TextRef; |
|
|
|
if( *Text == '#' ) |
|
|
|
if( aComponentsList[ii].m_Reference[0] == '#' ) |
|
|
|
{ |
|
|
|
BaseListeCmp[ii].m_IsNew = true; |
|
|
|
BaseListeCmp[ii].m_NumRef = 0; |
|
|
|
aComponentsList[ii].m_IsNew = true; |
|
|
|
aComponentsList[ii].m_NumRef = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ValText = RefText = ""; LastReferenceNumber = 1; |
|
|
|
for( ii = 0; ii < NbOfCmp; ii++ ) |
|
|
|
/* 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 ... |
|
|
|
*/ |
|
|
|
unsigned first = 0; |
|
|
|
/* calculate the last used number for this reference prefix: */ |
|
|
|
LastReferenceNumber = GetLastReferenceNumber( first, aComponentsList ); |
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ ) |
|
|
|
{ |
|
|
|
ObjRef = &BaseListeCmp[ii]; |
|
|
|
if( BaseListeCmp[ii].m_Flag ) |
|
|
|
if( aComponentsList[ii].m_Flag ) |
|
|
|
continue; |
|
|
|
|
|
|
|
Text = BaseListeCmp[ii].m_TextRef; |
|
|
|
if( strnicmp( RefText, Text, 32 ) != 0 ) /* Nouveau Identificateur */ |
|
|
|
if( aComponentsList[first].CompareRef( aComponentsList[ii] ) != 0 ) /* New reference found: we need a new ref number for this reference */ |
|
|
|
{ |
|
|
|
RefText = BaseListeCmp[ii].m_TextRef; |
|
|
|
LastReferenceNumber = GetLastReferenceNumber( BaseListeCmp + ii, |
|
|
|
BaseListeCmp, |
|
|
|
NbOfCmp ); |
|
|
|
first = ii; |
|
|
|
LastReferenceNumber = GetLastReferenceNumber( ii, aComponentsList ); |
|
|
|
} |
|
|
|
|
|
|
|
/* Annotation of one part per package components (trivial case)*/ |
|
|
|
if( BaseListeCmp[ii].m_NbParts <= 1 ) |
|
|
|
if( aComponentsList[ii].m_Entry->m_UnitCount <= 1 ) |
|
|
|
{ |
|
|
|
if( BaseListeCmp[ii].m_IsNew ) |
|
|
|
if( aComponentsList[ii].m_IsNew ) |
|
|
|
{ |
|
|
|
LastReferenceNumber++; |
|
|
|
BaseListeCmp[ii].m_NumRef = LastReferenceNumber; |
|
|
|
aComponentsList[ii].m_NumRef = LastReferenceNumber; |
|
|
|
} |
|
|
|
BaseListeCmp[ii].m_Unit = 1; |
|
|
|
BaseListeCmp[ii].m_Flag = 1; |
|
|
|
BaseListeCmp[ii].m_IsNew = FALSE; |
|
|
|
aComponentsList[ii].m_Unit = 1; |
|
|
|
aComponentsList[ii].m_Flag = 1; |
|
|
|
aComponentsList[ii].m_IsNew = false; |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
/* Annotation of multi-part components ( n parts per package )
|
|
|
|
* (complex case) */ |
|
|
|
ValText = BaseListeCmp[ii].m_TextValue; |
|
|
|
NumberOfUnits = BaseListeCmp[ii].m_NbParts; |
|
|
|
NumberOfUnits = aComponentsList[ii].m_Entry->m_UnitCount; |
|
|
|
|
|
|
|
if( BaseListeCmp[ii].m_IsNew ) |
|
|
|
if( aComponentsList[ii].m_IsNew ) |
|
|
|
{ |
|
|
|
LastReferenceNumber++; |
|
|
|
BaseListeCmp[ii].m_NumRef = LastReferenceNumber; |
|
|
|
aComponentsList[ii].m_NumRef = LastReferenceNumber; |
|
|
|
|
|
|
|
if( !BaseListeCmp[ii].m_PartsLocked ) |
|
|
|
BaseListeCmp[ii].m_Unit = 1; |
|
|
|
BaseListeCmp[ii].m_Flag = 1; |
|
|
|
if( !aComponentsList[ii].IsPartsLocked() ) |
|
|
|
aComponentsList[ii].m_Unit = 1; |
|
|
|
aComponentsList[ii].m_Flag = 1; |
|
|
|
} |
|
|
|
|
|
|
|
/* 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) |
|
|
|
*/ |
|
|
|
for( Unit = 1; Unit <= NumberOfUnits; Unit++ ) |
|
|
|
{ |
|
|
|
if( BaseListeCmp[ii].m_Unit == Unit ) |
|
|
|
if( aComponentsList[ii].m_Unit == Unit ) |
|
|
|
continue; |
|
|
|
jj = ExistUnit( BaseListeCmp + ii, Unit, BaseListeCmp, NbOfCmp ); |
|
|
|
if( jj >= 0 ) |
|
|
|
continue; /* Unit exists for this reference */ |
|
|
|
int found = ExistUnit( ii, Unit, aComponentsList ); |
|
|
|
if( found >= 0 ) |
|
|
|
continue; /* this unit exists for this reference (unit already annotated) */ |
|
|
|
|
|
|
|
/* Search a component to annotate ( same prefix, same value) */ |
|
|
|
for( jj = ii + 1; jj < NbOfCmp; jj++ ) |
|
|
|
/* Search a component to annotate ( same prefix, same value, not annotated) */ |
|
|
|
for( unsigned jj = ii + 1; jj < aComponentsList.size(); jj++ ) |
|
|
|
{ |
|
|
|
ObjToTest = &BaseListeCmp[jj]; |
|
|
|
if( BaseListeCmp[jj].m_Flag ) |
|
|
|
if( aComponentsList[jj].m_Flag ) // already tested
|
|
|
|
continue; |
|
|
|
|
|
|
|
if( aComponentsList[ii].CompareRef( aComponentsList[jj] ) != 0 ) // references are different
|
|
|
|
continue; |
|
|
|
Text = BaseListeCmp[jj].m_TextRef; |
|
|
|
if( strnicmp( RefText, Text, 32 ) != 0 ) |
|
|
|
continue; // references are different
|
|
|
|
Text = BaseListeCmp[jj].m_TextValue; |
|
|
|
if( strnicmp( ValText, Text, 32 ) != 0 ) |
|
|
|
if( aComponentsList[jj].CompareValue( aComponentsList[ii] ) != 0 ) |
|
|
|
continue; // values are different
|
|
|
|
if( !BaseListeCmp[jj].m_IsNew ) |
|
|
|
{ |
|
|
|
if( !aComponentsList[jj].m_IsNew ) |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
/* Component without reference number found, annotate it if
|
|
|
|
* possible */ |
|
|
|
if( !BaseListeCmp[jj].m_PartsLocked |
|
|
|
|| (BaseListeCmp[jj].m_Unit == Unit) ) |
|
|
|
/* Component without reference number found, annotate it if possible */ |
|
|
|
if( !aComponentsList[jj].IsPartsLocked() || (aComponentsList[jj].m_Unit == Unit) ) |
|
|
|
{ |
|
|
|
BaseListeCmp[jj].m_NumRef = BaseListeCmp[ii].m_NumRef; |
|
|
|
BaseListeCmp[jj].m_Unit = Unit; |
|
|
|
BaseListeCmp[jj].m_Flag = 1; |
|
|
|
BaseListeCmp[jj].m_IsNew = FALSE; |
|
|
|
aComponentsList[jj].m_NumRef = aComponentsList[ii].m_NumRef; |
|
|
|
aComponentsList[jj].m_Unit = Unit; |
|
|
|
aComponentsList[jj].m_Flag = 1; |
|
|
|
aComponentsList[jj].m_IsNew = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -590,26 +534,20 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ) |
|
|
|
* 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 |
|
|
|
* @param aObjet = reference item ( aComponentsList[aObjet].m_TextRef is the search pattern) |
|
|
|
* @param aComponentsList = list of items |
|
|
|
*****************************************************************************/ |
|
|
|
int GetLastReferenceNumber( CmpListStruct* Objet, |
|
|
|
CmpListStruct* BaseListeCmp, |
|
|
|
int NbOfCmp ) |
|
|
|
int GetLastReferenceNumber( int aObjet, std::vector <OBJ_CMP_TO_LIST>& aComponentsList ) |
|
|
|
{ |
|
|
|
CmpListStruct* LastObjet = BaseListeCmp + NbOfCmp; |
|
|
|
int LastNumber = 0; |
|
|
|
const char* RefText; |
|
|
|
int LastNumber = 0; |
|
|
|
|
|
|
|
RefText = Objet->m_TextRef; |
|
|
|
for( ; Objet < LastObjet; Objet++ ) |
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ ) |
|
|
|
{ |
|
|
|
/* Nouveau Identificateur */ |
|
|
|
if( strnicmp( RefText, Objet->m_TextRef, 32 ) != 0 ) |
|
|
|
break; |
|
|
|
if( LastNumber < Objet->m_NumRef ) |
|
|
|
LastNumber = Objet->m_NumRef; |
|
|
|
if( aComponentsList[aObjet].CompareRef( aComponentsList[ii] ) != 0 ) |
|
|
|
continue; |
|
|
|
if( LastNumber < aComponentsList[ii].m_NumRef ) |
|
|
|
LastNumber = aComponentsList[ii].m_NumRef; |
|
|
|
} |
|
|
|
|
|
|
|
return LastNumber; |
|
|
|
@ -620,36 +558,28 @@ int GetLastReferenceNumber( CmpListStruct* Objet, |
|
|
|
* 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 Objet = the given CmpListStruct* item to test |
|
|
|
* @param aObjet = index in aComponentsList for the given OBJ_CMP_TO_LIST item to test |
|
|
|
* @param Unit = the given unit number to search |
|
|
|
* @param BaseListeCmp = list of items to examine |
|
|
|
* @param NbOfCmp = size of list |
|
|
|
* @return index in BaseListeCmp if found or -1 if not found |
|
|
|
* @param aComponentsList = list of items to examine |
|
|
|
* @return index in aComponentsList if found or -1 if not found |
|
|
|
*****************************************************************************/ |
|
|
|
static int ExistUnit( CmpListStruct* Objet, int Unit, |
|
|
|
CmpListStruct* BaseListeCmp, int NbOfCmp ) |
|
|
|
static int ExistUnit( int aObjet, int Unit, |
|
|
|
std::vector <OBJ_CMP_TO_LIST>& aComponentsList ) |
|
|
|
{ |
|
|
|
CmpListStruct* EndList = BaseListeCmp + NbOfCmp; |
|
|
|
char* RefText, * ValText; |
|
|
|
int NumRef, ii; |
|
|
|
CmpListStruct* ItemToTest; |
|
|
|
|
|
|
|
RefText = Objet->m_TextRef; |
|
|
|
ValText = Objet->m_TextValue; |
|
|
|
NumRef = Objet->m_NumRef; |
|
|
|
for( ItemToTest = BaseListeCmp, ii = 0; |
|
|
|
ItemToTest < EndList; |
|
|
|
ItemToTest++, ii++ ) |
|
|
|
int NumRef; |
|
|
|
|
|
|
|
NumRef = aComponentsList[aObjet].m_NumRef; |
|
|
|
for( unsigned ii = 0; ii < aComponentsList.size(); ii++ ) |
|
|
|
{ |
|
|
|
if( Objet == ItemToTest ) // Do not compare with itself !
|
|
|
|
if( aObjet == (int) ii ) // Do not compare with itself !
|
|
|
|
continue; |
|
|
|
if( ItemToTest->m_IsNew ) // Not already with an updated reference
|
|
|
|
if( aComponentsList[ii].m_IsNew ) // Not already with an updated reference
|
|
|
|
continue; |
|
|
|
if( ItemToTest->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( strnicmp( RefText, ItemToTest->m_TextRef, 32 ) != 0 ) // Not the same reference prefix
|
|
|
|
if( aComponentsList[aObjet].CompareRef( aComponentsList[ii] ) != 0 ) // Not the same reference prefix
|
|
|
|
continue; |
|
|
|
if( ItemToTest->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; |
|
|
|
} |
|
|
|
@ -659,109 +589,87 @@ static int ExistUnit( CmpListStruct* Objet, int Unit, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* |
|
|
|
* Function CheckAnnotate |
|
|
|
* @return component 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 CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly ) |
|
|
|
/*******************************************************************/ |
|
|
|
|
|
|
|
/**
|
|
|
|
* Function CheckAnnotate |
|
|
|
* @return component 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 ii, error, NbOfCmp; |
|
|
|
DrawSheetPath* sheet; |
|
|
|
CmpListStruct* ListeCmp = NULL; |
|
|
|
wxString Buff; |
|
|
|
wxString msg, cmpref; |
|
|
|
int error; |
|
|
|
wxString Buff; |
|
|
|
wxString msg, cmpref; |
|
|
|
|
|
|
|
/* build the screen list */ |
|
|
|
EDA_SheetList SheetList( NULL ); |
|
|
|
EDA_SheetList SheetList( NULL ); |
|
|
|
|
|
|
|
g_RootSheet->m_AssociatedScreen->SetModify(); |
|
|
|
ii = 0; |
|
|
|
std::vector <OBJ_CMP_TO_LIST> ComponentsList; |
|
|
|
|
|
|
|
/* first pass : count composents */ |
|
|
|
if( !oneSheetOnly ) |
|
|
|
{ |
|
|
|
NbOfCmp = 0; |
|
|
|
for( sheet = SheetList.GetFirst(); |
|
|
|
sheet != NULL; |
|
|
|
sheet = SheetList.GetNext() ) |
|
|
|
NbOfCmp += ListeComposants( NULL, sheet ); |
|
|
|
} |
|
|
|
else |
|
|
|
NbOfCmp = ListeComposants( NULL, frame->GetSheet() ); |
|
|
|
|
|
|
|
if( NbOfCmp == 0 ) |
|
|
|
{ |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Second pass : create the list of components */ |
|
|
|
ListeCmp = (CmpListStruct*) MyZMalloc( NbOfCmp * sizeof(CmpListStruct) ); |
|
|
|
g_RootSheet->m_AssociatedScreen->SetModify(); |
|
|
|
|
|
|
|
/* Build the list of components */ |
|
|
|
if( !oneSheetOnly ) |
|
|
|
{ |
|
|
|
ii = 0; |
|
|
|
for( sheet = SheetList.GetFirst(); |
|
|
|
sheet != NULL; |
|
|
|
sheet = SheetList.GetNext() ) |
|
|
|
ii += ListeComposants( ListeCmp + ii, sheet ); |
|
|
|
DrawSheetPath* sheet; |
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) |
|
|
|
AddComponentsInSheetToList( ComponentsList, sheet ); |
|
|
|
} |
|
|
|
else |
|
|
|
ListeComposants( ListeCmp, frame->GetSheet() ); |
|
|
|
AddComponentsInSheetToList( ComponentsList, frame->GetSheet() ); |
|
|
|
|
|
|
|
qsort( ListeCmp, NbOfCmp, sizeof(CmpListStruct), AnnotateByValue ); |
|
|
|
sort( ComponentsList.begin(), ComponentsList.end(), AnnotateByValue ); |
|
|
|
|
|
|
|
/* Break full components reference in name (prefix) and number: example:
|
|
|
|
* IC1 become IC, and 1 */ |
|
|
|
BreakReference( ListeCmp, NbOfCmp ); |
|
|
|
BreakReference( ComponentsList ); |
|
|
|
|
|
|
|
/* count not yet annotated items */ |
|
|
|
error = 0; |
|
|
|
for( ii = 0; ii < NbOfCmp - 1; ii++ ) |
|
|
|
int imax = ComponentsList.size() - 1; |
|
|
|
for( int ii = 0; ii < imax; ii++ ) |
|
|
|
{ |
|
|
|
msg.Empty(); |
|
|
|
Buff.Empty(); |
|
|
|
|
|
|
|
if( ListeCmp[ii].m_IsNew ) |
|
|
|
if( ComponentsList[ii].m_IsNew ) |
|
|
|
{ |
|
|
|
if( ListeCmp[ii].m_NumRef >= 0 ) |
|
|
|
Buff << ListeCmp[ii].m_NumRef; |
|
|
|
if( ComponentsList[ii].m_NumRef >= 0 ) |
|
|
|
Buff << ComponentsList[ii].m_NumRef; |
|
|
|
else |
|
|
|
Buff = wxT( "?" ); |
|
|
|
|
|
|
|
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); |
|
|
|
cmpref = CONV_FROM_UTF8( ComponentsList[ii].m_Reference ); |
|
|
|
msg.Printf( _( "item not annotated: %s%s" ), |
|
|
|
cmpref.GetData(), Buff.GetData() ); |
|
|
|
|
|
|
|
if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) ) |
|
|
|
if( (ComponentsList[ii].m_Unit > 0) && (ComponentsList[ii].m_Unit < 0x7FFFFFFF) ) |
|
|
|
{ |
|
|
|
Buff.Printf( _( "( unit %d)" ), ListeCmp[ii].m_Unit ); |
|
|
|
Buff.Printf( _( "( unit %d)" ), ComponentsList[ii].m_Unit ); |
|
|
|
msg << Buff; |
|
|
|
} |
|
|
|
DisplayError( NULL, msg ); |
|
|
|
DisplayError( frame, msg ); |
|
|
|
error++; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
// Annotate error
|
|
|
|
if( MAX( ListeCmp[ii].m_NbParts, 1 ) < ListeCmp[ii].m_Unit ) |
|
|
|
if( MAX( ComponentsList[ii].m_Entry->m_UnitCount, 1 ) < ComponentsList[ii].m_Unit ) |
|
|
|
{ |
|
|
|
if( ListeCmp[ii].m_NumRef >= 0 ) |
|
|
|
Buff << ListeCmp[ii].m_NumRef; |
|
|
|
if( ComponentsList[ii].m_NumRef >= 0 ) |
|
|
|
Buff << ComponentsList[ii].m_NumRef; |
|
|
|
else |
|
|
|
Buff = wxT( "?" ); |
|
|
|
|
|
|
|
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); |
|
|
|
cmpref = CONV_FROM_UTF8( ComponentsList[ii].m_Reference ); |
|
|
|
msg.Printf( _( "Error item %s%s" ), cmpref.GetData(), |
|
|
|
Buff.GetData() ); |
|
|
|
|
|
|
|
Buff.Printf( _( " unit %d and no more than %d parts" ), |
|
|
|
ListeCmp[ii].m_Unit, ListeCmp[ii].m_NbParts ); |
|
|
|
ComponentsList[ii].m_Unit, ComponentsList[ii].m_Entry->m_UnitCount ); |
|
|
|
msg << Buff; |
|
|
|
DisplayError( frame, msg ); |
|
|
|
error++; |
|
|
|
@ -773,33 +681,31 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly ) |
|
|
|
return error; |
|
|
|
|
|
|
|
// count the duplicated elements (if all are annotated)
|
|
|
|
for( ii = 0; (ii < NbOfCmp - 1) && (error < 4); ii++ ) |
|
|
|
for( int ii = 0; (ii < imax) && (error < 4); ii++ ) |
|
|
|
{ |
|
|
|
msg.Empty(); |
|
|
|
Buff.Empty(); |
|
|
|
|
|
|
|
if( (stricmp( ListeCmp[ii].m_TextRef, |
|
|
|
ListeCmp[ii + 1].m_TextRef ) != 0) |
|
|
|
|| ( ListeCmp[ii].m_NumRef != ListeCmp[ii + 1].m_NumRef ) ) |
|
|
|
if( (ComponentsList[ii].CompareRef(ComponentsList[ii + 1]) != 0) |
|
|
|
|| ( ComponentsList[ii].m_NumRef != ComponentsList[ii + 1].m_NumRef ) ) |
|
|
|
continue; |
|
|
|
|
|
|
|
/* Same reference found */ |
|
|
|
|
|
|
|
/* If same unit, error ! */ |
|
|
|
if( ListeCmp[ii].m_Unit == ListeCmp[ii + 1].m_Unit ) |
|
|
|
/* Same reference found. If same unit, error !
|
|
|
|
*/ |
|
|
|
if( ComponentsList[ii].m_Unit == ComponentsList[ii + 1].m_Unit ) |
|
|
|
{ |
|
|
|
if( ListeCmp[ii].m_NumRef >= 0 ) |
|
|
|
Buff << ListeCmp[ii].m_NumRef; |
|
|
|
if( ComponentsList[ii].m_NumRef >= 0 ) |
|
|
|
Buff << ComponentsList[ii].m_NumRef; |
|
|
|
else |
|
|
|
Buff = wxT( "?" ); |
|
|
|
|
|
|
|
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); |
|
|
|
cmpref = CONV_FROM_UTF8( ComponentsList[ii].m_Reference ); |
|
|
|
msg.Printf( _( "Multiple item %s%s" ), |
|
|
|
cmpref.GetData(), Buff.GetData() ); |
|
|
|
|
|
|
|
if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) ) |
|
|
|
if( (ComponentsList[ii].m_Unit > 0) && (ComponentsList[ii].m_Unit < 0x7FFFFFFF) ) |
|
|
|
{ |
|
|
|
Buff.Printf( _( " (unit %d)" ), ListeCmp[ii].m_Unit ); |
|
|
|
Buff.Printf( _( " (unit %d)" ), ComponentsList[ii].m_Unit ); |
|
|
|
msg << Buff; |
|
|
|
} |
|
|
|
DisplayError( frame, msg ); |
|
|
|
@ -808,21 +714,21 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly ) |
|
|
|
} |
|
|
|
|
|
|
|
/* Test error if units are different but number of parts per package
|
|
|
|
* too hight (ex U3 ( 1 part) and we find U3B the is an error) */ |
|
|
|
if( ListeCmp[ii].m_NbParts != ListeCmp[ii + 1].m_NbParts ) |
|
|
|
* too hight (ex U3 ( 1 part) and we find U3B this is an error) */ |
|
|
|
if( ComponentsList[ii].m_Entry->m_UnitCount != ComponentsList[ii + 1].m_Entry->m_UnitCount ) |
|
|
|
{ |
|
|
|
if( ListeCmp[ii].m_NumRef >= 0 ) |
|
|
|
Buff << ListeCmp[ii].m_NumRef; |
|
|
|
if( ComponentsList[ii].m_NumRef >= 0 ) |
|
|
|
Buff << ComponentsList[ii].m_NumRef; |
|
|
|
else |
|
|
|
Buff = wxT( "?" ); |
|
|
|
|
|
|
|
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); |
|
|
|
cmpref = CONV_FROM_UTF8( ComponentsList[ii].m_Reference ); |
|
|
|
msg.Printf( _( "Multiple item %s%s" ), |
|
|
|
cmpref.GetData(), Buff.GetData() ); |
|
|
|
|
|
|
|
if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) ) |
|
|
|
if( (ComponentsList[ii].m_Unit > 0) && (ComponentsList[ii].m_Unit < 0x7FFFFFFF) ) |
|
|
|
{ |
|
|
|
Buff.Printf( _( " (unit %d)" ), ListeCmp[ii].m_Unit ); |
|
|
|
Buff.Printf( _( " (unit %d)" ), ComponentsList[ii].m_Unit ); |
|
|
|
msg << Buff; |
|
|
|
} |
|
|
|
|
|
|
|
@ -831,32 +737,30 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly ) |
|
|
|
} |
|
|
|
|
|
|
|
/* Error if values are different between units, for the same reference */ |
|
|
|
if( stricmp( ListeCmp[ii].m_TextValue, |
|
|
|
ListeCmp[ii + 1].m_TextValue ) != 0 ) |
|
|
|
int next = ii+1; |
|
|
|
if( ComponentsList[ii].CompareValue( ComponentsList[next] ) != 0 ) |
|
|
|
{ |
|
|
|
wxString nextcmpref, cmpvalue, nextcmpvalue; |
|
|
|
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); |
|
|
|
nextcmpref = CONV_FROM_UTF8( ListeCmp[ii + 1].m_TextRef ); |
|
|
|
cmpvalue = CONV_FROM_UTF8( ListeCmp[ii].m_TextValue ); |
|
|
|
nextcmpvalue = CONV_FROM_UTF8( ListeCmp[ii + 1].m_TextValue ); |
|
|
|
#if defined(KICAD_GOST)
|
|
|
|
wxString nextcmpref; |
|
|
|
cmpref = CONV_FROM_UTF8( ComponentsList[ii].m_Reference ); |
|
|
|
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(), |
|
|
|
ListeCmp[ii].m_NumRef, |
|
|
|
ListeCmp[ii].m_Unit + '1' - 1, |
|
|
|
cmpvalue.GetData(), nextcmpref.GetData(), |
|
|
|
ListeCmp[ii + 1].m_NumRef, |
|
|
|
ListeCmp[ii + 1].m_Unit + '1' - 1, |
|
|
|
nextcmpvalue.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(), |
|
|
|
ListeCmp[ii].m_NumRef, |
|
|
|
ListeCmp[ii].m_Unit + 'A' - 1, |
|
|
|
cmpvalue.GetData(), nextcmpref.GetData(), |
|
|
|
ListeCmp[ii + 1].m_NumRef, |
|
|
|
ListeCmp[ii + 1].m_Unit + 'A' - 1, |
|
|
|
nextcmpvalue.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
|
|
|
|
|
|
|
|
DisplayError( frame, msg ); |
|
|
|
@ -864,6 +768,5 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
MyFree( ListeCmp ); |
|
|
|
return error; |
|
|
|
} |