|
|
@ -7,6 +7,7 @@ |
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "trigo.h"
|
|
|
|
|
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
@ -37,12 +38,12 @@ void CreateDummyCmp() |
|
|
|
{ |
|
|
|
DummyCmp = new LIB_COMPONENT( wxEmptyString ); |
|
|
|
|
|
|
|
LIB_RECTANGLE* Square = new LIB_RECTANGLE(DummyCmp); |
|
|
|
LIB_RECTANGLE* Square = new LIB_RECTANGLE( DummyCmp ); |
|
|
|
|
|
|
|
Square->m_Pos = wxPoint( -200, 200 ); |
|
|
|
Square->m_End = wxPoint( 200, -200 ); |
|
|
|
Square->m_Pos = wxPoint( -200, 200 ); |
|
|
|
Square->m_End = wxPoint( 200, -200 ); |
|
|
|
|
|
|
|
LIB_TEXT* Text = new LIB_TEXT(DummyCmp); |
|
|
|
LIB_TEXT* Text = new LIB_TEXT( DummyCmp ); |
|
|
|
|
|
|
|
Text->m_Size.x = Text->m_Size.y = 150; |
|
|
|
Text->m_Text = wxT( "??" ); |
|
|
@ -134,7 +135,7 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) : |
|
|
|
m_Son = NULL; |
|
|
|
|
|
|
|
// Re-parent the fields, which before this had aTemplate as parent
|
|
|
|
for( int i=0; i<GetFieldCount(); ++i ) |
|
|
|
for( int i = 0; i<GetFieldCount(); ++i ) |
|
|
|
{ |
|
|
|
GetField( i )->SetParent( this ); |
|
|
|
} |
|
|
@ -143,8 +144,8 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) : |
|
|
|
|
|
|
|
void SCH_COMPONENT::Init( const wxPoint& pos ) |
|
|
|
{ |
|
|
|
m_Pos = pos; |
|
|
|
m_Multi = 0; // In multi unit chip - which unit to draw.
|
|
|
|
m_Pos = pos; |
|
|
|
m_Multi = 0; // In multi unit chip - which unit to draw.
|
|
|
|
m_Convert = 0; // De Morgan Handling
|
|
|
|
|
|
|
|
// The rotation/mirror transformation matrix. pos normal
|
|
|
@ -182,8 +183,8 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, |
|
|
|
bool DrawPinText ) |
|
|
|
{ |
|
|
|
LIB_COMPONENT* Entry; |
|
|
|
int ii; |
|
|
|
bool dummy = FALSE; |
|
|
|
int ii; |
|
|
|
bool dummy = FALSE; |
|
|
|
|
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); |
|
|
|
|
|
|
@ -329,7 +330,7 @@ const wxString SCH_COMPONENT::GetRef( SCH_SHEET_PATH* sheet ) |
|
|
|
h_ref = tokenizer.GetNextToken(); |
|
|
|
|
|
|
|
/* printf( "GetRef hpath: %s\n",
|
|
|
|
CONV_TO_UTF8( m_PathsAndReferences[ii] ) ); */ |
|
|
|
* CONV_TO_UTF8( m_PathsAndReferences[ii] ) ); */ |
|
|
|
return h_ref; |
|
|
|
} |
|
|
|
} |
|
|
@ -382,8 +383,8 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref ) |
|
|
|
SCH_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 ) ) |
|
|
|
|| ( abs( rf->m_Pos.x - m_Pos.x ) + |
|
|
|
abs( rf->m_Pos.y - m_Pos.y ) > 10000 ) ) |
|
|
|
{ |
|
|
|
// move it to a reasonable position
|
|
|
|
rf->m_Pos = m_Pos; |
|
|
@ -395,32 +396,36 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref ) |
|
|
|
|
|
|
|
// Reinit the m_PrefixString member if needed
|
|
|
|
wxString prefix = ref; |
|
|
|
while( prefix.Last() == '?' or isdigit(prefix.Last()) ) |
|
|
|
while( prefix.Last() == '?' or isdigit( prefix.Last() ) ) |
|
|
|
prefix.RemoveLast(); |
|
|
|
|
|
|
|
if( m_PrefixString != prefix ) |
|
|
|
m_PrefixString = prefix; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** function SetTimeStamp
|
|
|
|
* Change the old time stamp to the new time stamp. |
|
|
|
* the time stamp is also modified in paths |
|
|
|
* @param aNewTimeStamp = new time stamp |
|
|
|
*/ |
|
|
|
void SCH_COMPONENT::SetTimeStamp( long aNewTimeStamp) |
|
|
|
void SCH_COMPONENT::SetTimeStamp( long aNewTimeStamp ) |
|
|
|
{ |
|
|
|
wxString string_timestamp, string_oldtimestamp; |
|
|
|
string_timestamp.Printf(wxT("%8.8X"), aNewTimeStamp); |
|
|
|
string_oldtimestamp.Printf(wxT("%8.8X"), m_TimeStamp); |
|
|
|
|
|
|
|
string_timestamp.Printf( wxT( "%8.8X" ), aNewTimeStamp ); |
|
|
|
string_oldtimestamp.Printf( wxT( "%8.8X" ), m_TimeStamp ); |
|
|
|
m_TimeStamp = aNewTimeStamp; |
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ ) |
|
|
|
{ |
|
|
|
m_PathsAndReferences[ii].Replace( string_oldtimestamp.GetData(), |
|
|
|
string_timestamp.GetData() ); |
|
|
|
} |
|
|
|
string_timestamp.GetData() ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/ |
|
|
|
|
|
|
|
//returns the unit selection, for the given sheet path.
|
|
|
|
/***********************************************************/ |
|
|
|
int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet ) |
|
|
@ -452,6 +457,7 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet ) |
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/ |
|
|
|
|
|
|
|
//Set the unit selection, for the given sheet path.
|
|
|
|
/****************************************************************************/ |
|
|
|
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, |
|
|
@ -508,6 +514,7 @@ SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const |
|
|
|
SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField ) |
|
|
|
{ |
|
|
|
int newNdx = m_Fields.size(); |
|
|
|
|
|
|
|
m_Fields.push_back( aField ); |
|
|
|
return &m_Fields[newNdx]; |
|
|
|
} |
|
|
@ -515,11 +522,12 @@ SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField ) |
|
|
|
|
|
|
|
SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName ) |
|
|
|
{ |
|
|
|
for( unsigned i=0; i<m_Fields.size(); ++i ) |
|
|
|
for( unsigned i = 0; i<m_Fields.size(); ++i ) |
|
|
|
{ |
|
|
|
if( aFieldName == m_Fields[i].m_Name ) |
|
|
|
return &m_Fields[i]; |
|
|
|
} |
|
|
|
|
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
@ -536,6 +544,7 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number ) |
|
|
|
return Entry->GetPin( number, m_Multi, m_Convert ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetBoundaryBox |
|
|
|
* returns the orthogonal, bounding box of this object for display purposes. |
|
|
@ -546,8 +555,8 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number ) |
|
|
|
EDA_Rect SCH_COMPONENT::GetBoundaryBox() const |
|
|
|
{ |
|
|
|
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); |
|
|
|
EDA_Rect BoundaryBox; |
|
|
|
int x0, xm, y0, ym; |
|
|
|
EDA_Rect BoundaryBox; |
|
|
|
int x0, xm, y0, ym; |
|
|
|
|
|
|
|
/* Get the basic Boundary box */ |
|
|
|
if( Entry ) |
|
|
@ -569,10 +578,10 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const |
|
|
|
} |
|
|
|
|
|
|
|
/* Compute the real Boundary box (rotated, mirrored ...)*/ |
|
|
|
int x1 = m_Transform[0][0] * x0 + m_Transform[0][1] * y0; |
|
|
|
int y1 = m_Transform[1][0] * x0 + m_Transform[1][1] * y0; |
|
|
|
int x2 = m_Transform[0][0] * xm + m_Transform[0][1] * ym; |
|
|
|
int y2 = m_Transform[1][0] * xm + m_Transform[1][1] * ym; |
|
|
|
int x1 = m_Transform[0][0] *x0 + m_Transform[0][1] *y0; |
|
|
|
int y1 = m_Transform[1][0] *x0 + m_Transform[1][1] *y0; |
|
|
|
int x2 = m_Transform[0][0] *xm + m_Transform[0][1] *ym; |
|
|
|
int y2 = m_Transform[1][0] *xm + m_Transform[1][1] *ym; |
|
|
|
|
|
|
|
// H and W must be > 0:
|
|
|
|
if( x2 < x1 ) |
|
|
@ -610,14 +619,15 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem ) |
|
|
|
// (after swap(), m_Parent member does not point to the right parent):
|
|
|
|
for( int ii = 0; ii < copyitem->GetFieldCount(); ++ii ) |
|
|
|
{ |
|
|
|
copyitem->GetField(ii)->SetParent( copyitem ); |
|
|
|
copyitem->GetField( ii )->SetParent( copyitem ); |
|
|
|
} |
|
|
|
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ++ii ) |
|
|
|
{ |
|
|
|
GetField(ii)->SetParent( this ); |
|
|
|
GetField( ii )->SetParent( this ); |
|
|
|
} |
|
|
|
|
|
|
|
EXCHG( m_PathsAndReferences, copyitem->m_PathsAndReferences); |
|
|
|
EXCHG( m_PathsAndReferences, copyitem->m_PathsAndReferences ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -625,8 +635,8 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) |
|
|
|
{ |
|
|
|
/* save old text in undo list */ |
|
|
|
if( g_ItemToUndoCopy |
|
|
|
&& ( g_ItemToUndoCopy->Type() == Type() ) |
|
|
|
&& ( ( m_Flags & IS_NEW ) == 0 ) ) |
|
|
|
&& ( g_ItemToUndoCopy->Type() == Type() ) |
|
|
|
&& ( ( m_Flags & IS_NEW ) == 0 ) ) |
|
|
|
{ |
|
|
|
/* restore old values and save new ones */ |
|
|
|
SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); |
|
|
@ -709,6 +719,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheet ) |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/ |
|
|
|
|
|
|
|
/* Compute the new matrix transform for a schematic component
|
|
|
|
* in order to have the requested transform (type_rotate = rot, mirror..) |
|
|
|
* which is applied to the initial transform. |
|
|
@ -732,28 +743,28 @@ void SCH_COMPONENT::SetOrientation( int aOrientation ) |
|
|
|
TempMat[0][0] = TempMat[1][1] = 0; |
|
|
|
TempMat[0][1] = 1; |
|
|
|
TempMat[1][0] = -1; |
|
|
|
Transform = TRUE; |
|
|
|
Transform = TRUE; |
|
|
|
break; |
|
|
|
|
|
|
|
case CMP_ROTATE_COUNTERCLOCKWISE: /* Rotate - */ |
|
|
|
TempMat[0][0] = TempMat[1][1] = 0; |
|
|
|
TempMat[0][1] = -1; |
|
|
|
TempMat[1][0] = 1; |
|
|
|
Transform = TRUE; |
|
|
|
Transform = TRUE; |
|
|
|
break; |
|
|
|
|
|
|
|
case CMP_MIRROR_Y: /* MirrorY */ |
|
|
|
TempMat[0][0] = -1; |
|
|
|
TempMat[1][1] = 1; |
|
|
|
TempMat[0][1] = TempMat[1][0] = 0; |
|
|
|
Transform = TRUE; |
|
|
|
Transform = TRUE; |
|
|
|
break; |
|
|
|
|
|
|
|
case CMP_MIRROR_X: /* MirrorX */ |
|
|
|
TempMat[0][0] = 1; |
|
|
|
TempMat[1][1] = -1; |
|
|
|
TempMat[0][1] = TempMat[1][0] = 0; |
|
|
|
Transform = TRUE; |
|
|
|
Transform = TRUE; |
|
|
|
break; |
|
|
|
|
|
|
|
case CMP_ORIENT_90: |
|
|
@ -832,17 +843,17 @@ void SCH_COMPONENT::SetOrientation( int aOrientation ) |
|
|
|
*/ |
|
|
|
int NewMatrix[2][2]; |
|
|
|
|
|
|
|
NewMatrix[0][0] = m_Transform[0][0] * TempMat[0][0] + |
|
|
|
m_Transform[1][0] * TempMat[0][1]; |
|
|
|
NewMatrix[0][0] = m_Transform[0][0] *TempMat[0][0] + |
|
|
|
m_Transform[1][0] *TempMat[0][1]; |
|
|
|
|
|
|
|
NewMatrix[0][1] = m_Transform[0][1] * TempMat[0][0] + |
|
|
|
m_Transform[1][1] * TempMat[0][1]; |
|
|
|
NewMatrix[0][1] = m_Transform[0][1] *TempMat[0][0] + |
|
|
|
m_Transform[1][1] *TempMat[0][1]; |
|
|
|
|
|
|
|
NewMatrix[1][0] = m_Transform[0][0] * TempMat[1][0] + |
|
|
|
m_Transform[1][0] * TempMat[1][1]; |
|
|
|
NewMatrix[1][0] = m_Transform[0][0] *TempMat[1][0] + |
|
|
|
m_Transform[1][0] *TempMat[1][1]; |
|
|
|
|
|
|
|
NewMatrix[1][1] = m_Transform[0][1] * TempMat[1][0] + |
|
|
|
m_Transform[1][1] * TempMat[1][1]; |
|
|
|
NewMatrix[1][1] = m_Transform[0][1] *TempMat[1][0] + |
|
|
|
m_Transform[1][1] *TempMat[1][1]; |
|
|
|
|
|
|
|
m_Transform[0][0] = NewMatrix[0][0]; |
|
|
|
m_Transform[0][1] = NewMatrix[0][1]; |
|
|
@ -867,19 +878,20 @@ void SCH_COMPONENT::SetOrientation( int aOrientation ) |
|
|
|
*/ |
|
|
|
int SCH_COMPONENT::GetOrientation() |
|
|
|
{ |
|
|
|
int type_rotate = CMP_ORIENT_0; |
|
|
|
int ComponentMatOrient[2][2]; |
|
|
|
int ii; |
|
|
|
int type_rotate = CMP_ORIENT_0; |
|
|
|
int ComponentMatOrient[2][2]; |
|
|
|
int ii; |
|
|
|
|
|
|
|
#define ROTATE_VALUES_COUNT 12
|
|
|
|
|
|
|
|
// list of all possibilities, but only the first 8 are actually used
|
|
|
|
int rotate_value[ROTATE_VALUES_COUNT] = |
|
|
|
{ |
|
|
|
CMP_ORIENT_0, CMP_ORIENT_90, CMP_ORIENT_180, CMP_ORIENT_270, |
|
|
|
CMP_MIRROR_X + CMP_ORIENT_0, CMP_MIRROR_X + CMP_ORIENT_90, |
|
|
|
CMP_ORIENT_0, CMP_ORIENT_90, CMP_ORIENT_180, |
|
|
|
CMP_ORIENT_270, |
|
|
|
CMP_MIRROR_X + CMP_ORIENT_0, CMP_MIRROR_X + CMP_ORIENT_90, |
|
|
|
CMP_MIRROR_X + CMP_ORIENT_180, CMP_MIRROR_X + CMP_ORIENT_270, |
|
|
|
CMP_MIRROR_Y + CMP_ORIENT_0, CMP_MIRROR_Y + CMP_ORIENT_90, |
|
|
|
CMP_MIRROR_Y + CMP_ORIENT_0, CMP_MIRROR_Y + CMP_ORIENT_90, |
|
|
|
CMP_MIRROR_Y + CMP_ORIENT_180, CMP_MIRROR_Y + CMP_ORIENT_270 |
|
|
|
}; |
|
|
|
|
|
|
@ -891,12 +903,12 @@ int SCH_COMPONENT::GetOrientation() |
|
|
|
type_rotate = rotate_value[ii]; |
|
|
|
SetOrientation( type_rotate ); |
|
|
|
if( memcmp( ComponentMatOrient, m_Transform, |
|
|
|
sizeof(ComponentMatOrient) ) == 0 ) |
|
|
|
sizeof(ComponentMatOrient) ) == 0 ) |
|
|
|
return type_rotate; |
|
|
|
} |
|
|
|
|
|
|
|
// Error: orientation not found in list (should not happen)
|
|
|
|
wxMessageBox(wxT("Component orientation matrix internal error") ); |
|
|
|
wxMessageBox( wxT( "Component orientation matrix internal error" ) ); |
|
|
|
memcpy( m_Transform, ComponentMatOrient, sizeof( ComponentMatOrient ) ); |
|
|
|
return CMP_NORMAL; |
|
|
|
} |
|
|
@ -911,13 +923,13 @@ wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& coord ) |
|
|
|
{ |
|
|
|
wxPoint screenpos; |
|
|
|
|
|
|
|
screenpos.x = m_Transform[0][0] * coord.x + m_Transform[0][1] * coord.y; |
|
|
|
screenpos.y = m_Transform[1][0] * coord.x + m_Transform[1][1] * coord.y; |
|
|
|
screenpos.x = m_Transform[0][0] *coord.x + m_Transform[0][1] *coord.y; |
|
|
|
screenpos.y = m_Transform[1][0] *coord.x + m_Transform[1][1] *coord.y; |
|
|
|
return screenpos; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if defined (DEBUG)
|
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Show |
|
|
@ -932,7 +944,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) |
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() |
|
|
|
<< " ref=\"" << CONV_TO_UTF8( ReturnFieldName( 0 ) ) |
|
|
|
<< '"' << " chipName=\"" |
|
|
|
<< CONV_TO_UTF8( m_ChipName ) << '"' << m_Pos |
|
|
|
<< CONV_TO_UTF8( m_ChipName ) << '"' << m_Pos |
|
|
|
<< " layer=\"" << m_Layer |
|
|
|
<< '"' << ">\n"; |
|
|
|
|
|
|
@ -945,7 +957,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) |
|
|
|
{ |
|
|
|
NestedSpace( nestLevel + 1, os ) << "<field" << " name=\"" |
|
|
|
<< CONV_TO_UTF8( ReturnFieldName( i ) ) |
|
|
|
<< '"' << " value=\"" |
|
|
|
<< '"' << " value=\"" |
|
|
|
<< CONV_TO_UTF8( value ) << "\"/>\n"; |
|
|
|
} |
|
|
|
} |
|
|
@ -954,6 +966,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) |
|
|
|
<< ">\n"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
@ -979,15 +992,16 @@ bool SCH_COMPONENT::Save( FILE* f ) const |
|
|
|
strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof( Name1 ) ); |
|
|
|
else |
|
|
|
strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ), |
|
|
|
sizeof( Name1 ) ); |
|
|
|
sizeof( Name1 ) ); |
|
|
|
} |
|
|
|
for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) |
|
|
|
{ |
|
|
|
#if defined(KICAD_GOST)
|
|
|
|
if( Name1[ii] == ' ' ) |
|
|
|
if( Name1[ii] == ' ' ) |
|
|
|
#else
|
|
|
|
if( Name1[ii] <= ' ' ) |
|
|
|
if( Name1[ii] <= ' ' ) |
|
|
|
#endif
|
|
|
|
|
|
|
|
Name1[ii] = '~'; |
|
|
|
} |
|
|
|
|
|
|
@ -996,16 +1010,19 @@ bool SCH_COMPONENT::Save( FILE* f ) const |
|
|
|
strncpy( Name2, CONV_TO_UTF8( m_ChipName ), sizeof( Name2 ) ); |
|
|
|
for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) |
|
|
|
#if defined(KICAD_GOST)
|
|
|
|
|
|
|
|
if( Name2[ii] == ' ' ) |
|
|
|
#else
|
|
|
|
|
|
|
|
if( Name2[ii] <= ' ' ) |
|
|
|
#endif
|
|
|
|
|
|
|
|
Name2[ii] = '~'; |
|
|
|
} |
|
|
|
else |
|
|
|
strncpy( Name2, NULL_STRING, sizeof( Name2 ) ); |
|
|
|
|
|
|
|
if ( fprintf( f, "$Comp\n" ) == EOF ) |
|
|
|
if( fprintf( f, "$Comp\n" ) == EOF ) |
|
|
|
return false; |
|
|
|
|
|
|
|
if( fprintf( f, "L %s %s\n", Name2, Name1 ) == EOF ) |
|
|
@ -1040,15 +1057,15 @@ bool SCH_COMPONENT::Save( FILE* f ) const |
|
|
|
reference_fields = wxStringTokenize( m_PathsAndReferences[ii], |
|
|
|
delimiters ); |
|
|
|
if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n", |
|
|
|
CONV_TO_UTF8( reference_fields[0] ), |
|
|
|
CONV_TO_UTF8( reference_fields[1] ), |
|
|
|
CONV_TO_UTF8( reference_fields[2] ) ) == EOF ) |
|
|
|
CONV_TO_UTF8( reference_fields[0] ), |
|
|
|
CONV_TO_UTF8( reference_fields[1] ), |
|
|
|
CONV_TO_UTF8( reference_fields[2] ) ) == EOF ) |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// update the ugly field index, which I would like to see go away someday soon.
|
|
|
|
for( unsigned i=0; i<m_Fields.size(); ++i ) |
|
|
|
for( unsigned i = 0; i<m_Fields.size(); ++i ) |
|
|
|
{ |
|
|
|
SCH_FIELD* fld = GetField( i ); |
|
|
|
fld->m_FieldId = i; // we don't need field Ids, please be gone.
|
|
|
@ -1056,7 +1073,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const |
|
|
|
|
|
|
|
// Fixed fields:
|
|
|
|
// Save fixed fields which are non blank.
|
|
|
|
for( unsigned i=0; i<MANDATORY_FIELDS; ++i ) |
|
|
|
for( unsigned i = 0; i<MANDATORY_FIELDS; ++i ) |
|
|
|
{ |
|
|
|
SCH_FIELD* fld = GetField( i ); |
|
|
|
if( !fld->m_Text.IsEmpty() ) |
|
|
@ -1071,7 +1088,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const |
|
|
|
// only in the dialog editors. No policy should be enforced here, simply
|
|
|
|
// save all the user defined fields, they are present because a dialog editor
|
|
|
|
// thought they should be. If you disagree, go fix the dialog editors.
|
|
|
|
for( unsigned i=MANDATORY_FIELDS; i<m_Fields.size(); ++i ) |
|
|
|
for( unsigned i = MANDATORY_FIELDS; i<m_Fields.size(); ++i ) |
|
|
|
{ |
|
|
|
SCH_FIELD* fld = GetField( i ); |
|
|
|
if( !fld->Save( f ) ) |
|
|
@ -1111,7 +1128,7 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox() |
|
|
|
// Include BoundingBoxes of fields
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ii++ ) |
|
|
|
{ |
|
|
|
if( ! GetField( ii )->IsVisible() ) |
|
|
|
if( !GetField( ii )->IsVisible() ) |
|
|
|
continue; |
|
|
|
bbox.Merge( GetField( ii )->GetBoundaryBox() ); |
|
|
|
} |
|
|
@ -1138,7 +1155,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) |
|
|
|
frame->ClearMsgPanel(); |
|
|
|
|
|
|
|
frame->AppendMsgPanel( _( "Reference" ), |
|
|
|
GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()), |
|
|
|
GetRef( ( (WinEDA_SchematicFrame*) frame )->GetSheet() ), |
|
|
|
DARKCYAN ); |
|
|
|
|
|
|
|
if( root_component->isPower() ) |
|
|
@ -1149,7 +1166,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) |
|
|
|
|
|
|
|
// Display component reference in library and library
|
|
|
|
frame->AppendMsgPanel( _( "Component" ), m_ChipName, BROWN ); |
|
|
|
if( Entry->isAlias( ) ) |
|
|
|
if( Entry->isAlias() ) |
|
|
|
frame->AppendMsgPanel( _( "Alias of" ), root_component->GetName(), BROWN ); |
|
|
|
frame->AppendMsgPanel( _( "Library" ), Entry->GetLibraryName(), BROWN ); |
|
|
|
|
|
|
@ -1158,13 +1175,15 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) |
|
|
|
frame->AppendMsgPanel( _( "Key words" ), Entry->GetKeyWords(), DARKCYAN ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** virtual function Mirror_Y
|
|
|
|
* mirror item relative to an Y axis |
|
|
|
* @param aYaxis_position = the y axis position |
|
|
|
*/ |
|
|
|
void SCH_COMPONENT::Mirror_Y(int aYaxis_position) |
|
|
|
void SCH_COMPONENT::Mirror_Y( int aYaxis_position ) |
|
|
|
{ |
|
|
|
int dx = m_Pos.x; |
|
|
|
|
|
|
|
SetOrientation( CMP_MIRROR_Y ); |
|
|
|
m_Pos.x -= aYaxis_position; |
|
|
|
NEGATE( m_Pos.x ); |
|
|
@ -1180,15 +1199,58 @@ void SCH_COMPONENT::Mirror_Y(int aYaxis_position) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void * aAuxData ) |
|
|
|
/** virtual function Mirror_X
|
|
|
|
* mirror item relative to an X axis |
|
|
|
* @param aXaxis_position = the x axis position |
|
|
|
*/ |
|
|
|
void SCH_COMPONENT::Mirror_X( int aXaxis_position ) |
|
|
|
{ |
|
|
|
int dy = m_Pos.y; |
|
|
|
|
|
|
|
SetOrientation( CMP_MIRROR_X ); |
|
|
|
m_Pos.y -= aXaxis_position; |
|
|
|
NEGATE( m_Pos.y ); |
|
|
|
m_Pos.y += aXaxis_position; |
|
|
|
dy -= m_Pos.y; // dy,0 is the move vector for this transform
|
|
|
|
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ii++ ) |
|
|
|
{ |
|
|
|
/* move the fields to the new position because the component itself
|
|
|
|
* has moved */ |
|
|
|
GetField( ii )->m_Pos.y -= dy; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SCH_COMPONENT::Rotate( wxPoint rotationPoint ) |
|
|
|
{ |
|
|
|
wxPoint prev = m_Pos; |
|
|
|
|
|
|
|
RotatePoint( &m_Pos, rotationPoint, 900 ); |
|
|
|
|
|
|
|
//SetOrientation( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
|
|
SetOrientation( CMP_ROTATE_CLOCKWISE ); |
|
|
|
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ii++ ) |
|
|
|
{ |
|
|
|
/* move the fields to the new position because the component itself
|
|
|
|
* has moved */ |
|
|
|
GetField( ii )->m_Pos.x -= prev.x - m_Pos.x; |
|
|
|
GetField( ii )->m_Pos.y -= prev.y - m_Pos.y; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData ) |
|
|
|
{ |
|
|
|
// Search reference.
|
|
|
|
// reference is a special field because a part identifier is added
|
|
|
|
// in multi parts per package
|
|
|
|
// the .m_AddExtraText of the field msut be set to add this identifier:
|
|
|
|
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); |
|
|
|
|
|
|
|
if( Entry && Entry->GetPartCount() > 1 ) |
|
|
|
GetField( REFERENCE )->m_AddExtraText = true; |
|
|
|
GetField( REFERENCE )->m_AddExtraText = true; |
|
|
|
else |
|
|
|
GetField( REFERENCE )->m_AddExtraText = false; |
|
|
|
|
|
|
@ -1201,7 +1263,7 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void * aAuxData ) |
|
|
|
if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS ) ) |
|
|
|
return false; |
|
|
|
|
|
|
|
for( size_t i = VALUE+1; i < m_Fields.size(); i++ ) |
|
|
|
for( size_t i = VALUE + 1; i < m_Fields.size(); i++ ) |
|
|
|
{ |
|
|
|
if( GetField( i )->Matches( aSearchData, aAuxData ) ) |
|
|
|
return true; |
|
|
|