variable number of fields per schematic component
This commit is contained in:
parent
22c506125f
commit
ff193f1844
|
@ -1,6 +1,8 @@
|
|||
add_definitions(-DEESCHEMA)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||
# ${Boost_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(EESCHEMA_SRCS
|
||||
affiche.cpp
|
||||
|
|
|
@ -41,7 +41,8 @@ void SCH_COMPONENT::Display_Infos( WinEDA_DrawFrame* frame )
|
|||
msg = _( "Pwr Symb" );
|
||||
else
|
||||
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 );
|
||||
|
||||
|
|
|
@ -382,11 +382,11 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetPath* sheet )
|
|||
|
||||
BaseListeCmp[NbrCmp].m_NumRef = -1;
|
||||
|
||||
if( DrawLibItem->m_Field[VALUE].m_Text.IsEmpty() )
|
||||
DrawLibItem->m_Field[VALUE].m_Text = wxT( "~" );
|
||||
if( DrawLibItem->GetField(VALUE)->m_Text.IsEmpty() )
|
||||
DrawLibItem->GetField(VALUE)->m_Text = wxT( "~" );
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,22 +48,23 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent(
|
|||
|
||||
Cmp = (SCH_COMPONENT*) DrawList;
|
||||
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
|
||||
* the text is empty at position 0, because it is probably not yet initialised
|
||||
*/
|
||||
if( Cmp->m_Field[FOOTPRINT].m_Text.IsEmpty()
|
||||
&& ( Cmp->m_Field[FOOTPRINT].m_Pos == wxPoint( 0, 0 ) ) )
|
||||
if( Cmp->GetField(FOOTPRINT)->m_Text.IsEmpty()
|
||||
&& ( Cmp->GetField(FOOTPRINT)->m_Pos == wxPoint( 0, 0 ) ) )
|
||||
{
|
||||
Cmp->m_Field[FOOTPRINT].m_Orient = Cmp->m_Field[VALUE].m_Orient;
|
||||
Cmp->m_Field[FOOTPRINT].m_Pos = Cmp->m_Field[VALUE].m_Pos;
|
||||
Cmp->m_Field[FOOTPRINT].m_Pos.y -= 100;
|
||||
Cmp->GetField(FOOTPRINT)->m_Orient = Cmp->GetField(VALUE)->m_Orient;
|
||||
Cmp->GetField(FOOTPRINT)->m_Pos = Cmp->GetField(VALUE)->m_Pos;
|
||||
Cmp->GetField(FOOTPRINT)->m_Pos.y -= 100;
|
||||
}
|
||||
Cmp->m_Field[FOOTPRINT].m_Text = aFootPrint;
|
||||
Cmp->GetField(FOOTPRINT)->m_Text = aFootPrint;
|
||||
if( aSetVisible )
|
||||
Cmp->m_Field[FOOTPRINT].m_Attributs &= ~TEXT_NO_VISIBLE;
|
||||
Cmp->GetField(FOOTPRINT)->m_Attributs &= ~TEXT_NO_VISIBLE;
|
||||
else
|
||||
Cmp->m_Field[FOOTPRINT].m_Attributs |= TEXT_NO_VISIBLE;
|
||||
Cmp->GetField(FOOTPRINT)->m_Attributs |= TEXT_NO_VISIBLE;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -711,11 +711,12 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
|
|||
NULL, CMP_MIROIR_Y );
|
||||
MirrorYPoint( DrawLibItem->m_Pos, Center );
|
||||
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;
|
||||
|
||||
case DRAW_SHEET_STRUCT_TYPE:
|
||||
|
@ -1232,9 +1233,9 @@ void MoveOneStruct( SCH_ITEM * DrawStruct, const wxPoint& move_vector )
|
|||
case TYPE_SCH_COMPONENT:
|
||||
DrawLibItem = (SCH_COMPONENT*) DrawStruct;
|
||||
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;
|
||||
|
|
|
@ -420,8 +420,8 @@ static int ListTriComposantByVal( ListComponent* obj1,
|
|||
if( obj2->m_Comp == NULL )
|
||||
return 1;
|
||||
|
||||
Text1 = &(obj1->m_Comp->m_Field[VALUE].m_Text);
|
||||
Text2 = &(obj2->m_Comp->m_Field[VALUE].m_Text);
|
||||
Text1 = &(obj1->m_Comp->GetField(VALUE)->m_Text);
|
||||
Text2 = &(obj2->m_Comp->GetField(VALUE)->m_Text);
|
||||
ii = Text1->CmpNoCase( *Text2 );
|
||||
|
||||
if( ii == 0 )
|
||||
|
@ -471,8 +471,8 @@ static int ListTriComposantByRef( ListComponent* obj1,
|
|||
|
||||
if( ii == 0 )
|
||||
{
|
||||
Text1 = &( obj1->m_Comp->m_Field[VALUE].m_Text );
|
||||
Text2 = &( obj2->m_Comp->m_Field[VALUE].m_Text );
|
||||
Text1 = &( obj1->m_Comp->GetField(VALUE)->m_Text );
|
||||
Text2 = &( obj2->m_Comp->GetField(VALUE)->m_Text );
|
||||
ii = Text1->CmpNoCase( *Text2 );
|
||||
}
|
||||
|
||||
|
@ -594,7 +594,8 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem
|
|||
bool CompactForm )
|
||||
/*******************************************************************************************/
|
||||
{
|
||||
const wxCheckBox* FieldListCtrl[] = {
|
||||
// @todo make this variable length
|
||||
static const wxCheckBox* FieldListCtrl[] = {
|
||||
m_AddField1,
|
||||
m_AddField2,
|
||||
m_AddField3,
|
||||
|
@ -613,24 +614,26 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem
|
|||
if( CompactForm )
|
||||
{
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( DrawLibItem->m_Field[FOOTPRINT].m_Text ) );
|
||||
CONV_TO_UTF8( DrawLibItem->GetField(FOOTPRINT)->m_Text ) );
|
||||
}
|
||||
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];
|
||||
if( FieldCtrl == NULL )
|
||||
continue;
|
||||
|
||||
if( !FieldCtrl->IsChecked() )
|
||||
continue;
|
||||
|
||||
if( CompactForm )
|
||||
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
|
||||
CONV_TO_UTF8( DrawLibItem->m_Field[ii].m_Text ) );
|
||||
CONV_TO_UTF8( DrawLibItem->GetField(ii)->m_Text ) );
|
||||
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,
|
|||
|
||||
if( CompactForm )
|
||||
{
|
||||
const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] = {
|
||||
// @todo make this variable length
|
||||
static const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] = {
|
||||
m_AddField1,
|
||||
m_AddField2,
|
||||
m_AddField3,
|
||||
|
@ -673,7 +677,6 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f,
|
|||
{
|
||||
fprintf( f, "%csheet path", s_ExportSeparatorSymbol );
|
||||
fprintf( f, "%clocation", s_ExportSeparatorSymbol );
|
||||
|
||||
}
|
||||
|
||||
if( m_AddFootprintField->IsChecked() )
|
||||
|
@ -732,10 +735,10 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f,
|
|||
|
||||
if( CompactForm )
|
||||
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
|
||||
fprintf( f, "| %-10s %-12s", CmpName,
|
||||
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ) );
|
||||
CONV_TO_UTF8( DrawLibItem->GetField(VALUE)->m_Text ) );
|
||||
|
||||
if( aIncludeSubComponents )
|
||||
{
|
||||
|
@ -816,7 +819,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f,
|
|||
}
|
||||
|
||||
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
|
||||
if( aIncludeSubComponents )
|
||||
|
|
|
@ -625,24 +625,24 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
|
|||
switch( g_ItemToRepeat->Type() )
|
||||
{
|
||||
case DRAW_JUNCTION_STRUCT_TYPE:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (DrawJunctionStruct*) g_ItemToRepeat )
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (DrawJunctionStruct*) g_ItemToRepeat )
|
||||
g_ItemToRepeat = STRUCT->GenCopy();
|
||||
STRUCT->m_Pos += g_RepeatStep;
|
||||
new_pos = STRUCT->m_Pos;
|
||||
break;
|
||||
|
||||
case DRAW_NOCONNECT_STRUCT_TYPE:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (DrawNoConnectStruct*) g_ItemToRepeat )
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (DrawNoConnectStruct*) g_ItemToRepeat )
|
||||
g_ItemToRepeat = STRUCT->GenCopy();
|
||||
STRUCT->m_Pos += g_RepeatStep;
|
||||
new_pos = STRUCT->m_Pos;
|
||||
break;
|
||||
|
||||
case TYPE_SCH_TEXT:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_TEXT*) g_ItemToRepeat )
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_TEXT*) g_ItemToRepeat )
|
||||
g_ItemToRepeat = STRUCT->GenCopy();
|
||||
STRUCT->m_Pos += g_RepeatStep;
|
||||
new_pos = STRUCT->m_Pos;
|
||||
|
@ -652,8 +652,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
|
|||
|
||||
|
||||
case TYPE_SCH_LABEL:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_LABEL*) g_ItemToRepeat )
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_LABEL*) g_ItemToRepeat )
|
||||
g_ItemToRepeat = STRUCT->GenCopy();
|
||||
STRUCT->m_Pos += g_RepeatStep;
|
||||
new_pos = STRUCT->m_Pos;
|
||||
|
@ -663,8 +663,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
|
|||
|
||||
|
||||
case TYPE_SCH_HIERLABEL:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_HIERLABEL*) g_ItemToRepeat )
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_HIERLABEL*) g_ItemToRepeat )
|
||||
g_ItemToRepeat = STRUCT->GenCopy();
|
||||
STRUCT->m_Pos += g_RepeatStep;
|
||||
new_pos = STRUCT->m_Pos;
|
||||
|
@ -673,8 +673,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
|
|||
break;
|
||||
|
||||
case TYPE_SCH_GLOBALLABEL:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_GLOBALLABEL*) g_ItemToRepeat )
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_GLOBALLABEL*) g_ItemToRepeat )
|
||||
g_ItemToRepeat = STRUCT->GenCopy();
|
||||
STRUCT->m_Pos += g_RepeatStep;
|
||||
new_pos = STRUCT->m_Pos;
|
||||
|
@ -683,8 +683,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
|
|||
break;
|
||||
|
||||
case DRAW_SEGMENT_STRUCT_TYPE:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (EDA_DrawLineStruct*) g_ItemToRepeat )
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (EDA_DrawLineStruct*) g_ItemToRepeat )
|
||||
g_ItemToRepeat = STRUCT->GenCopy();
|
||||
STRUCT->m_Start += g_RepeatStep;
|
||||
new_pos = STRUCT->m_Start;
|
||||
|
@ -700,8 +700,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
|
|||
break;
|
||||
|
||||
case TYPE_SCH_COMPONENT: // In repeat command the new component is put in move mode
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat )
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat )
|
||||
|
||||
// Create the duplicate component, position = mouse cursor
|
||||
g_ItemToRepeat = STRUCT->GenCopy();
|
||||
|
@ -710,9 +710,10 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
|
|||
STRUCT->m_Pos = GetScreen()->m_Curseur;
|
||||
STRUCT->m_Flags = IS_NEW;
|
||||
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 );
|
||||
|
|
|
@ -380,7 +380,7 @@ int DrawSheetStruct::ComponentCount()
|
|||
if( bs->Type() == TYPE_SCH_COMPONENT )
|
||||
{
|
||||
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs;
|
||||
if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' )
|
||||
if( Cmp->GetField(VALUE)->m_Text.GetChar( 0 ) != '#' )
|
||||
n++;
|
||||
}
|
||||
if( bs->Type() == DRAW_SHEET_STRUCT_TYPE )
|
||||
|
@ -776,12 +776,6 @@ wxString DrawSheetPath::PathHumanReadable()
|
|||
/***********************************************/
|
||||
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();
|
||||
|
||||
|
@ -790,7 +784,7 @@ void DrawSheetPath::UpdateAllScreenReferences()
|
|||
if( t->Type() == TYPE_SCH_COMPONENT )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
t = t->Pnext;
|
||||
|
|
|
@ -138,11 +138,12 @@ public:
|
|||
/* class to handle a series of sheets *********/
|
||||
/* a 'path' so to speak.. *********************/
|
||||
/**********************************************/
|
||||
#define DSLSZ 32 // Max number of levels for a sheet path
|
||||
class DrawSheetPath
|
||||
{
|
||||
public:
|
||||
int m_numSheets;
|
||||
|
||||
#define DSLSZ 32 // Max number of levels for a sheet path
|
||||
DrawSheetStruct* m_sheets[DSLSZ];
|
||||
|
||||
DrawSheetPath();
|
||||
|
@ -168,9 +169,10 @@ public:
|
|||
*/
|
||||
wxString PathHumanReadable();
|
||||
|
||||
/** Function UpdateAllScreenReferences
|
||||
* Update the reference and the m_Multi parameter (part selection) for all components on a screen
|
||||
* depending on the actual sheet path.
|
||||
/**
|
||||
* Function UpdateAllScreenReferences
|
||||
* 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)
|
||||
* but with different references and part selection according to the displayed sheet
|
||||
*/
|
||||
|
|
|
@ -15,14 +15,18 @@
|
|||
|
||||
|
||||
/***************************************************************************/
|
||||
SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& pos, const wxString& text ) :
|
||||
SCH_ITEM( NULL, DRAW_PART_TEXT_STRUCT_TYPE ),
|
||||
EDA_TextStruct( text )
|
||||
SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) :
|
||||
SCH_ITEM( aParent, DRAW_PART_TEXT_STRUCT_TYPE ),
|
||||
EDA_TextStruct()
|
||||
/***************************************************************************/
|
||||
{
|
||||
m_Pos = pos;
|
||||
m_FieldId = 0;
|
||||
m_Pos = aPos;
|
||||
m_FieldId = aFieldId;
|
||||
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 )
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/***********************************************************/
|
||||
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_Flags = m_Flags;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*********************************/
|
||||
|
@ -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
|
||||
{
|
||||
char hjustify = 'C';
|
||||
|
||||
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
|
||||
hjustify = 'L';
|
||||
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
hjustify = 'R';
|
||||
|
||||
char vjustify = 'C';
|
||||
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
vjustify = 'B';
|
||||
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
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 ),
|
||||
m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V',
|
||||
m_Pos.x, m_Pos.y,
|
||||
|
@ -230,17 +232,12 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Save field name, if necessary
|
||||
if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() )
|
||||
// Save field name, if the name is user definable
|
||||
if( m_FieldId >= FIELD1 )
|
||||
{
|
||||
wxString fieldname = ReturnDefaultFieldName( m_FieldId );
|
||||
if( fieldname != m_Name )
|
||||
if( fprintf( aFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ) == EOF )
|
||||
{
|
||||
if( fprintf( aFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ) == EOF )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,43 +5,37 @@
|
|||
#ifndef CLASS_SCH_CMP_FIELD_H
|
||||
#define CLASS_SCH_CMP_FIELD_H
|
||||
|
||||
/*Fields are texts attached to a component, having a specuial meaning
|
||||
* Fields 0 and 1 are very important: reference and value
|
||||
* Field 2 is used as default footprint name.
|
||||
* Field 3 is reserved (not currently used
|
||||
* Fields 4 to 11 are user fields.
|
||||
* They can be renamed and can appear in reports
|
||||
/* Fields are texts attached to a component, having a specuial meaning
|
||||
* Fields 0 and 1 are very important: reference and value
|
||||
* Field 2 is used as default footprint name.
|
||||
* Field 3 is reserved (not currently used
|
||||
* Fields 4 to 11 are user fields.
|
||||
* 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
|
||||
/*************************************************************/
|
||||
{
|
||||
public:
|
||||
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 */
|
||||
bool m_AddExtraText; // Mainly for REFERENCE, add extar info (for REFERENCE: add part selection text
|
||||
|
||||
wxString m_Name; /* Field name (ref, value,pcb, sheet, filed 1..
|
||||
* 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:
|
||||
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();
|
||||
|
||||
virtual wxString GetClass() const
|
||||
|
@ -68,7 +62,7 @@ public:
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
|
|
|
@ -22,8 +22,47 @@ WX_DEFINE_OBJARRAY( ArrayOfSheetLists );
|
|||
/* class SCH_COMPONENT */
|
||||
/***************************/
|
||||
|
||||
/** Function AddHierarchicalReference
|
||||
* Add a full hierachical reference (path + local reference)
|
||||
|
||||
/*******************************************************************/
|
||||
SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
|
||||
SCH_ITEM( aParent, TYPE_SCH_COMPONENT )
|
||||
/*******************************************************************/
|
||||
{
|
||||
m_Multi = 0; /* In multi unit chip - which unit to draw. */
|
||||
|
||||
m_Pos = aPos;
|
||||
|
||||
m_Convert = 0; /* De Morgan Handling */
|
||||
|
||||
/* The rotation/mirror transformation matrix. pos normal */
|
||||
m_Transform[0][0] = 1;
|
||||
m_Transform[0][1] = 0;
|
||||
m_Transform[1][0] = 0;
|
||||
m_Transform[1][1] = -1;
|
||||
|
||||
m_Fields.reserve( NUMBER_OF_FIELDS );
|
||||
|
||||
for( int i=0; i<NUMBER_OF_FIELDS; ++i )
|
||||
{
|
||||
SCH_CMP_FIELD field( aPos, i, this, ReturnDefaultFieldName(i) );
|
||||
|
||||
if( i==REFERENCE )
|
||||
field.SetLayer( LAYER_REFERENCEPART );
|
||||
else if( i==VALUE )
|
||||
field.SetLayer( LAYER_VALUEPART );
|
||||
// else keep LAYER_FIELDS from SCH_CMP_FIELD constructor
|
||||
|
||||
// SCH_CMP_FIELD's implicitly created copy constructor is called in here
|
||||
AddField( field );
|
||||
}
|
||||
|
||||
m_PrefixString = wxString( _( "U" ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function AddHierarchicalReference
|
||||
* adds a full hierachical reference (path + local reference)
|
||||
* @param aPath = hierarchical path (/<sheet timestamp>/component timestamp> like /05678E50/A23EF560)
|
||||
* @param aRef = local reference like C45, R56
|
||||
* @param aMulti = part selection, used in multi part per package (0 or 1 for non multi)
|
||||
|
@ -56,7 +95,7 @@ void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath,
|
|||
|
||||
|
||||
/****************************************************************/
|
||||
const wxString& ReturnDefaultFieldName( int aFieldNdx )
|
||||
wxString ReturnDefaultFieldName( int aFieldNdx )
|
||||
/****************************************************************/
|
||||
|
||||
/* Return the default field name from its index (REFERENCE, VALUE ..)
|
||||
|
@ -65,42 +104,40 @@ const wxString& ReturnDefaultFieldName( int aFieldNdx )
|
|||
*/
|
||||
{
|
||||
// avoid unnecessarily copying wxStrings at runtime.
|
||||
static const wxString FieldDefaultNameList[] = {
|
||||
_( "Ref" ), /* Reference of part, i.e. "IC21" */
|
||||
_( "Value" ), /* Value of part, i.e. "3.3K" */
|
||||
_( "Footprint" ), /* Footprint, used by cvpcb or pcbnew, i.e. "16DIP300" */
|
||||
_( "Sheet" ), /* for components which are a schematic file, schematic file name, i.e. "cnt16.sch" */
|
||||
wxString( _( "Field" ) ) + wxT( "1" ),
|
||||
wxString( _( "Field" ) ) + wxT( "2" ),
|
||||
wxString( _( "Field" ) ) + wxT( "3" ),
|
||||
wxString( _( "Field" ) ) + wxT( "4" ),
|
||||
wxString( _( "Field" ) ) + wxT( "5" ),
|
||||
wxString( _( "Field" ) ) + wxT( "6" ),
|
||||
wxString( _( "Field" ) ) + wxT( "7" ),
|
||||
wxString( _( "Field" ) ) + wxT( "8" ),
|
||||
wxT( "badFieldNdx!" ) // error, and "sentinel" value
|
||||
static const wxString defaults[] = {
|
||||
_( "Ref" ), // Reference of part, i.e. "IC21"
|
||||
_( "Value" ), // Value of part, i.e. "3.3K"
|
||||
_( "Footprint" ), // Footprint, used by cvpcb or pcbnew, i.e. "16DIP300"
|
||||
_( "Datasheet" ),
|
||||
};
|
||||
|
||||
if( (unsigned) aFieldNdx > FIELD8 ) // catches < 0 also
|
||||
aFieldNdx = FIELD8 + 1; // return the sentinel text
|
||||
if( (unsigned) aFieldNdx <= DATASHEET )
|
||||
return defaults[ aFieldNdx ];
|
||||
|
||||
return FieldDefaultNameList[aFieldNdx];
|
||||
else
|
||||
{
|
||||
wxString ret = _("Field");
|
||||
ret << ( aFieldNdx - FIELD1 + 1);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
const wxString& SCH_COMPONENT::ReturnFieldName( int aFieldNdx ) const
|
||||
wxString SCH_COMPONENT::ReturnFieldName( int aFieldNdx ) const
|
||||
/****************************************************************/
|
||||
|
||||
/* Return the Field name from its index (REFERENCE, VALUE ..)
|
||||
*/
|
||||
{
|
||||
// avoid unnecessarily copying wxStrings.
|
||||
SCH_CMP_FIELD* field = GetField( aFieldNdx );
|
||||
|
||||
if( aFieldNdx < FIELD1 || m_Field[aFieldNdx].m_Name.IsEmpty() )
|
||||
return ReturnDefaultFieldName( aFieldNdx );
|
||||
if( field )
|
||||
{
|
||||
if( !field->m_Name.IsEmpty() )
|
||||
return field->m_Name;
|
||||
else
|
||||
return ReturnDefaultFieldName( aFieldNdx );
|
||||
}
|
||||
|
||||
return m_Field[aFieldNdx].m_Name;
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,15 +174,15 @@ const wxString SCH_COMPONENT::GetRef( DrawSheetPath* sheet )
|
|||
}
|
||||
}
|
||||
|
||||
//if it was not found in m_Paths array, then see if it is in
|
||||
// if it was not found in m_Paths array, then see if it is in
|
||||
// m_Field[REFERENCE] -- if so, use this as a default for this path.
|
||||
// this will happen if we load a version 1 schematic file.
|
||||
// it will also mean that multiple instances of the same sheet by default
|
||||
// all have the same component references, but perhaps this is best.
|
||||
if( !m_Field[REFERENCE].m_Text.IsEmpty() )
|
||||
if( !GetField(REFERENCE)->m_Text.IsEmpty() )
|
||||
{
|
||||
SetRef( sheet, m_Field[REFERENCE].m_Text );
|
||||
return m_Field[REFERENCE].m_Text;
|
||||
SetRef( sheet, GetField(REFERENCE)->m_Text );
|
||||
return GetField(REFERENCE)->m_Text;
|
||||
}
|
||||
return m_PrefixString;
|
||||
}
|
||||
|
@ -184,16 +221,19 @@ void SCH_COMPONENT::SetRef( DrawSheetPath* sheet, const wxString& ref )
|
|||
if( notInArray )
|
||||
AddHierarchicalReference( path, ref, m_Multi );
|
||||
|
||||
if( m_Field[REFERENCE].m_Text.IsEmpty()
|
||||
|| ( abs( m_Field[REFERENCE].m_Pos.x - m_Pos.x ) +
|
||||
abs( m_Field[REFERENCE].m_Pos.y - m_Pos.y ) > 10000) )
|
||||
SCH_CMP_FIELD* rf = GetField( REFERENCE );
|
||||
|
||||
if( rf->m_Text.IsEmpty()
|
||||
|| ( abs( rf->m_Pos.x - m_Pos.x ) +
|
||||
abs( rf->m_Pos.y - m_Pos.y ) > 10000) )
|
||||
{
|
||||
//move it to a reasonable position..
|
||||
m_Field[REFERENCE].m_Pos = m_Pos;
|
||||
m_Field[REFERENCE].m_Pos.x += 50; //a slight offset..
|
||||
m_Field[REFERENCE].m_Pos.y += 50;
|
||||
// move it to a reasonable position
|
||||
rf->m_Pos = m_Pos;
|
||||
rf->m_Pos.x += 50; // a slight offset
|
||||
rf->m_Pos.y += 50;
|
||||
}
|
||||
m_Field[REFERENCE].m_Text = ref; //for drawing.
|
||||
|
||||
rf->m_Text = ref; // for drawing.
|
||||
}
|
||||
|
||||
|
||||
|
@ -266,51 +306,28 @@ void SCH_COMPONENT::SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection
|
|||
|
||||
|
||||
/******************************************************************/
|
||||
const wxString& SCH_COMPONENT::GetFieldValue( int aFieldNdx ) const
|
||||
SCH_CMP_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
|
||||
/******************************************************************/
|
||||
{
|
||||
// avoid unnecessarily copying wxStrings.
|
||||
static const wxString myEmpty = wxEmptyString;
|
||||
const SCH_CMP_FIELD* field;
|
||||
|
||||
if( (unsigned) aFieldNdx > FIELD8 || m_Field[aFieldNdx].m_Text.IsEmpty() )
|
||||
return myEmpty;
|
||||
if( (unsigned) aFieldNdx < m_Fields.size() )
|
||||
field = &m_Fields[aFieldNdx];
|
||||
else
|
||||
field = NULL;
|
||||
|
||||
return m_Field[aFieldNdx].m_Text;
|
||||
wxASSERT( field );
|
||||
|
||||
// use case to remove const-ness
|
||||
return (SCH_CMP_FIELD*) field;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos ) :
|
||||
SCH_ITEM( NULL, TYPE_SCH_COMPONENT )
|
||||
/*******************************************************************/
|
||||
/******************************************************************/
|
||||
void SCH_COMPONENT::AddField( const SCH_CMP_FIELD& aField )
|
||||
/******************************************************************/
|
||||
{
|
||||
int ii;
|
||||
|
||||
m_Multi = 0; /* In multi unit chip - which unit to draw. */
|
||||
|
||||
m_Pos = aPos;
|
||||
|
||||
m_Convert = 0; /* De Morgan Handling */
|
||||
|
||||
/* The rotation/mirror transformation matrix. pos normal*/
|
||||
m_Transform[0][0] = 1;
|
||||
m_Transform[0][1] = 0;
|
||||
m_Transform[1][0] = 0;
|
||||
m_Transform[1][1] = -1;
|
||||
|
||||
/* initialisation des Fields */
|
||||
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
|
||||
{
|
||||
m_Field[ii].m_Pos = m_Pos;
|
||||
m_Field[ii].SetLayer( LAYER_FIELDS );
|
||||
m_Field[ii].m_FieldId = REFERENCE + ii;
|
||||
m_Field[ii].m_Parent = this;
|
||||
}
|
||||
|
||||
m_Field[VALUE].SetLayer( LAYER_VALUEPART );
|
||||
m_Field[REFERENCE].SetLayer( LAYER_REFERENCEPART );
|
||||
|
||||
m_PrefixString = wxString( _( "U" ) );
|
||||
m_Fields.push_back( aField );
|
||||
}
|
||||
|
||||
|
||||
|
@ -380,10 +397,10 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem )
|
|||
EXCHG( m_Transform[0][1], copyitem->m_Transform[0][1] );
|
||||
EXCHG( m_Transform[1][0], copyitem->m_Transform[1][0] );
|
||||
EXCHG( m_Transform[1][1], copyitem->m_Transform[1][1] );
|
||||
for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
|
||||
{
|
||||
m_Field[ii].SwapData( ©item->m_Field[ii] );
|
||||
}
|
||||
|
||||
SCH_CMP_FIELDS tmp = copyitem->m_Fields;
|
||||
copyitem->m_Fields = m_Fields;
|
||||
m_Fields = tmp;
|
||||
}
|
||||
|
||||
|
||||
|
@ -471,7 +488,7 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
|
|||
// When a clear annotation is made, the calling function must call a
|
||||
// UpdateAllScreenReferences for the active sheet.
|
||||
// But this call cannot made here.
|
||||
m_Field[REFERENCE].m_Text = defRef; //for drawing.
|
||||
m_Fields[REFERENCE].m_Text = defRef; //for drawing.
|
||||
|
||||
}
|
||||
|
||||
|
@ -480,9 +497,9 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
|
|||
SCH_COMPONENT* SCH_COMPONENT::GenCopy()
|
||||
/**************************************************************/
|
||||
{
|
||||
SCH_COMPONENT* new_item = new SCH_COMPONENT( m_Pos );
|
||||
|
||||
int ii;
|
||||
#if 0
|
||||
SCH_COMPONENT* new_item = new SCH_COMPONENT( m_Pos );
|
||||
|
||||
new_item->m_Multi = m_Multi;
|
||||
new_item->m_ChipName = m_ChipName;
|
||||
|
@ -495,12 +512,11 @@ SCH_COMPONENT* SCH_COMPONENT::GenCopy()
|
|||
new_item->m_Transform[1][1] = m_Transform[1][1];
|
||||
new_item->m_TimeStamp = m_TimeStamp;
|
||||
|
||||
new_item->m_Fields = m_Fields;
|
||||
#else
|
||||
SCH_COMPONENT* new_item = new SCH_COMPONENT( *this );
|
||||
|
||||
/* initialisation des Fields */
|
||||
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
|
||||
{
|
||||
m_Field[ii].PartTextCopy( &new_item->m_Field[ii] );
|
||||
}
|
||||
#endif
|
||||
|
||||
return new_item;
|
||||
}
|
||||
|
@ -752,9 +768,9 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
|
|||
"/>\n";
|
||||
|
||||
// skip the reference, it's been output already.
|
||||
for( int i = 1; i<NUMBER_OF_FIELDS; ++i )
|
||||
for( int i = 1; i<GetFieldCount(); ++i )
|
||||
{
|
||||
wxString value = GetFieldValue( i );
|
||||
wxString value = GetField( i )->m_Text;
|
||||
|
||||
if( !value.IsEmpty() )
|
||||
{
|
||||
|
@ -775,17 +791,11 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
|
|||
/****************************************/
|
||||
bool SCH_COMPONENT::Save( FILE* f ) 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.
|
||||
*/
|
||||
{
|
||||
int ii, Success = true;
|
||||
char Name1[256], Name2[256];
|
||||
wxArrayString reference_fields;
|
||||
|
||||
static wxString delimiters( wxT( " " ) );
|
||||
|
||||
//this is redundant with the AR entries below, but it makes the
|
||||
|
@ -797,10 +807,10 @@ bool SCH_COMPONENT::Save( FILE* f ) const
|
|||
}
|
||||
else
|
||||
{
|
||||
if( m_Field[REFERENCE].m_Text.IsEmpty() )
|
||||
if( GetField(REFERENCE)->m_Text.IsEmpty() )
|
||||
strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof(Name1) );
|
||||
else
|
||||
strncpy( Name1, CONV_TO_UTF8( m_Field[REFERENCE].m_Text ), sizeof(Name1) );
|
||||
strncpy( Name1, CONV_TO_UTF8( GetField(REFERENCE)->m_Text ), sizeof(Name1) );
|
||||
}
|
||||
for( ii = 0; ii < (int) strlen( Name1 ); ii++ )
|
||||
{
|
||||
|
@ -870,14 +880,25 @@ bool SCH_COMPONENT::Save( FILE* f ) const
|
|||
}
|
||||
}
|
||||
|
||||
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
|
||||
for( int fieldNdx=0; fieldNdx<GetFieldCount(); ++fieldNdx )
|
||||
{
|
||||
const SCH_CMP_FIELD* field = &m_Field[ii];
|
||||
if( field->m_Text.IsEmpty() )
|
||||
SCH_CMP_FIELD* field = GetField( fieldNdx );
|
||||
|
||||
wxString defaultName = ReturnDefaultFieldName( fieldNdx );
|
||||
|
||||
// only save the field if there is a value in the field or if field name
|
||||
// is different than the default field name
|
||||
if( field->m_Text.IsEmpty() && defaultName == field->m_Name )
|
||||
continue;
|
||||
|
||||
// re-number the fields on disk so they are contiguously numbered.
|
||||
// The field index is probably not needed long term.
|
||||
field->m_FieldId = fieldNdx;
|
||||
|
||||
if( !field->Save( f ) )
|
||||
{
|
||||
Success = false; break;
|
||||
Success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -914,9 +935,9 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox()
|
|||
EDA_Rect bbox = GetBoundaryBox();
|
||||
|
||||
// Include BoundingBoxes of fields
|
||||
for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ )
|
||||
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
||||
{
|
||||
bbox.Merge( m_Field[ii].GetBoundaryBox() );
|
||||
bbox.Merge( GetField(ii)->GetBoundaryBox() );
|
||||
}
|
||||
|
||||
// ... add padding
|
||||
|
|
|
@ -16,8 +16,49 @@
|
|||
|
||||
#include "class_sch_cmp_field.h"
|
||||
|
||||
|
||||
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
|
||||
* describes a real schematic component
|
||||
|
@ -33,25 +74,30 @@ public:
|
|||
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 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_Transform[2][2]; /* The rotation/mirror transformation matrix. */
|
||||
|
||||
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.
|
||||
* format is
|
||||
* path reference multi
|
||||
* with:
|
||||
* path = /<timestamp1>/<timestamp2> (subsheet path, = / for the root scheet)
|
||||
* reference = reference for this path (C23, R5, U78 ... )
|
||||
* multi = part selection in multi parts per package (0 or 1 for àne part per package)
|
||||
* format is
|
||||
* path reference multi
|
||||
* with:
|
||||
* path = /<timestamp1>/<timestamp2> (subsheet path, = / for the root scheet)
|
||||
* reference = reference for this path (C23, R5, U78 ... )
|
||||
* multi = part selection in multi parts per package (0 or 1 for àne part per package)
|
||||
*/
|
||||
wxArrayString m_PathsAndReferences;
|
||||
|
||||
public:
|
||||
SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||
SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_ITEM* aParent = NULL );
|
||||
~SCH_COMPONENT() { }
|
||||
|
||||
virtual wxString GetClass() const
|
||||
|
@ -68,11 +114,23 @@ public:
|
|||
*/
|
||||
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();
|
||||
void SetRotationMiroir( int type );
|
||||
int GetRotationMiroir();
|
||||
wxPoint GetScreenCoord( const wxPoint& coord );
|
||||
void Display_Infos( WinEDA_DrawFrame* frame );
|
||||
|
||||
/**
|
||||
* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1)
|
||||
* @param aSheet: DrawSheetPath value: if NULL remove all annotations,
|
||||
|
@ -83,17 +141,34 @@ public:
|
|||
EDA_Rect GetBoundaryBox() const;
|
||||
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 GetFieldValue
|
||||
* returns a reference to the field value.
|
||||
* @param aFieldNdx An index into the array of fields, 0 - FIELD8
|
||||
* @return const wxString& - the field value or wxEmptyString
|
||||
* 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
|
||||
*/
|
||||
const wxString& GetFieldValue( int aFieldNdx ) const;
|
||||
SCH_CMP_FIELD* GetField( int aFieldNdx ) const;
|
||||
|
||||
/**
|
||||
* Function AddField
|
||||
* adds a field to the component. The component takes over ownership
|
||||
* of the field.
|
||||
* @param aField A const reference to the SCH_CMP_FIELD to add.
|
||||
*/
|
||||
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,
|
||||
wxDC* DC,
|
||||
|
@ -109,18 +184,24 @@ public:
|
|||
//returns a unique ID, in the form of a path.
|
||||
wxString GetPath( DrawSheetPath* sheet );
|
||||
//returns the reference, for the given sheet path.
|
||||
|
||||
const wxString GetRef( DrawSheetPath* sheet );
|
||||
|
||||
//Set the reference, for the given sheet path.
|
||||
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 aRef = local reference like C45, R56
|
||||
* @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 );
|
||||
|
||||
//returns the unit selection, for the given sheet path.
|
||||
int GetUnitSelection( DrawSheetPath* aSheet );
|
||||
|
||||
//Set the unit selection, for the given sheet path.
|
||||
void SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection );
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ SCH_ITEM * WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Includ
|
|||
if( LibItem )
|
||||
Affiche_1_Parametre( this, 1,
|
||||
LibItem->GetRef(GetSheet()),
|
||||
LibItem->m_Field[VALUE].m_Text,
|
||||
LibItem->GetField(VALUE)->m_Text,
|
||||
CYAN );
|
||||
|
||||
// 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
|
|||
if( LibItem )
|
||||
Affiche_1_Parametre( this, 1,
|
||||
LibItem->GetRef(GetSheet()),
|
||||
LibItem->m_Field[VALUE].m_Text,
|
||||
LibItem->GetField(VALUE)->m_Text,
|
||||
CYAN );
|
||||
}
|
||||
else
|
||||
|
@ -182,7 +182,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
|
|||
if( LibItem )
|
||||
Affiche_1_Parametre( this, 1,
|
||||
LibItem->GetRef(GetSheet()),
|
||||
LibItem->m_Field[VALUE].m_Text,
|
||||
LibItem->GetField(VALUE)->m_Text,
|
||||
CYAN );
|
||||
if( IncludePin == TRUE )
|
||||
return LibItem;
|
||||
|
|
|
@ -109,14 +109,14 @@ void WinEDA_SchematicFrame::SendMessageToPCBNEW( EDA_BaseStruct* objectT
|
|||
{
|
||||
if( LibItem == NULL )
|
||||
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 );
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_SCH_COMPONENT:
|
||||
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 );
|
||||
break;
|
||||
|
||||
|
@ -130,10 +130,10 @@ void WinEDA_SchematicFrame::SendMessageToPCBNEW( EDA_BaseStruct* objectT
|
|||
wxString pinnum;
|
||||
Pin->ReturnPinStringNum( 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
|
||||
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 );
|
||||
break;
|
||||
|
|
|
@ -75,7 +75,7 @@ void WinEDA_ComponentPropertiesFrame::InitBuffers()
|
|||
m_CurrentFieldId = REFERENCE;
|
||||
|
||||
/* 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_FieldFlags[ii] = 1;
|
||||
|
@ -88,20 +88,21 @@ void WinEDA_ComponentPropertiesFrame::InitBuffers()
|
|||
for( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ )
|
||||
{
|
||||
m_FieldName[ii] = m_Cmp->ReturnFieldName( ii );
|
||||
if(ii == REFERENCE)
|
||||
m_FieldText[ii] = m_Cmp->GetRef(m_Parent->GetSheet());
|
||||
else
|
||||
m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text;
|
||||
m_FieldSize[ii] = m_Cmp->m_Field[ii].m_Size.x;
|
||||
m_FieldFlags[ii] =
|
||||
(m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1;
|
||||
m_FieldOrient[ii] = m_Cmp->m_Field[ii].m_Orient == TEXT_ORIENT_VERT ? 1 : 0;
|
||||
|
||||
if( m_Cmp->m_Field[ii].m_Text.IsEmpty() )
|
||||
if(ii == REFERENCE)
|
||||
m_FieldText[ii] = m_Cmp->GetRef( m_Parent->GetSheet() );
|
||||
else
|
||||
m_FieldText[ii] = m_Cmp->GetField( ii )->m_Text;
|
||||
|
||||
m_FieldSize[ii] = m_Cmp->GetField( ii )->m_Size.x;
|
||||
m_FieldFlags[ii] = (m_Cmp->GetField( ii )->m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1;
|
||||
m_FieldOrient[ii] = m_Cmp->GetField( ii )->m_Orient == TEXT_ORIENT_VERT ? 1 : 0;
|
||||
|
||||
if( m_Cmp->GetField( ii )->m_Text.IsEmpty() )
|
||||
continue;
|
||||
|
||||
// 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].y -= m_Cmp->m_Pos.y;
|
||||
}
|
||||
|
@ -403,30 +404,30 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent&
|
|||
EDA_LibComponentStruct* Entry = FindLibPart( m_Cmp->m_ChipName.GetData(
|
||||
), wxEmptyString, FIND_ROOT );
|
||||
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() )
|
||||
{
|
||||
m_Cmp->m_Field[ii].m_Text = m_FieldText[ii];
|
||||
m_Cmp->GetField( ii )->m_Text = m_FieldText[ii];
|
||||
}
|
||||
}
|
||||
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 ) )
|
||||
m_Cmp->m_Field[ii].m_Name = m_FieldName[ii];
|
||||
m_Cmp->GetField( ii )->m_Name = m_FieldName[ii];
|
||||
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->m_Field[ii].m_Size.y = m_FieldSize[ii];
|
||||
m_Cmp->GetField( ii )->m_Size.x =
|
||||
m_Cmp->GetField( ii )->m_Size.y = m_FieldSize[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
|
||||
m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE;
|
||||
m_Cmp->m_Field[ii].m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
|
||||
m_Cmp->m_Field[ii].m_Pos = m_FieldPosition[ii];
|
||||
m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x;
|
||||
m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y;
|
||||
m_Cmp->GetField( ii )->m_Attributs |= TEXT_NO_VISIBLE;
|
||||
m_Cmp->GetField( ii )->m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
|
||||
m_Cmp->GetField( ii )->m_Pos = m_FieldPosition[ii];
|
||||
m_Cmp->GetField( ii )->m_Pos.x += cmp_pos.x;
|
||||
m_Cmp->GetField( ii )->m_Pos.y += cmp_pos.y;
|
||||
}
|
||||
|
||||
m_Parent->GetScreen()->SetModify();
|
||||
|
@ -764,10 +765,10 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
|
|||
SaveCopyInUndoList( Cmp, IS_CHANGED );
|
||||
Cmp->SetRef(GetSheet(), ref);
|
||||
|
||||
Cmp->m_Field[REFERENCE].m_AddExtraText = flag;
|
||||
Cmp->m_Field[REFERENCE].Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
||||
Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
|
||||
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
||||
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 );
|
||||
GetScreen()->SetModify();
|
||||
}
|
||||
|
@ -790,7 +791,7 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
|
|||
if( Entry == NULL )
|
||||
return;
|
||||
|
||||
SCH_CMP_FIELD* TextField = &Cmp->m_Field[VALUE];
|
||||
SCH_CMP_FIELD* TextField = Cmp->GetField( VALUE );
|
||||
|
||||
message = TextField->m_Text;
|
||||
if( Get_Message( _( "Value" ), _("Component Value"), message, this ) )
|
||||
|
@ -827,35 +828,39 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
|
|||
if( Entry == NULL )
|
||||
return;
|
||||
|
||||
SCH_CMP_FIELD* TextField = &Cmp->m_Field[FOOTPRINT];
|
||||
SCH_CMP_FIELD* TextField = Cmp->GetField( FOOTPRINT );
|
||||
|
||||
message = TextField->m_Text;
|
||||
if(message.IsEmpty() )
|
||||
wasEmpty = true;
|
||||
if( Get_Message( _( "Footprint" ), _("Component Footprint"), message, this ) )
|
||||
message.Empty(); //allow the user to remove the value.
|
||||
|
||||
/* save old cmp in undo list if not already in edit, or moving ... */
|
||||
if( Get_Message( _( "Footprint" ), _("Component Footprint"), message, this ) )
|
||||
message.Empty(); // allow the user to remove the value.
|
||||
|
||||
// save old cmp in undo list if not already in edit, or moving ...
|
||||
if( Cmp->m_Flags == 0 )
|
||||
SaveCopyInUndoList( Cmp, IS_CHANGED );
|
||||
Cmp->m_Field[FOOTPRINT].Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
||||
//move the field if it was new.
|
||||
if(wasEmpty && !message.IsEmpty())
|
||||
{
|
||||
Cmp->m_Field[FOOTPRINT].m_Pos = Cmp->m_Field[REFERENCE].m_Pos;
|
||||
//add offset here - ? suitable heuristic below?
|
||||
Cmp->m_Field[FOOTPRINT].m_Pos.x +=
|
||||
(Cmp->m_Field[REFERENCE].m_Pos.x - Cmp->m_Pos.x) > 0 ?
|
||||
(Cmp->m_Field[REFERENCE].m_Size.x) : (-1*Cmp->m_Field[REFERENCE].m_Size.x);
|
||||
Cmp->m_Field[FOOTPRINT].m_Pos.y +=
|
||||
(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 )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
||||
|
||||
Cmp->m_Field[FOOTPRINT].m_Orient = Cmp->m_Field[REFERENCE].m_Orient;
|
||||
// move the field if it was new.
|
||||
if( wasEmpty && !message.IsEmpty() )
|
||||
{
|
||||
Cmp->GetField( FOOTPRINT )->m_Pos = Cmp->GetField( REFERENCE )->m_Pos;
|
||||
|
||||
// add offset here - ? suitable heuristic below?
|
||||
Cmp->GetField( FOOTPRINT )->m_Pos.x +=
|
||||
(Cmp->GetField( REFERENCE )->m_Pos.x - Cmp->m_Pos.x) > 0 ?
|
||||
(Cmp->GetField( REFERENCE )->m_Size.x) : (-1*Cmp->GetField( REFERENCE )->m_Size.x);
|
||||
|
||||
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->GetField( FOOTPRINT )->m_Orient = Cmp->GetField( REFERENCE )->m_Orient;
|
||||
}
|
||||
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 );
|
||||
GetScreen()->SetModify();
|
||||
|
||||
|
@ -885,23 +890,23 @@ void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event )
|
|||
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );
|
||||
|
||||
/* 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;
|
||||
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;
|
||||
m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient;
|
||||
m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size;
|
||||
m_Cmp->m_Field[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_Orient = Entry->m_Prefix.m_Orient;
|
||||
m_Cmp->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size;
|
||||
m_Cmp->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify;
|
||||
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;
|
||||
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;
|
||||
m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient;
|
||||
m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size;
|
||||
m_Cmp->m_Field[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_Orient = Entry->m_Name.m_Orient;
|
||||
m_Cmp->GetField( VALUE )->m_Size = Entry->m_Name.m_Size;
|
||||
m_Cmp->GetField( VALUE )->m_HJustify = Entry->m_Name.m_HJustify;
|
||||
m_Cmp->GetField( VALUE )->m_VJustify = Entry->m_Name.m_VJustify;
|
||||
|
||||
m_Cmp->SetRotationMiroir( CMP_NORMAL );
|
||||
|
||||
|
|
|
@ -185,7 +185,8 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|||
bool dummy = FALSE;
|
||||
|
||||
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;
|
||||
if( DummyCmp == NULL )
|
||||
CreateDummyCmp();
|
||||
|
@ -202,26 +203,31 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|||
* composant
|
||||
*/
|
||||
|
||||
if( ( (m_Field[REFERENCE].m_Attributs & TEXT_NO_VISIBLE) == 0 )
|
||||
&& !(m_Field[REFERENCE].m_Flags & IS_MOVED) )
|
||||
SCH_CMP_FIELD* field = GetField( REFERENCE );
|
||||
|
||||
if( ( (field->m_Attributs & TEXT_NO_VISIBLE) == 0 )
|
||||
&& !(field->m_Flags & IS_MOVED) )
|
||||
{
|
||||
if( Entry->m_UnitCount > 1 )
|
||||
{
|
||||
m_Field[REFERENCE].m_AddExtraText = true;
|
||||
m_Field[REFERENCE].Draw( panel, DC, offset, DrawMode );
|
||||
field->m_AddExtraText = true;
|
||||
field->Draw( panel, DC, offset, DrawMode );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Field[REFERENCE].m_AddExtraText = false;
|
||||
m_Field[REFERENCE].Draw( panel, DC, offset, DrawMode );
|
||||
field->m_AddExtraText = false;
|
||||
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;
|
||||
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,
|
|||
|
||||
if( m_Attributs & TEXT_NO_VISIBLE )
|
||||
return;
|
||||
|
||||
if( IsVoid() )
|
||||
return;
|
||||
|
||||
|
@ -290,6 +297,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel,
|
|||
color = ReturnLayerColor( LAYER_VALUEPART );
|
||||
else
|
||||
color = ReturnLayerColor( LAYER_FIELDS );
|
||||
|
||||
if( !m_AddExtraText || (m_FieldId != REFERENCE) )
|
||||
{
|
||||
DrawGraphicText( panel, DC, pos, color, m_Text.GetData(),
|
||||
|
@ -302,6 +310,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel,
|
|||
/* On ajoute alors A ou B ... a la reference */
|
||||
wxString fulltext = m_Text;
|
||||
fulltext.Append( 'A' - 1 + DrawLibItem->m_Multi );
|
||||
|
||||
DrawGraphicText( panel, DC, pos, color, fulltext.GetData(),
|
||||
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
|
||||
m_Size,
|
||||
|
@ -446,13 +455,13 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
|
|||
int x2 = BoundaryBox.GetRight();
|
||||
int y2 = BoundaryBox.GetBottom();
|
||||
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
|
||||
BoundaryBox = Component->m_Field[REFERENCE].GetBoundaryBox();
|
||||
BoundaryBox = Component->GetField( REFERENCE )->GetBoundaryBox();
|
||||
x1 = BoundaryBox.GetX();
|
||||
y1 = BoundaryBox.GetY();
|
||||
x2 = BoundaryBox.GetRight();
|
||||
y2 = BoundaryBox.GetBottom();
|
||||
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
|
||||
BoundaryBox = Component->m_Field[VALUE].GetBoundaryBox();
|
||||
BoundaryBox = Component->GetField( VALUE )->GetBoundaryBox();
|
||||
x1 = BoundaryBox.GetX();
|
||||
y1 = BoundaryBox.GetY();
|
||||
x2 = BoundaryBox.GetRight();
|
||||
|
|
|
@ -117,15 +117,15 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem(
|
|||
|
||||
case 2: // find reference
|
||||
NotFound = FALSE;
|
||||
pos = pSch->m_Field[REFERENCE].m_Pos;
|
||||
pos = pSch->GetField( REFERENCE )->m_Pos;
|
||||
break;
|
||||
|
||||
case 3: // find value
|
||||
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;
|
||||
NotFound = FALSE;
|
||||
pos = pSch->m_Field[VALUE].m_Pos;
|
||||
pos = pSch->GetField( VALUE )->m_Pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -469,13 +469,13 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem(
|
|||
if( WildCompareString( WildText, pSch->GetRef(Sheet), FALSE ) )
|
||||
{
|
||||
NotFound = FALSE;
|
||||
pos = pSch->m_Field[REFERENCE].m_Pos;
|
||||
pos = pSch->GetField( REFERENCE )->m_Pos;
|
||||
break;
|
||||
}
|
||||
if( WildCompareString( WildText, pSch->m_Field[VALUE].m_Text, FALSE ) )
|
||||
if( WildCompareString( WildText, pSch->GetField( VALUE )->m_Text, FALSE ) )
|
||||
{
|
||||
NotFound = FALSE;
|
||||
pos = pSch->m_Field[VALUE].m_Pos;
|
||||
pos = pSch->GetField( VALUE )->m_Pos;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -186,16 +186,16 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
|
|||
DrawLibItem->m_Flags = IS_NEW | IS_MOVED;
|
||||
|
||||
/* 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;
|
||||
DrawLibItem->m_Field[VALUE].m_Pos.y =
|
||||
DrawLibItem->GetField( VALUE )->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->m_Field[VALUE].m_Size = Entry->m_Name.m_Size;
|
||||
DrawLibItem->m_Field[VALUE].m_Text = DrawLibItem->m_ChipName;
|
||||
DrawLibItem->m_Field[VALUE].m_Attributs = Entry->m_Name.m_Attributs;
|
||||
DrawLibItem->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify;
|
||||
DrawLibItem->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify;
|
||||
DrawLibItem->GetField( VALUE )->m_Orient = Entry->m_Name.m_Orient;
|
||||
DrawLibItem->GetField( VALUE )->m_Size = Entry->m_Name.m_Size;
|
||||
DrawLibItem->GetField( VALUE )->m_Text = DrawLibItem->m_ChipName;
|
||||
DrawLibItem->GetField( VALUE )->m_Attributs = Entry->m_Name.m_Attributs;
|
||||
DrawLibItem->GetField( VALUE )->m_HJustify = Entry->m_Name.m_HJustify;
|
||||
DrawLibItem->GetField( VALUE )->m_VJustify = Entry->m_Name.m_VJustify;
|
||||
|
||||
msg = Entry->m_Prefix.m_Text;
|
||||
if( msg.IsEmpty() )
|
||||
|
@ -206,36 +206,41 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
|
|||
DrawLibItem->SetRef(GetSheet(), msg );
|
||||
|
||||
/* 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;
|
||||
DrawLibItem->m_Field[REFERENCE].m_Pos.y =
|
||||
DrawLibItem->GetField( REFERENCE )->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->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size;
|
||||
DrawLibItem->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient;
|
||||
DrawLibItem->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size;
|
||||
DrawLibItem->m_PrefixString = Entry->m_Prefix.m_Text;
|
||||
DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs;
|
||||
DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify;
|
||||
DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify;
|
||||
DrawLibItem->GetField( REFERENCE )->m_Attributs = Entry->m_Prefix.m_Attributs;
|
||||
DrawLibItem->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify;
|
||||
DrawLibItem->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify;
|
||||
|
||||
/* Init des autres champs si predefinis dans la librairie */
|
||||
for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext )
|
||||
{
|
||||
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
|
||||
continue;
|
||||
|
||||
ii = Field->m_FieldId;
|
||||
if( ii < 2 )
|
||||
continue;
|
||||
if( ii >= NUMBER_OF_FIELDS )
|
||||
|
||||
if( ii >= DrawLibItem->GetFieldCount() )
|
||||
continue;
|
||||
DrawLibItem->m_Field[ii].m_Pos.x += Field->m_Pos.x;
|
||||
DrawLibItem->m_Field[ii].m_Pos.y += Field->m_Pos.y;
|
||||
DrawLibItem->m_Field[ii].m_Size = Field->m_Size;
|
||||
DrawLibItem->m_Field[ii].m_Attributs = Field->m_Attributs;
|
||||
DrawLibItem->m_Field[ii].m_Orient = Field->m_Orient;
|
||||
DrawLibItem->m_Field[ii].m_Text = Field->m_Text;
|
||||
DrawLibItem->m_Field[ii].m_Name = Field->m_Name;
|
||||
DrawLibItem->m_Field[ii].m_HJustify = Field->m_HJustify;
|
||||
DrawLibItem->m_Field[ii].m_VJustify = Field->m_VJustify;
|
||||
|
||||
SCH_CMP_FIELD* f = DrawLibItem->GetField( ii );
|
||||
|
||||
f->m_Pos.x += Field->m_Pos.x;
|
||||
f->m_Pos.y += Field->m_Pos.y;
|
||||
f->m_Size = Field->m_Size;
|
||||
f->m_Attributs = Field->m_Attributs;
|
||||
f->m_Orient = Field->m_Orient;
|
||||
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 );
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
/****************************************/
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
//#include "gr_basic.h"
|
||||
|
||||
#include "common.h"
|
||||
|
@ -58,7 +59,7 @@
|
|||
|
||||
/* Fonctions locales */
|
||||
static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window );
|
||||
static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window);
|
||||
static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window );
|
||||
static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window );
|
||||
static void LoadLayers( FILE* f, int* linecnt );
|
||||
|
||||
|
@ -118,20 +119,24 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
fclose( f );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//get the file version here. TODO: Support version numbers > 9
|
||||
char version = Line[9 + sizeof(SCHEMATIC_HEAD_STRING)];
|
||||
int ver = version - '0';
|
||||
if ( ver > EESCHEMA_VERSION )
|
||||
int ver = version - '0';
|
||||
if( ver > EESCHEMA_VERSION )
|
||||
{
|
||||
MsgDiag = FullFileName + _( " was created by a more recent version of EESchema and may not load correctly. Please consider updating!");
|
||||
DisplayInfo( this, MsgDiag);
|
||||
MsgDiag = FullFileName + _(
|
||||
" was created by a more recent version of EESchema and may not load correctly. Please consider updating!" );
|
||||
DisplayInfo( this, MsgDiag );
|
||||
}
|
||||
#if 0
|
||||
|
||||
// Compile it if the new versiopn is unreadable by previous eeschema versions
|
||||
else if ( ver < EESCHEMA_VERSION )
|
||||
else if( ver < EESCHEMA_VERSION )
|
||||
{
|
||||
MsgDiag = FullFileName + _( " was created by an older version of EESchema. It will be stored in the new file format when you save this file again.");
|
||||
DisplayInfo( this, MsgDiag);
|
||||
MsgDiag = FullFileName + _(
|
||||
" was created by an older version of EESchema. It will be stored in the new file format when you save this file again." );
|
||||
DisplayInfo( this, MsgDiag );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -194,14 +199,14 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
LineCount++;
|
||||
if( fgets( Line, 256 - 1, f ) == NULL
|
||||
|| sscanf( Line, "%d %d %d %d ",
|
||||
&SegmentStruct->m_Start.x, &SegmentStruct->m_Start.y,
|
||||
&SegmentStruct->m_End.x, &SegmentStruct->m_End.y ) != 4 )
|
||||
&SegmentStruct->m_Start.x, &SegmentStruct->m_Start.y,
|
||||
&SegmentStruct->m_End.x, &SegmentStruct->m_End.y ) != 4 )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( "EESchema file Segment struct error at line %d, aborted" ),
|
||||
LineCount );
|
||||
Failed = TRUE;
|
||||
SAFE_DELETE( SegmentStruct ) ;
|
||||
SAFE_DELETE( SegmentStruct );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -227,17 +232,18 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
if( Name1[0] == 'B' )
|
||||
ii = BUS_TO_BUS;
|
||||
RaccordStruct = new DrawBusEntryStruct( wxPoint( 0, 0 ), '\\', ii );
|
||||
|
||||
LineCount++;
|
||||
if( fgets( Line, 256 - 1, f ) == NULL
|
||||
|| sscanf( Line, "%d %d %d %d ",
|
||||
&RaccordStruct->m_Pos.x, &RaccordStruct->m_Pos.y,
|
||||
&RaccordStruct->m_Size.x, &RaccordStruct->m_Size.y ) != 4 )
|
||||
&RaccordStruct->m_Pos.x, &RaccordStruct->m_Pos.y,
|
||||
&RaccordStruct->m_Size.x, &RaccordStruct->m_Size.y ) != 4 )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( "EESchema file Raccord struct error at line %d, aborted" ),
|
||||
LineCount );
|
||||
Failed = TRUE;
|
||||
SAFE_DELETE( RaccordStruct ) ;
|
||||
SAFE_DELETE( RaccordStruct );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -269,19 +275,19 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
|
||||
PolylineStruct->m_NumOfPoints = ii;
|
||||
PolylineStruct->m_Points = (int*) MyZMalloc( sizeof(int) * 2 *
|
||||
PolylineStruct->m_NumOfPoints );
|
||||
PolylineStruct->m_NumOfPoints );
|
||||
for( ii = 0; ii < PolylineStruct->m_NumOfPoints; ii++ )
|
||||
{
|
||||
LineCount++;
|
||||
if( fgets( Line, 256 - 1, f ) == NULL
|
||||
|| sscanf( Line, "%d %d", &PolylineStruct->m_Points[ii * 2],
|
||||
&PolylineStruct->m_Points[ii * 2 + 1] ) != 2 )
|
||||
&PolylineStruct->m_Points[ii * 2 + 1] ) != 2 )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( "EESchema file polyline struct error at line %d, aborted" ),
|
||||
LineCount );
|
||||
Failed = TRUE;
|
||||
SAFE_DELETE( PolylineStruct ) ;
|
||||
SAFE_DELETE( PolylineStruct );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -295,15 +301,16 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
|
||||
case 'C': /* Its a connection item. */
|
||||
ConnectionStruct = new DrawJunctionStruct( wxPoint( 0, 0 ) );
|
||||
|
||||
if( sscanf( SLine, "%s %d %d", Name1,
|
||||
&ConnectionStruct->m_Pos.x,
|
||||
&ConnectionStruct->m_Pos.y ) != 3 )
|
||||
&ConnectionStruct->m_Pos.x,
|
||||
&ConnectionStruct->m_Pos.y ) != 3 )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( "EESchema file connection struct error at line %d, aborted" ),
|
||||
LineCount );
|
||||
Failed = TRUE;
|
||||
SAFE_DELETE( ConnectionStruct ) ;
|
||||
SAFE_DELETE( ConnectionStruct );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -323,6 +330,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
else
|
||||
{
|
||||
NoConnectStruct = new DrawNoConnectStruct( pos );
|
||||
|
||||
NoConnectStruct->Pnext = screen->EEDrawList;
|
||||
screen->EEDrawList = NoConnectStruct;
|
||||
}
|
||||
|
@ -341,6 +349,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
char* text;
|
||||
char BufLine[1024];
|
||||
MarkerStruct = new DrawMarkerStruct( pos, wxEmptyString );
|
||||
|
||||
ii = ReadDelimitedText( BufLine, Line, 256 );
|
||||
MarkerStruct->m_Type = (TypeMarker) ( (Name1[0] & 255) - 'A' );
|
||||
if( MarkerStruct->m_Type < 0 )
|
||||
|
@ -363,7 +372,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
SCH_ITEM* Struct = NULL;
|
||||
*Name1 = *Name2 = 0;
|
||||
ii = sscanf( SLine, "%s %d %d %d %d %s",
|
||||
Name1, &pos.x, &pos.y, &orient, &size, Name2 );
|
||||
Name1, &pos.x, &pos.y, &orient, &size, Name2 );
|
||||
|
||||
if( ii < 4 )
|
||||
{
|
||||
|
@ -392,18 +401,20 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
if( Name1[0] == 'L' )
|
||||
{
|
||||
SCH_LABEL* TextStruct =
|
||||
new SCH_LABEL( pos, CONV_FROM_UTF8( text ) );
|
||||
new SCH_LABEL( pos, CONV_FROM_UTF8 ( text ) );
|
||||
|
||||
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
|
||||
TextStruct->m_Orient = orient;
|
||||
Struct = TextStruct;
|
||||
}
|
||||
else if( Name1[0] == 'G' && version > '1')
|
||||
else if( Name1[0] == 'G' && version > '1' )
|
||||
{
|
||||
SCH_GLOBALLABEL* TextStruct = new SCH_GLOBALLABEL(pos, CONV_FROM_UTF8( text ) );
|
||||
SCH_GLOBALLABEL* TextStruct = new SCH_GLOBALLABEL( pos, CONV_FROM_UTF8 ( text ) );
|
||||
|
||||
Struct = TextStruct;
|
||||
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
|
||||
TextStruct->m_Orient = orient;
|
||||
TextStruct->m_Shape = NET_INPUT;
|
||||
TextStruct->m_Shape = NET_INPUT;
|
||||
if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 )
|
||||
TextStruct->m_Shape = NET_OUTPUT;
|
||||
if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 )
|
||||
|
@ -413,13 +424,14 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 )
|
||||
TextStruct->m_Shape = NET_UNSPECIFIED;
|
||||
}
|
||||
else if( (Name1[0] == 'H') || (Name1[0] == 'G' && version == '1'))
|
||||
else if( (Name1[0] == 'H') || (Name1[0] == 'G' && version == '1') )
|
||||
{ //in schematic file version 1, glabels were actually hierarchal labels.
|
||||
SCH_HIERLABEL* TextStruct = new SCH_HIERLABEL(pos, CONV_FROM_UTF8( text ) );
|
||||
SCH_HIERLABEL* TextStruct = new SCH_HIERLABEL( pos, CONV_FROM_UTF8 ( text ) );
|
||||
|
||||
Struct = TextStruct;
|
||||
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
|
||||
TextStruct->m_Orient = orient;
|
||||
TextStruct->m_Shape = NET_INPUT;
|
||||
TextStruct->m_Shape = NET_INPUT;
|
||||
if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 )
|
||||
TextStruct->m_Shape = NET_OUTPUT;
|
||||
if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 )
|
||||
|
@ -432,7 +444,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
else
|
||||
{
|
||||
SCH_TEXT* TextStruct =
|
||||
new SCH_TEXT( pos, CONV_FROM_UTF8( text ) );
|
||||
new SCH_TEXT( pos, CONV_FROM_UTF8 ( text ) );
|
||||
|
||||
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
|
||||
TextStruct->m_Orient = orient;
|
||||
Struct = TextStruct;
|
||||
|
@ -473,7 +486,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
|
||||
screen->EEDrawList = Phead;
|
||||
|
||||
#if 0 && defined(DEBUG)
|
||||
#if 0 && defined (DEBUG)
|
||||
screen->Show( 0, std::cout );
|
||||
#endif
|
||||
|
||||
|
@ -481,7 +494,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
|
|||
|
||||
TestDanglingEnds( screen->EEDrawList, NULL );
|
||||
|
||||
MsgDiag = _( "Done Loading " ) + screen->m_FileName;
|
||||
MsgDiag = _( "Done Loading " ) + screen->m_FileName;
|
||||
PrintMsg( MsgDiag );
|
||||
|
||||
return TRUE; /* Although it may be that file is only partially loaded. */
|
||||
|
@ -497,15 +510,16 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
|
|||
* Lit les lignes relatives a la description d'un composant en schema
|
||||
*/
|
||||
{
|
||||
int ii, fieldref;
|
||||
char Name1[256], Name2[256],
|
||||
Char1[256], Char2[256], Char3[256];
|
||||
SCH_COMPONENT* LibItemStruct;
|
||||
int Failed = 0, newfmt = 0;
|
||||
char* ptcar;
|
||||
int ii;
|
||||
char Name1[256], Name2[256],
|
||||
Char1[256], Char2[256], Char3[256];
|
||||
SCH_COMPONENT* component;
|
||||
int Failed = 0, newfmt = 0;
|
||||
char* ptcar;
|
||||
|
||||
LibItemStruct = new SCH_COMPONENT();
|
||||
LibItemStruct->m_Convert = 1;
|
||||
component = new SCH_COMPONENT();
|
||||
|
||||
component->m_Convert = 1;
|
||||
|
||||
if( Line[0] == '$' )
|
||||
{
|
||||
|
@ -531,49 +545,60 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
|
|||
if( Name1[ii] == '~' )
|
||||
Name1[ii] = ' ';
|
||||
|
||||
LibItemStruct->m_ChipName = CONV_FROM_UTF8( Name1 );
|
||||
component->m_ChipName = CONV_FROM_UTF8( Name1 );
|
||||
if( !newfmt )
|
||||
LibItemStruct->m_Field[VALUE].m_Text = CONV_FROM_UTF8( Name1 );
|
||||
component->GetField( VALUE )->m_Text = CONV_FROM_UTF8( Name1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
LibItemStruct->m_ChipName.Empty();
|
||||
LibItemStruct->m_Field[VALUE].m_Text.Empty();
|
||||
LibItemStruct->m_Field[VALUE].m_Orient = TEXT_ORIENT_HORIZ;
|
||||
LibItemStruct->m_Field[VALUE].m_Attributs = TEXT_NO_VISIBLE;
|
||||
component->m_ChipName.Empty();
|
||||
component->GetField( VALUE )->m_Text.Empty();
|
||||
component->GetField( VALUE )->m_Orient = TEXT_ORIENT_HORIZ;
|
||||
component->GetField( VALUE )->m_Attributs = TEXT_NO_VISIBLE;
|
||||
}
|
||||
|
||||
if( strcmp( Name2, NULL_STRING ) != 0 )
|
||||
{
|
||||
bool isDigit = false;
|
||||
for( ii = 0; ii < (int) strlen( Name2 ); ii++ ){
|
||||
for( ii = 0; ii < (int) strlen( Name2 ); ii++ )
|
||||
{
|
||||
if( Name2[ii] == '~' )
|
||||
Name2[ii] = ' ';
|
||||
//get RefBase from this, too. store in Name1.
|
||||
if(Name2[ii] >= '0' && Name2[ii] <= '9'){
|
||||
isDigit = true;
|
||||
|
||||
// get RefBase from this, too. store in Name1.
|
||||
if( Name2[ii] >= '0' && Name2[ii] <= '9' )
|
||||
{
|
||||
isDigit = true;
|
||||
Name1[ii] = 0; //null-terminate.
|
||||
}
|
||||
if(!isDigit){
|
||||
if( !isDigit )
|
||||
{
|
||||
Name1[ii] = Name2[ii];
|
||||
}
|
||||
}
|
||||
|
||||
Name1[ii] = 0; //just in case
|
||||
int jj;
|
||||
for(jj=0; jj<ii && Name1[jj] == ' '; jj++);
|
||||
if(jj == ii){
|
||||
//blank string.
|
||||
LibItemStruct->m_PrefixString = wxT("U");
|
||||
}else{
|
||||
LibItemStruct->m_PrefixString = CONV_FROM_UTF8(&Name1[jj]);
|
||||
//printf("prefix: %s\n", CONV_TO_UTF8(LibItemStruct->m_PrefixString));
|
||||
int jj;
|
||||
for( jj = 0; jj<ii && Name1[jj] == ' '; jj++ )
|
||||
;
|
||||
|
||||
if( jj == ii )
|
||||
{
|
||||
// blank string.
|
||||
component->m_PrefixString = wxT( "U" );
|
||||
}
|
||||
else
|
||||
{
|
||||
component->m_PrefixString = CONV_FROM_UTF8( &Name1[jj] );
|
||||
|
||||
//printf("prefix: %s\n", CONV_TO_UTF8(component->m_PrefixString));
|
||||
}
|
||||
if( !newfmt )
|
||||
LibItemStruct->m_Field[REFERENCE].m_Text = CONV_FROM_UTF8( Name2 );
|
||||
component->GetField( REFERENCE )->m_Text = CONV_FROM_UTF8( Name2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
LibItemStruct->m_Field[REFERENCE].m_Attributs = TEXT_NO_VISIBLE;
|
||||
component->GetField( REFERENCE )->m_Attributs = TEXT_NO_VISIBLE;
|
||||
}
|
||||
|
||||
/* Traitement des autres lignes de description */
|
||||
|
@ -592,70 +617,68 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
|
|||
LineCount++;
|
||||
if( fgets( Line, 256 - 1, f ) == NULL )
|
||||
return TRUE;
|
||||
if( (Line[0] != 'F' )
|
||||
&& (Line[0] != 'P' )
|
||||
&& (Line[0] != 'A' )
|
||||
&& (Line[0] != 'U' ) )
|
||||
break;
|
||||
|
||||
if( Line[0] == 'U' ) /* Lecture num multi, conversion et time stamp */
|
||||
{
|
||||
sscanf( Line + 1, "%d %d %lX",
|
||||
&LibItemStruct->m_Multi, &LibItemStruct->m_Convert,
|
||||
&LibItemStruct->m_TimeStamp );
|
||||
&component->m_Multi, &component->m_Convert,
|
||||
&component->m_TimeStamp );
|
||||
}
|
||||
|
||||
if( Line[0] == 'P' )
|
||||
else if( Line[0] == 'P' )
|
||||
{
|
||||
sscanf( Line + 1, "%d %d",
|
||||
&LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y );
|
||||
&component->m_Pos.x, &component->m_Pos.y );
|
||||
}
|
||||
if( Line[0] == 'A' && Line[1] == 'R' )
|
||||
|
||||
else if( Line[0] == 'A' && Line[1] == 'R' )
|
||||
{
|
||||
/*format:
|
||||
AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1"
|
||||
where 9086AF6E is the unique timestamp of the containing sheet
|
||||
and 67452AA0 is the timestamp of this component.
|
||||
C99 is the reference given this path.
|
||||
*/
|
||||
/* format:
|
||||
* AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1"
|
||||
* where 9086AF6E is the unique timestamp of the containing sheet
|
||||
* and 67452AA0 is the timestamp of this component.
|
||||
* C99 is the reference given this path.
|
||||
*/
|
||||
int ii;
|
||||
ptcar = Line + 2;
|
||||
|
||||
//copy the path.
|
||||
ii = ReadDelimitedText(Name1, ptcar, 255 );
|
||||
ptcar += ii+1;
|
||||
wxString path = CONV_FROM_UTF8(Name1);
|
||||
ii = ReadDelimitedText( Name1, ptcar, 255 );
|
||||
ptcar += ii + 1;
|
||||
wxString path = CONV_FROM_UTF8( Name1 );
|
||||
|
||||
// copy the reference
|
||||
ii = ReadDelimitedText(Name1, ptcar, 255 );
|
||||
ptcar += ii+1;
|
||||
wxString ref = CONV_FROM_UTF8(Name1);
|
||||
ii = ReadDelimitedText( Name1, ptcar, 255 );
|
||||
ptcar += ii + 1;
|
||||
wxString ref = CONV_FROM_UTF8( Name1 );
|
||||
|
||||
// copy the multi, if exists
|
||||
ii = ReadDelimitedText(Name1, ptcar, 255 );
|
||||
if ( Name1[0] == 0 ) // Nothing read, put a default value
|
||||
sprintf( Name1, "%d", LibItemStruct->m_Multi );
|
||||
int multi = atoi(Name1);
|
||||
if ( multi < 0 || multi > 25 ) multi = 1;
|
||||
LibItemStruct->AddHierarchicalReference(path, ref, multi);
|
||||
LibItemStruct->m_Field[REFERENCE].m_Text = ref;
|
||||
ii = ReadDelimitedText( Name1, ptcar, 255 );
|
||||
if( Name1[0] == 0 ) // Nothing read, put a default value
|
||||
sprintf( Name1, "%d", component->m_Multi );
|
||||
int multi = atoi( Name1 );
|
||||
if( multi < 0 || multi > 25 )
|
||||
multi = 1;
|
||||
component->AddHierarchicalReference( path, ref, multi );
|
||||
component->GetField( REFERENCE )->m_Text = ref;
|
||||
}
|
||||
if( Line[0] == 'F' )
|
||||
|
||||
else if( Line[0] == 'F' )
|
||||
{
|
||||
int fieldNdx;
|
||||
|
||||
char FieldUserName[1024];
|
||||
int hjustify = GR_TEXT_HJUSTIFY_CENTER;
|
||||
int vjustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||
|
||||
wxString fieldName;
|
||||
|
||||
FieldUserName[0] = 0;
|
||||
|
||||
sscanf( Line + 1, "%d", &fieldref );
|
||||
if( fieldref >= NUMBER_OF_FIELDS )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( "Component Field number error at line %d, aborted" ),
|
||||
LineCount );
|
||||
return TRUE;
|
||||
}
|
||||
/* Lecture du champ */
|
||||
ptcar = Line; while( *ptcar && (*ptcar != '"') )
|
||||
ptcar = Line;
|
||||
|
||||
while( *ptcar && (*ptcar != '"') )
|
||||
ptcar++;
|
||||
|
||||
if( *ptcar != '"' )
|
||||
|
@ -676,23 +699,50 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
|
|||
LineCount );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if( *ptcar == '"' )
|
||||
{
|
||||
Name1[ii] = 0; ptcar++;
|
||||
Name1[ii] = 0;
|
||||
ptcar++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( LibItemStruct->m_Field[fieldref].m_Text.IsEmpty() )
|
||||
LibItemStruct->m_Field[fieldref].m_Text = CONV_FROM_UTF8( Name1 );
|
||||
fieldNdx = atoi( Line+2 );
|
||||
|
||||
ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) );
|
||||
|
||||
if( 0 == strlen(FieldUserName) )
|
||||
fieldName = ReturnDefaultFieldName( fieldNdx );
|
||||
else
|
||||
fieldName = CONV_FROM_UTF8( FieldUserName );
|
||||
|
||||
D(printf("FiledUserName=\"%s\"\n", FieldUserName );)
|
||||
|
||||
if( fieldNdx >= component->GetFieldCount() )
|
||||
{
|
||||
// add as many fields as needed so the m_FieldId's are contiguous, no gaps.
|
||||
while( fieldNdx >= component->GetFieldCount() )
|
||||
{
|
||||
int newNdx = component->GetFieldCount();
|
||||
|
||||
SCH_CMP_FIELD f( wxPoint(0,0), newNdx, component, fieldName );
|
||||
component->AddField( f );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
component->GetField( fieldNdx )->m_Name = fieldName;
|
||||
}
|
||||
|
||||
component->GetField( fieldNdx )->m_Text = CONV_FROM_UTF8( Name1 );
|
||||
|
||||
/* Lecture des coordonnees */
|
||||
if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1,
|
||||
&LibItemStruct->m_Field[fieldref].m_Pos.x,
|
||||
&LibItemStruct->m_Field[fieldref].m_Pos.y,
|
||||
&LibItemStruct->m_Field[fieldref].m_Size.x,
|
||||
&LibItemStruct->m_Field[fieldref].m_Attributs,
|
||||
Char2, Char3 ) ) < 4 )
|
||||
&component->GetField( fieldNdx )->m_Pos.x,
|
||||
&component->GetField( fieldNdx )->m_Pos.y,
|
||||
&component->GetField( fieldNdx )->m_Size.x,
|
||||
&component->GetField( fieldNdx )->m_Attributs,
|
||||
Char2, Char3 ) ) < 4 )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( "Component Field error line %d, aborted" ),
|
||||
|
@ -701,13 +751,15 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
|
|||
continue;
|
||||
}
|
||||
|
||||
ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) );
|
||||
if( (LibItemStruct->m_Field[fieldref].m_Size.x == 0 ) || (ii == 4) )
|
||||
LibItemStruct->m_Field[fieldref].m_Size.x = DEFAULT_SIZE_TEXT;
|
||||
LibItemStruct->m_Field[fieldref].m_Orient = TEXT_ORIENT_HORIZ;
|
||||
LibItemStruct->m_Field[fieldref].m_Size.y = LibItemStruct->m_Field[fieldref].m_Size.x;
|
||||
if( (component->GetField( fieldNdx )->m_Size.x == 0 ) || (ii == 4) )
|
||||
component->GetField( fieldNdx )->m_Size.x = DEFAULT_SIZE_TEXT;
|
||||
|
||||
component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_HORIZ;
|
||||
component->GetField( fieldNdx )->m_Size.y = component->GetField( fieldNdx )->m_Size.x;
|
||||
|
||||
if( Char1[0] == 'V' )
|
||||
LibItemStruct->m_Field[fieldref].m_Orient = TEXT_ORIENT_VERT;
|
||||
component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_VERT;
|
||||
|
||||
if( ii >= 7 )
|
||||
{
|
||||
if( *Char2 == 'L' )
|
||||
|
@ -718,25 +770,23 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
|
|||
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
else if( *Char3 == 'T' )
|
||||
vjustify = GR_TEXT_VJUSTIFY_TOP;
|
||||
LibItemStruct->m_Field[fieldref].m_HJustify = hjustify;
|
||||
LibItemStruct->m_Field[fieldref].m_VJustify = vjustify;
|
||||
|
||||
component->GetField( fieldNdx )->m_HJustify = hjustify;
|
||||
component->GetField( fieldNdx )->m_VJustify = vjustify;
|
||||
}
|
||||
|
||||
if( fieldref >= FIELD1 )
|
||||
{
|
||||
LibItemStruct->m_Field[fieldref].m_Name = CONV_FROM_UTF8( FieldUserName );
|
||||
}
|
||||
|
||||
if( fieldref == REFERENCE )
|
||||
if( LibItemStruct->m_Field[fieldref].m_Text[0] == '#' )
|
||||
LibItemStruct->m_Field[fieldref].m_Attributs |= TEXT_NO_VISIBLE;
|
||||
if( fieldNdx == REFERENCE )
|
||||
if( component->GetField( fieldNdx )->m_Text[0] == '#' )
|
||||
component->GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/* Lecture multi et position du composant */
|
||||
if( sscanf( Line, "%d %d %d",
|
||||
&LibItemStruct->m_Multi,
|
||||
&LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y ) != 3 )
|
||||
&component->m_Multi,
|
||||
&component->m_Pos.x, &component->m_Pos.y ) != 3 )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( "Component unit & pos error at line %d, aborted" ),
|
||||
|
@ -749,10 +799,10 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
|
|||
LineCount++;
|
||||
if( (fgets( Line, 256 - 1, f ) == NULL)
|
||||
|| (sscanf( Line, "%d %d %d %d",
|
||||
&LibItemStruct->m_Transform[0][0],
|
||||
&LibItemStruct->m_Transform[0][1],
|
||||
&LibItemStruct->m_Transform[1][0],
|
||||
&LibItemStruct->m_Transform[1][1] ) != 4) )
|
||||
&component->m_Transform[0][0],
|
||||
&component->m_Transform[0][1],
|
||||
&component->m_Transform[1][0],
|
||||
&component->m_Transform[1][1] ) != 4) )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( "Component orient error at line %d, aborted" ),
|
||||
|
@ -777,9 +827,9 @@ static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
|
|||
|
||||
if( !Failed )
|
||||
{
|
||||
LibItemStruct->Pnext = Window->EEDrawList;
|
||||
Window->EEDrawList = LibItemStruct;
|
||||
LibItemStruct->m_Parent = Window;
|
||||
component->Pnext = Window->EEDrawList;
|
||||
Window->EEDrawList = component;
|
||||
component->m_Parent = Window;
|
||||
}
|
||||
|
||||
return Failed; /* Fin lecture 1 composant */
|
||||
|
@ -794,15 +844,17 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
|
|||
* Lit les lignes relatives a la description d'une feuille de hierarchie
|
||||
*/
|
||||
{
|
||||
int ii, fieldref, size;
|
||||
char Name1[256], Char1[256], Char2[256];
|
||||
DrawSheetStruct* SheetStruct;
|
||||
int ii, fieldNdx, size;
|
||||
char Name1[256], Char1[256], Char2[256];
|
||||
DrawSheetStruct* SheetStruct;
|
||||
Hierarchical_PIN_Sheet_Struct* SheetLabelStruct, * OldSheetLabel = NULL;
|
||||
int Failed = FALSE;
|
||||
char* ptcar;
|
||||
int Failed = FALSE;
|
||||
char* ptcar;
|
||||
|
||||
SheetStruct = new DrawSheetStruct();
|
||||
|
||||
SheetStruct->m_TimeStamp = GetTimeStamp();
|
||||
|
||||
//sheets are added to the EEDrawList like other schematic components.
|
||||
//however, in order to preserve the heirarchy (through m_Parent pointers),
|
||||
//a duplicate of the sheet is added to m_SubSheet array.
|
||||
|
@ -821,8 +873,8 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
|
|||
/* Next line: must be "S xx yy nn mm" with xx, yy = sheet position
|
||||
* ( upper left corner ) et nn,mm = sheet size */
|
||||
if( (sscanf( &Line[1], "%d %d %d %d",
|
||||
&SheetStruct->m_Pos.x, &SheetStruct->m_Pos.y,
|
||||
&SheetStruct->m_Size.x, &SheetStruct->m_Size.y ) != 4)
|
||||
&SheetStruct->m_Pos.x, &SheetStruct->m_Pos.y,
|
||||
&SheetStruct->m_Size.x, &SheetStruct->m_Size.y ) != 4)
|
||||
|| (Line[0] != 'S' ) )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
|
@ -838,18 +890,19 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
|
|||
LineCount++;
|
||||
if( fgets( Line, 256 - 1, f ) == NULL )
|
||||
return TRUE;
|
||||
if( Line[0] == 'U' ){
|
||||
if( Line[0] == 'U' )
|
||||
{
|
||||
sscanf( Line + 1, "%lX", &(SheetStruct->m_TimeStamp) );
|
||||
if(SheetStruct->m_TimeStamp == 0) //zero is not unique!
|
||||
if( SheetStruct->m_TimeStamp == 0 ) //zero is not unique!
|
||||
SheetStruct->m_TimeStamp = GetTimeStamp();
|
||||
continue;
|
||||
}
|
||||
if( Line[0] != 'F' )
|
||||
break;
|
||||
sscanf( Line + 1, "%d", &fieldref );
|
||||
sscanf( Line + 1, "%d", &fieldNdx );
|
||||
|
||||
/* Lecture du champ :
|
||||
* si fieldref >= 2 : Fn "texte" t s posx posy
|
||||
* si fieldNdx >= 2 : Fn "texte" t s posx posy
|
||||
* sinon F0 "texte" pour sheetname
|
||||
* et F1 "texte" pour filename */
|
||||
|
||||
|
@ -860,7 +913,7 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
|
|||
{
|
||||
MsgDiag.Printf(
|
||||
wxT( " ** EESchema file sheet label F%d at line %d, aborted" ),
|
||||
fieldref, LineCount );
|
||||
fieldNdx, LineCount );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -880,7 +933,7 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
|
|||
}
|
||||
}
|
||||
|
||||
if( ( fieldref == 0 ) || ( fieldref == 1 ) )
|
||||
if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) )
|
||||
{
|
||||
if( sscanf( ptcar, "%d", &size ) != 1 )
|
||||
{
|
||||
|
@ -891,23 +944,26 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
|
|||
}
|
||||
if( size == 0 )
|
||||
size = DEFAULT_SIZE_TEXT;
|
||||
if( fieldref == 0 )
|
||||
if( fieldNdx == 0 )
|
||||
{
|
||||
SheetStruct->m_SheetName = CONV_FROM_UTF8( Name1 );
|
||||
SheetStruct->m_SheetNameSize = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
SheetStruct->SetFileName(CONV_FROM_UTF8( Name1 ));
|
||||
SheetStruct->SetFileName( CONV_FROM_UTF8( Name1 ) );
|
||||
|
||||
//printf("in ReadSheetDescr : SheetStruct->m_FileName = %s \n", Name1);
|
||||
SheetStruct->m_FileNameSize = size;
|
||||
}
|
||||
}
|
||||
|
||||
if( fieldref > 1 )
|
||||
if( fieldNdx > 1 )
|
||||
{
|
||||
SheetLabelStruct = new Hierarchical_PIN_Sheet_Struct( SheetStruct,
|
||||
wxPoint( 0, 0 ), CONV_FROM_UTF8( Name1 ) );
|
||||
wxPoint( 0,
|
||||
0 ), CONV_FROM_UTF8 ( Name1 ) );
|
||||
|
||||
if( SheetStruct->m_Label == NULL )
|
||||
OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct;
|
||||
else
|
||||
|
@ -916,8 +972,8 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
|
|||
|
||||
/* Lecture des coordonnees */
|
||||
if( sscanf( ptcar, "%s %s %d %d %d", Char1, Char2,
|
||||
&SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y,
|
||||
&size ) != 5 )
|
||||
&SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y,
|
||||
&size ) != 5 )
|
||||
{
|
||||
MsgDiag.Printf(
|
||||
wxT(
|
||||
|
@ -963,8 +1019,8 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
|
|||
}
|
||||
if( !Failed )
|
||||
{
|
||||
SheetStruct->Pnext = Window->EEDrawList;
|
||||
Window->EEDrawList = SheetStruct;
|
||||
SheetStruct->Pnext = Window->EEDrawList;
|
||||
Window->EEDrawList = SheetStruct;
|
||||
SheetStruct->m_Parent = Window;
|
||||
}
|
||||
return Failed; /* Fin lecture 1 composant */
|
||||
|
@ -1025,7 +1081,7 @@ static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* W
|
|||
|
||||
if( strnicmp( Line, "Sheet", 2 ) == 0 )
|
||||
sscanf( Line + 5, " %d %d",
|
||||
&Window->m_ScreenNumber, &Window->m_NumberOfScreen );
|
||||
&Window->m_ScreenNumber, &Window->m_NumberOfScreen );
|
||||
|
||||
if( strnicmp( Line, "Title", 2 ) == 0 )
|
||||
{
|
||||
|
|
|
@ -422,19 +422,21 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
|||
|
||||
if( SearchMask & FIELDCMPITEM )
|
||||
{
|
||||
SCH_CMP_FIELD* Field;
|
||||
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];
|
||||
if( (Field->m_Attributs & TEXT_NO_VISIBLE) )
|
||||
SCH_CMP_FIELD* field = DrawLibItem->GetField(i);
|
||||
|
||||
if( field->m_Attributs & TEXT_NO_VISIBLE )
|
||||
continue;
|
||||
if( Field->IsVoid() )
|
||||
|
||||
if( field->IsVoid() )
|
||||
continue;
|
||||
EDA_Rect BoundaryBox = Field->GetBoundaryBox();
|
||||
|
||||
EDA_Rect BoundaryBox = field->GetBoundaryBox();
|
||||
if( BoundaryBox.Inside( x, y ) )
|
||||
{
|
||||
LastSnappedStruct = Field;
|
||||
LastSnappedStruct = field;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -297,9 +297,9 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
|
|||
break; // No component left
|
||||
|
||||
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( "_" ) );
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
|
|||
Line.Replace( wxT( " " ), wxT( "_" ) );
|
||||
fprintf( tmpfile, CONV_TO_UTF8( Line ) );
|
||||
|
||||
Line = Component->m_Field[VALUE].m_Text;
|
||||
Line = Component->GetField( VALUE )->m_Text;
|
||||
Line.Replace( wxT( " " ), wxT( "_" ) );
|
||||
fprintf( tmpfile, "Value=%s\n", CONV_TO_UTF8( Line ) );
|
||||
|
||||
|
@ -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
|
|||
}
|
||||
}
|
||||
|
||||
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( "_" ) );
|
||||
}
|
||||
else
|
||||
|
@ -601,7 +601,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
|
|||
CONV_TO_UTF8( FootprintName ) );
|
||||
fprintf( f, " %s", CONV_TO_UTF8( Line ) );
|
||||
|
||||
Line = Component->m_Field[VALUE].m_Text;
|
||||
Line = Component->GetField( VALUE )->m_Text;
|
||||
Line.Replace( wxT( " " ), wxT( "_" ) );
|
||||
fprintf( f, " %s", CONV_TO_UTF8( Line ) );
|
||||
|
||||
|
@ -968,9 +968,9 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
|
|||
if( Component == NULL )
|
||||
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( "_" ) );
|
||||
}
|
||||
else
|
||||
|
@ -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( msg ) );
|
||||
|
||||
msg = Component->m_Field[VALUE].m_Text;
|
||||
msg = Component->GetField( VALUE )->m_Text;
|
||||
msg.Replace( wxT( " " ), wxT( "_" ) );
|
||||
fprintf( f, " \"%s\"", CONV_TO_UTF8( msg ) );
|
||||
fprintf( f, "\n" );
|
||||
|
|
|
@ -271,7 +271,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
if( !Component->m_Flags )
|
||||
{
|
||||
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 );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST,
|
||||
msg, move_xpm );
|
||||
|
|
|
@ -375,23 +375,23 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem,
|
|||
|
||||
{
|
||||
wxPoint textpos; /* Position des textes */
|
||||
SCH_CMP_FIELD* Field = &DrawLibItem->m_Field[FieldNumber];
|
||||
SCH_CMP_FIELD* field = DrawLibItem->GetField( FieldNumber );
|
||||
int hjustify, vjustify;
|
||||
int orient, color = -1;
|
||||
|
||||
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
|
||||
color = ReturnLayerColor( Field->GetLayer() );
|
||||
color = ReturnLayerColor( field->GetLayer() );
|
||||
|
||||
DrawMode = 0; /* Unused */
|
||||
if( Field->m_Attributs & TEXT_NO_VISIBLE )
|
||||
if( field->m_Attributs & TEXT_NO_VISIBLE )
|
||||
return;
|
||||
if( Field->IsVoid() )
|
||||
if( field->IsVoid() )
|
||||
return;
|
||||
|
||||
/* Calcul de la position des textes, selon orientation du composant */
|
||||
orient = Field->m_Orient;
|
||||
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
|
||||
orient = field->m_Orient;
|
||||
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 = TransformCoordinate( DrawLibItem->m_Transform, textpos ) + DrawLibItem->m_Pos;
|
||||
|
||||
|
@ -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.
|
||||
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,
|
||||
Field->m_Size,
|
||||
field->m_Size,
|
||||
hjustify, vjustify );
|
||||
}
|
||||
else /* We plt the reference, for a multiple parts per package */
|
||||
{
|
||||
/* Adding A, B ... to the reference */
|
||||
wxString Text;
|
||||
Text = Field->m_Text;
|
||||
Text = field->m_Text;
|
||||
Text.Append( 'A' - 1 + DrawLibItem->m_Multi );
|
||||
PlotGraphicText( g_PlotFormat, textpos, color, Text,
|
||||
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,
|
|||
int Unit, int Convert, SCH_COMPONENT * DrawItem = NULL);
|
||||
/* 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 {
|
|||
|
||||
#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.
|
||||
* 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
|
||||
{
|
||||
|
@ -492,7 +493,8 @@ public:
|
|||
int m_CharType; /* normal, bold, italic ... */
|
||||
int m_HJustify, m_VJustify; /* Horiz and Vert Justifications */
|
||||
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_TextDrawingsSize; /* segment count */
|
||||
|
||||
|
@ -503,10 +505,12 @@ public:
|
|||
|
||||
int GetLength() const { return m_Text.Length(); };
|
||||
|
||||
/** Function Pitch()
|
||||
* @return distance between 2 caracteres
|
||||
/**
|
||||
* Function Pitch
|
||||
* @return distance between 2 characters
|
||||
*/
|
||||
int Pitch();
|
||||
|
||||
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||
const wxPoint& offset, int color,
|
||||
int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
|
||||
|
|
Loading…
Reference in New Issue