Commit ff193f18 authored by dickelbeck's avatar dickelbeck

variable number of fields per schematic component

parent 22c50612
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.
*/
......
This diff is collapsed.
......@@ -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 GetField
* returns a field.
* @param aFieldNdx An index into the array of fields
* @return SCH_CMP_FIELD* - the field value or NULL if does not exist
*/
SCH_CMP_FIELD* GetField( int aFieldNdx ) const;
/**
* Function GetFieldValue
* 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 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.
*/
const wxString& GetFieldValue( int aFieldNdx ) const;
void AddField( const SCH_CMP_FIELD& aField );
/**
* Function GetFieldCount
* returns the number of fields in this component.
*/
int GetFieldCount() const { return (int) m_Fields.size(); }
virtual void Draw( WinEDA_DrawPanel* panel,
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());
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;
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->m_Field[ii].m_Text.IsEmpty() )
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.
message.Empty(); // allow the user to remove the value.
/* save old cmp in undo list if not already in edit, or moving ... */
// save old cmp in undo list if not already in edit, or moving ...
if( Cmp->m_Flags == 0 )
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->GetField( 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 )->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->m_Field[FOOTPRINT].m_Orient = Cmp->m_Field[REFERENCE].m_Orient;
Cmp->GetField( FOOTPRINT )->m_Orient = Cmp->GetField( REFERENCE )->m_Orient;
}
TextField->m_Text = message;
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 );
......
This diff is collapsed.
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment