Commit ff193f18 authored by dickelbeck's avatar dickelbeck

variable number of fields per schematic component

parent 22c50612
add_definitions(-DEESCHEMA) add_definitions(-DEESCHEMA)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}
# ${Boost_INCLUDE_DIR}
)
set(EESCHEMA_SRCS set(EESCHEMA_SRCS
affiche.cpp affiche.cpp
......
...@@ -41,7 +41,8 @@ void SCH_COMPONENT::Display_Infos( WinEDA_DrawFrame* frame ) ...@@ -41,7 +41,8 @@ void SCH_COMPONENT::Display_Infos( WinEDA_DrawFrame* frame )
msg = _( "Pwr Symb" ); msg = _( "Pwr Symb" );
else else
msg = _( "Val" ); msg = _( "Val" );
Affiche_1_Parametre( frame, 10, msg, m_Field[VALUE].m_Text, DARKCYAN );
Affiche_1_Parametre( frame, 10, msg, GetField(VALUE)->m_Text, DARKCYAN );
Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN ); Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN );
......
...@@ -382,11 +382,11 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetPath* sheet ) ...@@ -382,11 +382,11 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetPath* sheet )
BaseListeCmp[NbrCmp].m_NumRef = -1; BaseListeCmp[NbrCmp].m_NumRef = -1;
if( DrawLibItem->m_Field[VALUE].m_Text.IsEmpty() ) if( DrawLibItem->GetField(VALUE)->m_Text.IsEmpty() )
DrawLibItem->m_Field[VALUE].m_Text = wxT( "~" ); DrawLibItem->GetField(VALUE)->m_Text = wxT( "~" );
strncpy( BaseListeCmp[NbrCmp].m_TextValue, strncpy( BaseListeCmp[NbrCmp].m_TextValue,
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ), 32 ); CONV_TO_UTF8( DrawLibItem->GetField(VALUE)->m_Text ), 32 );
NbrCmp++; NbrCmp++;
} }
} }
......
...@@ -48,22 +48,23 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent( ...@@ -48,22 +48,23 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent(
Cmp = (SCH_COMPONENT*) DrawList; Cmp = (SCH_COMPONENT*) DrawList;
if( aReference.CmpNoCase( Cmp->GetRef( sheet ) ) == 0 ) if( aReference.CmpNoCase( Cmp->GetRef( sheet ) ) == 0 )
{ // Found: Init Footprint Field {
// Found: Init Footprint Field
/* Give a reasonnable value to the fied position and orientation, if /* Give a reasonnable value to the fied position and orientation, if
* the text is empty at position 0, because it is probably not yet initialised * the text is empty at position 0, because it is probably not yet initialised
*/ */
if( Cmp->m_Field[FOOTPRINT].m_Text.IsEmpty() if( Cmp->GetField(FOOTPRINT)->m_Text.IsEmpty()
&& ( Cmp->m_Field[FOOTPRINT].m_Pos == wxPoint( 0, 0 ) ) ) && ( Cmp->GetField(FOOTPRINT)->m_Pos == wxPoint( 0, 0 ) ) )
{ {
Cmp->m_Field[FOOTPRINT].m_Orient = Cmp->m_Field[VALUE].m_Orient; Cmp->GetField(FOOTPRINT)->m_Orient = Cmp->GetField(VALUE)->m_Orient;
Cmp->m_Field[FOOTPRINT].m_Pos = Cmp->m_Field[VALUE].m_Pos; Cmp->GetField(FOOTPRINT)->m_Pos = Cmp->GetField(VALUE)->m_Pos;
Cmp->m_Field[FOOTPRINT].m_Pos.y -= 100; Cmp->GetField(FOOTPRINT)->m_Pos.y -= 100;
} }
Cmp->m_Field[FOOTPRINT].m_Text = aFootPrint; Cmp->GetField(FOOTPRINT)->m_Text = aFootPrint;
if( aSetVisible ) if( aSetVisible )
Cmp->m_Field[FOOTPRINT].m_Attributs &= ~TEXT_NO_VISIBLE; Cmp->GetField(FOOTPRINT)->m_Attributs &= ~TEXT_NO_VISIBLE;
else else
Cmp->m_Field[FOOTPRINT].m_Attributs |= TEXT_NO_VISIBLE; Cmp->GetField(FOOTPRINT)->m_Attributs |= TEXT_NO_VISIBLE;
found = true; found = true;
} }
} }
......
...@@ -711,11 +711,12 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center ) ...@@ -711,11 +711,12 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
NULL, CMP_MIROIR_Y ); NULL, CMP_MIROIR_Y );
MirrorYPoint( DrawLibItem->m_Pos, Center ); MirrorYPoint( DrawLibItem->m_Pos, Center );
dx -= DrawLibItem->m_Pos.x; dx -= DrawLibItem->m_Pos.x;
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
{ /* move the fields to the new position because the component itself has moved */
DrawLibItem->m_Field[ii].m_Pos.x -= dx;
}
for( ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
{
/* move the fields to the new position because the component itself has moved */
DrawLibItem->GetField(ii)->m_Pos.x -= dx;
}
break; break;
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
...@@ -1232,9 +1233,9 @@ void MoveOneStruct( SCH_ITEM * DrawStruct, const wxPoint& move_vector ) ...@@ -1232,9 +1233,9 @@ void MoveOneStruct( SCH_ITEM * DrawStruct, const wxPoint& move_vector )
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawStruct; DrawLibItem = (SCH_COMPONENT*) DrawStruct;
DrawLibItem->m_Pos += move_vector; DrawLibItem->m_Pos += move_vector;
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) for( ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
{ {
DrawLibItem->m_Field[ii].m_Pos += move_vector; DrawLibItem->GetField(ii)->m_Pos += move_vector;
} }
break; break;
......
...@@ -420,8 +420,8 @@ static int ListTriComposantByVal( ListComponent* obj1, ...@@ -420,8 +420,8 @@ static int ListTriComposantByVal( ListComponent* obj1,
if( obj2->m_Comp == NULL ) if( obj2->m_Comp == NULL )
return 1; return 1;
Text1 = &(obj1->m_Comp->m_Field[VALUE].m_Text); Text1 = &(obj1->m_Comp->GetField(VALUE)->m_Text);
Text2 = &(obj2->m_Comp->m_Field[VALUE].m_Text); Text2 = &(obj2->m_Comp->GetField(VALUE)->m_Text);
ii = Text1->CmpNoCase( *Text2 ); ii = Text1->CmpNoCase( *Text2 );
if( ii == 0 ) if( ii == 0 )
...@@ -471,8 +471,8 @@ static int ListTriComposantByRef( ListComponent* obj1, ...@@ -471,8 +471,8 @@ static int ListTriComposantByRef( ListComponent* obj1,
if( ii == 0 ) if( ii == 0 )
{ {
Text1 = &( obj1->m_Comp->m_Field[VALUE].m_Text ); Text1 = &( obj1->m_Comp->GetField(VALUE)->m_Text );
Text2 = &( obj2->m_Comp->m_Field[VALUE].m_Text ); Text2 = &( obj2->m_Comp->GetField(VALUE)->m_Text );
ii = Text1->CmpNoCase( *Text2 ); ii = Text1->CmpNoCase( *Text2 );
} }
...@@ -594,7 +594,8 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem ...@@ -594,7 +594,8 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem
bool CompactForm ) bool CompactForm )
/*******************************************************************************************/ /*******************************************************************************************/
{ {
const wxCheckBox* FieldListCtrl[] = { // @todo make this variable length
static const wxCheckBox* FieldListCtrl[] = {
m_AddField1, m_AddField1,
m_AddField2, m_AddField2,
m_AddField3, m_AddField3,
...@@ -613,24 +614,26 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem ...@@ -613,24 +614,26 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem
if( CompactForm ) if( CompactForm )
{ {
fprintf( f, "%c%s", s_ExportSeparatorSymbol, fprintf( f, "%c%s", s_ExportSeparatorSymbol,
CONV_TO_UTF8( DrawLibItem->m_Field[FOOTPRINT].m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField(FOOTPRINT)->m_Text ) );
} }
else else
fprintf( f, "; %-12s", CONV_TO_UTF8( DrawLibItem->m_Field[FOOTPRINT].m_Text ) ); fprintf( f, "; %-12s", CONV_TO_UTF8( DrawLibItem->GetField(FOOTPRINT)->m_Text ) );
} }
for( ii = FIELD1; ii <= FIELD8; ii++ ) for( ii = FIELD1; ii < DrawLibItem->GetFieldCount(); ii++ )
{ {
FieldCtrl = FieldListCtrl[ii - FIELD1]; FieldCtrl = FieldListCtrl[ii - FIELD1];
if( FieldCtrl == NULL ) if( FieldCtrl == NULL )
continue; continue;
if( !FieldCtrl->IsChecked() ) if( !FieldCtrl->IsChecked() )
continue; continue;
if( CompactForm ) if( CompactForm )
fprintf( f, "%c%s", s_ExportSeparatorSymbol, fprintf( f, "%c%s", s_ExportSeparatorSymbol,
CONV_TO_UTF8( DrawLibItem->m_Field[ii].m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField(ii)->m_Text ) );
else else
fprintf( f, "; %-12s", CONV_TO_UTF8( DrawLibItem->m_Field[ii].m_Text ) ); fprintf( f, "; %-12s", CONV_TO_UTF8( DrawLibItem->GetField(ii)->m_Text ) );
} }
} }
...@@ -655,7 +658,8 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ...@@ -655,7 +658,8 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f,
if( CompactForm ) if( CompactForm )
{ {
const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] = { // @todo make this variable length
static const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] = {
m_AddField1, m_AddField1,
m_AddField2, m_AddField2,
m_AddField3, m_AddField3,
...@@ -673,7 +677,6 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ...@@ -673,7 +677,6 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f,
{ {
fprintf( f, "%csheet path", s_ExportSeparatorSymbol ); fprintf( f, "%csheet path", s_ExportSeparatorSymbol );
fprintf( f, "%clocation", s_ExportSeparatorSymbol ); fprintf( f, "%clocation", s_ExportSeparatorSymbol );
} }
if( m_AddFootprintField->IsChecked() ) if( m_AddFootprintField->IsChecked() )
...@@ -732,10 +735,10 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, ...@@ -732,10 +735,10 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f,
if( CompactForm ) if( CompactForm )
fprintf( f, "%s%c%s", CmpName, s_ExportSeparatorSymbol, fprintf( f, "%s%c%s", CmpName, s_ExportSeparatorSymbol,
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField(VALUE)->m_Text ) );
else else
fprintf( f, "| %-10s %-12s", CmpName, fprintf( f, "| %-10s %-12s", CmpName,
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField(VALUE)->m_Text ) );
if( aIncludeSubComponents ) if( aIncludeSubComponents )
{ {
...@@ -816,7 +819,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, ...@@ -816,7 +819,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f,
} }
sprintf( CmpName, "%s%c", aList[ii].m_Ref, Unit ); sprintf( CmpName, "%s%c", aList[ii].m_Ref, Unit );
fprintf( f, "| %-12s %-10s", CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ), CmpName ); fprintf( f, "| %-12s %-10s", CONV_TO_UTF8( DrawLibItem->GetField(VALUE)->m_Text ), CmpName );
// print the sheet path // print the sheet path
if( aIncludeSubComponents ) if( aIncludeSubComponents )
......
...@@ -625,24 +625,24 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -625,24 +625,24 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
switch( g_ItemToRepeat->Type() ) switch( g_ItemToRepeat->Type() )
{ {
case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) g_ItemToRepeat ) #define STRUCT ( (DrawJunctionStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
break; break;
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) g_ItemToRepeat ) #define STRUCT ( (DrawNoConnectStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
break; break;
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_TEXT*) g_ItemToRepeat ) #define STRUCT ( (SCH_TEXT*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
...@@ -652,8 +652,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -652,8 +652,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
case TYPE_SCH_LABEL: case TYPE_SCH_LABEL:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_LABEL*) g_ItemToRepeat ) #define STRUCT ( (SCH_LABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
...@@ -663,8 +663,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -663,8 +663,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_HIERLABEL*) g_ItemToRepeat ) #define STRUCT ( (SCH_HIERLABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
...@@ -673,8 +673,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -673,8 +673,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
break; break;
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_GLOBALLABEL*) g_ItemToRepeat ) #define STRUCT ( (SCH_GLOBALLABEL*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
...@@ -683,8 +683,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -683,8 +683,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
break; break;
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (EDA_DrawLineStruct*) g_ItemToRepeat ) #define STRUCT ( (EDA_DrawLineStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Start += g_RepeatStep; STRUCT->m_Start += g_RepeatStep;
new_pos = STRUCT->m_Start; new_pos = STRUCT->m_Start;
...@@ -700,8 +700,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -700,8 +700,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
break; break;
case TYPE_SCH_COMPONENT: // In repeat command the new component is put in move mode case TYPE_SCH_COMPONENT: // In repeat command the new component is put in move mode
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat ) #define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat )
// Create the duplicate component, position = mouse cursor // Create the duplicate component, position = mouse cursor
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
...@@ -710,9 +710,10 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -710,9 +710,10 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
STRUCT->m_Pos = GetScreen()->m_Curseur; STRUCT->m_Pos = GetScreen()->m_Curseur;
STRUCT->m_Flags = IS_NEW; STRUCT->m_Flags = IS_NEW;
STRUCT->m_TimeStamp = GetTimeStamp(); STRUCT->m_TimeStamp = GetTimeStamp();
for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
for( int ii = 0; ii < STRUCT->GetFieldCount(); ii++ )
{ {
STRUCT->m_Field[ii].m_Pos += new_pos; STRUCT->GetField(ii)->m_Pos += new_pos;
} }
RedrawOneStruct( DrawPanel, DC, STRUCT, g_XorMode ); RedrawOneStruct( DrawPanel, DC, STRUCT, g_XorMode );
......
...@@ -380,7 +380,7 @@ int DrawSheetStruct::ComponentCount() ...@@ -380,7 +380,7 @@ int DrawSheetStruct::ComponentCount()
if( bs->Type() == TYPE_SCH_COMPONENT ) if( bs->Type() == TYPE_SCH_COMPONENT )
{ {
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs; SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs;
if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' ) if( Cmp->GetField(VALUE)->m_Text.GetChar( 0 ) != '#' )
n++; n++;
} }
if( bs->Type() == DRAW_SHEET_STRUCT_TYPE ) if( bs->Type() == DRAW_SHEET_STRUCT_TYPE )
...@@ -776,12 +776,6 @@ wxString DrawSheetPath::PathHumanReadable() ...@@ -776,12 +776,6 @@ wxString DrawSheetPath::PathHumanReadable()
/***********************************************/ /***********************************************/
void DrawSheetPath::UpdateAllScreenReferences() void DrawSheetPath::UpdateAllScreenReferences()
/***********************************************/ /***********************************************/
/** Function UpdateAllScreenReferences
* Update the reference and the m_Multi parameter (part selection) for all components on a screen
* depending on the actual sheet path.
* Mandatory in complex hierarchies sheets use the same screen (basic schematic)
* but with different references and part selection according to the displayed sheet
*/
{ {
EDA_BaseStruct* t = LastDrawList(); EDA_BaseStruct* t = LastDrawList();
...@@ -790,7 +784,7 @@ void DrawSheetPath::UpdateAllScreenReferences() ...@@ -790,7 +784,7 @@ void DrawSheetPath::UpdateAllScreenReferences()
if( t->Type() == TYPE_SCH_COMPONENT ) if( t->Type() == TYPE_SCH_COMPONENT )
{ {
SCH_COMPONENT* component = (SCH_COMPONENT*) t; SCH_COMPONENT* component = (SCH_COMPONENT*) t;
component->m_Field[REFERENCE].m_Text = component->GetRef( this ); component->GetField(REFERENCE)->m_Text = component->GetRef( this );
component->m_Multi = component->GetUnitSelection( this ); component->m_Multi = component->GetUnitSelection( this );
} }
t = t->Pnext; t = t->Pnext;
......
...@@ -138,11 +138,12 @@ public: ...@@ -138,11 +138,12 @@ public:
/* class to handle a series of sheets *********/ /* class to handle a series of sheets *********/
/* a 'path' so to speak.. *********************/ /* a 'path' so to speak.. *********************/
/**********************************************/ /**********************************************/
#define DSLSZ 32 // Max number of levels for a sheet path
class DrawSheetPath class DrawSheetPath
{ {
public: public:
int m_numSheets; int m_numSheets;
#define DSLSZ 32 // Max number of levels for a sheet path
DrawSheetStruct* m_sheets[DSLSZ]; DrawSheetStruct* m_sheets[DSLSZ];
DrawSheetPath(); DrawSheetPath();
...@@ -168,9 +169,10 @@ public: ...@@ -168,9 +169,10 @@ public:
*/ */
wxString PathHumanReadable(); wxString PathHumanReadable();
/** Function UpdateAllScreenReferences /**
* Update the reference and the m_Multi parameter (part selection) for all components on a screen * Function UpdateAllScreenReferences
* depending on the actual sheet path. * updates the reference and the m_Multi parameter (part selection) for all
* components on a screen depending on the actual sheet path.
* Mandatory in complex hierarchies because sheets use the same screen (basic schematic) * Mandatory in complex hierarchies because sheets use the same screen (basic schematic)
* but with different references and part selection according to the displayed sheet * but with different references and part selection according to the displayed sheet
*/ */
......
...@@ -15,14 +15,18 @@ ...@@ -15,14 +15,18 @@
/***************************************************************************/ /***************************************************************************/
SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& pos, const wxString& text ) : SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) :
SCH_ITEM( NULL, DRAW_PART_TEXT_STRUCT_TYPE ), SCH_ITEM( aParent, DRAW_PART_TEXT_STRUCT_TYPE ),
EDA_TextStruct( text ) EDA_TextStruct()
/***************************************************************************/ /***************************************************************************/
{ {
m_Pos = pos; m_Pos = aPos;
m_FieldId = 0; m_FieldId = aFieldId;
m_AddExtraText = false; m_AddExtraText = false;
m_Attributs = TEXT_NO_VISIBLE;
m_Name = aName;
SetLayer( LAYER_FIELDS );
} }
...@@ -58,6 +62,7 @@ void SCH_CMP_FIELD::SwapData( SCH_CMP_FIELD* copyitem ) ...@@ -58,6 +62,7 @@ void SCH_CMP_FIELD::SwapData( SCH_CMP_FIELD* copyitem )
} }
#if 0
/***********************************************************/ /***********************************************************/
void SCH_CMP_FIELD::PartTextCopy( SCH_CMP_FIELD* target ) void SCH_CMP_FIELD::PartTextCopy( SCH_CMP_FIELD* target )
/***********************************************************/ /***********************************************************/
...@@ -75,6 +80,7 @@ void SCH_CMP_FIELD::PartTextCopy( SCH_CMP_FIELD* target ) ...@@ -75,6 +80,7 @@ void SCH_CMP_FIELD::PartTextCopy( SCH_CMP_FIELD* target )
target->m_VJustify = m_VJustify; target->m_VJustify = m_VJustify;
target->m_Flags = m_Flags; target->m_Flags = m_Flags;
} }
#endif
/*********************************/ /*********************************/
...@@ -200,26 +206,22 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const ...@@ -200,26 +206,22 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const
} }
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool SCH_CMP_FIELD::Save( FILE* aFile ) const bool SCH_CMP_FIELD::Save( FILE* aFile ) const
{ {
char hjustify = 'C'; char hjustify = 'C';
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
hjustify = 'L'; hjustify = 'L';
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
hjustify = 'R'; hjustify = 'R';
char vjustify = 'C'; char vjustify = 'C';
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
vjustify = 'B'; vjustify = 'B';
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
vjustify = 'T'; vjustify = 'T';
if( fprintf( aFile, "F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c", m_FieldId,
if( fprintf( aFile, "F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c",
m_FieldId,
CONV_TO_UTF8( m_Text ), CONV_TO_UTF8( m_Text ),
m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V',
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y,
...@@ -230,17 +232,12 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const ...@@ -230,17 +232,12 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const
return false; return false;
} }
// Save field name, if the name is user definable
// Save field name, if necessary if( m_FieldId >= FIELD1 )
if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() )
{ {
wxString fieldname = ReturnDefaultFieldName( m_FieldId ); if( fprintf( aFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ) == EOF )
if( fieldname != m_Name )
{ {
if( fprintf( aFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ) == EOF ) return false;
{
return false;
}
} }
} }
......
...@@ -5,43 +5,37 @@ ...@@ -5,43 +5,37 @@
#ifndef CLASS_SCH_CMP_FIELD_H #ifndef CLASS_SCH_CMP_FIELD_H
#define CLASS_SCH_CMP_FIELD_H #define CLASS_SCH_CMP_FIELD_H
/*Fields are texts attached to a component, having a specuial meaning /* Fields are texts attached to a component, having a specuial meaning
* Fields 0 and 1 are very important: reference and value * Fields 0 and 1 are very important: reference and value
* Field 2 is used as default footprint name. * Field 2 is used as default footprint name.
* Field 3 is reserved (not currently used * Field 3 is reserved (not currently used
* Fields 4 to 11 are user fields. * Fields 4 to 11 are user fields.
* They can be renamed and can appear in reports * They can be renamed and can appear in reports
*/ */
/* Fields identifiers */
enum NumFieldType {
REFERENCE = 0, /* Field Reference of part, i.e. "IC21" */
VALUE, /* Field Value of part, i.e. "3.3K" */
FOOTPRINT, /* Field Name Module PCB, i.e. "16DIP300" */
SHEET_FILENAME, /* Field Name Schema component, i.e. "cnt16.sch" */
FIELD1,
FIELD2,
FIELD3,
FIELD4,
FIELD5,
FIELD6,
FIELD7,
FIELD8,
NUMBER_OF_FIELDS /* used as Field count, not a field identifier */
};
/*************************************************************/ class SCH_COMPONENT;
/**
* Class SCH_CMP_FIELD
* instances are attached to a component and provide a place for the component's value,
* reference designator, footprint, and user definable name-value pairs of
* arbitrary purpose.
*/
class SCH_CMP_FIELD : public SCH_ITEM, public EDA_TextStruct class SCH_CMP_FIELD : public SCH_ITEM, public EDA_TextStruct
/*************************************************************/
{ {
public: public:
int m_FieldId; // Field indicator type (REFERENCE, VALUE or other id) int m_FieldId; // Field indicator type (REFERENCE, VALUE or other id)
wxString m_Name; /* Field name (ref, value,pcb, sheet, filed 1..
* and for fields 1 to 8 the name is editable */ wxString m_Name; /* Field name (ref, value,pcb, sheet, filed 1..
bool m_AddExtraText; // Mainly for REFERENCE, add extar info (for REFERENCE: add part selection text * and for fields 1 to 8 the name is editable
*/
bool m_AddExtraText; // Mainly for REFERENCE, add extra info (for REFERENCE: add part selection text
public: public:
SCH_CMP_FIELD( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString ); SCH_CMP_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName = wxEmptyString );
~SCH_CMP_FIELD(); ~SCH_CMP_FIELD();
virtual wxString GetClass() const virtual wxString GetClass() const
...@@ -68,7 +62,7 @@ public: ...@@ -68,7 +62,7 @@ public:
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
......
This diff is collapsed.
...@@ -16,8 +16,49 @@ ...@@ -16,8 +16,49 @@
#include "class_sch_cmp_field.h" #include "class_sch_cmp_field.h"
WX_DECLARE_OBJARRAY( DrawSheetPath, ArrayOfSheetLists ); WX_DECLARE_OBJARRAY( DrawSheetPath, ArrayOfSheetLists );
/**
* Struct Error
* is a holder of an error message and may be thrown from functions.
*/
struct Error
{
wxString errorText;
Error( const wxChar* aMsg ) :
errorText( aMsg )
{
}
Error( const wxString& aMsg ) :
errorText( aMsg )
{
}
};
/* Fields identifiers */
enum NumFieldType {
REFERENCE = 0, ///< Field Reference of part, i.e. "IC21"
VALUE, ///< Field Value of part, i.e. "3.3K"
FOOTPRINT, ///< Field Name Module PCB, i.e. "16DIP300"
DATASHEET, ///< name of datasheet
FIELD1,
FIELD2,
FIELD3,
FIELD4,
FIELD5,
FIELD6,
FIELD7,
FIELD8,
NUMBER_OF_FIELDS
};
/** /**
* Class SCH_COMPONENT * Class SCH_COMPONENT
* describes a real schematic component * describes a real schematic component
...@@ -33,25 +74,30 @@ public: ...@@ -33,25 +74,30 @@ public:
wxString m_PrefixString; /* C, R, U, Q etc - the first character which typically indicates what the component is. wxString m_PrefixString; /* C, R, U, Q etc - the first character which typically indicates what the component is.
* determined, upon placement, from the library component. * determined, upon placement, from the library component.
* determined, upon file load, by the first non-digits in the reference fields. */ * determined, upon file load, by the first non-digits in the reference fields. */
SCH_CMP_FIELD m_Field[NUMBER_OF_FIELDS];
int m_Convert; /* Gestion (management) des mutiples representations (ex: conversion De Morgan) */ int m_Convert; /* Gestion (management) des mutiples representations (ex: conversion De Morgan) */
int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */ int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */
private: private:
/** how many fields are fixed, or automatic and pre-made in the SCH_COMPONENT class */
typedef std::vector<SCH_CMP_FIELD> SCH_CMP_FIELDS;
SCH_CMP_FIELDS m_Fields;
/* Hierarchical references. /* Hierarchical references.
* format is * format is
* path reference multi * path reference multi
* with: * with:
* path = /<timestamp1>/<timestamp2> (subsheet path, = / for the root scheet) * path = /<timestamp1>/<timestamp2> (subsheet path, = / for the root scheet)
* reference = reference for this path (C23, R5, U78 ... ) * reference = reference for this path (C23, R5, U78 ... )
* multi = part selection in multi parts per package (0 or 1 for àne part per package) * multi = part selection in multi parts per package (0 or 1 for àne part per package)
*/ */
wxArrayString m_PathsAndReferences; wxArrayString m_PathsAndReferences;
public: public:
SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_ITEM* aParent = NULL );
~SCH_COMPONENT() { } ~SCH_COMPONENT() { }
virtual wxString GetClass() const virtual wxString GetClass() const
...@@ -68,11 +114,23 @@ public: ...@@ -68,11 +114,23 @@ public:
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/**
* Function Load
* reads a component in from a file. The file stream must be positioned at the
* first field of the file, not at the component tag.
* @param aFile The FILE to read from.
* @throw Error containing the error message text if there is a file format
* error or if the disk read has failed.
void Load( FILE* aFile ) throw( Error );
*/
SCH_COMPONENT* GenCopy(); SCH_COMPONENT* GenCopy();
void SetRotationMiroir( int type ); void SetRotationMiroir( int type );
int GetRotationMiroir(); int GetRotationMiroir();
wxPoint GetScreenCoord( const wxPoint& coord ); wxPoint GetScreenCoord( const wxPoint& coord );
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );
/** /**
* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1) * Suppress annotation ( i.i IC23 changed to IC? and part reset to 1)
* @param aSheet: DrawSheetPath value: if NULL remove all annotations, * @param aSheet: DrawSheetPath value: if NULL remove all annotations,
...@@ -83,17 +141,34 @@ public: ...@@ -83,17 +141,34 @@ public:
EDA_Rect GetBoundaryBox() const; EDA_Rect GetBoundaryBox() const;
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
const wxString& ReturnFieldName( int aFieldNdx ) const; /**
* Function ReturnFieldName
* returns the Field name given a field index like (REFERENCE, VALUE ..)
* @reeturn wxString - the field name or wxEmptyString if invalid field index.
*/
wxString ReturnFieldName( int aFieldNdx ) const;
/**
* Function GetField
* returns a field.
* @param aFieldNdx An index into the array of fields
* @return SCH_CMP_FIELD* - the field value or NULL if does not exist
*/
SCH_CMP_FIELD* GetField( int aFieldNdx ) const;
/** /**
* Function GetFieldValue * Function AddField
* returns a reference to the field value. * adds a field to the component. The component takes over ownership
* @param aFieldNdx An index into the array of fields, 0 - FIELD8 * of the field.
* @return const wxString& - the field value or wxEmptyString * @param aField A const reference to the SCH_CMP_FIELD to add.
*/ */
const wxString& GetFieldValue( int aFieldNdx ) const; void AddField( const SCH_CMP_FIELD& aField );
/**
* Function GetFieldCount
* returns the number of fields in this component.
*/
int GetFieldCount() const { return (int) m_Fields.size(); }
virtual void Draw( WinEDA_DrawPanel* panel, virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
...@@ -109,18 +184,24 @@ public: ...@@ -109,18 +184,24 @@ public:
//returns a unique ID, in the form of a path. //returns a unique ID, in the form of a path.
wxString GetPath( DrawSheetPath* sheet ); wxString GetPath( DrawSheetPath* sheet );
//returns the reference, for the given sheet path. //returns the reference, for the given sheet path.
const wxString GetRef( DrawSheetPath* sheet ); const wxString GetRef( DrawSheetPath* sheet );
//Set the reference, for the given sheet path. //Set the reference, for the given sheet path.
void SetRef( DrawSheetPath* sheet, const wxString& ref ); void SetRef( DrawSheetPath* sheet, const wxString& ref );
/** Function AddHierarchicalReference
* Add a full hierachical reference (path + local reference) /**
* Function AddHierarchicalReference
* adds a full hierachical reference (path + local reference)
* @param aPath = hierarchical path (/<sheet timestamp>/component timestamp> like /05678E50/A23EF560) * @param aPath = hierarchical path (/<sheet timestamp>/component timestamp> like /05678E50/A23EF560)
* @param aRef = local reference like C45, R56 * @param aRef = local reference like C45, R56
* @param aMulti = part selection, used in multi part per package (0 or 1 for non multi) * @param aMulti = part selection, used in multi part per package (0 or 1 for non multi)
*/ */
void AddHierarchicalReference( const wxString& aPath, const wxString& aRef, int aMulti ); void AddHierarchicalReference( const wxString& aPath, const wxString& aRef, int aMulti );
//returns the unit selection, for the given sheet path. //returns the unit selection, for the given sheet path.
int GetUnitSelection( DrawSheetPath* aSheet ); int GetUnitSelection( DrawSheetPath* aSheet );
//Set the unit selection, for the given sheet path. //Set the unit selection, for the given sheet path.
void SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection ); void SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection );
......
...@@ -82,7 +82,7 @@ SCH_ITEM * WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Includ ...@@ -82,7 +82,7 @@ SCH_ITEM * WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Includ
if( LibItem ) if( LibItem )
Affiche_1_Parametre( this, 1, Affiche_1_Parametre( this, 1,
LibItem->GetRef(GetSheet()), LibItem->GetRef(GetSheet()),
LibItem->m_Field[VALUE].m_Text, LibItem->GetField(VALUE)->m_Text,
CYAN ); CYAN );
// Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net) // Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net)
...@@ -156,7 +156,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin ...@@ -156,7 +156,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
if( LibItem ) if( LibItem )
Affiche_1_Parametre( this, 1, Affiche_1_Parametre( this, 1,
LibItem->GetRef(GetSheet()), LibItem->GetRef(GetSheet()),
LibItem->m_Field[VALUE].m_Text, LibItem->GetField(VALUE)->m_Text,
CYAN ); CYAN );
} }
else else
...@@ -182,7 +182,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin ...@@ -182,7 +182,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
if( LibItem ) if( LibItem )
Affiche_1_Parametre( this, 1, Affiche_1_Parametre( this, 1,
LibItem->GetRef(GetSheet()), LibItem->GetRef(GetSheet()),
LibItem->m_Field[VALUE].m_Text, LibItem->GetField(VALUE)->m_Text,
CYAN ); CYAN );
if( IncludePin == TRUE ) if( IncludePin == TRUE )
return LibItem; return LibItem;
......
...@@ -109,14 +109,14 @@ void WinEDA_SchematicFrame::SendMessageToPCBNEW( EDA_BaseStruct* objectT ...@@ -109,14 +109,14 @@ void WinEDA_SchematicFrame::SendMessageToPCBNEW( EDA_BaseStruct* objectT
{ {
if( LibItem == NULL ) if( LibItem == NULL )
break; break;
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->m_Field[REFERENCE].m_Text ) ); sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField(REFERENCE)->m_Text ) );
SendCommand( MSG_TO_PCB, Line ); SendCommand( MSG_TO_PCB, Line );
} }
break; break;
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
LibItem = (SCH_COMPONENT*) objectToSync; LibItem = (SCH_COMPONENT*) objectToSync;
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->m_Field[REFERENCE].m_Text ) ); sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
SendCommand( MSG_TO_PCB, Line ); SendCommand( MSG_TO_PCB, Line );
break; break;
...@@ -130,10 +130,10 @@ void WinEDA_SchematicFrame::SendMessageToPCBNEW( EDA_BaseStruct* objectT ...@@ -130,10 +130,10 @@ void WinEDA_SchematicFrame::SendMessageToPCBNEW( EDA_BaseStruct* objectT
wxString pinnum; wxString pinnum;
Pin->ReturnPinStringNum( pinnum ); Pin->ReturnPinStringNum( pinnum );
sprintf( Line, "$PIN: %s $PART: %s", CONV_TO_UTF8( pinnum ), sprintf( Line, "$PIN: %s $PART: %s", CONV_TO_UTF8( pinnum ),
CONV_TO_UTF8( LibItem->m_Field[REFERENCE].m_Text ) ); CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
} }
else else
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->m_Field[REFERENCE].m_Text ) ); sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
SendCommand( MSG_TO_PCB, Line ); SendCommand( MSG_TO_PCB, Line );
break; break;
......
...@@ -75,7 +75,7 @@ void WinEDA_ComponentPropertiesFrame::InitBuffers() ...@@ -75,7 +75,7 @@ void WinEDA_ComponentPropertiesFrame::InitBuffers()
m_CurrentFieldId = REFERENCE; m_CurrentFieldId = REFERENCE;
/* Init default values */ /* Init default values */
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
{ {
m_FieldSize[ii] = DEFAULT_SIZE_TEXT; m_FieldSize[ii] = DEFAULT_SIZE_TEXT;
m_FieldFlags[ii] = 1; m_FieldFlags[ii] = 1;
...@@ -88,20 +88,21 @@ void WinEDA_ComponentPropertiesFrame::InitBuffers() ...@@ -88,20 +88,21 @@ void WinEDA_ComponentPropertiesFrame::InitBuffers()
for( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) for( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ )
{ {
m_FieldName[ii] = m_Cmp->ReturnFieldName( ii ); m_FieldName[ii] = m_Cmp->ReturnFieldName( ii );
if(ii == REFERENCE) if(ii == REFERENCE)
m_FieldText[ii] = m_Cmp->GetRef(m_Parent->GetSheet()); m_FieldText[ii] = m_Cmp->GetRef( m_Parent->GetSheet() );
else else
m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text; m_FieldText[ii] = m_Cmp->GetField( ii )->m_Text;
m_FieldSize[ii] = m_Cmp->m_Field[ii].m_Size.x;
m_FieldFlags[ii] = m_FieldSize[ii] = m_Cmp->GetField( ii )->m_Size.x;
(m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1; m_FieldFlags[ii] = (m_Cmp->GetField( ii )->m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1;
m_FieldOrient[ii] = m_Cmp->m_Field[ii].m_Orient == TEXT_ORIENT_VERT ? 1 : 0; m_FieldOrient[ii] = m_Cmp->GetField( ii )->m_Orient == TEXT_ORIENT_VERT ? 1 : 0;
if( m_Cmp->m_Field[ii].m_Text.IsEmpty() ) if( m_Cmp->GetField( ii )->m_Text.IsEmpty() )
continue; continue;
// These values have meaning only if this field is not void: // These values have meaning only if this field is not void:
m_FieldPosition[ii] = m_Cmp->m_Field[ii].m_Pos; m_FieldPosition[ii] = m_Cmp->GetField( ii )->m_Pos;
m_FieldPosition[ii].x -= m_Cmp->m_Pos.x; m_FieldPosition[ii].x -= m_Cmp->m_Pos.x;
m_FieldPosition[ii].y -= m_Cmp->m_Pos.y; m_FieldPosition[ii].y -= m_Cmp->m_Pos.y;
} }
...@@ -403,30 +404,30 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent& ...@@ -403,30 +404,30 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent&
EDA_LibComponentStruct* Entry = FindLibPart( m_Cmp->m_ChipName.GetData( EDA_LibComponentStruct* Entry = FindLibPart( m_Cmp->m_ChipName.GetData(
), wxEmptyString, FIND_ROOT ); ), wxEmptyString, FIND_ROOT );
if( Entry && (Entry->m_Options == ENTRY_POWER) ) if( Entry && (Entry->m_Options == ENTRY_POWER) )
m_Cmp->m_Field[ii].m_Text = m_Cmp->m_ChipName; m_Cmp->GetField( ii )->m_Text = m_Cmp->m_ChipName;
else if( !m_FieldText[ii].IsEmpty() ) else if( !m_FieldText[ii].IsEmpty() )
{ {
m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; m_Cmp->GetField( ii )->m_Text = m_FieldText[ii];
} }
} }
else else
m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; m_Cmp->GetField( ii )->m_Text = m_FieldText[ii];
if( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName( ii ) ) if( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName( ii ) )
m_Cmp->m_Field[ii].m_Name = m_FieldName[ii]; m_Cmp->GetField( ii )->m_Name = m_FieldName[ii];
else else
m_Cmp->m_Field[ii].m_Name.Empty(); m_Cmp->GetField( ii )->m_Name.Empty();
m_Cmp->m_Field[ii].m_Size.x = m_Cmp->GetField( ii )->m_Size.x =
m_Cmp->m_Field[ii].m_Size.y = m_FieldSize[ii]; m_Cmp->GetField( ii )->m_Size.y = m_FieldSize[ii];
if( m_FieldFlags[ii] ) if( m_FieldFlags[ii] )
m_Cmp->m_Field[ii].m_Attributs &= ~TEXT_NO_VISIBLE; m_Cmp->GetField( ii )->m_Attributs &= ~TEXT_NO_VISIBLE;
else else
m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE; m_Cmp->GetField( ii )->m_Attributs |= TEXT_NO_VISIBLE;
m_Cmp->m_Field[ii].m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; m_Cmp->GetField( ii )->m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
m_Cmp->m_Field[ii].m_Pos = m_FieldPosition[ii]; m_Cmp->GetField( ii )->m_Pos = m_FieldPosition[ii];
m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x; m_Cmp->GetField( ii )->m_Pos.x += cmp_pos.x;
m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y; m_Cmp->GetField( ii )->m_Pos.y += cmp_pos.y;
} }
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
...@@ -764,10 +765,10 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -764,10 +765,10 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
SaveCopyInUndoList( Cmp, IS_CHANGED ); SaveCopyInUndoList( Cmp, IS_CHANGED );
Cmp->SetRef(GetSheet(), ref); Cmp->SetRef(GetSheet(), ref);
Cmp->m_Field[REFERENCE].m_AddExtraText = flag; Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
Cmp->m_Field[REFERENCE].Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode ); Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
Cmp->SetRef(GetSheet(), ref ); Cmp->SetRef(GetSheet(), ref );
Cmp->m_Field[REFERENCE].Draw( DrawPanel, DC, wxPoint(0,0), Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0),
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
...@@ -790,7 +791,7 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) ...@@ -790,7 +791,7 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
if( Entry == NULL ) if( Entry == NULL )
return; return;
SCH_CMP_FIELD* TextField = &Cmp->m_Field[VALUE]; SCH_CMP_FIELD* TextField = Cmp->GetField( VALUE );
message = TextField->m_Text; message = TextField->m_Text;
if( Get_Message( _( "Value" ), _("Component Value"), message, this ) ) if( Get_Message( _( "Value" ), _("Component Value"), message, this ) )
...@@ -827,35 +828,39 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -827,35 +828,39 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
if( Entry == NULL ) if( Entry == NULL )
return; return;
SCH_CMP_FIELD* TextField = &Cmp->m_Field[FOOTPRINT]; SCH_CMP_FIELD* TextField = Cmp->GetField( FOOTPRINT );
message = TextField->m_Text; message = TextField->m_Text;
if(message.IsEmpty() ) if(message.IsEmpty() )
wasEmpty = true; wasEmpty = true;
if( Get_Message( _( "Footprint" ), _("Component Footprint"), message, this ) ) if( Get_Message( _( "Footprint" ), _("Component Footprint"), message, this ) )
message.Empty(); //allow the user to remove the value. message.Empty(); // allow the user to remove the value.
/* save old cmp in undo list if not already in edit, or moving ... */ // save old cmp in undo list if not already in edit, or moving ...
if( Cmp->m_Flags == 0 ) if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED ); SaveCopyInUndoList( Cmp, IS_CHANGED );
Cmp->m_Field[FOOTPRINT].Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode ); Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
//move the field if it was new.
if(wasEmpty && !message.IsEmpty()) // move the field if it was new.
if( wasEmpty && !message.IsEmpty() )
{ {
Cmp->m_Field[FOOTPRINT].m_Pos = Cmp->m_Field[REFERENCE].m_Pos; Cmp->GetField( FOOTPRINT )->m_Pos = Cmp->GetField( REFERENCE )->m_Pos;
//add offset here - ? suitable heuristic below?
Cmp->m_Field[FOOTPRINT].m_Pos.x += // add offset here - ? suitable heuristic below?
(Cmp->m_Field[REFERENCE].m_Pos.x - Cmp->m_Pos.x) > 0 ? Cmp->GetField( FOOTPRINT )->m_Pos.x +=
(Cmp->m_Field[REFERENCE].m_Size.x) : (-1*Cmp->m_Field[REFERENCE].m_Size.x); (Cmp->GetField( REFERENCE )->m_Pos.x - Cmp->m_Pos.x) > 0 ?
Cmp->m_Field[FOOTPRINT].m_Pos.y += (Cmp->GetField( REFERENCE )->m_Size.x) : (-1*Cmp->GetField( REFERENCE )->m_Size.x);
(Cmp->m_Field[REFERENCE].m_Pos.y - Cmp->m_Pos.y) > 0 ?
(Cmp->m_Field[REFERENCE].m_Size.y) : (-1*Cmp->m_Field[REFERENCE].m_Size.y); Cmp->GetField( FOOTPRINT )->m_Pos.y +=
(Cmp->GetField( REFERENCE )->m_Pos.y - Cmp->m_Pos.y) > 0 ?
(Cmp->GetField( REFERENCE )->m_Size.y) : (-1*Cmp->GetField( REFERENCE )->m_Size.y);
Cmp->m_Field[FOOTPRINT].m_Orient = Cmp->m_Field[REFERENCE].m_Orient; Cmp->GetField( FOOTPRINT )->m_Orient = Cmp->GetField( REFERENCE )->m_Orient;
} }
TextField->m_Text = message; TextField->m_Text = message;
Cmp->m_Field[FOOTPRINT].Draw( DrawPanel, DC, wxPoint(0,0), Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0),
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -885,23 +890,23 @@ void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event ) ...@@ -885,23 +890,23 @@ void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event )
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );
/* Mise aux valeurs par defaut des champs et orientation */ /* Mise aux valeurs par defaut des champs et orientation */
m_Cmp->m_Field[REFERENCE].m_Pos.x = m_Cmp->GetField( REFERENCE )->m_Pos.x =
Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x;
m_Cmp->m_Field[REFERENCE].m_Pos.y = m_Cmp->GetField( REFERENCE )->m_Pos.y =
Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y;
m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; m_Cmp->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient;
m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; m_Cmp->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size;
m_Cmp->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; m_Cmp->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify;
m_Cmp->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; m_Cmp->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify;
m_Cmp->m_Field[VALUE].m_Pos.x = m_Cmp->GetField( VALUE )->m_Pos.x =
Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x;
m_Cmp->m_Field[VALUE].m_Pos.y = m_Cmp->GetField( VALUE )->m_Pos.y =
Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y;
m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; m_Cmp->GetField( VALUE )->m_Orient = Entry->m_Name.m_Orient;
m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; m_Cmp->GetField( VALUE )->m_Size = Entry->m_Name.m_Size;
m_Cmp->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; m_Cmp->GetField( VALUE )->m_HJustify = Entry->m_Name.m_HJustify;
m_Cmp->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; m_Cmp->GetField( VALUE )->m_VJustify = Entry->m_Name.m_VJustify;
m_Cmp->SetRotationMiroir( CMP_NORMAL ); m_Cmp->SetRotationMiroir( CMP_NORMAL );
......
...@@ -185,7 +185,8 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -185,7 +185,8 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
bool dummy = FALSE; bool dummy = FALSE;
if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL ) if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL )
{ /* composant non trouve, on affiche un composant "dummy" */ {
/* composant non trouve, on affiche un composant "dummy" */
dummy = TRUE; dummy = TRUE;
if( DummyCmp == NULL ) if( DummyCmp == NULL )
CreateDummyCmp(); CreateDummyCmp();
...@@ -202,26 +203,31 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -202,26 +203,31 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
* composant * composant
*/ */
if( ( (m_Field[REFERENCE].m_Attributs & TEXT_NO_VISIBLE) == 0 ) SCH_CMP_FIELD* field = GetField( REFERENCE );
&& !(m_Field[REFERENCE].m_Flags & IS_MOVED) )
if( ( (field->m_Attributs & TEXT_NO_VISIBLE) == 0 )
&& !(field->m_Flags & IS_MOVED) )
{ {
if( Entry->m_UnitCount > 1 ) if( Entry->m_UnitCount > 1 )
{ {
m_Field[REFERENCE].m_AddExtraText = true; field->m_AddExtraText = true;
m_Field[REFERENCE].Draw( panel, DC, offset, DrawMode ); field->Draw( panel, DC, offset, DrawMode );
} }
else else
{ {
m_Field[REFERENCE].m_AddExtraText = false; field->m_AddExtraText = false;
m_Field[REFERENCE].Draw( panel, DC, offset, DrawMode ); field->Draw( panel, DC, offset, DrawMode );
} }
} }
for( ii = VALUE; ii < NUMBER_OF_FIELDS; ii++ ) for( ii = VALUE; ii < GetFieldCount(); ii++ )
{ {
if( m_Field[ii].m_Flags & IS_MOVED ) field = GetField( ii );
if( field->m_Flags & IS_MOVED )
continue; continue;
m_Field[ii].Draw( panel, DC, offset, DrawMode );
field->Draw( panel, DC, offset, DrawMode );
} }
} }
...@@ -248,6 +254,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, ...@@ -248,6 +254,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel,
if( m_Attributs & TEXT_NO_VISIBLE ) if( m_Attributs & TEXT_NO_VISIBLE )
return; return;
if( IsVoid() ) if( IsVoid() )
return; return;
...@@ -290,6 +297,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, ...@@ -290,6 +297,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel,
color = ReturnLayerColor( LAYER_VALUEPART ); color = ReturnLayerColor( LAYER_VALUEPART );
else else
color = ReturnLayerColor( LAYER_FIELDS ); color = ReturnLayerColor( LAYER_FIELDS );
if( !m_AddExtraText || (m_FieldId != REFERENCE) ) if( !m_AddExtraText || (m_FieldId != REFERENCE) )
{ {
DrawGraphicText( panel, DC, pos, color, m_Text.GetData(), DrawGraphicText( panel, DC, pos, color, m_Text.GetData(),
...@@ -302,6 +310,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, ...@@ -302,6 +310,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel,
/* On ajoute alors A ou B ... a la reference */ /* On ajoute alors A ou B ... a la reference */
wxString fulltext = m_Text; wxString fulltext = m_Text;
fulltext.Append( 'A' - 1 + DrawLibItem->m_Multi ); fulltext.Append( 'A' - 1 + DrawLibItem->m_Multi );
DrawGraphicText( panel, DC, pos, color, fulltext.GetData(), DrawGraphicText( panel, DC, pos, color, fulltext.GetData(),
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size, m_Size,
...@@ -446,13 +455,13 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -446,13 +455,13 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
int x2 = BoundaryBox.GetRight(); int x2 = BoundaryBox.GetRight();
int y2 = BoundaryBox.GetBottom(); int y2 = BoundaryBox.GetBottom();
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
BoundaryBox = Component->m_Field[REFERENCE].GetBoundaryBox(); BoundaryBox = Component->GetField( REFERENCE )->GetBoundaryBox();
x1 = BoundaryBox.GetX(); x1 = BoundaryBox.GetX();
y1 = BoundaryBox.GetY(); y1 = BoundaryBox.GetY();
x2 = BoundaryBox.GetRight(); x2 = BoundaryBox.GetRight();
y2 = BoundaryBox.GetBottom(); y2 = BoundaryBox.GetBottom();
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
BoundaryBox = Component->m_Field[VALUE].GetBoundaryBox(); BoundaryBox = Component->GetField( VALUE )->GetBoundaryBox();
x1 = BoundaryBox.GetX(); x1 = BoundaryBox.GetX();
y1 = BoundaryBox.GetY(); y1 = BoundaryBox.GetY();
x2 = BoundaryBox.GetRight(); x2 = BoundaryBox.GetRight();
......
...@@ -117,15 +117,15 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem( ...@@ -117,15 +117,15 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem(
case 2: // find reference case 2: // find reference
NotFound = FALSE; NotFound = FALSE;
pos = pSch->m_Field[REFERENCE].m_Pos; pos = pSch->GetField( REFERENCE )->m_Pos;
break; break;
case 3: // find value case 3: // find value
pos = pSch->m_Pos; pos = pSch->m_Pos;
if( text_to_find.CmpNoCase( pSch->m_Field[VALUE].m_Text ) != 0 ) if( text_to_find.CmpNoCase( pSch->GetField( VALUE )->m_Text ) != 0 )
break; break;
NotFound = FALSE; NotFound = FALSE;
pos = pSch->m_Field[VALUE].m_Pos; pos = pSch->GetField( VALUE )->m_Pos;
break; break;
} }
} }
...@@ -469,13 +469,13 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( ...@@ -469,13 +469,13 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem(
if( WildCompareString( WildText, pSch->GetRef(Sheet), FALSE ) ) if( WildCompareString( WildText, pSch->GetRef(Sheet), FALSE ) )
{ {
NotFound = FALSE; NotFound = FALSE;
pos = pSch->m_Field[REFERENCE].m_Pos; pos = pSch->GetField( REFERENCE )->m_Pos;
break; break;
} }
if( WildCompareString( WildText, pSch->m_Field[VALUE].m_Text, FALSE ) ) if( WildCompareString( WildText, pSch->GetField( VALUE )->m_Text, FALSE ) )
{ {
NotFound = FALSE; NotFound = FALSE;
pos = pSch->m_Field[VALUE].m_Pos; pos = pSch->GetField( VALUE )->m_Pos;
} }
break; break;
......
...@@ -186,16 +186,16 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -186,16 +186,16 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
DrawLibItem->m_Flags = IS_NEW | IS_MOVED; DrawLibItem->m_Flags = IS_NEW | IS_MOVED;
/* Init champ Valeur */ /* Init champ Valeur */
DrawLibItem->m_Field[VALUE].m_Pos.x = DrawLibItem->GetField( VALUE )->m_Pos.x =
Entry->m_Name.m_Pos.x + DrawLibItem->m_Pos.x; Entry->m_Name.m_Pos.x + DrawLibItem->m_Pos.x;
DrawLibItem->m_Field[VALUE].m_Pos.y = DrawLibItem->GetField( VALUE )->m_Pos.y =
Entry->m_Name.m_Pos.y + DrawLibItem->m_Pos.y; Entry->m_Name.m_Pos.y + DrawLibItem->m_Pos.y;
DrawLibItem->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; DrawLibItem->GetField( VALUE )->m_Orient = Entry->m_Name.m_Orient;
DrawLibItem->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; DrawLibItem->GetField( VALUE )->m_Size = Entry->m_Name.m_Size;
DrawLibItem->m_Field[VALUE].m_Text = DrawLibItem->m_ChipName; DrawLibItem->GetField( VALUE )->m_Text = DrawLibItem->m_ChipName;
DrawLibItem->m_Field[VALUE].m_Attributs = Entry->m_Name.m_Attributs; DrawLibItem->GetField( VALUE )->m_Attributs = Entry->m_Name.m_Attributs;
DrawLibItem->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; DrawLibItem->GetField( VALUE )->m_HJustify = Entry->m_Name.m_HJustify;
DrawLibItem->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; DrawLibItem->GetField( VALUE )->m_VJustify = Entry->m_Name.m_VJustify;
msg = Entry->m_Prefix.m_Text; msg = Entry->m_Prefix.m_Text;
if( msg.IsEmpty() ) if( msg.IsEmpty() )
...@@ -206,36 +206,41 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -206,36 +206,41 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
DrawLibItem->SetRef(GetSheet(), msg ); DrawLibItem->SetRef(GetSheet(), msg );
/* Init champ Reference */ /* Init champ Reference */
DrawLibItem->m_Field[REFERENCE].m_Pos.x = DrawLibItem->GetField( REFERENCE )->m_Pos.x =
Entry->m_Prefix.m_Pos.x + DrawLibItem->m_Pos.x; Entry->m_Prefix.m_Pos.x + DrawLibItem->m_Pos.x;
DrawLibItem->m_Field[REFERENCE].m_Pos.y = DrawLibItem->GetField( REFERENCE )->m_Pos.y =
Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y; Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y;
DrawLibItem->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; DrawLibItem->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient;
DrawLibItem->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; DrawLibItem->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size;
DrawLibItem->m_PrefixString = Entry->m_Prefix.m_Text; DrawLibItem->m_PrefixString = Entry->m_Prefix.m_Text;
DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs; DrawLibItem->GetField( REFERENCE )->m_Attributs = Entry->m_Prefix.m_Attributs;
DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; DrawLibItem->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify;
DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; DrawLibItem->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify;
/* Init des autres champs si predefinis dans la librairie */ /* Init des autres champs si predefinis dans la librairie */
for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext ) for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext )
{ {
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
continue; continue;
ii = Field->m_FieldId; ii = Field->m_FieldId;
if( ii < 2 ) if( ii < 2 )
continue; continue;
if( ii >= NUMBER_OF_FIELDS )
if( ii >= DrawLibItem->GetFieldCount() )
continue; continue;
DrawLibItem->m_Field[ii].m_Pos.x += Field->m_Pos.x;
DrawLibItem->m_Field[ii].m_Pos.y += Field->m_Pos.y; SCH_CMP_FIELD* f = DrawLibItem->GetField( ii );
DrawLibItem->m_Field[ii].m_Size = Field->m_Size;
DrawLibItem->m_Field[ii].m_Attributs = Field->m_Attributs; f->m_Pos.x += Field->m_Pos.x;
DrawLibItem->m_Field[ii].m_Orient = Field->m_Orient; f->m_Pos.y += Field->m_Pos.y;
DrawLibItem->m_Field[ii].m_Text = Field->m_Text; f->m_Size = Field->m_Size;
DrawLibItem->m_Field[ii].m_Name = Field->m_Name; f->m_Attributs = Field->m_Attributs;
DrawLibItem->m_Field[ii].m_HJustify = Field->m_HJustify; f->m_Orient = Field->m_Orient;
DrawLibItem->m_Field[ii].m_VJustify = Field->m_VJustify; f->m_Text = Field->m_Text;
f->m_Name = Field->m_Name;
f->m_HJustify = Field->m_HJustify;
f->m_VJustify = Field->m_VJustify;
} }
DrawStructsInGhost( DrawPanel, DC, DrawLibItem, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, DrawLibItem, 0, 0 );
......
This diff is collapsed.
...@@ -422,19 +422,21 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask, ...@@ -422,19 +422,21 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
if( SearchMask & FIELDCMPITEM ) if( SearchMask & FIELDCMPITEM )
{ {
SCH_CMP_FIELD* Field;
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList; SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList;
for( i = REFERENCE; i < NUMBER_OF_FIELDS; i++ ) for( i = REFERENCE; i < DrawLibItem->GetFieldCount(); i++ )
{ {
Field = &DrawLibItem->m_Field[i]; SCH_CMP_FIELD* field = DrawLibItem->GetField(i);
if( (Field->m_Attributs & TEXT_NO_VISIBLE) )
if( field->m_Attributs & TEXT_NO_VISIBLE )
continue; continue;
if( Field->IsVoid() )
if( field->IsVoid() )
continue; continue;
EDA_Rect BoundaryBox = Field->GetBoundaryBox();
EDA_Rect BoundaryBox = field->GetBoundaryBox();
if( BoundaryBox.Inside( x, y ) ) if( BoundaryBox.Inside( x, y ) )
{ {
LastSnappedStruct = Field; LastSnappedStruct = field;
return TRUE; return TRUE;
} }
} }
......
...@@ -297,9 +297,9 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, ...@@ -297,9 +297,9 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
break; // No component left break; // No component left
FootprintName.Empty(); FootprintName.Empty();
if( !Component->m_Field[FOOTPRINT].IsVoid() ) if( !Component->GetField( FOOTPRINT )->IsVoid() )
{ {
FootprintName = Component->m_Field[FOOTPRINT].m_Text; FootprintName = Component->GetField( FOOTPRINT )->m_Text;
FootprintName.Replace( wxT( " " ), wxT( "_" ) ); FootprintName.Replace( wxT( " " ), wxT( "_" ) );
} }
...@@ -310,7 +310,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, ...@@ -310,7 +310,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
fprintf( tmpfile, CONV_TO_UTF8( Line ) ); fprintf( tmpfile, CONV_TO_UTF8( Line ) );
Line = Component->m_Field[VALUE].m_Text; Line = Component->GetField( VALUE )->m_Text;
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
fprintf( tmpfile, "Value=%s\n", CONV_TO_UTF8( Line ) ); fprintf( tmpfile, "Value=%s\n", CONV_TO_UTF8( Line ) );
...@@ -496,7 +496,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, ...@@ -496,7 +496,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
} }
} }
fprintf( f, " %s\n", CONV_TO_UTF8( Component->m_Field[VALUE].m_Text ) ); fprintf( f, " %s\n", CONV_TO_UTF8( Component->GetField( VALUE )->m_Text ) );
} }
} }
...@@ -587,9 +587,9 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with ...@@ -587,9 +587,9 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
} }
} }
if( !Component->m_Field[FOOTPRINT].IsVoid() ) if( !Component->GetField( FOOTPRINT )->IsVoid() )
{ {
FootprintName = Component->m_Field[FOOTPRINT].m_Text; FootprintName = Component->GetField( FOOTPRINT )->m_Text;
FootprintName.Replace( wxT( " " ), wxT( "_" ) ); FootprintName.Replace( wxT( " " ), wxT( "_" ) );
} }
else else
...@@ -601,7 +601,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with ...@@ -601,7 +601,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
CONV_TO_UTF8( FootprintName ) ); CONV_TO_UTF8( FootprintName ) );
fprintf( f, " %s", CONV_TO_UTF8( Line ) ); fprintf( f, " %s", CONV_TO_UTF8( Line ) );
Line = Component->m_Field[VALUE].m_Text; Line = Component->GetField( VALUE )->m_Text;
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
fprintf( f, " %s", CONV_TO_UTF8( Line ) ); fprintf( f, " %s", CONV_TO_UTF8( Line ) );
...@@ -968,9 +968,9 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) ...@@ -968,9 +968,9 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
if( Component == NULL ) if( Component == NULL )
break; break;
if( !Component->m_Field[FOOTPRINT].IsVoid() ) if( !Component->GetField( FOOTPRINT )->IsVoid() )
{ {
FootprintName = Component->m_Field[FOOTPRINT].m_Text; FootprintName = Component->GetField( FOOTPRINT )->m_Text;
FootprintName.Replace( wxT( " " ), wxT( "_" ) ); FootprintName.Replace( wxT( " " ), wxT( "_" ) );
} }
else else
...@@ -980,7 +980,7 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) ...@@ -980,7 +980,7 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
fprintf( f, "%s ", CONV_TO_UTF8( StartCmpDesc ) ); fprintf( f, "%s ", CONV_TO_UTF8( StartCmpDesc ) );
fprintf( f, "%s", CONV_TO_UTF8( msg ) ); fprintf( f, "%s", CONV_TO_UTF8( msg ) );
msg = Component->m_Field[VALUE].m_Text; msg = Component->GetField( VALUE )->m_Text;
msg.Replace( wxT( " " ), wxT( "_" ) ); msg.Replace( wxT( " " ), wxT( "_" ) );
fprintf( f, " \"%s\"", CONV_TO_UTF8( msg ) ); fprintf( f, " \"%s\"", CONV_TO_UTF8( msg ) );
fprintf( f, "\n" ); fprintf( f, "\n" );
......
...@@ -271,7 +271,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ...@@ -271,7 +271,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
if( !Component->m_Flags ) if( !Component->m_Flags )
{ {
msg = _( "Move Component" ); msg = _( "Move Component" );
msg << wxT(" ") << Component->GetFieldValue( REFERENCE ); msg << wxT(" ") << Component->GetField( REFERENCE )->m_Text;
msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT ); msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST,
msg, move_xpm ); msg, move_xpm );
......
...@@ -375,23 +375,23 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, ...@@ -375,23 +375,23 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
{ {
wxPoint textpos; /* Position des textes */ wxPoint textpos; /* Position des textes */
SCH_CMP_FIELD* Field = &DrawLibItem->m_Field[FieldNumber]; SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber );
int hjustify, vjustify; int hjustify, vjustify;
int orient, color = -1; int orient, color = -1;
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor( Field->GetLayer() ); color = ReturnLayerColor( field->GetLayer() );
DrawMode = 0; /* Unused */ DrawMode = 0; /* Unused */
if( Field->m_Attributs & TEXT_NO_VISIBLE ) if( field->m_Attributs & TEXT_NO_VISIBLE )
return; return;
if( Field->IsVoid() ) if( field->IsVoid() )
return; return;
/* Calcul de la position des textes, selon orientation du composant */ /* Calcul de la position des textes, selon orientation du composant */
orient = Field->m_Orient; orient = field->m_Orient;
hjustify = Field->m_HJustify; vjustify = Field->m_VJustify; hjustify = field->m_HJustify; vjustify = field->m_VJustify;
textpos = Field->m_Pos - DrawLibItem->m_Pos; // textpos is the text position relative to the component anchor textpos = field->m_Pos - DrawLibItem->m_Pos; // textpos is the text position relative to the component anchor
textpos = TransformCoordinate( DrawLibItem->m_Transform, textpos ) + DrawLibItem->m_Pos; textpos = TransformCoordinate( DrawLibItem->m_Transform, textpos ) + DrawLibItem->m_Pos;
...@@ -423,20 +423,20 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, ...@@ -423,20 +423,20 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
//not sure what to do here in terms of plotting components that may have multiple REFERENCE entries. //not sure what to do here in terms of plotting components that may have multiple REFERENCE entries.
if( !IsMulti || (FieldNumber != REFERENCE) ) if( !IsMulti || (FieldNumber != REFERENCE) )
{ {
PlotGraphicText( g_PlotFormat, textpos, color, Field->m_Text, PlotGraphicText( g_PlotFormat, textpos, color, field->m_Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size, field->m_Size,
hjustify, vjustify ); hjustify, vjustify );
} }
else /* We plt the reference, for a multiple parts per package */ else /* We plt the reference, for a multiple parts per package */
{ {
/* Adding A, B ... to the reference */ /* Adding A, B ... to the reference */
wxString Text; wxString Text;
Text = Field->m_Text; Text = field->m_Text;
Text.Append( 'A' - 1 + DrawLibItem->m_Multi ); Text.Append( 'A' - 1 + DrawLibItem->m_Multi );
PlotGraphicText( g_PlotFormat, textpos, color, Text, PlotGraphicText( g_PlotFormat, textpos, color, Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size, hjustify, vjustify ); field->m_Size, hjustify, vjustify );
} }
} }
......
...@@ -8,7 +8,7 @@ LibEDA_BaseStruct * LocatePin(const wxPoint & RefPos, ...@@ -8,7 +8,7 @@ LibEDA_BaseStruct * LocatePin(const wxPoint & RefPos,
int Unit, int Convert, SCH_COMPONENT * DrawItem = NULL); int Unit, int Convert, SCH_COMPONENT * DrawItem = NULL);
/* Routine de localisation d'une PIN de la PartLib pointee par Entry */ /* Routine de localisation d'une PIN de la PartLib pointee par Entry */
const wxString& ReturnDefaultFieldName( int aFieldNdx ); wxString ReturnDefaultFieldName( int aFieldNdx );
/****************/ /****************/
......
...@@ -474,10 +474,11 @@ typedef enum { ...@@ -474,10 +474,11 @@ typedef enum {
#define DEFAULT_SIZE_TEXT 60 /* default text height (in mils or 1/1000") */ #define DEFAULT_SIZE_TEXT 60 /* default text height (in mils or 1/1000") */
/** class EDA_TextStruct /**
* basic class to handle texts (labels, texts on components or footprints ..) * Class EDA_TextStruct
* is a basic class to handle texts (labels, texts on components or footprints ..)
* not used directly. * not used directly.
* the text classes are derived from EDA_BaseStruct and EDA_TextStruct * The text classes are derived from EDA_BaseStruct and EDA_TextStruct
*/ */
class EDA_TextStruct class EDA_TextStruct
{ {
...@@ -492,7 +493,8 @@ public: ...@@ -492,7 +493,8 @@ public:
int m_CharType; /* normal, bold, italic ... */ int m_CharType; /* normal, bold, italic ... */
int m_HJustify, m_VJustify; /* Horiz and Vert Justifications */ int m_HJustify, m_VJustify; /* Horiz and Vert Justifications */
int m_ZoomLevelDrawable; /* zoom level to draw text. int m_ZoomLevelDrawable; /* zoom level to draw text.
* if zoom < m_ZoomLevelDrawable: the text is drawn as a single line */ * if zoom < m_ZoomLevelDrawable: the text is drawn as a single line
*/
int* m_TextDrawings; /* list of segments to draw, for the Draw function */ int* m_TextDrawings; /* list of segments to draw, for the Draw function */
int m_TextDrawingsSize; /* segment count */ int m_TextDrawingsSize; /* segment count */
...@@ -503,10 +505,12 @@ public: ...@@ -503,10 +505,12 @@ public:
int GetLength() const { return m_Text.Length(); }; int GetLength() const { return m_Text.Length(); };
/** Function Pitch() /**
* @return distance between 2 caracteres * Function Pitch
* @return distance between 2 characters
*/ */
int Pitch(); int Pitch();
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int color, const wxPoint& offset, int color,
int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 ); int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment