2007-05-06 16:03:28 +00:00
|
|
|
|
/***********************************************************************/
|
2008-04-15 19:38:19 +00:00
|
|
|
|
/* component_class.cpp : handle the class SCH_COMPONENT */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
|
#include "class_drawpanel.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "confirm.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "program.h"
|
|
|
|
|
#include "libcmp.h"
|
|
|
|
|
#include "general.h"
|
2007-11-05 07:07:00 +00:00
|
|
|
|
#include "macros.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
#include <wx/arrimpl.cpp>
|
2008-04-15 19:38:19 +00:00
|
|
|
|
#include <wx/tokenzr.h>
|
2008-02-27 19:38:16 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
#include "component_class.h"
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
WX_DEFINE_OBJARRAY( ArrayOfSheetLists );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/* Local variables */
|
|
|
|
|
static EDA_LibComponentStruct* DummyCmp;
|
|
|
|
|
|
|
|
|
|
/* Descr component <DUMMY> used when a component is not found in library,
|
|
|
|
|
* to draw a dummy shape
|
|
|
|
|
* This component is a 400 mils square with the text ??
|
|
|
|
|
* DEF DUMMY U 0 40 Y Y 1 0 N
|
|
|
|
|
* F0 "U" 0 -350 60 H V
|
|
|
|
|
* F1 "DUMMY" 0 350 60 H V
|
|
|
|
|
* DRAW
|
|
|
|
|
* T 0 0 0 150 0 0 0 ??
|
|
|
|
|
* S -200 200 200 -200 0 1 0
|
|
|
|
|
* ENDDRAW
|
|
|
|
|
* ENDDEF
|
|
|
|
|
*/
|
|
|
|
|
void CreateDummyCmp()
|
|
|
|
|
{
|
|
|
|
|
DummyCmp = new EDA_LibComponentStruct( NULL );
|
|
|
|
|
|
|
|
|
|
LibDrawSquare* Square = new LibDrawSquare();
|
|
|
|
|
|
|
|
|
|
Square->m_Pos = wxPoint( -200, 200 );
|
|
|
|
|
Square->m_End = wxPoint( 200, -200 );
|
|
|
|
|
Square->m_Width = 4;
|
|
|
|
|
|
|
|
|
|
LibDrawText* Text = new LibDrawText();
|
|
|
|
|
|
|
|
|
|
Text->m_Size.x = Text->m_Size.y = 150;
|
|
|
|
|
Text->m_Text = wxT( "??" );
|
|
|
|
|
|
|
|
|
|
DummyCmp->m_Drawings = Square;
|
|
|
|
|
Square->SetNext( Text );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
|
* Routine to draw the given part at given position, transformed/mirror as
|
|
|
|
|
* specified, and in the given drawing mode.
|
|
|
|
|
* if Color < 0: Draw in normal color
|
|
|
|
|
* else draw in color = Color
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
/* DrawMode = GrXOR, GrOR ..*/
|
|
|
|
|
void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
|
|
|
|
|
SCH_COMPONENT* Component,
|
|
|
|
|
EDA_LibComponentStruct* Entry,
|
|
|
|
|
const wxPoint& Pos, const int TransMat[2][2],
|
|
|
|
|
int Multi, int convert, int DrawMode,
|
|
|
|
|
int Color, bool DrawPinText )
|
|
|
|
|
{
|
|
|
|
|
wxPoint pos1, pos2;
|
|
|
|
|
bool force_nofill;
|
|
|
|
|
LibEDA_BaseStruct* DEntry;
|
|
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
|
|
|
|
|
|
if( Entry->m_Drawings == NULL )
|
|
|
|
|
return;
|
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
|
|
|
|
|
for( DEntry = Entry->m_Drawings; DEntry != NULL; DEntry = DEntry->Next() )
|
|
|
|
|
{
|
|
|
|
|
/* Do not draw items not attached to the current part */
|
|
|
|
|
if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Do not draw an item while moving (the cursor handler does that)
|
|
|
|
|
if( DEntry->m_Flags & IS_MOVED )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
force_nofill = false;
|
|
|
|
|
|
|
|
|
|
switch( DEntry->Type() )
|
|
|
|
|
{
|
|
|
|
|
case COMPONENT_PIN_DRAW_TYPE:
|
|
|
|
|
{
|
|
|
|
|
DrawPinPrms prms( Entry, DrawPinText );
|
|
|
|
|
DEntry->Draw( panel, DC, Pos, Color, DrawMode, &prms, TransMat );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
|
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
|
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
|
|
|
|
default:
|
|
|
|
|
if( screen->m_IsPrinting
|
|
|
|
|
&& DEntry->m_Fill == FILLED_WITH_BG_BODYCOLOR
|
|
|
|
|
&& GetGRForceBlackPenState() )
|
|
|
|
|
force_nofill = true;
|
|
|
|
|
DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*) force_nofill,
|
|
|
|
|
TransMat );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( g_DebugLevel > 4 ) /* Draw the component boundary box */
|
|
|
|
|
{
|
|
|
|
|
EDA_Rect BoundaryBox;
|
|
|
|
|
if( Component )
|
|
|
|
|
BoundaryBox = Component->GetBoundaryBox();
|
|
|
|
|
else
|
|
|
|
|
BoundaryBox = Entry->GetBoundaryBox( Multi, convert );
|
|
|
|
|
int x1 = BoundaryBox.GetX();
|
|
|
|
|
int y1 = BoundaryBox.GetY();
|
|
|
|
|
int x2 = BoundaryBox.GetRight();
|
|
|
|
|
int y2 = BoundaryBox.GetBottom();
|
|
|
|
|
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
|
|
|
|
|
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->GetField( VALUE )->GetBoundaryBox();
|
|
|
|
|
x1 = BoundaryBox.GetX();
|
|
|
|
|
y1 = BoundaryBox.GetY();
|
|
|
|
|
x2 = BoundaryBox.GetRight();
|
|
|
|
|
y2 = BoundaryBox.GetBottom();
|
|
|
|
|
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
/*******************************************************************/
|
|
|
|
|
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 );
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( int i = 0; i < NUMBER_OF_FIELDS; ++i )
|
2008-10-06 05:44:29 +00:00
|
|
|
|
{
|
2008-10-18 13:42:21 +00:00
|
|
|
|
SCH_CMP_FIELD field( aPos, i, this, ReturnDefaultFieldName( i ) );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
if( i==REFERENCE )
|
|
|
|
|
field.SetLayer( LAYER_REFERENCEPART );
|
|
|
|
|
else if( i==VALUE )
|
|
|
|
|
field.SetLayer( LAYER_VALUEPART );
|
2008-10-18 13:42:21 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
// 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" ) );
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-19 18:31:09 +00:00
|
|
|
|
|
|
|
|
|
SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
|
|
|
|
|
SCH_ITEM( NULL, TYPE_SCH_COMPONENT )
|
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/* assignment of all fields, including field vector elements, and linked
|
|
|
|
|
* list pointers */
|
2008-10-19 18:31:09 +00:00
|
|
|
|
*this = aTemplate;
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/* set linked list pointers to null, before this they were copies of
|
|
|
|
|
* aTemplate's */
|
2008-10-19 18:31:09 +00:00
|
|
|
|
Pback = NULL;
|
|
|
|
|
Pnext = NULL;
|
|
|
|
|
m_Son = NULL;
|
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
// Re-parent the fields, which before this had aTemplate as parent
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( int i=0; i<GetFieldCount(); ++i )
|
2008-10-19 18:31:09 +00:00
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
GetField( i )->SetParent( this );
|
2008-10-19 18:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/*****************************************************************************
|
|
|
|
|
* Routine to draw the given part at given position, transformed/mirror as *
|
|
|
|
|
* specified, and in the given drawing mode. Only this one is visible... *
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|
|
|
|
const wxPoint& offset, int DrawMode, int Color )
|
|
|
|
|
{
|
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
int ii;
|
|
|
|
|
bool dummy = FALSE;
|
|
|
|
|
|
|
|
|
|
if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString,
|
|
|
|
|
FIND_ROOT ) ) == NULL )
|
|
|
|
|
{
|
|
|
|
|
/* composant non trouve, on affiche un composant "dummy" */
|
|
|
|
|
dummy = TRUE;
|
|
|
|
|
if( DummyCmp == NULL )
|
|
|
|
|
CreateDummyCmp();
|
|
|
|
|
Entry = DummyCmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawLibPartAux( panel, DC, this, Entry, m_Pos + offset, m_Transform,
|
|
|
|
|
dummy ? 0 : m_Multi, dummy ? 0 : m_Convert, DrawMode );
|
|
|
|
|
|
|
|
|
|
/* Trace des champs, avec placement et orientation selon orient. du
|
|
|
|
|
* composant
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
SCH_CMP_FIELD* field = GetField( REFERENCE );
|
|
|
|
|
|
|
|
|
|
if( ( ( field->m_Attributs & TEXT_NO_VISIBLE ) == 0 )
|
|
|
|
|
&& !( field->m_Flags & IS_MOVED ) )
|
|
|
|
|
{
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
|
{
|
|
|
|
|
field->m_AddExtraText = true;
|
|
|
|
|
field->Draw( panel, DC, offset, DrawMode );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
field->m_AddExtraText = false;
|
|
|
|
|
field->Draw( panel, DC, offset, DrawMode );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( ii = VALUE; ii < GetFieldCount(); ii++ )
|
|
|
|
|
{
|
|
|
|
|
field = GetField( ii );
|
|
|
|
|
|
|
|
|
|
if( field->m_Flags & IS_MOVED )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
field->Draw( panel, DC, offset, DrawMode );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function AddHierarchicalReference
|
|
|
|
|
* adds a full hierachical reference (path + local reference)
|
2009-04-05 20:49:15 +00:00
|
|
|
|
* @param aPath = hierarchical path (/<sheet timestamp>/component timestamp>
|
|
|
|
|
* like /05678E50/A23EF560)
|
2008-04-16 08:40:31 +00:00
|
|
|
|
* @param aRef = local reference like C45, R56
|
2009-04-05 20:49:15 +00:00
|
|
|
|
* @param aMulti = part selection, used in multi part per package (0 or 1 for
|
|
|
|
|
* non multi)
|
2008-04-12 18:39:20 +00:00
|
|
|
|
*/
|
2008-04-16 08:40:31 +00:00
|
|
|
|
void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath,
|
|
|
|
|
const wxString& aRef,
|
|
|
|
|
int aMulti )
|
2008-04-12 18:39:20 +00:00
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
|
wxString h_path, h_ref;
|
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
|
wxString separators( wxT( " " ) );
|
|
|
|
|
|
|
|
|
|
// Search for an existing path and remove it if found (should not occur)
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-15 19:38:19 +00:00
|
|
|
|
{
|
|
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
if( h_path.Cmp( aPath ) == 0 )
|
2008-04-15 19:38:19 +00:00
|
|
|
|
{
|
2008-04-16 08:40:31 +00:00
|
|
|
|
m_PathsAndReferences.RemoveAt( ii );
|
|
|
|
|
ii--;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
h_ref = aPath + wxT( " " ) + aRef;
|
|
|
|
|
h_ref << wxT( " " ) << aMulti;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
m_PathsAndReferences.Add( h_ref );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/****************************************************************/
|
2008-10-06 05:44:29 +00:00
|
|
|
|
wxString SCH_COMPONENT::ReturnFieldName( int aFieldNdx ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/****************************************************************/
|
|
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
|
SCH_CMP_FIELD* field = GetField( aFieldNdx );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
if( field )
|
|
|
|
|
{
|
|
|
|
|
if( !field->m_Name.IsEmpty() )
|
|
|
|
|
return field->m_Name;
|
|
|
|
|
else
|
|
|
|
|
return ReturnDefaultFieldName( aFieldNdx );
|
|
|
|
|
}
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
return wxEmptyString;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
|
wxString SCH_COMPONENT::GetPath( DrawSheetPath* sheet )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
/****************************************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
|
{
|
2008-02-21 12:21:01 +00:00
|
|
|
|
wxString str;
|
|
|
|
|
|
|
|
|
|
str.Printf( wxT( "%8.8lX" ), m_TimeStamp );
|
|
|
|
|
return sheet->Path() + str;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
|
|
|
|
/********************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
|
const wxString SCH_COMPONENT::GetRef( DrawSheetPath* sheet )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
/********************************************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
|
wxString path = GetPath( sheet );
|
|
|
|
|
wxString h_path, h_ref;
|
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
|
wxString separators( wxT( " " ) );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
if( h_path.Cmp( path ) == 0 )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
|
h_ref = tokenizer.GetNextToken();
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/* printf( "GetRef hpath: %s\n",
|
|
|
|
|
CONV_TO_UTF8( m_PathsAndReferences[ii] ) ); */
|
2008-04-15 19:38:19 +00:00
|
|
|
|
return h_ref;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
// if it was not found in m_Paths array, then see if it is in
|
2008-02-21 12:21:01 +00:00
|
|
|
|
// 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.
|
2008-10-18 13:42:21 +00:00
|
|
|
|
if( !GetField( REFERENCE )->m_Text.IsEmpty() )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
{
|
2008-10-18 13:42:21 +00:00
|
|
|
|
SetRef( sheet, GetField( REFERENCE )->m_Text );
|
|
|
|
|
return GetField( REFERENCE )->m_Text;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
}
|
|
|
|
|
return m_PrefixString;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
2008-04-12 18:39:20 +00:00
|
|
|
|
void SCH_COMPONENT::SetRef( DrawSheetPath* sheet, const wxString& ref )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
/***********************************************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
|
wxString path = GetPath( sheet );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
bool notInArray = true;
|
|
|
|
|
|
|
|
|
|
wxString h_path, h_ref;
|
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
|
wxString separators( wxT( " " ) );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
//check to see if it is already there before inserting it
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
|
h_path = tokenizer.GetNextToken();
|
|
|
|
|
if( h_path.Cmp( path ) == 0 )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
{
|
|
|
|
|
//just update the reference text, not the timestamp.
|
2008-04-15 19:38:19 +00:00
|
|
|
|
h_ref = h_path + wxT( " " ) + ref;
|
|
|
|
|
h_ref += wxT( " " );
|
|
|
|
|
tokenizer.GetNextToken(); // Skip old reference
|
|
|
|
|
h_ref += tokenizer.GetNextToken(); // Add part selection
|
|
|
|
|
// Ann the part selection
|
|
|
|
|
m_PathsAndReferences[ii] = h_ref;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
notInArray = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( notInArray )
|
2008-04-16 08:40:31 +00:00
|
|
|
|
AddHierarchicalReference( path, ref, m_Multi );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
SCH_CMP_FIELD* rf = GetField( REFERENCE );
|
|
|
|
|
|
|
|
|
|
if( rf->m_Text.IsEmpty()
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|| ( abs( rf->m_Pos.x - m_Pos.x ) +
|
|
|
|
|
abs( rf->m_Pos.y - m_Pos.y ) > 10000 ) )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
|
// move it to a reasonable position
|
|
|
|
|
rf->m_Pos = m_Pos;
|
|
|
|
|
rf->m_Pos.x += 50; // a slight offset
|
|
|
|
|
rf->m_Pos.y += 50;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
}
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
rf->m_Text = ref; // for drawing.
|
2008-02-12 21:12:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-04-25 10:12:30 +00:00
|
|
|
|
/** 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)
|
|
|
|
|
{
|
|
|
|
|
wxString string_timestamp, string_oldtimestamp;
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
/***********************************************************/
|
|
|
|
|
//returns the unit selection, for the given sheet path.
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/***********************************************************/
|
|
|
|
|
int SCH_COMPONENT::GetUnitSelection( DrawSheetPath* aSheet )
|
2008-04-16 08:40:31 +00:00
|
|
|
|
{
|
|
|
|
|
wxString path = GetPath( aSheet );
|
|
|
|
|
wxString h_path, h_multi;
|
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
|
wxString separators( wxT( " " ) );
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-16 08:40:31 +00:00
|
|
|
|
{
|
|
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
if( h_path.Cmp( path ) == 0 )
|
|
|
|
|
{
|
|
|
|
|
tokenizer.GetNextToken(); // Skip reference
|
|
|
|
|
h_multi = tokenizer.GetNextToken();
|
|
|
|
|
long imulti = 1;
|
|
|
|
|
h_multi.ToLong( &imulti );
|
|
|
|
|
return imulti;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
// if it was not found in m_Paths array, then use m_Multi.
|
2008-04-16 08:40:31 +00:00
|
|
|
|
// this will happen if we load a version 1 schematic file.
|
|
|
|
|
return m_Multi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/****************************************************************************/
|
2008-04-16 08:40:31 +00:00
|
|
|
|
//Set the unit selection, for the given sheet path.
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/****************************************************************************/
|
|
|
|
|
void SCH_COMPONENT::SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection )
|
2008-04-16 08:40:31 +00:00
|
|
|
|
{
|
|
|
|
|
wxString path = GetPath( aSheet );
|
|
|
|
|
|
|
|
|
|
bool notInArray = true;
|
|
|
|
|
|
|
|
|
|
wxString h_path, h_ref;
|
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
|
wxString separators( wxT( " " ) );
|
|
|
|
|
|
|
|
|
|
//check to see if it is already there before inserting it
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-16 08:40:31 +00:00
|
|
|
|
{
|
|
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
if( h_path.Cmp( path ) == 0 )
|
|
|
|
|
{
|
|
|
|
|
//just update the unit selection.
|
|
|
|
|
h_ref = h_path + wxT( " " );
|
|
|
|
|
h_ref += tokenizer.GetNextToken(); // Add reference
|
|
|
|
|
h_ref += wxT( " " );
|
|
|
|
|
h_ref << aUnitSelection; // Add part selection
|
|
|
|
|
// Ann the part selection
|
|
|
|
|
m_PathsAndReferences[ii] = h_ref;
|
|
|
|
|
notInArray = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( notInArray )
|
|
|
|
|
AddHierarchicalReference( path, m_PrefixString, aUnitSelection );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
SCH_CMP_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
|
const SCH_CMP_FIELD* field;
|
|
|
|
|
|
|
|
|
|
if( (unsigned) aFieldNdx < m_Fields.size() )
|
|
|
|
|
field = &m_Fields[aFieldNdx];
|
|
|
|
|
else
|
|
|
|
|
field = NULL;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
wxASSERT( field );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
// use case to remove const-ness
|
|
|
|
|
return (SCH_CMP_FIELD*) field;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
void SCH_COMPONENT::AddField( const SCH_CMP_FIELD& aField )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
|
m_Fields.push_back( aField );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(),
|
|
|
|
|
wxEmptyString, FIND_ROOT );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
EDA_Rect BoundaryBox;
|
|
|
|
|
int x0, xm, y0, ym;
|
|
|
|
|
|
|
|
|
|
/* Get the basic Boundary box */
|
|
|
|
|
if( Entry )
|
|
|
|
|
{
|
|
|
|
|
BoundaryBox = Entry->GetBoundaryBox( m_Multi, m_Convert );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
x0 = BoundaryBox.GetX();
|
|
|
|
|
xm = BoundaryBox.GetRight();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
// We must reverse Y values, because matrix orientation
|
|
|
|
|
// suppose Y axis normal for the library items coordinates,
|
2008-02-21 12:21:01 +00:00
|
|
|
|
// m_Transform reverse Y values, but BoundaryBox is already reversed!
|
2007-09-20 21:06:49 +00:00
|
|
|
|
y0 = -BoundaryBox.GetY();
|
|
|
|
|
ym = -BoundaryBox.GetBottom();
|
|
|
|
|
}
|
|
|
|
|
else /* if lib Entry not found, give a reasonable size */
|
|
|
|
|
{
|
|
|
|
|
x0 = y0 = -50;
|
|
|
|
|
xm = ym = 50;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
|
// H and W must be > 0:
|
2007-09-20 21:06:49 +00:00
|
|
|
|
if( x2 < x1 )
|
|
|
|
|
EXCHG( x2, x1 );
|
|
|
|
|
if( y2 < y1 )
|
|
|
|
|
EXCHG( y2, y1 );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
BoundaryBox.SetX( x1 );
|
|
|
|
|
BoundaryBox.SetY( y1 );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
BoundaryBox.SetWidth( x2 - x1 );
|
|
|
|
|
BoundaryBox.SetHeight( y2 - y1 );
|
|
|
|
|
|
|
|
|
|
BoundaryBox.Offset( m_Pos );
|
|
|
|
|
return BoundaryBox;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**************************************************************************/
|
|
|
|
|
/* Used if undo / redo command:
|
2007-09-20 21:06:49 +00:00
|
|
|
|
* swap data between this and copyitem
|
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/**************************************************************************/
|
|
|
|
|
void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
|
EXCHG( m_ChipName, copyitem->m_ChipName );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
EXCHG( m_Pos, copyitem->m_Pos );
|
|
|
|
|
EXCHG( m_Multi, copyitem->m_Multi );
|
|
|
|
|
EXCHG( m_Convert, copyitem->m_Convert );
|
|
|
|
|
EXCHG( m_Transform[0][0], copyitem->m_Transform[0][0] );
|
|
|
|
|
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] );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-10-17 18:45:14 +00:00
|
|
|
|
m_Fields.swap( copyitem->m_Fields ); // std::vector's swap()
|
2008-10-18 13:42:21 +00:00
|
|
|
|
|
2008-10-19 10:13:04 +00:00
|
|
|
|
// Reparent items after copying data
|
2008-10-19 18:31:09 +00:00
|
|
|
|
// (after swap(), m_Parent member does not point to the right parent):
|
2008-10-18 13:42:21 +00:00
|
|
|
|
for( int ii = 0; ii < copyitem->GetFieldCount(); ++ii )
|
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
copyitem->GetField(ii)->SetParent( copyitem );
|
2008-10-18 13:42:21 +00:00
|
|
|
|
}
|
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ++ii )
|
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
GetField(ii)->SetParent( this );
|
2008-10-18 13:42:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***********************************************************************/
|
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
/* save old text in undo list */
|
|
|
|
|
if( g_ItemToUndoCopy
|
2009-04-05 20:49:15 +00:00
|
|
|
|
&& ( g_ItemToUndoCopy->Type() == Type() )
|
|
|
|
|
&& ( ( m_Flags & IS_NEW ) == 0 ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
/* restore old values and save new ones */
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
/* save in undo list */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
frame->SaveCopyInUndoList( this, IS_CHANGED );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
/* restore new values */
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
SAFE_DELETE( g_ItemToUndoCopy );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
SCH_ITEM::Place( frame, DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1)
|
|
|
|
|
* @param aSheet: DrawSheetPath value: if NULL remove all annotations,
|
2009-04-05 20:49:15 +00:00
|
|
|
|
* else remove annotation relative to this sheetpath
|
2007-09-20 21:06:49 +00:00
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
|
void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-04-21 06:34:56 +00:00
|
|
|
|
wxString defRef = m_PrefixString;
|
|
|
|
|
bool KeepMulti = false;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
EDA_LibComponentStruct* Entry;
|
2008-04-21 06:34:56 +00:00
|
|
|
|
wxString separators( wxT( " " ) );
|
|
|
|
|
wxArrayString reference_fields;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
|
|
|
|
Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
|
|
|
|
|
if( Entry && Entry->m_UnitSelectionLocked )
|
|
|
|
|
KeepMulti = true;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
|
|
|
|
while( defRef.Last() == '?' )
|
|
|
|
|
defRef.RemoveLast();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
defRef.Append( wxT( "?" ) );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
|
|
|
|
wxString multi = wxT( "1" );
|
2008-09-20 17:20:40 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
// We cannot remove all annotations: part selection must be kept
|
|
|
|
|
if( KeepMulti )
|
2008-02-21 12:21:01 +00:00
|
|
|
|
{
|
2008-05-15 11:20:19 +00:00
|
|
|
|
wxString NewHref;
|
|
|
|
|
wxString path;
|
|
|
|
|
if( aSheet )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
path = GetPath( aSheet );
|
|
|
|
|
for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-21 06:34:56 +00:00
|
|
|
|
{
|
2008-05-15 11:20:19 +00:00
|
|
|
|
// Break hierachical reference in path, ref and multi selection:
|
2009-04-05 20:49:15 +00:00
|
|
|
|
reference_fields = wxStringTokenize( m_PathsAndReferences[ii],
|
|
|
|
|
separators );
|
2008-05-15 11:20:19 +00:00
|
|
|
|
if( aSheet == NULL || reference_fields[0].Cmp( path ) == 0 )
|
|
|
|
|
{
|
|
|
|
|
if( KeepMulti ) // Get and keep part selection
|
|
|
|
|
multi = reference_fields[2];
|
|
|
|
|
NewHref = reference_fields[0];
|
|
|
|
|
NewHref << wxT( " " ) << defRef << wxT( " " ) << multi;
|
|
|
|
|
m_PathsAndReferences[ii] = NewHref;
|
|
|
|
|
}
|
2008-04-21 06:34:56 +00:00
|
|
|
|
}
|
2008-02-21 12:21:01 +00:00
|
|
|
|
}
|
2008-05-15 11:20:19 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
// Empty strings, but does not free memory because a new annotation
|
|
|
|
|
// will reuse it
|
|
|
|
|
m_PathsAndReferences.Empty();
|
2008-05-15 11:20:19 +00:00
|
|
|
|
m_Multi = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
|
// These 2 changes do not work in complex hierarchy.
|
|
|
|
|
// When a clear annotation is made, the calling function must call a
|
|
|
|
|
// UpdateAllScreenReferences for the active sheet.
|
2008-05-15 11:20:19 +00:00
|
|
|
|
// But this call cannot made here.
|
2008-10-06 05:44:29 +00:00
|
|
|
|
m_Fields[REFERENCE].m_Text = defRef; //for drawing.
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************************************/
|
|
|
|
|
/* Compute the new matrix transform for a schematic component
|
2007-09-20 21:06:49 +00:00
|
|
|
|
* in order to have the requested transform (type_rotate = rot, mirror..)
|
|
|
|
|
* which is applied to the initial transform.
|
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/*****************************************************************/
|
|
|
|
|
void SCH_COMPONENT::SetRotationMiroir( int type_rotate )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
int TempMat[2][2];
|
|
|
|
|
bool Transform = FALSE;
|
|
|
|
|
|
|
|
|
|
switch( type_rotate )
|
|
|
|
|
{
|
|
|
|
|
case CMP_ORIENT_0:
|
|
|
|
|
case CMP_NORMAL: /* Position Initiale */
|
|
|
|
|
m_Transform[0][0] = 1;
|
|
|
|
|
m_Transform[1][1] = -1;
|
|
|
|
|
m_Transform[1][0] = m_Transform[0][1] = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CMP_ROTATE_CLOCKWISE: /* Rotate + */
|
|
|
|
|
TempMat[0][0] = TempMat[1][1] = 0;
|
|
|
|
|
TempMat[0][1] = 1;
|
|
|
|
|
TempMat[1][0] = -1;
|
|
|
|
|
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;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CMP_MIROIR_Y: /* MirrorY */
|
|
|
|
|
TempMat[0][0] = -1;
|
|
|
|
|
TempMat[1][1] = 1;
|
|
|
|
|
TempMat[0][1] = TempMat[1][0] = 0;
|
|
|
|
|
Transform = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CMP_MIROIR_X: /* MirrorX */
|
|
|
|
|
TempMat[0][0] = 1;
|
|
|
|
|
TempMat[1][1] = -1;
|
|
|
|
|
TempMat[0][1] = TempMat[1][0] = 0;
|
|
|
|
|
Transform = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CMP_ORIENT_90:
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_0 );
|
|
|
|
|
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CMP_ORIENT_180:
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_0 );
|
|
|
|
|
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
|
|
|
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CMP_ORIENT_270:
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_0 );
|
|
|
|
|
SetRotationMiroir( CMP_ROTATE_CLOCKWISE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (CMP_ORIENT_0 + CMP_MIROIR_X):
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_0 );
|
|
|
|
|
SetRotationMiroir( CMP_MIROIR_X );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (CMP_ORIENT_0 + CMP_MIROIR_Y):
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_0 );
|
|
|
|
|
SetRotationMiroir( CMP_MIROIR_Y );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (CMP_ORIENT_90 + CMP_MIROIR_X):
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_90 );
|
|
|
|
|
SetRotationMiroir( CMP_MIROIR_X );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (CMP_ORIENT_90 + CMP_MIROIR_Y):
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_90 );
|
|
|
|
|
SetRotationMiroir( CMP_MIROIR_Y );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (CMP_ORIENT_180 + CMP_MIROIR_X):
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_180 );
|
|
|
|
|
SetRotationMiroir( CMP_MIROIR_X );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (CMP_ORIENT_180 + CMP_MIROIR_Y):
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_180 );
|
|
|
|
|
SetRotationMiroir( CMP_MIROIR_Y );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (CMP_ORIENT_270 + CMP_MIROIR_X):
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_270 );
|
|
|
|
|
SetRotationMiroir( CMP_MIROIR_X );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (CMP_ORIENT_270 + CMP_MIROIR_Y):
|
|
|
|
|
SetRotationMiroir( CMP_ORIENT_270 );
|
|
|
|
|
SetRotationMiroir( CMP_MIROIR_Y );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
Transform = FALSE;
|
|
|
|
|
DisplayError( NULL, wxT( "SetRotateMiroir() error: ill value" ) );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( Transform )
|
2008-04-12 18:39:20 +00:00
|
|
|
|
{
|
|
|
|
|
/* The new matrix transform is the old matrix transform modified by the
|
2009-04-05 20:49:15 +00:00
|
|
|
|
* requested transformation, which is the TempMat transform (rot,
|
|
|
|
|
* mirror ..) in order to have (in term of matrix transform):
|
2008-04-12 18:39:20 +00:00
|
|
|
|
* transform coord = new_m_Transform * coord
|
2009-04-05 20:49:15 +00:00
|
|
|
|
* where transform coord is the coord modified by new_m_Transform from
|
|
|
|
|
* the initial value coord.
|
|
|
|
|
* new_m_Transform is computed (from old_m_Transform and TempMat) to
|
|
|
|
|
* have:
|
2008-04-12 18:39:20 +00:00
|
|
|
|
* transform coord = old_m_Transform * coord * TempMat
|
|
|
|
|
*/
|
2007-09-20 21:06:49 +00:00
|
|
|
|
int NewMatrix[2][2];
|
|
|
|
|
|
|
|
|
|
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[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];
|
|
|
|
|
|
|
|
|
|
m_Transform[0][0] = NewMatrix[0][0];
|
|
|
|
|
m_Transform[0][1] = NewMatrix[0][1];
|
|
|
|
|
m_Transform[1][0] = NewMatrix[1][0];
|
|
|
|
|
m_Transform[1][1] = NewMatrix[1][1];
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
int SCH_COMPONENT::GetRotationMiroir()
|
2009-04-09 11:34:41 +00:00
|
|
|
|
/** function GetRotationMiroir()
|
|
|
|
|
* Used to display component orientation (in dialog editor or info)
|
|
|
|
|
* @return the orientation and mirror
|
|
|
|
|
* Note: Because there are different ways to have a given orientation/mirror,
|
|
|
|
|
* the orientation/mirror is not necessary wht the used does
|
|
|
|
|
* (example : a mirrorX then a mirrorY give no mirror but rotate the component).
|
|
|
|
|
* So this function find a rotation and a mirror value
|
|
|
|
|
* ( CMP_MIROIR_X because this is the first mirror option tested)
|
|
|
|
|
* but can differs from the orientation made by an user
|
|
|
|
|
* ( a CMP_MIROIR_Y is find as a CMP_MIROIR_X + orientation 180, because they are equivalent)
|
|
|
|
|
*
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
int type_rotate = CMP_ORIENT_0;
|
2009-04-09 11:34:41 +00:00
|
|
|
|
int ComponentMatOrient[2][2];
|
2007-09-20 21:06:49 +00:00
|
|
|
|
int ii;
|
2009-04-17 08:51:02 +00:00
|
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
|
#define ROTATE_VALUES_COUNT 12
|
|
|
|
|
int rotate_value[ROTATE_VALUES_COUNT] = // list of all possibilities, but only the first 8 are actually used
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-04-09 11:34:41 +00:00
|
|
|
|
CMP_ORIENT_0, CMP_ORIENT_90, CMP_ORIENT_180, CMP_ORIENT_270,
|
|
|
|
|
CMP_MIROIR_X + CMP_ORIENT_0, CMP_MIROIR_X + CMP_ORIENT_90, CMP_MIROIR_X + CMP_ORIENT_180, CMP_MIROIR_X + CMP_ORIENT_270,
|
|
|
|
|
CMP_MIROIR_Y + CMP_ORIENT_0, CMP_MIROIR_Y + CMP_ORIENT_90, CMP_MIROIR_Y + CMP_ORIENT_180, CMP_MIROIR_Y + CMP_ORIENT_270
|
|
|
|
|
};
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
|
// Try to find the current transform option:
|
|
|
|
|
memcpy( ComponentMatOrient, m_Transform, sizeof( ComponentMatOrient ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
|
for( ii = 0; ii < ROTATE_VALUES_COUNT; ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-04-09 11:34:41 +00:00
|
|
|
|
type_rotate = rotate_value[ii];
|
|
|
|
|
SetRotationMiroir( type_rotate );
|
|
|
|
|
if( memcmp( ComponentMatOrient, m_Transform, sizeof(ComponentMatOrient) ) == 0 )
|
|
|
|
|
return type_rotate;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
|
// Error: orientation not found in list (should not happen)
|
|
|
|
|
DisplayError(NULL, wxT("Component orientation matrix internal error") );
|
|
|
|
|
memcpy( m_Transform, ComponentMatOrient, sizeof( ComponentMatOrient ) );
|
|
|
|
|
return CMP_NORMAL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/**
|
|
|
|
|
* Renvoie la coordonn<EFBFBD>e du point coord, en fonction de l'orientation
|
2007-09-20 21:06:49 +00:00
|
|
|
|
* du composant (rotation, miroir).
|
2008-04-15 19:38:19 +00:00
|
|
|
|
* Les coord sont toujours relatives a l'ancre (coord 0,0) du composant
|
2007-09-20 21:06:49 +00:00
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
|
wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& coord )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
return screenpos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
#if defined (DEBUG)
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function Show
|
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
2008-02-21 12:21:01 +00:00
|
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
2007-09-20 21:06:49 +00:00
|
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
|
*/
|
2008-03-20 01:50:21 +00:00
|
|
|
|
void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
// for now, make it look like XML:
|
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
|
2009-04-05 20:49:15 +00:00
|
|
|
|
" ref=\"" << ReturnFieldName( 0 ) << '"' << " chipName=\"" <<
|
|
|
|
|
m_ChipName.mb_str() << '"' << m_Pos << " layer=\"" << m_Layer <<
|
|
|
|
|
'"' << "/>\n";
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
|
|
|
|
// skip the reference, it's been output already.
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( int i = 1; i < GetFieldCount(); ++i )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
|
wxString value = GetField( i )->m_Text;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
if( !value.IsEmpty() )
|
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
NestedSpace( nestLevel + 1, os ) << "<field" << " name=\"" <<
|
|
|
|
|
ReturnFieldName( i ).mb_str() << '"' << " value=\"" <<
|
|
|
|
|
value.mb_str() << "\"/>\n";
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
2008-02-21 12:21:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
#endif
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
bool SCH_COMPONENT::Save( FILE* f ) const
|
2008-04-12 18:39:20 +00:00
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
int ii;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
char Name1[256], Name2[256];
|
|
|
|
|
wxArrayString reference_fields;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
static wxString delimiters( wxT( " " ) );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
|
|
|
|
//this is redundant with the AR entries below, but it makes the
|
|
|
|
|
//files backwards-compatible.
|
2008-04-15 19:38:19 +00:00
|
|
|
|
if( m_PathsAndReferences.GetCount() > 0 )
|
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
reference_fields = wxStringTokenize( m_PathsAndReferences[0],
|
|
|
|
|
delimiters );
|
|
|
|
|
strncpy( Name1, CONV_TO_UTF8( reference_fields[1] ), sizeof( Name1 ) );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
}
|
2008-04-12 18:39:20 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2008-10-18 13:42:21 +00:00
|
|
|
|
if( GetField( REFERENCE )->m_Text.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof( Name1 ) );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
else
|
2009-04-05 20:49:15 +00:00
|
|
|
|
strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ),
|
|
|
|
|
sizeof( Name1 ) );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
}
|
|
|
|
|
for( ii = 0; ii < (int) strlen( Name1 ); ii++ )
|
|
|
|
|
{
|
|
|
|
|
if( Name1[ii] <= ' ' )
|
|
|
|
|
Name1[ii] = '~';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !m_ChipName.IsEmpty() )
|
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
strncpy( Name2, CONV_TO_UTF8( m_ChipName ), sizeof( Name2 ) );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
for( ii = 0; ii < (int) strlen( Name2 ); ii++ )
|
|
|
|
|
if( Name2[ii] <= ' ' )
|
|
|
|
|
Name2[ii] = '~';
|
|
|
|
|
}
|
|
|
|
|
else
|
2009-04-05 20:49:15 +00:00
|
|
|
|
strncpy( Name2, NULL_STRING, sizeof( Name2 ) );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
if ( fprintf( f, "$Comp\n" ) == EOF )
|
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
|
|
|
|
if( fprintf( f, "L %s %s\n", Name2, Name1 ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
|
|
|
|
/* Generation de numero d'unit, convert et Time Stamp*/
|
2009-04-05 20:49:15 +00:00
|
|
|
|
if( fprintf( f, "U %d %d %8.8lX\n", m_Multi, m_Convert,
|
|
|
|
|
m_TimeStamp ) == EOF )
|
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
/* Save the position */
|
2008-04-12 18:39:20 +00:00
|
|
|
|
if( fprintf( f, "P %d %d\n", m_Pos.x, m_Pos.y ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
return false;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
|
|
|
|
/* If this is a complex hierarchy; save hierarchical references.
|
2008-04-16 08:40:31 +00:00
|
|
|
|
* but for simple hierarchies it is not necessary.
|
|
|
|
|
* the reference inf is already saved
|
|
|
|
|
* this is usefull for old eeschema version compatibility
|
2008-04-15 19:38:19 +00:00
|
|
|
|
*/
|
|
|
|
|
if( m_PathsAndReferences.GetCount() > 1 )
|
2008-04-12 18:39:20 +00:00
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-12 18:39:20 +00:00
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
|
/*format:
|
|
|
|
|
* AR Path="/140/2" Ref="C99" Part="1"
|
|
|
|
|
* where 140 is the uid of the containing sheet
|
|
|
|
|
* and 2 is the timestamp of this component.
|
|
|
|
|
* (timestamps are actually 8 hex chars)
|
|
|
|
|
* Ref is the conventional component reference for this 'path'
|
|
|
|
|
* Part is the conventional component part selection for this 'path'
|
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
|
reference_fields = wxStringTokenize( m_PathsAndReferences[ii],
|
|
|
|
|
delimiters );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n",
|
2009-04-05 20:49:15 +00:00
|
|
|
|
CONV_TO_UTF8( reference_fields[0] ),
|
|
|
|
|
CONV_TO_UTF8( reference_fields[1] ),
|
|
|
|
|
CONV_TO_UTF8( reference_fields[2] ) ) == EOF )
|
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
for( int fieldNdx = 0; fieldNdx < GetFieldCount(); ++fieldNdx )
|
2008-04-12 18:39:20 +00:00
|
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
|
SCH_CMP_FIELD* field = GetField( fieldNdx );
|
2008-10-18 13:42:21 +00:00
|
|
|
|
wxString defaultName = ReturnDefaultFieldName( fieldNdx );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
// 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 )
|
2008-04-12 18:39:20 +00:00
|
|
|
|
continue;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
if( !field->Save( f ) )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Generation du num unit, position, box ( ancienne norme )*/
|
|
|
|
|
if( fprintf( f, "\t%-4d %-4d %-4d\n", m_Multi, m_Pos.x, m_Pos.y ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
|
|
|
|
if( fprintf( f, "\t%-4d %-4d %-4d %-4d\n",
|
2009-04-05 20:49:15 +00:00
|
|
|
|
m_Transform[0][0], m_Transform[0][1],
|
|
|
|
|
m_Transform[1][0], m_Transform[1][1] ) == EOF )
|
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
if( fprintf( f, "$EndComp\n" ) == EOF )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EDA_Rect SCH_COMPONENT::GetBoundingBox()
|
|
|
|
|
{
|
|
|
|
|
const int PADDING = 40;
|
|
|
|
|
|
2008-09-20 17:20:40 +00:00
|
|
|
|
// This gives a reasonable approximation (but some things are missing so...)
|
|
|
|
|
EDA_Rect bbox = GetBoundaryBox();
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
|
|
|
|
// Include BoundingBoxes of fields
|
2008-10-06 05:44:29 +00:00
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
2008-04-15 19:38:19 +00:00
|
|
|
|
{
|
2008-10-18 13:42:21 +00:00
|
|
|
|
bbox.Merge( GetField( ii )->GetBoundaryBox() );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ... add padding
|
2008-09-20 17:20:40 +00:00
|
|
|
|
bbox.Inflate( PADDING, PADDING );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
2008-09-20 17:20:40 +00:00
|
|
|
|
return bbox;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
|
void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
{
|
|
|
|
|
EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(),
|
|
|
|
|
wxEmptyString, FIND_ROOT );
|
|
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
|
|
frame->MsgPanel->EraseMsgBox();
|
|
|
|
|
|
|
|
|
|
Affiche_1_Parametre( frame, 1, _( "Ref" ),
|
|
|
|
|
GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()),
|
|
|
|
|
DARKCYAN );
|
|
|
|
|
|
|
|
|
|
if( Entry && Entry->m_Options == ENTRY_POWER )
|
|
|
|
|
msg = _( "Pwr Symb" );
|
|
|
|
|
else
|
|
|
|
|
msg = _( "Val" );
|
|
|
|
|
|
|
|
|
|
Affiche_1_Parametre( frame, 10, msg, GetField( VALUE )->m_Text, DARKCYAN );
|
|
|
|
|
|
|
|
|
|
Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN );
|
|
|
|
|
|
|
|
|
|
msg = FindLibName;
|
|
|
|
|
Affiche_1_Parametre( frame, 40, _( "Lib" ), msg, DARKRED );
|
|
|
|
|
|
|
|
|
|
if( Entry )
|
|
|
|
|
{
|
|
|
|
|
Affiche_1_Parametre( frame, 52, Entry->m_Doc, Entry->m_KeyWord,
|
|
|
|
|
DARKCYAN );
|
|
|
|
|
}
|
|
|
|
|
}
|